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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
francium/highlight-page | src/highlight-page.js | function () {
let selection = dom(el).getSelection(),
range;
if (selection.rangeCount > 0) {
range = selection.getRangeAt(0);
}
return range;
} | javascript | function () {
let selection = dom(el).getSelection(),
range;
if (selection.rangeCount > 0) {
range = selection.getRangeAt(0);
}
return range;
} | [
"function",
"(",
")",
"{",
"let",
"selection",
"=",
"dom",
"(",
"el",
")",
".",
"getSelection",
"(",
")",
",",
"range",
";",
"if",
"(",
"selection",
".",
"rangeCount",
">",
"0",
")",
"{",
"range",
"=",
"selection",
".",
"getRangeAt",
"(",
"0",
")",... | Returns first range of the window of base element.
@returns {Range} | [
"Returns",
"first",
"range",
"of",
"the",
"window",
"of",
"base",
"element",
"."
] | 4e67fc531321f9987397dc247abba59b9d5ee521 | https://github.com/francium/highlight-page/blob/4e67fc531321f9987397dc247abba59b9d5ee521/src/highlight-page.js#L347-L356 | train | |
insacjs/field-creator | lib/class/Field.js | _isTHIS | function _isTHIS (obj) {
if (obj && obj._this && (obj._this === true)) {
return true
}
return false
} | javascript | function _isTHIS (obj) {
if (obj && obj._this && (obj._this === true)) {
return true
}
return false
} | [
"function",
"_isTHIS",
"(",
"obj",
")",
"{",
"if",
"(",
"obj",
"&&",
"obj",
".",
"_this",
"&&",
"(",
"obj",
".",
"_this",
"===",
"true",
")",
")",
"{",
"return",
"true",
"}",
"return",
"false",
"}"
] | Indica si un objeto es una referencia THIS.
@param {Object} obj - Objeto.
@return {Boolean} | [
"Indica",
"si",
"un",
"objeto",
"es",
"una",
"referencia",
"THIS",
"."
] | bbba706852966b61658288d9b42659fdc42f342b | https://github.com/insacjs/field-creator/blob/bbba706852966b61658288d9b42659fdc42f342b/lib/class/Field.js#L245-L250 | train |
insacjs/field-creator | lib/class/Field.js | _isField | function _isField (obj) {
if (obj && obj._modelAttribute && (obj._modelAttribute === true)) {
return true
}
return false
} | javascript | function _isField (obj) {
if (obj && obj._modelAttribute && (obj._modelAttribute === true)) {
return true
}
return false
} | [
"function",
"_isField",
"(",
"obj",
")",
"{",
"if",
"(",
"obj",
"&&",
"obj",
".",
"_modelAttribute",
"&&",
"(",
"obj",
".",
"_modelAttribute",
"===",
"true",
")",
")",
"{",
"return",
"true",
"}",
"return",
"false",
"}"
] | Indica si un objeto es atributo de un modelo.
@param {Object} obj - Objeto.
@return {Boolean} | [
"Indica",
"si",
"un",
"objeto",
"es",
"atributo",
"de",
"un",
"modelo",
"."
] | bbba706852966b61658288d9b42659fdc42f342b | https://github.com/insacjs/field-creator/blob/bbba706852966b61658288d9b42659fdc42f342b/lib/class/Field.js#L257-L262 | train |
insacjs/field-creator | lib/class/Field.js | _updateTHIS | function _updateTHIS (model, obj) {
const RESULT = {}
if (Array.isArray(obj)) {
return [_updateTHIS(model, obj[0])]
}
Object.keys(obj).forEach(prop => {
const OBJ = obj[prop]
if (_isTHIS(OBJ)) {
delete OBJ._this
RESULT[prop] = Object.assign(_.cloneDeep(model.attributes[prop]), OBJ)
... | javascript | function _updateTHIS (model, obj) {
const RESULT = {}
if (Array.isArray(obj)) {
return [_updateTHIS(model, obj[0])]
}
Object.keys(obj).forEach(prop => {
const OBJ = obj[prop]
if (_isTHIS(OBJ)) {
delete OBJ._this
RESULT[prop] = Object.assign(_.cloneDeep(model.attributes[prop]), OBJ)
... | [
"function",
"_updateTHIS",
"(",
"model",
",",
"obj",
")",
"{",
"const",
"RESULT",
"=",
"{",
"}",
"if",
"(",
"Array",
".",
"isArray",
"(",
"obj",
")",
")",
"{",
"return",
"[",
"_updateTHIS",
"(",
"model",
",",
"obj",
"[",
"0",
"]",
")",
"]",
"}",
... | Devuelve un objeto cuyos campos han sido definidos como THIS, con el valor que le corresponde.
Si el atributo no tiene un fieldName, se le asigna uno.
@param {SequelizeModel} model - Modelo Sequelize
@param {Object} obj - Objeto (grupo de fields).
@return {Object} | [
"Devuelve",
"un",
"objeto",
"cuyos",
"campos",
"han",
"sido",
"definidos",
"como",
"THIS",
"con",
"el",
"valor",
"que",
"le",
"corresponde",
".",
"Si",
"el",
"atributo",
"no",
"tiene",
"un",
"fieldName",
"se",
"le",
"asigna",
"uno",
"."
] | bbba706852966b61658288d9b42659fdc42f342b | https://github.com/insacjs/field-creator/blob/bbba706852966b61658288d9b42659fdc42f342b/lib/class/Field.js#L271-L295 | train |
insacjs/field-creator | lib/class/Field.js | _createValidate | function _createValidate (type, defaultValidate = {}, customValidate) {
if (customValidate === null) { return null }
let val = {}
if (type.key === 'STRING') { val = { len: [0, type.options.length] } }
if (type.key === 'TEXT') { val = { len: [0, 2147483647] } }
if (type.key === 'INTEGER') { val = { isIn... | javascript | function _createValidate (type, defaultValidate = {}, customValidate) {
if (customValidate === null) { return null }
let val = {}
if (type.key === 'STRING') { val = { len: [0, type.options.length] } }
if (type.key === 'TEXT') { val = { len: [0, 2147483647] } }
if (type.key === 'INTEGER') { val = { isIn... | [
"function",
"_createValidate",
"(",
"type",
",",
"defaultValidate",
"=",
"{",
"}",
",",
"customValidate",
")",
"{",
"if",
"(",
"customValidate",
"===",
"null",
")",
"{",
"return",
"null",
"}",
"let",
"val",
"=",
"{",
"}",
"if",
"(",
"type",
".",
"key",... | Devuelve un objeto validate.
@param {!SequelizeType} type - Propiedad tipo del atributo de un modelo sequelize.
@param {Object} [defaultValidate] - Propiedad validate por defecto.
@param {Object} [customValidate] - Propiedad validate personalizado.
@return {Object} | [
"Devuelve",
"un",
"objeto",
"validate",
"."
] | bbba706852966b61658288d9b42659fdc42f342b | https://github.com/insacjs/field-creator/blob/bbba706852966b61658288d9b42659fdc42f342b/lib/class/Field.js#L304-L323 | train |
insacjs/field-creator | lib/class/Field.js | _normalizeValidate | function _normalizeValidate (field) {
if (field.validate) {
Object.keys(field.validate).forEach(key => {
let validateItem = field.validate[key]
if (typeof validateItem === 'function') { return }
// Adiciona la propiedad args, si el validador no lo tuviera.
// Ejemplo: min: 10 -> min... | javascript | function _normalizeValidate (field) {
if (field.validate) {
Object.keys(field.validate).forEach(key => {
let validateItem = field.validate[key]
if (typeof validateItem === 'function') { return }
// Adiciona la propiedad args, si el validador no lo tuviera.
// Ejemplo: min: 10 -> min... | [
"function",
"_normalizeValidate",
"(",
"field",
")",
"{",
"if",
"(",
"field",
".",
"validate",
")",
"{",
"Object",
".",
"keys",
"(",
"field",
".",
"validate",
")",
".",
"forEach",
"(",
"key",
"=>",
"{",
"let",
"validateItem",
"=",
"field",
".",
"valida... | Normaliza la propiedad validate.
@param {Object} field Atributo de un modelo sequelize. | [
"Normaliza",
"la",
"propiedad",
"validate",
"."
] | bbba706852966b61658288d9b42659fdc42f342b | https://github.com/insacjs/field-creator/blob/bbba706852966b61658288d9b42659fdc42f342b/lib/class/Field.js#L404-L430 | train |
expedit85/valichain | index.js | function(v) {
return _.isNil(v) || (_.isString(v) && _.isEmpty(v));
} | javascript | function(v) {
return _.isNil(v) || (_.isString(v) && _.isEmpty(v));
} | [
"function",
"(",
"v",
")",
"{",
"return",
"_",
".",
"isNil",
"(",
"v",
")",
"||",
"(",
"_",
".",
"isString",
"(",
"v",
")",
"&&",
"_",
".",
"isEmpty",
"(",
"v",
")",
")",
";",
"}"
] | Returns true if argument is null, undefined or empty string.
@param {*} v - the value to be tested
@return {boolean} true if nil or "", false otherwise.
@memberof Valichain.$
@static | [
"Returns",
"true",
"if",
"argument",
"is",
"null",
"undefined",
"or",
"empty",
"string",
"."
] | 56f79fb9d53f879bbd81b25d573c8287993811f1 | https://github.com/expedit85/valichain/blob/56f79fb9d53f879bbd81b25d573c8287993811f1/index.js#L433-L435 | train | |
expedit85/valichain | index.js | function(v) {
return _.isNull(v) || (_.isString(v) && _.isEmpty(v));
} | javascript | function(v) {
return _.isNull(v) || (_.isString(v) && _.isEmpty(v));
} | [
"function",
"(",
"v",
")",
"{",
"return",
"_",
".",
"isNull",
"(",
"v",
")",
"||",
"(",
"_",
".",
"isString",
"(",
"v",
")",
"&&",
"_",
".",
"isEmpty",
"(",
"v",
")",
")",
";",
"}"
] | Returns true if argument is null or empty string.
@param {*} v - the value to be tested
@return {boolean} true if null or "", false otherwise.
@memberof Valichain.$
@static | [
"Returns",
"true",
"if",
"argument",
"is",
"null",
"or",
"empty",
"string",
"."
] | 56f79fb9d53f879bbd81b25d573c8287993811f1 | https://github.com/expedit85/valichain/blob/56f79fb9d53f879bbd81b25d573c8287993811f1/index.js#L446-L448 | train | |
expedit85/valichain | index.js | function(v) {
return !_.isNil(v)
&& (_.isString(v) || _.isNumber(v) || _.isBoolean)
&& !_.isObject(v);
} | javascript | function(v) {
return !_.isNil(v)
&& (_.isString(v) || _.isNumber(v) || _.isBoolean)
&& !_.isObject(v);
} | [
"function",
"(",
"v",
")",
"{",
"return",
"!",
"_",
".",
"isNil",
"(",
"v",
")",
"&&",
"(",
"_",
".",
"isString",
"(",
"v",
")",
"||",
"_",
".",
"isNumber",
"(",
"v",
")",
"||",
"_",
".",
"isBoolean",
")",
"&&",
"!",
"_",
".",
"isObject",
"... | Returns true if argument is not nil primitive. A not nil primitive is
a boolean, number or string, but neither null, undefined nor object.
@param {*} v - the value to be tested
@return {boolean} true if boolean, number or string, false otherwise.
@memberof Valichain.$
@static | [
"Returns",
"true",
"if",
"argument",
"is",
"not",
"nil",
"primitive",
".",
"A",
"not",
"nil",
"primitive",
"is",
"a",
"boolean",
"number",
"or",
"string",
"but",
"neither",
"null",
"undefined",
"nor",
"object",
"."
] | 56f79fb9d53f879bbd81b25d573c8287993811f1 | https://github.com/expedit85/valichain/blob/56f79fb9d53f879bbd81b25d573c8287993811f1/index.js#L460-L464 | train | |
DeadAlready/node-foldermap | lib/map.js | normalize | function normalize(opts) {
if (typeof opts === 'string') {
opts = {path: opts};
}
opts.path = path.resolve(opts.path);
return opts;
} | javascript | function normalize(opts) {
if (typeof opts === 'string') {
opts = {path: opts};
}
opts.path = path.resolve(opts.path);
return opts;
} | [
"function",
"normalize",
"(",
"opts",
")",
"{",
"if",
"(",
"typeof",
"opts",
"===",
"'string'",
")",
"{",
"opts",
"=",
"{",
"path",
":",
"opts",
"}",
";",
"}",
"opts",
".",
"path",
"=",
"path",
".",
"resolve",
"(",
"opts",
".",
"path",
")",
";",
... | Function for normalizing input
@param opts
@returns {*} | [
"Function",
"for",
"normalizing",
"input"
] | be6048cb3b3e9fa3b6f36542cb8835d48c7bde1d | https://github.com/DeadAlready/node-foldermap/blob/be6048cb3b3e9fa3b6f36542cb8835d48c7bde1d/lib/map.js#L13-L19 | train |
DeadAlready/node-foldermap | lib/map.js | mapObjects | function mapObjects(root, list, callback) {
var ret = {};
var sent = false;
var count = list.length;
if (count === 0) {
callback(null, ret);
}
list.forEach(function (pointer) {
var name = path.join(root._path, pointer);
fp.define({filePath: name, parent: root}, function (err, obj) {
if (err) {
if (!s... | javascript | function mapObjects(root, list, callback) {
var ret = {};
var sent = false;
var count = list.length;
if (count === 0) {
callback(null, ret);
}
list.forEach(function (pointer) {
var name = path.join(root._path, pointer);
fp.define({filePath: name, parent: root}, function (err, obj) {
if (err) {
if (!s... | [
"function",
"mapObjects",
"(",
"root",
",",
"list",
",",
"callback",
")",
"{",
"var",
"ret",
"=",
"{",
"}",
";",
"var",
"sent",
"=",
"false",
";",
"var",
"count",
"=",
"list",
".",
"length",
";",
"if",
"(",
"count",
"===",
"0",
")",
"{",
"callbac... | Function for mapping a list of objects relative to root object
@param root - Folder object
@param list - Array of file names
@param callback(err, result) - Function | [
"Function",
"for",
"mapping",
"a",
"list",
"of",
"objects",
"relative",
"to",
"root",
"object"
] | be6048cb3b3e9fa3b6f36542cb8835d48c7bde1d | https://github.com/DeadAlready/node-foldermap/blob/be6048cb3b3e9fa3b6f36542cb8835d48c7bde1d/lib/map.js#L28-L55 | train |
DeadAlready/node-foldermap | lib/map.js | filter | function filter(pObjects, opts, returnArray) {
var filtered = returnArray ? [] : {};
function addToFiltered(key) {
if(returnArray) {
filtered.push((returnArray === 'keys' ? key : pObjects[key]));
} else {
filtered[key] = pObjects[key];
}
}
if (!opts) {
... | javascript | function filter(pObjects, opts, returnArray) {
var filtered = returnArray ? [] : {};
function addToFiltered(key) {
if(returnArray) {
filtered.push((returnArray === 'keys' ? key : pObjects[key]));
} else {
filtered[key] = pObjects[key];
}
}
if (!opts) {
... | [
"function",
"filter",
"(",
"pObjects",
",",
"opts",
",",
"returnArray",
")",
"{",
"var",
"filtered",
"=",
"returnArray",
"?",
"[",
"]",
":",
"{",
"}",
";",
"function",
"addToFiltered",
"(",
"key",
")",
"{",
"if",
"(",
"returnArray",
")",
"{",
"filtered... | Function for filtering pointer objects based on options
@param pObjects - object with subobjects being pointer objects
@param opts - options to use when filtering
@param returnArray - return an array instead of object
@returns {*} || [*] - object or array with filtered results | [
"Function",
"for",
"filtering",
"pointer",
"objects",
"based",
"on",
"options"
] | be6048cb3b3e9fa3b6f36542cb8835d48c7bde1d | https://github.com/DeadAlready/node-foldermap/blob/be6048cb3b3e9fa3b6f36542cb8835d48c7bde1d/lib/map.js#L65-L121 | train |
DeadAlready/node-foldermap | lib/map.js | transfer | function transfer(root, map, opts) {
map = filter(map, opts);
var folders = [];
function getIndex(k) {
var index = k;
if (opts.relative) {
var replace = opts.relative === true ? (root._path + path.sep) : opts.relative;
index = k.replace(replace, '');
}
return index;
}
Object.keys(map).forEach(func... | javascript | function transfer(root, map, opts) {
map = filter(map, opts);
var folders = [];
function getIndex(k) {
var index = k;
if (opts.relative) {
var replace = opts.relative === true ? (root._path + path.sep) : opts.relative;
index = k.replace(replace, '');
}
return index;
}
Object.keys(map).forEach(func... | [
"function",
"transfer",
"(",
"root",
",",
"map",
",",
"opts",
")",
"{",
"map",
"=",
"filter",
"(",
"map",
",",
"opts",
")",
";",
"var",
"folders",
"=",
"[",
"]",
";",
"function",
"getIndex",
"(",
"k",
")",
"{",
"var",
"index",
"=",
"k",
";",
"i... | Function for transferring properties from map to root using opts
@param root {Object} - object to attach new pointers to
@param map {Object} - object with properties being pointer objects
@param opts {Object} - options
@returns {Array} - Folders for recursive mapping | [
"Function",
"for",
"transferring",
"properties",
"from",
"map",
"to",
"root",
"using",
"opts"
] | be6048cb3b3e9fa3b6f36542cb8835d48c7bde1d | https://github.com/DeadAlready/node-foldermap/blob/be6048cb3b3e9fa3b6f36542cb8835d48c7bde1d/lib/map.js#L131-L159 | train |
DeadAlready/node-foldermap | lib/map.js | simpleMap | function simpleMap(map, lvls, opts, type, ext, callback) {
opts = utils.clone(opts);
lvls--;
if(lvls < 1) {
opts.simple = false;
opts.recursive = true;
opts.type = type;
opts.ext = ext;
}
var folders = map.__filter({type:'directory'}, true);
var count = folders.le... | javascript | function simpleMap(map, lvls, opts, type, ext, callback) {
opts = utils.clone(opts);
lvls--;
if(lvls < 1) {
opts.simple = false;
opts.recursive = true;
opts.type = type;
opts.ext = ext;
}
var folders = map.__filter({type:'directory'}, true);
var count = folders.le... | [
"function",
"simpleMap",
"(",
"map",
",",
"lvls",
",",
"opts",
",",
"type",
",",
"ext",
",",
"callback",
")",
"{",
"opts",
"=",
"utils",
".",
"clone",
"(",
"opts",
")",
";",
"lvls",
"--",
";",
"if",
"(",
"lvls",
"<",
"1",
")",
"{",
"opts",
".",... | Function for mapping simple first x lvls
@param map -> root map
@param lvls -> nr of levels
@param opts -> the options
@param type -> the final type to use
@param callback | [
"Function",
"for",
"mapping",
"simple",
"first",
"x",
"lvls"
] | be6048cb3b3e9fa3b6f36542cb8835d48c7bde1d | https://github.com/DeadAlready/node-foldermap/blob/be6048cb3b3e9fa3b6f36542cb8835d48c7bde1d/lib/map.js#L327-L366 | train |
DeadAlready/node-foldermap | lib/map.js | map | function map(opts, callback) {
if(utils.isArray(opts)) {
mapWithArrayInput(opts, callback);
return;
}
opts = normalize(opts);
// Assume that the root is a folder
var root = new fp.Folder(opts.path);
var sent = false;
root.__listen('error', function (err) {
if (!sent)... | javascript | function map(opts, callback) {
if(utils.isArray(opts)) {
mapWithArrayInput(opts, callback);
return;
}
opts = normalize(opts);
// Assume that the root is a folder
var root = new fp.Folder(opts.path);
var sent = false;
root.__listen('error', function (err) {
if (!sent)... | [
"function",
"map",
"(",
"opts",
",",
"callback",
")",
"{",
"if",
"(",
"utils",
".",
"isArray",
"(",
"opts",
")",
")",
"{",
"mapWithArrayInput",
"(",
"opts",
",",
"callback",
")",
";",
"return",
";",
"}",
"opts",
"=",
"normalize",
"(",
"opts",
")",
... | Function for mapping a folder and returning a foldermap
@param opts -> object or array of objects
@param callback | [
"Function",
"for",
"mapping",
"a",
"folder",
"and",
"returning",
"a",
"foldermap"
] | be6048cb3b3e9fa3b6f36542cb8835d48c7bde1d | https://github.com/DeadAlready/node-foldermap/blob/be6048cb3b3e9fa3b6f36542cb8835d48c7bde1d/lib/map.js#L405-L468 | train |
kvnneff/incremental | index.js | increment | function increment(value, skip, incrementBy) {
var str = (typeof value === 'string');
var incrementBy = incrementBy || 1;
var numeric = !isNaN(value);
var skip = skip || [];
var nextVal;
if (numeric) {
value = parseInt(value) + parseInt(incrementBy);
} else {
value = String.... | javascript | function increment(value, skip, incrementBy) {
var str = (typeof value === 'string');
var incrementBy = incrementBy || 1;
var numeric = !isNaN(value);
var skip = skip || [];
var nextVal;
if (numeric) {
value = parseInt(value) + parseInt(incrementBy);
} else {
value = String.... | [
"function",
"increment",
"(",
"value",
",",
"skip",
",",
"incrementBy",
")",
"{",
"var",
"str",
"=",
"(",
"typeof",
"value",
"===",
"'string'",
")",
";",
"var",
"incrementBy",
"=",
"incrementBy",
"||",
"1",
";",
"var",
"numeric",
"=",
"!",
"isNaN",
"("... | Increment a number or alpha character
@param {String|Number} value
@param {Array} skip
@param {Number} incrementBy
@return {String|Number}
@api public | [
"Increment",
"a",
"number",
"or",
"alpha",
"character"
] | ed412879d3c22a3912ebfb9e7fc6a41f789196bb | https://github.com/kvnneff/incremental/blob/ed412879d3c22a3912ebfb9e7fc6a41f789196bb/index.js#L15-L31 | train |
samleybrize/node-package-json-discover | lib/package-json-discover.js | discover | function discover(from) {
from = from || caller();
// check 'from' validity
if ("string" != typeof from) {
var given = typeof from;
throw new Error("'from' must be a string, [" + given + "] given");
}
// if 'from' is not absolute, make it absolute
if (!pathIsAbsolute(from)) {
... | javascript | function discover(from) {
from = from || caller();
// check 'from' validity
if ("string" != typeof from) {
var given = typeof from;
throw new Error("'from' must be a string, [" + given + "] given");
}
// if 'from' is not absolute, make it absolute
if (!pathIsAbsolute(from)) {
... | [
"function",
"discover",
"(",
"from",
")",
"{",
"from",
"=",
"from",
"||",
"caller",
"(",
")",
";",
"// check 'from' validity",
"if",
"(",
"\"string\"",
"!=",
"typeof",
"from",
")",
"{",
"var",
"given",
"=",
"typeof",
"from",
";",
"throw",
"new",
"Error",... | Discovers the closest package.json file and returns its absolute path
@param {string} [from] - The path to the directory where to start discovering. If omitted, it is the path to the file that calls this function.
@returns {string} | [
"Discovers",
"the",
"closest",
"package",
".",
"json",
"file",
"and",
"returns",
"its",
"absolute",
"path"
] | 1e95d15406ba32b80d3998a5bb4016a1431ebd5c | https://github.com/samleybrize/node-package-json-discover/blob/1e95d15406ba32b80d3998a5bb4016a1431ebd5c/lib/package-json-discover.js#L21-L87 | train |
enricostara/get-log | lib/get-log.js | Logger | function Logger(name) {
var prjName = module.exports.PROJECT_NAME;
this.name = prjName ? prjName + ':' + name : name;
this._debug = debug(this.name);
this._debug.log = logDebug;
this.debugEnabled = debug.enabled(this.name);
if (this.debugEnabled) {
logDebug('[%s] debug is %s', this.name.... | javascript | function Logger(name) {
var prjName = module.exports.PROJECT_NAME;
this.name = prjName ? prjName + ':' + name : name;
this._debug = debug(this.name);
this._debug.log = logDebug;
this.debugEnabled = debug.enabled(this.name);
if (this.debugEnabled) {
logDebug('[%s] debug is %s', this.name.... | [
"function",
"Logger",
"(",
"name",
")",
"{",
"var",
"prjName",
"=",
"module",
".",
"exports",
".",
"PROJECT_NAME",
";",
"this",
".",
"name",
"=",
"prjName",
"?",
"prjName",
"+",
"':'",
"+",
"name",
":",
"name",
";",
"this",
".",
"_debug",
"=",
"debug... | The constructor requires the logger name | [
"The",
"constructor",
"requires",
"the",
"logger",
"name"
] | 2a78a8397e4282064979bcd4291685cbe8e52745 | https://github.com/enricostara/get-log/blob/2a78a8397e4282064979bcd4291685cbe8e52745/lib/get-log.js#L55-L64 | train |
schwarzkopfb/extw | index.js | extractWords | function extractWords(str, store) {
if (!str)
return []
if (Array.isArray(str))
return str
assert.equal(typeof str, 'string', 'first parameter must be an array or string')
switch (store) {
case undefined:
if (cache)
return parseWordListCached(str, c... | javascript | function extractWords(str, store) {
if (!str)
return []
if (Array.isArray(str))
return str
assert.equal(typeof str, 'string', 'first parameter must be an array or string')
switch (store) {
case undefined:
if (cache)
return parseWordListCached(str, c... | [
"function",
"extractWords",
"(",
"str",
",",
"store",
")",
"{",
"if",
"(",
"!",
"str",
")",
"return",
"[",
"]",
"if",
"(",
"Array",
".",
"isArray",
"(",
"str",
")",
")",
"return",
"str",
"assert",
".",
"equal",
"(",
"typeof",
"str",
",",
"'string'"... | Extract words from a given string.
@param {string|Array} str The string to parse.
@param {null|Object} [store] Pass an object to use for caching instead of the default one. Or pass `null` to disable caching for this call.
@returns {[string]} | [
"Extract",
"words",
"from",
"a",
"given",
"string",
"."
] | d95befe35cdd3c2ed5b10bbe83176323a3f86521 | https://github.com/schwarzkopfb/extw/blob/d95befe35cdd3c2ed5b10bbe83176323a3f86521/index.js#L26-L50 | train |
nathanhood/postcss-variable-media | index.js | registerBreakpoints | function registerBreakpoints(breakpoints) {
let register = [];
Object.keys(breakpoints).forEach(name => {
register.push('(^' + escRgx(name) + '$)');
});
if (! register.length) {
return false;
}
return new RegExp(register.join('|'));
} | javascript | function registerBreakpoints(breakpoints) {
let register = [];
Object.keys(breakpoints).forEach(name => {
register.push('(^' + escRgx(name) + '$)');
});
if (! register.length) {
return false;
}
return new RegExp(register.join('|'));
} | [
"function",
"registerBreakpoints",
"(",
"breakpoints",
")",
"{",
"let",
"register",
"=",
"[",
"]",
";",
"Object",
".",
"keys",
"(",
"breakpoints",
")",
".",
"forEach",
"(",
"name",
"=>",
"{",
"register",
".",
"push",
"(",
"'(^'",
"+",
"escRgx",
"(",
"n... | Create regex to identify breakpoints
@param {object} breakpoints
@returns {RegExp} | [
"Create",
"regex",
"to",
"identify",
"breakpoints"
] | c8a761e6dc6d925309197e39e4e650b8ef5cdab7 | https://github.com/nathanhood/postcss-variable-media/blob/c8a761e6dc6d925309197e39e4e650b8ef5cdab7/index.js#L19-L31 | train |
nathanhood/postcss-variable-media | index.js | convertBreakpointToMedia | function convertBreakpointToMedia(rule) {
rule.params = `(min-width: ${breakpoints[rule.name]}px)`;
rule.name = 'media';
rule.raws.afterName = ' ';
rule.raws.between = ' ';
return rule;
} | javascript | function convertBreakpointToMedia(rule) {
rule.params = `(min-width: ${breakpoints[rule.name]}px)`;
rule.name = 'media';
rule.raws.afterName = ' ';
rule.raws.between = ' ';
return rule;
} | [
"function",
"convertBreakpointToMedia",
"(",
"rule",
")",
"{",
"rule",
".",
"params",
"=",
"`",
"${",
"breakpoints",
"[",
"rule",
".",
"name",
"]",
"}",
"`",
";",
"rule",
".",
"name",
"=",
"'media'",
";",
"rule",
".",
"raws",
".",
"afterName",
"=",
"... | Turn breakpoint to media
@param {postcss.Container} rule - AtRule
@returns {*} | [
"Turn",
"breakpoint",
"to",
"media"
] | c8a761e6dc6d925309197e39e4e650b8ef5cdab7 | https://github.com/nathanhood/postcss-variable-media/blob/c8a761e6dc6d925309197e39e4e650b8ef5cdab7/index.js#L39-L46 | train |
nathanhood/postcss-variable-media | index.js | addToRegistry | function addToRegistry(rule) {
let name = rule.name;
if (registry.hasOwnProperty(name)) {
// `each` allows for safe looping while modifying the
// array being looped over. `append` is removing the rule
// from the array being looped over, so it is necessary
// to use this method instead of forEach
... | javascript | function addToRegistry(rule) {
let name = rule.name;
if (registry.hasOwnProperty(name)) {
// `each` allows for safe looping while modifying the
// array being looped over. `append` is removing the rule
// from the array being looped over, so it is necessary
// to use this method instead of forEach
... | [
"function",
"addToRegistry",
"(",
"rule",
")",
"{",
"let",
"name",
"=",
"rule",
".",
"name",
";",
"if",
"(",
"registry",
".",
"hasOwnProperty",
"(",
"name",
")",
")",
"{",
"// `each` allows for safe looping while modifying the",
"// array being looped over. `append` i... | Add breakpoint to registry
@param {object} rule - AtRule | [
"Add",
"breakpoint",
"to",
"registry"
] | c8a761e6dc6d925309197e39e4e650b8ef5cdab7 | https://github.com/nathanhood/postcss-variable-media/blob/c8a761e6dc6d925309197e39e4e650b8ef5cdab7/index.js#L53-L65 | train |
gethuman/pancakes-hapi | lib/pancakes.hapi.web.js | processRoute | function processRoute(opts) {
if (routeHandler) {
routeHandler(opts.request, opts.reply, opts.urlOverride, opts.returnCode);
}
else {
opts.reply.continue();
}
} | javascript | function processRoute(opts) {
if (routeHandler) {
routeHandler(opts.request, opts.reply, opts.urlOverride, opts.returnCode);
}
else {
opts.reply.continue();
}
} | [
"function",
"processRoute",
"(",
"opts",
")",
"{",
"if",
"(",
"routeHandler",
")",
"{",
"routeHandler",
"(",
"opts",
".",
"request",
",",
"opts",
".",
"reply",
",",
"opts",
".",
"urlOverride",
",",
"opts",
".",
"returnCode",
")",
";",
"}",
"else",
"{",... | The idea here is to use the same request and reply
but a different route handler based on the given URL override | [
"The",
"idea",
"here",
"is",
"to",
"use",
"the",
"same",
"request",
"and",
"reply",
"but",
"a",
"different",
"route",
"handler",
"based",
"on",
"the",
"given",
"URL",
"override"
] | 1167cd7564cd8949c446c6fd8d95185f52b14492 | https://github.com/gethuman/pancakes-hapi/blob/1167cd7564cd8949c446c6fd8d95185f52b14492/lib/pancakes.hapi.web.js#L80-L87 | train |
gethuman/pancakes-hapi | lib/pancakes.hapi.web.js | getServerPreProcessing | function getServerPreProcessing(request, reply) {
var me = this;
return function (routeInfo, page, model) {
if (!page.serverPreprocessing) { return false; }
var deps = { request: request, reply: reply, model: model, routeInfo: routeInfo };
return me.pancakes.cook(page.serverPreprocessi... | javascript | function getServerPreProcessing(request, reply) {
var me = this;
return function (routeInfo, page, model) {
if (!page.serverPreprocessing) { return false; }
var deps = { request: request, reply: reply, model: model, routeInfo: routeInfo };
return me.pancakes.cook(page.serverPreprocessi... | [
"function",
"getServerPreProcessing",
"(",
"request",
",",
"reply",
")",
"{",
"var",
"me",
"=",
"this",
";",
"return",
"function",
"(",
"routeInfo",
",",
"page",
",",
"model",
")",
"{",
"if",
"(",
"!",
"page",
".",
"serverPreprocessing",
")",
"{",
"retur... | Execute the server preprocessing method and return true if the preprocessor
handled the request
@param request
@param reply
@returns {Function} | [
"Execute",
"the",
"server",
"preprocessing",
"method",
"and",
"return",
"true",
"if",
"the",
"preprocessor",
"handled",
"the",
"request"
] | 1167cd7564cd8949c446c6fd8d95185f52b14492 | https://github.com/gethuman/pancakes-hapi/blob/1167cd7564cd8949c446c6fd8d95185f52b14492/lib/pancakes.hapi.web.js#L97-L106 | train |
gethuman/pancakes-hapi | lib/pancakes.hapi.web.js | getWebRouteHandler | function getWebRouteHandler(opts) {
var webRouteHandler = this.pancakes.webRouteHandler;
var me = this;
return function handleWebRoute(request, reply, urlOverride, returnCode) {
var appName = request.app.name;
var url = urlOverride || request.url.pathname;
var routeInfo = null;
... | javascript | function getWebRouteHandler(opts) {
var webRouteHandler = this.pancakes.webRouteHandler;
var me = this;
return function handleWebRoute(request, reply, urlOverride, returnCode) {
var appName = request.app.name;
var url = urlOverride || request.url.pathname;
var routeInfo = null;
... | [
"function",
"getWebRouteHandler",
"(",
"opts",
")",
"{",
"var",
"webRouteHandler",
"=",
"this",
".",
"pancakes",
".",
"webRouteHandler",
";",
"var",
"me",
"=",
"this",
";",
"return",
"function",
"handleWebRoute",
"(",
"request",
",",
"reply",
",",
"urlOverride... | Render the web route for one of the dynamic routes. These routes are based off of
the .app config files for each app.
@param opts | [
"Render",
"the",
"web",
"route",
"for",
"one",
"of",
"the",
"dynamic",
"routes",
".",
"These",
"routes",
"are",
"based",
"off",
"of",
"the",
".",
"app",
"config",
"files",
"for",
"each",
"app",
"."
] | 1167cd7564cd8949c446c6fd8d95185f52b14492 | https://github.com/gethuman/pancakes-hapi/blob/1167cd7564cd8949c446c6fd8d95185f52b14492/lib/pancakes.hapi.web.js#L114-L196 | train |
konfirm/node-wanted | lib/wanted.js | error | function error(message) {
if (EventEmitter.listenerCount(wanted, 'error') > 0) {
return wanted.emit('error', message);
}
throw new Error(message);
} | javascript | function error(message) {
if (EventEmitter.listenerCount(wanted, 'error') > 0) {
return wanted.emit('error', message);
}
throw new Error(message);
} | [
"function",
"error",
"(",
"message",
")",
"{",
"if",
"(",
"EventEmitter",
".",
"listenerCount",
"(",
"wanted",
",",
"'error'",
")",
">",
"0",
")",
"{",
"return",
"wanted",
".",
"emit",
"(",
"'error'",
",",
"message",
")",
";",
"}",
"throw",
"new",
"E... | Trigger an error emission or throw it, depending on where a listener for error emission is present
@name error
@access internal
@param string message
@return void | [
"Trigger",
"an",
"error",
"emission",
"or",
"throw",
"it",
"depending",
"on",
"where",
"a",
"listener",
"for",
"error",
"emission",
"is",
"present"
] | 797cf41bde7bf67f74bcd59a97cc28ddb084e2ca | https://github.com/konfirm/node-wanted/blob/797cf41bde7bf67f74bcd59a97cc28ddb084e2ca/lib/wanted.js#L52-L58 | train |
konfirm/node-wanted | lib/wanted.js | processed | function processed(module) {
pool.processed.push(module);
if (!module.installed) {
pool.install.push(module);
}
setImmediate(next);
} | javascript | function processed(module) {
pool.processed.push(module);
if (!module.installed) {
pool.install.push(module);
}
setImmediate(next);
} | [
"function",
"processed",
"(",
"module",
")",
"{",
"pool",
".",
"processed",
".",
"push",
"(",
"module",
")",
";",
"if",
"(",
"!",
"module",
".",
"installed",
")",
"{",
"pool",
".",
"install",
".",
"push",
"(",
"module",
")",
";",
"}",
"setImmediate",... | Remove a module from the queue
@name processed
@access internal
@param object module
@return void | [
"Remove",
"a",
"module",
"from",
"the",
"queue"
] | 797cf41bde7bf67f74bcd59a97cc28ddb084e2ca | https://github.com/konfirm/node-wanted/blob/797cf41bde7bf67f74bcd59a97cc28ddb084e2ca/lib/wanted.js#L67-L75 | train |
konfirm/node-wanted | lib/wanted.js | next | function next() {
var module;
if (pool.queue.length <= 0) {
if (pool.install.length) {
error('Update needed: ' + pool.install.map(function(module) {
return module.name;
}).join(', '));
}
else {
wanted.emit('ready', pool.processed.map(shallow));
}
return reset();
}
module = poo... | javascript | function next() {
var module;
if (pool.queue.length <= 0) {
if (pool.install.length) {
error('Update needed: ' + pool.install.map(function(module) {
return module.name;
}).join(', '));
}
else {
wanted.emit('ready', pool.processed.map(shallow));
}
return reset();
}
module = poo... | [
"function",
"next",
"(",
")",
"{",
"var",
"module",
";",
"if",
"(",
"pool",
".",
"queue",
".",
"length",
"<=",
"0",
")",
"{",
"if",
"(",
"pool",
".",
"install",
".",
"length",
")",
"{",
"error",
"(",
"'Update needed: '",
"+",
"pool",
".",
"install"... | Pick the next item from the queue and process it
@name next
@return void | [
"Pick",
"the",
"next",
"item",
"from",
"the",
"queue",
"and",
"process",
"it"
] | 797cf41bde7bf67f74bcd59a97cc28ddb084e2ca | https://github.com/konfirm/node-wanted/blob/797cf41bde7bf67f74bcd59a97cc28ddb084e2ca/lib/wanted.js#L82-L119 | train |
konfirm/node-wanted | lib/wanted.js | fileExists | function fileExists(file, handle) {
fs.exists(file, function(exists) {
handle.apply(null, exists ? [file] : []);
});
} | javascript | function fileExists(file, handle) {
fs.exists(file, function(exists) {
handle.apply(null, exists ? [file] : []);
});
} | [
"function",
"fileExists",
"(",
"file",
",",
"handle",
")",
"{",
"fs",
".",
"exists",
"(",
"file",
",",
"function",
"(",
"exists",
")",
"{",
"handle",
".",
"apply",
"(",
"null",
",",
"exists",
"?",
"[",
"file",
"]",
":",
"[",
"]",
")",
";",
"}",
... | Simple wrapper around fs.exists, allowing us to provide the filename in case it does exist
@name fileExists
@access internal
@param string file
@param function handle
@return void | [
"Simple",
"wrapper",
"around",
"fs",
".",
"exists",
"allowing",
"us",
"to",
"provide",
"the",
"filename",
"in",
"case",
"it",
"does",
"exist"
] | 797cf41bde7bf67f74bcd59a97cc28ddb084e2ca | https://github.com/konfirm/node-wanted/blob/797cf41bde7bf67f74bcd59a97cc28ddb084e2ca/lib/wanted.js#L170-L174 | train |
konfirm/node-wanted | lib/wanted.js | shallow | function shallow(module) {
return {
name: module.name,
version: module.version,
installed: module.installed,
scope: module.scope,
state: module.current ? 'current' : (module.upgrade ? 'upgrade' : 'install')
};
} | javascript | function shallow(module) {
return {
name: module.name,
version: module.version,
installed: module.installed,
scope: module.scope,
state: module.current ? 'current' : (module.upgrade ? 'upgrade' : 'install')
};
} | [
"function",
"shallow",
"(",
"module",
")",
"{",
"return",
"{",
"name",
":",
"module",
".",
"name",
",",
"version",
":",
"module",
".",
"version",
",",
"installed",
":",
"module",
".",
"installed",
",",
"scope",
":",
"module",
".",
"scope",
",",
"state"... | Reduce the internal module configuration for external exposure
@name shallow
@param Object module
@return Object shallow module | [
"Reduce",
"the",
"internal",
"module",
"configuration",
"for",
"external",
"exposure"
] | 797cf41bde7bf67f74bcd59a97cc28ddb084e2ca | https://github.com/konfirm/node-wanted/blob/797cf41bde7bf67f74bcd59a97cc28ddb084e2ca/lib/wanted.js#L255-L263 | train |
syntheticore/declaire | src/bootstrap.js | function(name) {
var handler = function(e) {
//XXX add id to element
_declaireLog.push(e);
};
var html = document.getElementsByTagName('html')[0];
html.addEventListener(name, handler);
return handler;
} | javascript | function(name) {
var handler = function(e) {
//XXX add id to element
_declaireLog.push(e);
};
var html = document.getElementsByTagName('html')[0];
html.addEventListener(name, handler);
return handler;
} | [
"function",
"(",
"name",
")",
"{",
"var",
"handler",
"=",
"function",
"(",
"e",
")",
"{",
"//XXX add id to element",
"_declaireLog",
".",
"push",
"(",
"e",
")",
";",
"}",
";",
"var",
"html",
"=",
"document",
".",
"getElementsByTagName",
"(",
"'html'",
")... | Listen for events on html element and save these to the log | [
"Listen",
"for",
"events",
"on",
"html",
"element",
"and",
"save",
"these",
"to",
"the",
"log"
] | cb5ea205eeb3aa26fd0c6348e86d840c04e9ba9f | https://github.com/syntheticore/declaire/blob/cb5ea205eeb3aa26fd0c6348e86d840c04e9ba9f/src/bootstrap.js#L6-L14 | train | |
scrapjs/rela | lib/server.js | Server | function Server(opts){
// Shorthand, no "new" required.
if (!(this instanceof Server))
return new Server(...arguments);
if (typeof opts !== 'object')
opts = {};
this.clients = opts.dummies || [];
this.server = opts.server || new SocketServer(socket => {
let client = new Client(socket);
this... | javascript | function Server(opts){
// Shorthand, no "new" required.
if (!(this instanceof Server))
return new Server(...arguments);
if (typeof opts !== 'object')
opts = {};
this.clients = opts.dummies || [];
this.server = opts.server || new SocketServer(socket => {
let client = new Client(socket);
this... | [
"function",
"Server",
"(",
"opts",
")",
"{",
"// Shorthand, no \"new\" required.",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Server",
")",
")",
"return",
"new",
"Server",
"(",
"...",
"arguments",
")",
";",
"if",
"(",
"typeof",
"opts",
"!==",
"'object'",
... | The server object, Rela. | [
"The",
"server",
"object",
"Rela",
"."
] | 7e3ed535fea68a3292bad9d9ce220360c45389e8 | https://github.com/scrapjs/rela/blob/7e3ed535fea68a3292bad9d9ce220360c45389e8/lib/server.js#L17-L37 | train |
xiamidaxia/xiami | meteor/minimongo/selector_modifier.js | function (obj, keys) {
return _.all(obj, function (v, k) {
return _.contains(keys, k);
});
} | javascript | function (obj, keys) {
return _.all(obj, function (v, k) {
return _.contains(keys, k);
});
} | [
"function",
"(",
"obj",
",",
"keys",
")",
"{",
"return",
"_",
".",
"all",
"(",
"obj",
",",
"function",
"(",
"v",
",",
"k",
")",
"{",
"return",
"_",
".",
"contains",
"(",
"keys",
",",
"k",
")",
";",
"}",
")",
";",
"}"
] | A helper to ensure object has only certain keys | [
"A",
"helper",
"to",
"ensure",
"object",
"has",
"only",
"certain",
"keys"
] | 6fcee92c493c12bf8fd67c7068e67fa6a72a306b | https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/minimongo/selector_modifier.js#L214-L218 | train | |
alexpods/ClazzJS | src/components/meta/Methods.js | function(clazz, metaData) {
this.applyMethods(clazz, metaData.clazz_methods || {});
this.applyMethods(clazz.prototype, metaData.methods || {});
} | javascript | function(clazz, metaData) {
this.applyMethods(clazz, metaData.clazz_methods || {});
this.applyMethods(clazz.prototype, metaData.methods || {});
} | [
"function",
"(",
"clazz",
",",
"metaData",
")",
"{",
"this",
".",
"applyMethods",
"(",
"clazz",
",",
"metaData",
".",
"clazz_methods",
"||",
"{",
"}",
")",
";",
"this",
".",
"applyMethods",
"(",
"clazz",
".",
"prototype",
",",
"metaData",
".",
"methods",... | Applies methods to clazz and its prototype
@param {clazz} clazz Clazz
@param {object} metaData Meta data with properties 'methods' and 'clazz_methods'
@this {metaProcessor} | [
"Applies",
"methods",
"to",
"clazz",
"and",
"its",
"prototype"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Methods.js#L15-L18 | train | |
alexpods/ClazzJS | src/components/meta/Methods.js | function(object, methods) {
_.each(methods, function(method, name) {
if (!_.isFunction(method)) {
throw new Error('Method "' + name + '" must be a function!');
}
object[name] = method
});
} | javascript | function(object, methods) {
_.each(methods, function(method, name) {
if (!_.isFunction(method)) {
throw new Error('Method "' + name + '" must be a function!');
}
object[name] = method
});
} | [
"function",
"(",
"object",
",",
"methods",
")",
"{",
"_",
".",
"each",
"(",
"methods",
",",
"function",
"(",
"method",
",",
"name",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isFunction",
"(",
"method",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Me... | Applies methods to specified object
@param {object} object Object for methods applying
@param {object} methods Hash of methods
@this {Error} if method is not a funciton
@this {metaProcessor} | [
"Applies",
"methods",
"to",
"specified",
"object"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Methods.js#L30-L37 | train | |
cli-kit/cli-locale | index.js | sanitize | function sanitize(lang, filter) {
if(!(typeof lang == 'string')) return lang;
lang = lang.replace(/\..*$/, '').toLowerCase();
if(typeof filter == 'function') {
lang = filter(lang);
}
return lang;
} | javascript | function sanitize(lang, filter) {
if(!(typeof lang == 'string')) return lang;
lang = lang.replace(/\..*$/, '').toLowerCase();
if(typeof filter == 'function') {
lang = filter(lang);
}
return lang;
} | [
"function",
"sanitize",
"(",
"lang",
",",
"filter",
")",
"{",
"if",
"(",
"!",
"(",
"typeof",
"lang",
"==",
"'string'",
")",
")",
"return",
"lang",
";",
"lang",
"=",
"lang",
".",
"replace",
"(",
"/",
"\\..*$",
"/",
",",
"''",
")",
".",
"toLowerCase"... | Sanitize the value of an LC variable removing any character
encoding portion, such that en_GB.UTF-8 becomes en_gb.
@param lang A language identifier extracted from an LC variable.
@param filter A filter function.
@return A sanitized language identifier. | [
"Sanitize",
"the",
"value",
"of",
"an",
"LC",
"variable",
"removing",
"any",
"character",
"encoding",
"portion",
"such",
"that",
"en_GB",
".",
"UTF",
"-",
"8",
"becomes",
"en_gb",
"."
] | 5e1c759d551207de80b4bd9206101df077f61a14 | https://github.com/cli-kit/cli-locale/blob/5e1c759d551207de80b4bd9206101df077f61a14/index.js#L12-L19 | train |
cli-kit/cli-locale | index.js | find | function find(search, filter, strict) {
var lang, search = search || [], i, k, v, re = /^(LC_|LANG)/;
for(i = 0;i < search.length;i++) {
lang = sanitize(process.env[search[i]] || '', filter);
if(lang) return c(lang);
}
// nothing found in search array, find first available
for(k in process.env) {
... | javascript | function find(search, filter, strict) {
var lang, search = search || [], i, k, v, re = /^(LC_|LANG)/;
for(i = 0;i < search.length;i++) {
lang = sanitize(process.env[search[i]] || '', filter);
if(lang) return c(lang);
}
// nothing found in search array, find first available
for(k in process.env) {
... | [
"function",
"find",
"(",
"search",
",",
"filter",
",",
"strict",
")",
"{",
"var",
"lang",
",",
"search",
"=",
"search",
"||",
"[",
"]",
",",
"i",
",",
"k",
",",
"v",
",",
"re",
"=",
"/",
"^(LC_|LANG)",
"/",
";",
"for",
"(",
"i",
"=",
"0",
";"... | Find the value of an LC environment variable and return a
sanitized represention of the locale.
If no variable value is found in the search array then this
method returns the first available LC variable.
@param search An array of LC variables to prefer.
@param filter A filter function.
@param strict A boolean indicat... | [
"Find",
"the",
"value",
"of",
"an",
"LC",
"environment",
"variable",
"and",
"return",
"a",
"sanitized",
"represention",
"of",
"the",
"locale",
"."
] | 5e1c759d551207de80b4bd9206101df077f61a14 | https://github.com/cli-kit/cli-locale/blob/5e1c759d551207de80b4bd9206101df077f61a14/index.js#L45-L61 | train |
aMarCruz/flatten-brunch-map | index.js | flattenBrunchMap | function flattenBrunchMap (sourceFile, compiled, sourceMap) {
let asString = false
let prevMap = sourceFile.map
let newMap = sourceMap
// make sure the current map is an object
if (prevMap && (typeof prevMap == 'string' || prevMap instanceof String)) {
prevMap = JSON.parse(prevMap)
}
const result = ... | javascript | function flattenBrunchMap (sourceFile, compiled, sourceMap) {
let asString = false
let prevMap = sourceFile.map
let newMap = sourceMap
// make sure the current map is an object
if (prevMap && (typeof prevMap == 'string' || prevMap instanceof String)) {
prevMap = JSON.parse(prevMap)
}
const result = ... | [
"function",
"flattenBrunchMap",
"(",
"sourceFile",
",",
"compiled",
",",
"sourceMap",
")",
"{",
"let",
"asString",
"=",
"false",
"let",
"prevMap",
"=",
"sourceFile",
".",
"map",
"let",
"newMap",
"=",
"sourceMap",
"// make sure the current map is an object",
"if",
... | Return a re-mapped source map string
@param {object} [sourceFile] - The param received by the plugin
@param {string} compiled - Processed or compiled code
@param {object|string} sourceMap - Generated source map
@returns {object} The resulting file object with flatten source map, if any. | [
"Return",
"a",
"re",
"-",
"mapped",
"source",
"map",
"string"
] | 4b37048700403bf74b7bc1e76f26e82e6b973356 | https://github.com/aMarCruz/flatten-brunch-map/blob/4b37048700403bf74b7bc1e76f26e82e6b973356/index.js#L46-L97 | train |
iwillwen/watchman.js | dist/watchman.js | pathToRegExp | function pathToRegExp(path) {
if (path instanceof RegExp) {
return {
keys: [],
regexp: path
};
}
if (path instanceof Array) {
path = '(' + path.join('|') + ')';
}
var rtn = {
keys: [],
regexp: null
};
rtn.regexp = new RegExp((isHashRouter(path)... | javascript | function pathToRegExp(path) {
if (path instanceof RegExp) {
return {
keys: [],
regexp: path
};
}
if (path instanceof Array) {
path = '(' + path.join('|') + ')';
}
var rtn = {
keys: [],
regexp: null
};
rtn.regexp = new RegExp((isHashRouter(path)... | [
"function",
"pathToRegExp",
"(",
"path",
")",
"{",
"if",
"(",
"path",
"instanceof",
"RegExp",
")",
"{",
"return",
"{",
"keys",
":",
"[",
"]",
",",
"regexp",
":",
"path",
"}",
";",
"}",
"if",
"(",
"path",
"instanceof",
"Array",
")",
"{",
"path",
"="... | Convert the path string to a RegExp object
@param {String} path path
@return {RegExp} RegExp object | [
"Convert",
"the",
"path",
"string",
"to",
"a",
"RegExp",
"object"
] | 54b380f53311aa03422cf7ce4e41a5fb7a2c067a | https://github.com/iwillwen/watchman.js/blob/54b380f53311aa03422cf7ce4e41a5fb7a2c067a/dist/watchman.js#L303-L334 | train |
iwillwen/watchman.js | dist/watchman.js | paramsParser | function paramsParser(url, rule) {
var matches = rule.regexp.exec(url).slice(1);
var keys = rule.keys;
var params = {};
for (var i = 0; i < keys.length; i++) {
params[keys[i]] = matches[i];
}
return params;
} | javascript | function paramsParser(url, rule) {
var matches = rule.regexp.exec(url).slice(1);
var keys = rule.keys;
var params = {};
for (var i = 0; i < keys.length; i++) {
params[keys[i]] = matches[i];
}
return params;
} | [
"function",
"paramsParser",
"(",
"url",
",",
"rule",
")",
"{",
"var",
"matches",
"=",
"rule",
".",
"regexp",
".",
"exec",
"(",
"url",
")",
".",
"slice",
"(",
"1",
")",
";",
"var",
"keys",
"=",
"rule",
".",
"keys",
";",
"var",
"params",
"=",
"{",
... | url params parser
@param {String} url current url
@param {Object} rule matched rule
@return {Object} params | [
"url",
"params",
"parser"
] | 54b380f53311aa03422cf7ce4e41a5fb7a2c067a | https://github.com/iwillwen/watchman.js/blob/54b380f53311aa03422cf7ce4e41a5fb7a2c067a/dist/watchman.js#L402-L412 | train |
hubiquitus/hubiquitus-gateway | index.js | sendHeartbeat | function sendHeartbeat() {
_.forOwn(_this.socks, function (sock) {
sock.write('hb');
});
setTimeout(sendHeartbeat, _this.heartbeatFreq);
} | javascript | function sendHeartbeat() {
_.forOwn(_this.socks, function (sock) {
sock.write('hb');
});
setTimeout(sendHeartbeat, _this.heartbeatFreq);
} | [
"function",
"sendHeartbeat",
"(",
")",
"{",
"_",
".",
"forOwn",
"(",
"_this",
".",
"socks",
",",
"function",
"(",
"sock",
")",
"{",
"sock",
".",
"write",
"(",
"'hb'",
")",
";",
"}",
")",
";",
"setTimeout",
"(",
"sendHeartbeat",
",",
"_this",
".",
"... | Send a heartbeat to all opened sockets | [
"Send",
"a",
"heartbeat",
"to",
"all",
"opened",
"sockets"
] | 4f2466ef818eb4cfa60be6640f4d84dbeadb2da7 | https://github.com/hubiquitus/hubiquitus-gateway/blob/4f2466ef818eb4cfa60be6640f4d84dbeadb2da7/index.js#L192-L197 | train |
hubiquitus/hubiquitus-gateway | index.js | checkClientsHeartbeat | function checkClientsHeartbeat() {
var now = Date.now();
_.forOwn(_this.socks, function (sock) {
if (sock.hb + _this.clientTimeout < now) {
logout(sock);
}
});
setTimeout(checkClientsHeartbeat, 1000)
} | javascript | function checkClientsHeartbeat() {
var now = Date.now();
_.forOwn(_this.socks, function (sock) {
if (sock.hb + _this.clientTimeout < now) {
logout(sock);
}
});
setTimeout(checkClientsHeartbeat, 1000)
} | [
"function",
"checkClientsHeartbeat",
"(",
")",
"{",
"var",
"now",
"=",
"Date",
".",
"now",
"(",
")",
";",
"_",
".",
"forOwn",
"(",
"_this",
".",
"socks",
",",
"function",
"(",
"sock",
")",
"{",
"if",
"(",
"sock",
".",
"hb",
"+",
"_this",
".",
"cl... | Check that all clients respond to the heartbeat in time | [
"Check",
"that",
"all",
"clients",
"respond",
"to",
"the",
"heartbeat",
"in",
"time"
] | 4f2466ef818eb4cfa60be6640f4d84dbeadb2da7 | https://github.com/hubiquitus/hubiquitus-gateway/blob/4f2466ef818eb4cfa60be6640f4d84dbeadb2da7/index.js#L203-L211 | train |
derdesign/protos | engines/ejs.js | EJS | function EJS() {
var opts = (app.config.engines && app.config.engines.ejs) || {};
this.options = protos.extend({
delimiter: '?'
}, opts);
this.module = ejs;
this.multiPart = true;
this.extensions = ['ejs', 'ejs.html'];
} | javascript | function EJS() {
var opts = (app.config.engines && app.config.engines.ejs) || {};
this.options = protos.extend({
delimiter: '?'
}, opts);
this.module = ejs;
this.multiPart = true;
this.extensions = ['ejs', 'ejs.html'];
} | [
"function",
"EJS",
"(",
")",
"{",
"var",
"opts",
"=",
"(",
"app",
".",
"config",
".",
"engines",
"&&",
"app",
".",
"config",
".",
"engines",
".",
"ejs",
")",
"||",
"{",
"}",
";",
"this",
".",
"options",
"=",
"protos",
".",
"extend",
"(",
"{",
"... | EJS engine class
https://github.com/mde/ejs | [
"EJS",
"engine",
"class"
] | 0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9 | https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/engines/ejs.js#L14-L26 | train |
vkiding/jud-vue-render | src/render/browser/extend/components/slider/carrousel.js | cloneEvents | function cloneEvents(origin, clone, deep) {
var listeners = origin._listeners
if (listeners) {
clone._listeners = listeners
for (var type in listeners) {
clone.addEventListener(type, listeners[type])
}
}
if (deep && origin.children && origin.children.length) {
... | javascript | function cloneEvents(origin, clone, deep) {
var listeners = origin._listeners
if (listeners) {
clone._listeners = listeners
for (var type in listeners) {
clone.addEventListener(type, listeners[type])
}
}
if (deep && origin.children && origin.children.length) {
... | [
"function",
"cloneEvents",
"(",
"origin",
",",
"clone",
",",
"deep",
")",
"{",
"var",
"listeners",
"=",
"origin",
".",
"_listeners",
"if",
"(",
"listeners",
")",
"{",
"clone",
".",
"_listeners",
"=",
"listeners",
"for",
"(",
"var",
"type",
"in",
"listene... | If there a _listeners attribute on the dom element then clone the _listeners as well for the events' binding | [
"If",
"there",
"a",
"_listeners",
"attribute",
"on",
"the",
"dom",
"element",
"then",
"clone",
"the",
"_listeners",
"as",
"well",
"for",
"the",
"events",
"binding"
] | 07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47 | https://github.com/vkiding/jud-vue-render/blob/07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47/src/render/browser/extend/components/slider/carrousel.js#L153-L166 | train |
Digznav/bilberry | promise-read-files.js | promiseReadFiles | function promiseReadFiles(pattern) {
return glob(pattern)
.then(foundFiles => {
const promisesToReadFiles = foundFiles.map(fileName => pReadFile(fileName));
return Promise.all(promisesToReadFiles);
})
.catch(log.error);
} | javascript | function promiseReadFiles(pattern) {
return glob(pattern)
.then(foundFiles => {
const promisesToReadFiles = foundFiles.map(fileName => pReadFile(fileName));
return Promise.all(promisesToReadFiles);
})
.catch(log.error);
} | [
"function",
"promiseReadFiles",
"(",
"pattern",
")",
"{",
"return",
"glob",
"(",
"pattern",
")",
".",
"then",
"(",
"foundFiles",
"=>",
"{",
"const",
"promisesToReadFiles",
"=",
"foundFiles",
".",
"map",
"(",
"fileName",
"=>",
"pReadFile",
"(",
"fileName",
")... | Get the content of files using the patterns the shell uses, like stars and stuff.
@param {string} pattern Regex pattern.
@return {promise} Glob promise to get the content. | [
"Get",
"the",
"content",
"of",
"files",
"using",
"the",
"patterns",
"the",
"shell",
"uses",
"like",
"stars",
"and",
"stuff",
"."
] | ef6db49de6c8b0d2f4f9d3e10e8a8153e39ffcc4 | https://github.com/Digznav/bilberry/blob/ef6db49de6c8b0d2f4f9d3e10e8a8153e39ffcc4/promise-read-files.js#L10-L18 | train |
jldec/pub-serve-sessions | serve-sessions.js | isAuthorized | function isAuthorized(acl, user) {
acl = u.str(acl).toUpperCase();
user = u.str(user).toUpperCase();
if (user && user === acl) return true;
if (!aclRe[acl]) {
aclRe[acl] = reAccess(sessionOpts.acl[acl] || process.env['ACL_' + acl]);
}
return aclRe[acl].test(user) || aclRe.ADMIN.test(user);... | javascript | function isAuthorized(acl, user) {
acl = u.str(acl).toUpperCase();
user = u.str(user).toUpperCase();
if (user && user === acl) return true;
if (!aclRe[acl]) {
aclRe[acl] = reAccess(sessionOpts.acl[acl] || process.env['ACL_' + acl]);
}
return aclRe[acl].test(user) || aclRe.ADMIN.test(user);... | [
"function",
"isAuthorized",
"(",
"acl",
",",
"user",
")",
"{",
"acl",
"=",
"u",
".",
"str",
"(",
"acl",
")",
".",
"toUpperCase",
"(",
")",
";",
"user",
"=",
"u",
".",
"str",
"(",
"user",
")",
".",
"toUpperCase",
"(",
")",
";",
"if",
"(",
"user"... | low-level authz api - returns true if user matches or belongs to acl | [
"low",
"-",
"level",
"authz",
"api",
"-",
"returns",
"true",
"if",
"user",
"matches",
"or",
"belongs",
"to",
"acl"
] | 5164480af2632cda59bfed236e92fa7c1a988418 | https://github.com/jldec/pub-serve-sessions/blob/5164480af2632cda59bfed236e92fa7c1a988418/serve-sessions.js#L153-L161 | train |
jldec/pub-serve-sessions | serve-sessions.js | reAccess | function reAccess(s) {
var list = s ? s.split(/[, ]+/) : []; // avoid ['']
return new RegExp(
u.map(list, function(s) {
return '^' + u.escapeRegExp(s) + '$'; // exact matches only
}).join('|') // join([]) returns ''
|| '$(?=.)' ... | javascript | function reAccess(s) {
var list = s ? s.split(/[, ]+/) : []; // avoid ['']
return new RegExp(
u.map(list, function(s) {
return '^' + u.escapeRegExp(s) + '$'; // exact matches only
}).join('|') // join([]) returns ''
|| '$(?=.)' ... | [
"function",
"reAccess",
"(",
"s",
")",
"{",
"var",
"list",
"=",
"s",
"?",
"s",
".",
"split",
"(",
"/",
"[, ]+",
"/",
")",
":",
"[",
"]",
";",
"// avoid ['']",
"return",
"new",
"RegExp",
"(",
"u",
".",
"map",
"(",
"list",
",",
"function",
"(",
"... | turns ACLs into regexps | [
"turns",
"ACLs",
"into",
"regexps"
] | 5164480af2632cda59bfed236e92fa7c1a988418 | https://github.com/jldec/pub-serve-sessions/blob/5164480af2632cda59bfed236e92fa7c1a988418/serve-sessions.js#L164-L172 | train |
jldec/pub-serve-sessions | serve-sessions.js | saveOldSessions | function saveOldSessions() {
var db = self.store;
var oldDestroy = db.destroy;
db.destroy = newDestroy;
return;
// rename instead of delete
function newDestroy(sid, cb) {
db.get(sid, function(err, session) {
if (err) return cb(err);
if (!session) return cb();
db.se... | javascript | function saveOldSessions() {
var db = self.store;
var oldDestroy = db.destroy;
db.destroy = newDestroy;
return;
// rename instead of delete
function newDestroy(sid, cb) {
db.get(sid, function(err, session) {
if (err) return cb(err);
if (!session) return cb();
db.se... | [
"function",
"saveOldSessions",
"(",
")",
"{",
"var",
"db",
"=",
"self",
".",
"store",
";",
"var",
"oldDestroy",
"=",
"db",
".",
"destroy",
";",
"db",
".",
"destroy",
"=",
"newDestroy",
";",
"return",
";",
"// rename instead of delete",
"function",
"newDestro... | replace session.store destroy handler with a replacement which saves a copy of the session using sid_d first | [
"replace",
"session",
".",
"store",
"destroy",
"handler",
"with",
"a",
"replacement",
"which",
"saves",
"a",
"copy",
"of",
"the",
"session",
"using",
"sid_d",
"first"
] | 5164480af2632cda59bfed236e92fa7c1a988418 | https://github.com/jldec/pub-serve-sessions/blob/5164480af2632cda59bfed236e92fa7c1a988418/serve-sessions.js#L176-L193 | train |
jldec/pub-serve-sessions | serve-sessions.js | newDestroy | function newDestroy(sid, cb) {
db.get(sid, function(err, session) {
if (err) return cb(err);
if (!session) return cb();
db.set(sid + '_d', session, function(err) {
if (err) return cb(err);
oldDestroy.call(db, sid, cb);
});
});
} | javascript | function newDestroy(sid, cb) {
db.get(sid, function(err, session) {
if (err) return cb(err);
if (!session) return cb();
db.set(sid + '_d', session, function(err) {
if (err) return cb(err);
oldDestroy.call(db, sid, cb);
});
});
} | [
"function",
"newDestroy",
"(",
"sid",
",",
"cb",
")",
"{",
"db",
".",
"get",
"(",
"sid",
",",
"function",
"(",
"err",
",",
"session",
")",
"{",
"if",
"(",
"err",
")",
"return",
"cb",
"(",
"err",
")",
";",
"if",
"(",
"!",
"session",
")",
"return... | rename instead of delete | [
"rename",
"instead",
"of",
"delete"
] | 5164480af2632cda59bfed236e92fa7c1a988418 | https://github.com/jldec/pub-serve-sessions/blob/5164480af2632cda59bfed236e92fa7c1a988418/serve-sessions.js#L183-L192 | train |
xiamidaxia/xiami | meteor/minimongo/sort.js | function (i) {
var self = this;
var invert = !self._sortSpecParts[i].ascending;
return function (key1, key2) {
var compare = LocalCollection._f._cmp(key1[i], key2[i]);
if (invert)
compare = -compare;
return compare;
};
} | javascript | function (i) {
var self = this;
var invert = !self._sortSpecParts[i].ascending;
return function (key1, key2) {
var compare = LocalCollection._f._cmp(key1[i], key2[i]);
if (invert)
compare = -compare;
return compare;
};
} | [
"function",
"(",
"i",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"invert",
"=",
"!",
"self",
".",
"_sortSpecParts",
"[",
"i",
"]",
".",
"ascending",
";",
"return",
"function",
"(",
"key1",
",",
"key2",
")",
"{",
"var",
"compare",
"=",
"Local... | Given an index 'i', returns a comparator that compares two key arrays based on field 'i'. | [
"Given",
"an",
"index",
"i",
"returns",
"a",
"comparator",
"that",
"compares",
"two",
"key",
"arrays",
"based",
"on",
"field",
"i",
"."
] | 6fcee92c493c12bf8fd67c7068e67fa6a72a306b | https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/minimongo/sort.js#L269-L278 | train | |
skerit/alchemy | lib/init/functions.js | doClose | function doClose(next, err) {
if (fd > 0 && file_path !== fd) {
fs.close(fd, function closed() {
// Ignore errors
next(err);
});
} else {
next(err);
}
} | javascript | function doClose(next, err) {
if (fd > 0 && file_path !== fd) {
fs.close(fd, function closed() {
// Ignore errors
next(err);
});
} else {
next(err);
}
} | [
"function",
"doClose",
"(",
"next",
",",
"err",
")",
"{",
"if",
"(",
"fd",
">",
"0",
"&&",
"file_path",
"!==",
"fd",
")",
"{",
"fs",
".",
"close",
"(",
"fd",
",",
"function",
"closed",
"(",
")",
"{",
"// Ignore errors",
"next",
"(",
"err",
")",
"... | Function to close the descriptor | [
"Function",
"to",
"close",
"the",
"descriptor"
] | ede1dad07a5a737d5d1e10c2ff87fdfb057443f8 | https://github.com/skerit/alchemy/blob/ede1dad07a5a737d5d1e10c2ff87fdfb057443f8/lib/init/functions.js#L765-L774 | train |
skerit/alchemy | lib/init/functions.js | mcFile | function mcFile(type, source, target, cb) {
var targetDir,
bin,
cmd;
if (type == 'cp' || type == 'copy') {
bin = '/bin/cp';
} else if (type == 'mv' || type == 'move') {
bin = '/bin/mv';
}
// We assume the last piece of the target is the file name
// Split the string by slashes
targetDir = target... | javascript | function mcFile(type, source, target, cb) {
var targetDir,
bin,
cmd;
if (type == 'cp' || type == 'copy') {
bin = '/bin/cp';
} else if (type == 'mv' || type == 'move') {
bin = '/bin/mv';
}
// We assume the last piece of the target is the file name
// Split the string by slashes
targetDir = target... | [
"function",
"mcFile",
"(",
"type",
",",
"source",
",",
"target",
",",
"cb",
")",
"{",
"var",
"targetDir",
",",
"bin",
",",
"cmd",
";",
"if",
"(",
"type",
"==",
"'cp'",
"||",
"type",
"==",
"'copy'",
")",
"{",
"bin",
"=",
"'/bin/cp'",
";",
"}",
"el... | Move or copy a file
@author Jelle De Loecker <jelle@develry.be>
@since 0.0.1
@version 1.0.5
@param {String} source Origin path
@param {String} target Target path
@param {Function} cb | [
"Move",
"or",
"copy",
"a",
"file"
] | ede1dad07a5a737d5d1e10c2ff87fdfb057443f8 | https://github.com/skerit/alchemy/blob/ede1dad07a5a737d5d1e10c2ff87fdfb057443f8/lib/init/functions.js#L982-L1048 | train |
jenkinsci/js-preferences | preferences/Preferences.js | Preferences | function Preferences(preferencesArray, namespace) {
if (!preferencesArray) {
throw new Error('Cannot create config. Must pass an array of properties!');
}
this.store = {};
// store the keys we know
this.keys = preferencesArray.map((item) => {
this.store[item.key] = preference.newPref... | javascript | function Preferences(preferencesArray, namespace) {
if (!preferencesArray) {
throw new Error('Cannot create config. Must pass an array of properties!');
}
this.store = {};
// store the keys we know
this.keys = preferencesArray.map((item) => {
this.store[item.key] = preference.newPref... | [
"function",
"Preferences",
"(",
"preferencesArray",
",",
"namespace",
")",
"{",
"if",
"(",
"!",
"preferencesArray",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Cannot create config. Must pass an array of properties!'",
")",
";",
"}",
"this",
".",
"store",
"=",
"{",
... | Creates a configuration object based on preferences.
This means we use localStorage to interact with the components.
@param preferencesArray {Array} the preferences that we want to sync with the local storage
@param {string} [namespace] - if no value we use default namespace
@constructor
@example
const preferencesArray... | [
"Creates",
"a",
"configuration",
"object",
"based",
"on",
"preferences",
".",
"This",
"means",
"we",
"use",
"localStorage",
"to",
"interact",
"with",
"the",
"components",
"."
] | 2d2e3e11752898461160e22ff65b4a0516890dcc | https://github.com/jenkinsci/js-preferences/blob/2d2e3e11752898461160e22ff65b4a0516890dcc/preferences/Preferences.js#L32-L42 | train |
alexpods/ClazzJS | src/components/meta/Property/Setters.js | function(object, setters, property) {
_.each(setters, function(setter, name) {
object.__addSetter(property, name, setter);
});
} | javascript | function(object, setters, property) {
_.each(setters, function(setter, name) {
object.__addSetter(property, name, setter);
});
} | [
"function",
"(",
"object",
",",
"setters",
",",
"property",
")",
"{",
"_",
".",
"each",
"(",
"setters",
",",
"function",
"(",
"setter",
",",
"name",
")",
"{",
"object",
".",
"__addSetter",
"(",
"property",
",",
"name",
",",
"setter",
")",
";",
"}",
... | Add property setters to object
@param {object} object Some object
@param {object} setters Hash of property setters
@param {string} property Property name
@this {metaProcessor} | [
"Add",
"property",
"setters",
"to",
"object"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Property/Setters.js#L16-L21 | train | |
tolokoban/ToloFrameWork | ker/com/x-code/x-code.com.js | removeLeftMargin | function removeLeftMargin( code ) {
var margin = 999;
var lines = code.split("\n");
lines.forEach(function (line) {
var s = line.length;
var m = 0;
while( m < s && line.charAt(m) == ' ' ) m++;
margin = Math.min( m, margin );
});
return lines.map(function(line) {
return line.substr( margin ... | javascript | function removeLeftMargin( code ) {
var margin = 999;
var lines = code.split("\n");
lines.forEach(function (line) {
var s = line.length;
var m = 0;
while( m < s && line.charAt(m) == ' ' ) m++;
margin = Math.min( m, margin );
});
return lines.map(function(line) {
return line.substr( margin ... | [
"function",
"removeLeftMargin",
"(",
"code",
")",
"{",
"var",
"margin",
"=",
"999",
";",
"var",
"lines",
"=",
"code",
".",
"split",
"(",
"\"\\n\"",
")",
";",
"lines",
".",
"forEach",
"(",
"function",
"(",
"line",
")",
"{",
"var",
"s",
"=",
"line",
... | Remove common indentation. | [
"Remove",
"common",
"indentation",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/com/x-code/x-code.com.js#L60-L72 | train |
tolokoban/ToloFrameWork | ker/com/x-code/x-code.com.js | restrictToSection | function restrictToSection( code, section ) {
var linesToKeep = [];
var outOfSection = true;
var lookFor = '#(' + section + ')';
code.split('\n').forEach(function( line ) {
if (outOfSection) {
if (line.indexOf( lookFor ) > -1) {
outOfSection = false;
}
} else {
if (line.indexO... | javascript | function restrictToSection( code, section ) {
var linesToKeep = [];
var outOfSection = true;
var lookFor = '#(' + section + ')';
code.split('\n').forEach(function( line ) {
if (outOfSection) {
if (line.indexOf( lookFor ) > -1) {
outOfSection = false;
}
} else {
if (line.indexO... | [
"function",
"restrictToSection",
"(",
"code",
",",
"section",
")",
"{",
"var",
"linesToKeep",
"=",
"[",
"]",
";",
"var",
"outOfSection",
"=",
"true",
";",
"var",
"lookFor",
"=",
"'#('",
"+",
"section",
"+",
"')'",
";",
"code",
".",
"split",
"(",
"'\\n'... | it can be useful to restrict the display to just a section of the entire file.
Such sections must start with the following line where we find it's name.
Look at the definition of the section `init` in the following example.
@example
var canvas = $.elem( this, 'div' );
// #(init)
var gl = canvas.getContext("webgl") || ... | [
"it",
"can",
"be",
"useful",
"to",
"restrict",
"the",
"display",
"to",
"just",
"a",
"section",
"of",
"the",
"entire",
"file",
".",
"Such",
"sections",
"must",
"start",
"with",
"the",
"following",
"line",
"where",
"we",
"find",
"it",
"s",
"name",
".",
"... | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/com/x-code/x-code.com.js#L90-L110 | train |
dominicbarnes/duo-serve | lib/server.js | Server | function Server(root) {
if (!(this instanceof Server)) return new Server(root);
this.settings = defaults({}, Server.defaults);
if (root) this.root(root);
this.plugins = [];
this.entries = {};
var auth = netrc('api.github.com');
if ('GH_TOKEN' in process.env) this.token(process.env.GH_TOKEN);
else if (... | javascript | function Server(root) {
if (!(this instanceof Server)) return new Server(root);
this.settings = defaults({}, Server.defaults);
if (root) this.root(root);
this.plugins = [];
this.entries = {};
var auth = netrc('api.github.com');
if ('GH_TOKEN' in process.env) this.token(process.env.GH_TOKEN);
else if (... | [
"function",
"Server",
"(",
"root",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Server",
")",
")",
"return",
"new",
"Server",
"(",
"root",
")",
";",
"this",
".",
"settings",
"=",
"defaults",
"(",
"{",
"}",
",",
"Server",
".",
"defaults",
"... | Represents a duo-serve instance
@constructor
@param {String} root The project root | [
"Represents",
"a",
"duo",
"-",
"serve",
"instance"
] | c6b2e7073ccd729617567995c28880b94b47f947 | https://github.com/dominicbarnes/duo-serve/blob/c6b2e7073ccd729617567995c28880b94b47f947/lib/server.js#L27-L38 | train |
ryanramage/schema-couch-boilerplate | jam/couchr/couchr-browser.js | onComplete | function onComplete(options, callback) {
return function (req) {
var resp;
if (ctype = req.getResponseHeader('Content-Type')) {
ctype = ctype.split(';')[0];
}
if (ctype === 'application/json' || ctype === 'text/json') {
try {
... | javascript | function onComplete(options, callback) {
return function (req) {
var resp;
if (ctype = req.getResponseHeader('Content-Type')) {
ctype = ctype.split(';')[0];
}
if (ctype === 'application/json' || ctype === 'text/json') {
try {
... | [
"function",
"onComplete",
"(",
"options",
",",
"callback",
")",
"{",
"return",
"function",
"(",
"req",
")",
"{",
"var",
"resp",
";",
"if",
"(",
"ctype",
"=",
"req",
".",
"getResponseHeader",
"(",
"'Content-Type'",
")",
")",
"{",
"ctype",
"=",
"ctype",
... | Returns a function for handling ajax responses from jquery and calls
the callback with the data or appropriate error.
@param {Function} callback(err,response)
@api private | [
"Returns",
"a",
"function",
"for",
"handling",
"ajax",
"responses",
"from",
"jquery",
"and",
"calls",
"the",
"callback",
"with",
"the",
"data",
"or",
"appropriate",
"error",
"."
] | c323516f02c90101aa6b21592bfdd2a6f2e47680 | https://github.com/ryanramage/schema-couch-boilerplate/blob/c323516f02c90101aa6b21592bfdd2a6f2e47680/jam/couchr/couchr-browser.js#L28-L69 | train |
caiguanhao/assemble-permalink | permalink.js | function(permalink) {
permalink = permalink || '';
if (permalink.slice(0, 1) !== PATH_SEP) {
permalink = PATH_SEP + permalink;
}
permalink = permalink.replace(INDEX_RE, PATH_SEP);
return permalink;
} | javascript | function(permalink) {
permalink = permalink || '';
if (permalink.slice(0, 1) !== PATH_SEP) {
permalink = PATH_SEP + permalink;
}
permalink = permalink.replace(INDEX_RE, PATH_SEP);
return permalink;
} | [
"function",
"(",
"permalink",
")",
"{",
"permalink",
"=",
"permalink",
"||",
"''",
";",
"if",
"(",
"permalink",
".",
"slice",
"(",
"0",
",",
"1",
")",
"!==",
"PATH_SEP",
")",
"{",
"permalink",
"=",
"PATH_SEP",
"+",
"permalink",
";",
"}",
"permalink",
... | standardize permalink output | [
"standardize",
"permalink",
"output"
] | ffba65d742c10e456b95bbf63e24e575e905a967 | https://github.com/caiguanhao/assemble-permalink/blob/ffba65d742c10e456b95bbf63e24e575e905a967/permalink.js#L42-L49 | train | |
alejonext/humanquery | lib/parse.js | parse | function parse(str) {
str = '(' + str.trim() + ')';
/**
* expr
*/
return expr();
/**
* Assert `expr`.
*/
function error(expr, msg) {
if (expr) return;
var ctx = str.slice(0, 10);
assert(0, msg + ' near `' + ctx + '`');
}
/**
* '(' binop ')'
*/
function expr() {
error('(' == str[0], "mi... | javascript | function parse(str) {
str = '(' + str.trim() + ')';
/**
* expr
*/
return expr();
/**
* Assert `expr`.
*/
function error(expr, msg) {
if (expr) return;
var ctx = str.slice(0, 10);
assert(0, msg + ' near `' + ctx + '`');
}
/**
* '(' binop ')'
*/
function expr() {
error('(' == str[0], "mi... | [
"function",
"parse",
"(",
"str",
")",
"{",
"str",
"=",
"'('",
"+",
"str",
".",
"trim",
"(",
")",
"+",
"')'",
";",
"/**\n\t * expr\n\t */",
"return",
"expr",
"(",
")",
";",
"/**\n\t * Assert `expr`.\n\t */",
"function",
"error",
"(",
"expr",
",",
"msg",
"... | Parse `str` to produce an AST.
@param {String} str
@return {Object}
@api public | [
"Parse",
"str",
"to",
"produce",
"an",
"AST",
"."
] | f3dbc46379122f40bf9336991e9856a82fc95310 | https://github.com/alejonext/humanquery/blob/f3dbc46379122f40bf9336991e9856a82fc95310/lib/parse.js#L23-L114 | train |
alejonext/humanquery | lib/parse.js | error | function error(expr, msg) {
if (expr) return;
var ctx = str.slice(0, 10);
assert(0, msg + ' near `' + ctx + '`');
} | javascript | function error(expr, msg) {
if (expr) return;
var ctx = str.slice(0, 10);
assert(0, msg + ' near `' + ctx + '`');
} | [
"function",
"error",
"(",
"expr",
",",
"msg",
")",
"{",
"if",
"(",
"expr",
")",
"return",
";",
"var",
"ctx",
"=",
"str",
".",
"slice",
"(",
"0",
",",
"10",
")",
";",
"assert",
"(",
"0",
",",
"msg",
"+",
"' near `'",
"+",
"ctx",
"+",
"'`'",
")... | Assert `expr`. | [
"Assert",
"expr",
"."
] | f3dbc46379122f40bf9336991e9856a82fc95310 | https://github.com/alejonext/humanquery/blob/f3dbc46379122f40bf9336991e9856a82fc95310/lib/parse.js#L36-L40 | train |
mathieudutour/nplint | lib/ignore-deps.js | loadIgnoreFile | function loadIgnoreFile(filepath) {
var ignoredDeps = [];
/**
* Check if string is not empty
* @param {string} line string to examine
* @returns {boolean} True is its not empty
* @private
*/
function nonEmpty(line) {
return line.trim() !== '' && line[0] !== '#';
}
if (filepath) ... | javascript | function loadIgnoreFile(filepath) {
var ignoredDeps = [];
/**
* Check if string is not empty
* @param {string} line string to examine
* @returns {boolean} True is its not empty
* @private
*/
function nonEmpty(line) {
return line.trim() !== '' && line[0] !== '#';
}
if (filepath) ... | [
"function",
"loadIgnoreFile",
"(",
"filepath",
")",
"{",
"var",
"ignoredDeps",
"=",
"[",
"]",
";",
"/**\n * Check if string is not empty\n * @param {string} line string to examine\n * @returns {boolean} True is its not empty\n * @private\n */",
"function",
"nonEmpty",... | Load and parse ignore dependencies from the file at the given path
@param {string} filepath Path to the ignore file.
@returns {string[]} An array of ignore dependencies or an empty array if no ignore file. | [
"Load",
"and",
"parse",
"ignore",
"dependencies",
"from",
"the",
"file",
"at",
"the",
"given",
"path"
] | ef444abcc6dd08fb61d5fc8ce618598d4455e08e | https://github.com/mathieudutour/nplint/blob/ef444abcc6dd08fb61d5fc8ce618598d4455e08e/lib/ignore-deps.js#L13-L38 | train |
kumori-systems/component | taskfile.js | getJSON | function getJSON(filepath) {
const jsonString = "g = " + fs.readFileSync(filepath, 'utf8') + "; g";
return (new vm.Script(jsonString)).runInNewContext();
} | javascript | function getJSON(filepath) {
const jsonString = "g = " + fs.readFileSync(filepath, 'utf8') + "; g";
return (new vm.Script(jsonString)).runInNewContext();
} | [
"function",
"getJSON",
"(",
"filepath",
")",
"{",
"const",
"jsonString",
"=",
"\"g = \"",
"+",
"fs",
".",
"readFileSync",
"(",
"filepath",
",",
"'utf8'",
")",
"+",
"\"; g\"",
";",
"return",
"(",
"new",
"vm",
".",
"Script",
"(",
"jsonString",
")",
")",
... | Gobble up a JSON file with comments | [
"Gobble",
"up",
"a",
"JSON",
"file",
"with",
"comments"
] | 6ff796e5fd8800daf35b10c352a14e09db651fe2 | https://github.com/kumori-systems/component/blob/6ff796e5fd8800daf35b10c352a14e09db651fe2/taskfile.js#L8-L11 | train |
jm-root/core | packages/jm-event/lib/index.js | emitAsync | async function emitAsync (eventName, ...args) {
// using a copy to avoid error when listener array changed
let listeners = this.listeners(eventName)
for (let i = 0; i < listeners.length; i++) {
let fn = listeners[i]
let obj = fn(...args)
if (!!obj && (typeof obj === 'object' || typeof obj === 'functio... | javascript | async function emitAsync (eventName, ...args) {
// using a copy to avoid error when listener array changed
let listeners = this.listeners(eventName)
for (let i = 0; i < listeners.length; i++) {
let fn = listeners[i]
let obj = fn(...args)
if (!!obj && (typeof obj === 'object' || typeof obj === 'functio... | [
"async",
"function",
"emitAsync",
"(",
"eventName",
",",
"...",
"args",
")",
"{",
"// using a copy to avoid error when listener array changed",
"let",
"listeners",
"=",
"this",
".",
"listeners",
"(",
"eventName",
")",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
... | event module.
@module event | [
"event",
"module",
"."
] | d05c7356a2991edf861e5c1aac2d0bc971cfdff3 | https://github.com/jm-root/core/blob/d05c7356a2991edf861e5c1aac2d0bc971cfdff3/packages/jm-event/lib/index.js#L6-L15 | train |
redisjs/jsr-store | lib/store.js | getDatabase | function getDatabase(index, opts) {
var db;
if(!this._databases[index]) {
db = new Database(this, opts);
this._databases[index] = db;
}
return this._databases[index];
} | javascript | function getDatabase(index, opts) {
var db;
if(!this._databases[index]) {
db = new Database(this, opts);
this._databases[index] = db;
}
return this._databases[index];
} | [
"function",
"getDatabase",
"(",
"index",
",",
"opts",
")",
"{",
"var",
"db",
";",
"if",
"(",
"!",
"this",
".",
"_databases",
"[",
"index",
"]",
")",
"{",
"db",
"=",
"new",
"Database",
"(",
"this",
",",
"opts",
")",
";",
"this",
".",
"_databases",
... | Get a database and inject it into the list at the
specified index if no db exists at that index.
@param index The database index.
@param opts Database options. | [
"Get",
"a",
"database",
"and",
"inject",
"it",
"into",
"the",
"list",
"at",
"the",
"specified",
"index",
"if",
"no",
"db",
"exists",
"at",
"that",
"index",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/store.js#L46-L53 | train |
energimolnet/energimolnet-ng | src/date-util.js | getPeriod | function getPeriod(dates, granularity, forced) {
var isArray = angular.isArray(dates);
var isRange = (isArray && dates.length > 1);
if ((isArray && dates.length === 0) || dates === null || dates === undefined) {
return null;
}
if (granularity === 'month') {
return (isRange || forced) ? getMonthPerio... | javascript | function getPeriod(dates, granularity, forced) {
var isArray = angular.isArray(dates);
var isRange = (isArray && dates.length > 1);
if ((isArray && dates.length === 0) || dates === null || dates === undefined) {
return null;
}
if (granularity === 'month') {
return (isRange || forced) ? getMonthPerio... | [
"function",
"getPeriod",
"(",
"dates",
",",
"granularity",
",",
"forced",
")",
"{",
"var",
"isArray",
"=",
"angular",
".",
"isArray",
"(",
"dates",
")",
";",
"var",
"isRange",
"=",
"(",
"isArray",
"&&",
"dates",
".",
"length",
">",
"1",
")",
";",
"if... | Returns a period for the provided date range, or single date. Will auto-calculate period style depending on granularity, unless force is set to true. E.g. when getting day granularity for a single date, the function will assume you want day values for the date's month. | [
"Returns",
"a",
"period",
"for",
"the",
"provided",
"date",
"range",
"or",
"single",
"date",
".",
"Will",
"auto",
"-",
"calculate",
"period",
"style",
"depending",
"on",
"granularity",
"unless",
"force",
"is",
"set",
"to",
"true",
".",
"E",
".",
"g",
"."... | 7249c7a52aa6878d462a429c3aacb33d43bf9484 | https://github.com/energimolnet/energimolnet-ng/blob/7249c7a52aa6878d462a429c3aacb33d43bf9484/src/date-util.js#L72-L100 | train |
energimolnet/energimolnet-ng | src/date-util.js | daysInMonth | function daysInMonth(date) {
var d = new Date(date.getTime());
d.setMonth(d.getMonth() + 1);
d.setDate(0);
return d.getDate();
} | javascript | function daysInMonth(date) {
var d = new Date(date.getTime());
d.setMonth(d.getMonth() + 1);
d.setDate(0);
return d.getDate();
} | [
"function",
"daysInMonth",
"(",
"date",
")",
"{",
"var",
"d",
"=",
"new",
"Date",
"(",
"date",
".",
"getTime",
"(",
")",
")",
";",
"d",
".",
"setMonth",
"(",
"d",
".",
"getMonth",
"(",
")",
"+",
"1",
")",
";",
"d",
".",
"setDate",
"(",
"0",
"... | Helper function for returning the number of days in a month | [
"Helper",
"function",
"for",
"returning",
"the",
"number",
"of",
"days",
"in",
"a",
"month"
] | 7249c7a52aa6878d462a429c3aacb33d43bf9484 | https://github.com/energimolnet/energimolnet-ng/blob/7249c7a52aa6878d462a429c3aacb33d43bf9484/src/date-util.js#L123-L129 | train |
the-terribles/evergreen | lib/directive-context.js | DirectiveContext | function DirectiveContext(strategy, expression, arrayPath){
this.resolved = false;
this.strategy = strategy;
this.expression = expression;
this.path = arrayPath;
this.sympath = treeUtils.joinPaths(arrayPath);
} | javascript | function DirectiveContext(strategy, expression, arrayPath){
this.resolved = false;
this.strategy = strategy;
this.expression = expression;
this.path = arrayPath;
this.sympath = treeUtils.joinPaths(arrayPath);
} | [
"function",
"DirectiveContext",
"(",
"strategy",
",",
"expression",
",",
"arrayPath",
")",
"{",
"this",
".",
"resolved",
"=",
"false",
";",
"this",
".",
"strategy",
"=",
"strategy",
";",
"this",
".",
"expression",
"=",
"expression",
";",
"this",
".",
"path... | Represent the context needed to resolve a directive. This should be returned by the directive to the callback.
If the directive has resolved the value, there is a convenience method "resolve" you can call to set the value
and transition the completion state to "resolved".
@param strategy {String} name of the directive... | [
"Represent",
"the",
"context",
"needed",
"to",
"resolve",
"a",
"directive",
".",
"This",
"should",
"be",
"returned",
"by",
"the",
"directive",
"to",
"the",
"callback",
".",
"If",
"the",
"directive",
"has",
"resolved",
"the",
"value",
"there",
"is",
"a",
"c... | c1adaea1ce825727c5c5ed75d858e2f0d22657e2 | https://github.com/the-terribles/evergreen/blob/c1adaea1ce825727c5c5ed75d858e2f0d22657e2/lib/directive-context.js#L14-L20 | train |
on-point/thin-orm | table.js | Table | function Table(tableName, registry) {
this.id = 'id';
this.tableName = tableName;
this.joins = {};
this.defaultJoins = [];
this.columns = null;
this.selectColumns = null;
this.defaultSelectCriteria = null;
this.columnMap = null;
this.isInitialized = false;
this.defaultJoinsNeedPo... | javascript | function Table(tableName, registry) {
this.id = 'id';
this.tableName = tableName;
this.joins = {};
this.defaultJoins = [];
this.columns = null;
this.selectColumns = null;
this.defaultSelectCriteria = null;
this.columnMap = null;
this.isInitialized = false;
this.defaultJoinsNeedPo... | [
"function",
"Table",
"(",
"tableName",
",",
"registry",
")",
"{",
"this",
".",
"id",
"=",
"'id'",
";",
"this",
".",
"tableName",
"=",
"tableName",
";",
"this",
".",
"joins",
"=",
"{",
"}",
";",
"this",
".",
"defaultJoins",
"=",
"[",
"]",
";",
"this... | a table model | [
"a",
"table",
"model"
] | 761783a133ef6983f46060af68febc07e1f880e8 | https://github.com/on-point/thin-orm/blob/761783a133ef6983f46060af68febc07e1f880e8/table.js#L5-L17 | train |
on-point/thin-orm | table.js | camelCaseToUnderscoreMap | function camelCaseToUnderscoreMap(columns) {
var map = {};
for (var i = 0; i < columns.length; i++)
map[columns[i]] = toUnderscore(columns[i]);
return map;
} | javascript | function camelCaseToUnderscoreMap(columns) {
var map = {};
for (var i = 0; i < columns.length; i++)
map[columns[i]] = toUnderscore(columns[i]);
return map;
} | [
"function",
"camelCaseToUnderscoreMap",
"(",
"columns",
")",
"{",
"var",
"map",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"columns",
".",
"length",
";",
"i",
"++",
")",
"map",
"[",
"columns",
"[",
"i",
"]",
"]",
"=",
... | build a map that converts each camel case column name to an underscore name | [
"build",
"a",
"map",
"that",
"converts",
"each",
"camel",
"case",
"column",
"name",
"to",
"an",
"underscore",
"name"
] | 761783a133ef6983f46060af68febc07e1f880e8 | https://github.com/on-point/thin-orm/blob/761783a133ef6983f46060af68febc07e1f880e8/table.js#L108-L113 | train |
DerZyklop/eslint-plugin-no-unsafe-chars | lib/rules/custom.js | checkForDisallowedCharactersInString | function checkForDisallowedCharactersInString(node, identifier) {
if (typeof identifier !== "undefined" && isNotAllowed(identifier)) {
context.report(node, "Unexpected umlaut in \"" + identifier + "\".");
}
} | javascript | function checkForDisallowedCharactersInString(node, identifier) {
if (typeof identifier !== "undefined" && isNotAllowed(identifier)) {
context.report(node, "Unexpected umlaut in \"" + identifier + "\".");
}
} | [
"function",
"checkForDisallowedCharactersInString",
"(",
"node",
",",
"identifier",
")",
"{",
"if",
"(",
"typeof",
"identifier",
"!==",
"\"undefined\"",
"&&",
"isNotAllowed",
"(",
"identifier",
")",
")",
"{",
"context",
".",
"report",
"(",
"node",
",",
"\"Unexpe... | Check if function has a underscore at the end
@param {ASTNode} node node to evaluate
@returns {void}
@private | [
"Check",
"if",
"function",
"has",
"a",
"underscore",
"at",
"the",
"end"
] | f2b23367f02f88ecef65d71be56e15eaaa1400d8 | https://github.com/DerZyklop/eslint-plugin-no-unsafe-chars/blob/f2b23367f02f88ecef65d71be56e15eaaa1400d8/lib/rules/custom.js#L40-L44 | train |
csbun/grunt-cmd | tasks/cmd.js | processOptions | function processOptions(opt) {
keys(opt).forEach(function (key) {
var value = opt[key];
if (typeof value === 'string') {
opt[key] = grunt.template.process(value);
} else if (Array.isArray(value)) {
opt[key] = value.slice().map(function (i) {
... | javascript | function processOptions(opt) {
keys(opt).forEach(function (key) {
var value = opt[key];
if (typeof value === 'string') {
opt[key] = grunt.template.process(value);
} else if (Array.isArray(value)) {
opt[key] = value.slice().map(function (i) {
... | [
"function",
"processOptions",
"(",
"opt",
")",
"{",
"keys",
"(",
"opt",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"var",
"value",
"=",
"opt",
"[",
"key",
"]",
";",
"if",
"(",
"typeof",
"value",
"===",
"'string'",
")",
"{",
"opt",
... | preprocess template in options default template delimiters are | [
"preprocess",
"template",
"in",
"options",
"default",
"template",
"delimiters",
"are"
] | a806eb8b890e4e6d218341fc4bd45fdd080375ca | https://github.com/csbun/grunt-cmd/blob/a806eb8b890e4e6d218341fc4bd45fdd080375ca/tasks/cmd.js#L21-L32 | train |
derdesign/protos | storages/redis.js | RedisStorage | function RedisStorage(config) {
var self = this;
config = protos.extend({
host: 'localhost',
port: 6379,
db: undefined,
password: undefined
}, config || {});
app.debug(util.format('Initializing Redis Storage for %s:%s', config.host, config.port));
this.db = 0;
th... | javascript | function RedisStorage(config) {
var self = this;
config = protos.extend({
host: 'localhost',
port: 6379,
db: undefined,
password: undefined
}, config || {});
app.debug(util.format('Initializing Redis Storage for %s:%s', config.host, config.port));
this.db = 0;
th... | [
"function",
"RedisStorage",
"(",
"config",
")",
"{",
"var",
"self",
"=",
"this",
";",
"config",
"=",
"protos",
".",
"extend",
"(",
"{",
"host",
":",
"'localhost'",
",",
"port",
":",
"6379",
",",
"db",
":",
"undefined",
",",
"password",
":",
"undefined"... | Redis Storage class
@class RedisStorage
@extends Storage
@constructor
@param {object} app Application instance
@param {object} config Storage configuration | [
"Redis",
"Storage",
"class"
] | 0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9 | https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/storages/redis.js#L20-L66 | train |
JohnnieFucker/dreamix-rpc | lib/rpc-client/client.js | rpcToSpecifiedServer | function rpcToSpecifiedServer(client, msg, serverType, routeParam, cb) {
if (typeof routeParam !== 'string') {
logger.error('[dreamix-rpc] server id is not a string, server id: %j', routeParam);
return;
}
if (routeParam === '*') {
const servers = client._station.servers;
asyn... | javascript | function rpcToSpecifiedServer(client, msg, serverType, routeParam, cb) {
if (typeof routeParam !== 'string') {
logger.error('[dreamix-rpc] server id is not a string, server id: %j', routeParam);
return;
}
if (routeParam === '*') {
const servers = client._station.servers;
asyn... | [
"function",
"rpcToSpecifiedServer",
"(",
"client",
",",
"msg",
",",
"serverType",
",",
"routeParam",
",",
"cb",
")",
"{",
"if",
"(",
"typeof",
"routeParam",
"!==",
"'string'",
")",
"{",
"logger",
".",
"error",
"(",
"'[dreamix-rpc] server id is not a string, server... | client has closed
Rpc to specified server id or servers.
@param client {Object} current client instance.
@param msg {Object} rpc message.
@param serverType {String} remote server type.
@param routeParam {Object} mailbox init context parameter.
@param cb {Function} callback.
@api private | [
"client",
"has",
"closed",
"Rpc",
"to",
"specified",
"server",
"id",
"or",
"servers",
"."
] | eb29e247214148c025456b2bb0542e1094fd2edb | https://github.com/JohnnieFucker/dreamix-rpc/blob/eb29e247214148c025456b2bb0542e1094fd2edb/lib/rpc-client/client.js#L29-L46 | train |
meaku/lawyer | lib/index.js | checkModuleLicense | function checkModuleLicense(folder) {
var licensePath = folder + "/LICENSE",
readMePath = folder + "/README.md",
licenseContent;
//check for LICENSE File First
if(fs.existsSync(licensePath)){
licenseContent = fs.readFileSync(licensePath, "utf-8");
return { isMIT : isLicense... | javascript | function checkModuleLicense(folder) {
var licensePath = folder + "/LICENSE",
readMePath = folder + "/README.md",
licenseContent;
//check for LICENSE File First
if(fs.existsSync(licensePath)){
licenseContent = fs.readFileSync(licensePath, "utf-8");
return { isMIT : isLicense... | [
"function",
"checkModuleLicense",
"(",
"folder",
")",
"{",
"var",
"licensePath",
"=",
"folder",
"+",
"\"/LICENSE\"",
",",
"readMePath",
"=",
"folder",
"+",
"\"/README.md\"",
",",
"licenseContent",
";",
"//check for LICENSE File First",
"if",
"(",
"fs",
".",
"exist... | checks the License of a single module-folder
@param folder
@return {Object} | [
"checks",
"the",
"License",
"of",
"a",
"single",
"module",
"-",
"folder"
] | 6056e7937a1b3cd415b53e1be9b9c4ff8cc115e7 | https://github.com/meaku/lawyer/blob/6056e7937a1b3cd415b53e1be9b9c4ff8cc115e7/lib/index.js#L14-L33 | train |
meaku/lawyer | lib/index.js | checkLicenses | function checkLicenses(rootDir){
var licenses = {},
nodeModulesFolder = path.resolve(rootDir, "./node_modules"),
moduleFolders = fs.readdirSync(nodeModulesFolder),
res;
_(moduleFolders).each(function(module) {
licenses[module] = checkModuleLicense(nodeModulesFolder + "/" + modu... | javascript | function checkLicenses(rootDir){
var licenses = {},
nodeModulesFolder = path.resolve(rootDir, "./node_modules"),
moduleFolders = fs.readdirSync(nodeModulesFolder),
res;
_(moduleFolders).each(function(module) {
licenses[module] = checkModuleLicense(nodeModulesFolder + "/" + modu... | [
"function",
"checkLicenses",
"(",
"rootDir",
")",
"{",
"var",
"licenses",
"=",
"{",
"}",
",",
"nodeModulesFolder",
"=",
"path",
".",
"resolve",
"(",
"rootDir",
",",
"\"./node_modules\"",
")",
",",
"moduleFolders",
"=",
"fs",
".",
"readdirSync",
"(",
"nodeMod... | check all licenses of your node_modules
@param {String} rootDir your modules' root dir | [
"check",
"all",
"licenses",
"of",
"your",
"node_modules"
] | 6056e7937a1b3cd415b53e1be9b9c4ff8cc115e7 | https://github.com/meaku/lawyer/blob/6056e7937a1b3cd415b53e1be9b9c4ff8cc115e7/lib/index.js#L39-L51 | train |
meaku/lawyer | lib/index.js | writeLicensesFile | function writeLicensesFile(rootDir) {
var licenses = checkLicenses(rootDir),
licensesFileContent = "LICENSES " + "\n \n";
_(licenses).each(function(licenseData, licenseName) {
licensesFileContent += licenseName + " : ";
if(licenseData.isMIT) {
licensesFileContent += "MIT"... | javascript | function writeLicensesFile(rootDir) {
var licenses = checkLicenses(rootDir),
licensesFileContent = "LICENSES " + "\n \n";
_(licenses).each(function(licenseData, licenseName) {
licensesFileContent += licenseName + " : ";
if(licenseData.isMIT) {
licensesFileContent += "MIT"... | [
"function",
"writeLicensesFile",
"(",
"rootDir",
")",
"{",
"var",
"licenses",
"=",
"checkLicenses",
"(",
"rootDir",
")",
",",
"licensesFileContent",
"=",
"\"LICENSES \"",
"+",
"\"\\n \\n\"",
";",
"_",
"(",
"licenses",
")",
".",
"each",
"(",
"function",
"(",
... | writes all License-information in a single file
called LICENSES
@param rootDir the rootDir of your module | [
"writes",
"all",
"License",
"-",
"information",
"in",
"a",
"single",
"file",
"called",
"LICENSES"
] | 6056e7937a1b3cd415b53e1be9b9c4ff8cc115e7 | https://github.com/meaku/lawyer/blob/6056e7937a1b3cd415b53e1be9b9c4ff8cc115e7/lib/index.js#L59-L84 | train |
tolokoban/ToloFrameWork | spec-jasmine/util.spec.js | check | function check( input, expected ) {
const output = Util.replaceDotsWithSlashes( input );
expect( output ).toBe( expected.split( '/' ).join( Path.sep ) );
} | javascript | function check( input, expected ) {
const output = Util.replaceDotsWithSlashes( input );
expect( output ).toBe( expected.split( '/' ).join( Path.sep ) );
} | [
"function",
"check",
"(",
"input",
",",
"expected",
")",
"{",
"const",
"output",
"=",
"Util",
".",
"replaceDotsWithSlashes",
"(",
"input",
")",
";",
"expect",
"(",
"output",
")",
".",
"toBe",
"(",
"expected",
".",
"split",
"(",
"'/'",
")",
".",
"join",... | Check if the input produces what was expected.
@param {string} input - File name with full path.
@param {string} expected - What was expected.
@returns {undefined} | [
"Check",
"if",
"the",
"input",
"produces",
"what",
"was",
"expected",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/spec-jasmine/util.spec.js#L17-L20 | train |
mikesamuel/template-tag-common | index.js | memoizedTagFunction | function memoizedTagFunction (computeStaticHelper, computeResultHelper) {
const memoTable = new LruCache()
/**
* @param {!Array.<string>} staticStrings
* @return {T}
*/
function staticStateFor (staticStrings) {
let staticState = null
const canMemoize = Object.isFrozen(staticStrings) &&
... | javascript | function memoizedTagFunction (computeStaticHelper, computeResultHelper) {
const memoTable = new LruCache()
/**
* @param {!Array.<string>} staticStrings
* @return {T}
*/
function staticStateFor (staticStrings) {
let staticState = null
const canMemoize = Object.isFrozen(staticStrings) &&
... | [
"function",
"memoizedTagFunction",
"(",
"computeStaticHelper",
",",
"computeResultHelper",
")",
"{",
"const",
"memoTable",
"=",
"new",
"LruCache",
"(",
")",
"/**\n * @param {!Array.<string>} staticStrings\n * @return {T}\n */",
"function",
"staticStateFor",
"(",
"staticSt... | Memoizes operations on the static portions so the per-use cost
of a tagged template literal is related to the complexity of handling
the dynamic values.
@template O
@template R
@template T
@param {!function (!Array.<string>): T} computeStaticHelper
called when there is no entry for the
frozen static strings object, an... | [
"Memoizes",
"operations",
"on",
"the",
"static",
"portions",
"so",
"the",
"per",
"-",
"use",
"cost",
"of",
"a",
"tagged",
"template",
"literal",
"is",
"related",
"to",
"the",
"complexity",
"of",
"handling",
"the",
"dynamic",
"values",
"."
] | 4e397aafc2a570379709172ea110ecdbe1135e91 | https://github.com/mikesamuel/template-tag-common/blob/4e397aafc2a570379709172ea110ecdbe1135e91/index.js#L127-L179 | train |
mikesamuel/template-tag-common | index.js | commonPrefixOf | function commonPrefixOf (a, b) { // eslint-disable-line id-length
const minLen = Math.min(a.length, b.length)
let i = 0
for (; i < minLen; ++i) {
if (a[i] !== b[i]) {
break
}
}
return a.substring(0, i)
} | javascript | function commonPrefixOf (a, b) { // eslint-disable-line id-length
const minLen = Math.min(a.length, b.length)
let i = 0
for (; i < minLen; ++i) {
if (a[i] !== b[i]) {
break
}
}
return a.substring(0, i)
} | [
"function",
"commonPrefixOf",
"(",
"a",
",",
"b",
")",
"{",
"// eslint-disable-line id-length",
"const",
"minLen",
"=",
"Math",
".",
"min",
"(",
"a",
".",
"length",
",",
"b",
".",
"length",
")",
"let",
"i",
"=",
"0",
"for",
"(",
";",
"i",
"<",
"minLe... | The longest prefix of a that is also a prefix of b | [
"The",
"longest",
"prefix",
"of",
"a",
"that",
"is",
"also",
"a",
"prefix",
"of",
"b"
] | 4e397aafc2a570379709172ea110ecdbe1135e91 | https://github.com/mikesamuel/template-tag-common/blob/4e397aafc2a570379709172ea110ecdbe1135e91/index.js#L182-L191 | train |
mikesamuel/template-tag-common | index.js | trimCommonWhitespaceFromLines | function trimCommonWhitespaceFromLines (
templateStrings,
{
trimEolAtStart = false,
trimEolAtEnd = false
} = {}) {
// Find a common prefix to remove
const commonPrefix = commonPrefixOfTemplateStrings(templateStrings)
let prefixPattern = null
if (commonPrefix) {
// commonPrefix contains no Reg... | javascript | function trimCommonWhitespaceFromLines (
templateStrings,
{
trimEolAtStart = false,
trimEolAtEnd = false
} = {}) {
// Find a common prefix to remove
const commonPrefix = commonPrefixOfTemplateStrings(templateStrings)
let prefixPattern = null
if (commonPrefix) {
// commonPrefix contains no Reg... | [
"function",
"trimCommonWhitespaceFromLines",
"(",
"templateStrings",
",",
"{",
"trimEolAtStart",
"=",
"false",
",",
"trimEolAtEnd",
"=",
"false",
"}",
"=",
"{",
"}",
")",
"{",
"// Find a common prefix to remove",
"const",
"commonPrefix",
"=",
"commonPrefixOfTemplateStri... | Simplifies tripping common leading whitespace from a multiline
template tag so that a template tag can be re-indented as a block.
This may be called from a computeStaticHandler so that it need not
happen every time a particular template is reached.
"Whitespace" and "line terminators" mean the same as they do in ES6:
... | [
"Simplifies",
"tripping",
"common",
"leading",
"whitespace",
"from",
"a",
"multiline",
"template",
"tag",
"so",
"that",
"a",
"template",
"tag",
"can",
"be",
"re",
"-",
"indented",
"as",
"a",
"block",
"."
] | 4e397aafc2a570379709172ea110ecdbe1135e91 | https://github.com/mikesamuel/template-tag-common/blob/4e397aafc2a570379709172ea110ecdbe1135e91/index.js#L236-L278 | train |
redisjs/jsr-store | lib/type/set.js | Set | function Set(source) {
HashMap.call(this);
this._rtype = TYPE_NAMES.SET;
if(source) {
this.sadd(source);
}
} | javascript | function Set(source) {
HashMap.call(this);
this._rtype = TYPE_NAMES.SET;
if(source) {
this.sadd(source);
}
} | [
"function",
"Set",
"(",
"source",
")",
"{",
"HashMap",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"_rtype",
"=",
"TYPE_NAMES",
".",
"SET",
";",
"if",
"(",
"source",
")",
"{",
"this",
".",
"sadd",
"(",
"source",
")",
";",
"}",
"}"
] | Represents the set type. | [
"Represents",
"the",
"set",
"type",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/type/set.js#L10-L16 | train |
redisjs/jsr-store | lib/type/set.js | sadd | function sadd(members) {
var i
, c = 0;
for(i = 0;i < members.length;i++) {
if(!this._data[members[i]]) {
this.setKey(members[i], 1);
c++;
}
}
return c;
} | javascript | function sadd(members) {
var i
, c = 0;
for(i = 0;i < members.length;i++) {
if(!this._data[members[i]]) {
this.setKey(members[i], 1);
c++;
}
}
return c;
} | [
"function",
"sadd",
"(",
"members",
")",
"{",
"var",
"i",
",",
"c",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"members",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_data",
"[",
"members",
"[",
"i",... | Add the specified members to the set. | [
"Add",
"the",
"specified",
"members",
"to",
"the",
"set",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/type/set.js#L23-L33 | train |
redisjs/jsr-store | lib/type/set.js | spop | function spop() {
var ind = Math.floor(Math.random() * this._keys.length)
, val = this._keys[ind];
this.delKey(val);
return val;
} | javascript | function spop() {
var ind = Math.floor(Math.random() * this._keys.length)
, val = this._keys[ind];
this.delKey(val);
return val;
} | [
"function",
"spop",
"(",
")",
"{",
"var",
"ind",
"=",
"Math",
".",
"floor",
"(",
"Math",
".",
"random",
"(",
")",
"*",
"this",
".",
"_keys",
".",
"length",
")",
",",
"val",
"=",
"this",
".",
"_keys",
"[",
"ind",
"]",
";",
"this",
".",
"delKey",... | Removes and returns a random element from the set. | [
"Removes",
"and",
"returns",
"a",
"random",
"element",
"from",
"the",
"set",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/type/set.js#L80-L85 | train |
redisjs/jsr-store | lib/type/set.js | srem | function srem(members) {
var i
, c = 0;
for(i = 0;i < members.length;i++) {
if(this.keyExists(members[i])) {
this.delKey(members[i]);
c++;
}
}
return c;
} | javascript | function srem(members) {
var i
, c = 0;
for(i = 0;i < members.length;i++) {
if(this.keyExists(members[i])) {
this.delKey(members[i]);
c++;
}
}
return c;
} | [
"function",
"srem",
"(",
"members",
")",
"{",
"var",
"i",
",",
"c",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"members",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"this",
".",
"keyExists",
"(",
"members",
"[",
"i",
... | Remove the specified members from the set. | [
"Remove",
"the",
"specified",
"members",
"from",
"the",
"set",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/type/set.js#L90-L100 | train |
PanthR/panthrMath | panthrMath/basicFunc/choose.js | lchoose | function lchoose(n, k) {
k = Math.round(k);
if (utils.hasNaN(n, k)) { return NaN; }
if (k < 0) { return -Infinity; }
if (k === 0) { return 0; }
if (k === 1) { return Math.log(Math.abs(n)); }
if (n < 0) { return lchoose(-n + k - 1, k); }
if (n === Math.round(n)) {
if (n... | javascript | function lchoose(n, k) {
k = Math.round(k);
if (utils.hasNaN(n, k)) { return NaN; }
if (k < 0) { return -Infinity; }
if (k === 0) { return 0; }
if (k === 1) { return Math.log(Math.abs(n)); }
if (n < 0) { return lchoose(-n + k - 1, k); }
if (n === Math.round(n)) {
if (n... | [
"function",
"lchoose",
"(",
"n",
",",
"k",
")",
"{",
"k",
"=",
"Math",
".",
"round",
"(",
"k",
")",
";",
"if",
"(",
"utils",
".",
"hasNaN",
"(",
"n",
",",
"k",
")",
")",
"{",
"return",
"NaN",
";",
"}",
"if",
"(",
"k",
"<",
"0",
")",
"{",
... | Computes the logarithm of the absolute value of the binomial coefficient.
Valid for any real n and for integer k.
k will be rounded if it is not an integer. | [
"Computes",
"the",
"logarithm",
"of",
"the",
"absolute",
"value",
"of",
"the",
"binomial",
"coefficient",
".",
"Valid",
"for",
"any",
"real",
"n",
"and",
"for",
"integer",
"k",
".",
"k",
"will",
"be",
"rounded",
"if",
"it",
"is",
"not",
"an",
"integer",
... | 54d249ca9903a9535f963da711bd3a87fb229c0b | https://github.com/PanthR/panthrMath/blob/54d249ca9903a9535f963da711bd3a87fb229c0b/panthrMath/basicFunc/choose.js#L18-L34 | train |
PanthR/panthrMath | panthrMath/basicFunc/choose.js | choose | function choose(n, k) {
var ret, j;
k = Math.round(k);
if (utils.hasNaN(n, k)) { return NaN; }
if (k < kSmallMax) {
if (n - k < k && n >= 0 && n === Math.round(n)) { k = n - k; }
if (k < 0) { return 0; }
if (k === 0) { return 1; }
ret = n;
for (j = 2... | javascript | function choose(n, k) {
var ret, j;
k = Math.round(k);
if (utils.hasNaN(n, k)) { return NaN; }
if (k < kSmallMax) {
if (n - k < k && n >= 0 && n === Math.round(n)) { k = n - k; }
if (k < 0) { return 0; }
if (k === 0) { return 1; }
ret = n;
for (j = 2... | [
"function",
"choose",
"(",
"n",
",",
"k",
")",
"{",
"var",
"ret",
",",
"j",
";",
"k",
"=",
"Math",
".",
"round",
"(",
"k",
")",
";",
"if",
"(",
"utils",
".",
"hasNaN",
"(",
"n",
",",
"k",
")",
")",
"{",
"return",
"NaN",
";",
"}",
"if",
"(... | Computes the binomial coefficient "n choose k".
Valid for any real n and for integer k.
k will be rounded if it is not an integer. | [
"Computes",
"the",
"binomial",
"coefficient",
"n",
"choose",
"k",
".",
"Valid",
"for",
"any",
"real",
"n",
"and",
"for",
"integer",
"k",
".",
"k",
"will",
"be",
"rounded",
"if",
"it",
"is",
"not",
"an",
"integer",
"."
] | 54d249ca9903a9535f963da711bd3a87fb229c0b | https://github.com/PanthR/panthrMath/blob/54d249ca9903a9535f963da711bd3a87fb229c0b/panthrMath/basicFunc/choose.js#L41-L73 | train |
syntheticore/declaire | src/collection.js | function(item) {
var self = this;
var items = Array.isArray(item) ? item : [item];
var added = false;
_.each(items, function(item) {
if(!_.contains(self.items, item)) {
self.items.push(item);
if(item && item.klass == 'Instance') {
item.once('delete', funct... | javascript | function(item) {
var self = this;
var items = Array.isArray(item) ? item : [item];
var added = false;
_.each(items, function(item) {
if(!_.contains(self.items, item)) {
self.items.push(item);
if(item && item.klass == 'Instance') {
item.once('delete', funct... | [
"function",
"(",
"item",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"items",
"=",
"Array",
".",
"isArray",
"(",
"item",
")",
"?",
"item",
":",
"[",
"item",
"]",
";",
"var",
"added",
"=",
"false",
";",
"_",
".",
"each",
"(",
"items",
",",... | Add one or many items | [
"Add",
"one",
"or",
"many",
"items"
] | cb5ea205eeb3aa26fd0c6348e86d840c04e9ba9f | https://github.com/syntheticore/declaire/blob/cb5ea205eeb3aa26fd0c6348e86d840c04e9ba9f/src/collection.js#L11-L32 | train | |
MakerCollider/node-red-contrib-smartnode-hook | html/scripts/RGraph/RGraph.bar.js | myOnresizebeforedraw | function myOnresizebeforedraw (obj)
{
var gutterLeft = obj.Get('chart.gutter.left');
var gutterRight = obj.Get('chart.gutter.right');
obj.Set('chart.hmargin', (obj.canvas.width - gutterLeft - gutterRight) / (obj.original_data[0].length * 2));
... | javascript | function myOnresizebeforedraw (obj)
{
var gutterLeft = obj.Get('chart.gutter.left');
var gutterRight = obj.Get('chart.gutter.right');
obj.Set('chart.hmargin', (obj.canvas.width - gutterLeft - gutterRight) / (obj.original_data[0].length * 2));
... | [
"function",
"myOnresizebeforedraw",
"(",
"obj",
")",
"{",
"var",
"gutterLeft",
"=",
"obj",
".",
"Get",
"(",
"'chart.gutter.left'",
")",
";",
"var",
"gutterRight",
"=",
"obj",
".",
"Get",
"(",
"'chart.gutter.right'",
")",
";",
"obj",
".",
"Set",
"(",
"'char... | This recalculates the Line chart hmargin when the chart is resized | [
"This",
"recalculates",
"the",
"Line",
"chart",
"hmargin",
"when",
"the",
"chart",
"is",
"resized"
] | 245c267e832968bad880ca009929043e82c7bc25 | https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/RGraph/RGraph.bar.js#L3059-L3065 | train |
gethuman/pancakes-recipe | utils/hash.js | compare | function compare(data, encrypted) {
var deferred = Q.defer();
bcrypt.compare(data, encrypted, function (err, res) {
err ? deferred.reject(err) : deferred.resolve(res);
});
return deferred.promise;
} | javascript | function compare(data, encrypted) {
var deferred = Q.defer();
bcrypt.compare(data, encrypted, function (err, res) {
err ? deferred.reject(err) : deferred.resolve(res);
});
return deferred.promise;
} | [
"function",
"compare",
"(",
"data",
",",
"encrypted",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"bcrypt",
".",
"compare",
"(",
"data",
",",
"encrypted",
",",
"function",
"(",
"err",
",",
"res",
")",
"{",
"err",
"?",
"defer... | Compare some data to an encrypted version
@param data
@param encrypted | [
"Compare",
"some",
"data",
"to",
"an",
"encrypted",
"version"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/utils/hash.js#L15-L23 | train |
gethuman/pancakes-recipe | utils/hash.js | generateHash | function generateHash(data) {
var deferred = Q.defer();
bcrypt.hash(data, 10, function (err, res) {
err ? deferred.reject(err) : deferred.resolve(res);
});
return deferred.promise;
} | javascript | function generateHash(data) {
var deferred = Q.defer();
bcrypt.hash(data, 10, function (err, res) {
err ? deferred.reject(err) : deferred.resolve(res);
});
return deferred.promise;
} | [
"function",
"generateHash",
"(",
"data",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"bcrypt",
".",
"hash",
"(",
"data",
",",
"10",
",",
"function",
"(",
"err",
",",
"res",
")",
"{",
"err",
"?",
"deferred",
".",
"reject",
... | Generate hash off some data
@param data | [
"Generate",
"hash",
"off",
"some",
"data"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/utils/hash.js#L29-L37 | train |
base/base-pipeline | index.js | isDisabled | function isDisabled(app, key, prop) {
// key + '.plugin'
if (app.isFalse([key, prop])) {
return true;
}
// key + '.plugin.disable'
if (app.isTrue([key, prop, 'disable'])) {
return true;
}
return false;
} | javascript | function isDisabled(app, key, prop) {
// key + '.plugin'
if (app.isFalse([key, prop])) {
return true;
}
// key + '.plugin.disable'
if (app.isTrue([key, prop, 'disable'])) {
return true;
}
return false;
} | [
"function",
"isDisabled",
"(",
"app",
",",
"key",
",",
"prop",
")",
"{",
"// key + '.plugin'",
"if",
"(",
"app",
".",
"isFalse",
"(",
"[",
"key",
",",
"prop",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"// key + '.plugin.disable'",
"if",
"(",
"app... | Returns true if the plugin is disabled. | [
"Returns",
"true",
"if",
"the",
"plugin",
"is",
"disabled",
"."
] | 7f5aa3365caa1401567cd5eaf222d92356e1bac0 | https://github.com/base/base-pipeline/blob/7f5aa3365caa1401567cd5eaf222d92356e1bac0/index.js#L126-L136 | train |
express-bem/bh | lib/engines/bh.js | bh | function bh(name, options, cb) {
var filePath;
var bhModule;
var html;
var lang;
if (typeof options.lang === 'string') {
lang = options.lang;
}
// reject rendering for empty options.bemjson
if (!options.bemjson) {
cb(Error('No bem... | javascript | function bh(name, options, cb) {
var filePath;
var bhModule;
var html;
var lang;
if (typeof options.lang === 'string') {
lang = options.lang;
}
// reject rendering for empty options.bemjson
if (!options.bemjson) {
cb(Error('No bem... | [
"function",
"bh",
"(",
"name",
",",
"options",
",",
"cb",
")",
"{",
"var",
"filePath",
";",
"var",
"bhModule",
";",
"var",
"html",
";",
"var",
"lang",
";",
"if",
"(",
"typeof",
"options",
".",
"lang",
"===",
"'string'",
")",
"{",
"lang",
"=",
"opti... | bh.js express view engine adapter
Produces html from bh-templates and data and invokes passed callback with result
@param {String} name Bundle name
@param {Object} options Data to use in templates
@param {String} options.lang Lang ID to render a localized template
@param {Object} options.bemjson
@param {Boolean} opti... | [
"bh",
".",
"js",
"express",
"view",
"engine",
"adapter",
"Produces",
"html",
"from",
"bh",
"-",
"templates",
"and",
"data",
"and",
"invokes",
"passed",
"callback",
"with",
"result"
] | 28da346ad991f09b224445b93f9abfaf6fa3d7b0 | https://github.com/express-bem/bh/blob/28da346ad991f09b224445b93f9abfaf6fa3d7b0/lib/engines/bh.js#L25-L76 | train |
onehilltech/blueprint-testing | lib/request.js | request | function request (app) {
app = app || blueprint.app.server.express;
return supertest (app);
} | javascript | function request (app) {
app = app || blueprint.app.server.express;
return supertest (app);
} | [
"function",
"request",
"(",
"app",
")",
"{",
"app",
"=",
"app",
"||",
"blueprint",
".",
"app",
".",
"server",
".",
"express",
";",
"return",
"supertest",
"(",
"app",
")",
";",
"}"
] | Make a test request. If no Express.js application is provided, then
the request is sent to the current Blueprint.js application.
@param app Optional application
@returns {Test} | [
"Make",
"a",
"test",
"request",
".",
"If",
"no",
"Express",
".",
"js",
"application",
"is",
"provided",
"then",
"the",
"request",
"is",
"sent",
"to",
"the",
"current",
"Blueprint",
".",
"js",
"application",
"."
] | f14e38c5671dd7b009049962a0a27b9e5a0bf4a6 | https://github.com/onehilltech/blueprint-testing/blob/f14e38c5671dd7b009049962a0a27b9e5a0bf4a6/lib/request.js#L28-L31 | train |
patchless/patchavatar-names | index.js | function (id) {
var span = document.createElement('span')
span.title = id
api.sbot.names.getSignifier(id, function (err, name) {
span.textContent = name
})
if(!span.textContent)
span.textContent = id
return span
} | javascript | function (id) {
var span = document.createElement('span')
span.title = id
api.sbot.names.getSignifier(id, function (err, name) {
span.textContent = name
})
if(!span.textContent)
span.textContent = id
return span
} | [
"function",
"(",
"id",
")",
"{",
"var",
"span",
"=",
"document",
".",
"createElement",
"(",
"'span'",
")",
"span",
".",
"title",
"=",
"id",
"api",
".",
"sbot",
".",
"names",
".",
"getSignifier",
"(",
"id",
",",
"function",
"(",
"err",
",",
"name",
... | fall through... | [
"fall",
"through",
"..."
] | b7ad555bfaaefceb41e3912b6bdf69aef8a99015 | https://github.com/patchless/patchavatar-names/blob/b7ad555bfaaefceb41e3912b6bdf69aef8a99015/index.js#L32-L41 | train | |
asavoy/grunt-requirejs-auto-bundles | lib/bundle.js | generateBundleName | function generateBundleName(mains) {
// Join mains into a string.
var joinedMains = mains.sort().join('-');
// Create hash.
var hash = crypto.createHash('md5').update(joinedMains).digest('hex');
// Replace any special chars.
joinedMains = joinedMains.replace(/\/|\\|\./g, '_');
// Truncate... | javascript | function generateBundleName(mains) {
// Join mains into a string.
var joinedMains = mains.sort().join('-');
// Create hash.
var hash = crypto.createHash('md5').update(joinedMains).digest('hex');
// Replace any special chars.
joinedMains = joinedMains.replace(/\/|\\|\./g, '_');
// Truncate... | [
"function",
"generateBundleName",
"(",
"mains",
")",
"{",
"// Join mains into a string.",
"var",
"joinedMains",
"=",
"mains",
".",
"sort",
"(",
")",
".",
"join",
"(",
"'-'",
")",
";",
"// Create hash.",
"var",
"hash",
"=",
"crypto",
".",
"createHash",
"(",
"... | Calculate a unique bundle name, given a list of main modules that depend on
its contents. | [
"Calculate",
"a",
"unique",
"bundle",
"name",
"given",
"a",
"list",
"of",
"main",
"modules",
"that",
"depend",
"on",
"its",
"contents",
"."
] | c0f587c9720943dd32098203d2c71ab1387f1700 | https://github.com/asavoy/grunt-requirejs-auto-bundles/blob/c0f587c9720943dd32098203d2c71ab1387f1700/lib/bundle.js#L9-L22 | train |
andrewscwei/requiem | src/helpers/getDirectCustomChildren.js | getDirectCustomChildren | function getDirectCustomChildren(element, inclusive) {
if (!inclusive && element.nodeState !== undefined) return [];
let childRegistry = getChildRegistry(element);
let children = [];
for (let name in childRegistry) {
let child = [].concat(childRegistry[name]);
child.forEach((c) => {
if (isCusto... | javascript | function getDirectCustomChildren(element, inclusive) {
if (!inclusive && element.nodeState !== undefined) return [];
let childRegistry = getChildRegistry(element);
let children = [];
for (let name in childRegistry) {
let child = [].concat(childRegistry[name]);
child.forEach((c) => {
if (isCusto... | [
"function",
"getDirectCustomChildren",
"(",
"element",
",",
"inclusive",
")",
"{",
"if",
"(",
"!",
"inclusive",
"&&",
"element",
".",
"nodeState",
"!==",
"undefined",
")",
"return",
"[",
"]",
";",
"let",
"childRegistry",
"=",
"getChildRegistry",
"(",
"element"... | Gets all the direct custom children of an element, flattened to a single
array.
@param {Node} element - The DOM element to get the direct custom children
from.
@param {boolean} [inclusive] - Specifies whether the element provided should
be included as part of the search even if
it is already a custom element.
@return... | [
"Gets",
"all",
"the",
"direct",
"custom",
"children",
"of",
"an",
"element",
"flattened",
"to",
"a",
"single",
"array",
"."
] | c4182bfffc9841c6de5718f689ad3c2060511777 | https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/helpers/getDirectCustomChildren.js#L22-L40 | train |
andrewscwei/requiem | src/dom/setStyle.js | setStyle | function setStyle(element, key, value) {
assertType(element, Node, false, 'Invalid element specified');
if (typeof value === 'number') value = String(value);
if (value === null || value === undefined) value = '';
element.style[key] = value;
} | javascript | function setStyle(element, key, value) {
assertType(element, Node, false, 'Invalid element specified');
if (typeof value === 'number') value = String(value);
if (value === null || value === undefined) value = '';
element.style[key] = value;
} | [
"function",
"setStyle",
"(",
"element",
",",
"key",
",",
"value",
")",
"{",
"assertType",
"(",
"element",
",",
"Node",
",",
"false",
",",
"'Invalid element specified'",
")",
";",
"if",
"(",
"typeof",
"value",
"===",
"'number'",
")",
"value",
"=",
"String",... | Sets an inline CSS rule of a Node.
@param {Node} element - Target element.
@param {string} key - Name of the CSS rule in camelCase.
@param {*} value - Value of the style. If a number is provided, it will be
automatically suffixed with 'px'.
@see {@link http://www.w3schools.com/jsref/dom_obj_style.asp}
@alias module:... | [
"Sets",
"an",
"inline",
"CSS",
"rule",
"of",
"a",
"Node",
"."
] | c4182bfffc9841c6de5718f689ad3c2060511777 | https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/dom/setStyle.js#L19-L25 | train |
willdavis/discrete-time | lib/time_traveler.js | TimeTraveler | function TimeTraveler(settings) {
// coerce the +starts_at+ value into a moment
var starts_at_moment = moment(settings.starts_at);
// initialize new TimeTraveler object attributes
this.starts_at = starts_at_moment;
this.steps = settings.steps;
this.time_units = settings.time_units;
this.time_scale = set... | javascript | function TimeTraveler(settings) {
// coerce the +starts_at+ value into a moment
var starts_at_moment = moment(settings.starts_at);
// initialize new TimeTraveler object attributes
this.starts_at = starts_at_moment;
this.steps = settings.steps;
this.time_units = settings.time_units;
this.time_scale = set... | [
"function",
"TimeTraveler",
"(",
"settings",
")",
"{",
"// coerce the +starts_at+ value into a moment",
"var",
"starts_at_moment",
"=",
"moment",
"(",
"settings",
".",
"starts_at",
")",
";",
"// initialize new TimeTraveler object attributes",
"this",
".",
"starts_at",
"=",
... | Encapsulates helper functions and attributes to create and step
through time series data.
@example
var settings = { starts_at: "2016-10-31", steps: 100, time_units: "days", time_scale: 10 };
var TimeTraveler = require('discrete-time').traveler;
var traveler = new TimeTraveler(settings);
// send the TimeTraveler on th... | [
"Encapsulates",
"helper",
"functions",
"and",
"attributes",
"to",
"create",
"and",
"step",
"through",
"time",
"series",
"data",
"."
] | d429adb698b00c2ddd6a945c6368d2267480b839 | https://github.com/willdavis/discrete-time/blob/d429adb698b00c2ddd6a945c6368d2267480b839/lib/time_traveler.js#L29-L40 | train |
Fovea/jackbone | jackbone.js | function (t, timerName) {
if (this.enabled) {
var id = _.uniqueId('jt');
this._startDate[id] = t || (+new Date());
if (console.profile && timerName) {
this._timerConsoleName[id] = timerName;
console.profile(timerName);
... | javascript | function (t, timerName) {
if (this.enabled) {
var id = _.uniqueId('jt');
this._startDate[id] = t || (+new Date());
if (console.profile && timerName) {
this._timerConsoleName[id] = timerName;
console.profile(timerName);
... | [
"function",
"(",
"t",
",",
"timerName",
")",
"{",
"if",
"(",
"this",
".",
"enabled",
")",
"{",
"var",
"id",
"=",
"_",
".",
"uniqueId",
"(",
"'jt'",
")",
";",
"this",
".",
"_startDate",
"[",
"id",
"]",
"=",
"t",
"||",
"(",
"+",
"new",
"Date",
... | Called at the beggining of an operation | [
"Called",
"at",
"the",
"beggining",
"of",
"an",
"operation"
] | 94631030d20c6ff5c331cb824e135120f60c4ff2 | https://github.com/Fovea/jackbone/blob/94631030d20c6ff5c331cb824e135120f60c4ff2/jackbone.js#L70-L80 | 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.