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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
iolo/express-toybox | logger.js | logger | function logger(options) {
DEBUG && debug('configure http logger middleware', options);
var format;
if (typeof options === 'string') {
format = options;
options = {};
} else {
format = options.format || 'combined';
delete options.format;
}
if (options.debug) {
... | javascript | function logger(options) {
DEBUG && debug('configure http logger middleware', options);
var format;
if (typeof options === 'string') {
format = options;
options = {};
} else {
format = options.format || 'combined';
delete options.format;
}
if (options.debug) {
... | [
"function",
"logger",
"(",
"options",
")",
"{",
"DEBUG",
"&&",
"debug",
"(",
"'configure http logger middleware'",
",",
"options",
")",
";",
"var",
"format",
";",
"if",
"(",
"typeof",
"options",
"===",
"'string'",
")",
"{",
"format",
"=",
"options",
";",
"... | logger middleware using "morgan" or "debug".
@param {*|String} options or log format.
@param {Number|Boolean} [options.buffer]
@param {Boolean} [options.immediate]
@param {Function} [options.skip]
@param {*} [options.stream]
@param {String} [options.format='combined'] log format. "combined", "common", "dev", "short", ... | [
"logger",
"middleware",
"using",
"morgan",
"or",
"debug",
"."
] | c375a1388cfc167017e8dcd2325e71ca86ccb994 | https://github.com/iolo/express-toybox/blob/c375a1388cfc167017e8dcd2325e71ca86ccb994/logger.js#L24-L55 | train |
gretro/robs-fetch | samples/simple-example/src/store/reducer.js | handlePeopleRetrieved | function handlePeopleRetrieved(state, action) {
if (action.error) {
return {
...state,
people: null,
error: getErrorDescription(action.payload)
};
}
return {
...state,
people: action.payload,
error: null
};
} | javascript | function handlePeopleRetrieved(state, action) {
if (action.error) {
return {
...state,
people: null,
error: getErrorDescription(action.payload)
};
}
return {
...state,
people: action.payload,
error: null
};
} | [
"function",
"handlePeopleRetrieved",
"(",
"state",
",",
"action",
")",
"{",
"if",
"(",
"action",
".",
"error",
")",
"{",
"return",
"{",
"...",
"state",
",",
"people",
":",
"null",
",",
"error",
":",
"getErrorDescription",
"(",
"action",
".",
"payload",
"... | Handling the response of the REST Action. | [
"Handling",
"the",
"response",
"of",
"the",
"REST",
"Action",
"."
] | 65178913bbfeea2c9bdd064c6afed6704c50f79a | https://github.com/gretro/robs-fetch/blob/65178913bbfeea2c9bdd064c6afed6704c50f79a/samples/simple-example/src/store/reducer.js#L18-L32 | train |
francejs/karma-effroi | lib/effroi.js | function(element, options) {
var event;
options = options || {};
options.canBubble = ('false' === options.canBubble ? false : true);
options.cancelable = ('false' === options.cancelable ? false : true);
options.view = options.view || window;
try {
event = new Event(options.type, {
... | javascript | function(element, options) {
var event;
options = options || {};
options.canBubble = ('false' === options.canBubble ? false : true);
options.cancelable = ('false' === options.cancelable ? false : true);
options.view = options.view || window;
try {
event = new Event(options.type, {
... | [
"function",
"(",
"element",
",",
"options",
")",
"{",
"var",
"event",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"options",
".",
"canBubble",
"=",
"(",
"'false'",
"===",
"options",
".",
"canBubble",
"?",
"false",
":",
"true",
")",
";",
"opt... | dispatch a simple event | [
"dispatch",
"a",
"simple",
"event"
] | 7a624211bfd51927618e12e56439924da741d3b1 | https://github.com/francejs/karma-effroi/blob/7a624211bfd51927618e12e56439924da741d3b1/lib/effroi.js#L1560-L1589 | train | |
magicdawn/impress-router-table | index.js | bind | function bind(method, path, controller, action) {
let handler = controllerRegistry[controller] && controllerRegistry[controller][action]
if (!handler) {
console.warn(`can't bind route ${ path } to unknown action ${ controller }.${ action }`)
return
}
const policyName = LocalUtil.getPolicyNa... | javascript | function bind(method, path, controller, action) {
let handler = controllerRegistry[controller] && controllerRegistry[controller][action]
if (!handler) {
console.warn(`can't bind route ${ path } to unknown action ${ controller }.${ action }`)
return
}
const policyName = LocalUtil.getPolicyNa... | [
"function",
"bind",
"(",
"method",
",",
"path",
",",
"controller",
",",
"action",
")",
"{",
"let",
"handler",
"=",
"controllerRegistry",
"[",
"controller",
"]",
"&&",
"controllerRegistry",
"[",
"controller",
"]",
"[",
"action",
"]",
"if",
"(",
"!",
"handle... | bind path to controller & action | [
"bind",
"path",
"to",
"controller",
"&",
"action"
] | 03a6925fba1be5982d67b1a41f3095f3d2da8a46 | https://github.com/magicdawn/impress-router-table/blob/03a6925fba1be5982d67b1a41f3095f3d2da8a46/index.js#L114-L130 | train |
tunnckoCore/online-branch-exist | index.js | verify | function verify(pattern, opts, callback) {
if (typeof opts === 'function') {
callback = opts;
opts = {};
}
if (typeof callback !== 'function') {
errs.type('expect `callback` to be function');
}
if (typeof pattern !== 'string') {
errs.type('expect `pattern` to be string');
}
if (!regex.test... | javascript | function verify(pattern, opts, callback) {
if (typeof opts === 'function') {
callback = opts;
opts = {};
}
if (typeof callback !== 'function') {
errs.type('expect `callback` to be function');
}
if (typeof pattern !== 'string') {
errs.type('expect `pattern` to be string');
}
if (!regex.test... | [
"function",
"verify",
"(",
"pattern",
",",
"opts",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"opts",
"===",
"'function'",
")",
"{",
"callback",
"=",
"opts",
";",
"opts",
"=",
"{",
"}",
";",
"}",
"if",
"(",
"typeof",
"callback",
"!==",
"'functio... | Verify the given arguments.
@param {String} `pattern`
@param {Object} `opts`
@param {Function} `callback`
@return {Object}
@api private | [
"Verify",
"the",
"given",
"arguments",
"."
] | 5913351870ee22c44083a2f47b6d3196aa5a9df4 | https://github.com/tunnckoCore/online-branch-exist/blob/5913351870ee22c44083a2f47b6d3196aa5a9df4/index.js#L85-L119 | train |
rafrex/current-input | src/index.js | updateCurrentInput | function updateCurrentInput(input) {
if (input !== currentInput) {
body.classList.remove(`current-input-${currentInput}`);
body.classList.add(`current-input-${input}`);
currentInput = input;
}
} | javascript | function updateCurrentInput(input) {
if (input !== currentInput) {
body.classList.remove(`current-input-${currentInput}`);
body.classList.add(`current-input-${input}`);
currentInput = input;
}
} | [
"function",
"updateCurrentInput",
"(",
"input",
")",
"{",
"if",
"(",
"input",
"!==",
"currentInput",
")",
"{",
"body",
".",
"classList",
".",
"remove",
"(",
"`",
"${",
"currentInput",
"}",
"`",
")",
";",
"body",
".",
"classList",
".",
"add",
"(",
"`",
... | set current input class on body | [
"set",
"current",
"input",
"class",
"on",
"body"
] | d8b1764a235d1c0113083f8dde0f85c4f97f6376 | https://github.com/rafrex/current-input/blob/d8b1764a235d1c0113083f8dde0f85c4f97f6376/src/index.js#L9-L15 | train |
Gozala/method | core.js | ArrayindexOf | function ArrayindexOf(thing) {
var index = 0;
var count = this.length;
while (index < count) {
if (this[index] === thing) return index
index = index + 1
}
return -1
} | javascript | function ArrayindexOf(thing) {
var index = 0;
var count = this.length;
while (index < count) {
if (this[index] === thing) return index
index = index + 1
}
return -1
} | [
"function",
"ArrayindexOf",
"(",
"thing",
")",
"{",
"var",
"index",
"=",
"0",
";",
"var",
"count",
"=",
"this",
".",
"length",
";",
"while",
"(",
"index",
"<",
"count",
")",
"{",
"if",
"(",
"this",
"[",
"index",
"]",
"===",
"thing",
")",
"return",
... | IE does not really has indexOf on arrays so we shim if that's what we're dealing with. | [
"IE",
"does",
"not",
"really",
"has",
"indexOf",
"on",
"arrays",
"so",
"we",
"shim",
"if",
"that",
"s",
"what",
"we",
"re",
"dealing",
"with",
"."
] | 4c1d83ef7b9524af2a7b35e6fed3b42316af2820 | https://github.com/Gozala/method/blob/4c1d83ef7b9524af2a7b35e6fed3b42316af2820/core.js#L10-L18 | train |
godaddy/joi-of-cql | index.js | int64 | function int64(name) {
return joi.alternatives().meta({ cql: true, type: name }).try(
// a string that represents a number that is larger than JavaScript can handle
joi.string().regex(/^\-?\d{1,19}$/m),
// any integer that can be represented in JavaScript
joi.number().integer()
);
} | javascript | function int64(name) {
return joi.alternatives().meta({ cql: true, type: name }).try(
// a string that represents a number that is larger than JavaScript can handle
joi.string().regex(/^\-?\d{1,19}$/m),
// any integer that can be represented in JavaScript
joi.number().integer()
);
} | [
"function",
"int64",
"(",
"name",
")",
"{",
"return",
"joi",
".",
"alternatives",
"(",
")",
".",
"meta",
"(",
"{",
"cql",
":",
"true",
",",
"type",
":",
"name",
"}",
")",
".",
"try",
"(",
"// a string that represents a number that is larger than JavaScript can... | Used for creating Int64 with string and number alternative formats
@param {String} name - the type of int64 value
@returns {Joi} - the validator | [
"Used",
"for",
"creating",
"Int64",
"with",
"string",
"and",
"number",
"alternative",
"formats"
] | e9498171eaf4b068aab4b76b8ba762c8ed657f23 | https://github.com/godaddy/joi-of-cql/blob/e9498171eaf4b068aab4b76b8ba762c8ed657f23/index.js#L123-L130 | train |
godaddy/joi-of-cql | index.js | decimal | function decimal(name) {
return joi.alternatives().meta({ cql: true, type: name }).try(
// a string that represents a number that is larger than JavaScript can handle
joi.string().regex(/^\-?\d+(\.\d+)?$/m),
// any number that can be represented in JavaScript
joi.number()
);
} | javascript | function decimal(name) {
return joi.alternatives().meta({ cql: true, type: name }).try(
// a string that represents a number that is larger than JavaScript can handle
joi.string().regex(/^\-?\d+(\.\d+)?$/m),
// any number that can be represented in JavaScript
joi.number()
);
} | [
"function",
"decimal",
"(",
"name",
")",
"{",
"return",
"joi",
".",
"alternatives",
"(",
")",
".",
"meta",
"(",
"{",
"cql",
":",
"true",
",",
"type",
":",
"name",
"}",
")",
".",
"try",
"(",
"// a string that represents a number that is larger than JavaScript c... | Used for creating decimal with string and number alternative formats
@param {String} name - the type of decimal value
@returns {Joi} - the validator | [
"Used",
"for",
"creating",
"decimal",
"with",
"string",
"and",
"number",
"alternative",
"formats"
] | e9498171eaf4b068aab4b76b8ba762c8ed657f23 | https://github.com/godaddy/joi-of-cql/blob/e9498171eaf4b068aab4b76b8ba762c8ed657f23/index.js#L138-L145 | train |
godaddy/joi-of-cql | index.js | function (keyType, valueType) {
var meta = findMeta(valueType);
return joi.object().meta({
cql: true,
type: 'map',
mapType: ['text', meta.type],
serialize: convertMap(meta.serialize),
deserialize: convertMap(meta.deserialize)
}).pattern(/[\-\w]+/, valueType);
} | javascript | function (keyType, valueType) {
var meta = findMeta(valueType);
return joi.object().meta({
cql: true,
type: 'map',
mapType: ['text', meta.type],
serialize: convertMap(meta.serialize),
deserialize: convertMap(meta.deserialize)
}).pattern(/[\-\w]+/, valueType);
} | [
"function",
"(",
"keyType",
",",
"valueType",
")",
"{",
"var",
"meta",
"=",
"findMeta",
"(",
"valueType",
")",
";",
"return",
"joi",
".",
"object",
"(",
")",
".",
"meta",
"(",
"{",
"cql",
":",
"true",
",",
"type",
":",
"'map'",
",",
"mapType",
":",... | Create a joi object that can validate a `map` for Cassandra.
@param {(String|Joi)} keyType - used for validating the fields of the object, ignored currently
@param {Joi} valueType - used for validating the values of the fields in the object
@returns {Joi} - the validator | [
"Create",
"a",
"joi",
"object",
"that",
"can",
"validate",
"a",
"map",
"for",
"Cassandra",
"."
] | e9498171eaf4b068aab4b76b8ba762c8ed657f23 | https://github.com/godaddy/joi-of-cql/blob/e9498171eaf4b068aab4b76b8ba762c8ed657f23/index.js#L298-L307 | train | |
godaddy/joi-of-cql | index.js | function (type) {
var meta = findMeta(type);
var set = joi.array().sparse(false).unique().items(type);
return joi.alternatives().meta({
cql: true,
type: 'set',
setType: meta.type,
serialize: convertArray(meta.serialize),
deserialize: convertArray(meta.deserialize)
}).try(se... | javascript | function (type) {
var meta = findMeta(type);
var set = joi.array().sparse(false).unique().items(type);
return joi.alternatives().meta({
cql: true,
type: 'set',
setType: meta.type,
serialize: convertArray(meta.serialize),
deserialize: convertArray(meta.deserialize)
}).try(se... | [
"function",
"(",
"type",
")",
"{",
"var",
"meta",
"=",
"findMeta",
"(",
"type",
")",
";",
"var",
"set",
"=",
"joi",
".",
"array",
"(",
")",
".",
"sparse",
"(",
"false",
")",
".",
"unique",
"(",
")",
".",
"items",
"(",
"type",
")",
";",
"return"... | Create a joi object that can validate a `set` for Cassandra.
@param {Joi} type - used for validating the values of the set
@returns {Joi} - the validator | [
"Create",
"a",
"joi",
"object",
"that",
"can",
"validate",
"a",
"set",
"for",
"Cassandra",
"."
] | e9498171eaf4b068aab4b76b8ba762c8ed657f23 | https://github.com/godaddy/joi-of-cql/blob/e9498171eaf4b068aab4b76b8ba762c8ed657f23/index.js#L314-L327 | train | |
godaddy/joi-of-cql | index.js | function (type) {
var meta = findMeta(type);
var list = joi.array().sparse(false).items(type);
return joi.alternatives().meta({
cql: true,
type: 'list',
listType: meta.type,
serialize: convertArray(meta.serialize),
deserialize: convertArray(meta.deserialize)
}).try(list, jo... | javascript | function (type) {
var meta = findMeta(type);
var list = joi.array().sparse(false).items(type);
return joi.alternatives().meta({
cql: true,
type: 'list',
listType: meta.type,
serialize: convertArray(meta.serialize),
deserialize: convertArray(meta.deserialize)
}).try(list, jo... | [
"function",
"(",
"type",
")",
"{",
"var",
"meta",
"=",
"findMeta",
"(",
"type",
")",
";",
"var",
"list",
"=",
"joi",
".",
"array",
"(",
")",
".",
"sparse",
"(",
"false",
")",
".",
"items",
"(",
"type",
")",
";",
"return",
"joi",
".",
"alternative... | Create a joi object that can validate a `list` for Cassandra.
@param {Joi} type - used for validating the values in the list
@returns {Joi} - the validator | [
"Create",
"a",
"joi",
"object",
"that",
"can",
"validate",
"a",
"list",
"for",
"Cassandra",
"."
] | e9498171eaf4b068aab4b76b8ba762c8ed657f23 | https://github.com/godaddy/joi-of-cql/blob/e9498171eaf4b068aab4b76b8ba762c8ed657f23/index.js#L334-L349 | train | |
godaddy/joi-of-cql | index.js | function (validator, options) {
var when = options.default;
var fn = function (context, config) {
if ((when === config.context.operation) ||
(when === 'update' && ['create', 'update'].indexOf(config.context.operation) > -1)
) {
return new Date().toISOString();
}
return ... | javascript | function (validator, options) {
var when = options.default;
var fn = function (context, config) {
if ((when === config.context.operation) ||
(when === 'update' && ['create', 'update'].indexOf(config.context.operation) > -1)
) {
return new Date().toISOString();
}
return ... | [
"function",
"(",
"validator",
",",
"options",
")",
"{",
"var",
"when",
"=",
"options",
".",
"default",
";",
"var",
"fn",
"=",
"function",
"(",
"context",
",",
"config",
")",
"{",
"if",
"(",
"(",
"when",
"===",
"config",
".",
"context",
".",
"operatio... | Set a default date based on the contextual operation in which the joi object is being validated.
If 'update' is the specified default, default the value on both 'update' && 'create' operations
otherwise only default if the operation matches the specified default.
@param {Joi} validator - the object that is having a d... | [
"Set",
"a",
"default",
"date",
"based",
"on",
"the",
"contextual",
"operation",
"in",
"which",
"the",
"joi",
"object",
"is",
"being",
"validated",
"."
] | e9498171eaf4b068aab4b76b8ba762c8ed657f23 | https://github.com/godaddy/joi-of-cql/blob/e9498171eaf4b068aab4b76b8ba762c8ed657f23/index.js#L394-L406 | train | |
godaddy/joi-of-cql | index.js | function (validator, options) {
var fn = function (context, config) {
if (config.context.operation === 'create')
return options.default === 'empty' ? '00000000-0000-0000-0000-000000000000' : uuid[options.default]();
return undef;
};
fn.isJoi = true;
return validator.default(fn);
} | javascript | function (validator, options) {
var fn = function (context, config) {
if (config.context.operation === 'create')
return options.default === 'empty' ? '00000000-0000-0000-0000-000000000000' : uuid[options.default]();
return undef;
};
fn.isJoi = true;
return validator.default(fn);
} | [
"function",
"(",
"validator",
",",
"options",
")",
"{",
"var",
"fn",
"=",
"function",
"(",
"context",
",",
"config",
")",
"{",
"if",
"(",
"config",
".",
"context",
".",
"operation",
"===",
"'create'",
")",
"return",
"options",
".",
"default",
"===",
"'... | Set a default uuid when the the contextual operation is 'create'.
@param {Joi} validator - the object that is having a default set
@param {DefaultSpecifierOptions} options - the options for setting the default
@param {String} options.default - [empty, v1, v4]
@returns {Joi} - the new validator | [
"Set",
"a",
"default",
"uuid",
"when",
"the",
"the",
"contextual",
"operation",
"is",
"create",
"."
] | e9498171eaf4b068aab4b76b8ba762c8ed657f23 | https://github.com/godaddy/joi-of-cql/blob/e9498171eaf4b068aab4b76b8ba762c8ed657f23/index.js#L416-L424 | train | |
godaddy/joi-of-cql | index.js | defaultify | function defaultify(type, validator, options) {
return options && options.default ? defaults[type](validator, options) : validator;
} | javascript | function defaultify(type, validator, options) {
return options && options.default ? defaults[type](validator, options) : validator;
} | [
"function",
"defaultify",
"(",
"type",
",",
"validator",
",",
"options",
")",
"{",
"return",
"options",
"&&",
"options",
".",
"default",
"?",
"defaults",
"[",
"type",
"]",
"(",
"validator",
",",
"options",
")",
":",
"validator",
";",
"}"
] | Create a default based on a string identifier if one is provided.
@param {String} type - types of defaults [date, uuid]
@param {Joi} validator - the object being defaulted
@param {DefaultSpecifierOptions} options - the options for creating the default
@returns {Joi} - the new validator, possibly with a default | [
"Create",
"a",
"default",
"based",
"on",
"a",
"string",
"identifier",
"if",
"one",
"is",
"provided",
"."
] | e9498171eaf4b068aab4b76b8ba762c8ed657f23 | https://github.com/godaddy/joi-of-cql/blob/e9498171eaf4b068aab4b76b8ba762c8ed657f23/index.js#L435-L437 | train |
godaddy/joi-of-cql | index.js | findMeta | function findMeta(any, key) {
key = key || 'cql';
var meta = (any.describe().meta || []).filter(function (m) {
return key in m;
});
return meta[meta.length - 1];
} | javascript | function findMeta(any, key) {
key = key || 'cql';
var meta = (any.describe().meta || []).filter(function (m) {
return key in m;
});
return meta[meta.length - 1];
} | [
"function",
"findMeta",
"(",
"any",
",",
"key",
")",
"{",
"key",
"=",
"key",
"||",
"'cql'",
";",
"var",
"meta",
"=",
"(",
"any",
".",
"describe",
"(",
")",
".",
"meta",
"||",
"[",
"]",
")",
".",
"filter",
"(",
"function",
"(",
"m",
")",
"{",
... | Find the meta object that has the key given.
@param {Joi} any - the validator to be inspected
@param {String} key - the name of the field in the meta object that we are looking for
@returns {JoiMetaDefinition} - the result | [
"Find",
"the",
"meta",
"object",
"that",
"has",
"the",
"key",
"given",
"."
] | e9498171eaf4b068aab4b76b8ba762c8ed657f23 | https://github.com/godaddy/joi-of-cql/blob/e9498171eaf4b068aab4b76b8ba762c8ed657f23/index.js#L446-L452 | train |
godaddy/joi-of-cql | index.js | convertToJsonOnValidate | function convertToJsonOnValidate(any) {
var validate = any._validate;
any._validate = function () {
var result = validate.apply(this, arguments);
if (!result.error && result.value) {
result.value = JSON.stringify(result.value);
}
return result;
};
return any;
} | javascript | function convertToJsonOnValidate(any) {
var validate = any._validate;
any._validate = function () {
var result = validate.apply(this, arguments);
if (!result.error && result.value) {
result.value = JSON.stringify(result.value);
}
return result;
};
return any;
} | [
"function",
"convertToJsonOnValidate",
"(",
"any",
")",
"{",
"var",
"validate",
"=",
"any",
".",
"_validate",
";",
"any",
".",
"_validate",
"=",
"function",
"(",
")",
"{",
"var",
"result",
"=",
"validate",
".",
"apply",
"(",
"this",
",",
"arguments",
")"... | Convert the resulting object back to JSON after validation.
* Warning: This relies on the internal structure of a joi object
@param {Joi} any - the object that will be extended to convert the given value
@returns {Joi} - the extended validator | [
"Convert",
"the",
"resulting",
"object",
"back",
"to",
"JSON",
"after",
"validation",
"."
] | e9498171eaf4b068aab4b76b8ba762c8ed657f23 | https://github.com/godaddy/joi-of-cql/blob/e9498171eaf4b068aab4b76b8ba762c8ed657f23/index.js#L473-L483 | train |
godaddy/joi-of-cql | index.js | defaultUuid | function defaultUuid(options, version) {
if (options && options.default) {
if ([version, 'empty'].indexOf(options.default) > -1) {
return options.default;
}
return version;
}
return undef;
} | javascript | function defaultUuid(options, version) {
if (options && options.default) {
if ([version, 'empty'].indexOf(options.default) > -1) {
return options.default;
}
return version;
}
return undef;
} | [
"function",
"defaultUuid",
"(",
"options",
",",
"version",
")",
"{",
"if",
"(",
"options",
"&&",
"options",
".",
"default",
")",
"{",
"if",
"(",
"[",
"version",
",",
"'empty'",
"]",
".",
"indexOf",
"(",
"options",
".",
"default",
")",
">",
"-",
"1",
... | Ensure that `uuid` type joi objects have a default specified.
@param {DefaultSpecifierOptions} [options] - possible default options
@property {String} options.default - [empty, v1, v4]
@param {String} version - the uuid version that should be used as a default if no other default is specified
@returns {(Undefined|Stri... | [
"Ensure",
"that",
"uuid",
"type",
"joi",
"objects",
"have",
"a",
"default",
"specified",
"."
] | e9498171eaf4b068aab4b76b8ba762c8ed657f23 | https://github.com/godaddy/joi-of-cql/blob/e9498171eaf4b068aab4b76b8ba762c8ed657f23/index.js#L493-L501 | train |
pagespace/pagespace | static/inpage/inpage-edit.js | handleAdminEvents | function handleAdminEvents() {
//listen for clicks that bubble in up in the admin bar
document.body.addEventListener('click', function (ev) {
if(ev.target.hasAttribute('data-edit-include')) {
launchPluginEditor(ev.target);
} else if(ev.target.hasAttribute('data-... | javascript | function handleAdminEvents() {
//listen for clicks that bubble in up in the admin bar
document.body.addEventListener('click', function (ev) {
if(ev.target.hasAttribute('data-edit-include')) {
launchPluginEditor(ev.target);
} else if(ev.target.hasAttribute('data-... | [
"function",
"handleAdminEvents",
"(",
")",
"{",
"//listen for clicks that bubble in up in the admin bar",
"document",
".",
"body",
".",
"addEventListener",
"(",
"'click'",
",",
"function",
"(",
"ev",
")",
"{",
"if",
"(",
"ev",
".",
"target",
".",
"hasAttribute",
"... | Handle Admin Events | [
"Handle",
"Admin",
"Events"
] | 943c45ddd9aaa4f3136e1ba4c2593aa0289daf43 | https://github.com/pagespace/pagespace/blob/943c45ddd9aaa4f3136e1ba4c2593aa0289daf43/static/inpage/inpage-edit.js#L15-L36 | train |
pagespace/pagespace | static/inpage/inpage-edit.js | getIncludeDragData | function getIncludeDragData(ev) {
var data = ev.dataTransfer.getData('include-info');
return data ? JSON.parse(data) : null;
} | javascript | function getIncludeDragData(ev) {
var data = ev.dataTransfer.getData('include-info');
return data ? JSON.parse(data) : null;
} | [
"function",
"getIncludeDragData",
"(",
"ev",
")",
"{",
"var",
"data",
"=",
"ev",
".",
"dataTransfer",
".",
"getData",
"(",
"'include-info'",
")",
";",
"return",
"data",
"?",
"JSON",
".",
"parse",
"(",
"data",
")",
":",
"null",
";",
"}"
] | utils for drag+drop | [
"utils",
"for",
"drag",
"+",
"drop"
] | 943c45ddd9aaa4f3136e1ba4c2593aa0289daf43 | https://github.com/pagespace/pagespace/blob/943c45ddd9aaa4f3136e1ba4c2593aa0289daf43/static/inpage/inpage-edit.js#L257-L260 | train |
envone/ember-runner | index.js | function(callback) {
helpers.walk(buildInfo.srcApps, function(err, results) {
if (err) return callback("Error walking files.");
callback(null, results);
});
} | javascript | function(callback) {
helpers.walk(buildInfo.srcApps, function(err, results) {
if (err) return callback("Error walking files.");
callback(null, results);
});
} | [
"function",
"(",
"callback",
")",
"{",
"helpers",
".",
"walk",
"(",
"buildInfo",
".",
"srcApps",
",",
"function",
"(",
"err",
",",
"results",
")",
"{",
"if",
"(",
"err",
")",
"return",
"callback",
"(",
"\"Error walking files.\"",
")",
";",
"callback",
"(... | Load apps files | [
"Load",
"apps",
"files"
] | 2bd8c0a86cc251f4ea7b00885b804646f0a2190c | https://github.com/envone/ember-runner/blob/2bd8c0a86cc251f4ea7b00885b804646f0a2190c/index.js#L280-L285 | train | |
envone/ember-runner | index.js | function(callback) {
helpers.walk(buildInfo.srcVendors, function(err, results) {
if (err) return callback("Error walking files.");
callback(null, results);
});
} | javascript | function(callback) {
helpers.walk(buildInfo.srcVendors, function(err, results) {
if (err) return callback("Error walking files.");
callback(null, results);
});
} | [
"function",
"(",
"callback",
")",
"{",
"helpers",
".",
"walk",
"(",
"buildInfo",
".",
"srcVendors",
",",
"function",
"(",
"err",
",",
"results",
")",
"{",
"if",
"(",
"err",
")",
"return",
"callback",
"(",
"\"Error walking files.\"",
")",
";",
"callback",
... | Load vendors files | [
"Load",
"vendors",
"files"
] | 2bd8c0a86cc251f4ea7b00885b804646f0a2190c | https://github.com/envone/ember-runner/blob/2bd8c0a86cc251f4ea7b00885b804646f0a2190c/index.js#L287-L292 | train | |
IonicaBizau/cb-buffer | example/index.js | getUniqueRandomNumberAsync | function getUniqueRandomNumberAsync(callback) {
if (cb.check(callback)) { return; }
setTimeout(() => {
debugger
cb.done(Math.random());
}, 1000);
} | javascript | function getUniqueRandomNumberAsync(callback) {
if (cb.check(callback)) { return; }
setTimeout(() => {
debugger
cb.done(Math.random());
}, 1000);
} | [
"function",
"getUniqueRandomNumberAsync",
"(",
"callback",
")",
"{",
"if",
"(",
"cb",
".",
"check",
"(",
"callback",
")",
")",
"{",
"return",
";",
"}",
"setTimeout",
"(",
"(",
")",
"=>",
"{",
"debugger",
"cb",
".",
"done",
"(",
"Math",
".",
"random",
... | Callbacks a random unique number after 1 sec | [
"Callbacks",
"a",
"random",
"unique",
"number",
"after",
"1",
"sec"
] | cf4d6b6c4b77500bb5f68fa569745cdfb9f54f42 | https://github.com/IonicaBizau/cb-buffer/blob/cf4d6b6c4b77500bb5f68fa569745cdfb9f54f42/example/index.js#L8-L14 | train |
feedhenry/fh-service-auth | lib/models/service.js | initServiceModel | function initServiceModel(connectionUrl) {
log.logger.debug("initServiceModel ", {connectionUrl: connectionUrl});
if (!connectionUrl) {
log.logger.error("No Connection Url Specified");
return null;
}
//If the connection has not already been created, create it and initialise the Service Schema For That ... | javascript | function initServiceModel(connectionUrl) {
log.logger.debug("initServiceModel ", {connectionUrl: connectionUrl});
if (!connectionUrl) {
log.logger.error("No Connection Url Specified");
return null;
}
//If the connection has not already been created, create it and initialise the Service Schema For That ... | [
"function",
"initServiceModel",
"(",
"connectionUrl",
")",
"{",
"log",
".",
"logger",
".",
"debug",
"(",
"\"initServiceModel \"",
",",
"{",
"connectionUrl",
":",
"connectionUrl",
"}",
")",
";",
"if",
"(",
"!",
"connectionUrl",
")",
"{",
"log",
".",
"logger",... | Creating A connection To The Domain Database If It Does Not Already Exist
@param connectionUrl - Full Mongo Connection String For A Domain Database
@returns {null} | [
"Creating",
"A",
"connection",
"To",
"The",
"Domain",
"Database",
"If",
"It",
"Does",
"Not",
"Already",
"Exist"
] | ba3b8d736fb495c00d03c38ec2dc456f516b28c8 | https://github.com/feedhenry/fh-service-auth/blob/ba3b8d736fb495c00d03c38ec2dc456f516b28c8/lib/models/service.js#L173-L203 | train |
kgryte/eval-serialize-typed-array | examples/index.js | create | function create( arr ) {
var f = '';
f += 'return function fill( len ) {';
f += 'var arr = new Array( len );';
f += 'for ( var i = 0; i < len; i++ ) {';
f += 'arr[ i ] = ' + serialize( arr ) + ';';
f += '}';
f += 'return arr;';
f += '}';
return ( new Function( f ) )();
} | javascript | function create( arr ) {
var f = '';
f += 'return function fill( len ) {';
f += 'var arr = new Array( len );';
f += 'for ( var i = 0; i < len; i++ ) {';
f += 'arr[ i ] = ' + serialize( arr ) + ';';
f += '}';
f += 'return arr;';
f += '}';
return ( new Function( f ) )();
} | [
"function",
"create",
"(",
"arr",
")",
"{",
"var",
"f",
"=",
"''",
";",
"f",
"+=",
"'return function fill( len ) {'",
";",
"f",
"+=",
"'var arr = new Array( len );'",
";",
"f",
"+=",
"'for ( var i = 0; i < len; i++ ) {'",
";",
"f",
"+=",
"'arr[ i ] = '",
"+",
"s... | Returns a function to create a filled array. | [
"Returns",
"a",
"function",
"to",
"create",
"a",
"filled",
"array",
"."
] | 65cb14bd7b5417b555b1003d46f0ee7e94adebf8 | https://github.com/kgryte/eval-serialize-typed-array/blob/65cb14bd7b5417b555b1003d46f0ee7e94adebf8/examples/index.js#L9-L19 | train |
patrickfatrick/harsh | dist/harsh.js | hash | function hash() {
var ids = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [Math.floor(Math.random() * 100)];
var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
var base = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 36;
if (!ids.splice) {... | javascript | function hash() {
var ids = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [Math.floor(Math.random() * 100)];
var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
var base = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 36;
if (!ids.splice) {... | [
"function",
"hash",
"(",
")",
"{",
"var",
"ids",
"=",
"arguments",
".",
"length",
">",
"0",
"&&",
"arguments",
"[",
"0",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"0",
"]",
":",
"[",
"Math",
".",
"floor",
"(",
"Math",
".",
"random",
"(",
")... | Takes a number and a radix base, outputs a salted hash
@param {Array} ids list of ids to hash
@param {Number} n number of salts to add to the hash
@param {Number} base radix base, 16 through 36 allowed
@return {Object} a hash object containing the hashes as well as info needed to reverse them | [
"Takes",
"a",
"number",
"and",
"a",
"radix",
"base",
"outputs",
"a",
"salted",
"hash"
] | 5a99a5b0e8c30889a99cd68aabe52635724e2c8d | https://github.com/patrickfatrick/harsh/blob/5a99a5b0e8c30889a99cd68aabe52635724e2c8d/dist/harsh.js#L38-L70 | train |
patrickfatrick/harsh | dist/harsh.js | bunch | function bunch() {
var num = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
var base = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 36;
if (typeof num !== 'number') {
throw new Type... | javascript | function bunch() {
var num = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
var base = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 36;
if (typeof num !== 'number') {
throw new Type... | [
"function",
"bunch",
"(",
")",
"{",
"var",
"num",
"=",
"arguments",
".",
"length",
">",
"0",
"&&",
"arguments",
"[",
"0",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"0",
"]",
":",
"1",
";",
"var",
"n",
"=",
"arguments",
".",
"length",
">",
"... | Creates a specified number of random tokens
@param {Number} num number of tokens to create
@param {Number} n number of salts to add to each hash
@param {Number} base radix base, 16 through 36 allowed
@return {Object} a hash object containing the hashes as well as info needed to reverse them | [
"Creates",
"a",
"specified",
"number",
"of",
"random",
"tokens"
] | 5a99a5b0e8c30889a99cd68aabe52635724e2c8d | https://github.com/patrickfatrick/harsh/blob/5a99a5b0e8c30889a99cd68aabe52635724e2c8d/dist/harsh.js#L91-L126 | train |
ashpool/telldus-live-promise | lib/api.js | request | function request(path, json) {
return new Promise(function (resolve, reject) {
oauth._performSecureRequest(config.telldusToken,
config.telldusTokenSecret,
'GET',
'https://api.telldus.com/json' + path,
null,
json,
!!json ? 'application/json' : null, function (err... | javascript | function request(path, json) {
return new Promise(function (resolve, reject) {
oauth._performSecureRequest(config.telldusToken,
config.telldusTokenSecret,
'GET',
'https://api.telldus.com/json' + path,
null,
json,
!!json ? 'application/json' : null, function (err... | [
"function",
"request",
"(",
"path",
",",
"json",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"oauth",
".",
"_performSecureRequest",
"(",
"config",
".",
"telldusToken",
",",
"config",
".",
"telldusTokenSecre... | Performs a secure oauth request to Telldus API.
@param path
@param json optional
@returns {Promise} | [
"Performs",
"a",
"secure",
"oauth",
"request",
"to",
"Telldus",
"API",
"."
] | ee13365136da640d78907f468b19580bdd8545d8 | https://github.com/ashpool/telldus-live-promise/blob/ee13365136da640d78907f468b19580bdd8545d8/lib/api.js#L27-L39 | train |
segmentio/clear-ajax | lib/index.js | clearAjax | function clearAjax() {
each(function(request) {
try {
request.onload = noop;
request.onerror = noop;
request.onabort = noop;
request.onreadystatechange = noop;
each(function(added) {
request[added[0]].apply(request, added[1]);
}, request._queue || []);
request.abo... | javascript | function clearAjax() {
each(function(request) {
try {
request.onload = noop;
request.onerror = noop;
request.onabort = noop;
request.onreadystatechange = noop;
each(function(added) {
request[added[0]].apply(request, added[1]);
}, request._queue || []);
request.abo... | [
"function",
"clearAjax",
"(",
")",
"{",
"each",
"(",
"function",
"(",
"request",
")",
"{",
"try",
"{",
"request",
".",
"onload",
"=",
"noop",
";",
"request",
".",
"onerror",
"=",
"noop",
";",
"request",
".",
"onabort",
"=",
"noop",
";",
"request",
".... | Clear all active AJAX requests.
@api public | [
"Clear",
"all",
"active",
"AJAX",
"requests",
"."
] | 930f38b0ffb7fef082ce7227168ad3d28ab9ea71 | https://github.com/segmentio/clear-ajax/blob/930f38b0ffb7fef082ce7227168ad3d28ab9ea71/lib/index.js#L45-L61 | train |
ffan-fe/fancyui | lib/datetimepicker/index.js | getMoment | function getMoment(modelValue) {
return moment(modelValue, angular.isString(modelValue) ? configuration.parseFormat : undefined)
} | javascript | function getMoment(modelValue) {
return moment(modelValue, angular.isString(modelValue) ? configuration.parseFormat : undefined)
} | [
"function",
"getMoment",
"(",
"modelValue",
")",
"{",
"return",
"moment",
"(",
"modelValue",
",",
"angular",
".",
"isString",
"(",
"modelValue",
")",
"?",
"configuration",
".",
"parseFormat",
":",
"undefined",
")",
"}"
] | Converts a time value into a moment.
This function is now necessary because moment logs a warning when parsing a string without a format.
@param modelValue
a time value in any of the supported formats (Date, moment, milliseconds, and string)
@returns {moment}
representing the specified time value. | [
"Converts",
"a",
"time",
"value",
"into",
"a",
"moment",
"."
] | e6077985d0e939976da435d7eeaa28886359e6e7 | https://github.com/ffan-fe/fancyui/blob/e6077985d0e939976da435d7eeaa28886359e6e7/lib/datetimepicker/index.js#L358-L360 | train |
ChrisAckerman/politic | src/main/util/debounce.js | debounce | function debounce(callback) {
let timeout = null;
return () => {
if (timeout !== null) {
return;
}
timeout = setTimeout(() => {
timeout = null;
callback();
}, 0);
}
} | javascript | function debounce(callback) {
let timeout = null;
return () => {
if (timeout !== null) {
return;
}
timeout = setTimeout(() => {
timeout = null;
callback();
}, 0);
}
} | [
"function",
"debounce",
"(",
"callback",
")",
"{",
"let",
"timeout",
"=",
"null",
";",
"return",
"(",
")",
"=>",
"{",
"if",
"(",
"timeout",
"!==",
"null",
")",
"{",
"return",
";",
"}",
"timeout",
"=",
"setTimeout",
"(",
"(",
")",
"=>",
"{",
"timeou... | Wrap a function so that multiple calls result in a single invocation on the next event loop tick. This function
cannot accept arguments or return a value.
@param {function()} callback - Function to be wrapped.
@returns {function()} Wrapped function. | [
"Wrap",
"a",
"function",
"so",
"that",
"multiple",
"calls",
"result",
"in",
"a",
"single",
"invocation",
"on",
"the",
"next",
"event",
"loop",
"tick",
".",
"This",
"function",
"cannot",
"accept",
"arguments",
"or",
"return",
"a",
"value",
"."
] | dd90696c933b4afe5ef1f88fafea2cd0adb8cd3b | https://github.com/ChrisAckerman/politic/blob/dd90696c933b4afe5ef1f88fafea2cd0adb8cd3b/src/main/util/debounce.js#L8-L21 | train |
aledbf/deis-api | lib/keys.js | add | function add(keyId, sshKey, callback) {
try {
sshKeyparser(sshKey);
}catch (e) {
return callback(e);
}
commons.post(format('/%s/keys/', deis.version), {
id: keyId || deis.username,
'public': sshKey
},callback);
} | javascript | function add(keyId, sshKey, callback) {
try {
sshKeyparser(sshKey);
}catch (e) {
return callback(e);
}
commons.post(format('/%s/keys/', deis.version), {
id: keyId || deis.username,
'public': sshKey
},callback);
} | [
"function",
"add",
"(",
"keyId",
",",
"sshKey",
",",
"callback",
")",
"{",
"try",
"{",
"sshKeyparser",
"(",
"sshKey",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"return",
"callback",
"(",
"e",
")",
";",
"}",
"commons",
".",
"post",
"(",
"format",
... | add an SSH key | [
"add",
"an",
"SSH",
"key"
] | f0833789998032b11221a3a617bb566ade1fcc13 | https://github.com/aledbf/deis-api/blob/f0833789998032b11221a3a617bb566ade1fcc13/lib/keys.js#L18-L29 | train |
aledbf/deis-api | lib/keys.js | remove | function remove(keyId, callback) {
commons.del(format('/%s/keys/%s', deis.version, keyId), callback);
} | javascript | function remove(keyId, callback) {
commons.del(format('/%s/keys/%s', deis.version, keyId), callback);
} | [
"function",
"remove",
"(",
"keyId",
",",
"callback",
")",
"{",
"commons",
".",
"del",
"(",
"format",
"(",
"'/%s/keys/%s'",
",",
"deis",
".",
"version",
",",
"keyId",
")",
",",
"callback",
")",
";",
"}"
] | remove an SSH key | [
"remove",
"an",
"SSH",
"key"
] | f0833789998032b11221a3a617bb566ade1fcc13 | https://github.com/aledbf/deis-api/blob/f0833789998032b11221a3a617bb566ade1fcc13/lib/keys.js#L34-L36 | train |
AndiDittrich/Node.Logging-Facility | logging-facility.js | exposeAPI | function exposeAPI(log){
return {
emerg: log(_loglevel.EMERGENCY),
emergency: log(_loglevel.EMERGENCY),
alert: log(_loglevel.ALERT),
crit: log(_loglevel.CRITICAL),
critical: log(_loglevel.CRITICAL),
error: log(_loglevel.ERROR),
err: log(_loglevel.ERROR),
... | javascript | function exposeAPI(log){
return {
emerg: log(_loglevel.EMERGENCY),
emergency: log(_loglevel.EMERGENCY),
alert: log(_loglevel.ALERT),
crit: log(_loglevel.CRITICAL),
critical: log(_loglevel.CRITICAL),
error: log(_loglevel.ERROR),
err: log(_loglevel.ERROR),
... | [
"function",
"exposeAPI",
"(",
"log",
")",
"{",
"return",
"{",
"emerg",
":",
"log",
"(",
"_loglevel",
".",
"EMERGENCY",
")",
",",
"emergency",
":",
"log",
"(",
"_loglevel",
".",
"EMERGENCY",
")",
",",
"alert",
":",
"log",
"(",
"_loglevel",
".",
"ALERT",... | utility function to expose logging api | [
"utility",
"function",
"to",
"expose",
"logging",
"api"
] | 015ec21aca6b257a4fbbf3170474c2b96752958a | https://github.com/AndiDittrich/Node.Logging-Facility/blob/015ec21aca6b257a4fbbf3170474c2b96752958a/logging-facility.js#L13-L36 | train |
AndiDittrich/Node.Logging-Facility | logging-facility.js | createLogger | function createLogger(instance){
// generator
function log(level){
return function(...args){
// logging backend available ?
if (_loggingBackends.length > 0){
// trigger backends
_loggingBackends.forEach(function(backend){
bac... | javascript | function createLogger(instance){
// generator
function log(level){
return function(...args){
// logging backend available ?
if (_loggingBackends.length > 0){
// trigger backends
_loggingBackends.forEach(function(backend){
bac... | [
"function",
"createLogger",
"(",
"instance",
")",
"{",
"// generator",
"function",
"log",
"(",
"level",
")",
"{",
"return",
"function",
"(",
"...",
"args",
")",
"{",
"// logging backend available ?",
"if",
"(",
"_loggingBackends",
".",
"length",
">",
"0",
")",... | generator to create the logging instance | [
"generator",
"to",
"create",
"the",
"logging",
"instance"
] | 015ec21aca6b257a4fbbf3170474c2b96752958a | https://github.com/AndiDittrich/Node.Logging-Facility/blob/015ec21aca6b257a4fbbf3170474c2b96752958a/logging-facility.js#L39-L61 | train |
AndiDittrich/Node.Logging-Facility | logging-facility.js | getLogger | function getLogger(instance){
// create new instance if not available
if (!_loggerInstances[instance]){
_loggerInstances[instance] = createLogger(instance);
}
return _loggerInstances[instance];
} | javascript | function getLogger(instance){
// create new instance if not available
if (!_loggerInstances[instance]){
_loggerInstances[instance] = createLogger(instance);
}
return _loggerInstances[instance];
} | [
"function",
"getLogger",
"(",
"instance",
")",
"{",
"// create new instance if not available",
"if",
"(",
"!",
"_loggerInstances",
"[",
"instance",
"]",
")",
"{",
"_loggerInstances",
"[",
"instance",
"]",
"=",
"createLogger",
"(",
"instance",
")",
";",
"}",
"ret... | utility function to fetch or create loggers by namespace | [
"utility",
"function",
"to",
"fetch",
"or",
"create",
"loggers",
"by",
"namespace"
] | 015ec21aca6b257a4fbbf3170474c2b96752958a | https://github.com/AndiDittrich/Node.Logging-Facility/blob/015ec21aca6b257a4fbbf3170474c2b96752958a/logging-facility.js#L64-L71 | train |
AndiDittrich/Node.Logging-Facility | logging-facility.js | addLoggingBackend | function addLoggingBackend(backend, minLoglevel=99){
// function or string input supported
if (typeof backend === 'function'){
_loggingBackends.push(backend);
// lookup
}else{
if (backend === 'fancy-cli'){
_loggingBackends.push(_fancyCliLogger(minLoglevel));
}else if... | javascript | function addLoggingBackend(backend, minLoglevel=99){
// function or string input supported
if (typeof backend === 'function'){
_loggingBackends.push(backend);
// lookup
}else{
if (backend === 'fancy-cli'){
_loggingBackends.push(_fancyCliLogger(minLoglevel));
}else if... | [
"function",
"addLoggingBackend",
"(",
"backend",
",",
"minLoglevel",
"=",
"99",
")",
"{",
"// function or string input supported",
"if",
"(",
"typeof",
"backend",
"===",
"'function'",
")",
"{",
"_loggingBackends",
".",
"push",
"(",
"backend",
")",
";",
"// lookup"... | add multiple upstream backends | [
"add",
"multiple",
"upstream",
"backends"
] | 015ec21aca6b257a4fbbf3170474c2b96752958a | https://github.com/AndiDittrich/Node.Logging-Facility/blob/015ec21aca6b257a4fbbf3170474c2b96752958a/logging-facility.js#L74-L89 | train |
spacemaus/postvox | vox-client/stanza-fetcher.js | StanzaFetcher | function StanzaFetcher(db, getInterchangeSession) {
var self = this;
self.db = db;
self._closed = false;
self.getInterchangeSession = getInterchangeSession;
self._highWaterMarks = new Chain(self._fetchMostRecentStanzaSeq.bind(self));
events.EventEmitter.call(this);
} | javascript | function StanzaFetcher(db, getInterchangeSession) {
var self = this;
self.db = db;
self._closed = false;
self.getInterchangeSession = getInterchangeSession;
self._highWaterMarks = new Chain(self._fetchMostRecentStanzaSeq.bind(self));
events.EventEmitter.call(this);
} | [
"function",
"StanzaFetcher",
"(",
"db",
",",
"getInterchangeSession",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"db",
"=",
"db",
";",
"self",
".",
"_closed",
"=",
"false",
";",
"self",
".",
"getInterchangeSession",
"=",
"getInterchangeSession",... | Fetches stanzas from interchange servers. Also listens for interchange push
messages. | [
"Fetches",
"stanzas",
"from",
"interchange",
"servers",
".",
"Also",
"listens",
"for",
"interchange",
"push",
"messages",
"."
] | de98e5ed37edaee1b1edadf93e15eb8f8d21f457 | https://github.com/spacemaus/postvox/blob/de98e5ed37edaee1b1edadf93e15eb8f8d21f457/vox-client/stanza-fetcher.js#L15-L22 | train |
pqml/dom | lib/render.js | render | function render (vnode, parent, context) {
// render
var i = 0
var rendered = rawRender(vnode)
// mount
if (typeof parent === 'function') {
var nodes = rendered.nodes.length < 2 ? rendered.nodes[0] : rendered.nodes
parent(nodes)
} else if (parent) {
for (i = 0; i < rendered.nodes.length; i++) {... | javascript | function render (vnode, parent, context) {
// render
var i = 0
var rendered = rawRender(vnode)
// mount
if (typeof parent === 'function') {
var nodes = rendered.nodes.length < 2 ? rendered.nodes[0] : rendered.nodes
parent(nodes)
} else if (parent) {
for (i = 0; i < rendered.nodes.length; i++) {... | [
"function",
"render",
"(",
"vnode",
",",
"parent",
",",
"context",
")",
"{",
"// render",
"var",
"i",
"=",
"0",
"var",
"rendered",
"=",
"rawRender",
"(",
"vnode",
")",
"// mount",
"if",
"(",
"typeof",
"parent",
"===",
"'function'",
")",
"{",
"var",
"no... | > Renders a virtual node and mount-it into a `parent` Element
> :warning: `render` always dispatch lifecycle events. Even if you don't pass a parent as 2nd argument, all componentDidMount methods and callback refs will be called. Be carreful!
> :warning: If you render a virtual node inside an already mounted componen... | [
">",
"Renders",
"a",
"virtual",
"node",
"and",
"mount",
"-",
"it",
"into",
"a",
"parent",
"Element"
] | c9dfc7c8237f7662361fc635af4b1e1302260f44 | https://github.com/pqml/dom/blob/c9dfc7c8237f7662361fc635af4b1e1302260f44/lib/render.js#L37-L72 | train |
iolo/express-toybox | errors.js | HttpError | function HttpError(message, status, cause) {
this.status = status || StatusCode.UNKNOWN;
HttpError.super_.call(this, errors.ErrorCode.HTTP + this.status, message || StatusLine[this.status] || StatusLine[StatusCode.UNKNOWN], cause);
} | javascript | function HttpError(message, status, cause) {
this.status = status || StatusCode.UNKNOWN;
HttpError.super_.call(this, errors.ErrorCode.HTTP + this.status, message || StatusLine[this.status] || StatusLine[StatusCode.UNKNOWN], cause);
} | [
"function",
"HttpError",
"(",
"message",
",",
"status",
",",
"cause",
")",
"{",
"this",
".",
"status",
"=",
"status",
"||",
"StatusCode",
".",
"UNKNOWN",
";",
"HttpError",
".",
"super_",
".",
"call",
"(",
"this",
",",
"errors",
".",
"ErrorCode",
".",
"... | abstract superclass for HTTP specific error.
@param {String} [message]
@param {Number} [status=599]
@param {*} [cause]
@constructor
@abstract
@memberOf errors | [
"abstract",
"superclass",
"for",
"HTTP",
"specific",
"error",
"."
] | c375a1388cfc167017e8dcd2325e71ca86ccb994 | https://github.com/iolo/express-toybox/blob/c375a1388cfc167017e8dcd2325e71ca86ccb994/errors.js#L59-L62 | train |
aaronpowell/bespoke-markdown | lib/bespoke-markdown.js | function(path, callbackSuccess, callbackError) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.status >= 200 && xhr.status < 300) {
callbackSuccess(xhr.responseText);
} else {
callbackError();
}
}
};
xhr.open('... | javascript | function(path, callbackSuccess, callbackError) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.status >= 200 && xhr.status < 300) {
callbackSuccess(xhr.responseText);
} else {
callbackError();
}
}
};
xhr.open('... | [
"function",
"(",
"path",
",",
"callbackSuccess",
",",
"callbackError",
")",
"{",
"var",
"xhr",
"=",
"new",
"XMLHttpRequest",
"(",
")",
";",
"xhr",
".",
"onreadystatechange",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"xhr",
".",
"readyState",
"===",
"4",... | Fetches the content of a file through AJAX.
@param {string} path the path of the file to fetch
@param {Function} callbackSuccess
@param {Function} callbackError | [
"Fetches",
"the",
"content",
"of",
"a",
"file",
"through",
"AJAX",
"."
] | fa518c99647c81b97644feb4a7239210ca875e59 | https://github.com/aaronpowell/bespoke-markdown/blob/fa518c99647c81b97644feb4a7239210ca875e59/lib/bespoke-markdown.js#L42-L59 | train | |
AndiDittrich/Node.mysql-magic | lib/pool-manager.js | initPool | function initPool(name, config){
// new pool
const pool = _mysql.createPool(config);
// create pool wrapper
_pools[name || '_default'] = {
_instance: pool,
getConnection: function(scope){
return _poolConnection.getConnection(pool, scope);
}
}
} | javascript | function initPool(name, config){
// new pool
const pool = _mysql.createPool(config);
// create pool wrapper
_pools[name || '_default'] = {
_instance: pool,
getConnection: function(scope){
return _poolConnection.getConnection(pool, scope);
}
}
} | [
"function",
"initPool",
"(",
"name",
",",
"config",
")",
"{",
"// new pool",
"const",
"pool",
"=",
"_mysql",
".",
"createPool",
"(",
"config",
")",
";",
"// create pool wrapper",
"_pools",
"[",
"name",
"||",
"'_default'",
"]",
"=",
"{",
"_instance",
":",
"... | create new pool | [
"create",
"new",
"pool"
] | f9783ac93f4a5744407781d7875ae68cad58cc48 | https://github.com/AndiDittrich/Node.mysql-magic/blob/f9783ac93f4a5744407781d7875ae68cad58cc48/lib/pool-manager.js#L8-L19 | train |
AndCake/zino | zino-ssr.js | merge | function merge(target) {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
for (var arg, len = args.length, index = 0; arg = args[index], index < len; index += 1) {
for (var all in arg) {
if (typeof HTMLElement !== 'u... | javascript | function merge(target) {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
for (var arg, len = args.length, index = 0; arg = args[index], index < len; index += 1) {
for (var all in arg) {
if (typeof HTMLElement !== 'u... | [
"function",
"merge",
"(",
"target",
")",
"{",
"for",
"(",
"var",
"_len",
"=",
"arguments",
".",
"length",
",",
"args",
"=",
"Array",
"(",
"_len",
">",
"1",
"?",
"_len",
"-",
"1",
":",
"0",
")",
",",
"_key",
"=",
"1",
";",
"_key",
"<",
"_len",
... | Merges all objects provided as parameters into the first parameter object
@param {...Object} args list of arguments
@return {Object} the merged object (same as first argument) | [
"Merges",
"all",
"objects",
"provided",
"as",
"parameters",
"into",
"the",
"first",
"parameter",
"object"
] | a9d1de87ad80fe2d106fd84a0c20984c0f3ab125 | https://github.com/AndCake/zino/blob/a9d1de87ad80fe2d106fd84a0c20984c0f3ab125/zino-ssr.js#L22-L36 | train |
AndCake/zino | zino-ssr.js | getInnerHTML | function getInnerHTML(node) {
if (!node.children) return '';
if (!isArray(node.children) && typeof HTMLCollection !== 'undefined' && !(node.children instanceof HTMLCollection)) node.children = [node.children];
return (isArray(node) && node || (typeof HTMLCollection !== 'undefined' && node.children instanceof HTMLCo... | javascript | function getInnerHTML(node) {
if (!node.children) return '';
if (!isArray(node.children) && typeof HTMLCollection !== 'undefined' && !(node.children instanceof HTMLCollection)) node.children = [node.children];
return (isArray(node) && node || (typeof HTMLCollection !== 'undefined' && node.children instanceof HTMLCo... | [
"function",
"getInnerHTML",
"(",
"node",
")",
"{",
"if",
"(",
"!",
"node",
".",
"children",
")",
"return",
"''",
";",
"if",
"(",
"!",
"isArray",
"(",
"node",
".",
"children",
")",
"&&",
"typeof",
"HTMLCollection",
"!==",
"'undefined'",
"&&",
"!",
"(",
... | Calculates the HTML structure as a String represented by the VDOM
@param {Object} node - the VDOM node whose inner HTML to generate
@return {String} - the HTML structure representing the VDOM | [
"Calculates",
"the",
"HTML",
"structure",
"as",
"a",
"String",
"represented",
"by",
"the",
"VDOM"
] | a9d1de87ad80fe2d106fd84a0c20984c0f3ab125 | https://github.com/AndCake/zino/blob/a9d1de87ad80fe2d106fd84a0c20984c0f3ab125/zino-ssr.js#L216-L236 | train |
AndCake/zino | zino-ssr.js | createElement | function createElement(node, document) {
var tag = void 0;
if ((typeof node === 'undefined' ? 'undefined' : _typeof(node)) !== 'object') {
// we have a text node, so create one
tag = document.createTextNode('' + node);
} else {
tag = document.createElement(node.tagName);
// add all required attributes
Obje... | javascript | function createElement(node, document) {
var tag = void 0;
if ((typeof node === 'undefined' ? 'undefined' : _typeof(node)) !== 'object') {
// we have a text node, so create one
tag = document.createTextNode('' + node);
} else {
tag = document.createElement(node.tagName);
// add all required attributes
Obje... | [
"function",
"createElement",
"(",
"node",
",",
"document",
")",
"{",
"var",
"tag",
"=",
"void",
"0",
";",
"if",
"(",
"(",
"typeof",
"node",
"===",
"'undefined'",
"?",
"'undefined'",
":",
"_typeof",
"(",
"node",
")",
")",
"!==",
"'object'",
")",
"{",
... | Creates a new DOM node
@param {Object|String} node - a VDOM node
@param {Document} document - the document in which to create the DOM node
@return {Node} - the DOM node created (either a text element or an HTML element) | [
"Creates",
"a",
"new",
"DOM",
"node"
] | a9d1de87ad80fe2d106fd84a0c20984c0f3ab125 | https://github.com/AndCake/zino/blob/a9d1de87ad80fe2d106fd84a0c20984c0f3ab125/zino-ssr.js#L263-L281 | train |
changchang/stream-pkg | lib/composer.js | function(opts) {
EventEmitter.call(this);
opts = opts || {};
this.maxLength = opts.maxLength || DEFAULT_MAX_LENGTH;
this.offset = 0;
this.left = 0;
this.length = 0;
this.buf = null;
this.state = ST_LENGTH;
} | javascript | function(opts) {
EventEmitter.call(this);
opts = opts || {};
this.maxLength = opts.maxLength || DEFAULT_MAX_LENGTH;
this.offset = 0;
this.left = 0;
this.length = 0;
this.buf = null;
this.state = ST_LENGTH;
} | [
"function",
"(",
"opts",
")",
"{",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"this",
".",
"maxLength",
"=",
"opts",
".",
"maxLength",
"||",
"DEFAULT_MAX_LENGTH",
";",
"this",
".",
"offset",
"=",
"0"... | state that something wrong has happened | [
"state",
"that",
"something",
"wrong",
"has",
"happened"
] | b8c2ab9fb2ce537a3c786588e798a7b5be3e11eb | https://github.com/changchang/stream-pkg/blob/b8c2ab9fb2ce537a3c786588e798a7b5be3e11eb/lib/composer.js#L11-L23 | train | |
viskan/log4js-logstash-appender | index.js | send | function send(socket, host, port, loggingObject)
{
var buffer = new Buffer(JSON.stringify(loggingObject));
socket.send(buffer, 0, buffer.length, port, host, function(err, bytes)
{
if (err)
{
console.error('log4js-logstash-appender (%s:%p) - %s', host, port, util.inspect(err));
}
});
} | javascript | function send(socket, host, port, loggingObject)
{
var buffer = new Buffer(JSON.stringify(loggingObject));
socket.send(buffer, 0, buffer.length, port, host, function(err, bytes)
{
if (err)
{
console.error('log4js-logstash-appender (%s:%p) - %s', host, port, util.inspect(err));
}
});
} | [
"function",
"send",
"(",
"socket",
",",
"host",
",",
"port",
",",
"loggingObject",
")",
"{",
"var",
"buffer",
"=",
"new",
"Buffer",
"(",
"JSON",
".",
"stringify",
"(",
"loggingObject",
")",
")",
";",
"socket",
".",
"send",
"(",
"buffer",
",",
"0",
",... | Sends data to logstash. | [
"Sends",
"data",
"to",
"logstash",
"."
] | 08722aa00714abf86866aa45826ced454b32fd14 | https://github.com/viskan/log4js-logstash-appender/blob/08722aa00714abf86866aa45826ced454b32fd14/index.js#L10-L20 | train |
viskan/log4js-logstash-appender | index.js | appender | function appender(configuration)
{
var socket = dgram.createSocket('udp4');
return function(loggingEvent)
{
var loggingObject =
{
name: loggingEvent.categoryName,
message: layout(loggingEvent),
severity: loggingEvent.level.level,
severityText: loggingEvent.level.levelStr,
};
if (configuration.a... | javascript | function appender(configuration)
{
var socket = dgram.createSocket('udp4');
return function(loggingEvent)
{
var loggingObject =
{
name: loggingEvent.categoryName,
message: layout(loggingEvent),
severity: loggingEvent.level.level,
severityText: loggingEvent.level.levelStr,
};
if (configuration.a... | [
"function",
"appender",
"(",
"configuration",
")",
"{",
"var",
"socket",
"=",
"dgram",
".",
"createSocket",
"(",
"'udp4'",
")",
";",
"return",
"function",
"(",
"loggingEvent",
")",
"{",
"var",
"loggingObject",
"=",
"{",
"name",
":",
"loggingEvent",
".",
"c... | Returns the appender. | [
"Returns",
"the",
"appender",
"."
] | 08722aa00714abf86866aa45826ced454b32fd14 | https://github.com/viskan/log4js-logstash-appender/blob/08722aa00714abf86866aa45826ced454b32fd14/index.js#L23-L57 | train |
wilmoore/inarray.js | index.js | inarray | function inarray (list, item) {
list = Object.prototype.toString.call(list) === '[object Array]' ? list : []
var idx = -1
var end = list.length
while (++idx < end) {
if (list[idx] === item) return true
}
return false
} | javascript | function inarray (list, item) {
list = Object.prototype.toString.call(list) === '[object Array]' ? list : []
var idx = -1
var end = list.length
while (++idx < end) {
if (list[idx] === item) return true
}
return false
} | [
"function",
"inarray",
"(",
"list",
",",
"item",
")",
"{",
"list",
"=",
"Object",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"list",
")",
"===",
"'[object Array]'",
"?",
"list",
":",
"[",
"]",
"var",
"idx",
"=",
"-",
"1",
"var",
"end",
"=... | Whether given value exists in array.
@param {Array} list
The list to search.
@param {*} item
The item/value to search for.
@return {Boolean}
Whether given value exists in array. | [
"Whether",
"given",
"value",
"exists",
"in",
"array",
"."
] | 8ea7cd7efb10d46e56ebed08427e0297d525c458 | https://github.com/wilmoore/inarray.js/blob/8ea7cd7efb10d46e56ebed08427e0297d525c458/index.js#L28-L39 | train |
coen-hyde/gulp-cog | index.js | getIncludes | function getIncludes(file) {
var content = String(file.contents);
var matches = [];
while (regexMatch = DIRECTIVE_REGEX.exec(content)) {
matches.push(regexMatch);
}
// For every require fetch it's matching files
var fileLists = _.map(matches, function(match) {
return globMatch(matc... | javascript | function getIncludes(file) {
var content = String(file.contents);
var matches = [];
while (regexMatch = DIRECTIVE_REGEX.exec(content)) {
matches.push(regexMatch);
}
// For every require fetch it's matching files
var fileLists = _.map(matches, function(match) {
return globMatch(matc... | [
"function",
"getIncludes",
"(",
"file",
")",
"{",
"var",
"content",
"=",
"String",
"(",
"file",
".",
"contents",
")",
";",
"var",
"matches",
"=",
"[",
"]",
";",
"while",
"(",
"regexMatch",
"=",
"DIRECTIVE_REGEX",
".",
"exec",
"(",
"content",
")",
")",
... | Get all includes for a file | [
"Get",
"all",
"includes",
"for",
"a",
"file"
] | c96c71e4bbb3426a5580ba3029b003563ab13da6 | https://github.com/coen-hyde/gulp-cog/blob/c96c71e4bbb3426a5580ba3029b003563ab13da6/index.js#L32-L53 | train |
coen-hyde/gulp-cog | index.js | globMatch | function globMatch(match, file) {
var directiveType = match[1];
var globPattern = match[2]; // relative file
// require all files under a directory
if (directiveType.indexOf('_tree') !== -1) {
globPattern = globPattern.concat('/**/*');
directiveType = directiveType.replace('_tree', '');
... | javascript | function globMatch(match, file) {
var directiveType = match[1];
var globPattern = match[2]; // relative file
// require all files under a directory
if (directiveType.indexOf('_tree') !== -1) {
globPattern = globPattern.concat('/**/*');
directiveType = directiveType.replace('_tree', '');
... | [
"function",
"globMatch",
"(",
"match",
",",
"file",
")",
"{",
"var",
"directiveType",
"=",
"match",
"[",
"1",
"]",
";",
"var",
"globPattern",
"=",
"match",
"[",
"2",
"]",
";",
"// relative file",
"// require all files under a directory",
"if",
"(",
"directiveT... | Translate an include match to a glob | [
"Translate",
"an",
"include",
"match",
"to",
"a",
"glob"
] | c96c71e4bbb3426a5580ba3029b003563ab13da6 | https://github.com/coen-hyde/gulp-cog/blob/c96c71e4bbb3426a5580ba3029b003563ab13da6/index.js#L64-L106 | train |
Psychopoulet/node-logs | lib/inputInterfaces.js | _inputInterfaces | function _inputInterfaces (interfaces, msg, type, options, i = 0) {
return i >= interfaces.length ? Promise.resolve() : Promise.resolve().then(() => {
let result = null;
switch (type) {
case "log":
result = interfaces[i].log(msg, options);
break;
case "success":
result = ... | javascript | function _inputInterfaces (interfaces, msg, type, options, i = 0) {
return i >= interfaces.length ? Promise.resolve() : Promise.resolve().then(() => {
let result = null;
switch (type) {
case "log":
result = interfaces[i].log(msg, options);
break;
case "success":
result = ... | [
"function",
"_inputInterfaces",
"(",
"interfaces",
",",
"msg",
",",
"type",
",",
"options",
",",
"i",
"=",
"0",
")",
"{",
"return",
"i",
">=",
"interfaces",
".",
"length",
"?",
"Promise",
".",
"resolve",
"(",
")",
":",
"Promise",
".",
"resolve",
"(",
... | methods
Execute interfaces
@param {Array} interfaces all interfaces
@param {string} msg message to log
@param {string} type log type
@param {null|object} options style options
@param {number} i cursor
@returns {Promise} Operation result | [
"methods",
"Execute",
"interfaces"
] | 907c341ad87452604bf2dc86e92e6bb7220b88e2 | https://github.com/Psychopoulet/node-logs/blob/907c341ad87452604bf2dc86e92e6bb7220b88e2/lib/inputInterfaces.js#L20-L69 | train |
deanlandolt/endo | auth.js | auth | function auth(endo, options) {
options || (options = {});
//
// add token utility methods, binding first options arg
//
endo.createToken = auth.createToken.bind(null, options.sign);
endo.verifyToken = auth.verifyToken.bind(null, options.verify);
//
// verify provided credentials are valid and set user... | javascript | function auth(endo, options) {
options || (options = {});
//
// add token utility methods, binding first options arg
//
endo.createToken = auth.createToken.bind(null, options.sign);
endo.verifyToken = auth.verifyToken.bind(null, options.verify);
//
// verify provided credentials are valid and set user... | [
"function",
"auth",
"(",
"endo",
",",
"options",
")",
"{",
"options",
"||",
"(",
"options",
"=",
"{",
"}",
")",
";",
"//",
"// add token utility methods, binding first options arg",
"//",
"endo",
".",
"createToken",
"=",
"auth",
".",
"createToken",
".",
"bind"... | wrapper to add JWT-based bearer auth to an endo instance | [
"wrapper",
"to",
"add",
"JWT",
"-",
"based",
"bearer",
"auth",
"to",
"an",
"endo",
"instance"
] | e96234226e3a56e5c71b7f68690b5cc98123ed03 | https://github.com/deanlandolt/endo/blob/e96234226e3a56e5c71b7f68690b5cc98123ed03/auth.js#L12-L60 | train |
supercrabtree/tie-dye | hslToRgb.js | hslToRgb | function hslToRgb(h, s, l) {
h /= 360;
s /= 100;
l /= 100;
var r, g, b;
if (s === 0) {
r = g = b = l; // achromatic
} else {
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
var p = 2 * l - q;
r = hueToRgb(p, q, h + 1 / 3);
g = hueToRgb(p, q, h);
b = hueToRgb(p, q, h - 1 / 3);
}
... | javascript | function hslToRgb(h, s, l) {
h /= 360;
s /= 100;
l /= 100;
var r, g, b;
if (s === 0) {
r = g = b = l; // achromatic
} else {
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
var p = 2 * l - q;
r = hueToRgb(p, q, h + 1 / 3);
g = hueToRgb(p, q, h);
b = hueToRgb(p, q, h - 1 / 3);
}
... | [
"function",
"hslToRgb",
"(",
"h",
",",
"s",
",",
"l",
")",
"{",
"h",
"/=",
"360",
";",
"s",
"/=",
"100",
";",
"l",
"/=",
"100",
";",
"var",
"r",
",",
"g",
",",
"b",
";",
"if",
"(",
"s",
"===",
"0",
")",
"{",
"r",
"=",
"g",
"=",
"b",
"... | Convert a color from HSL to RGB
@param {number} h - A value from 0 - 360
@param {number} s - A value from 0 - 100
@param {number} l - A value from 0 - 100
@returns {object} With the signature {r: 0-255, g: 0-255, b: 0-255} | [
"Convert",
"a",
"color",
"from",
"HSL",
"to",
"RGB"
] | 1bf045767ce1a3fcf88450fbf95f72b5646f63df | https://github.com/supercrabtree/tie-dye/blob/1bf045767ce1a3fcf88450fbf95f72b5646f63df/hslToRgb.js#L11-L34 | train |
jfseb/mgnlq_model | js/match/breakdown.js | isCombinableSplit | function isCombinableSplit(tokenized) {
if (tokenized.tokens.length <= 1) {
return false;
}
for (var i = 1; i < tokenized.tokens.length; ++i) {
if (!tokenized.fusable[i]) {
return false;
}
}
return true;
} | javascript | function isCombinableSplit(tokenized) {
if (tokenized.tokens.length <= 1) {
return false;
}
for (var i = 1; i < tokenized.tokens.length; ++i) {
if (!tokenized.fusable[i]) {
return false;
}
}
return true;
} | [
"function",
"isCombinableSplit",
"(",
"tokenized",
")",
"{",
"if",
"(",
"tokenized",
".",
"tokens",
".",
"length",
"<=",
"1",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"1",
";",
"i",
"<",
"tokenized",
".",
"tokens",
".",
"... | Returns true iff tokenized represents multiple words, which
can potenially be added together; | [
"Returns",
"true",
"iff",
"tokenized",
"represents",
"multiple",
"words",
"which",
"can",
"potenially",
"be",
"added",
"together",
";"
] | be1be4406b05718d666d6d0f712c9cadb5169f2c | https://github.com/jfseb/mgnlq_model/blob/be1be4406b05718d666d6d0f712c9cadb5169f2c/js/match/breakdown.js#L157-L167 | train |
mini-eggs/babel-plugin-css-modules | src/main.js | toCssModule | function toCssModule(styles) {
var done = false;
var res;
new modules().load(styles, prefix + uni()).then(function(next) {
done = true;
res = next;
});
deasync.loopWhile(function() {
return !done;
});
return res;
} | javascript | function toCssModule(styles) {
var done = false;
var res;
new modules().load(styles, prefix + uni()).then(function(next) {
done = true;
res = next;
});
deasync.loopWhile(function() {
return !done;
});
return res;
} | [
"function",
"toCssModule",
"(",
"styles",
")",
"{",
"var",
"done",
"=",
"false",
";",
"var",
"res",
";",
"new",
"modules",
"(",
")",
".",
"load",
"(",
"styles",
",",
"prefix",
"+",
"uni",
"(",
")",
")",
".",
"then",
"(",
"function",
"(",
"next",
... | sync create css module | [
"sync",
"create",
"css",
"module"
] | 37960a59a0d732ed70fd8ed27805f360246341d9 | https://github.com/mini-eggs/babel-plugin-css-modules/blob/37960a59a0d732ed70fd8ed27805f360246341d9/src/main.js#L15-L29 | train |
smikes/molfile | lib/parser.js | SDFSplitter | function SDFSplitter(handler) {
parser.SDFTransform.call(this);
this.on('data', function (chunk) {
handler(String(chunk));
});
} | javascript | function SDFSplitter(handler) {
parser.SDFTransform.call(this);
this.on('data', function (chunk) {
handler(String(chunk));
});
} | [
"function",
"SDFSplitter",
"(",
"handler",
")",
"{",
"parser",
".",
"SDFTransform",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"on",
"(",
"'data'",
",",
"function",
"(",
"chunk",
")",
"{",
"handler",
"(",
"String",
"(",
"chunk",
")",
")",
";",
... | A Writable stream that splits an SDF file into individual MOL file segments
suitable for passing to parseMol.
Output is via callback. See SDFTransform for output via Streams API
@class SDFSplitter
@constructor
@method SDFSplitter
@param {Function} callback function to call with molfile data
@return {SDFSplitter} ... | [
"A",
"Writable",
"stream",
"that",
"splits",
"an",
"SDF",
"file",
"into",
"individual",
"MOL",
"file",
"segments",
"suitable",
"for",
"passing",
"to",
"parseMol",
"."
] | d851fab7f963b27deca945255be9eb0d26dd57bd | https://github.com/smikes/molfile/blob/d851fab7f963b27deca945255be9eb0d26dd57bd/lib/parser.js#L521-L527 | train |
jwilm/pygments-async | lib/pygmentize_options.js | PygmentizeOptions | function PygmentizeOptions (options) {
if(!(this instanceof PygmentizeOptions))
return new PygmentizeOptions(options);
if(options.lexer && validate.lexer.test(options.lexer))
this.lexer = options.lexer;
if(options.guess && !this.lexer)
this.guess = true;
if(options.formatter && validate.formatter... | javascript | function PygmentizeOptions (options) {
if(!(this instanceof PygmentizeOptions))
return new PygmentizeOptions(options);
if(options.lexer && validate.lexer.test(options.lexer))
this.lexer = options.lexer;
if(options.guess && !this.lexer)
this.guess = true;
if(options.formatter && validate.formatter... | [
"function",
"PygmentizeOptions",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"PygmentizeOptions",
")",
")",
"return",
"new",
"PygmentizeOptions",
"(",
"options",
")",
";",
"if",
"(",
"options",
".",
"lexer",
"&&",
"validate",
".",
... | Wrap an options object with convenience methods
for working with pygmentize
@param {Object} options | [
"Wrap",
"an",
"options",
"object",
"with",
"convenience",
"methods",
"for",
"working",
"with",
"pygmentize"
] | 4167b1b2d53edf79f10fe2c330596e316ade5f79 | https://github.com/jwilm/pygments-async/blob/4167b1b2d53edf79f10fe2c330596e316ade5f79/lib/pygmentize_options.js#L13-L28 | train |
linyngfly/omelo | lib/common/service/handlerService.js | function(app, opts) {
this.app = app;
this.handlerMap = {};
if(!!opts.reloadHandlers) {
watchHandlers(app, this.handlerMap);
}
this.enableForwardLog = opts.enableForwardLog || false;
} | javascript | function(app, opts) {
this.app = app;
this.handlerMap = {};
if(!!opts.reloadHandlers) {
watchHandlers(app, this.handlerMap);
}
this.enableForwardLog = opts.enableForwardLog || false;
} | [
"function",
"(",
"app",
",",
"opts",
")",
"{",
"this",
".",
"app",
"=",
"app",
";",
"this",
".",
"handlerMap",
"=",
"{",
"}",
";",
"if",
"(",
"!",
"!",
"opts",
".",
"reloadHandlers",
")",
"{",
"watchHandlers",
"(",
"app",
",",
"this",
".",
"handl... | Handler service.
Dispatch request to the relactive handler.
@param {Object} app current application context | [
"Handler",
"service",
".",
"Dispatch",
"request",
"to",
"the",
"relactive",
"handler",
"."
] | fb5f79fa31c69de36bd1c370bad5edfa753ca601 | https://github.com/linyngfly/omelo/blob/fb5f79fa31c69de36bd1c370bad5edfa753ca601/lib/common/service/handlerService.js#L13-L21 | train | |
linyngfly/omelo | lib/common/service/handlerService.js | function(app, serverType, handlerMap) {
let p = pathUtil.getHandlerPath(app.getBase(), serverType);
if(p) {
handlerMap[serverType] = Loader.load(p, app);
}
} | javascript | function(app, serverType, handlerMap) {
let p = pathUtil.getHandlerPath(app.getBase(), serverType);
if(p) {
handlerMap[serverType] = Loader.load(p, app);
}
} | [
"function",
"(",
"app",
",",
"serverType",
",",
"handlerMap",
")",
"{",
"let",
"p",
"=",
"pathUtil",
".",
"getHandlerPath",
"(",
"app",
".",
"getBase",
"(",
")",
",",
"serverType",
")",
";",
"if",
"(",
"p",
")",
"{",
"handlerMap",
"[",
"serverType",
... | Load handlers from current application | [
"Load",
"handlers",
"from",
"current",
"application"
] | fb5f79fa31c69de36bd1c370bad5edfa753ca601 | https://github.com/linyngfly/omelo/blob/fb5f79fa31c69de36bd1c370bad5edfa753ca601/lib/common/service/handlerService.js#L96-L101 | train | |
ludwigschubert/postal-react-mixin | postal-react-mixin.js | function() {
if (!this.hasOwnProperty("_postalSubscriptions")) {
this._postalSubscriptions = {};
}
for (var topic in this.subscriptions) {
if (this.subscriptions.hasOwnProperty(topic)) {
var callback = this.subscriptions[topic];
this.subscribe(topic, callback);
}
}
... | javascript | function() {
if (!this.hasOwnProperty("_postalSubscriptions")) {
this._postalSubscriptions = {};
}
for (var topic in this.subscriptions) {
if (this.subscriptions.hasOwnProperty(topic)) {
var callback = this.subscriptions[topic];
this.subscribe(topic, callback);
}
}
... | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"hasOwnProperty",
"(",
"\"_postalSubscriptions\"",
")",
")",
"{",
"this",
".",
"_postalSubscriptions",
"=",
"{",
"}",
";",
"}",
"for",
"(",
"var",
"topic",
"in",
"this",
".",
"subscriptions",
")",
... | React component lifecycle methods | [
"React",
"component",
"lifecycle",
"methods"
] | de732aa939e8a2b857e723e3b5b92b44f4155aef | https://github.com/ludwigschubert/postal-react-mixin/blob/de732aa939e8a2b857e723e3b5b92b44f4155aef/postal-react-mixin.js#L41-L51 | train | |
frankban/shapeup | shapeup.js | fromShape | function fromShape(obj, propType, options=null) {
const declaration = propType[SHAPE];
if (!(declaration instanceof Declaration)) {
throw new Error('fromShape called with a non-shape property type');
}
const shape = declaration.shape;
const instance = {};
const checker = {};
Object.keys(shape).forEach... | javascript | function fromShape(obj, propType, options=null) {
const declaration = propType[SHAPE];
if (!(declaration instanceof Declaration)) {
throw new Error('fromShape called with a non-shape property type');
}
const shape = declaration.shape;
const instance = {};
const checker = {};
Object.keys(shape).forEach... | [
"function",
"fromShape",
"(",
"obj",
",",
"propType",
",",
"options",
"=",
"null",
")",
"{",
"const",
"declaration",
"=",
"propType",
"[",
"SHAPE",
"]",
";",
"if",
"(",
"!",
"(",
"declaration",
"instanceof",
"Declaration",
")",
")",
"{",
"throw",
"new",
... | Build a property from the given object and shape property type.
The resulting property is a deeply frozen object, with initially unbound
methods bound to the provided object.
All fields in the provided object that are not declared in the shape are not
included in the returned object.
If the shape property type includes... | [
"Build",
"a",
"property",
"from",
"the",
"given",
"object",
"and",
"shape",
"property",
"type",
".",
"The",
"resulting",
"property",
"is",
"a",
"deeply",
"frozen",
"object",
"with",
"initially",
"unbound",
"methods",
"bound",
"to",
"the",
"provided",
"object",... | a537f051f2597582197f0d5e54afd971578a6363 | https://github.com/frankban/shapeup/blob/a537f051f2597582197f0d5e54afd971578a6363/shapeup.js#L87-L124 | train |
frankban/shapeup | shapeup.js | isRequiredWrapper | function isRequiredWrapper(propType) {
const isRequired = (props, propName, componentName, ...rest) => {
if (!props[propName]) {
return new Error(
`the property "${propName}" is marked as required for the component ` +
`"${componentName}" but "${props[propName]}" has been provided`
);
... | javascript | function isRequiredWrapper(propType) {
const isRequired = (props, propName, componentName, ...rest) => {
if (!props[propName]) {
return new Error(
`the property "${propName}" is marked as required for the component ` +
`"${componentName}" but "${props[propName]}" has been provided`
);
... | [
"function",
"isRequiredWrapper",
"(",
"propType",
")",
"{",
"const",
"isRequired",
"=",
"(",
"props",
",",
"propName",
",",
"componentName",
",",
"...",
"rest",
")",
"=>",
"{",
"if",
"(",
"!",
"props",
"[",
"propName",
"]",
")",
"{",
"return",
"new",
"... | Return the isRequired wrapper for the given propType validator.
@param {Function} propType A shape or frozen validator.
@return {Function} The isRequired validator. | [
"Return",
"the",
"isRequired",
"wrapper",
"for",
"the",
"given",
"propType",
"validator",
"."
] | a537f051f2597582197f0d5e54afd971578a6363 | https://github.com/frankban/shapeup/blob/a537f051f2597582197f0d5e54afd971578a6363/shapeup.js#L150-L162 | train |
frankban/shapeup | shapeup.js | frozenWrapper | function frozenWrapper(propType) {
const checkFrozen = (obj, propName, componentName) => {
if (!Object.isFrozen(obj)) {
throw new Error(
`the property "${propName}" provided to component ` +
`"${componentName}" is not frozen`
);
}
forEachKeyValue(obj, (name, prop) => {
co... | javascript | function frozenWrapper(propType) {
const checkFrozen = (obj, propName, componentName) => {
if (!Object.isFrozen(obj)) {
throw new Error(
`the property "${propName}" provided to component ` +
`"${componentName}" is not frozen`
);
}
forEachKeyValue(obj, (name, prop) => {
co... | [
"function",
"frozenWrapper",
"(",
"propType",
")",
"{",
"const",
"checkFrozen",
"=",
"(",
"obj",
",",
"propName",
",",
"componentName",
")",
"=>",
"{",
"if",
"(",
"!",
"Object",
".",
"isFrozen",
"(",
"obj",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
... | Return a frozen wrapper for the given propType validator.
The resulting validator checks that the provided property is deeply frozen.
@param {Function} propType A shape validator.
@return {Function} The frozen validator. | [
"Return",
"a",
"frozen",
"wrapper",
"for",
"the",
"given",
"propType",
"validator",
".",
"The",
"resulting",
"validator",
"checks",
"that",
"the",
"provided",
"property",
"is",
"deeply",
"frozen",
"."
] | a537f051f2597582197f0d5e54afd971578a6363 | https://github.com/frankban/shapeup/blob/a537f051f2597582197f0d5e54afd971578a6363/shapeup.js#L171-L201 | train |
frankban/shapeup | shapeup.js | deepFreeze | function deepFreeze(obj) {
Object.freeze(obj);
forEachKeyValue(obj, (name, prop) => {
const type = typeof obj;
if (
prop !== null &&
(type === 'object' || type === 'function') &&
!Object.isFrozen(prop)
) {
deepFreeze(prop);
}
});
return obj;
} | javascript | function deepFreeze(obj) {
Object.freeze(obj);
forEachKeyValue(obj, (name, prop) => {
const type = typeof obj;
if (
prop !== null &&
(type === 'object' || type === 'function') &&
!Object.isFrozen(prop)
) {
deepFreeze(prop);
}
});
return obj;
} | [
"function",
"deepFreeze",
"(",
"obj",
")",
"{",
"Object",
".",
"freeze",
"(",
"obj",
")",
";",
"forEachKeyValue",
"(",
"obj",
",",
"(",
"name",
",",
"prop",
")",
"=>",
"{",
"const",
"type",
"=",
"typeof",
"obj",
";",
"if",
"(",
"prop",
"!==",
"null... | Deep freeze the given object and all its properties.
@param {Object} obj The object to freeze.
@returns {Object} The resulting deeply frozen object. | [
"Deep",
"freeze",
"the",
"given",
"object",
"and",
"all",
"its",
"properties",
"."
] | a537f051f2597582197f0d5e54afd971578a6363 | https://github.com/frankban/shapeup/blob/a537f051f2597582197f0d5e54afd971578a6363/shapeup.js#L209-L222 | train |
TestArmada/midway-logger | lib/utils/validator.js | function (level) {
var lowerCaseLevel = level.toLowerCase();
if (_.contains(LEVELS, lowerCaseLevel)) {
return lowerCaseLevel;
} else {
return LEVEL_OFF;
}
} | javascript | function (level) {
var lowerCaseLevel = level.toLowerCase();
if (_.contains(LEVELS, lowerCaseLevel)) {
return lowerCaseLevel;
} else {
return LEVEL_OFF;
}
} | [
"function",
"(",
"level",
")",
"{",
"var",
"lowerCaseLevel",
"=",
"level",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"_",
".",
"contains",
"(",
"LEVELS",
",",
"lowerCaseLevel",
")",
")",
"{",
"return",
"lowerCaseLevel",
";",
"}",
"else",
"{",
"retu... | If level returned by tracer is not in LEVELS object, treat it as 'off'. | [
"If",
"level",
"returned",
"by",
"tracer",
"is",
"not",
"in",
"LEVELS",
"object",
"treat",
"it",
"as",
"off",
"."
] | b3479e2ab2909ec3420246d1edd27d300da97887 | https://github.com/TestArmada/midway-logger/blob/b3479e2ab2909ec3420246d1edd27d300da97887/lib/utils/validator.js#L34-L41 | train | |
keithws/x10 | lib/x10.js | HouseCode | function HouseCode(houseCode) {
this.raw = null;
switch (typeof houseCode) {
case "string":
if (houseCode !== "" && houseCode.length === 1) {
var index = houseCode.charCodeAt(0) - 65;
if ((index >= 0) && (index <= (deviceCodes.length - 1))) {
this.raw = deviceCodes[index];
} else {
throw new Erro... | javascript | function HouseCode(houseCode) {
this.raw = null;
switch (typeof houseCode) {
case "string":
if (houseCode !== "" && houseCode.length === 1) {
var index = houseCode.charCodeAt(0) - 65;
if ((index >= 0) && (index <= (deviceCodes.length - 1))) {
this.raw = deviceCodes[index];
} else {
throw new Erro... | [
"function",
"HouseCode",
"(",
"houseCode",
")",
"{",
"this",
".",
"raw",
"=",
"null",
";",
"switch",
"(",
"typeof",
"houseCode",
")",
"{",
"case",
"\"string\"",
":",
"if",
"(",
"houseCode",
"!==",
"\"\"",
"&&",
"houseCode",
".",
"length",
"===",
"1",
"... | object to convert X-10 house codes from numbers to strings and back | [
"object",
"to",
"convert",
"X",
"-",
"10",
"house",
"codes",
"from",
"numbers",
"to",
"strings",
"and",
"back"
] | c3f050580a14e1d43df31e72639cc66f9427e5b3 | https://github.com/keithws/x10/blob/c3f050580a14e1d43df31e72639cc66f9427e5b3/lib/x10.js#L20-L45 | train |
keithws/x10 | lib/x10.js | UnitCode | function UnitCode(unitCode) {
switch (typeof unitCode) {
case "string":
unitCode = parseInt(unitCode, 10);
if (unitCode || unitCode === 0) {
var index = unitCode - 1;
if ((index >= 0) && (index <= (deviceCodes.length - 1))) {
this.raw = deviceCodes[index];
} else {
throw new Error("Unit code stri... | javascript | function UnitCode(unitCode) {
switch (typeof unitCode) {
case "string":
unitCode = parseInt(unitCode, 10);
if (unitCode || unitCode === 0) {
var index = unitCode - 1;
if ((index >= 0) && (index <= (deviceCodes.length - 1))) {
this.raw = deviceCodes[index];
} else {
throw new Error("Unit code stri... | [
"function",
"UnitCode",
"(",
"unitCode",
")",
"{",
"switch",
"(",
"typeof",
"unitCode",
")",
"{",
"case",
"\"string\"",
":",
"unitCode",
"=",
"parseInt",
"(",
"unitCode",
",",
"10",
")",
";",
"if",
"(",
"unitCode",
"||",
"unitCode",
"===",
"0",
")",
"{... | object to convert X-10 unit codes from numbers to strings and back | [
"object",
"to",
"convert",
"X",
"-",
"10",
"unit",
"codes",
"from",
"numbers",
"to",
"strings",
"and",
"back"
] | c3f050580a14e1d43df31e72639cc66f9427e5b3 | https://github.com/keithws/x10/blob/c3f050580a14e1d43df31e72639cc66f9427e5b3/lib/x10.js#L63-L87 | train |
keithws/x10 | lib/x10.js | Address | function Address(address) {
this.houseCode = null;
this.unitCode = null;
try {
switch (typeof address) {
case "object":
if (_.isArray(address) && address.length === 2) {
this.houseCode = new HouseCode(address[0]);
this.unitCode = new UnitCode(address[1]);
} else {
if (address.houseCode !== und... | javascript | function Address(address) {
this.houseCode = null;
this.unitCode = null;
try {
switch (typeof address) {
case "object":
if (_.isArray(address) && address.length === 2) {
this.houseCode = new HouseCode(address[0]);
this.unitCode = new UnitCode(address[1]);
} else {
if (address.houseCode !== und... | [
"function",
"Address",
"(",
"address",
")",
"{",
"this",
".",
"houseCode",
"=",
"null",
";",
"this",
".",
"unitCode",
"=",
"null",
";",
"try",
"{",
"switch",
"(",
"typeof",
"address",
")",
"{",
"case",
"\"object\"",
":",
"if",
"(",
"_",
".",
"isArray... | object to convert X-10 addresses from numbers to strings and back | [
"object",
"to",
"convert",
"X",
"-",
"10",
"addresses",
"from",
"numbers",
"to",
"strings",
"and",
"back"
] | c3f050580a14e1d43df31e72639cc66f9427e5b3 | https://github.com/keithws/x10/blob/c3f050580a14e1d43df31e72639cc66f9427e5b3/lib/x10.js#L106-L150 | train |
boylesoftware/x2node-validators | lib/record-normalizer.js | normalize | function normalize(recordTypes, recordTypeName, record, lang, validationSets) {
// check that we have the record
if ((record === null) || ((typeof record) !== 'object'))
throw new common.X2UsageError('Record object was not provided.');
// get the record type descriptor (or throw error if invalid record type)
co... | javascript | function normalize(recordTypes, recordTypeName, record, lang, validationSets) {
// check that we have the record
if ((record === null) || ((typeof record) !== 'object'))
throw new common.X2UsageError('Record object was not provided.');
// get the record type descriptor (or throw error if invalid record type)
co... | [
"function",
"normalize",
"(",
"recordTypes",
",",
"recordTypeName",
",",
"record",
",",
"lang",
",",
"validationSets",
")",
"{",
"// check that we have the record",
"if",
"(",
"(",
"record",
"===",
"null",
")",
"||",
"(",
"(",
"typeof",
"record",
")",
"!==",
... | Validate and normalize the specified record.
@function module:x2node-validators.normalizeRecord
@param {module:x2node-records~RecordTypesLibrary} recordType Record types
library.
@param {string} recordTypeName Record type name.
@param {Object} record The record to validate. May not be <code>null</code> or
<code>undefi... | [
"Validate",
"and",
"normalize",
"the",
"specified",
"record",
"."
] | e98a65c13a4092f80e96517c8e8c9523f8e84c63 | https://github.com/boylesoftware/x2node-validators/blob/e98a65c13a4092f80e96517c8e8c9523f8e84c63/lib/record-normalizer.js#L29-L57 | train |
boylesoftware/x2node-validators | lib/record-normalizer.js | getValidators | function getValidators(subjDesc, element, validationSets) {
const validators = subjDesc.validators;
if (!validators)
return null;
const allValidators = new Array();
for (let set in validators) {
if (element && !set.startsWith('element:'))
continue;
if (validationSets.has(element ? set.substring('element... | javascript | function getValidators(subjDesc, element, validationSets) {
const validators = subjDesc.validators;
if (!validators)
return null;
const allValidators = new Array();
for (let set in validators) {
if (element && !set.startsWith('element:'))
continue;
if (validationSets.has(element ? set.substring('element... | [
"function",
"getValidators",
"(",
"subjDesc",
",",
"element",
",",
"validationSets",
")",
"{",
"const",
"validators",
"=",
"subjDesc",
".",
"validators",
";",
"if",
"(",
"!",
"validators",
")",
"return",
"null",
";",
"const",
"allValidators",
"=",
"new",
"Ar... | Get validators sequence for the specified subject descriptor.
@private
@param {(module:x2node-records~RecordTypeDescriptor|module:x2node-records~PropertyDescriptor)} subjDesc
Descriptor with validators on it.
@param {boolean} element <code>true</code> for collection element validators.
@param {Set.<string>} validation... | [
"Get",
"validators",
"sequence",
"for",
"the",
"specified",
"subject",
"descriptor",
"."
] | e98a65c13a4092f80e96517c8e8c9523f8e84c63 | https://github.com/boylesoftware/x2node-validators/blob/e98a65c13a4092f80e96517c8e8c9523f8e84c63/lib/record-normalizer.js#L223-L240 | train |
aledbf/deis-api | lib/perms.js | list | function list(appName, callback) {
commons.get(format('/%s/apps/%s/perms/', deis.version, appName), callback);
} | javascript | function list(appName, callback) {
commons.get(format('/%s/apps/%s/perms/', deis.version, appName), callback);
} | [
"function",
"list",
"(",
"appName",
",",
"callback",
")",
"{",
"commons",
".",
"get",
"(",
"format",
"(",
"'/%s/apps/%s/perms/'",
",",
"deis",
".",
"version",
",",
"appName",
")",
",",
"callback",
")",
";",
"}"
] | list permissions granted on an app | [
"list",
"permissions",
"granted",
"on",
"an",
"app"
] | f0833789998032b11221a3a617bb566ade1fcc13 | https://github.com/aledbf/deis-api/blob/f0833789998032b11221a3a617bb566ade1fcc13/lib/perms.js#L10-L12 | train |
teabyii/qa | lib/ui.js | UI | function UI (input, output) {
this.rl = readline.createInterface({
input: input || ttys.stdin,
output: output || ttys.stdout
})
// Delegated events bind.
this.onLine = (function onLine () {
_events.line.apply(this, arguments)
}).bind(this)
this.onKeypress = (function onKeypress () {
if... | javascript | function UI (input, output) {
this.rl = readline.createInterface({
input: input || ttys.stdin,
output: output || ttys.stdout
})
// Delegated events bind.
this.onLine = (function onLine () {
_events.line.apply(this, arguments)
}).bind(this)
this.onKeypress = (function onKeypress () {
if... | [
"function",
"UI",
"(",
"input",
",",
"output",
")",
"{",
"this",
".",
"rl",
"=",
"readline",
".",
"createInterface",
"(",
"{",
"input",
":",
"input",
"||",
"ttys",
".",
"stdin",
",",
"output",
":",
"output",
"||",
"ttys",
".",
"stdout",
"}",
")",
"... | UI constructor, to create ui to control IO.
@constructor
@param {Stream} [input]
@param {Stream} [output] | [
"UI",
"constructor",
"to",
"create",
"ui",
"to",
"control",
"IO",
"."
] | 9224180dcb9e6b57c021f83b259316e84ebc573e | https://github.com/teabyii/qa/blob/9224180dcb9e6b57c021f83b259316e84ebc573e/lib/ui.js#L21-L45 | train |
h1bomb/yo | examples/yo.yohobuy-mobile/client/js/saunter.js | lazyLoad | function lazyLoad(imgs, options) {
var setting = {
effect: 'fadeIn',
effect_speed: 10,
placeholder: 'data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP///93d3f///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw=='
},
$imgs;
if (typeof imgs === 'undefine... | javascript | function lazyLoad(imgs, options) {
var setting = {
effect: 'fadeIn',
effect_speed: 10,
placeholder: 'data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP///93d3f///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw=='
},
$imgs;
if (typeof imgs === 'undefine... | [
"function",
"lazyLoad",
"(",
"imgs",
",",
"options",
")",
"{",
"var",
"setting",
"=",
"{",
"effect",
":",
"'fadeIn'",
",",
"effect_speed",
":",
"10",
",",
"placeholder",
":",
"'data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP///93d3f///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw=='",
... | lazyLoad-Fn | [
"lazyLoad",
"-",
"Fn"
] | 11a05222d4fd1c0b5e8239672058f3d0d93aad44 | https://github.com/h1bomb/yo/blob/11a05222d4fd1c0b5e8239672058f3d0d93aad44/examples/yo.yohobuy-mobile/client/js/saunter.js#L14-L30 | train |
aledbf/deis-api | lib/tags.js | list | function list(appName, callback) {
var url = format('/%s/apps/%s/config/', deis.version, appName);
commons.get(url, function onListResponse(err, result) {
callback(err, result ? result.tags : null);
});
} | javascript | function list(appName, callback) {
var url = format('/%s/apps/%s/config/', deis.version, appName);
commons.get(url, function onListResponse(err, result) {
callback(err, result ? result.tags : null);
});
} | [
"function",
"list",
"(",
"appName",
",",
"callback",
")",
"{",
"var",
"url",
"=",
"format",
"(",
"'/%s/apps/%s/config/'",
",",
"deis",
".",
"version",
",",
"appName",
")",
";",
"commons",
".",
"get",
"(",
"url",
",",
"function",
"onListResponse",
"(",
"e... | list tags for an app | [
"list",
"tags",
"for",
"an",
"app"
] | f0833789998032b11221a3a617bb566ade1fcc13 | https://github.com/aledbf/deis-api/blob/f0833789998032b11221a3a617bb566ade1fcc13/lib/tags.js#L12-L17 | train |
aledbf/deis-api | lib/tags.js | set | function set(appName, tagValues, callback) {
if (!isObject(tagValues)) {
return callback(new Error('To set a variable pass an object'));
}
commons.post(format('/%s/apps/%s/config/', deis.version, appName), {
tags: tagValues
},function onSetResponse(err, result) {
callback(err, result ... | javascript | function set(appName, tagValues, callback) {
if (!isObject(tagValues)) {
return callback(new Error('To set a variable pass an object'));
}
commons.post(format('/%s/apps/%s/config/', deis.version, appName), {
tags: tagValues
},function onSetResponse(err, result) {
callback(err, result ... | [
"function",
"set",
"(",
"appName",
",",
"tagValues",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"isObject",
"(",
"tagValues",
")",
")",
"{",
"return",
"callback",
"(",
"new",
"Error",
"(",
"'To set a variable pass an object'",
")",
")",
";",
"}",
"commons"... | set tags for an app | [
"set",
"tags",
"for",
"an",
"app"
] | f0833789998032b11221a3a617bb566ade1fcc13 | https://github.com/aledbf/deis-api/blob/f0833789998032b11221a3a617bb566ade1fcc13/lib/tags.js#L22-L32 | train |
aledbf/deis-api | lib/tags.js | unset | function unset(appName, tagNames, callback) {
if (!util.isArray(tagNames)) {
return callback(new Error('To unset a tag pass an array of names'));
}
var keyValues = {};
tagNames.forEach(function eachTag(tagName) {
keyValues[tagName] = null;
});
set(appName, keyValues, callback);
} | javascript | function unset(appName, tagNames, callback) {
if (!util.isArray(tagNames)) {
return callback(new Error('To unset a tag pass an array of names'));
}
var keyValues = {};
tagNames.forEach(function eachTag(tagName) {
keyValues[tagName] = null;
});
set(appName, keyValues, callback);
} | [
"function",
"unset",
"(",
"appName",
",",
"tagNames",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"util",
".",
"isArray",
"(",
"tagNames",
")",
")",
"{",
"return",
"callback",
"(",
"new",
"Error",
"(",
"'To unset a tag pass an array of names'",
")",
")",
";... | unset tags for an app | [
"unset",
"tags",
"for",
"an",
"app"
] | f0833789998032b11221a3a617bb566ade1fcc13 | https://github.com/aledbf/deis-api/blob/f0833789998032b11221a3a617bb566ade1fcc13/lib/tags.js#L37-L48 | train |
lmammino/indexed-string-variation | lib/generate/generateBigInt.js | getLevel | function getLevel(base, index) {
var level = (0, _bigInteger2.default)('0');
var current = index;
var parent = void 0;
while (current.gt(zero)) {
parent = current.prev().divide(base);
level = level.next();
current = parent;
}
return level;
} | javascript | function getLevel(base, index) {
var level = (0, _bigInteger2.default)('0');
var current = index;
var parent = void 0;
while (current.gt(zero)) {
parent = current.prev().divide(base);
level = level.next();
current = parent;
}
return level;
} | [
"function",
"getLevel",
"(",
"base",
",",
"index",
")",
"{",
"var",
"level",
"=",
"(",
"0",
",",
"_bigInteger2",
".",
"default",
")",
"(",
"'0'",
")",
";",
"var",
"current",
"=",
"index",
";",
"var",
"parent",
"=",
"void",
"0",
";",
"while",
"(",
... | calculates the level of a given index in the current virtual tree | [
"calculates",
"the",
"level",
"of",
"a",
"given",
"index",
"in",
"the",
"current",
"virtual",
"tree"
] | 52fb6b5b05940138fb58f9a1c937531ad90adda5 | https://github.com/lmammino/indexed-string-variation/blob/52fb6b5b05940138fb58f9a1c937531ad90adda5/lib/generate/generateBigInt.js#L17-L28 | train |
glennschler/spotspec | lib/spotspec.js | SpotSpec | function SpotSpec (options) {
if (this.constructor.name === 'Object') {
throw new Error('Object must be instantiated using new')
}
let self = this
let specOptions = Object.assign({}, options)
// Have the superclass constuct as an EC2 service
Service.call(this, SvcAws.EC2, specOptions)
this.logger.in... | javascript | function SpotSpec (options) {
if (this.constructor.name === 'Object') {
throw new Error('Object must be instantiated using new')
}
let self = this
let specOptions = Object.assign({}, options)
// Have the superclass constuct as an EC2 service
Service.call(this, SvcAws.EC2, specOptions)
this.logger.in... | [
"function",
"SpotSpec",
"(",
"options",
")",
"{",
"if",
"(",
"this",
".",
"constructor",
".",
"name",
"===",
"'Object'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Object must be instantiated using new'",
")",
"}",
"let",
"self",
"=",
"this",
"let",
"specOpti... | Constructs a new SpotSpec Library
@constructor
@arg {object} options - The AWS service IAM credentials - See [aws docs]{@link http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Credentials.html}
@arg {object} options.keys - AWS credentials
@arg {string} options.keys.accessKeyId - AWS access key ID
@arg {string} opt... | [
"Constructs",
"a",
"new",
"SpotSpec",
"Library"
] | ca6f5b17b84b3536b6b2ce9a472d5ae91c8cd727 | https://github.com/glennschler/spotspec/blob/ca6f5b17b84b3536b6b2ce9a472d5ae91c8cd727/lib/spotspec.js#L25-L46 | train |
hashchange/backbone.cycle | demo/amd/main.js | function ( options ) {
_.bindAll( this, "selectNext", "selectPrev", "onSelect", "render" );
this.collection = options.collection;
this.listenTo( this.collection, "select:one", this.onSelect );
this.listenTo( this.collection, "remove", this.render );
... | javascript | function ( options ) {
_.bindAll( this, "selectNext", "selectPrev", "onSelect", "render" );
this.collection = options.collection;
this.listenTo( this.collection, "select:one", this.onSelect );
this.listenTo( this.collection, "remove", this.render );
... | [
"function",
"(",
"options",
")",
"{",
"_",
".",
"bindAll",
"(",
"this",
",",
"\"selectNext\"",
",",
"\"selectPrev\"",
",",
"\"onSelect\"",
",",
"\"render\"",
")",
";",
"this",
".",
"collection",
"=",
"options",
".",
"collection",
";",
"this",
".",
"listenT... | A base class. Extend, don't instantiate. By default, render is a no-op. Override if necessary. | [
"A",
"base",
"class",
".",
"Extend",
"don",
"t",
"instantiate",
".",
"By",
"default",
"render",
"is",
"a",
"no",
"-",
"op",
".",
"Override",
"if",
"necessary",
"."
] | 7e898ae2ebc6540b62a66f32fcb10f1a60d2f4b1 | https://github.com/hashchange/backbone.cycle/blob/7e898ae2ebc6540b62a66f32fcb10f1a60d2f4b1/demo/amd/main.js#L32-L38 | train | |
harrisiirak/buffer-stream-reader | reader.js | BufferStreamReader | function BufferStreamReader (data, options) {
if (!(this instanceof BufferStreamReader)) {
return new BufferStreamReader(data);
}
if (!options) {
options = {};
}
stream.Readable.call(this, options);
this._data = null;
this._chunkSize = options.chunkSize || -1;
if (typeof data === 'string') {... | javascript | function BufferStreamReader (data, options) {
if (!(this instanceof BufferStreamReader)) {
return new BufferStreamReader(data);
}
if (!options) {
options = {};
}
stream.Readable.call(this, options);
this._data = null;
this._chunkSize = options.chunkSize || -1;
if (typeof data === 'string') {... | [
"function",
"BufferStreamReader",
"(",
"data",
",",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"BufferStreamReader",
")",
")",
"{",
"return",
"new",
"BufferStreamReader",
"(",
"data",
")",
";",
"}",
"if",
"(",
"!",
"options",
")",
"{... | Create a new stream reader
@param data
@param options
@returns {StringReader}
@constructor | [
"Create",
"a",
"new",
"stream",
"reader"
] | 79ef10ddd35a95790c5eae1861b315a97156b400 | https://github.com/harrisiirak/buffer-stream-reader/blob/79ef10ddd35a95790c5eae1861b315a97156b400/reader.js#L15-L34 | train |
spacemaus/postvox | vox-client/vox.js | RootContext | function RootContext(argv, profileFilenames, view) {
var self = {
commands: COMMANDS, // Overwritten when interactive
profileFilenames: profileFilenames,
interactive: false,
argv: argv,
view: view,
config: null,
nick: null,
privkey: null,
hubClient: null,
vo... | javascript | function RootContext(argv, profileFilenames, view) {
var self = {
commands: COMMANDS, // Overwritten when interactive
profileFilenames: profileFilenames,
interactive: false,
argv: argv,
view: view,
config: null,
nick: null,
privkey: null,
hubClient: null,
vo... | [
"function",
"RootContext",
"(",
"argv",
",",
"profileFilenames",
",",
"view",
")",
"{",
"var",
"self",
"=",
"{",
"commands",
":",
"COMMANDS",
",",
"// Overwritten when interactive",
"profileFilenames",
":",
"profileFilenames",
",",
"interactive",
":",
"false",
","... | Creates a context object that can be passed to command handlers. | [
"Creates",
"a",
"context",
"object",
"that",
"can",
"be",
"passed",
"to",
"command",
"handlers",
"."
] | de98e5ed37edaee1b1edadf93e15eb8f8d21f457 | https://github.com/spacemaus/postvox/blob/de98e5ed37edaee1b1edadf93e15eb8f8d21f457/vox-client/vox.js#L133-L201 | train |
mathieuhays/LCD_Scrolling | index.js | progress | function progress( _line ){
messages[ _line ].progress++;
if( (messages[ _line ].progress + messages[ _line ].diff) > 0 ){
messages[ _line ].progress = 0;
}
} | javascript | function progress( _line ){
messages[ _line ].progress++;
if( (messages[ _line ].progress + messages[ _line ].diff) > 0 ){
messages[ _line ].progress = 0;
}
} | [
"function",
"progress",
"(",
"_line",
")",
"{",
"messages",
"[",
"_line",
"]",
".",
"progress",
"++",
";",
"if",
"(",
"(",
"messages",
"[",
"_line",
"]",
".",
"progress",
"+",
"messages",
"[",
"_line",
"]",
".",
"diff",
")",
">",
"0",
")",
"{",
"... | Incremente progress or reset if done.
@param (int) _line - Line index | [
"Incremente",
"progress",
"or",
"reset",
"if",
"done",
"."
] | b70b5f54268eefc6dca384ec4de090643e53adb1 | https://github.com/mathieuhays/LCD_Scrolling/blob/b70b5f54268eefc6dca384ec4de090643e53adb1/index.js#L67-L77 | train |
mathieuhays/LCD_Scrolling | index.js | anim | function anim( _line ){
var msg = messages[ _line ];
lcd.cursor( _line, 0 );
if( msg.progress === 0 ){
lcd.print( msg.msg );
progress( _line );
(function( _line ){
timeout = setTimeout(function(){
anim( _line )
}, anim_settings.firstCharP... | javascript | function anim( _line ){
var msg = messages[ _line ];
lcd.cursor( _line, 0 );
if( msg.progress === 0 ){
lcd.print( msg.msg );
progress( _line );
(function( _line ){
timeout = setTimeout(function(){
anim( _line )
}, anim_settings.firstCharP... | [
"function",
"anim",
"(",
"_line",
")",
"{",
"var",
"msg",
"=",
"messages",
"[",
"_line",
"]",
";",
"lcd",
".",
"cursor",
"(",
"_line",
",",
"0",
")",
";",
"if",
"(",
"msg",
".",
"progress",
"===",
"0",
")",
"{",
"lcd",
".",
"print",
"(",
"msg",... | Animate the text on screen
@param (int) _line - Line index | [
"Animate",
"the",
"text",
"on",
"screen"
] | b70b5f54268eefc6dca384ec4de090643e53adb1 | https://github.com/mathieuhays/LCD_Scrolling/blob/b70b5f54268eefc6dca384ec4de090643e53adb1/index.js#L84-L123 | train |
rkaw92/esdf | Commit.js | Commit | function Commit(events, sequenceID, sequenceSlot, aggregateType, metadata){
if(!Array.isArray(events)){ throw new Error('events must be an array while constructing Commit'); }
if(typeof(sequenceID) !== 'string'){ throw new Error('sequenceID is not a string while constructing Commit'); }
if(!sequenceSlot){ throw new ... | javascript | function Commit(events, sequenceID, sequenceSlot, aggregateType, metadata){
if(!Array.isArray(events)){ throw new Error('events must be an array while constructing Commit'); }
if(typeof(sequenceID) !== 'string'){ throw new Error('sequenceID is not a string while constructing Commit'); }
if(!sequenceSlot){ throw new ... | [
"function",
"Commit",
"(",
"events",
",",
"sequenceID",
",",
"sequenceSlot",
",",
"aggregateType",
",",
"metadata",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"events",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'events must be an array while... | Construct a new commit. A commit is an atomic group of events, handled in an all-or-nothing manner by an event sink. It is the basic unit of event storage in this framework.
@constructor
@param {module:esdf/core/Event.Event[]} events A list of events that the commit is composed of.
@param {String} sequenceID Character-... | [
"Construct",
"a",
"new",
"commit",
".",
"A",
"commit",
"is",
"an",
"atomic",
"group",
"of",
"events",
"handled",
"in",
"an",
"all",
"-",
"or",
"-",
"nothing",
"manner",
"by",
"an",
"event",
"sink",
".",
"It",
"is",
"the",
"basic",
"unit",
"of",
"even... | 9c6bd2c278428096cb8c1ceeca62a5493d19613e | https://github.com/rkaw92/esdf/blob/9c6bd2c278428096cb8c1ceeca62a5493d19613e/Commit.js#L15-L25 | train |
marcelomf/graojs | modeling/assets/WebGL/webgl-debug.js | init | function init(ctx) {
if (glEnums == null) {
glEnums = { };
for (var propertyName in ctx) {
if (typeof ctx[propertyName] == 'number') {
glEnums[ctx[propertyName]] = propertyName;
}
}
}
} | javascript | function init(ctx) {
if (glEnums == null) {
glEnums = { };
for (var propertyName in ctx) {
if (typeof ctx[propertyName] == 'number') {
glEnums[ctx[propertyName]] = propertyName;
}
}
}
} | [
"function",
"init",
"(",
"ctx",
")",
"{",
"if",
"(",
"glEnums",
"==",
"null",
")",
"{",
"glEnums",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"propertyName",
"in",
"ctx",
")",
"{",
"if",
"(",
"typeof",
"ctx",
"[",
"propertyName",
"]",
"==",
"'number'",... | Initializes this module. Safe to call more than once.
@param {!WebGLRenderingContext} ctx A WebGL context. If
you have more than one context it doesn't matter which one
you pass in, it is only used to pull out constants. | [
"Initializes",
"this",
"module",
".",
"Safe",
"to",
"call",
"more",
"than",
"once",
"."
] | f8fd9e5ed9406c6266c30777eb4f77474fe6ac4f | https://github.com/marcelomf/graojs/blob/f8fd9e5ed9406c6266c30777eb4f77474fe6ac4f/modeling/assets/WebGL/webgl-debug.js#L143-L152 | train |
marcelomf/graojs | modeling/assets/WebGL/webgl-debug.js | glEnumToString | function glEnumToString(value) {
checkInit();
var name = glEnums[value];
return (name !== undefined) ? name :
("*UNKNOWN WebGL ENUM (0x" + value.toString(16) + ")");
} | javascript | function glEnumToString(value) {
checkInit();
var name = glEnums[value];
return (name !== undefined) ? name :
("*UNKNOWN WebGL ENUM (0x" + value.toString(16) + ")");
} | [
"function",
"glEnumToString",
"(",
"value",
")",
"{",
"checkInit",
"(",
")",
";",
"var",
"name",
"=",
"glEnums",
"[",
"value",
"]",
";",
"return",
"(",
"name",
"!==",
"undefined",
")",
"?",
"name",
":",
"(",
"\"*UNKNOWN WebGL ENUM (0x\"",
"+",
"value",
"... | Gets an string version of an WebGL enum.
Example:
var str = WebGLDebugUtil.glEnumToString(ctx.getError());
@param {number} value Value to return an enum for
@return {string} The string version of the enum. | [
"Gets",
"an",
"string",
"version",
"of",
"an",
"WebGL",
"enum",
"."
] | f8fd9e5ed9406c6266c30777eb4f77474fe6ac4f | https://github.com/marcelomf/graojs/blob/f8fd9e5ed9406c6266c30777eb4f77474fe6ac4f/modeling/assets/WebGL/webgl-debug.js#L182-L187 | train |
marcelomf/graojs | modeling/assets/WebGL/webgl-debug.js | glFunctionArgsToString | function glFunctionArgsToString(functionName, args) {
// apparently we can't do args.join(",");
var argStr = "";
for (var ii = 0; ii < args.length; ++ii) {
argStr += ((ii == 0) ? '' : ', ') +
glFunctionArgToString(functionName, ii, args[ii]);
}
return argStr;
} | javascript | function glFunctionArgsToString(functionName, args) {
// apparently we can't do args.join(",");
var argStr = "";
for (var ii = 0; ii < args.length; ++ii) {
argStr += ((ii == 0) ? '' : ', ') +
glFunctionArgToString(functionName, ii, args[ii]);
}
return argStr;
} | [
"function",
"glFunctionArgsToString",
"(",
"functionName",
",",
"args",
")",
"{",
"// apparently we can't do args.join(\",\");",
"var",
"argStr",
"=",
"\"\"",
";",
"for",
"(",
"var",
"ii",
"=",
"0",
";",
"ii",
"<",
"args",
".",
"length",
";",
"++",
"ii",
")"... | Converts the arguments of a WebGL function to a string.
Attempts to convert enum arguments to strings.
@param {string} functionName the name of the WebGL function.
@param {number} args The arguments.
@return {string} The arguments as a string. | [
"Converts",
"the",
"arguments",
"of",
"a",
"WebGL",
"function",
"to",
"a",
"string",
".",
"Attempts",
"to",
"convert",
"enum",
"arguments",
"to",
"strings",
"."
] | f8fd9e5ed9406c6266c30777eb4f77474fe6ac4f | https://github.com/marcelomf/graojs/blob/f8fd9e5ed9406c6266c30777eb4f77474fe6ac4f/modeling/assets/WebGL/webgl-debug.js#L221-L229 | train |
marcelomf/graojs | modeling/assets/WebGL/webgl-debug.js | makeDebugContext | function makeDebugContext(ctx, opt_onErrorFunc, opt_onFunc) {
init(ctx);
opt_onErrorFunc = opt_onErrorFunc || function(err, functionName, args) {
// apparently we can't do args.join(",");
var argStr = "";
for (var ii = 0; ii < args.length; ++ii) {
argStr += ((ii == 0) ? '' : ', ') ... | javascript | function makeDebugContext(ctx, opt_onErrorFunc, opt_onFunc) {
init(ctx);
opt_onErrorFunc = opt_onErrorFunc || function(err, functionName, args) {
// apparently we can't do args.join(",");
var argStr = "";
for (var ii = 0; ii < args.length; ++ii) {
argStr += ((ii == 0) ? '' : ', ') ... | [
"function",
"makeDebugContext",
"(",
"ctx",
",",
"opt_onErrorFunc",
",",
"opt_onFunc",
")",
"{",
"init",
"(",
"ctx",
")",
";",
"opt_onErrorFunc",
"=",
"opt_onErrorFunc",
"||",
"function",
"(",
"err",
",",
"functionName",
",",
"args",
")",
"{",
"// apparently w... | Given a WebGL context returns a wrapped context that calls
gl.getError after every command and calls a function if the
result is not gl.NO_ERROR.
@param {!WebGLRenderingContext} ctx The webgl context to
wrap.
@param {!function(err, funcName, args): void} opt_onErrorFunc
The function to call when gl.getError returns an... | [
"Given",
"a",
"WebGL",
"context",
"returns",
"a",
"wrapped",
"context",
"that",
"calls",
"gl",
".",
"getError",
"after",
"every",
"command",
"and",
"calls",
"a",
"function",
"if",
"the",
"result",
"is",
"not",
"gl",
".",
"NO_ERROR",
"."
] | f8fd9e5ed9406c6266c30777eb4f77474fe6ac4f | https://github.com/marcelomf/graojs/blob/f8fd9e5ed9406c6266c30777eb4f77474fe6ac4f/modeling/assets/WebGL/webgl-debug.js#L271-L329 | train |
Raynos/seaport-proxy | lib/service.js | createServer | function createServer(serverName) {
console.log("creating server", serverName)
var server = servers[serverName] = net.createServer(handleConnection)
ports.service(serverName, listen)
function handleConnection(connection) {
console.log("got incoming connection", connection)
... | javascript | function createServer(serverName) {
console.log("creating server", serverName)
var server = servers[serverName] = net.createServer(handleConnection)
ports.service(serverName, listen)
function handleConnection(connection) {
console.log("got incoming connection", connection)
... | [
"function",
"createServer",
"(",
"serverName",
")",
"{",
"console",
".",
"log",
"(",
"\"creating server\"",
",",
"serverName",
")",
"var",
"server",
"=",
"servers",
"[",
"serverName",
"]",
"=",
"net",
".",
"createServer",
"(",
"handleConnection",
")",
"ports",... | create seaport service when server stream comes up | [
"create",
"seaport",
"service",
"when",
"server",
"stream",
"comes",
"up"
] | 3a05afe6e6f801b09a3810eea27e7366221cadad | https://github.com/Raynos/seaport-proxy/blob/3a05afe6e6f801b09a3810eea27e7366221cadad/lib/service.js#L20-L46 | train |
haasz/laravel-mix-ext | config/index.js | modifyOutRules | function modifyOutRules(rules) {
for (let i = 0; i < rules.length; ++i) {
if (rules[i].test) {
switch ('' + rules[i].test) {
// Images
case '/\\.(png|jpe?g|gif)$/':
modifyOutRule(rules[i], 'images');
break;
// Fonts
case '/\\.(woff2?|ttf|eot|svg|otf)$/':
modifyOutRule(rules[i], 'fon... | javascript | function modifyOutRules(rules) {
for (let i = 0; i < rules.length; ++i) {
if (rules[i].test) {
switch ('' + rules[i].test) {
// Images
case '/\\.(png|jpe?g|gif)$/':
modifyOutRule(rules[i], 'images');
break;
// Fonts
case '/\\.(woff2?|ttf|eot|svg|otf)$/':
modifyOutRule(rules[i], 'fon... | [
"function",
"modifyOutRules",
"(",
"rules",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"rules",
".",
"length",
";",
"++",
"i",
")",
"{",
"if",
"(",
"rules",
"[",
"i",
"]",
".",
"test",
")",
"{",
"switch",
"(",
"''",
"+",
"rule... | Modify the rules of output directories.
@param {Array} rules The rules. | [
"Modify",
"the",
"rules",
"of",
"output",
"directories",
"."
] | bd1c794bdbf934dae233ab697dc5d5593d4b1124 | https://github.com/haasz/laravel-mix-ext/blob/bd1c794bdbf934dae233ab697dc5d5593d4b1124/config/index.js#L41-L58 | train |
haasz/laravel-mix-ext | config/index.js | modifyOutRule | function modifyOutRule(rule, type) {
rule.test = new RegExp(
'\\.(' + Config.out[type].extensions.join('|') + ')$'
);
} | javascript | function modifyOutRule(rule, type) {
rule.test = new RegExp(
'\\.(' + Config.out[type].extensions.join('|') + ')$'
);
} | [
"function",
"modifyOutRule",
"(",
"rule",
",",
"type",
")",
"{",
"rule",
".",
"test",
"=",
"new",
"RegExp",
"(",
"'\\\\.('",
"+",
"Config",
".",
"out",
"[",
"type",
"]",
".",
"extensions",
".",
"join",
"(",
"'|'",
")",
"+",
"')$'",
")",
";",
"}"
] | Modify the rule of output directory.
@param {Object} rule The rule.
@param {string} type The output directory type. | [
"Modify",
"the",
"rule",
"of",
"output",
"directory",
"."
] | bd1c794bdbf934dae233ab697dc5d5593d4b1124 | https://github.com/haasz/laravel-mix-ext/blob/bd1c794bdbf934dae233ab697dc5d5593d4b1124/config/index.js#L67-L71 | train |
jfseb/mgnlq_model | js/modelload/schemaload.js | loadModelNames | function loadModelNames(modelPath) {
modelPath = modelPath || envModelPath;
debuglog(() => `modelpath is ${modelPath} `);
var mdls = FUtils.readFileAsJSON('./' + modelPath + '/models.json');
mdls.forEach(name => {
if (name !== makeMongoCollectionName(name)) {
throw new Error('bad mod... | javascript | function loadModelNames(modelPath) {
modelPath = modelPath || envModelPath;
debuglog(() => `modelpath is ${modelPath} `);
var mdls = FUtils.readFileAsJSON('./' + modelPath + '/models.json');
mdls.forEach(name => {
if (name !== makeMongoCollectionName(name)) {
throw new Error('bad mod... | [
"function",
"loadModelNames",
"(",
"modelPath",
")",
"{",
"modelPath",
"=",
"modelPath",
"||",
"envModelPath",
";",
"debuglog",
"(",
"(",
")",
"=>",
"`",
"${",
"modelPath",
"}",
"`",
")",
";",
"var",
"mdls",
"=",
"FUtils",
".",
"readFileAsJSON",
"(",
"'.... | load the models | [
"load",
"the",
"models"
] | be1be4406b05718d666d6d0f712c9cadb5169f2c | https://github.com/jfseb/mgnlq_model/blob/be1be4406b05718d666d6d0f712c9cadb5169f2c/js/modelload/schemaload.js#L58-L68 | train |
jfseb/mgnlq_model | js/modelload/schemaload.js | makeMongooseModelName | function makeMongooseModelName(collectionName) {
if (collectionName !== collectionName.toLowerCase()) {
throw new Error('expect lowercase, was ' + collectionName);
}
if (collectionName.charAt(collectionName.length - 1) === 's') {
return collectionName.substring(0, collectionName.length - 1);... | javascript | function makeMongooseModelName(collectionName) {
if (collectionName !== collectionName.toLowerCase()) {
throw new Error('expect lowercase, was ' + collectionName);
}
if (collectionName.charAt(collectionName.length - 1) === 's') {
return collectionName.substring(0, collectionName.length - 1);... | [
"function",
"makeMongooseModelName",
"(",
"collectionName",
")",
"{",
"if",
"(",
"collectionName",
"!==",
"collectionName",
".",
"toLowerCase",
"(",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'expect lowercase, was '",
"+",
"collectionName",
")",
";",
"}",
"i... | return a modelname without a traling s
@param collectionName | [
"return",
"a",
"modelname",
"without",
"a",
"traling",
"s"
] | be1be4406b05718d666d6d0f712c9cadb5169f2c | https://github.com/jfseb/mgnlq_model/blob/be1be4406b05718d666d6d0f712c9cadb5169f2c/js/modelload/schemaload.js#L176-L184 | train |
jfseb/mgnlq_model | js/modelload/schemaload.js | makeMongoCollectionName | function makeMongoCollectionName(modelName) {
if (modelName !== modelName.toLowerCase()) {
throw new Error('expect lowercase, was ' + modelName);
}
if (modelName.charAt(modelName.length - 1) !== 's') {
return modelName + 's';
}
return modelName;
} | javascript | function makeMongoCollectionName(modelName) {
if (modelName !== modelName.toLowerCase()) {
throw new Error('expect lowercase, was ' + modelName);
}
if (modelName.charAt(modelName.length - 1) !== 's') {
return modelName + 's';
}
return modelName;
} | [
"function",
"makeMongoCollectionName",
"(",
"modelName",
")",
"{",
"if",
"(",
"modelName",
"!==",
"modelName",
".",
"toLowerCase",
"(",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'expect lowercase, was '",
"+",
"modelName",
")",
";",
"}",
"if",
"(",
"mode... | returns a mongoose collection name
@param modelName | [
"returns",
"a",
"mongoose",
"collection",
"name"
] | be1be4406b05718d666d6d0f712c9cadb5169f2c | https://github.com/jfseb/mgnlq_model/blob/be1be4406b05718d666d6d0f712c9cadb5169f2c/js/modelload/schemaload.js#L190-L198 | train |
SolarNetwork/solarnetwork-d3 | src/net/sec.js | token | function token(value) {
if ( !arguments.length ) return cred.token;
cred.token = (value && value.length > 0 ? value : undefined);
return that;
} | javascript | function token(value) {
if ( !arguments.length ) return cred.token;
cred.token = (value && value.length > 0 ? value : undefined);
return that;
} | [
"function",
"token",
"(",
"value",
")",
"{",
"if",
"(",
"!",
"arguments",
".",
"length",
")",
"return",
"cred",
".",
"token",
";",
"cred",
".",
"token",
"=",
"(",
"value",
"&&",
"value",
".",
"length",
">",
"0",
"?",
"value",
":",
"undefined",
")",... | Get or set the in-memory security token to use.
@param {String} [value] The value to set, or <code>null</code> to clear.
@returs When used as a getter, the current token value, otherwise this object.
@preserve | [
"Get",
"or",
"set",
"the",
"in",
"-",
"memory",
"security",
"token",
"to",
"use",
"."
] | 26848b1c303b98b7c0ddeefb8c68c5f5bf78927e | https://github.com/SolarNetwork/solarnetwork-d3/blob/26848b1c303b98b7c0ddeefb8c68c5f5bf78927e/src/net/sec.js#L55-L59 | train |
SolarNetwork/solarnetwork-d3 | src/net/sec.js | generateAuthorizationHeaderValue | function generateAuthorizationHeaderValue(signedHeaders, signKey, signingMsg) {
var signature = CryptoJS.HmacSHA256(signingMsg, signKey);
var authHeader = 'SNWS2 Credential=' +cred.token
+',SignedHeaders=' +signedHeaders.join(';')
+',Signature=' +CryptoJS.enc.Hex.stringify(signature);
return authHeader;
} | javascript | function generateAuthorizationHeaderValue(signedHeaders, signKey, signingMsg) {
var signature = CryptoJS.HmacSHA256(signingMsg, signKey);
var authHeader = 'SNWS2 Credential=' +cred.token
+',SignedHeaders=' +signedHeaders.join(';')
+',Signature=' +CryptoJS.enc.Hex.stringify(signature);
return authHeader;
} | [
"function",
"generateAuthorizationHeaderValue",
"(",
"signedHeaders",
",",
"signKey",
",",
"signingMsg",
")",
"{",
"var",
"signature",
"=",
"CryptoJS",
".",
"HmacSHA256",
"(",
"signingMsg",
",",
"signKey",
")",
";",
"var",
"authHeader",
"=",
"'SNWS2 Credential='",
... | Generate the V2 HTTP Authorization header.
@param {String} token the SN token ID
@param {Array} signedHeaders the sorted array of signed header names
@param {Object} signKey the key to encrypt the signature with
@param {String} signingMsg the message to sign
@return {String} the HTTP header value
@preserve | [
"Generate",
"the",
"V2",
"HTTP",
"Authorization",
"header",
"."
] | 26848b1c303b98b7c0ddeefb8c68c5f5bf78927e | https://github.com/SolarNetwork/solarnetwork-d3/blob/26848b1c303b98b7c0ddeefb8c68c5f5bf78927e/src/net/sec.js#L160-L166 | train |
SolarNetwork/solarnetwork-d3 | src/net/sec.js | computeAuthorization | function computeAuthorization(url, method, data, contentType, date) {
date = (date || new Date());
var uri = URI.parse(url);
var canonQueryParams = canonicalQueryParameters(uri, data, contentType);
var canonHeaders = canonicalHeaders(uri, contentType, date, bodyContentDigest);
var bodyContentDigest = body... | javascript | function computeAuthorization(url, method, data, contentType, date) {
date = (date || new Date());
var uri = URI.parse(url);
var canonQueryParams = canonicalQueryParameters(uri, data, contentType);
var canonHeaders = canonicalHeaders(uri, contentType, date, bodyContentDigest);
var bodyContentDigest = body... | [
"function",
"computeAuthorization",
"(",
"url",
",",
"method",
",",
"data",
",",
"contentType",
",",
"date",
")",
"{",
"date",
"=",
"(",
"date",
"||",
"new",
"Date",
"(",
")",
")",
";",
"var",
"uri",
"=",
"URI",
".",
"parse",
"(",
"url",
")",
";",
... | Compute SNWS2 authorization info.
<p>This method will compute the components necessary to later invoke a SolarNetwork
API request using the SNWS2 authorization scheme. The {@code token} and {@code secret}
properties must have been set on this object before calling this method.
Often just the <code>header</code> value... | [
"Compute",
"SNWS2",
"authorization",
"info",
"."
] | 26848b1c303b98b7c0ddeefb8c68c5f5bf78927e | https://github.com/SolarNetwork/solarnetwork-d3/blob/26848b1c303b98b7c0ddeefb8c68c5f5bf78927e/src/net/sec.js#L358-L395 | train |
SolarNetwork/solarnetwork-d3 | src/net/sec.js | json | function json(url, method, data, contentType, callback) {
var requestUrl = url;
// We might be passed to queue, and then our callback will be the last argument (but possibly not #5
// if the original call to queue didn't pass all arguments) so we check for that at the start and
// adjust what we consider the me... | javascript | function json(url, method, data, contentType, callback) {
var requestUrl = url;
// We might be passed to queue, and then our callback will be the last argument (but possibly not #5
// if the original call to queue didn't pass all arguments) so we check for that at the start and
// adjust what we consider the me... | [
"function",
"json",
"(",
"url",
",",
"method",
",",
"data",
",",
"contentType",
",",
"callback",
")",
"{",
"var",
"requestUrl",
"=",
"url",
";",
"// We might be passed to queue, and then our callback will be the last argument (but possibly not #5",
"// if the original call to... | Invoke the web service URL, adding the required SNWS2 authorization headers to the request.
<p>This method will construct the <code>X-SN-Date</code> and <code>Authorization</code>
header values needed to invoke the web service. It returns a d3 XHR object,
so you can call <code>.on()</code> on that to handle the respon... | [
"Invoke",
"the",
"web",
"service",
"URL",
"adding",
"the",
"required",
"SNWS2",
"authorization",
"headers",
"to",
"the",
"request",
"."
] | 26848b1c303b98b7c0ddeefb8c68c5f5bf78927e | https://github.com/SolarNetwork/solarnetwork-d3/blob/26848b1c303b98b7c0ddeefb8c68c5f5bf78927e/src/net/sec.js#L415-L474 | train |
racker/node-rackspace-shared-middleware | lib/middleware/validator.js | check | function check(log, validity, req, res, type, full, finalValidator, callback) {
var validator, v;
log.info.call(log, 'deserializing and validating request body', {
serializerType: type,
full: full,
finalValidator: finalValidator ? true : false
});
if (!req.body) {
callback(new Error('Empty Req... | javascript | function check(log, validity, req, res, type, full, finalValidator, callback) {
var validator, v;
log.info.call(log, 'deserializing and validating request body', {
serializerType: type,
full: full,
finalValidator: finalValidator ? true : false
});
if (!req.body) {
callback(new Error('Empty Req... | [
"function",
"check",
"(",
"log",
",",
"validity",
",",
"req",
",",
"res",
",",
"type",
",",
"full",
",",
"finalValidator",
",",
"callback",
")",
"{",
"var",
"validator",
",",
"v",
";",
"log",
".",
"info",
".",
"call",
"(",
"log",
",",
"'deserializing... | Verifies the object given. I thought about having it detect things
but that just seemed to be too leaky.
Serializes the object pointed to by data, into XML or JSON,
depending on the request headers. Using the object_name we look
up a consistent mapping of the Object -> XML/JSON layout.
@param {Object} log Log method... | [
"Verifies",
"the",
"object",
"given",
".",
"I",
"thought",
"about",
"having",
"it",
"detect",
"things",
"but",
"that",
"just",
"seemed",
"to",
"be",
"too",
"leaky",
"."
] | 613657b98b646e750882b5ce9b56ee7a1c6ac122 | https://github.com/racker/node-rackspace-shared-middleware/blob/613657b98b646e750882b5ce9b56ee7a1c6ac122/lib/middleware/validator.js#L26-L67 | 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.