repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
origin1tech/chek | dist/modules/to.js | toBoolean | function toBoolean(val, def) {
if (is_1.isBoolean(val))
return val;
if (!is_1.isValue(val))
return toDefault(null, def);
val = val.toString();
return (parseFloat(val) > 0 ||
is_1.isInfinite(val) ||
val === 'true' ||
val === 'yes' ||
val === '1' ||
... | javascript | function toBoolean(val, def) {
if (is_1.isBoolean(val))
return val;
if (!is_1.isValue(val))
return toDefault(null, def);
val = val.toString();
return (parseFloat(val) > 0 ||
is_1.isInfinite(val) ||
val === 'true' ||
val === 'yes' ||
val === '1' ||
... | [
"function",
"toBoolean",
"(",
"val",
",",
"def",
")",
"{",
"if",
"(",
"is_1",
".",
"isBoolean",
"(",
"val",
")",
")",
"return",
"val",
";",
"if",
"(",
"!",
"is_1",
".",
"isValue",
"(",
"val",
")",
")",
"return",
"toDefault",
"(",
"null",
",",
"de... | To Boolean
Converts value if not boolean to boolean.
Will convert 'true', '1', 'yes' or '+' to true.
@param val the value to inspect.
@param def optional default value on null. | [
"To",
"Boolean",
"Converts",
"value",
"if",
"not",
"boolean",
"to",
"boolean",
".",
"Will",
"convert",
"true",
"1",
"yes",
"or",
"+",
"to",
"true",
"."
] | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/to.js#L53-L65 | train |
origin1tech/chek | dist/modules/to.js | toDate | function toDate(val, format, def) {
if (is_1.isDate(format)) {
def = format;
format = undefined;
}
var opts = format;
// Date format options a simple timezine
// ex: 'America/Los_Angeles'.
if (is_1.isString(opts)) {
opts = {
timeZone: format
};
}
... | javascript | function toDate(val, format, def) {
if (is_1.isDate(format)) {
def = format;
format = undefined;
}
var opts = format;
// Date format options a simple timezine
// ex: 'America/Los_Angeles'.
if (is_1.isString(opts)) {
opts = {
timeZone: format
};
}
... | [
"function",
"toDate",
"(",
"val",
",",
"format",
",",
"def",
")",
"{",
"if",
"(",
"is_1",
".",
"isDate",
"(",
"format",
")",
")",
"{",
"def",
"=",
"format",
";",
"format",
"=",
"undefined",
";",
"}",
"var",
"opts",
"=",
"format",
";",
"// Date form... | To Date
Converts value to date using Date.parse when string.
Optionally you can pass a format object containing
Intl.DateFormatOptions and locales. You may also pass
the timezone ONLY as a string. In this case locale en-US
is assumed.
@param val the value to be converted to date.
@param format date locale format optio... | [
"To",
"Date",
"Converts",
"value",
"to",
"date",
"using",
"Date",
".",
"parse",
"when",
"string",
".",
"Optionally",
"you",
"can",
"pass",
"a",
"format",
"object",
"containing",
"Intl",
".",
"DateFormatOptions",
"and",
"locales",
".",
"You",
"may",
"also",
... | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/to.js#L79-L117 | train |
origin1tech/chek | dist/modules/to.js | canParse | function canParse() {
return !/^[0-9]+$/.test(val) &&
(is_1.isString(val) && /[0-9]/g.test(val) &&
/(\.|\/|-|:)/g.test(val));
} | javascript | function canParse() {
return !/^[0-9]+$/.test(val) &&
(is_1.isString(val) && /[0-9]/g.test(val) &&
/(\.|\/|-|:)/g.test(val));
} | [
"function",
"canParse",
"(",
")",
"{",
"return",
"!",
"/",
"^[0-9]+$",
"/",
".",
"test",
"(",
"val",
")",
"&&",
"(",
"is_1",
".",
"isString",
"(",
"val",
")",
"&&",
"/",
"[0-9]",
"/",
"g",
".",
"test",
"(",
"val",
")",
"&&",
"/",
"(\\.|\\/|-|:)",... | This just checks loosely if string is date like string, below parse should catch majority of scenarios. | [
"This",
"just",
"checks",
"loosely",
"if",
"string",
"is",
"date",
"like",
"string",
"below",
"parse",
"should",
"catch",
"majority",
"of",
"scenarios",
"."
] | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/to.js#L95-L99 | train |
origin1tech/chek | dist/modules/to.js | toDefault | function toDefault(val, def) {
if (is_1.isValue(val) && !(is_1.isEmpty(val) && !is_1.isEmpty(def)))
return val;
return is_1.isValue(def) ? def : null;
} | javascript | function toDefault(val, def) {
if (is_1.isValue(val) && !(is_1.isEmpty(val) && !is_1.isEmpty(def)))
return val;
return is_1.isValue(def) ? def : null;
} | [
"function",
"toDefault",
"(",
"val",
",",
"def",
")",
"{",
"if",
"(",
"is_1",
".",
"isValue",
"(",
"val",
")",
"&&",
"!",
"(",
"is_1",
".",
"isEmpty",
"(",
"val",
")",
"&&",
"!",
"is_1",
".",
"isEmpty",
"(",
"def",
")",
")",
")",
"return",
"val... | To Default
Returns a default value when provided if
primary value is null or undefined. If neither
then null is returned.
@param val the value to return if defined.
@param def an optional default value to be returned. | [
"To",
"Default",
"Returns",
"a",
"default",
"value",
"when",
"provided",
"if",
"primary",
"value",
"is",
"null",
"or",
"undefined",
".",
"If",
"neither",
"then",
"null",
"is",
"returned",
"."
] | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/to.js#L128-L132 | train |
origin1tech/chek | dist/modules/to.js | toEpoch | function toEpoch(val, def) {
return toDefault((is_1.isDate(val) && val.getTime()), def);
} | javascript | function toEpoch(val, def) {
return toDefault((is_1.isDate(val) && val.getTime()), def);
} | [
"function",
"toEpoch",
"(",
"val",
",",
"def",
")",
"{",
"return",
"toDefault",
"(",
"(",
"is_1",
".",
"isDate",
"(",
"val",
")",
"&&",
"val",
".",
"getTime",
"(",
")",
")",
",",
"def",
")",
";",
"}"
] | To Epoch
Converts a Date type to an epoch.
@param val the date value to convert.
@param def optional default value when null. | [
"To",
"Epoch",
"Converts",
"a",
"Date",
"type",
"to",
"an",
"epoch",
"."
] | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/to.js#L141-L143 | train |
origin1tech/chek | dist/modules/to.js | toFloat | function toFloat(val, def) {
if (is_1.isFloat(val))
return val;
if (!is_1.isValue(val))
return toDefault(null, def);
var parsed = function_1.tryWrap(parseFloat, val)(def);
if (is_1.isFloat(parsed) || is_1.isNumber(parsed))
return parsed;
if (toBoolean(val))
return 1;
... | javascript | function toFloat(val, def) {
if (is_1.isFloat(val))
return val;
if (!is_1.isValue(val))
return toDefault(null, def);
var parsed = function_1.tryWrap(parseFloat, val)(def);
if (is_1.isFloat(parsed) || is_1.isNumber(parsed))
return parsed;
if (toBoolean(val))
return 1;
... | [
"function",
"toFloat",
"(",
"val",
",",
"def",
")",
"{",
"if",
"(",
"is_1",
".",
"isFloat",
"(",
"val",
")",
")",
"return",
"val",
";",
"if",
"(",
"!",
"is_1",
".",
"isValue",
"(",
"val",
")",
")",
"return",
"toDefault",
"(",
"null",
",",
"def",
... | To Float
Converts value to a float.
@param val the value to convert to float. | [
"To",
"Float",
"Converts",
"value",
"to",
"a",
"float",
"."
] | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/to.js#L151-L162 | train |
origin1tech/chek | dist/modules/to.js | toJSON | function toJSON(obj, pretty, def) {
if (is_1.isString(pretty)) {
def = pretty;
pretty = undefined;
}
var tabs = 0;
pretty = is_1.isBoolean(pretty) ? 2 : pretty;
tabs = pretty ? pretty : tabs;
if (!is_1.isObject(obj))
return toDefault(null, def);
return function_1.tryW... | javascript | function toJSON(obj, pretty, def) {
if (is_1.isString(pretty)) {
def = pretty;
pretty = undefined;
}
var tabs = 0;
pretty = is_1.isBoolean(pretty) ? 2 : pretty;
tabs = pretty ? pretty : tabs;
if (!is_1.isObject(obj))
return toDefault(null, def);
return function_1.tryW... | [
"function",
"toJSON",
"(",
"obj",
",",
"pretty",
",",
"def",
")",
"{",
"if",
"(",
"is_1",
".",
"isString",
"(",
"pretty",
")",
")",
"{",
"def",
"=",
"pretty",
";",
"pretty",
"=",
"undefined",
";",
"}",
"var",
"tabs",
"=",
"0",
";",
"pretty",
"=",... | To JSON
Simple wrapper to strinigy using JSON.
@param obj the object to be stringified.
@param pretty an integer or true for tabs in JSON.
@param def optional default value on null. | [
"To",
"JSON",
"Simple",
"wrapper",
"to",
"strinigy",
"using",
"JSON",
"."
] | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/to.js#L172-L183 | train |
origin1tech/chek | dist/modules/to.js | toInteger | function toInteger(val, def) {
if (!is_1.isValue(val))
return toDefault(null, def);
var parsed = function_1.tryWrap(parseInt, val)(def);
if (is_1.isInteger(parsed))
return parsed;
if (toBoolean(val))
return 1;
return 0;
} | javascript | function toInteger(val, def) {
if (!is_1.isValue(val))
return toDefault(null, def);
var parsed = function_1.tryWrap(parseInt, val)(def);
if (is_1.isInteger(parsed))
return parsed;
if (toBoolean(val))
return 1;
return 0;
} | [
"function",
"toInteger",
"(",
"val",
",",
"def",
")",
"{",
"if",
"(",
"!",
"is_1",
".",
"isValue",
"(",
"val",
")",
")",
"return",
"toDefault",
"(",
"null",
",",
"def",
")",
";",
"var",
"parsed",
"=",
"function_1",
".",
"tryWrap",
"(",
"parseInt",
... | To Integer
Convert value to integer.
@param val the value to convert to integer.
@param def optional default value on null or error. | [
"To",
"Integer",
"Convert",
"value",
"to",
"integer",
"."
] | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/to.js#L192-L201 | train |
origin1tech/chek | dist/modules/to.js | toMap | function toMap(val, id, def) {
if (is_1.isValue(id) && !is_1.isString(id)) {
def = id;
id = undefined;
}
if (is_1.isPlainObject(val))
return val;
if (!is_1.isValue(val) || (!is_1.isString(val) && !is_1.isArray(val)))
return toDefault(null, def);
// Default id key.
... | javascript | function toMap(val, id, def) {
if (is_1.isValue(id) && !is_1.isString(id)) {
def = id;
id = undefined;
}
if (is_1.isPlainObject(val))
return val;
if (!is_1.isValue(val) || (!is_1.isString(val) && !is_1.isArray(val)))
return toDefault(null, def);
// Default id key.
... | [
"function",
"toMap",
"(",
"val",
",",
"id",
",",
"def",
")",
"{",
"if",
"(",
"is_1",
".",
"isValue",
"(",
"id",
")",
"&&",
"!",
"is_1",
".",
"isString",
"(",
"id",
")",
")",
"{",
"def",
"=",
"id",
";",
"id",
"=",
"undefined",
";",
"}",
"if",
... | To Map
Converts arrays, strings, to an object literal.
@example
Array: ['one', 'two', 'three'] Maps To: { 0: 'one', 1: 'two', 2: 'three' }
String: 'Star Wars' Maps To: { 0: 'Star Wars' }
String: 'Star Wars, Star Trek' Maps To { 0: 'Star Wars', 1: 'Star Trek' }
Array: [{ id: '123', name: 'Joe' }] Maps To: { 123: { name... | [
"To",
"Map",
"Converts",
"arrays",
"strings",
"to",
"an",
"object",
"literal",
"."
] | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/to.js#L221-L256 | train |
origin1tech/chek | dist/modules/to.js | toNested | function toNested(val, def) {
function nest(src) {
var dest = {};
for (var p in src) {
if (src.hasOwnProperty(p))
if (/\./g.test(p))
object_1.set(dest, p, src[p]);
else
dest[p] = src[p];
}
return dest... | javascript | function toNested(val, def) {
function nest(src) {
var dest = {};
for (var p in src) {
if (src.hasOwnProperty(p))
if (/\./g.test(p))
object_1.set(dest, p, src[p]);
else
dest[p] = src[p];
}
return dest... | [
"function",
"toNested",
"(",
"val",
",",
"def",
")",
"{",
"function",
"nest",
"(",
"src",
")",
"{",
"var",
"dest",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"p",
"in",
"src",
")",
"{",
"if",
"(",
"src",
".",
"hasOwnProperty",
"(",
"p",
")",
")",
... | To Nested
Takes an object that was flattened by toUnnested
and re-nests it.
@param val the flattened object to be nested. | [
"To",
"Nested",
"Takes",
"an",
"object",
"that",
"was",
"flattened",
"by",
"toUnnested",
"and",
"re",
"-",
"nests",
"it",
"."
] | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/to.js#L265-L278 | train |
origin1tech/chek | dist/modules/to.js | toRegExp | function toRegExp(val, def) {
var exp = /^\/.+\/(g|i|m)?([m,i,u,y]{1,4})?/;
var optsExp = /(g|i|m)?([m,i,u,y]{1,4})?$/;
if (is_1.isRegExp(val))
return val;
if (!is_1.isValue(val) || !is_1.isString(val))
return toDefault(null, def);
function regExpFromStr() {
var opts;
... | javascript | function toRegExp(val, def) {
var exp = /^\/.+\/(g|i|m)?([m,i,u,y]{1,4})?/;
var optsExp = /(g|i|m)?([m,i,u,y]{1,4})?$/;
if (is_1.isRegExp(val))
return val;
if (!is_1.isValue(val) || !is_1.isString(val))
return toDefault(null, def);
function regExpFromStr() {
var opts;
... | [
"function",
"toRegExp",
"(",
"val",
",",
"def",
")",
"{",
"var",
"exp",
"=",
"/",
"^\\/.+\\/(g|i|m)?([m,i,u,y]{1,4})?",
"/",
";",
"var",
"optsExp",
"=",
"/",
"(g|i|m)?([m,i,u,y]{1,4})?$",
"/",
";",
"if",
"(",
"is_1",
".",
"isRegExp",
"(",
"val",
")",
")",
... | To Regular Expression
Attempts to convert to a regular expression
from a string.
@param val the value to convert to RegExp.
@param def optional express as default on null. | [
"To",
"Regular",
"Expression",
"Attempts",
"to",
"convert",
"to",
"a",
"regular",
"expression",
"from",
"a",
"string",
"."
] | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/to.js#L299-L315 | train |
origin1tech/chek | dist/modules/to.js | toUnnested | function toUnnested(obj, prefix, def) {
if (is_1.isValue(prefix) && !is_1.isBoolean(prefix)) {
def = prefix;
prefix = undefined;
}
var dupes = 0;
function unnest(src, dest, pre) {
dest = dest || {};
for (var p in src) {
if (dupes > 0)
return;
... | javascript | function toUnnested(obj, prefix, def) {
if (is_1.isValue(prefix) && !is_1.isBoolean(prefix)) {
def = prefix;
prefix = undefined;
}
var dupes = 0;
function unnest(src, dest, pre) {
dest = dest || {};
for (var p in src) {
if (dupes > 0)
return;
... | [
"function",
"toUnnested",
"(",
"obj",
",",
"prefix",
",",
"def",
")",
"{",
"if",
"(",
"is_1",
".",
"isValue",
"(",
"prefix",
")",
"&&",
"!",
"is_1",
".",
"isBoolean",
"(",
"prefix",
")",
")",
"{",
"def",
"=",
"prefix",
";",
"prefix",
"=",
"undefine... | To Unnested
Takes a nested object and flattens it
to a single level safely. To disable key
prefixing set prefix to false.
@param val the object to be unnested.
@param prefix when NOT false parent key is prefixed to children.
@param def optional default value on null. | [
"To",
"Unnested",
"Takes",
"a",
"nested",
"object",
"and",
"flattens",
"it",
"to",
"a",
"single",
"level",
"safely",
".",
"To",
"disable",
"key",
"prefixing",
"set",
"prefix",
"to",
"false",
"."
] | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/to.js#L345-L379 | train |
origin1tech/chek | dist/modules/to.js | toWindow | function toWindow(key, val, exclude) {
/* istanbul ignore if */
if (!is_1.isBrowser())
return;
exclude = toArray(exclude);
var _keys, i;
// key/val was passed.
if (is_1.isString(key)) {
if (!is_1.isPlainObject(val)) {
window[key] = val;
}
else {
... | javascript | function toWindow(key, val, exclude) {
/* istanbul ignore if */
if (!is_1.isBrowser())
return;
exclude = toArray(exclude);
var _keys, i;
// key/val was passed.
if (is_1.isString(key)) {
if (!is_1.isPlainObject(val)) {
window[key] = val;
}
else {
... | [
"function",
"toWindow",
"(",
"key",
",",
"val",
",",
"exclude",
")",
"{",
"/* istanbul ignore if */",
"if",
"(",
"!",
"is_1",
".",
"isBrowser",
"(",
")",
")",
"return",
";",
"exclude",
"=",
"toArray",
"(",
"exclude",
")",
";",
"var",
"_keys",
",",
"i",... | To Window
Adds key to window object if is browser.
@param key the key or object to add to the window object.
@param val the corresponding value to add to window object.
@param exclude string or array of keys to exclude. | [
"To",
"Window",
"Adds",
"key",
"to",
"window",
"object",
"if",
"is",
"browser",
"."
] | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/to.js#L389-L420 | train |
chrisui/Constructr | src/constructr.js | function(child, parent, protoProps, staticProps) {
// Inherit prototype properties from parent
// Set the prototype chain to inherit without calling parent's constructor function.
SharedConstructor.prototype = parent.prototype;
child.prototype = new SharedConstructor();
child.prototype.constructor =... | javascript | function(child, parent, protoProps, staticProps) {
// Inherit prototype properties from parent
// Set the prototype chain to inherit without calling parent's constructor function.
SharedConstructor.prototype = parent.prototype;
child.prototype = new SharedConstructor();
child.prototype.constructor =... | [
"function",
"(",
"child",
",",
"parent",
",",
"protoProps",
",",
"staticProps",
")",
"{",
"// Inherit prototype properties from parent",
"// Set the prototype chain to inherit without calling parent's constructor function.",
"SharedConstructor",
".",
"prototype",
"=",
"parent",
"... | Correctly setup the prototype chain for sub classes while optionally passing
new prototype and static properties to be mixed in with the new child
@return {Constructr} | [
"Correctly",
"setup",
"the",
"prototype",
"chain",
"for",
"sub",
"classes",
"while",
"optionally",
"passing",
"new",
"prototype",
"and",
"static",
"properties",
"to",
"be",
"mixed",
"in",
"with",
"the",
"new",
"child"
] | e970a612acd28ca8e33a755e595823996a5ccd75 | https://github.com/chrisui/Constructr/blob/e970a612acd28ca8e33a755e595823996a5ccd75/src/constructr.js#L49-L70 | train | |
linyngfly/omelo-admin | lib/monitor/monitorAgent.js | function(opts) {
EventEmitter.call(this);
this.reqId = 1;
this.opts = opts;
this.id = opts.id;
this.socket = null;
this.callbacks = {};
this.type = opts.type;
this.info = opts.info;
this.state = ST_INITED;
this.consoleService = opts.consoleService;
} | javascript | function(opts) {
EventEmitter.call(this);
this.reqId = 1;
this.opts = opts;
this.id = opts.id;
this.socket = null;
this.callbacks = {};
this.type = opts.type;
this.info = opts.info;
this.state = ST_INITED;
this.consoleService = opts.consoleService;
} | [
"function",
"(",
"opts",
")",
"{",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"reqId",
"=",
"1",
";",
"this",
".",
"opts",
"=",
"opts",
";",
"this",
".",
"id",
"=",
"opts",
".",
"id",
";",
"this",
".",
"socket",
"=",
"null... | 60 seconds
MonitorAgent Constructor
@class MasterAgent
@constructor
@param {Object} opts construct parameter
opts.consoleService {Object} consoleService
opts.id {String} server id
opts.type {String} server type, 'master', 'connector', etc.
opts.info {Object} more server info for curren... | [
"60",
"seconds",
"MonitorAgent",
"Constructor"
] | 1cd692c16ab63b9c0d4009535f300f2ca584b691 | https://github.com/linyngfly/omelo-admin/blob/1cd692c16ab63b9c0d4009535f300f2ca584b691/lib/monitor/monitorAgent.js#L26-L37 | train | |
savushkin-yauheni/our-connect | lib/proto.js | call | function call(handle, route, err, req, res, next) {
var arity = handle.length;
var hasError = Boolean(err);
debug('%s %s : %s', handle.name || '<anonymous>', route, req.originalUrl);
try {
if (hasError && arity === 4) {
// error-handling middleware
handle(err, req, res, next);
return;
... | javascript | function call(handle, route, err, req, res, next) {
var arity = handle.length;
var hasError = Boolean(err);
debug('%s %s : %s', handle.name || '<anonymous>', route, req.originalUrl);
try {
if (hasError && arity === 4) {
// error-handling middleware
handle(err, req, res, next);
return;
... | [
"function",
"call",
"(",
"handle",
",",
"route",
",",
"err",
",",
"req",
",",
"res",
",",
"next",
")",
"{",
"var",
"arity",
"=",
"handle",
".",
"length",
";",
"var",
"hasError",
"=",
"Boolean",
"(",
"err",
")",
";",
"debug",
"(",
"'%s %s : %s'",
",... | Invoke a route handle.
@api private | [
"Invoke",
"a",
"route",
"handle",
"."
] | aa327a2a87a788535b1e5f6be5503a4419d3aabf | https://github.com/savushkin-yauheni/our-connect/blob/aa327a2a87a788535b1e5f6be5503a4419d3aabf/lib/proto.js#L192-L215 | train |
Becklyn/becklyn-gulp | tasks/jshint.js | lintAllFiles | function lintAllFiles (src, options)
{
glob(src,
function (err, files)
{
if (err) throw err;
for (var i = 0, l = files.length; i < l; i++)
{
jsHintHelper.lintFile(files[i], options.rules);
}
}
);
} | javascript | function lintAllFiles (src, options)
{
glob(src,
function (err, files)
{
if (err) throw err;
for (var i = 0, l = files.length; i < l; i++)
{
jsHintHelper.lintFile(files[i], options.rules);
}
}
);
} | [
"function",
"lintAllFiles",
"(",
"src",
",",
"options",
")",
"{",
"glob",
"(",
"src",
",",
"function",
"(",
"err",
",",
"files",
")",
"{",
"if",
"(",
"err",
")",
"throw",
"err",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"files",
"."... | Lints all files in a given glob
@param {string} src
@param {JsHintTaskOptions} options | [
"Lints",
"all",
"files",
"in",
"a",
"given",
"glob"
] | 1c633378d561f07101f9db19ccd153617b8e0252 | https://github.com/Becklyn/becklyn-gulp/blob/1c633378d561f07101f9db19ccd153617b8e0252/tasks/jshint.js#L25-L38 | train |
jkresner/meanair-server | lib/configure.merge.js | mergeRecursive | function mergeRecursive(key, defaults, app) {
key = key ? key.toUpperCase() : null
if (app === undefined || app == undefine || process.env[key] == undefine)
return undefine
var config = defaults
var atOverrideVal = app === null ? false : atLeaf(app)
var atDefaultVal = defaults === null || atLeaf(defau... | javascript | function mergeRecursive(key, defaults, app) {
key = key ? key.toUpperCase() : null
if (app === undefined || app == undefine || process.env[key] == undefine)
return undefine
var config = defaults
var atOverrideVal = app === null ? false : atLeaf(app)
var atDefaultVal = defaults === null || atLeaf(defau... | [
"function",
"mergeRecursive",
"(",
"key",
",",
"defaults",
",",
"app",
")",
"{",
"key",
"=",
"key",
"?",
"key",
".",
"toUpperCase",
"(",
")",
":",
"null",
"if",
"(",
"app",
"===",
"undefined",
"||",
"app",
"==",
"undefine",
"||",
"process",
".",
"env... | recusiveMerge(
Recursively traverse and merge
String @key to check for environment values to apply
Object @defaults (meanair default base config : configure.defaults.js)
Object @app (application specific sections / exclusions
@return tree (or leaf) of instance of config combining defaults,
app and environm... | [
"recusiveMerge",
"(",
"Recursively",
"traverse",
"and",
"merge"
] | 54acca001b1e185c93992cb64c88478b0289a6e5 | https://github.com/jkresner/meanair-server/blob/54acca001b1e185c93992cb64c88478b0289a6e5/lib/configure.merge.js#L17-L60 | train |
yanatan16/multipart-pipe | index.js | s3streamer | function s3streamer(s3, opts) {
var headers = (opts || {}).headers || { }
return function (file, filename, mimetype, encoding, callback) {
headers['Content-Type'] = mimetype
var buf = Buffer(0)
file.on('data', function (chunk) {
buf = Buffer.concat([buf, chunk])
})
file.on('end', function... | javascript | function s3streamer(s3, opts) {
var headers = (opts || {}).headers || { }
return function (file, filename, mimetype, encoding, callback) {
headers['Content-Type'] = mimetype
var buf = Buffer(0)
file.on('data', function (chunk) {
buf = Buffer.concat([buf, chunk])
})
file.on('end', function... | [
"function",
"s3streamer",
"(",
"s3",
",",
"opts",
")",
"{",
"var",
"headers",
"=",
"(",
"opts",
"||",
"{",
"}",
")",
".",
"headers",
"||",
"{",
"}",
"return",
"function",
"(",
"file",
",",
"filename",
",",
"mimetype",
",",
"encoding",
",",
"callback"... | An s3 streamer | [
"An",
"s3",
"streamer"
] | 676363d98dc04e898206175daa028253ec2f4cb9 | https://github.com/yanatan16/multipart-pipe/blob/676363d98dc04e898206175daa028253ec2f4cb9/index.js#L86-L107 | train |
pattern-library/pattern-library-utilities | lib/gulp-tasks/patterns-import.js | function () {
'use strict';
// default options for angularTemplatecache gulp task
var options = {
config: {
compilePatternsOnImport: false,
dataSource: 'pattern',
dataFileName: 'pattern.yml',
htmlTemplateDest: './source/_patterns',
stylesDest: './source/css/scss',
scriptsD... | javascript | function () {
'use strict';
// default options for angularTemplatecache gulp task
var options = {
config: {
compilePatternsOnImport: false,
dataSource: 'pattern',
dataFileName: 'pattern.yml',
htmlTemplateDest: './source/_patterns',
stylesDest: './source/css/scss',
scriptsD... | [
"function",
"(",
")",
"{",
"'use strict'",
";",
"// default options for angularTemplatecache gulp task",
"var",
"options",
"=",
"{",
"config",
":",
"{",
"compilePatternsOnImport",
":",
"false",
",",
"dataSource",
":",
"'pattern'",
",",
"dataFileName",
":",
"'pattern.y... | Function to get default options for an implementation of patternlab-import
@return {Object} options an object of default patternlab-import options | [
"Function",
"to",
"get",
"default",
"options",
"for",
"an",
"implementation",
"of",
"patternlab",
"-",
"import"
] | a0198f7bb698eb5b859576b11afa3d0ebd3e5911 | https://github.com/pattern-library/pattern-library-utilities/blob/a0198f7bb698eb5b859576b11afa3d0ebd3e5911/lib/gulp-tasks/patterns-import.js#L15-L44 | train | |
sendanor/nor-db | lib/mysql/Pool.js | Pool | function Pool(config) {
if(!(this instanceof Pool)) {
return new Pool(config);
}
var self = this;
if(!config) { throw new TypeError("config not set"); }
self._pool = require('mysql').createPool(config);
self._get_connection = Q.nfbind(self._pool.getConnection.bind(self._pool));
db.Pool.call(this);
} | javascript | function Pool(config) {
if(!(this instanceof Pool)) {
return new Pool(config);
}
var self = this;
if(!config) { throw new TypeError("config not set"); }
self._pool = require('mysql').createPool(config);
self._get_connection = Q.nfbind(self._pool.getConnection.bind(self._pool));
db.Pool.call(this);
} | [
"function",
"Pool",
"(",
"config",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Pool",
")",
")",
"{",
"return",
"new",
"Pool",
"(",
"config",
")",
";",
"}",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"!",
"config",
")",
"{",
"throw",
... | Create MySQL connection pool object | [
"Create",
"MySQL",
"connection",
"pool",
"object"
] | db4b78691956a49370fc9d9a4eed27e7d3720aeb | https://github.com/sendanor/nor-db/blob/db4b78691956a49370fc9d9a4eed27e7d3720aeb/lib/mysql/Pool.js#L11-L20 | train |
Psychopoulet/node-promfs | lib/extends/_filesToString.js | _filesToString | function _filesToString (files, encoding, separator, callback) {
if ("undefined" === typeof files) {
throw new ReferenceError("missing \"files\" argument");
}
else if ("object" !== typeof files || !(files instanceof Array)) {
throw new TypeError("\"files\" argument is not an Array");
}
else i... | javascript | function _filesToString (files, encoding, separator, callback) {
if ("undefined" === typeof files) {
throw new ReferenceError("missing \"files\" argument");
}
else if ("object" !== typeof files || !(files instanceof Array)) {
throw new TypeError("\"files\" argument is not an Array");
}
else i... | [
"function",
"_filesToString",
"(",
"files",
",",
"encoding",
",",
"separator",
",",
"callback",
")",
"{",
"if",
"(",
"\"undefined\"",
"===",
"typeof",
"files",
")",
"{",
"throw",
"new",
"ReferenceError",
"(",
"\"missing \\\"files\\\" argument\"",
")",
";",
"}",
... | methods
Async filesToString
@param {Array} files : files to read
@param {string} encoding : encoding
@param {string} separator : files separator
@param {function|null} callback : operation's result
@returns {void} | [
"methods",
"Async",
"filesToString"
] | 016e272fc58c6ef6eae5ea551a0e8873f0ac20cc | https://github.com/Psychopoulet/node-promfs/blob/016e272fc58c6ef6eae5ea551a0e8873f0ac20cc/lib/extends/_filesToString.js#L25-L84 | train |
fnogatz/tconsole | lib/insert.js | insert | function insert (table, object, fields) {
var input = this
if (input instanceof Array) {
insertArray.call(input, table, object, fields)
} else {
insertObject.call(input, table, object, fields)
}
} | javascript | function insert (table, object, fields) {
var input = this
if (input instanceof Array) {
insertArray.call(input, table, object, fields)
} else {
insertObject.call(input, table, object, fields)
}
} | [
"function",
"insert",
"(",
"table",
",",
"object",
",",
"fields",
")",
"{",
"var",
"input",
"=",
"this",
"if",
"(",
"input",
"instanceof",
"Array",
")",
"{",
"insertArray",
".",
"call",
"(",
"input",
",",
"table",
",",
"object",
",",
"fields",
")",
"... | Default renderer.insert function, `this` bound to the input.
@param {Table} table cli-table
@param {Object} object renderer object
@param {Array} fields fields to show | [
"Default",
"renderer",
".",
"insert",
"function",
"this",
"bound",
"to",
"the",
"input",
"."
] | debcdaf916f7e8f43b35c4c907b585f5c1c69f0f | https://github.com/fnogatz/tconsole/blob/debcdaf916f7e8f43b35c4c907b585f5c1c69f0f/lib/insert.js#L11-L19 | train |
fnogatz/tconsole | lib/insert.js | insertArray | function insertArray (table, object, fields) {
var input = this
input.forEach(function addRow (entry, rowNo) {
var tableRow = fields.map(function cell (fieldName) {
return getCellContent.call(entry, object.fields[fieldName], rowNo)
})
table.push(tableRow)
})
} | javascript | function insertArray (table, object, fields) {
var input = this
input.forEach(function addRow (entry, rowNo) {
var tableRow = fields.map(function cell (fieldName) {
return getCellContent.call(entry, object.fields[fieldName], rowNo)
})
table.push(tableRow)
})
} | [
"function",
"insertArray",
"(",
"table",
",",
"object",
",",
"fields",
")",
"{",
"var",
"input",
"=",
"this",
"input",
".",
"forEach",
"(",
"function",
"addRow",
"(",
"entry",
",",
"rowNo",
")",
"{",
"var",
"tableRow",
"=",
"fields",
".",
"map",
"(",
... | renderer.insert function for rendering arrays,
`this` bound to the input.
@param {Table} table cli-table
@param {Object} object renderer object
@param {Array} fields fields to show | [
"renderer",
".",
"insert",
"function",
"for",
"rendering",
"arrays",
"this",
"bound",
"to",
"the",
"input",
"."
] | debcdaf916f7e8f43b35c4c907b585f5c1c69f0f | https://github.com/fnogatz/tconsole/blob/debcdaf916f7e8f43b35c4c907b585f5c1c69f0f/lib/insert.js#L28-L37 | train |
fnogatz/tconsole | lib/insert.js | insertObject | function insertObject (table, object, fields) {
var input = this
fields.forEach(function addField (field) {
var cells = {}
cells[field] = getCellContent.call(input, object.fields[field])
table.push(cells)
})
} | javascript | function insertObject (table, object, fields) {
var input = this
fields.forEach(function addField (field) {
var cells = {}
cells[field] = getCellContent.call(input, object.fields[field])
table.push(cells)
})
} | [
"function",
"insertObject",
"(",
"table",
",",
"object",
",",
"fields",
")",
"{",
"var",
"input",
"=",
"this",
"fields",
".",
"forEach",
"(",
"function",
"addField",
"(",
"field",
")",
"{",
"var",
"cells",
"=",
"{",
"}",
"cells",
"[",
"field",
"]",
"... | renderer.insert function for rendering objects,
`this` bound to the input.
@param {Table} table cli-table
@param {Object} object renderer object
@param {Array} fields fields to show | [
"renderer",
".",
"insert",
"function",
"for",
"rendering",
"objects",
"this",
"bound",
"to",
"the",
"input",
"."
] | debcdaf916f7e8f43b35c4c907b585f5c1c69f0f | https://github.com/fnogatz/tconsole/blob/debcdaf916f7e8f43b35c4c907b585f5c1c69f0f/lib/insert.js#L46-L54 | train |
fnogatz/tconsole | lib/insert.js | getCellContent | function getCellContent (field) {
var entry = this
var args = Array.prototype.slice.call(arguments, 1)
if (typeof field === 'string') {
return field
}
if (typeof field === 'function') {
var value
try {
value = field.apply(entry, args)
} catch (e) {
value = '(err)'
}
if (va... | javascript | function getCellContent (field) {
var entry = this
var args = Array.prototype.slice.call(arguments, 1)
if (typeof field === 'string') {
return field
}
if (typeof field === 'function') {
var value
try {
value = field.apply(entry, args)
} catch (e) {
value = '(err)'
}
if (va... | [
"function",
"getCellContent",
"(",
"field",
")",
"{",
"var",
"entry",
"=",
"this",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
"if",
"(",
"typeof",
"field",
"===",
"'string'",
")",
"{",
"... | Get the content of a cell. `field` is the function or string
to use. `this` should be bound to the actual entry.
Additional parameters are forwarded to the function `field`.
@param {Function|String} field
@return {String} | [
"Get",
"the",
"content",
"of",
"a",
"cell",
".",
"field",
"is",
"the",
"function",
"or",
"string",
"to",
"use",
".",
"this",
"should",
"be",
"bound",
"to",
"the",
"actual",
"entry",
".",
"Additional",
"parameters",
"are",
"forwarded",
"to",
"the",
"funct... | debcdaf916f7e8f43b35c4c907b585f5c1c69f0f | https://github.com/fnogatz/tconsole/blob/debcdaf916f7e8f43b35c4c907b585f5c1c69f0f/lib/insert.js#L63-L84 | train |
wrote/read | build/index.js | readBuffer | async function readBuffer(path) {
const rs = createReadStream(path)
/** @type {Buffer} */
const res = await collect(rs, { binary: true })
return res
} | javascript | async function readBuffer(path) {
const rs = createReadStream(path)
/** @type {Buffer} */
const res = await collect(rs, { binary: true })
return res
} | [
"async",
"function",
"readBuffer",
"(",
"path",
")",
"{",
"const",
"rs",
"=",
"createReadStream",
"(",
"path",
")",
"/** @type {Buffer} */",
"const",
"res",
"=",
"await",
"collect",
"(",
"rs",
",",
"{",
"binary",
":",
"true",
"}",
")",
"return",
"res",
"... | Read a file as a buffer.
@param {string} path The path to the file to read. | [
"Read",
"a",
"file",
"as",
"a",
"buffer",
"."
] | 503ae9ab03e9654fea77276a076562afff3aeb24 | https://github.com/wrote/read/blob/503ae9ab03e9654fea77276a076562afff3aeb24/build/index.js#L19-L24 | train |
rkamradt/meta-app-mem | index.js | function(data, done) {
this._data.push(this._clone(data));
var ret = this._data.length;
done(null, ret);
} | javascript | function(data, done) {
this._data.push(this._clone(data));
var ret = this._data.length;
done(null, ret);
} | [
"function",
"(",
"data",
",",
"done",
")",
"{",
"this",
".",
"_data",
".",
"push",
"(",
"this",
".",
"_clone",
"(",
"data",
")",
")",
";",
"var",
"ret",
"=",
"this",
".",
"_data",
".",
"length",
";",
"done",
"(",
"null",
",",
"ret",
")",
";",
... | add an item to the store
@param {Object} data The item to store
@param {Function} done The callback when done | [
"add",
"an",
"item",
"to",
"the",
"store"
] | 9602b1eb44fad27cec9a05bcbd652dcf3202dbc7 | https://github.com/rkamradt/meta-app-mem/blob/9602b1eb44fad27cec9a05bcbd652dcf3202dbc7/index.js#L41-L45 | train | |
rkamradt/meta-app-mem | index.js | function(data, done) {
if(!this._key) {
done('no key found for metadata');
return;
}
var key = data[this._key.getName()];
var ix = -1;
for(var i = 0; i < this._data.length; i++) {
if(this._data[i][this._key.getName()] === key) {
ix = i;
break;
... | javascript | function(data, done) {
if(!this._key) {
done('no key found for metadata');
return;
}
var key = data[this._key.getName()];
var ix = -1;
for(var i = 0; i < this._data.length; i++) {
if(this._data[i][this._key.getName()] === key) {
ix = i;
break;
... | [
"function",
"(",
"data",
",",
"done",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_key",
")",
"{",
"done",
"(",
"'no key found for metadata'",
")",
";",
"return",
";",
"}",
"var",
"key",
"=",
"data",
"[",
"this",
".",
"_key",
".",
"getName",
"(",
")",
... | update an item in the store
@param {Object} data The item to update
@param {Function} done The callback when done | [
"update",
"an",
"item",
"in",
"the",
"store"
] | 9602b1eb44fad27cec9a05bcbd652dcf3202dbc7 | https://github.com/rkamradt/meta-app-mem/blob/9602b1eb44fad27cec9a05bcbd652dcf3202dbc7/index.js#L51-L70 | train | |
rkamradt/meta-app-mem | index.js | function(key, done) {
if(!this._key) {
done('no key found for metadata');
return;
}
var ret = null; // if not found return null
for(var i = 0; i < this._data.length; i++) {
if(this._data[i][this._key.getName()] === key) {
ret = this._clone(this._data[i]);
... | javascript | function(key, done) {
if(!this._key) {
done('no key found for metadata');
return;
}
var ret = null; // if not found return null
for(var i = 0; i < this._data.length; i++) {
if(this._data[i][this._key.getName()] === key) {
ret = this._clone(this._data[i]);
... | [
"function",
"(",
"key",
",",
"done",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_key",
")",
"{",
"done",
"(",
"'no key found for metadata'",
")",
";",
"return",
";",
"}",
"var",
"ret",
"=",
"null",
";",
"// if not found return null",
"for",
"(",
"var",
"i... | return an item by id
@param {String} key The key value
@param {Function} done The callback when done | [
"return",
"an",
"item",
"by",
"id"
] | 9602b1eb44fad27cec9a05bcbd652dcf3202dbc7 | https://github.com/rkamradt/meta-app-mem/blob/9602b1eb44fad27cec9a05bcbd652dcf3202dbc7/index.js#L87-L100 | train | |
gethuman/pancakes-recipe | batch/db.purge/db.purge.batch.js | purgeResource | function purgeResource(resource, archive) {
if (!resource.purge) { return true; }
var criteria = resource.purge();
var deferred = Q.defer();
archive.bind(resource.name);
archive[resource.name].remove(criteria, function (err, results) {
err ? deferred.reject(err) : d... | javascript | function purgeResource(resource, archive) {
if (!resource.purge) { return true; }
var criteria = resource.purge();
var deferred = Q.defer();
archive.bind(resource.name);
archive[resource.name].remove(criteria, function (err, results) {
err ? deferred.reject(err) : d... | [
"function",
"purgeResource",
"(",
"resource",
",",
"archive",
")",
"{",
"if",
"(",
"!",
"resource",
".",
"purge",
")",
"{",
"return",
"true",
";",
"}",
"var",
"criteria",
"=",
"resource",
".",
"purge",
"(",
")",
";",
"var",
"deferred",
"=",
"Q",
".",... | Purge one particular resource
@param resource
@param archive | [
"Purge",
"one",
"particular",
"resource"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/batch/db.purge/db.purge.batch.js#L43-L54 | train |
billinghamj/resilient-mailer-mandrill | lib/mandrill-provider.js | MandrillProvider | function MandrillProvider(apiKey, options) {
if (typeof apiKey !== 'string') {
throw new Error('Invalid parameters');
}
options = options || {};
if (typeof options.async === 'undefined')
options.async = false;
if (typeof options.apiSecure === 'undefined')
options.apiSecure = true;
options.apiHostname = ... | javascript | function MandrillProvider(apiKey, options) {
if (typeof apiKey !== 'string') {
throw new Error('Invalid parameters');
}
options = options || {};
if (typeof options.async === 'undefined')
options.async = false;
if (typeof options.apiSecure === 'undefined')
options.apiSecure = true;
options.apiHostname = ... | [
"function",
"MandrillProvider",
"(",
"apiKey",
",",
"options",
")",
"{",
"if",
"(",
"typeof",
"apiKey",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Invalid parameters'",
")",
";",
"}",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"if"... | Creates an instance of the Mandrill email provider.
@constructor
@this {MandrillProvider}
@param {string} apiKey API Key for the Mandrill account.
@param {object} [options] Additional optional configuration.
@param {string} [options.async=false] See 'async' field: {@link https://mandrillapp.com/api/docs/messages.html#... | [
"Creates",
"an",
"instance",
"of",
"the",
"Mandrill",
"email",
"provider",
"."
] | 630e82a8c39d36361c42bde463a40afea993bfb9 | https://github.com/billinghamj/resilient-mailer-mandrill/blob/630e82a8c39d36361c42bde463a40afea993bfb9/lib/mandrill-provider.js#L19-L37 | train |
MarkNijhof/client.express.js | src/client.express.ondomready.js | function (event){
//IE compatibility
event = event || window.event;
//Mozilla, Opera, & Legacy
if(event && event.type && (/DOMContentLoaded|load/).test(event.type)) {
fireDOMReady();
//Legacy
} else if(document.readyState) {
if ((/loaded|complete/).test(doc.readyState)) {
fireDOMReady();
//IE,... | javascript | function (event){
//IE compatibility
event = event || window.event;
//Mozilla, Opera, & Legacy
if(event && event.type && (/DOMContentLoaded|load/).test(event.type)) {
fireDOMReady();
//Legacy
} else if(document.readyState) {
if ((/loaded|complete/).test(doc.readyState)) {
fireDOMReady();
//IE,... | [
"function",
"(",
"event",
")",
"{",
"//IE compatibility",
"event",
"=",
"event",
"||",
"window",
".",
"event",
";",
"//Mozilla, Opera, & Legacy",
"if",
"(",
"event",
"&&",
"event",
".",
"type",
"&&",
"(",
"/",
"DOMContentLoaded|load",
"/",
")",
".",
"test",
... | Responsible for handling events and each tick of the interval | [
"Responsible",
"for",
"handling",
"events",
"and",
"each",
"tick",
"of",
"the",
"interval"
] | 8737f5885014e80f89a5e14cbeed6658e21d1f33 | https://github.com/MarkNijhof/client.express.js/blob/8737f5885014e80f89a5e14cbeed6658e21d1f33/src/client.express.ondomready.js#L12-L33 | train | |
MarkNijhof/client.express.js | src/client.express.ondomready.js | function() {
if (!ready) {
ready = true;
//Call the stack of onload functions in given context or window object
for (var i=0, len=stack.length; i < len; i++) {
stack[i][0].call(stack[i][1]);
}
//Clean up after the DOM is ready
if (document.removeEventListener) {
document.removeEventListener... | javascript | function() {
if (!ready) {
ready = true;
//Call the stack of onload functions in given context or window object
for (var i=0, len=stack.length; i < len; i++) {
stack[i][0].call(stack[i][1]);
}
//Clean up after the DOM is ready
if (document.removeEventListener) {
document.removeEventListener... | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"ready",
")",
"{",
"ready",
"=",
"true",
";",
"//Call the stack of onload functions in given context or window object",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"stack",
".",
"length",
";",
"i",
"<",
"le... | Fires all the functions and cleans up memory | [
"Fires",
"all",
"the",
"functions",
"and",
"cleans",
"up",
"memory"
] | 8737f5885014e80f89a5e14cbeed6658e21d1f33 | https://github.com/MarkNijhof/client.express.js/blob/8737f5885014e80f89a5e14cbeed6658e21d1f33/src/client.express.ondomready.js#L36-L52 | train | |
vkiding/judpack-lib | src/hooks/HooksRunner.js | runScript | function runScript(script, context) {
if (typeof script.useModuleLoader == 'undefined') {
// if it is not explicitly defined whether we should use modeule loader or not
// we assume we should use module loader for .js files
script.useModuleLoader = path.extname(script.path).toLowerCase() == ... | javascript | function runScript(script, context) {
if (typeof script.useModuleLoader == 'undefined') {
// if it is not explicitly defined whether we should use modeule loader or not
// we assume we should use module loader for .js files
script.useModuleLoader = path.extname(script.path).toLowerCase() == ... | [
"function",
"runScript",
"(",
"script",
",",
"context",
")",
"{",
"if",
"(",
"typeof",
"script",
".",
"useModuleLoader",
"==",
"'undefined'",
")",
"{",
"// if it is not explicitly defined whether we should use modeule loader or not",
"// we assume we should use module loader fo... | Async runs single script file. | [
"Async",
"runs",
"single",
"script",
"file",
"."
] | 8657cecfec68221109279106adca8dbc81f430f4 | https://github.com/vkiding/judpack-lib/blob/8657cecfec68221109279106adca8dbc81f430f4/src/hooks/HooksRunner.js#L141-L169 | train |
vkiding/judpack-lib | src/hooks/HooksRunner.js | runScriptViaModuleLoader | function runScriptViaModuleLoader(script, context) {
if(!fs.existsSync(script.fullPath)) {
events.emit('warn', 'Script file does\'t exist and will be skipped: ' + script.fullPath);
return Q();
}
var scriptFn = require(script.fullPath);
context.scriptLocation = script.fullPath;
contex... | javascript | function runScriptViaModuleLoader(script, context) {
if(!fs.existsSync(script.fullPath)) {
events.emit('warn', 'Script file does\'t exist and will be skipped: ' + script.fullPath);
return Q();
}
var scriptFn = require(script.fullPath);
context.scriptLocation = script.fullPath;
contex... | [
"function",
"runScriptViaModuleLoader",
"(",
"script",
",",
"context",
")",
"{",
"if",
"(",
"!",
"fs",
".",
"existsSync",
"(",
"script",
".",
"fullPath",
")",
")",
"{",
"events",
".",
"emit",
"(",
"'warn'",
",",
"'Script file does\\'t exist and will be skipped: ... | Runs script using require.
Returns a promise. | [
"Runs",
"script",
"using",
"require",
".",
"Returns",
"a",
"promise",
"."
] | 8657cecfec68221109279106adca8dbc81f430f4 | https://github.com/vkiding/judpack-lib/blob/8657cecfec68221109279106adca8dbc81f430f4/src/hooks/HooksRunner.js#L174-L191 | train |
vkiding/judpack-lib | src/hooks/HooksRunner.js | runScriptViaChildProcessSpawn | function runScriptViaChildProcessSpawn(script, context) {
var opts = context.opts;
var command = script.fullPath;
var args = [opts.projectRoot];
if (fs.statSync(script.fullPath).isDirectory()) {
events.emit('verbose', 'Skipped directory "' + script.fullPath + '" within hook directory');
... | javascript | function runScriptViaChildProcessSpawn(script, context) {
var opts = context.opts;
var command = script.fullPath;
var args = [opts.projectRoot];
if (fs.statSync(script.fullPath).isDirectory()) {
events.emit('verbose', 'Skipped directory "' + script.fullPath + '" within hook directory');
... | [
"function",
"runScriptViaChildProcessSpawn",
"(",
"script",
",",
"context",
")",
"{",
"var",
"opts",
"=",
"context",
".",
"opts",
";",
"var",
"command",
"=",
"script",
".",
"fullPath",
";",
"var",
"args",
"=",
"[",
"opts",
".",
"projectRoot",
"]",
";",
"... | Runs script using child_process spawn method.
Returns a promise. | [
"Runs",
"script",
"using",
"child_process",
"spawn",
"method",
".",
"Returns",
"a",
"promise",
"."
] | 8657cecfec68221109279106adca8dbc81f430f4 | https://github.com/vkiding/judpack-lib/blob/8657cecfec68221109279106adca8dbc81f430f4/src/hooks/HooksRunner.js#L196-L233 | train |
vkiding/judpack-lib | src/hooks/HooksRunner.js | extractSheBangInterpreter | function extractSheBangInterpreter(fullpath) {
var fileChunk;
var octetsRead;
var fileData;
var hookFd = fs.openSync(fullpath, 'r');
try {
// this is a modern cluster size. no need to read less
fileData = new Buffer(4096);
octetsRead = fs.readSync(hookFd, fileData, 0, 4096, 0... | javascript | function extractSheBangInterpreter(fullpath) {
var fileChunk;
var octetsRead;
var fileData;
var hookFd = fs.openSync(fullpath, 'r');
try {
// this is a modern cluster size. no need to read less
fileData = new Buffer(4096);
octetsRead = fs.readSync(hookFd, fileData, 0, 4096, 0... | [
"function",
"extractSheBangInterpreter",
"(",
"fullpath",
")",
"{",
"var",
"fileChunk",
";",
"var",
"octetsRead",
";",
"var",
"fileData",
";",
"var",
"hookFd",
"=",
"fs",
".",
"openSync",
"(",
"fullpath",
",",
"'r'",
")",
";",
"try",
"{",
"// this is a moder... | Extracts shebang interpreter from script' source. | [
"Extracts",
"shebang",
"interpreter",
"from",
"script",
"source",
"."
] | 8657cecfec68221109279106adca8dbc81f430f4 | https://github.com/vkiding/judpack-lib/blob/8657cecfec68221109279106adca8dbc81f430f4/src/hooks/HooksRunner.js#L237-L264 | train |
nbrownus/ppunit | lib/PPUnit.js | function (options) {
var self = this
PPUnit.super_.call(self)
options = options || {}
self.concurrency = options.concurrency || -1
self.rootSuite = new Suite(undefined)
self.rootSuite.timeout(2000)
self.rootSuite.globallyExclusive()
self.rootSuite.locallyExclusiveTests()
self.all... | javascript | function (options) {
var self = this
PPUnit.super_.call(self)
options = options || {}
self.concurrency = options.concurrency || -1
self.rootSuite = new Suite(undefined)
self.rootSuite.timeout(2000)
self.rootSuite.globallyExclusive()
self.rootSuite.locallyExclusiveTests()
self.all... | [
"function",
"(",
"options",
")",
"{",
"var",
"self",
"=",
"this",
"PPUnit",
".",
"super_",
".",
"call",
"(",
"self",
")",
"options",
"=",
"options",
"||",
"{",
"}",
"self",
".",
"concurrency",
"=",
"options",
".",
"concurrency",
"||",
"-",
"1",
"self... | Creates a new PPUnit object
@constructor | [
"Creates",
"a",
"new",
"PPUnit",
"object"
] | dcce602497d9548ce9085a8db115e65561dcc3de | https://github.com/nbrownus/ppunit/blob/dcce602497d9548ce9085a8db115e65561dcc3de/lib/PPUnit.js#L14-L53 | train | |
deftly/node-deftly | src/log.js | addAdapter | function addAdapter (state, name, config, logger) {
if (_.isFunction(name)) {
logger = name
name = logger.name
config = config || {}
} else if (_.isFunction(config)) {
logger = config
if (_.isObject(name)) {
config = name
name = logger.name
} else {
config = {}
}
} el... | javascript | function addAdapter (state, name, config, logger) {
if (_.isFunction(name)) {
logger = name
name = logger.name
config = config || {}
} else if (_.isFunction(config)) {
logger = config
if (_.isObject(name)) {
config = name
name = logger.name
} else {
config = {}
}
} el... | [
"function",
"addAdapter",
"(",
"state",
",",
"name",
",",
"config",
",",
"logger",
")",
"{",
"if",
"(",
"_",
".",
"isFunction",
"(",
"name",
")",
")",
"{",
"logger",
"=",
"name",
"name",
"=",
"logger",
".",
"name",
"config",
"=",
"config",
"||",
"{... | normalizes arguments for logger creation from a user supplied object or function | [
"normalizes",
"arguments",
"for",
"logger",
"creation",
"from",
"a",
"user",
"supplied",
"object",
"or",
"function"
] | 0c34205fd6726356b69bcdd6dec4fcba55027af6 | https://github.com/deftly/node-deftly/blob/0c34205fd6726356b69bcdd6dec4fcba55027af6/src/log.js#L27-L49 | train |
deftly/node-deftly | src/log.js | addFilter | function addFilter (config, filter) {
if (filter) {
if (filter[ 0 ] === '-') {
config.filters.ignore[ filter ] = new RegExp('^' + filter.slice(1).replace(/[*]/g, '.*?') + '$')
} else {
config.filters.should[ filter ] = new RegExp('^' + filter.replace(/[*]/g, '.*?') + '$')
}
}
} | javascript | function addFilter (config, filter) {
if (filter) {
if (filter[ 0 ] === '-') {
config.filters.ignore[ filter ] = new RegExp('^' + filter.slice(1).replace(/[*]/g, '.*?') + '$')
} else {
config.filters.should[ filter ] = new RegExp('^' + filter.replace(/[*]/g, '.*?') + '$')
}
}
} | [
"function",
"addFilter",
"(",
"config",
",",
"filter",
")",
"{",
"if",
"(",
"filter",
")",
"{",
"if",
"(",
"filter",
"[",
"0",
"]",
"===",
"'-'",
")",
"{",
"config",
".",
"filters",
".",
"ignore",
"[",
"filter",
"]",
"=",
"new",
"RegExp",
"(",
"'... | add the regex filter to the right hash for use later | [
"add",
"the",
"regex",
"filter",
"to",
"the",
"right",
"hash",
"for",
"use",
"later"
] | 0c34205fd6726356b69bcdd6dec4fcba55027af6 | https://github.com/deftly/node-deftly/blob/0c34205fd6726356b69bcdd6dec4fcba55027af6/src/log.js#L52-L60 | train |
deftly/node-deftly | src/log.js | addLogger | function addLogger (state, name, config, adapter) {
config = Object.assign({}, defaultConfig, config)
setFilters(config)
const logger = {
name: name,
config: config,
adapter: adapter,
addFilter: addFilter.bind(null, config),
removeFilter: removeFilter.bind(null, config),
setFilter: setFilt... | javascript | function addLogger (state, name, config, adapter) {
config = Object.assign({}, defaultConfig, config)
setFilters(config)
const logger = {
name: name,
config: config,
adapter: adapter,
addFilter: addFilter.bind(null, config),
removeFilter: removeFilter.bind(null, config),
setFilter: setFilt... | [
"function",
"addLogger",
"(",
"state",
",",
"name",
",",
"config",
",",
"adapter",
")",
"{",
"config",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"defaultConfig",
",",
"config",
")",
"setFilters",
"(",
"config",
")",
"const",
"logger",
"=",
"{",... | creates a logger from a user supplied adapter | [
"creates",
"a",
"logger",
"from",
"a",
"user",
"supplied",
"adapter"
] | 0c34205fd6726356b69bcdd6dec4fcba55027af6 | https://github.com/deftly/node-deftly/blob/0c34205fd6726356b69bcdd6dec4fcba55027af6/src/log.js#L63-L80 | train |
deftly/node-deftly | src/log.js | attach | function attach (state, logger, namespace) {
_.each(levels, function (level, name) {
logger[ name ] = prepMessage.bind(null, state, name, namespace)
})
} | javascript | function attach (state, logger, namespace) {
_.each(levels, function (level, name) {
logger[ name ] = prepMessage.bind(null, state, name, namespace)
})
} | [
"function",
"attach",
"(",
"state",
",",
"logger",
",",
"namespace",
")",
"{",
"_",
".",
"each",
"(",
"levels",
",",
"function",
"(",
"level",
",",
"name",
")",
"{",
"logger",
"[",
"name",
"]",
"=",
"prepMessage",
".",
"bind",
"(",
"null",
",",
"st... | create a bound prepMessage call for each log level | [
"create",
"a",
"bound",
"prepMessage",
"call",
"for",
"each",
"log",
"level"
] | 0c34205fd6726356b69bcdd6dec4fcba55027af6 | https://github.com/deftly/node-deftly/blob/0c34205fd6726356b69bcdd6dec4fcba55027af6/src/log.js#L83-L87 | train |
deftly/node-deftly | src/log.js | init | function init (state, namespace) {
namespace = namespace || 'deftly'
const logger = { namespace: namespace }
attach(state, logger, namespace)
return logger
} | javascript | function init (state, namespace) {
namespace = namespace || 'deftly'
const logger = { namespace: namespace }
attach(state, logger, namespace)
return logger
} | [
"function",
"init",
"(",
"state",
",",
"namespace",
")",
"{",
"namespace",
"=",
"namespace",
"||",
"'deftly'",
"const",
"logger",
"=",
"{",
"namespace",
":",
"namespace",
"}",
"attach",
"(",
"state",
",",
"logger",
",",
"namespace",
")",
"return",
"logger"... | create a namespaced log instance for use in modules | [
"create",
"a",
"namespaced",
"log",
"instance",
"for",
"use",
"in",
"modules"
] | 0c34205fd6726356b69bcdd6dec4fcba55027af6 | https://github.com/deftly/node-deftly/blob/0c34205fd6726356b69bcdd6dec4fcba55027af6/src/log.js#L90-L95 | train |
deftly/node-deftly | src/log.js | log | function log (state, type, namespace, message) {
const level = levels[ type ]
_.each(state.loggers, function (logger) {
logger.log({
type: type,
level: level,
namespace: namespace,
message: message
})
})
} | javascript | function log (state, type, namespace, message) {
const level = levels[ type ]
_.each(state.loggers, function (logger) {
logger.log({
type: type,
level: level,
namespace: namespace,
message: message
})
})
} | [
"function",
"log",
"(",
"state",
",",
"type",
",",
"namespace",
",",
"message",
")",
"{",
"const",
"level",
"=",
"levels",
"[",
"type",
"]",
"_",
".",
"each",
"(",
"state",
".",
"loggers",
",",
"function",
"(",
"logger",
")",
"{",
"logger",
".",
"l... | calls log for each logger | [
"calls",
"log",
"for",
"each",
"logger"
] | 0c34205fd6726356b69bcdd6dec4fcba55027af6 | https://github.com/deftly/node-deftly/blob/0c34205fd6726356b69bcdd6dec4fcba55027af6/src/log.js#L98-L108 | train |
deftly/node-deftly | src/log.js | prepMessage | function prepMessage (state, level, namespace, message) {
if (_.isString(message)) {
const formatArgs = Array.prototype.slice.call(arguments, 3)
message = format.apply(null, formatArgs)
}
log(state, level, namespace, message)
} | javascript | function prepMessage (state, level, namespace, message) {
if (_.isString(message)) {
const formatArgs = Array.prototype.slice.call(arguments, 3)
message = format.apply(null, formatArgs)
}
log(state, level, namespace, message)
} | [
"function",
"prepMessage",
"(",
"state",
",",
"level",
",",
"namespace",
",",
"message",
")",
"{",
"if",
"(",
"_",
".",
"isString",
"(",
"message",
")",
")",
"{",
"const",
"formatArgs",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
... | handles message format if necessary before calling the actual log function to emit | [
"handles",
"message",
"format",
"if",
"necessary",
"before",
"calling",
"the",
"actual",
"log",
"function",
"to",
"emit"
] | 0c34205fd6726356b69bcdd6dec4fcba55027af6 | https://github.com/deftly/node-deftly/blob/0c34205fd6726356b69bcdd6dec4fcba55027af6/src/log.js#L136-L142 | train |
deftly/node-deftly | src/log.js | removeFilter | function removeFilter (config, filter) {
if (filter) {
if (config.filters.ignore[ filter ]) {
delete config.filters.ignore[ filter ]
} else {
delete config.filters.should[ filter ]
}
}
} | javascript | function removeFilter (config, filter) {
if (filter) {
if (config.filters.ignore[ filter ]) {
delete config.filters.ignore[ filter ]
} else {
delete config.filters.should[ filter ]
}
}
} | [
"function",
"removeFilter",
"(",
"config",
",",
"filter",
")",
"{",
"if",
"(",
"filter",
")",
"{",
"if",
"(",
"config",
".",
"filters",
".",
"ignore",
"[",
"filter",
"]",
")",
"{",
"delete",
"config",
".",
"filters",
".",
"ignore",
"[",
"filter",
"]"... | remove the regex filter from the correct hash | [
"remove",
"the",
"regex",
"filter",
"from",
"the",
"correct",
"hash"
] | 0c34205fd6726356b69bcdd6dec4fcba55027af6 | https://github.com/deftly/node-deftly/blob/0c34205fd6726356b69bcdd6dec4fcba55027af6/src/log.js#L145-L153 | train |
deftly/node-deftly | src/log.js | setFilters | function setFilters (config) {
const parts = config.filter.split(/[\s,]+/)
config.filters = {
should: {},
ignore: {}
}
_.each(parts, addFilter.bind(null, config))
} | javascript | function setFilters (config) {
const parts = config.filter.split(/[\s,]+/)
config.filters = {
should: {},
ignore: {}
}
_.each(parts, addFilter.bind(null, config))
} | [
"function",
"setFilters",
"(",
"config",
")",
"{",
"const",
"parts",
"=",
"config",
".",
"filter",
".",
"split",
"(",
"/",
"[\\s,]+",
"/",
")",
"config",
".",
"filters",
"=",
"{",
"should",
":",
"{",
"}",
",",
"ignore",
":",
"{",
"}",
"}",
"_",
"... | sets should and musn't filters | [
"sets",
"should",
"and",
"musn",
"t",
"filters"
] | 0c34205fd6726356b69bcdd6dec4fcba55027af6 | https://github.com/deftly/node-deftly/blob/0c34205fd6726356b69bcdd6dec4fcba55027af6/src/log.js#L167-L174 | train |
deftly/node-deftly | src/log.js | shouldRender | function shouldRender (config, entry) {
// if we're below the log level, return false
if (config.level < entry.level) {
return false
}
// if we match the ignore list at all, return false
const ignoreMatch = _.find(_.values(config.filters.ignore), ignore => {
return ignore.test(entry.namespace)
})
... | javascript | function shouldRender (config, entry) {
// if we're below the log level, return false
if (config.level < entry.level) {
return false
}
// if we match the ignore list at all, return false
const ignoreMatch = _.find(_.values(config.filters.ignore), ignore => {
return ignore.test(entry.namespace)
})
... | [
"function",
"shouldRender",
"(",
"config",
",",
"entry",
")",
"{",
"// if we're below the log level, return false",
"if",
"(",
"config",
".",
"level",
"<",
"entry",
".",
"level",
")",
"{",
"return",
"false",
"}",
"// if we match the ignore list at all, return false",
... | check entry against configuration to see if it should be logged by adapter | [
"check",
"entry",
"against",
"configuration",
"to",
"see",
"if",
"it",
"should",
"be",
"logged",
"by",
"adapter"
] | 0c34205fd6726356b69bcdd6dec4fcba55027af6 | https://github.com/deftly/node-deftly/blob/0c34205fd6726356b69bcdd6dec4fcba55027af6/src/log.js#L178-L203 | train |
skylarkax/skylark-slax-nodeserver | bin/cli.js | initTerminateHandlers | function initTerminateHandlers() {
var readLine;
if (process.platform === "win32"){
readLine = require("readline");
readLine.createInterface ({
input: process.stdin,
output: process.stdout
}).on("SIGINT", function () {
process.emit("SIGINT");
});
}
// handle INTERRUPT (CTRL+... | javascript | function initTerminateHandlers() {
var readLine;
if (process.platform === "win32"){
readLine = require("readline");
readLine.createInterface ({
input: process.stdin,
output: process.stdout
}).on("SIGINT", function () {
process.emit("SIGINT");
});
}
// handle INTERRUPT (CTRL+... | [
"function",
"initTerminateHandlers",
"(",
")",
"{",
"var",
"readLine",
";",
"if",
"(",
"process",
".",
"platform",
"===",
"\"win32\"",
")",
"{",
"readLine",
"=",
"require",
"(",
"\"readline\"",
")",
";",
"readLine",
".",
"createInterface",
"(",
"{",
"input",... | Prepare the 'exit' handler for the program termination | [
"Prepare",
"the",
"exit",
"handler",
"for",
"the",
"program",
"termination"
] | af0840a4689495a1efa3b23ad34848034fcc313f | https://github.com/skylarkax/skylark-slax-nodeserver/blob/af0840a4689495a1efa3b23ad34848034fcc313f/bin/cli.js#L55-L85 | train |
sendanor/nor-nopg | src/schema/v0020.js | fetch_object_by_uuid | function fetch_object_by_uuid(data, prop, uuid) {
if(!is_object(data)) { return error('fetch_object_by_uuid(data, ..., ...) not object: '+ data); }
if(!is_string(prop)) { return error('fetch_object_by_uuid(..., prop, ...) not string: '+ prop); }
if(!is_uuid(uuid)) { return warn('Property ' + prop + ' was no... | javascript | function fetch_object_by_uuid(data, prop, uuid) {
if(!is_object(data)) { return error('fetch_object_by_uuid(data, ..., ...) not object: '+ data); }
if(!is_string(prop)) { return error('fetch_object_by_uuid(..., prop, ...) not string: '+ prop); }
if(!is_uuid(uuid)) { return warn('Property ' + prop + ' was no... | [
"function",
"fetch_object_by_uuid",
"(",
"data",
",",
"prop",
",",
"uuid",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"data",
")",
")",
"{",
"return",
"error",
"(",
"'fetch_object_by_uuid(data, ..., ...) not object: '",
"+",
"data",
")",
";",
"}",
"if",
"("... | Get document by UUID | [
"Get",
"document",
"by",
"UUID"
] | 0d99b86c1a1996b5828b56de8de23700df8bbc0c | https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/schema/v0020.js#L60-L69 | train |
buzzin0609/tagbuildr | src/setDomAttrs.js | setDomAttrs | function setDomAttrs(attrs, el) {
for (let attr in attrs) {
if (!attrs.hasOwnProperty(attr)) { continue; }
switch (attr) {
case 'className':
case 'id':
el[attr] = attrs[attr];
break;
default:
el.setAttribute(attr, attrs[attr]);
break;
}
}
return el;
} | javascript | function setDomAttrs(attrs, el) {
for (let attr in attrs) {
if (!attrs.hasOwnProperty(attr)) { continue; }
switch (attr) {
case 'className':
case 'id':
el[attr] = attrs[attr];
break;
default:
el.setAttribute(attr, attrs[attr]);
break;
}
}
return el;
} | [
"function",
"setDomAttrs",
"(",
"attrs",
",",
"el",
")",
"{",
"for",
"(",
"let",
"attr",
"in",
"attrs",
")",
"{",
"if",
"(",
"!",
"attrs",
".",
"hasOwnProperty",
"(",
"attr",
")",
")",
"{",
"continue",
";",
"}",
"switch",
"(",
"attr",
")",
"{",
"... | Add attributes to the dom element
@private
@param {Object} attrs object of key-value pairs of dom attributes. Classes and Id are added directly to element and others are set via setAttribute
@param {Element} el the dom element | [
"Add",
"attributes",
"to",
"the",
"dom",
"element"
] | 9d6a52ad51c0fc3230de2da1e8e3f63f95a6e542 | https://github.com/buzzin0609/tagbuildr/blob/9d6a52ad51c0fc3230de2da1e8e3f63f95a6e542/src/setDomAttrs.js#L7-L22 | train |
rqt/github | build/api/activity/star.js | del | async function del(owner, repo) {
const endpoint = `/user/starred/${owner}/${repo}`
const { statusCode } = await this._request({
method: 'PUT',
data: {},
endpoint,
})
if (statusCode != 204) {
throw new Error(`Unexpected status code ${statusCode}.`)
}
} | javascript | async function del(owner, repo) {
const endpoint = `/user/starred/${owner}/${repo}`
const { statusCode } = await this._request({
method: 'PUT',
data: {},
endpoint,
})
if (statusCode != 204) {
throw new Error(`Unexpected status code ${statusCode}.`)
}
} | [
"async",
"function",
"del",
"(",
"owner",
",",
"repo",
")",
"{",
"const",
"endpoint",
"=",
"`",
"${",
"owner",
"}",
"${",
"repo",
"}",
"`",
"const",
"{",
"statusCode",
"}",
"=",
"await",
"this",
".",
"_request",
"(",
"{",
"method",
":",
"'PUT'",
",... | Star a repository.
@param {string} owner
@param {string} repo | [
"Star",
"a",
"repository",
"."
] | e6d3cdd8633628cd4aba30e70d8258aa7f6f0c5a | https://github.com/rqt/github/blob/e6d3cdd8633628cd4aba30e70d8258aa7f6f0c5a/build/api/activity/star.js#L6-L16 | train |
jigarjain/object-clean | index.js | objCleaner | function objCleaner(obj, removeTypes) {
var defaultRemoveTypes = [null, 'undefined', false, '', [], {}];
var key;
function allowEmptyObject() {
var i;
for (i = 0; i < removeTypes.length; i++) {
if (removeTypes[i] instanceof Object && Object.keys(removeTypes[i]).length === 0) {
... | javascript | function objCleaner(obj, removeTypes) {
var defaultRemoveTypes = [null, 'undefined', false, '', [], {}];
var key;
function allowEmptyObject() {
var i;
for (i = 0; i < removeTypes.length; i++) {
if (removeTypes[i] instanceof Object && Object.keys(removeTypes[i]).length === 0) {
... | [
"function",
"objCleaner",
"(",
"obj",
",",
"removeTypes",
")",
"{",
"var",
"defaultRemoveTypes",
"=",
"[",
"null",
",",
"'undefined'",
",",
"false",
",",
"''",
",",
"[",
"]",
",",
"{",
"}",
"]",
";",
"var",
"key",
";",
"function",
"allowEmptyObject",
"... | Will delete the keys of the object which are set to null, undefined or empty string
@param {Object/Array} obj An object or array which needs to be cleaned
@param {Array} removeTypes Array of values and/or types which needs to be discarded (OPTIONAL)
@return {Object/Array} | [
"Will",
"delete",
"the",
"keys",
"of",
"the",
"object",
"which",
"are",
"set",
"to",
"null",
"undefined",
"or",
"empty",
"string"
] | ebfad9301e6588796abb4f08a44fb3ab4b9af823 | https://github.com/jigarjain/object-clean/blob/ebfad9301e6588796abb4f08a44fb3ab4b9af823/index.js#L11-L80 | train |
byron-dupreez/rcc-redis-mock-adapter | rcc-redis-mock-adapter.js | createClient | function createClient(redisClientOptions) {
const client = redis.createClient(redisClientOptions);
if (!client._options) {
client._options = redisClientOptions;
}
return client;
} | javascript | function createClient(redisClientOptions) {
const client = redis.createClient(redisClientOptions);
if (!client._options) {
client._options = redisClientOptions;
}
return client;
} | [
"function",
"createClient",
"(",
"redisClientOptions",
")",
"{",
"const",
"client",
"=",
"redis",
".",
"createClient",
"(",
"redisClientOptions",
")",
";",
"if",
"(",
"!",
"client",
".",
"_options",
")",
"{",
"client",
".",
"_options",
"=",
"redisClientOptions... | Creates a new RedisClient instance.
@param {RedisClientOptions|undefined} [redisClientOptions] - the options to use to construct the new RedisClient
instance
@return {RedisClient} returns the new RedisClient instance | [
"Creates",
"a",
"new",
"RedisClient",
"instance",
"."
] | 30297a11c2319b215f7826a39fc61a9d95ed810f | https://github.com/byron-dupreez/rcc-redis-mock-adapter/blob/30297a11c2319b215f7826a39fc61a9d95ed810f/rcc-redis-mock-adapter.js#L100-L106 | train |
alexcu/node-pact-publisher | lib/pact-publisher.js | PactPublisher | function PactPublisher (configOrVersion, brokerBaseUrl, pacts) {
var _version, _brokerBaseUrl, _pacts;
if (!_.contains(['object', 'string'], typeof configOrVersion)) {
throw new TypeError('Invalid first parameter provided constructing Pact Publisher. Expected a config object or version string for first paramete... | javascript | function PactPublisher (configOrVersion, brokerBaseUrl, pacts) {
var _version, _brokerBaseUrl, _pacts;
if (!_.contains(['object', 'string'], typeof configOrVersion)) {
throw new TypeError('Invalid first parameter provided constructing Pact Publisher. Expected a config object or version string for first paramete... | [
"function",
"PactPublisher",
"(",
"configOrVersion",
",",
"brokerBaseUrl",
",",
"pacts",
")",
"{",
"var",
"_version",
",",
"_brokerBaseUrl",
",",
"_pacts",
";",
"if",
"(",
"!",
"_",
".",
"contains",
"(",
"[",
"'object'",
",",
"'string'",
"]",
",",
"typeof"... | A pact publisher
@param {Object|String} configOrVersion Config object or version number.
If config object is provided, it's
just an object containing:
- {String} appVersion
- {String} brokerBaseUrl
- {Array|String} pact
- {Boolean} logging (if set to
false, no logs will be output)
@param {String} brokerBaseU... | [
"A",
"pact",
"publisher"
] | b87bf328e1699409c09680d182505e18e0e397e0 | https://github.com/alexcu/node-pact-publisher/blob/b87bf328e1699409c09680d182505e18e0e397e0/lib/pact-publisher.js#L36-L72 | train |
tolokoban/ToloFrameWork | ker/mod/wdg.input.js | function(opts) {
Widget.call(this);
var input = Widget.tag("input");
this._input = input;
var that = this;
this.addClass("wdg-input");
if (typeof opts !== 'object') opts = {};
if (typeof opts.type !== 'string') opts.type = 'text';
input.attr("type", opts.type);
if (typeof op... | javascript | function(opts) {
Widget.call(this);
var input = Widget.tag("input");
this._input = input;
var that = this;
this.addClass("wdg-input");
if (typeof opts !== 'object') opts = {};
if (typeof opts.type !== 'string') opts.type = 'text';
input.attr("type", opts.type);
if (typeof op... | [
"function",
"(",
"opts",
")",
"{",
"Widget",
".",
"call",
"(",
"this",
")",
";",
"var",
"input",
"=",
"Widget",
".",
"tag",
"(",
"\"input\"",
")",
";",
"this",
".",
"_input",
"=",
"input",
";",
"var",
"that",
"=",
"this",
";",
"this",
".",
"addCl... | HTML5 text input with many options.
@param {string} opts.value Initial value.
@param {string} opts.type Input's type. Can be `text`, `password`, ...
@param {string} opts.name The name can be used by the browser to give a help combo.
@param {string} opts.placeholder Text to display when input is empty.
@param {functio... | [
"HTML5",
"text",
"input",
"with",
"many",
"options",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/wdg.input.js#L55-L142 | train | |
tombenke/proper | bin/cli.js | function( fileName ) {
// console.log('Read configuration from ' + fileName);
var pathSep = require('path').sep;
var inFileName = process.cwd() + pathSep + fileName;
var config = require( inFileName );
// TODO: validate config
for ( var procs in config ) {
... | javascript | function( fileName ) {
// console.log('Read configuration from ' + fileName);
var pathSep = require('path').sep;
var inFileName = process.cwd() + pathSep + fileName;
var config = require( inFileName );
// TODO: validate config
for ( var procs in config ) {
... | [
"function",
"(",
"fileName",
")",
"{",
"// console.log('Read configuration from ' + fileName);",
"var",
"pathSep",
"=",
"require",
"(",
"'path'",
")",
".",
"sep",
";",
"var",
"inFileName",
"=",
"process",
".",
"cwd",
"(",
")",
"+",
"pathSep",
"+",
"fileName",
... | Read the config file
@param {string} fileName The name of the config file
@return {Object} The configuration object | [
"Read",
"the",
"config",
"file"
] | 3f766df6ec7dbb0c4d136373a94002d00d340a48 | https://github.com/tombenke/proper/blob/3f766df6ec7dbb0c4d136373a94002d00d340a48/bin/cli.js#L19-L38 | train | |
redisjs/jsr-persistence | lib/index.js | saveSync | function saveSync(store, conf) {
try {
this.save(store, conf);
}catch(e) {
log.warning('failed to save rdb snapshot: %s', e.message);
}
} | javascript | function saveSync(store, conf) {
try {
this.save(store, conf);
}catch(e) {
log.warning('failed to save rdb snapshot: %s', e.message);
}
} | [
"function",
"saveSync",
"(",
"store",
",",
"conf",
")",
"{",
"try",
"{",
"this",
".",
"save",
"(",
"store",
",",
"conf",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"log",
".",
"warning",
"(",
"'failed to save rdb snapshot: %s'",
",",
"e",
".",
"mess... | Synchronous save. | [
"Synchronous",
"save",
"."
] | 77f3fc84ea7cbdb9f41a4dfa7ee1d89be61f7510 | https://github.com/redisjs/jsr-persistence/blob/77f3fc84ea7cbdb9f41a4dfa7ee1d89be61f7510/lib/index.js#L20-L26 | train |
pkrll/Salvation | src/salvation.js | function () {
var emptyFunction = new RegExp(/(\{\s\})|(\{\})/),
publicMethods = {};
for (property in this.settings) {
if (typeof this.settings[property] == 'function' &&
typeof this[property] == 'function') {
var method = t... | javascript | function () {
var emptyFunction = new RegExp(/(\{\s\})|(\{\})/),
publicMethods = {};
for (property in this.settings) {
if (typeof this.settings[property] == 'function' &&
typeof this[property] == 'function') {
var method = t... | [
"function",
"(",
")",
"{",
"var",
"emptyFunction",
"=",
"new",
"RegExp",
"(",
"/",
"(\\{\\s\\})|(\\{\\})",
"/",
")",
",",
"publicMethods",
"=",
"{",
"}",
";",
"for",
"(",
"property",
"in",
"this",
".",
"settings",
")",
"{",
"if",
"(",
"typeof",
"this",... | Creates an object of pseudo-public
methods that will be returned when
the plugin is initialized.
@returns Object | [
"Creates",
"an",
"object",
"of",
"pseudo",
"-",
"public",
"methods",
"that",
"will",
"be",
"returned",
"when",
"the",
"plugin",
"is",
"initialized",
"."
] | 143e8a69d1b81b409b4aeff106f7fba21cf14645 | https://github.com/pkrll/Salvation/blob/143e8a69d1b81b409b4aeff106f7fba21cf14645/src/salvation.js#L97-L117 | train | |
pkrll/Salvation | src/salvation.js | function(name) {
if (/[A-Z]/.test(name.charAt(0)))
return "default" + name;
var firstLetter = name.charAt(0);
return "default" + firstLetter.toUpperCase() + name.substring(1);
} | javascript | function(name) {
if (/[A-Z]/.test(name.charAt(0)))
return "default" + name;
var firstLetter = name.charAt(0);
return "default" + firstLetter.toUpperCase() + name.substring(1);
} | [
"function",
"(",
"name",
")",
"{",
"if",
"(",
"/",
"[A-Z]",
"/",
".",
"test",
"(",
"name",
".",
"charAt",
"(",
"0",
")",
")",
")",
"return",
"\"default\"",
"+",
"name",
";",
"var",
"firstLetter",
"=",
"name",
".",
"charAt",
"(",
"0",
")",
";",
... | Prepends method name with string
"default", using camelCase.
@param string Name to manipulate
@returns string | [
"Prepends",
"method",
"name",
"with",
"string",
"default",
"using",
"camelCase",
"."
] | 143e8a69d1b81b409b4aeff106f7fba21cf14645 | https://github.com/pkrll/Salvation/blob/143e8a69d1b81b409b4aeff106f7fba21cf14645/src/salvation.js#L125-L130 | train | |
pkrll/Salvation | src/salvation.js | function (primary, secondary) {
var primary = primary || {};
for (var property in secondary)
if (secondary.hasOwnProperty(property))
primary[property] = secondary[property];
return primary;
} | javascript | function (primary, secondary) {
var primary = primary || {};
for (var property in secondary)
if (secondary.hasOwnProperty(property))
primary[property] = secondary[property];
return primary;
} | [
"function",
"(",
"primary",
",",
"secondary",
")",
"{",
"var",
"primary",
"=",
"primary",
"||",
"{",
"}",
";",
"for",
"(",
"var",
"property",
"in",
"secondary",
")",
"if",
"(",
"secondary",
".",
"hasOwnProperty",
"(",
"property",
")",
")",
"primary",
"... | Extend a given object with
another object.
@param object Object that is to be extended
@param object Object with properties to add to first object
@returns object | [
"Extend",
"a",
"given",
"object",
"with",
"another",
"object",
"."
] | 143e8a69d1b81b409b4aeff106f7fba21cf14645 | https://github.com/pkrll/Salvation/blob/143e8a69d1b81b409b4aeff106f7fba21cf14645/src/salvation.js#L149-L155 | train | |
pkrll/Salvation | src/salvation.js | function (event) {
var self = this;
if (this.invalidElements.length > 0)
event.preventDefault();
// Even if the invalidElements count
// does not indicate any invalidated
// elements, the plugin should make
// sure that there are no... | javascript | function (event) {
var self = this;
if (this.invalidElements.length > 0)
event.preventDefault();
// Even if the invalidElements count
// does not indicate any invalidated
// elements, the plugin should make
// sure that there are no... | [
"function",
"(",
"event",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"this",
".",
"invalidElements",
".",
"length",
">",
"0",
")",
"event",
".",
"preventDefault",
"(",
")",
";",
"// Even if the invalidElements count",
"// does not indicate any invalid... | Callback function for event submit.
Validates elements, but will first
check if the global "formInvalid"-
variable is set, before validation.
@param Event | [
"Callback",
"function",
"for",
"event",
"submit",
".",
"Validates",
"elements",
"but",
"will",
"first",
"check",
"if",
"the",
"global",
"formInvalid",
"-",
"variable",
"is",
"set",
"before",
"validation",
"."
] | 143e8a69d1b81b409b4aeff106f7fba21cf14645 | https://github.com/pkrll/Salvation/blob/143e8a69d1b81b409b4aeff106f7fba21cf14645/src/salvation.js#L164-L184 | train | |
pkrll/Salvation | src/salvation.js | function(event) {
var target = event.target;
if (this.checkElementByPattern(target)) {
if (this.invalidElements.indexOf(target) > -1)
this.invalidElements.splice(this.invalidElements.indexOf(target), 1);
this.publicInterface.onValidation([targe... | javascript | function(event) {
var target = event.target;
if (this.checkElementByPattern(target)) {
if (this.invalidElements.indexOf(target) > -1)
this.invalidElements.splice(this.invalidElements.indexOf(target), 1);
this.publicInterface.onValidation([targe... | [
"function",
"(",
"event",
")",
"{",
"var",
"target",
"=",
"event",
".",
"target",
";",
"if",
"(",
"this",
".",
"checkElementByPattern",
"(",
"target",
")",
")",
"{",
"if",
"(",
"this",
".",
"invalidElements",
".",
"indexOf",
"(",
"target",
")",
">",
... | Callback function for the change
event. Validates elements live.
@param Event | [
"Callback",
"function",
"for",
"the",
"change",
"event",
".",
"Validates",
"elements",
"live",
"."
] | 143e8a69d1b81b409b4aeff106f7fba21cf14645 | https://github.com/pkrll/Salvation/blob/143e8a69d1b81b409b4aeff106f7fba21cf14645/src/salvation.js#L191-L203 | train | |
pkrll/Salvation | src/salvation.js | function (event) {
// Check if the node is a child of the plugin's element.
if (event.relatedNode === this.element) {
var attributeValues = event.target.getAttribute("data-validate");
if (attributeValues !== null) {
attributeValues = this.split... | javascript | function (event) {
// Check if the node is a child of the plugin's element.
if (event.relatedNode === this.element) {
var attributeValues = event.target.getAttribute("data-validate");
if (attributeValues !== null) {
attributeValues = this.split... | [
"function",
"(",
"event",
")",
"{",
"// Check if the node is a child of the plugin's element.",
"if",
"(",
"event",
".",
"relatedNode",
"===",
"this",
".",
"element",
")",
"{",
"var",
"attributeValues",
"=",
"event",
".",
"target",
".",
"getAttribute",
"(",
"\"dat... | Callback for DOMNodeInserted.
Adds inserted element to the
elements list, if it has the
appropriate attributes.
@param Event | [
"Callback",
"for",
"DOMNodeInserted",
".",
"Adds",
"inserted",
"element",
"to",
"the",
"elements",
"list",
"if",
"it",
"has",
"the",
"appropriate",
"attributes",
"."
] | 143e8a69d1b81b409b4aeff106f7fba21cf14645 | https://github.com/pkrll/Salvation/blob/143e8a69d1b81b409b4aeff106f7fba21cf14645/src/salvation.js#L212-L229 | train | |
pkrll/Salvation | src/salvation.js | function (elements, legend) {
var elements = elements || [];
for (var i = 0; i < elements.length; i++) {
if (elements[i].classList.contains(this.stylings.error) === false)
elements[i].classList.add(this.stylings.error);
var legend = elements[i]... | javascript | function (elements, legend) {
var elements = elements || [];
for (var i = 0; i < elements.length; i++) {
if (elements[i].classList.contains(this.stylings.error) === false)
elements[i].classList.add(this.stylings.error);
var legend = elements[i]... | [
"function",
"(",
"elements",
",",
"legend",
")",
"{",
"var",
"elements",
"=",
"elements",
"||",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"elements",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"elements",
"[",
"i"... | Performs the default invalidation
action on invalid elements.
@param HTMLFormElement | [
"Performs",
"the",
"default",
"invalidation",
"action",
"on",
"invalid",
"elements",
"."
] | 143e8a69d1b81b409b4aeff106f7fba21cf14645 | https://github.com/pkrll/Salvation/blob/143e8a69d1b81b409b4aeff106f7fba21cf14645/src/salvation.js#L236-L247 | train | |
pkrll/Salvation | src/salvation.js | function (elements) {
var elements = elements || [];
for (var i = 0; i < elements.length; i++) {
if (elements[i].classList.contains(this.stylings.error)) {
elements[i].classList.remove(this.stylings.error);
var parent = elements[i].parentNo... | javascript | function (elements) {
var elements = elements || [];
for (var i = 0; i < elements.length; i++) {
if (elements[i].classList.contains(this.stylings.error)) {
elements[i].classList.remove(this.stylings.error);
var parent = elements[i].parentNo... | [
"function",
"(",
"elements",
")",
"{",
"var",
"elements",
"=",
"elements",
"||",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"elements",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"elements",
"[",
"i",
"]",
".",
"... | Performs the default validation
action on revalidated elements.
@param HTMLFormElement | [
"Performs",
"the",
"default",
"validation",
"action",
"on",
"revalidated",
"elements",
"."
] | 143e8a69d1b81b409b4aeff106f7fba21cf14645 | https://github.com/pkrll/Salvation/blob/143e8a69d1b81b409b4aeff106f7fba21cf14645/src/salvation.js#L254-L263 | train | |
pkrll/Salvation | src/salvation.js | function (elements, attribute, value) {
var foundElements = [], value = value || null;
for (i = 0; i < elements.length; i++) {
// If the value parameter is set, return only the
// elements that has the given attribute value.
if (value !== null) {
... | javascript | function (elements, attribute, value) {
var foundElements = [], value = value || null;
for (i = 0; i < elements.length; i++) {
// If the value parameter is set, return only the
// elements that has the given attribute value.
if (value !== null) {
... | [
"function",
"(",
"elements",
",",
"attribute",
",",
"value",
")",
"{",
"var",
"foundElements",
"=",
"[",
"]",
",",
"value",
"=",
"value",
"||",
"null",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"elements",
".",
"length",
";",
"i",
"++",
")",... | Find elements by attribute name, with option
to also go by the attribute value.
@param elements Array of elements to search
@param string Value to find
@returns array List of elements found | [
"Find",
"elements",
"by",
"attribute",
"name",
"with",
"option",
"to",
"also",
"go",
"by",
"the",
"attribute",
"value",
"."
] | 143e8a69d1b81b409b4aeff106f7fba21cf14645 | https://github.com/pkrll/Salvation/blob/143e8a69d1b81b409b4aeff106f7fba21cf14645/src/salvation.js#L284-L299 | train | |
pkrll/Salvation | src/salvation.js | function (elements, attribute) {
var foundElements = {};
for (i = 0; i < elements.length; i++) {
var attributeValues = elements[i].getAttribute(attribute);
if (attributeValues === undefined || attributeValues === null)
continue;
... | javascript | function (elements, attribute) {
var foundElements = {};
for (i = 0; i < elements.length; i++) {
var attributeValues = elements[i].getAttribute(attribute);
if (attributeValues === undefined || attributeValues === null)
continue;
... | [
"function",
"(",
"elements",
",",
"attribute",
")",
"{",
"var",
"foundElements",
"=",
"{",
"}",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"elements",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"attributeValues",
"=",
"elements",
"[",
"i",... | Find elements by attribute name, and return
them as an object with attribute value as key.
This method will sort elements in different
objects, depending on attributes. An element
with multiple attribute values will be added
to multiple objects.
@param elements Array of elements to search
@param string ... | [
"Find",
"elements",
"by",
"attribute",
"name",
"and",
"return",
"them",
"as",
"an",
"object",
"with",
"attribute",
"value",
"as",
"key",
".",
"This",
"method",
"will",
"sort",
"elements",
"in",
"different",
"objects",
"depending",
"on",
"attributes",
".",
"A... | 143e8a69d1b81b409b4aeff106f7fba21cf14645 | https://github.com/pkrll/Salvation/blob/143e8a69d1b81b409b4aeff106f7fba21cf14645/src/salvation.js#L340-L364 | train | |
pkrll/Salvation | src/salvation.js | function (element) {
// Begin with checking the validate
var elementAsArray = [ element ],
validationType = element.getAttribute("data-validate") || null;
invalidElement = [];
if (validationType !== null) {
validationType = this.splitSt... | javascript | function (element) {
// Begin with checking the validate
var elementAsArray = [ element ],
validationType = element.getAttribute("data-validate") || null;
invalidElement = [];
if (validationType !== null) {
validationType = this.splitSt... | [
"function",
"(",
"element",
")",
"{",
"// Begin with checking the validate",
"var",
"elementAsArray",
"=",
"[",
"element",
"]",
",",
"validationType",
"=",
"element",
".",
"getAttribute",
"(",
"\"data-validate\"",
")",
"||",
"null",
";",
"invalidElement",
"=",
"["... | Validates a single element. Used as callback on invalidated
elements to check when they are valid.
@param element The element to check.
@returns bool True on valid | [
"Validates",
"a",
"single",
"element",
".",
"Used",
"as",
"callback",
"on",
"invalidated",
"elements",
"to",
"check",
"when",
"they",
"are",
"valid",
"."
] | 143e8a69d1b81b409b4aeff106f7fba21cf14645 | https://github.com/pkrll/Salvation/blob/143e8a69d1b81b409b4aeff106f7fba21cf14645/src/salvation.js#L527-L553 | train | |
robertontiu/wrapper6 | build/packages.js | requireDependencies | function requireDependencies(dependencies) {
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var promise = new _es6Promise.Promise(function (succeed, fail) {
var requirements = {};
// no requirements
if (!(dependencies instanceof Array)) {
... | javascript | function requireDependencies(dependencies) {
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var promise = new _es6Promise.Promise(function (succeed, fail) {
var requirements = {};
// no requirements
if (!(dependencies instanceof Array)) {
... | [
"function",
"requireDependencies",
"(",
"dependencies",
")",
"{",
"var",
"callback",
"=",
"arguments",
".",
"length",
">",
"1",
"&&",
"arguments",
"[",
"1",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"1",
"]",
":",
"null",
";",
"var",
"promise",
"="... | Resolve an array of dependencies
@param dependencies
@returns {Promise} | [
"Resolve",
"an",
"array",
"of",
"dependencies"
] | 70f99dcda0f2e0926b689be349ab9bb95e84a22d | https://github.com/robertontiu/wrapper6/blob/70f99dcda0f2e0926b689be349ab9bb95e84a22d/build/packages.js#L48-L82 | train |
robertontiu/wrapper6 | build/packages.js | definePackage | function definePackage(name, dependencies, callback) {
// Adjust arguments
if (typeof name === "function") {
callback = name;
name = null;
dependencies = null;
} else if (typeof dependencies === "function") {
callback = dependencies;
dependencies = null;
if (... | javascript | function definePackage(name, dependencies, callback) {
// Adjust arguments
if (typeof name === "function") {
callback = name;
name = null;
dependencies = null;
} else if (typeof dependencies === "function") {
callback = dependencies;
dependencies = null;
if (... | [
"function",
"definePackage",
"(",
"name",
",",
"dependencies",
",",
"callback",
")",
"{",
"// Adjust arguments",
"if",
"(",
"typeof",
"name",
"===",
"\"function\"",
")",
"{",
"callback",
"=",
"name",
";",
"name",
"=",
"null",
";",
"dependencies",
"=",
"null"... | Define a package
@param name
@param dependencies
@param callback
@returns {Promise.<TResult>} | [
"Define",
"a",
"package"
] | 70f99dcda0f2e0926b689be349ab9bb95e84a22d | https://github.com/robertontiu/wrapper6/blob/70f99dcda0f2e0926b689be349ab9bb95e84a22d/build/packages.js#L92-L169 | train |
robertontiu/wrapper6 | build/packages.js | wrapAll | function wrapAll(callback) {
// Prepare packages
var packs = {};
packages.forEach(function (pack, name) {
packs[name] = pack;
});
return callback(packs);
} | javascript | function wrapAll(callback) {
// Prepare packages
var packs = {};
packages.forEach(function (pack, name) {
packs[name] = pack;
});
return callback(packs);
} | [
"function",
"wrapAll",
"(",
"callback",
")",
"{",
"// Prepare packages",
"var",
"packs",
"=",
"{",
"}",
";",
"packages",
".",
"forEach",
"(",
"function",
"(",
"pack",
",",
"name",
")",
"{",
"packs",
"[",
"name",
"]",
"=",
"pack",
";",
"}",
")",
";",
... | Runs the callback with all currently loaded packages
@param callback
@returns {*} | [
"Runs",
"the",
"callback",
"with",
"all",
"currently",
"loaded",
"packages"
] | 70f99dcda0f2e0926b689be349ab9bb95e84a22d | https://github.com/robertontiu/wrapper6/blob/70f99dcda0f2e0926b689be349ab9bb95e84a22d/build/packages.js#L177-L186 | train |
gethuman/jyt | lib/jyt.utils.js | isEmptyObject | function isEmptyObject(obj) {
if (obj === null) {
return true;
}
if (!isObject(obj)) {
return false;
}
for (var key in obj) {
if (obj.hasOwnProperty(key) && obj[key]) {
return false;
}
}
return true;
} | javascript | function isEmptyObject(obj) {
if (obj === null) {
return true;
}
if (!isObject(obj)) {
return false;
}
for (var key in obj) {
if (obj.hasOwnProperty(key) && obj[key]) {
return false;
}
}
return true;
} | [
"function",
"isEmptyObject",
"(",
"obj",
")",
"{",
"if",
"(",
"obj",
"===",
"null",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"isObject",
"(",
"obj",
")",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"var",
"key",
"in",
"obj",
... | Return true if an object and is empty
@param obj
@returns {boolean} | [
"Return",
"true",
"if",
"an",
"object",
"and",
"is",
"empty"
] | 716be37e09217b4be917e179389f752212a428b3 | https://github.com/gethuman/jyt/blob/716be37e09217b4be917e179389f752212a428b3/lib/jyt.utils.js#L53-L68 | train |
gethuman/jyt | lib/jyt.utils.js | dashToCamelCase | function dashToCamelCase(dashCase) {
if (!dashCase) { return dashCase; }
var parts = dashCase.split('-');
var camelCase = parts[0];
var part;
for (var i = 1; i < parts.length; i++) {
part = parts[i];
camelCase += part.substring(0, 1).toUpperCase() + part.substring(1);
}
re... | javascript | function dashToCamelCase(dashCase) {
if (!dashCase) { return dashCase; }
var parts = dashCase.split('-');
var camelCase = parts[0];
var part;
for (var i = 1; i < parts.length; i++) {
part = parts[i];
camelCase += part.substring(0, 1).toUpperCase() + part.substring(1);
}
re... | [
"function",
"dashToCamelCase",
"(",
"dashCase",
")",
"{",
"if",
"(",
"!",
"dashCase",
")",
"{",
"return",
"dashCase",
";",
"}",
"var",
"parts",
"=",
"dashCase",
".",
"split",
"(",
"'-'",
")",
";",
"var",
"camelCase",
"=",
"parts",
"[",
"0",
"]",
";",... | Convert a string with dashes to camel case
@param dashCase | [
"Convert",
"a",
"string",
"with",
"dashes",
"to",
"camel",
"case"
] | 716be37e09217b4be917e179389f752212a428b3 | https://github.com/gethuman/jyt/blob/716be37e09217b4be917e179389f752212a428b3/lib/jyt.utils.js#L74-L87 | train |
esoodev/eve-swagger-simple | index.js | function (route, parameters) {
return new Promise((resolve, reject) => {
request.get({
url: baseUrl + route + '?' + querystring.stringify(parameters)
}, (error, response, body) => {
if (error) {
reject(error);
} else ... | javascript | function (route, parameters) {
return new Promise((resolve, reject) => {
request.get({
url: baseUrl + route + '?' + querystring.stringify(parameters)
}, (error, response, body) => {
if (error) {
reject(error);
} else ... | [
"function",
"(",
"route",
",",
"parameters",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"request",
".",
"get",
"(",
"{",
"url",
":",
"baseUrl",
"+",
"route",
"+",
"'?'",
"+",
"querystring",
".",
"stringi... | Send a GET request to ESI - try POST if it fails. | [
"Send",
"a",
"GET",
"request",
"to",
"ESI",
"-",
"try",
"POST",
"if",
"it",
"fails",
"."
] | 1a47aeb5074bc95c2e5caa7caf9fdbcc5ed302f9 | https://github.com/esoodev/eve-swagger-simple/blob/1a47aeb5074bc95c2e5caa7caf9fdbcc5ed302f9/index.js#L8-L40 | train | |
esoodev/eve-swagger-simple | index.js | function (route, parameters) {
return new Promise((resolve, reject) => {
request.post({
url: baseUrl + route,
qs: parameters
}, (error, response, body) => {
if (error) {
reject(error);
} else { resolve... | javascript | function (route, parameters) {
return new Promise((resolve, reject) => {
request.post({
url: baseUrl + route,
qs: parameters
}, (error, response, body) => {
if (error) {
reject(error);
} else { resolve... | [
"function",
"(",
"route",
",",
"parameters",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"request",
".",
"post",
"(",
"{",
"url",
":",
"baseUrl",
"+",
"route",
",",
"qs",
":",
"parameters",
"}",
",",
"(... | Send a post request to ESI | [
"Send",
"a",
"post",
"request",
"to",
"ESI"
] | 1a47aeb5074bc95c2e5caa7caf9fdbcc5ed302f9 | https://github.com/esoodev/eve-swagger-simple/blob/1a47aeb5074bc95c2e5caa7caf9fdbcc5ed302f9/index.js#L43-L57 | train | |
danillouz/product-hunt | src/utils/http.js | GET | function GET(uri, params) {
const reqUrl = `${uri}${url.format({ query: params })}`;
log(`request URL: ${reqUrl}`);
return fetch(reqUrl)
.then(function handleGetRequest(res) {
const status = res.status;
const statusText = res.statusText;
log(`status code: ${status}`);
log(`status text: ${statusText}... | javascript | function GET(uri, params) {
const reqUrl = `${uri}${url.format({ query: params })}`;
log(`request URL: ${reqUrl}`);
return fetch(reqUrl)
.then(function handleGetRequest(res) {
const status = res.status;
const statusText = res.statusText;
log(`status code: ${status}`);
log(`status text: ${statusText}... | [
"function",
"GET",
"(",
"uri",
",",
"params",
")",
"{",
"const",
"reqUrl",
"=",
"`",
"${",
"uri",
"}",
"${",
"url",
".",
"format",
"(",
"{",
"query",
":",
"params",
"}",
")",
"}",
"`",
";",
"log",
"(",
"`",
"${",
"reqUrl",
"}",
"`",
")",
";",... | Makes an HTTP GET request for a specific URI.
@param {String} uri - the request URI
@param {Object} params - the request query parameters
@return {Promise} resolves with the HTTP response | [
"Makes",
"an",
"HTTP",
"GET",
"request",
"for",
"a",
"specific",
"URI",
"."
] | de7196db39365874055ad363cf3736de6de13856 | https://github.com/danillouz/product-hunt/blob/de7196db39365874055ad363cf3736de6de13856/src/utils/http.js#L17-L52 | train |
jamiter/swapi-schema | src/schema.js | jsonSchemaTypeToGraphQL | function jsonSchemaTypeToGraphQL(jsonSchemaType, schemaName) {
if (jsonSchemaType === "array") {
if (graphQLObjectTypes[schemaName]) {
return new GraphQLList(graphQLObjectTypes[schemaName]);
} else {
const translated = {
pilots: "people",
characters: "people",
residents: "p... | javascript | function jsonSchemaTypeToGraphQL(jsonSchemaType, schemaName) {
if (jsonSchemaType === "array") {
if (graphQLObjectTypes[schemaName]) {
return new GraphQLList(graphQLObjectTypes[schemaName]);
} else {
const translated = {
pilots: "people",
characters: "people",
residents: "p... | [
"function",
"jsonSchemaTypeToGraphQL",
"(",
"jsonSchemaType",
",",
"schemaName",
")",
"{",
"if",
"(",
"jsonSchemaType",
"===",
"\"array\"",
")",
"{",
"if",
"(",
"graphQLObjectTypes",
"[",
"schemaName",
"]",
")",
"{",
"return",
"new",
"GraphQLList",
"(",
"graphQL... | Convert the JSON Schema types to the actual GraphQL types in our schema | [
"Convert",
"the",
"JSON",
"Schema",
"types",
"to",
"the",
"actual",
"GraphQL",
"types",
"in",
"our",
"schema"
] | f05b28b75d7205739c0415bf379b5cd1f4936a7d | https://github.com/jamiter/swapi-schema/blob/f05b28b75d7205739c0415bf379b5cd1f4936a7d/src/schema.js#L55-L85 | train |
jamiter/swapi-schema | src/schema.js | fetchPageOfType | function fetchPageOfType(typePluralName, pageNumber) {
let url = `http://swapi.co/api/${typePluralName}/`;
if (pageNumber) {
url += `?page=${pageNumber}`;
};
return restLoader.load(url).then((data) => {
// Paginated results have a different shape
return data.results;
});
} | javascript | function fetchPageOfType(typePluralName, pageNumber) {
let url = `http://swapi.co/api/${typePluralName}/`;
if (pageNumber) {
url += `?page=${pageNumber}`;
};
return restLoader.load(url).then((data) => {
// Paginated results have a different shape
return data.results;
});
} | [
"function",
"fetchPageOfType",
"(",
"typePluralName",
",",
"pageNumber",
")",
"{",
"let",
"url",
"=",
"`",
"${",
"typePluralName",
"}",
"`",
";",
"if",
"(",
"pageNumber",
")",
"{",
"url",
"+=",
"`",
"${",
"pageNumber",
"}",
"`",
";",
"}",
";",
"return"... | A helper to unwrap the paginated object from SWAPI | [
"A",
"helper",
"to",
"unwrap",
"the",
"paginated",
"object",
"from",
"SWAPI"
] | f05b28b75d7205739c0415bf379b5cd1f4936a7d | https://github.com/jamiter/swapi-schema/blob/f05b28b75d7205739c0415bf379b5cd1f4936a7d/src/schema.js#L134-L144 | train |
tolokoban/ToloFrameWork | ker/mod/tfw.color.js | rgb2hsl | function rgb2hsl() {
const
R = this.R,
G = this.G,
B = this.B,
min = Math.min( R, G, B ),
max = Math.max( R, G, B ),
delta = max - min;
this.L = 0.5 * ( max + min );
if ( delta < 0.000001 ) {
this.H = 0;
this.S = 0;
} else {... | javascript | function rgb2hsl() {
const
R = this.R,
G = this.G,
B = this.B,
min = Math.min( R, G, B ),
max = Math.max( R, G, B ),
delta = max - min;
this.L = 0.5 * ( max + min );
if ( delta < 0.000001 ) {
this.H = 0;
this.S = 0;
} else {... | [
"function",
"rgb2hsl",
"(",
")",
"{",
"const",
"R",
"=",
"this",
".",
"R",
",",
"G",
"=",
"this",
".",
"G",
",",
"B",
"=",
"this",
".",
"B",
",",
"min",
"=",
"Math",
".",
"min",
"(",
"R",
",",
"G",
",",
"B",
")",
",",
"max",
"=",
"Math",
... | Read R,G,B and write H,S,L.
@this Color
@returns {undefined} | [
"Read",
"R",
"G",
"B",
"and",
"write",
"H",
"S",
"L",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/tfw.color.js#L106-L134 | train |
BlueRival/confection | lib/core/index.js | getConf | function getConf( path, environment, callback, context ) {
// relative paths need to be auto-prefixed with the environment
if ( path.match( /^[^\.]/ ) ) {
path = "." + environment + "." + path;
}
if ( !context ) {
context = {
pathsSeen: {}
};
}
// avoid circular references
if ( context.pathsSeen[path... | javascript | function getConf( path, environment, callback, context ) {
// relative paths need to be auto-prefixed with the environment
if ( path.match( /^[^\.]/ ) ) {
path = "." + environment + "." + path;
}
if ( !context ) {
context = {
pathsSeen: {}
};
}
// avoid circular references
if ( context.pathsSeen[path... | [
"function",
"getConf",
"(",
"path",
",",
"environment",
",",
"callback",
",",
"context",
")",
"{",
"// relative paths need to be auto-prefixed with the environment",
"if",
"(",
"path",
".",
"match",
"(",
"/",
"^[^\\.]",
"/",
")",
")",
"{",
"path",
"=",
"\".\"",
... | getConf is responsible for the core logic in the API. It handles applying all extensions and wildcard lookups.
External Params:
@param path the dot notation path to pull from the storage engine
@param environment the name of the environment to pull the configuration for
@param callback
Recursive Params:
@param contex... | [
"getConf",
"is",
"responsible",
"for",
"the",
"core",
"logic",
"in",
"the",
"API",
".",
"It",
"handles",
"applying",
"all",
"extensions",
"and",
"wildcard",
"lookups",
"."
] | c1eb8c78bae9eb059b825978896d0a4ef8ca6771 | https://github.com/BlueRival/confection/blob/c1eb8c78bae9eb059b825978896d0a4ef8ca6771/lib/core/index.js#L131-L191 | train |
BlueRival/confection | lib/core/index.js | getPath | function getPath( req, res, next ) {
var path = req.path.replace( /\..*$/, '' ).replace( /\//g, '.' ).replace( /^\.conf/, '' ).replace( /\.$/, '' ).trim();
if ( path.length < 1 ) {
path = null;
}
var outputFilter = req.path.trim().match( /\.(.*)$/ );
if ( outputFilter ) {
outputFilter = outputFilter[1].trim... | javascript | function getPath( req, res, next ) {
var path = req.path.replace( /\..*$/, '' ).replace( /\//g, '.' ).replace( /^\.conf/, '' ).replace( /\.$/, '' ).trim();
if ( path.length < 1 ) {
path = null;
}
var outputFilter = req.path.trim().match( /\.(.*)$/ );
if ( outputFilter ) {
outputFilter = outputFilter[1].trim... | [
"function",
"getPath",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"var",
"path",
"=",
"req",
".",
"path",
".",
"replace",
"(",
"/",
"\\..*$",
"/",
",",
"''",
")",
".",
"replace",
"(",
"/",
"\\/",
"/",
"g",
",",
"'.'",
")",
".",
"replace",
... | Get the conf path from the URL path.
@param req The express request handle
@param res The response object passed to the middleware
@param next The next function to trigger the next middleware
@return {null} | [
"Get",
"the",
"conf",
"path",
"from",
"the",
"URL",
"path",
"."
] | c1eb8c78bae9eb059b825978896d0a4ef8ca6771 | https://github.com/BlueRival/confection/blob/c1eb8c78bae9eb059b825978896d0a4ef8ca6771/lib/core/index.js#L343-L365 | train |
BlueRival/confection | lib/core/index.js | configureExpress | function configureExpress() {
// create configuration routes
moduleConfig.express.get( /^\/conf.*/, checkAuth, getPath, getMiddlewareWrapper( onGetConf ) );
moduleConfig.express.post( /^\/conf.*/, storeRequestBody, checkAuth, getPath, getMiddlewareWrapper( onPostConf ) );
moduleConfig.express.delete( /^\/conf.*/, ... | javascript | function configureExpress() {
// create configuration routes
moduleConfig.express.get( /^\/conf.*/, checkAuth, getPath, getMiddlewareWrapper( onGetConf ) );
moduleConfig.express.post( /^\/conf.*/, storeRequestBody, checkAuth, getPath, getMiddlewareWrapper( onPostConf ) );
moduleConfig.express.delete( /^\/conf.*/, ... | [
"function",
"configureExpress",
"(",
")",
"{",
"// create configuration routes",
"moduleConfig",
".",
"express",
".",
"get",
"(",
"/",
"^\\/conf.*",
"/",
",",
"checkAuth",
",",
"getPath",
",",
"getMiddlewareWrapper",
"(",
"onGetConf",
")",
")",
";",
"moduleConfig"... | Configures the express instance. | [
"Configures",
"the",
"express",
"instance",
"."
] | c1eb8c78bae9eb059b825978896d0a4ef8ca6771 | https://github.com/BlueRival/confection/blob/c1eb8c78bae9eb059b825978896d0a4ef8ca6771/lib/core/index.js#L386-L397 | train |
BlueRival/confection | lib/core/index.js | getMiddlewareWrapper | function getMiddlewareWrapper( middleware ) {
return function ( req, res, next ) {
try {
middleware( req, res, next );
}
catch ( e ) {
getResponder( req, res )( 500 );
}
};
} | javascript | function getMiddlewareWrapper( middleware ) {
return function ( req, res, next ) {
try {
middleware( req, res, next );
}
catch ( e ) {
getResponder( req, res )( 500 );
}
};
} | [
"function",
"getMiddlewareWrapper",
"(",
"middleware",
")",
"{",
"return",
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"try",
"{",
"middleware",
"(",
"req",
",",
"res",
",",
"next",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"getRespo... | This wrapper simply traps any uncaught exceptions.
@param middleware The middleware function to wrap
@return {Function} The wrapper function to pass to express | [
"This",
"wrapper",
"simply",
"traps",
"any",
"uncaught",
"exceptions",
"."
] | c1eb8c78bae9eb059b825978896d0a4ef8ca6771 | https://github.com/BlueRival/confection/blob/c1eb8c78bae9eb059b825978896d0a4ef8ca6771/lib/core/index.js#L405-L414 | train |
BlueRival/confection | lib/core/index.js | getResponder | function getResponder( req, res ) {
return function ( code, body, contentType ) {
if ( code !== 200 ) {
body = "";
contentType = "text/html; charset=utf-8";
}
if ( !contentType ) {
contentType = "text/html; charset=utf-8";
}
res.writeHead( code, {
"Content-type": contentType
} );
res.end... | javascript | function getResponder( req, res ) {
return function ( code, body, contentType ) {
if ( code !== 200 ) {
body = "";
contentType = "text/html; charset=utf-8";
}
if ( !contentType ) {
contentType = "text/html; charset=utf-8";
}
res.writeHead( code, {
"Content-type": contentType
} );
res.end... | [
"function",
"getResponder",
"(",
"req",
",",
"res",
")",
"{",
"return",
"function",
"(",
"code",
",",
"body",
",",
"contentType",
")",
"{",
"if",
"(",
"code",
"!==",
"200",
")",
"{",
"body",
"=",
"\"\"",
";",
"contentType",
"=",
"\"text/html; charset=utf... | Gets a response generating function. Used in middleware to simplify response logic.
@param res A handle to a response object to send the response to when the responder function is called
@return {Function} The responder function for middleware to call to send a response to a request | [
"Gets",
"a",
"response",
"generating",
"function",
".",
"Used",
"in",
"middleware",
"to",
"simplify",
"response",
"logic",
"."
] | c1eb8c78bae9eb059b825978896d0a4ef8ca6771 | https://github.com/BlueRival/confection/blob/c1eb8c78bae9eb059b825978896d0a4ef8ca6771/lib/core/index.js#L422-L442 | train |
billinghamj/resilient-mailer-sendgrid | lib/sendgrid-provider.js | SendgridProvider | function SendgridProvider(apiUser, apiKey, options) {
if (typeof apiUser !== 'string'
|| typeof apiKey !== 'string') {
throw new Error('Invalid parameters');
}
options = options || {};
if (typeof options.apiSecure === 'undefined')
options.apiSecure = true;
options.apiHostname = options.apiHostname || 'api... | javascript | function SendgridProvider(apiUser, apiKey, options) {
if (typeof apiUser !== 'string'
|| typeof apiKey !== 'string') {
throw new Error('Invalid parameters');
}
options = options || {};
if (typeof options.apiSecure === 'undefined')
options.apiSecure = true;
options.apiHostname = options.apiHostname || 'api... | [
"function",
"SendgridProvider",
"(",
"apiUser",
",",
"apiKey",
",",
"options",
")",
"{",
"if",
"(",
"typeof",
"apiUser",
"!==",
"'string'",
"||",
"typeof",
"apiKey",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Invalid parameters'",
")",
";",... | Creates an instance of the SendGrid email provider.
@constructor
@this {SendgridProvider}
@param {string} apiUser API user for the SendGrid account.
@param {string} apiKey API key for the SendGrid account.
@param {object} [options] Additional optional configuration.
@param {boolean} [options.apiSecure=true] API connec... | [
"Creates",
"an",
"instance",
"of",
"the",
"SendGrid",
"email",
"provider",
"."
] | 89eec1fe27da6ba54dcb32fed111163d81a919f6 | https://github.com/billinghamj/resilient-mailer-sendgrid/blob/89eec1fe27da6ba54dcb32fed111163d81a919f6/lib/sendgrid-provider.js#L19-L36 | train |
me-ventures/microservice-toolkit | src/context.js | consume | function consume(exchangeName, topics, handler) {
// Setup chain
var messageHandler = function(message) {
// make sure we don't have things like buffers
message.content = JSON.parse(message.content.toString());
topics.forEach(function(topic){
statusProvider.setEventConsumeEx... | javascript | function consume(exchangeName, topics, handler) {
// Setup chain
var messageHandler = function(message) {
// make sure we don't have things like buffers
message.content = JSON.parse(message.content.toString());
topics.forEach(function(topic){
statusProvider.setEventConsumeEx... | [
"function",
"consume",
"(",
"exchangeName",
",",
"topics",
",",
"handler",
")",
"{",
"// Setup chain",
"var",
"messageHandler",
"=",
"function",
"(",
"message",
")",
"{",
"// make sure we don't have things like buffers",
"message",
".",
"content",
"=",
"JSON",
".",
... | Create a consume function for an exchange.
Handler should return a promise and accept a message. If this is reject promise the message is not acknowledged. If
the resolves it should contain the original message.
@param exchangeName
@param topics
@param handler | [
"Create",
"a",
"consume",
"function",
"for",
"an",
"exchange",
"."
] | 9aedc9542dffdc274a5142515bd22e92833220d2 | https://github.com/me-ventures/microservice-toolkit/blob/9aedc9542dffdc274a5142515bd22e92833220d2/src/context.js#L35-L58 | train |
me-ventures/microservice-toolkit | src/context.js | consumeShared | function consumeShared(exchangeName, topics, queueName, handler, fetchCount = 1) {
var messageHandler = function(message) {
// make sure we don't have things like buffers
message.content = JSON.parse(message.content.toString());
topics.forEach(function(topic){
statusProvider.set... | javascript | function consumeShared(exchangeName, topics, queueName, handler, fetchCount = 1) {
var messageHandler = function(message) {
// make sure we don't have things like buffers
message.content = JSON.parse(message.content.toString());
topics.forEach(function(topic){
statusProvider.set... | [
"function",
"consumeShared",
"(",
"exchangeName",
",",
"topics",
",",
"queueName",
",",
"handler",
",",
"fetchCount",
"=",
"1",
")",
"{",
"var",
"messageHandler",
"=",
"function",
"(",
"message",
")",
"{",
"// make sure we don't have things like buffers",
"message",... | Create a consume function for an exchange using a shared queue. This queue can be used by other workers and the messages
will be shared round-robin.
Handler should return a promise and accept a message. If this is reject promise the message is not acknowledged. If
the resolves it should contain the original message.
... | [
"Create",
"a",
"consume",
"function",
"for",
"an",
"exchange",
"using",
"a",
"shared",
"queue",
".",
"This",
"queue",
"can",
"be",
"used",
"by",
"other",
"workers",
"and",
"the",
"messages",
"will",
"be",
"shared",
"round",
"-",
"robin",
"."
] | 9aedc9542dffdc274a5142515bd22e92833220d2 | https://github.com/me-ventures/microservice-toolkit/blob/9aedc9542dffdc274a5142515bd22e92833220d2/src/context.js#L73-L95 | train |
integreat-io/great-uri-template | lib/filters/upper.js | upper | function upper (value) {
if (value === null || value === undefined) {
return value
}
return String.prototype.toUpperCase.call(value)
} | javascript | function upper (value) {
if (value === null || value === undefined) {
return value
}
return String.prototype.toUpperCase.call(value)
} | [
"function",
"upper",
"(",
"value",
")",
"{",
"if",
"(",
"value",
"===",
"null",
"||",
"value",
"===",
"undefined",
")",
"{",
"return",
"value",
"}",
"return",
"String",
".",
"prototype",
".",
"toUpperCase",
".",
"call",
"(",
"value",
")",
"}"
] | Returns the value in upper case.
@param {string} value - The value
@returns {string} Upper case value | [
"Returns",
"the",
"value",
"in",
"upper",
"case",
"."
] | 0e896ead0567737cf31a4a8b76a26cfa6ce60759 | https://github.com/integreat-io/great-uri-template/blob/0e896ead0567737cf31a4a8b76a26cfa6ce60759/lib/filters/upper.js#L6-L11 | train |
phelpstream/svp | lib/functions/iftr.js | iftr | function iftr(conditionResult, trueValue, falseValue) {
if (conditionResult && (0, _is.isDefined)(trueValue)) return trueValue;
if (!conditionResult && (0, _is.isDefined)(falseValue)) return falseValue;
} | javascript | function iftr(conditionResult, trueValue, falseValue) {
if (conditionResult && (0, _is.isDefined)(trueValue)) return trueValue;
if (!conditionResult && (0, _is.isDefined)(falseValue)) return falseValue;
} | [
"function",
"iftr",
"(",
"conditionResult",
",",
"trueValue",
",",
"falseValue",
")",
"{",
"if",
"(",
"conditionResult",
"&&",
"(",
"0",
",",
"_is",
".",
"isDefined",
")",
"(",
"trueValue",
")",
")",
"return",
"trueValue",
";",
"if",
"(",
"!",
"condition... | If Then Return | [
"If",
"Then",
"Return"
] | 2f99adb9c5d0709e567264bba896d6a59f6a0a59 | https://github.com/phelpstream/svp/blob/2f99adb9c5d0709e567264bba896d6a59f6a0a59/lib/functions/iftr.js#L11-L14 | train |
telyn/node-jrc | lib/message.js | function() {
switch(self.command) {
case constants.WHOIS:
return (self.params[0][0] == 'A');
case constants.PASSWORD:
return true;
case constants.NUMERICINFO:
case constants.GENERALINFO: // client-to-server
... | javascript | function() {
switch(self.command) {
case constants.WHOIS:
return (self.params[0][0] == 'A');
case constants.PASSWORD:
return true;
case constants.NUMERICINFO:
case constants.GENERALINFO: // client-to-server
... | [
"function",
"(",
")",
"{",
"switch",
"(",
"self",
".",
"command",
")",
"{",
"case",
"constants",
".",
"WHOIS",
":",
"return",
"(",
"self",
".",
"params",
"[",
"0",
"]",
"[",
"0",
"]",
"==",
"'A'",
")",
";",
"case",
"constants",
".",
"PASSWORD",
"... | returns true for commands like HcCreatures | [
"returns",
"true",
"for",
"commands",
"like",
"HcCreatures"
] | c91b8d0a7d95856b7650b815234d8ab77f06b3f5 | https://github.com/telyn/node-jrc/blob/c91b8d0a7d95856b7650b815234d8ab77f06b3f5/lib/message.js#L13-L27 | train | |
CHENXCHEN/merges-utils | lib/index.js | merge | function merge(need, options, level){
// 如果没有传第三个参数,默认无限递归右边覆盖左边
if (level == undefined) level = -1;
if (options === undefined) options = {};
if (need.length == 1) return need[0];
var res = {};
for (var i = 0; i < need.length; i++){
_merge(res, need[i], options, level - 1);
}
ret... | javascript | function merge(need, options, level){
// 如果没有传第三个参数,默认无限递归右边覆盖左边
if (level == undefined) level = -1;
if (options === undefined) options = {};
if (need.length == 1) return need[0];
var res = {};
for (var i = 0; i < need.length; i++){
_merge(res, need[i], options, level - 1);
}
ret... | [
"function",
"merge",
"(",
"need",
",",
"options",
",",
"level",
")",
"{",
"// 如果没有传第三个参数,默认无限递归右边覆盖左边",
"if",
"(",
"level",
"==",
"undefined",
")",
"level",
"=",
"-",
"1",
";",
"if",
"(",
"options",
"===",
"undefined",
")",
"options",
"=",
"{",
"}",
";... | global merge function
@param {Array} need need to merge
@param {Object} options options for merge method
@param {Number} level merge level
@return {Object} the result of merges | [
"global",
"merge",
"function"
] | 5fde6058ba791c58102a109ac4ac20e0afe7ebe7 | https://github.com/CHENXCHEN/merges-utils/blob/5fde6058ba791c58102a109ac4ac20e0afe7ebe7/lib/index.js#L47-L57 | train |
meltmedia/node-usher | lib/decider/tasks/loop.js | Loop | function Loop(name, deps, fragment, loopFn, options) {
if (!(this instanceof Loop)) {
return new Loop(name, deps, fragment, loopFn, options);
}
Task.apply(this, Array.prototype.slice.call(arguments));
this.fragment = fragment;
this.loopFn = (_.isFunction(loopFn)) ? loopFn : function (input) { return [i... | javascript | function Loop(name, deps, fragment, loopFn, options) {
if (!(this instanceof Loop)) {
return new Loop(name, deps, fragment, loopFn, options);
}
Task.apply(this, Array.prototype.slice.call(arguments));
this.fragment = fragment;
this.loopFn = (_.isFunction(loopFn)) ? loopFn : function (input) { return [i... | [
"function",
"Loop",
"(",
"name",
",",
"deps",
",",
"fragment",
",",
"loopFn",
",",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Loop",
")",
")",
"{",
"return",
"new",
"Loop",
"(",
"name",
",",
"deps",
",",
"fragment",
",",
"loop... | The loop executes in batches to help alleviate rate limit exceptions
The number of items to proccess per batch and the delay between batches are both
configurable
@constructor | [
"The",
"loop",
"executes",
"in",
"batches",
"to",
"help",
"alleviate",
"rate",
"limit",
"exceptions",
"The",
"number",
"of",
"items",
"to",
"proccess",
"per",
"batch",
"and",
"the",
"delay",
"between",
"batches",
"are",
"both",
"configurable"
] | fe6183bf7097f84bef935e8d9c19463accc08ad6 | https://github.com/meltmedia/node-usher/blob/fe6183bf7097f84bef935e8d9c19463accc08ad6/lib/decider/tasks/loop.js#L26-L37 | train |
quantumpayments/media | lib/qpm_media.js | createTables | function createTables() {
// setup config
var config = require('../config/config.js')
var db = wc_db.getConnection(config.db)
var sql = fs.readFileSync('model/Media.sql').toString()
debug(sql)
db.query(sql).then(function(ret){
debug(ret)
}).catch(function(err) {
debug(err)
})
var sql = fs.re... | javascript | function createTables() {
// setup config
var config = require('../config/config.js')
var db = wc_db.getConnection(config.db)
var sql = fs.readFileSync('model/Media.sql').toString()
debug(sql)
db.query(sql).then(function(ret){
debug(ret)
}).catch(function(err) {
debug(err)
})
var sql = fs.re... | [
"function",
"createTables",
"(",
")",
"{",
"// setup config",
"var",
"config",
"=",
"require",
"(",
"'../config/config.js'",
")",
"var",
"db",
"=",
"wc_db",
".",
"getConnection",
"(",
"config",
".",
"db",
")",
"var",
"sql",
"=",
"fs",
".",
"readFileSync",
... | Creates database tables. | [
"Creates",
"database",
"tables",
"."
] | b53034e6dd2a94dca950e60a49e403aceaa1cdf1 | https://github.com/quantumpayments/media/blob/b53034e6dd2a94dca950e60a49e403aceaa1cdf1/lib/qpm_media.js#L37-L98 | train |
quantumpayments/media | lib/qpm_media.js | addMedia | function addMedia(uri, contentType, safe) {
if (!uri || uri === '') {
return 'You must enter a valid uri'
}
safe = safe || 0
return new Promise((resolve, reject) => {
var config = require('../config/config.js')
var conn = wc_db.getConnection(config.db)
// sniff content type
if (!contentTyp... | javascript | function addMedia(uri, contentType, safe) {
if (!uri || uri === '') {
return 'You must enter a valid uri'
}
safe = safe || 0
return new Promise((resolve, reject) => {
var config = require('../config/config.js')
var conn = wc_db.getConnection(config.db)
// sniff content type
if (!contentTyp... | [
"function",
"addMedia",
"(",
"uri",
",",
"contentType",
",",
"safe",
")",
"{",
"if",
"(",
"!",
"uri",
"||",
"uri",
"===",
"''",
")",
"{",
"return",
"'You must enter a valid uri'",
"}",
"safe",
"=",
"safe",
"||",
"0",
"return",
"new",
"Promise",
"(",
"(... | Adds media to the database
@param {string} uri The URI to add.
@param {string} contentType The content type.
@param {Object} callback The callback. | [
"Adds",
"media",
"to",
"the",
"database"
] | b53034e6dd2a94dca950e60a49e403aceaa1cdf1 | https://github.com/quantumpayments/media/blob/b53034e6dd2a94dca950e60a49e403aceaa1cdf1/lib/qpm_media.js#L106-L175 | train |
quantumpayments/media | lib/qpm_media.js | addRating | function addRating(rating, config, conn) {
// validate
if (!rating.uri || rating.uri === '') {
return 'You must enter a valid uri'
}
if (!rating.reviewer || rating.reviewer === '') {
return 'You must enter a valid reviewer'
}
if (isNaN(rating.rating)) {
return 'You must enter a valid rating'
... | javascript | function addRating(rating, config, conn) {
// validate
if (!rating.uri || rating.uri === '') {
return 'You must enter a valid uri'
}
if (!rating.reviewer || rating.reviewer === '') {
return 'You must enter a valid reviewer'
}
if (isNaN(rating.rating)) {
return 'You must enter a valid rating'
... | [
"function",
"addRating",
"(",
"rating",
",",
"config",
",",
"conn",
")",
"{",
"// validate",
"if",
"(",
"!",
"rating",
".",
"uri",
"||",
"rating",
".",
"uri",
"===",
"''",
")",
"{",
"return",
"'You must enter a valid uri'",
"}",
"if",
"(",
"!",
"rating",... | Adds rating to the database
@param {Object} rating The rating to add.
@param {Object} config The optional config.
@param {Object} conn The optional db connection.
@return {Object} Promise with success or fail. | [
"Adds",
"rating",
"to",
"the",
"database"
] | b53034e6dd2a94dca950e60a49e403aceaa1cdf1 | https://github.com/quantumpayments/media/blob/b53034e6dd2a94dca950e60a49e403aceaa1cdf1/lib/qpm_media.js#L185-L224 | train |
quantumpayments/media | lib/qpm_media.js | addMeta | function addMeta(params, config, conn) {
params = params || {}
// validate
if (!params.uri || params.uri === '') {
return 'You must enter a valid uri'
}
// defaults
config = config || require('../config/config.js')
debug(params)
// main
// main
return new Promise((resolve, reject) => {
... | javascript | function addMeta(params, config, conn) {
params = params || {}
// validate
if (!params.uri || params.uri === '') {
return 'You must enter a valid uri'
}
// defaults
config = config || require('../config/config.js')
debug(params)
// main
// main
return new Promise((resolve, reject) => {
... | [
"function",
"addMeta",
"(",
"params",
",",
"config",
",",
"conn",
")",
"{",
"params",
"=",
"params",
"||",
"{",
"}",
"// validate",
"if",
"(",
"!",
"params",
".",
"uri",
"||",
"params",
".",
"uri",
"===",
"''",
")",
"{",
"return",
"'You must enter a va... | Adds a meta record to the database
@param {Object} params The meta info.
@param {Object} config The optional config.
@param {Object} conn The optional db connection.
@return {Object} Promise with success or fail. | [
"Adds",
"a",
"meta",
"record",
"to",
"the",
"database"
] | b53034e6dd2a94dca950e60a49e403aceaa1cdf1 | https://github.com/quantumpayments/media/blob/b53034e6dd2a94dca950e60a49e403aceaa1cdf1/lib/qpm_media.js#L274-L315 | train |
quantumpayments/media | lib/qpm_media.js | addFragment | function addFragment(params, config, conn) {
// validate
if ( (!params.id || params.id === '') && (!params.uri || params.uri === '') ) {
return 'You must enter a valid id or uri'
}
// defaults
config = config || require('../config/config.js')
debug(params)
// main
return new Promise((resolve, re... | javascript | function addFragment(params, config, conn) {
// validate
if ( (!params.id || params.id === '') && (!params.uri || params.uri === '') ) {
return 'You must enter a valid id or uri'
}
// defaults
config = config || require('../config/config.js')
debug(params)
// main
return new Promise((resolve, re... | [
"function",
"addFragment",
"(",
"params",
",",
"config",
",",
"conn",
")",
"{",
"// validate",
"if",
"(",
"(",
"!",
"params",
".",
"id",
"||",
"params",
".",
"id",
"===",
"''",
")",
"&&",
"(",
"!",
"params",
".",
"uri",
"||",
"params",
".",
"uri",
... | Adds a fragment to the database
@param {Object} params The parameter info.
@param {Object} config The optional config.
@param {Object} conn The optional db connection.
@return {Object} Promise with success or fail. | [
"Adds",
"a",
"fragment",
"to",
"the",
"database"
] | b53034e6dd2a94dca950e60a49e403aceaa1cdf1 | https://github.com/quantumpayments/media/blob/b53034e6dd2a94dca950e60a49e403aceaa1cdf1/lib/qpm_media.js#L324-L359 | train |
quantumpayments/media | lib/qpm_media.js | insertRating | function insertRating(rating, config, conn) {
// validate
if ( (!rating.uri || rating.uri === '') && (!rating.cacheURI || rating.cacheURI === '') ) {
return 'You must enter a valid uri'
}
if (!rating.reviewer || rating.reviewer === '') {
return 'You must enter a valid reviewer'
}
// defaults
co... | javascript | function insertRating(rating, config, conn) {
// validate
if ( (!rating.uri || rating.uri === '') && (!rating.cacheURI || rating.cacheURI === '') ) {
return 'You must enter a valid uri'
}
if (!rating.reviewer || rating.reviewer === '') {
return 'You must enter a valid reviewer'
}
// defaults
co... | [
"function",
"insertRating",
"(",
"rating",
",",
"config",
",",
"conn",
")",
"{",
"// validate",
"if",
"(",
"(",
"!",
"rating",
".",
"uri",
"||",
"rating",
".",
"uri",
"===",
"''",
")",
"&&",
"(",
"!",
"rating",
".",
"cacheURI",
"||",
"rating",
".",
... | Inserts rating to the database
@param {Object} rating The rating to add.
@param {Object} config The optional config.
@param {Object} conn The optional db connection.
@return {Object} Promise with success or fail. | [
"Inserts",
"rating",
"to",
"the",
"database"
] | b53034e6dd2a94dca950e60a49e403aceaa1cdf1 | https://github.com/quantumpayments/media/blob/b53034e6dd2a94dca950e60a49e403aceaa1cdf1/lib/qpm_media.js#L413-L451 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.