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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
epeios-q37/xdhelcq | js/Sortable/Sortable.js | function () {
var order = [],
el,
children = this.el.children,
i = 0,
n = children.length,
options = this.options;
for (; i < n; i++) {
el = children[i];
if (_closest(el, options.draggable, this.el)) {
order.push(el.getAttribute(options.dataIdAttr) || _generateId(el));
}
}... | javascript | function () {
var order = [],
el,
children = this.el.children,
i = 0,
n = children.length,
options = this.options;
for (; i < n; i++) {
el = children[i];
if (_closest(el, options.draggable, this.el)) {
order.push(el.getAttribute(options.dataIdAttr) || _generateId(el));
}
}... | [
"function",
"(",
")",
"{",
"var",
"order",
"=",
"[",
"]",
",",
"el",
",",
"children",
"=",
"this",
".",
"el",
".",
"children",
",",
"i",
"=",
"0",
",",
"n",
"=",
"children",
".",
"length",
",",
"options",
"=",
"this",
".",
"options",
";",
"for"... | Serializes the item into an array of string.
@returns {String[]} | [
"Serializes",
"the",
"item",
"into",
"an",
"array",
"of",
"string",
"."
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/Sortable/Sortable.js#L757-L773 | train | |
epeios-q37/xdhelcq | js/Sortable/Sortable.js | function (order) {
var items = {}, rootEl = this.el;
this.toArray().forEach(function (id, i) {
var el = rootEl.children[i];
if (_closest(el, this.options.draggable, rootEl)) {
items[id] = el;
}
}, this);
order.forEach(function (id) {
if (items[id]) {
rootEl.removeChild(items[id]... | javascript | function (order) {
var items = {}, rootEl = this.el;
this.toArray().forEach(function (id, i) {
var el = rootEl.children[i];
if (_closest(el, this.options.draggable, rootEl)) {
items[id] = el;
}
}, this);
order.forEach(function (id) {
if (items[id]) {
rootEl.removeChild(items[id]... | [
"function",
"(",
"order",
")",
"{",
"var",
"items",
"=",
"{",
"}",
",",
"rootEl",
"=",
"this",
".",
"el",
";",
"this",
".",
"toArray",
"(",
")",
".",
"forEach",
"(",
"function",
"(",
"id",
",",
"i",
")",
"{",
"var",
"el",
"=",
"rootEl",
".",
... | Sorts the elements according to the array.
@param {String[]} order order of the items | [
"Sorts",
"the",
"elements",
"according",
"to",
"the",
"array",
"."
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/Sortable/Sortable.js#L780-L797 | train | |
epeios-q37/xdhelcq | js/Sortable/Sortable.js | _index | function _index(/**HTMLElement*/el) {
var index = 0;
while (el && (el = el.previousElementSibling)) {
if (el.nodeName.toUpperCase() !== 'TEMPLATE') {
index++;
}
}
return index;
} | javascript | function _index(/**HTMLElement*/el) {
var index = 0;
while (el && (el = el.previousElementSibling)) {
if (el.nodeName.toUpperCase() !== 'TEMPLATE') {
index++;
}
}
return index;
} | [
"function",
"_index",
"(",
"/**HTMLElement*/",
"el",
")",
"{",
"var",
"index",
"=",
"0",
";",
"while",
"(",
"el",
"&&",
"(",
"el",
"=",
"el",
".",
"previousElementSibling",
")",
")",
"{",
"if",
"(",
"el",
".",
"nodeName",
".",
"toUpperCase",
"(",
")"... | Returns the index of an element within its parent
@param el
@returns {number}
@private | [
"Returns",
"the",
"index",
"of",
"an",
"element",
"within",
"its",
"parent"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/Sortable/Sortable.js#L1069-L1077 | train |
aureooms/js-grammar | lib/util/setaddall.js | setaddall | function setaddall(set, iterable) {
var changed = false;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = iterable[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompl... | javascript | function setaddall(set, iterable) {
var changed = false;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = iterable[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompl... | [
"function",
"setaddall",
"(",
"set",
",",
"iterable",
")",
"{",
"var",
"changed",
"=",
"false",
";",
"var",
"_iteratorNormalCompletion",
"=",
"true",
";",
"var",
"_didIteratorError",
"=",
"false",
";",
"var",
"_iteratorError",
"=",
"undefined",
";",
"try",
"... | Adds all elements of an iterable to a set and returns true if the set has
changed.
@param {Set} set - The set to add to.
@param {Iterable} iterable - The iterable of elements to add to the set.
@returns {Boolean} Whether <code>set</code> has changed. | [
"Adds",
"all",
"elements",
"of",
"an",
"iterable",
"to",
"a",
"set",
"and",
"returns",
"true",
"if",
"the",
"set",
"has",
"changed",
"."
] | 28c4d1a3175327b33766c34539eab317303e26c5 | https://github.com/aureooms/js-grammar/blob/28c4d1a3175327b33766c34539eab317303e26c5/lib/util/setaddall.js#L20-L47 | train |
coderaiser/node-tomas | lib/tomas.js | getName | function getName(name) {
const ext = path.extname(name);
const nameCrypt = crypto.createHash('sha1')
.update(name)
.digest('hex') + ext;
return getDir() + nameCrypt;
} | javascript | function getName(name) {
const ext = path.extname(name);
const nameCrypt = crypto.createHash('sha1')
.update(name)
.digest('hex') + ext;
return getDir() + nameCrypt;
} | [
"function",
"getName",
"(",
"name",
")",
"{",
"const",
"ext",
"=",
"path",
".",
"extname",
"(",
"name",
")",
";",
"const",
"nameCrypt",
"=",
"crypto",
".",
"createHash",
"(",
"'sha1'",
")",
".",
"update",
"(",
"name",
")",
".",
"digest",
"(",
"'hex'"... | function get name of file in min folder
@param name | [
"function",
"get",
"name",
"of",
"file",
"in",
"min",
"folder"
] | 62012fcdd432ccea9214969e8ca678baadbe32a0 | https://github.com/coderaiser/node-tomas/blob/62012fcdd432ccea9214969e8ca678baadbe32a0/lib/tomas.js#L91-L99 | train |
agbowlin/liquicode_membership | Membership.js | function(password, salt) {
var hash = npm_crypto.createHmac('sha512', salt); /** Hashing algorithm sha512 */
hash.update(password);
var value = hash.digest('hex');
return {
salt: salt,
passwordHash: value
};
} | javascript | function(password, salt) {
var hash = npm_crypto.createHmac('sha512', salt); /** Hashing algorithm sha512 */
hash.update(password);
var value = hash.digest('hex');
return {
salt: salt,
passwordHash: value
};
} | [
"function",
"(",
"password",
",",
"salt",
")",
"{",
"var",
"hash",
"=",
"npm_crypto",
".",
"createHmac",
"(",
"'sha512'",
",",
"salt",
")",
";",
"/** Hashing algorithm sha512 */",
"hash",
".",
"update",
"(",
"password",
")",
";",
"var",
"value",
"=",
"hash... | hash password with sha512.
@function
@param {string} password - List of required fields.
@param {string} salt - Data to be validated. | [
"hash",
"password",
"with",
"sha512",
"."
] | bf680ce8bf07fd17f6f1670d8c10c9e75757edd5 | https://github.com/agbowlin/liquicode_membership/blob/bf680ce8bf07fd17f6f1670d8c10c9e75757edd5/Membership.js#L128-L136 | train | |
fibo/write-file-utf8 | write-file-utf8.js | writeFileUtf8 | function writeFileUtf8 (filePath, content, callback) {
// Argument callback defaults to throwError.
if (typeof callback !== 'function') callback = throwError
if (typeof content === 'string') {
fs.writeFile(filePath, content, 'utf8', callback)
} else {
throw TypeError(error.contentIsNotString)
}
} | javascript | function writeFileUtf8 (filePath, content, callback) {
// Argument callback defaults to throwError.
if (typeof callback !== 'function') callback = throwError
if (typeof content === 'string') {
fs.writeFile(filePath, content, 'utf8', callback)
} else {
throw TypeError(error.contentIsNotString)
}
} | [
"function",
"writeFileUtf8",
"(",
"filePath",
",",
"content",
",",
"callback",
")",
"{",
"// Argument callback defaults to throwError.",
"if",
"(",
"typeof",
"callback",
"!==",
"'function'",
")",
"callback",
"=",
"throwError",
"if",
"(",
"typeof",
"content",
"===",
... | Write content to file using utf8 encoding
@param {String} filePath
@param {String} content
@param {Function} [callback] | [
"Write",
"content",
"to",
"file",
"using",
"utf8",
"encoding"
] | 2ae2667b0d3942380708412f7f8a6b4d492d191f | https://github.com/fibo/write-file-utf8/blob/2ae2667b0d3942380708412f7f8a6b4d492d191f/write-file-utf8.js#L22-L31 | train |
atd-schubert/node-stream-lib | lib/unit.js | function (stream) {
var self = this;
stream.on('data', function (chunk) {
self.push(chunk);
});
stream.on('end', function () {
self.push(null);
});
this.readableUnit = stream;
return this;
} | javascript | function (stream) {
var self = this;
stream.on('data', function (chunk) {
self.push(chunk);
});
stream.on('end', function () {
self.push(null);
});
this.readableUnit = stream;
return this;
} | [
"function",
"(",
"stream",
")",
"{",
"var",
"self",
"=",
"this",
";",
"stream",
".",
"on",
"(",
"'data'",
",",
"function",
"(",
"chunk",
")",
"{",
"self",
".",
"push",
"(",
"chunk",
")",
";",
"}",
")",
";",
"stream",
".",
"on",
"(",
"'end'",
",... | Set a readable stream for this unit
@param {stream.Readable|stream.Duplex|stream.Transform} stream - Use this stream as readable stream
@returns {Unit} | [
"Set",
"a",
"readable",
"stream",
"for",
"this",
"unit"
] | 90f27042fae84d2fbdbf9d28149b0673997f151a | https://github.com/atd-schubert/node-stream-lib/blob/90f27042fae84d2fbdbf9d28149b0673997f151a/lib/unit.js#L56-L66 | train | |
interlockjs/plugins | packages/h2/src/index.js | buildPushManifest | function buildPushManifest (bundles, manifestFilename) {
const manifestableBundles = filter(bundles, bundle => bundle.module);
const bundlesByModuleId = chain(manifestableBundles)
.map(bundle => [ bundle.module.id, bundle ])
.fromPairs()
.value();
const bundleDepGraph = chain... | javascript | function buildPushManifest (bundles, manifestFilename) {
const manifestableBundles = filter(bundles, bundle => bundle.module);
const bundlesByModuleId = chain(manifestableBundles)
.map(bundle => [ bundle.module.id, bundle ])
.fromPairs()
.value();
const bundleDepGraph = chain... | [
"function",
"buildPushManifest",
"(",
"bundles",
",",
"manifestFilename",
")",
"{",
"const",
"manifestableBundles",
"=",
"filter",
"(",
"bundles",
",",
"bundle",
"=>",
"bundle",
".",
"module",
")",
";",
"const",
"bundlesByModuleId",
"=",
"chain",
"(",
"manifesta... | Build a bundle dependency graph, such that when a JS bundle is requested, the server can know what other files will be requested once the bundle loads in the client browser. | [
"Build",
"a",
"bundle",
"dependency",
"graph",
"such",
"that",
"when",
"a",
"JS",
"bundle",
"is",
"requested",
"the",
"server",
"can",
"know",
"what",
"other",
"files",
"will",
"be",
"requested",
"once",
"the",
"bundle",
"loads",
"in",
"the",
"client",
"br... | 05197e4511b64d269260fe3c701ceff864897ab3 | https://github.com/interlockjs/plugins/blob/05197e4511b64d269260fe3c701ceff864897ab3/packages/h2/src/index.js#L97-L123 | train |
ohmlang/eslint-plugin-camelcase-ohm | lib/camelcase-ohm.js | checkCamelCase | function checkCamelCase(idNode) {
var reported = false;
var fakeContext = {
report: function() { reported = true; },
options: []
};
camelcase(fakeContext).Identifier(idNode); // eslint-disable-line new-cap
return !reported;
} | javascript | function checkCamelCase(idNode) {
var reported = false;
var fakeContext = {
report: function() { reported = true; },
options: []
};
camelcase(fakeContext).Identifier(idNode); // eslint-disable-line new-cap
return !reported;
} | [
"function",
"checkCamelCase",
"(",
"idNode",
")",
"{",
"var",
"reported",
"=",
"false",
";",
"var",
"fakeContext",
"=",
"{",
"report",
":",
"function",
"(",
")",
"{",
"reported",
"=",
"true",
";",
"}",
",",
"options",
":",
"[",
"]",
"}",
";",
"camelc... | Checks whether the given node is considered an error by the camelcase rule. | [
"Checks",
"whether",
"the",
"given",
"node",
"is",
"considered",
"an",
"error",
"by",
"the",
"camelcase",
"rule",
"."
] | 21cdfa68b973eac43d68852ffbc3cb7cf688296f | https://github.com/ohmlang/eslint-plugin-camelcase-ohm/blob/21cdfa68b973eac43d68852ffbc3cb7cf688296f/lib/camelcase-ohm.js#L6-L14 | train |
ohmlang/eslint-plugin-camelcase-ohm | lib/camelcase-ohm.js | checkSemanticActionName | function checkSemanticActionName(node) {
var name = node.name;
var underscoreIdx = name.indexOf('_');
// The underscore should not appear on the ends,
// case names should begin with a lowercase letter,
// and there should be only one underscore in the name.
if ((underscoreIdx > 0 && underscoreIdx < (name.... | javascript | function checkSemanticActionName(node) {
var name = node.name;
var underscoreIdx = name.indexOf('_');
// The underscore should not appear on the ends,
// case names should begin with a lowercase letter,
// and there should be only one underscore in the name.
if ((underscoreIdx > 0 && underscoreIdx < (name.... | [
"function",
"checkSemanticActionName",
"(",
"node",
")",
"{",
"var",
"name",
"=",
"node",
".",
"name",
";",
"var",
"underscoreIdx",
"=",
"name",
".",
"indexOf",
"(",
"'_'",
")",
";",
"// The underscore should not appear on the ends,",
"// case names should begin with ... | Returns true if `name` appears to be the name of a semantic action. The idiomatic style in Ohm is `RuleName_caseName`. | [
"Returns",
"true",
"if",
"name",
"appears",
"to",
"be",
"the",
"name",
"of",
"a",
"semantic",
"action",
".",
"The",
"idiomatic",
"style",
"in",
"Ohm",
"is",
"RuleName_caseName",
"."
] | 21cdfa68b973eac43d68852ffbc3cb7cf688296f | https://github.com/ohmlang/eslint-plugin-camelcase-ohm/blob/21cdfa68b973eac43d68852ffbc3cb7cf688296f/lib/camelcase-ohm.js#L23-L36 | train |
andrewscwei/requiem | src/dom/setAttribute.js | setAttribute | function setAttribute(element, name, value) {
assertType(element, Node, false, 'Invalid element specified');
if (value === undefined || value === null || value === false)
element.removeAttribute(name);
else if (value === true)
element.setAttribute(name, '');
else
element.setAttribute(name, value);
... | javascript | function setAttribute(element, name, value) {
assertType(element, Node, false, 'Invalid element specified');
if (value === undefined || value === null || value === false)
element.removeAttribute(name);
else if (value === true)
element.setAttribute(name, '');
else
element.setAttribute(name, value);
... | [
"function",
"setAttribute",
"(",
"element",
",",
"name",
",",
"value",
")",
"{",
"assertType",
"(",
"element",
",",
"Node",
",",
"false",
",",
"'Invalid element specified'",
")",
";",
"if",
"(",
"value",
"===",
"undefined",
"||",
"value",
"===",
"null",
"|... | Sets an attribute of an element by the attribute name.
@param {Node} element - Target element.
@param {string} name - Attribute name.
@param {*} value - Attribute value.
@alias module:requiem~dom.setAttribute | [
"Sets",
"an",
"attribute",
"of",
"an",
"element",
"by",
"the",
"attribute",
"name",
"."
] | c4182bfffc9841c6de5718f689ad3c2060511777 | https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/dom/setAttribute.js#L17-L27 | train |
Nazariglez/perenquen | lib/pixi/src/core/display/DisplayObject.js | DisplayObject | function DisplayObject()
{
EventEmitter.call(this);
/**
* The coordinate of the object relative to the local coordinates of the parent.
*
* @member {Point}
*/
this.position = new math.Point();
/**
* The scale factor of the object.
*
* @member {Point}
*/
this... | javascript | function DisplayObject()
{
EventEmitter.call(this);
/**
* The coordinate of the object relative to the local coordinates of the parent.
*
* @member {Point}
*/
this.position = new math.Point();
/**
* The scale factor of the object.
*
* @member {Point}
*/
this... | [
"function",
"DisplayObject",
"(",
")",
"{",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"/**\n * The coordinate of the object relative to the local coordinates of the parent.\n *\n * @member {Point}\n */",
"this",
".",
"position",
"=",
"new",
"math",
"."... | The base class for all objects that are rendered on the screen.
This is an abstract class and should not be used on its own rather it should be extended.
@class
@memberof PIXI | [
"The",
"base",
"class",
"for",
"all",
"objects",
"that",
"are",
"rendered",
"on",
"the",
"screen",
".",
"This",
"is",
"an",
"abstract",
"class",
"and",
"should",
"not",
"be",
"used",
"on",
"its",
"own",
"rather",
"it",
"should",
"be",
"extended",
"."
] | e023964d05afeefebdcac4e2044819fdfa3899ae | https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/core/display/DisplayObject.js#L14-L152 | train |
lourenzo/gulp-jscs-custom | index.js | loadReporter | function loadReporter(reporterPath) {
var reporter;
reporterPath = reporterPath || 'checkstyle';
if (!fs.existsSync(path.resolve(reporterPath))) {
try {
reporter = require('./lib/reporters/' + reporterPath);
} catch (e) {
try {
reporter = require('jscs... | javascript | function loadReporter(reporterPath) {
var reporter;
reporterPath = reporterPath || 'checkstyle';
if (!fs.existsSync(path.resolve(reporterPath))) {
try {
reporter = require('./lib/reporters/' + reporterPath);
} catch (e) {
try {
reporter = require('jscs... | [
"function",
"loadReporter",
"(",
"reporterPath",
")",
"{",
"var",
"reporter",
";",
"reporterPath",
"=",
"reporterPath",
"||",
"'checkstyle'",
";",
"if",
"(",
"!",
"fs",
".",
"existsSync",
"(",
"path",
".",
"resolve",
"(",
"reporterPath",
")",
")",
")",
"{"... | load a proper Reporter
@todo Throw error when no reporter was found
@return {Function} the selected report | [
"load",
"a",
"proper",
"Reporter"
] | 8fe9eb834f407aa0b4368131786704c5bc3bd989 | https://github.com/lourenzo/gulp-jscs-custom/blob/8fe9eb834f407aa0b4368131786704c5bc3bd989/index.js#L16-L38 | train |
SSharyk/encrypted-ticket | index.js | generateRandomString | function generateRandomString(length) {
let s = "";
let i = length;
while (length-- > 0) {
let c = Math.floor(Math.random() * (MAX_HEX_SYMBOL - MIN_HEX_SYMBOL + 1)) + MIN_HEX_SYMBOL;
c = c.toString(16).toLowerCase();
s += c;
}
return s;
} | javascript | function generateRandomString(length) {
let s = "";
let i = length;
while (length-- > 0) {
let c = Math.floor(Math.random() * (MAX_HEX_SYMBOL - MIN_HEX_SYMBOL + 1)) + MIN_HEX_SYMBOL;
c = c.toString(16).toLowerCase();
s += c;
}
return s;
} | [
"function",
"generateRandomString",
"(",
"length",
")",
"{",
"let",
"s",
"=",
"\"\"",
";",
"let",
"i",
"=",
"length",
";",
"while",
"(",
"length",
"--",
">",
"0",
")",
"{",
"let",
"c",
"=",
"Math",
".",
"floor",
"(",
"Math",
".",
"random",
"(",
"... | Generates string, each symbol of that is either number or A..F
@param {number} length - length of string to be generated
@return {string} Random string of the required length | [
"Generates",
"string",
"each",
"symbol",
"of",
"that",
"is",
"either",
"number",
"or",
"A",
"..",
"F"
] | 0597b9680d343fede99d59894fe5ff9da93bdfc2 | https://github.com/SSharyk/encrypted-ticket/blob/0597b9680d343fede99d59894fe5ff9da93bdfc2/index.js#L104-L113 | train |
willscott/grunt-jasmine-chromeapp | tasks/jasmine-chromeapp/relay.js | send | function send() {
'use strict';
var req = new XMLHttpRequest(),
specs = jsApiReporter.specs(),
payload;
if (specs.length) {
specs.push(logs);
}
payload = JSON.stringify(specs);
req.open('post', 'http://localhost:' + port + '/put', true);
req.onload = function () {
if (this.responseText =... | javascript | function send() {
'use strict';
var req = new XMLHttpRequest(),
specs = jsApiReporter.specs(),
payload;
if (specs.length) {
specs.push(logs);
}
payload = JSON.stringify(specs);
req.open('post', 'http://localhost:' + port + '/put', true);
req.onload = function () {
if (this.responseText =... | [
"function",
"send",
"(",
")",
"{",
"'use strict'",
";",
"var",
"req",
"=",
"new",
"XMLHttpRequest",
"(",
")",
",",
"specs",
"=",
"jsApiReporter",
".",
"specs",
"(",
")",
",",
"payload",
";",
"if",
"(",
"specs",
".",
"length",
")",
"{",
"specs",
".",
... | This code sends the report. | [
"This",
"code",
"sends",
"the",
"report",
"."
] | 8582a56e0fd3c559948656fae157082910c45055 | https://github.com/willscott/grunt-jasmine-chromeapp/blob/8582a56e0fd3c559948656fae157082910c45055/tasks/jasmine-chromeapp/relay.js#L7-L25 | train |
PanthR/panthrMath | panthrMath/rgen/rgen.js | function(name) {
// "name" encapsulates some simple options like precision
rgen.random = rgen.algorithms[name].random;
rgen.setSeed = rgen.algorithms[name].setSeed;
return rgen.setRandomSeed();
} | javascript | function(name) {
// "name" encapsulates some simple options like precision
rgen.random = rgen.algorithms[name].random;
rgen.setSeed = rgen.algorithms[name].setSeed;
return rgen.setRandomSeed();
} | [
"function",
"(",
"name",
")",
"{",
"// \"name\" encapsulates some simple options like precision",
"rgen",
".",
"random",
"=",
"rgen",
".",
"algorithms",
"[",
"name",
"]",
".",
"random",
";",
"rgen",
".",
"setSeed",
"=",
"rgen",
".",
"algorithms",
"[",
"name",
... | Sets the algorithm to be used for random number generation.
Expects `name` to be one of the strings returned by `getAlgorithms`. | [
"Sets",
"the",
"algorithm",
"to",
"be",
"used",
"for",
"random",
"number",
"generation",
".",
"Expects",
"name",
"to",
"be",
"one",
"of",
"the",
"strings",
"returned",
"by",
"getAlgorithms",
"."
] | 54d249ca9903a9535f963da711bd3a87fb229c0b | https://github.com/PanthR/panthrMath/blob/54d249ca9903a9535f963da711bd3a87fb229c0b/panthrMath/rgen/rgen.js#L69-L74 | train | |
redisjs/jsr-server | lib/command/database/string/setbit.js | validate | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var value = parseInt('' + args[2]);
if(value !== 0 && value !== 1) throw InvalidBit;
args[2] = value;
} | javascript | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var value = parseInt('' + args[2]);
if(value !== 0 && value !== 1) throw InvalidBit;
args[2] = value;
} | [
"function",
"validate",
"(",
"cmd",
",",
"args",
",",
"info",
")",
"{",
"AbstractCommand",
".",
"prototype",
".",
"validate",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"var",
"value",
"=",
"parseInt",
"(",
"''",
"+",
"args",
"[",
"2",
"]... | Validate the SETBIT command. | [
"Validate",
"the",
"SETBIT",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/database/string/setbit.js#L19-L24 | train |
thomasfr/Timeliner.Core | lib/tokenizeText.js | tokenizeText | function tokenizeText(text, callback) {
"use strict";
processTokens(tokenizer.tokenize(text) || [], function (error, tokens) {
process.nextTick(function () {
callback(error, tokens);
});
});
} | javascript | function tokenizeText(text, callback) {
"use strict";
processTokens(tokenizer.tokenize(text) || [], function (error, tokens) {
process.nextTick(function () {
callback(error, tokens);
});
});
} | [
"function",
"tokenizeText",
"(",
"text",
",",
"callback",
")",
"{",
"\"use strict\"",
";",
"processTokens",
"(",
"tokenizer",
".",
"tokenize",
"(",
"text",
")",
"||",
"[",
"]",
",",
"function",
"(",
"error",
",",
"tokens",
")",
"{",
"process",
".",
"next... | Tokenizes the given text into normalized uppercased tokens
@param String text Text you want to parse and tokenize
@param Function callback Callback gets called with this parameters function(error, String[])
@api public | [
"Tokenizes",
"the",
"given",
"text",
"into",
"normalized",
"uppercased",
"tokens"
] | f776202c22c7ca2ee50deb1bae6130fd3dcfe7fc | https://github.com/thomasfr/Timeliner.Core/blob/f776202c22c7ca2ee50deb1bae6130fd3dcfe7fc/lib/tokenizeText.js#L13-L20 | train |
vesln/refractory | lib/refractory.js | load | function load(mod) {
var base = path.dirname(mod.filename);
var folders = [].slice.call(arguments, 1);
return function refractory() {
var files = [].slice.call(arguments);
var paths = [];
files
.map(function(file) {
return path.basename(file);
})
.forEach(function(file) {
fol... | javascript | function load(mod) {
var base = path.dirname(mod.filename);
var folders = [].slice.call(arguments, 1);
return function refractory() {
var files = [].slice.call(arguments);
var paths = [];
files
.map(function(file) {
return path.basename(file);
})
.forEach(function(file) {
fol... | [
"function",
"load",
"(",
"mod",
")",
"{",
"var",
"base",
"=",
"path",
".",
"dirname",
"(",
"mod",
".",
"filename",
")",
";",
"var",
"folders",
"=",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
";",
"return",
"function",
"... | Load a file.
`refractory` will search the paths in the order specified
for each module provided on `load`.
@param {Object} module (contains filename to resolve from)
@param {String} path(s) to search
@param ...
@returns {Function} file loader
@api public | [
"Load",
"a",
"file",
"."
] | 9bc07ad8e7ad5f93201400ad0a15037dfabda207 | https://github.com/vesln/refractory/blob/9bc07ad8e7ad5f93201400ad0a15037dfabda207/lib/refractory.js#L26-L61 | train |
Nazariglez/perenquen | lib/pixi/src/core/renderers/webgl/filters/SpriteMaskFilter.js | SpriteMaskFilter | function SpriteMaskFilter(sprite)
{
var maskMatrix = new math.Matrix();
AbstractFilter.call(this,
fs.readFileSync(__dirname + '/spriteMaskFilter.vert', 'utf8'),
fs.readFileSync(__dirname + '/spriteMaskFilter.frag', 'utf8'),
{
mask: { type: 'sampler2D', value: sprit... | javascript | function SpriteMaskFilter(sprite)
{
var maskMatrix = new math.Matrix();
AbstractFilter.call(this,
fs.readFileSync(__dirname + '/spriteMaskFilter.vert', 'utf8'),
fs.readFileSync(__dirname + '/spriteMaskFilter.frag', 'utf8'),
{
mask: { type: 'sampler2D', value: sprit... | [
"function",
"SpriteMaskFilter",
"(",
"sprite",
")",
"{",
"var",
"maskMatrix",
"=",
"new",
"math",
".",
"Matrix",
"(",
")",
";",
"AbstractFilter",
".",
"call",
"(",
"this",
",",
"fs",
".",
"readFileSync",
"(",
"__dirname",
"+",
"'/spriteMaskFilter.vert'",
","... | The SpriteMaskFilter class
@class
@extends AbstractFilter
@memberof PIXI
@param sprite {Sprite} the target sprite | [
"The",
"SpriteMaskFilter",
"class"
] | e023964d05afeefebdcac4e2044819fdfa3899ae | https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/core/renderers/webgl/filters/SpriteMaskFilter.js#L15-L31 | train |
SalvatorePreviti/tslint-config-quick | hasPrettier.js | hasPrettier | function hasPrettier() {
if (hasPrettierCache === true || hasPrettierCache === false) {
return hasPrettierCache
}
hasPrettierCache = false
try {
const requireOptions = { paths: [getRootPath()] }
const manifestPath = require.resolve('./package.json', requireOptions)
const manifest = JSON.parse(fs... | javascript | function hasPrettier() {
if (hasPrettierCache === true || hasPrettierCache === false) {
return hasPrettierCache
}
hasPrettierCache = false
try {
const requireOptions = { paths: [getRootPath()] }
const manifestPath = require.resolve('./package.json', requireOptions)
const manifest = JSON.parse(fs... | [
"function",
"hasPrettier",
"(",
")",
"{",
"if",
"(",
"hasPrettierCache",
"===",
"true",
"||",
"hasPrettierCache",
"===",
"false",
")",
"{",
"return",
"hasPrettierCache",
"}",
"hasPrettierCache",
"=",
"false",
"try",
"{",
"const",
"requireOptions",
"=",
"{",
"p... | Check wether prettier is present in the main package.json
@returns {boolean} True if prettier is present in the main package.json | [
"Check",
"wether",
"prettier",
"is",
"present",
"in",
"the",
"main",
"package",
".",
"json"
] | 2bc58f6acd86fe112150c8e825f6274f09f2cd52 | https://github.com/SalvatorePreviti/tslint-config-quick/blob/2bc58f6acd86fe112150c8e825f6274f09f2cd52/hasPrettier.js#L12-L30 | train |
creationix/culvert | wrap-web-socket.js | wrapNodeSocket | function wrapNodeSocket(ws, reportError) {
// Data traveling from websocket to consumer
var incoming = makeChannel();
// Data traveling from consumer to websocket
var outgoing = makeChannel();
onTake = wrapHandler(onTake, onError);
outgoing.take(onTake);
ws.onerror = onError;
ws.onmessage = wrap(onMes... | javascript | function wrapNodeSocket(ws, reportError) {
// Data traveling from websocket to consumer
var incoming = makeChannel();
// Data traveling from consumer to websocket
var outgoing = makeChannel();
onTake = wrapHandler(onTake, onError);
outgoing.take(onTake);
ws.onerror = onError;
ws.onmessage = wrap(onMes... | [
"function",
"wrapNodeSocket",
"(",
"ws",
",",
"reportError",
")",
"{",
"// Data traveling from websocket to consumer",
"var",
"incoming",
"=",
"makeChannel",
"(",
")",
";",
"// Data traveling from consumer to websocket",
"var",
"outgoing",
"=",
"makeChannel",
"(",
")",
... | Given a browser websocket, return a culvert duplex channel. | [
"Given",
"a",
"browser",
"websocket",
"return",
"a",
"culvert",
"duplex",
"channel",
"."
] | 42b83894041cd7f8ee3993af0df65c1afe17b2c5 | https://github.com/creationix/culvert/blob/42b83894041cd7f8ee3993af0df65c1afe17b2c5/wrap-web-socket.js#L6-L49 | train |
vantagejs/vantage-auth-basic | lib/vantage-auth-basic.js | search | function search(user, pass, userArray) {
return _.findWhere(userArray, { user: user, pass: pass });
} | javascript | function search(user, pass, userArray) {
return _.findWhere(userArray, { user: user, pass: pass });
} | [
"function",
"search",
"(",
"user",
",",
"pass",
",",
"userArray",
")",
"{",
"return",
"_",
".",
"findWhere",
"(",
"userArray",
",",
"{",
"user",
":",
"user",
",",
"pass",
":",
"pass",
"}",
")",
";",
"}"
] | Check if submitted user matches anything. | [
"Check",
"if",
"submitted",
"user",
"matches",
"anything",
"."
] | fb966abb64ab26dfef975bc6b13350e6306169d5 | https://github.com/vantagejs/vantage-auth-basic/blob/fb966abb64ab26dfef975bc6b13350e6306169d5/lib/vantage-auth-basic.js#L85-L87 | train |
vantagejs/vantage-auth-basic | lib/vantage-auth-basic.js | ask | function ask(question, cbk, skip) {
if (skip) {
cbk(skip);
return;
}
self.prompt(question, function(answ) {
if (String(answ.answer).trim() === "") {
return ask(question, cbk);
} else {
cbk(answ.answer);
}
});
} | javascript | function ask(question, cbk, skip) {
if (skip) {
cbk(skip);
return;
}
self.prompt(question, function(answ) {
if (String(answ.answer).trim() === "") {
return ask(question, cbk);
} else {
cbk(answ.answer);
}
});
} | [
"function",
"ask",
"(",
"question",
",",
"cbk",
",",
"skip",
")",
"{",
"if",
"(",
"skip",
")",
"{",
"cbk",
"(",
"skip",
")",
";",
"return",
";",
"}",
"self",
".",
"prompt",
"(",
"question",
",",
"function",
"(",
"answ",
")",
"{",
"if",
"(",
"St... | If a value is given, skip, otherwise prompt user for data. | [
"If",
"a",
"value",
"is",
"given",
"skip",
"otherwise",
"prompt",
"user",
"for",
"data",
"."
] | fb966abb64ab26dfef975bc6b13350e6306169d5 | https://github.com/vantagejs/vantage-auth-basic/blob/fb966abb64ab26dfef975bc6b13350e6306169d5/lib/vantage-auth-basic.js#L91-L103 | train |
vantagejs/vantage-auth-basic | lib/vantage-auth-basic.js | gather | function gather(cbk) {
ask(questions[0], function(user) {
state.user = user;
ask(questions[1], function(pass){
state.pass = pass;
cbk(state.user, state.pass);
}, state.pass);
}, state.user);
} | javascript | function gather(cbk) {
ask(questions[0], function(user) {
state.user = user;
ask(questions[1], function(pass){
state.pass = pass;
cbk(state.user, state.pass);
}, state.pass);
}, state.user);
} | [
"function",
"gather",
"(",
"cbk",
")",
"{",
"ask",
"(",
"questions",
"[",
"0",
"]",
",",
"function",
"(",
"user",
")",
"{",
"state",
".",
"user",
"=",
"user",
";",
"ask",
"(",
"questions",
"[",
"1",
"]",
",",
"function",
"(",
"pass",
")",
"{",
... | Ask for a user and password. If a user is passed in, just ask for a password and skip the user. | [
"Ask",
"for",
"a",
"user",
"and",
"password",
".",
"If",
"a",
"user",
"is",
"passed",
"in",
"just",
"ask",
"for",
"a",
"password",
"and",
"skip",
"the",
"user",
"."
] | fb966abb64ab26dfef975bc6b13350e6306169d5 | https://github.com/vantagejs/vantage-auth-basic/blob/fb966abb64ab26dfef975bc6b13350e6306169d5/lib/vantage-auth-basic.js#L108-L116 | train |
vantagejs/vantage-auth-basic | lib/vantage-auth-basic.js | attempt | function attempt() {
connections[id].attempts++;
if (connections[id].attempts > retry) {
connections[id].attempts = 0;
connections[id].deny++;
self.log(chalk.yellow("Access denied: too many attempts."));
callback("Access denied: too many attempts.", false);
ret... | javascript | function attempt() {
connections[id].attempts++;
if (connections[id].attempts > retry) {
connections[id].attempts = 0;
connections[id].deny++;
self.log(chalk.yellow("Access denied: too many attempts."));
callback("Access denied: too many attempts.", false);
ret... | [
"function",
"attempt",
"(",
")",
"{",
"connections",
"[",
"id",
"]",
".",
"attempts",
"++",
";",
"if",
"(",
"connections",
"[",
"id",
"]",
".",
"attempts",
">",
"retry",
")",
"{",
"connections",
"[",
"id",
"]",
".",
"attempts",
"=",
"0",
";",
"conn... | Authentication attempt logic, including adding up retry and deny counts, etc. | [
"Authentication",
"attempt",
"logic",
"including",
"adding",
"up",
"retry",
"and",
"deny",
"counts",
"etc",
"."
] | fb966abb64ab26dfef975bc6b13350e6306169d5 | https://github.com/vantagejs/vantage-auth-basic/blob/fb966abb64ab26dfef975bc6b13350e6306169d5/lib/vantage-auth-basic.js#L121-L155 | train |
feedhenry/fh-mbaas-middleware | lib/email/index.js | sendAlertEmail | function sendAlertEmail(alertEmailData, cb) {
var mongoAlert = alertEmailData.alert;
var eventDetails = alertEmailData.eventDetails;
var emailConfig = config.getConfig().email;
var from = emailConfig ? emailConfig.alert_email_from : 'noreply@feedhenry.com';
fs.readFile(ALERT_EMAIL_TEMPLATE, function(err, dat... | javascript | function sendAlertEmail(alertEmailData, cb) {
var mongoAlert = alertEmailData.alert;
var eventDetails = alertEmailData.eventDetails;
var emailConfig = config.getConfig().email;
var from = emailConfig ? emailConfig.alert_email_from : 'noreply@feedhenry.com';
fs.readFile(ALERT_EMAIL_TEMPLATE, function(err, dat... | [
"function",
"sendAlertEmail",
"(",
"alertEmailData",
",",
"cb",
")",
"{",
"var",
"mongoAlert",
"=",
"alertEmailData",
".",
"alert",
";",
"var",
"eventDetails",
"=",
"alertEmailData",
".",
"eventDetails",
";",
"var",
"emailConfig",
"=",
"config",
".",
"getConfig"... | Send an Alert email to recipients for given Event
@param alertEmailData
@param cb | [
"Send",
"an",
"Alert",
"email",
"to",
"recipients",
"for",
"given",
"Event"
] | f906e98efbb4b0963bf5137b34b5e0589ba24e69 | https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/email/index.js#L57-L90 | train |
iwillwen/watchman.js | src/watchman.js | createRule | function createRule(path, handler) {
if ('*' !== path && 0 != path.indexOf(watch.__base)) {
path = watch.__base + (path == '/' ? '' : path)
}
let rule = pathToRegExp(path)
if (handler instanceof String) {
let target = handler
handler = function() {
watch({
url: target
})
}
... | javascript | function createRule(path, handler) {
if ('*' !== path && 0 != path.indexOf(watch.__base)) {
path = watch.__base + (path == '/' ? '' : path)
}
let rule = pathToRegExp(path)
if (handler instanceof String) {
let target = handler
handler = function() {
watch({
url: target
})
}
... | [
"function",
"createRule",
"(",
"path",
",",
"handler",
")",
"{",
"if",
"(",
"'*'",
"!==",
"path",
"&&",
"0",
"!=",
"path",
".",
"indexOf",
"(",
"watch",
".",
"__base",
")",
")",
"{",
"path",
"=",
"watch",
".",
"__base",
"+",
"(",
"path",
"==",
"'... | create a rule
@param {String} path path
@param {Funtion} handler handle callback
@return {Object} rule object | [
"create",
"a",
"rule"
] | 54b380f53311aa03422cf7ce4e41a5fb7a2c067a | https://github.com/iwillwen/watchman.js/blob/54b380f53311aa03422cf7ce4e41a5fb7a2c067a/src/watchman.js#L249-L265 | train |
novadiscovery/nway | lib/builders/standard.js | initialize | function initialize(done) {
debug('prepare');
parser(options.index, options, function(err, modules) {
if(err) return done(err)
debug('Parser return, now build the tree...');
tree = buildTree(options, modules, true);
debug('Tree builded');
// Extract from tree as a flatten list of packet... | javascript | function initialize(done) {
debug('prepare');
parser(options.index, options, function(err, modules) {
if(err) return done(err)
debug('Parser return, now build the tree...');
tree = buildTree(options, modules, true);
debug('Tree builded');
// Extract from tree as a flatten list of packet... | [
"function",
"initialize",
"(",
"done",
")",
"{",
"debug",
"(",
"'prepare'",
")",
";",
"parser",
"(",
"options",
".",
"index",
",",
"options",
",",
"function",
"(",
"err",
",",
"modules",
")",
"{",
"if",
"(",
"err",
")",
"return",
"done",
"(",
"err",
... | BUILD FLOW
Step 1
Prepare builder information using nway.prepare() :
modules object, root module, sources, tree and packet list
@api private | [
"BUILD",
"FLOW",
"Step",
"1"
] | fa31c6fe56f2305721e581ac25e8ac9a87e15dda | https://github.com/novadiscovery/nway/blob/fa31c6fe56f2305721e581ac25e8ac9a87e15dda/lib/builders/standard.js#L97-L114 | train |
thomasfr/Timeliner.Core | lib/tokenizeWord.js | tokenizeWord | function tokenizeWord(word, callback) {
"use strict";
var match, parts = [], stemmedPart, singularPart, singularMetaphones, stemmedMetaphones, token;
// TODO: Improve that. Should be in the stemmer actually
//if (-1 === (match = word.match(/^([#"',;:!?(.\[{])*([a-z0-9]+)+([,;:!?)\]}"'.])*$/i))) {
/... | javascript | function tokenizeWord(word, callback) {
"use strict";
var match, parts = [], stemmedPart, singularPart, singularMetaphones, stemmedMetaphones, token;
// TODO: Improve that. Should be in the stemmer actually
//if (-1 === (match = word.match(/^([#"',;:!?(.\[{])*([a-z0-9]+)+([,;:!?)\]}"'.])*$/i))) {
/... | [
"function",
"tokenizeWord",
"(",
"word",
",",
"callback",
")",
"{",
"\"use strict\"",
";",
"var",
"match",
",",
"parts",
"=",
"[",
"]",
",",
"stemmedPart",
",",
"singularPart",
",",
"singularMetaphones",
",",
"stemmedMetaphones",
",",
"token",
";",
"// TODO: I... | Processes a given word.
Will do stemming, singularizing and adds double metaphone of each.
also adds the stemmed and singularized and the word itself.
So at max there are 7 tokens generated for each word.
Tokens gets sorted and duplicates gets removed
@param String word
@param Function callback function(error, String[... | [
"Processes",
"a",
"given",
"word",
".",
"Will",
"do",
"stemming",
"singularizing",
"and",
"adds",
"double",
"metaphone",
"of",
"each",
".",
"also",
"adds",
"the",
"stemmed",
"and",
"singularized",
"and",
"the",
"word",
"itself",
".",
"So",
"at",
"max",
"th... | f776202c22c7ca2ee50deb1bae6130fd3dcfe7fc | https://github.com/thomasfr/Timeliner.Core/blob/f776202c22c7ca2ee50deb1bae6130fd3dcfe7fc/lib/tokenizeWord.js#L19-L87 | train |
xiamidaxia/xiami | meteor/mongo-livedata/mongo_driver.js | function (ordered) {
var self = this;
if (ordered) {
return self.fetch();
} else {
var results = new LocalCollection._IdMap;
self.forEach(function (doc) {
results.set(doc._id, doc);
});
return results;
}
} | javascript | function (ordered) {
var self = this;
if (ordered) {
return self.fetch();
} else {
var results = new LocalCollection._IdMap;
self.forEach(function (doc) {
results.set(doc._id, doc);
});
return results;
}
} | [
"function",
"(",
"ordered",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"ordered",
")",
"{",
"return",
"self",
".",
"fetch",
"(",
")",
";",
"}",
"else",
"{",
"var",
"results",
"=",
"new",
"LocalCollection",
".",
"_IdMap",
";",
"self",
"."... | This method is NOT wrapped in Cursor. | [
"This",
"method",
"is",
"NOT",
"wrapped",
"in",
"Cursor",
"."
] | 6fcee92c493c12bf8fd67c7068e67fa6a72a306b | https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/mongo-livedata/mongo_driver.js#L926-L937 | train | |
tolokoban/ToloFrameWork | ker/mod/tfw.binding.list.js | function(arg) {
readOnly(this, ID, COUNT++);
readOnly(this, "_listeners", new Listeners());
readOnly(this, "_links", []);
// An object with the attribute `isContentChangeAware === true`
// can fire a property value changed when its contant has change.
readOnly(this, "isContentChangeAware", tr... | javascript | function(arg) {
readOnly(this, ID, COUNT++);
readOnly(this, "_listeners", new Listeners());
readOnly(this, "_links", []);
// An object with the attribute `isContentChangeAware === true`
// can fire a property value changed when its contant has change.
readOnly(this, "isContentChangeAware", tr... | [
"function",
"(",
"arg",
")",
"{",
"readOnly",
"(",
"this",
",",
"ID",
",",
"COUNT",
"++",
")",
";",
"readOnly",
"(",
"this",
",",
"\"_listeners\"",
",",
"new",
"Listeners",
"(",
")",
")",
";",
"readOnly",
"(",
"this",
",",
"\"_links\"",
",",
"[",
"... | A list is an observable array.
Several lists can share the same internal array. In that case, when
one list modifies the array, all lists will emit the same event as
it. Such lists are linked. | [
"A",
"list",
"is",
"an",
"observable",
"array",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/tfw.binding.list.js#L33-L48 | train | |
redisjs/jsr-server | lib/stats.js | Stats | function Stats(state) {
this.state = state;
this.clear();
this.onConnect = onConnect.bind(this);
this.onDisconnect = onDisconnect.bind(this);
this.onRejected = onRejected.bind(this);
this.onHit = onHit.bind(this);
this.onMiss = onMiss.bind(this);
this.onExpired = onExpired.bind(this);
this.onExpired =... | javascript | function Stats(state) {
this.state = state;
this.clear();
this.onConnect = onConnect.bind(this);
this.onDisconnect = onDisconnect.bind(this);
this.onRejected = onRejected.bind(this);
this.onHit = onHit.bind(this);
this.onMiss = onMiss.bind(this);
this.onExpired = onExpired.bind(this);
this.onExpired =... | [
"function",
"Stats",
"(",
"state",
")",
"{",
"this",
".",
"state",
"=",
"state",
";",
"this",
".",
"clear",
"(",
")",
";",
"this",
".",
"onConnect",
"=",
"onConnect",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"onDisconnect",
"=",
"onDisconnect... | Encapsulates the server statistics. | [
"Encapsulates",
"the",
"server",
"statistics",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/stats.js#L4-L15 | train |
hydrojs/karma-hydro | adapter.js | function(error) {
if (!error.stack) return error.message;
var stack = error.stack;
var firstLine = stack.substring(0, stack.indexOf('\n'));
if (error.message && firstLine.indexOf(error.message) === -1) stack = error.message + '\n' + stack;
return stack.replace(/\n.+\/adapter(\/lib)?\/hydro.js\?\d*\:... | javascript | function(error) {
if (!error.stack) return error.message;
var stack = error.stack;
var firstLine = stack.substring(0, stack.indexOf('\n'));
if (error.message && firstLine.indexOf(error.message) === -1) stack = error.message + '\n' + stack;
return stack.replace(/\n.+\/adapter(\/lib)?\/hydro.js\?\d*\:... | [
"function",
"(",
"error",
")",
"{",
"if",
"(",
"!",
"error",
".",
"stack",
")",
"return",
"error",
".",
"message",
";",
"var",
"stack",
"=",
"error",
".",
"stack",
";",
"var",
"firstLine",
"=",
"stack",
".",
"substring",
"(",
"0",
",",
"stack",
"."... | Format error.
@param {Error} error
@returns {String}
@api private | [
"Format",
"error",
"."
] | a0d5e083b1ddd1c4fbc7d6fa29ed1b0d9d4a5193 | https://github.com/hydrojs/karma-hydro/blob/a0d5e083b1ddd1c4fbc7d6fa29ed1b0d9d4a5193/adapter.js#L17-L23 | train | |
awto/mfjs-core | index.js | defaults | function defaults(defs,opts) {
if (!opts)
opts = {}
if (opts.context == null)
opts.context = true;
if (opts.coerce == null)
opts.coerce = true;
completeMonad(defs);
if (opts.control === "token")
defs = M.addControlByToken(defs);
if (opts.wrap)
defs = M.wrap(defs,opts.wrap);
if (opts.co... | javascript | function defaults(defs,opts) {
if (!opts)
opts = {}
if (opts.context == null)
opts.context = true;
if (opts.coerce == null)
opts.coerce = true;
completeMonad(defs);
if (opts.control === "token")
defs = M.addControlByToken(defs);
if (opts.wrap)
defs = M.wrap(defs,opts.wrap);
if (opts.co... | [
"function",
"defaults",
"(",
"defs",
",",
"opts",
")",
"{",
"if",
"(",
"!",
"opts",
")",
"opts",
"=",
"{",
"}",
"if",
"(",
"opts",
".",
"context",
"==",
"null",
")",
"opts",
".",
"context",
"=",
"true",
";",
"if",
"(",
"opts",
".",
"coerce",
"=... | Runs definitions transformations based on specified set of options.
Options:
* wrap - constructor function used for wrapped value,
it should construct objects with inner field
* context - boolean or "run" string for only wrapping run method,
default is true
* coerce - boolean for adding coercions to functions returnin... | [
"Runs",
"definitions",
"transformations",
"based",
"on",
"specified",
"set",
"of",
"options",
"."
] | 6138e74c373998592777b8849ec5a22d6b8edd7d | https://github.com/awto/mfjs-core/blob/6138e74c373998592777b8849ec5a22d6b8edd7d/index.js#L1101-L1120 | train |
awto/mfjs-core | index.js | liftContext | function liftContext(ctx, func) {
if (!ctx.pure) {
throw new Error("no monad's definition is provided");
}
return function() {
var saved;
saved = context;
context = ctx;
try {
return func.apply(null, arguments);
} finally {
context = saved;
}
};
} | javascript | function liftContext(ctx, func) {
if (!ctx.pure) {
throw new Error("no monad's definition is provided");
}
return function() {
var saved;
saved = context;
context = ctx;
try {
return func.apply(null, arguments);
} finally {
context = saved;
}
};
} | [
"function",
"liftContext",
"(",
"ctx",
",",
"func",
")",
"{",
"if",
"(",
"!",
"ctx",
".",
"pure",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"no monad's definition is provided\"",
")",
";",
"}",
"return",
"function",
"(",
")",
"{",
"var",
"saved",
";",
... | Turns a function into a function initializing global context to `ctx`
and reverting it to the old value on exit.
@function M.liftContext
@param {MonadDict} ctx
@param {Function} func
@return {Function} | [
"Turns",
"a",
"function",
"into",
"a",
"function",
"initializing",
"global",
"context",
"to",
"ctx",
"and",
"reverting",
"it",
"to",
"the",
"old",
"value",
"on",
"exit",
"."
] | 6138e74c373998592777b8849ec5a22d6b8edd7d | https://github.com/awto/mfjs-core/blob/6138e74c373998592777b8849ec5a22d6b8edd7d/index.js#L1173-L1187 | train |
awto/mfjs-core | index.js | liftContextG | function liftContextG(ctx, gen) {
return liftContext(ctx, function() {
return liftContextIterator(ctx, gen.apply(null, arguments));
});
} | javascript | function liftContextG(ctx, gen) {
return liftContext(ctx, function() {
return liftContextIterator(ctx, gen.apply(null, arguments));
});
} | [
"function",
"liftContextG",
"(",
"ctx",
",",
"gen",
")",
"{",
"return",
"liftContext",
"(",
"ctx",
",",
"function",
"(",
")",
"{",
"return",
"liftContextIterator",
"(",
"ctx",
",",
"gen",
".",
"apply",
"(",
"null",
",",
"arguments",
")",
")",
";",
"}",... | Same as `liftContext` but lifts generator function.
@function M.liftContextG
@param {MonadDict} ctx
@param {GeneratorFunction} gen
@return {Function} | [
"Same",
"as",
"liftContext",
"but",
"lifts",
"generator",
"function",
"."
] | 6138e74c373998592777b8849ec5a22d6b8edd7d | https://github.com/awto/mfjs-core/blob/6138e74c373998592777b8849ec5a22d6b8edd7d/index.js#L1197-L1201 | train |
jonschlinkert/expand-config | index.js | Config | function Config(options) {
if (!(this instanceof Config)) {
return new Config(options);
}
utils.is(this, 'config');
use(this);
define(this, 'count', 0);
this.options = options || {};
this.targets = {};
this.tasks = {};
if (utils.isConfig(options)) {
this.options = {};
this.expand(option... | javascript | function Config(options) {
if (!(this instanceof Config)) {
return new Config(options);
}
utils.is(this, 'config');
use(this);
define(this, 'count', 0);
this.options = options || {};
this.targets = {};
this.tasks = {};
if (utils.isConfig(options)) {
this.options = {};
this.expand(option... | [
"function",
"Config",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Config",
")",
")",
"{",
"return",
"new",
"Config",
"(",
"options",
")",
";",
"}",
"utils",
".",
"is",
"(",
"this",
",",
"'config'",
")",
";",
"use",
"(",
... | Expand a declarative configuration with tasks and targets.
Create a new Config with the given `options`
```js
var config = new Config();
// example usage
config.expand({
jshint: {
src: ['*.js', 'lib/*.js']
}
});
```
@param {Object} `options`
@api public | [
"Expand",
"a",
"declarative",
"configuration",
"with",
"tasks",
"and",
"targets",
".",
"Create",
"a",
"new",
"Config",
"with",
"the",
"given",
"options"
] | 338fc219577d11318a08fe732410ac57a2d07b74 | https://github.com/jonschlinkert/expand-config/blob/338fc219577d11318a08fe732410ac57a2d07b74/index.js#L27-L45 | train |
cli-kit/cli-mid-version | index.js | handler | function handler(req, next) {
var conf = this.configure();
var pkg = this.package();
var copyright = conf.copyright || (pkg ? pkg.copyright : null);
var opts = [this._version];
var msg = this._name + ' %s';
// NOTE: allows deferring to this handler from a custom handler
if(arguments.length > 1 && typeof(... | javascript | function handler(req, next) {
var conf = this.configure();
var pkg = this.package();
var copyright = conf.copyright || (pkg ? pkg.copyright : null);
var opts = [this._version];
var msg = this._name + ' %s';
// NOTE: allows deferring to this handler from a custom handler
if(arguments.length > 1 && typeof(... | [
"function",
"handler",
"(",
"req",
",",
"next",
")",
"{",
"var",
"conf",
"=",
"this",
".",
"configure",
"(",
")",
";",
"var",
"pkg",
"=",
"this",
".",
"package",
"(",
")",
";",
"var",
"copyright",
"=",
"conf",
".",
"copyright",
"||",
"(",
"pkg",
... | Default program version action.
@param alive Do not exit the process.
@param ... Message replacement parameters. | [
"Default",
"program",
"version",
"action",
"."
] | 4040eac6ba52af4c4cf540b9cc0c0f6bbdc1d579 | https://github.com/cli-kit/cli-mid-version/blob/4040eac6ba52af4c4cf540b9cc0c0f6bbdc1d579/index.js#L10-L35 | train |
slikts/delta-ticker | index.js | _start | function _start() {
var now = Date.now();
var config = this._config;
var missing = !config ? required : required.filter(function(key) {
return config[key] === undefined;
});
if (missing.length) {
throw TypeError('Missing config properties: ' + missing.join(', '));
}
if (this._... | javascript | function _start() {
var now = Date.now();
var config = this._config;
var missing = !config ? required : required.filter(function(key) {
return config[key] === undefined;
});
if (missing.length) {
throw TypeError('Missing config properties: ' + missing.join(', '));
}
if (this._... | [
"function",
"_start",
"(",
")",
"{",
"var",
"now",
"=",
"Date",
".",
"now",
"(",
")",
";",
"var",
"config",
"=",
"this",
".",
"_config",
";",
"var",
"missing",
"=",
"!",
"config",
"?",
"required",
":",
"required",
".",
"filter",
"(",
"function",
"(... | Used with config.limit
Start the ticker, setting the timeout for the first tick.
@returns {Ticker} | [
"Used",
"with",
"config",
".",
"limit",
"Start",
"the",
"ticker",
"setting",
"the",
"timeout",
"for",
"the",
"first",
"tick",
"."
] | 8cab89af6fa175df5dabce17bf654d163578ce2e | https://github.com/slikts/delta-ticker/blob/8cab89af6fa175df5dabce17bf654d163578ce2e/index.js#L51-L73 | train |
slikts/delta-ticker | index.js | _stop | function _stop() {
if (!this._started) {
throw Error('Ticker not started');
}
clearTimeout(this._timeout);
delete this._started;
delete this._before;
delete this._count;
if (this._config.stop) {
this._config.stop();
}
return this;
} | javascript | function _stop() {
if (!this._started) {
throw Error('Ticker not started');
}
clearTimeout(this._timeout);
delete this._started;
delete this._before;
delete this._count;
if (this._config.stop) {
this._config.stop();
}
return this;
} | [
"function",
"_stop",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_started",
")",
"{",
"throw",
"Error",
"(",
"'Ticker not started'",
")",
";",
"}",
"clearTimeout",
"(",
"this",
".",
"_timeout",
")",
";",
"delete",
"this",
".",
"_started",
";",
"delete... | Stop the ticker, clearing any currently set timeouts.
@returns {Ticker} | [
"Stop",
"the",
"ticker",
"clearing",
"any",
"currently",
"set",
"timeouts",
"."
] | 8cab89af6fa175df5dabce17bf654d163578ce2e | https://github.com/slikts/delta-ticker/blob/8cab89af6fa175df5dabce17bf654d163578ce2e/index.js#L79-L93 | train |
slikts/delta-ticker | index.js | _use | function _use(config) {
var _config = this._config;
Object.keys(config).forEach(function(key) {
_config[key] = config[key];
});
return this;
} | javascript | function _use(config) {
var _config = this._config;
Object.keys(config).forEach(function(key) {
_config[key] = config[key];
});
return this;
} | [
"function",
"_use",
"(",
"config",
")",
"{",
"var",
"_config",
"=",
"this",
".",
"_config",
";",
"Object",
".",
"keys",
"(",
"config",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"_config",
"[",
"key",
"]",
"=",
"config",
"[",
"key"... | Extend the ticker's config.
@param {{ limit: Number, async: Boolean, task: Function, stop: Function }} config
@returns {Ticker} | [
"Extend",
"the",
"ticker",
"s",
"config",
"."
] | 8cab89af6fa175df5dabce17bf654d163578ce2e | https://github.com/slikts/delta-ticker/blob/8cab89af6fa175df5dabce17bf654d163578ce2e/index.js#L99-L107 | train |
slikts/delta-ticker | index.js | _tick | function _tick() {
var config = this._config;
var now = Date.now();
var dt = now - this._before;
if (!this._started) {
// The ticker has been stopped
return;
}
if (config.async) {
config.task(this._tock, dt);
} else {
config.task(dt);
this._tock();
}
} | javascript | function _tick() {
var config = this._config;
var now = Date.now();
var dt = now - this._before;
if (!this._started) {
// The ticker has been stopped
return;
}
if (config.async) {
config.task(this._tock, dt);
} else {
config.task(dt);
this._tock();
}
} | [
"function",
"_tick",
"(",
")",
"{",
"var",
"config",
"=",
"this",
".",
"_config",
";",
"var",
"now",
"=",
"Date",
".",
"now",
"(",
")",
";",
"var",
"dt",
"=",
"now",
"-",
"this",
".",
"_before",
";",
"if",
"(",
"!",
"this",
".",
"_started",
")"... | The first part of an iteration that determines how to call the task | [
"The",
"first",
"part",
"of",
"an",
"iteration",
"that",
"determines",
"how",
"to",
"call",
"the",
"task"
] | 8cab89af6fa175df5dabce17bf654d163578ce2e | https://github.com/slikts/delta-ticker/blob/8cab89af6fa175df5dabce17bf654d163578ce2e/index.js#L109-L125 | train |
slikts/delta-ticker | index.js | _tock | function _tock() {
var config = this._config;
var now = Date.now();
var taskTime = now - this._started; // The time it took to finish the last task
var delay = Math.max(0, config.delay - (taskTime)); // Delay until the next task is run
if (config.limit) {
this._count += 1;
if (this._co... | javascript | function _tock() {
var config = this._config;
var now = Date.now();
var taskTime = now - this._started; // The time it took to finish the last task
var delay = Math.max(0, config.delay - (taskTime)); // Delay until the next task is run
if (config.limit) {
this._count += 1;
if (this._co... | [
"function",
"_tock",
"(",
")",
"{",
"var",
"config",
"=",
"this",
".",
"_config",
";",
"var",
"now",
"=",
"Date",
".",
"now",
"(",
")",
";",
"var",
"taskTime",
"=",
"now",
"-",
"this",
".",
"_started",
";",
"// The time it took to finish the last task",
... | The second part of an iteration that is called after the task is done | [
"The",
"second",
"part",
"of",
"an",
"iteration",
"that",
"is",
"called",
"after",
"the",
"task",
"is",
"done"
] | 8cab89af6fa175df5dabce17bf654d163578ce2e | https://github.com/slikts/delta-ticker/blob/8cab89af6fa175df5dabce17bf654d163578ce2e/index.js#L128-L148 | train |
tolokoban/ToloFrameWork | ker/mod/interact.js | indexOfDeepestElement | function indexOfDeepestElement (elements) {
var dropzone,
deepestZone = elements[0],
index = deepestZone? 0: -1,
parent,
deepestZoneParents = [],
dropzoneParents = [],
child,
i,
n;
for (i = 1; i < elements.l... | javascript | function indexOfDeepestElement (elements) {
var dropzone,
deepestZone = elements[0],
index = deepestZone? 0: -1,
parent,
deepestZoneParents = [],
dropzoneParents = [],
child,
i,
n;
for (i = 1; i < elements.l... | [
"function",
"indexOfDeepestElement",
"(",
"elements",
")",
"{",
"var",
"dropzone",
",",
"deepestZone",
"=",
"elements",
"[",
"0",
"]",
",",
"index",
"=",
"deepestZone",
"?",
"0",
":",
"-",
"1",
",",
"parent",
",",
"deepestZoneParents",
"=",
"[",
"]",
","... | Test for the element that's "above" all other qualifiers | [
"Test",
"for",
"the",
"element",
"that",
"s",
"above",
"all",
"other",
"qualifiers"
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/interact.js#L1064-L1164 | train |
tolokoban/ToloFrameWork | ker/mod/interact.js | function (pointer, event, eventTarget, curEventTarget, matches, matchElements) {
var target = this.target;
if (!this.prepared.name && this.mouse) {
var action;
// update pointer coords for defaultActionChecker to use
this.setEventXY(this.curCoor... | javascript | function (pointer, event, eventTarget, curEventTarget, matches, matchElements) {
var target = this.target;
if (!this.prepared.name && this.mouse) {
var action;
// update pointer coords for defaultActionChecker to use
this.setEventXY(this.curCoor... | [
"function",
"(",
"pointer",
",",
"event",
",",
"eventTarget",
",",
"curEventTarget",
",",
"matches",
",",
"matchElements",
")",
"{",
"var",
"target",
"=",
"this",
".",
"target",
";",
"if",
"(",
"!",
"this",
".",
"prepared",
".",
"name",
"&&",
"this",
"... | Check what action would be performed on pointerMove target if a mouse button were pressed and change the cursor accordingly | [
"Check",
"what",
"action",
"would",
"be",
"performed",
"on",
"pointerMove",
"target",
"if",
"a",
"mouse",
"button",
"were",
"pressed",
"and",
"change",
"the",
"cursor",
"accordingly"
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/interact.js#L1402-L1431 | train | |
tolokoban/ToloFrameWork | ker/mod/interact.js | function (dragElement) {
// get dropzones and their elements that could receive the draggable
var possibleDrops = this.collectDrops(dragElement, true);
this.activeDrops.dropzones = possibleDrops.dropzones;
this.activeDrops.elements = possibleDrops.elements;
... | javascript | function (dragElement) {
// get dropzones and their elements that could receive the draggable
var possibleDrops = this.collectDrops(dragElement, true);
this.activeDrops.dropzones = possibleDrops.dropzones;
this.activeDrops.elements = possibleDrops.elements;
... | [
"function",
"(",
"dragElement",
")",
"{",
"// get dropzones and their elements that could receive the draggable",
"var",
"possibleDrops",
"=",
"this",
".",
"collectDrops",
"(",
"dragElement",
",",
"true",
")",
";",
"this",
".",
"activeDrops",
".",
"dropzones",
"=",
"p... | Collect a new set of possible drops and save them in activeDrops. setActiveDrops should always be called when a drag has just started or a drag event happens while dynamicDrop is true | [
"Collect",
"a",
"new",
"set",
"of",
"possible",
"drops",
"and",
"save",
"them",
"in",
"activeDrops",
".",
"setActiveDrops",
"should",
"always",
"be",
"called",
"when",
"a",
"drag",
"has",
"just",
"started",
"or",
"a",
"drag",
"event",
"happens",
"while",
"... | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/interact.js#L2471-L2482 | train | |
tolokoban/ToloFrameWork | ker/mod/interact.js | validateAction | function validateAction (action, interactable) {
if (!isObject(action)) { return null; }
var actionName = action.name,
options = interactable.options;
if (( (actionName === 'resize' && options.resize.enabled )
|| (actionName === 'drag' && options.drag.enabl... | javascript | function validateAction (action, interactable) {
if (!isObject(action)) { return null; }
var actionName = action.name,
options = interactable.options;
if (( (actionName === 'resize' && options.resize.enabled )
|| (actionName === 'drag' && options.drag.enabl... | [
"function",
"validateAction",
"(",
"action",
",",
"interactable",
")",
"{",
"if",
"(",
"!",
"isObject",
"(",
"action",
")",
")",
"{",
"return",
"null",
";",
"}",
"var",
"actionName",
"=",
"action",
".",
"name",
",",
"options",
"=",
"interactable",
".",
... | Check if action is enabled globally and the current target supports it If so, return the validated action. Otherwise, return null | [
"Check",
"if",
"action",
"is",
"enabled",
"globally",
"and",
"the",
"current",
"target",
"supports",
"it",
"If",
"so",
"return",
"the",
"validated",
"action",
".",
"Otherwise",
"return",
"null"
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/interact.js#L3753-L3771 | train |
tolokoban/ToloFrameWork | ker/mod/interact.js | delegateListener | function delegateListener (event, useCapture) {
var fakeEvent = {},
delegated = delegatedEvents[event.type],
eventTarget = getActualElement(event.path
? event.path[0]
: event.target),
elemen... | javascript | function delegateListener (event, useCapture) {
var fakeEvent = {},
delegated = delegatedEvents[event.type],
eventTarget = getActualElement(event.path
? event.path[0]
: event.target),
elemen... | [
"function",
"delegateListener",
"(",
"event",
",",
"useCapture",
")",
"{",
"var",
"fakeEvent",
"=",
"{",
"}",
",",
"delegated",
"=",
"delegatedEvents",
"[",
"event",
".",
"type",
"]",
",",
"eventTarget",
"=",
"getActualElement",
"(",
"event",
".",
"path",
... | bound to the interactable context when a DOM event listener is added to a selector interactable | [
"bound",
"to",
"the",
"interactable",
"context",
"when",
"a",
"DOM",
"event",
"listener",
"is",
"added",
"to",
"a",
"selector",
"interactable"
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/interact.js#L3789-L3831 | train |
asavoy/grunt-requirejs-auto-bundles | lib/amd.js | modulePathToId | function modulePathToId(path) {
// We can only transform if there's no plugin used.
if (path.indexOf('!') === -1) {
// If it ends with ".js", chop it off.
var extension = '.js'
if (path.slice(-extension.length) === '.js') {
path = path.slice(0, path.length - extension.length)... | javascript | function modulePathToId(path) {
// We can only transform if there's no plugin used.
if (path.indexOf('!') === -1) {
// If it ends with ".js", chop it off.
var extension = '.js'
if (path.slice(-extension.length) === '.js') {
path = path.slice(0, path.length - extension.length)... | [
"function",
"modulePathToId",
"(",
"path",
")",
"{",
"// We can only transform if there's no plugin used.",
"if",
"(",
"path",
".",
"indexOf",
"(",
"'!'",
")",
"===",
"-",
"1",
")",
"{",
"// If it ends with \".js\", chop it off.",
"var",
"extension",
"=",
"'.js'",
"... | Convert a module path into a module ID. | [
"Convert",
"a",
"module",
"path",
"into",
"a",
"module",
"ID",
"."
] | c0f587c9720943dd32098203d2c71ab1387f1700 | https://github.com/asavoy/grunt-requirejs-auto-bundles/blob/c0f587c9720943dd32098203d2c71ab1387f1700/lib/amd.js#L9-L19 | train |
asavoy/grunt-requirejs-auto-bundles | lib/amd.js | moduleSize | function moduleSize(id, paths) {
var path = id;
var extension = '.js';
// Use `paths:` to resolve an alias.
if (paths[id]) {
path = paths[id];
}
// Does the dependency reference a plugin?
if (path.indexOf('!') !== -1) {
// Split into plugin and path.
var pathParts = p... | javascript | function moduleSize(id, paths) {
var path = id;
var extension = '.js';
// Use `paths:` to resolve an alias.
if (paths[id]) {
path = paths[id];
}
// Does the dependency reference a plugin?
if (path.indexOf('!') !== -1) {
// Split into plugin and path.
var pathParts = p... | [
"function",
"moduleSize",
"(",
"id",
",",
"paths",
")",
"{",
"var",
"path",
"=",
"id",
";",
"var",
"extension",
"=",
"'.js'",
";",
"// Use `paths:` to resolve an alias.",
"if",
"(",
"paths",
"[",
"id",
"]",
")",
"{",
"path",
"=",
"paths",
"[",
"id",
"]... | Returns the size of a module given its ID.
At best this can be considered an estimate because it will return the
size before compression, and doesn't take into consideration the effect
of plugins.
If the module cannot be resolved to a file, returns null. | [
"Returns",
"the",
"size",
"of",
"a",
"module",
"given",
"its",
"ID",
".",
"At",
"best",
"this",
"can",
"be",
"considered",
"an",
"estimate",
"because",
"it",
"will",
"return",
"the",
"size",
"before",
"compression",
"and",
"doesn",
"t",
"take",
"into",
"... | c0f587c9720943dd32098203d2c71ab1387f1700 | https://github.com/asavoy/grunt-requirejs-auto-bundles/blob/c0f587c9720943dd32098203d2c71ab1387f1700/lib/amd.js#L42-L77 | train |
jasonsites/proxy-es-aws | src/http/app.js | createHandler | function createHandler(options) {
/**
* Client request handler
* Data from the incoming request (plus options) is forwarded to the AWS module
*/
return async (ctx) => {
const { credentials, endpoint, region } = options
const { rawBody: body, header: headers, method, url: path } = ctx.request
c... | javascript | function createHandler(options) {
/**
* Client request handler
* Data from the incoming request (plus options) is forwarded to the AWS module
*/
return async (ctx) => {
const { credentials, endpoint, region } = options
const { rawBody: body, header: headers, method, url: path } = ctx.request
c... | [
"function",
"createHandler",
"(",
"options",
")",
"{",
"/**\n * Client request handler\n * Data from the incoming request (plus options) is forwarded to the AWS module\n */",
"return",
"async",
"(",
"ctx",
")",
"=>",
"{",
"const",
"{",
"credentials",
",",
"endpoint",
",",... | Creates request handler middleware
@param {Object} options.credentials - aws credentials object
@param {Object} options.endpoint - aws elasticsearch endpoint
@param {Object} options.region - aws region | [
"Creates",
"request",
"handler",
"middleware"
] | b2625106d877fea76f74b0b88ed8568a8ff61612 | https://github.com/jasonsites/proxy-es-aws/blob/b2625106d877fea76f74b0b88ed8568a8ff61612/src/http/app.js#L54-L74 | train |
jasonsites/proxy-es-aws | src/http/app.js | getInitOptions | async function getInitOptions(args) {
const { debug, endpoint, host, port, profile, region } = args
const options = { debug, host, port, profile, region }
options.endpoint = getAWSEndpoint({ endpoint })
options.credentials = await getAWSCredentials()
return options
} | javascript | async function getInitOptions(args) {
const { debug, endpoint, host, port, profile, region } = args
const options = { debug, host, port, profile, region }
options.endpoint = getAWSEndpoint({ endpoint })
options.credentials = await getAWSCredentials()
return options
} | [
"async",
"function",
"getInitOptions",
"(",
"args",
")",
"{",
"const",
"{",
"debug",
",",
"endpoint",
",",
"host",
",",
"port",
",",
"profile",
",",
"region",
"}",
"=",
"args",
"const",
"options",
"=",
"{",
"debug",
",",
"host",
",",
"port",
",",
"pr... | Composes server initialization options from CLI arguments
@param {Boolean} args.debug - debug flag
@param {String} args.endpoint - aws elasticsearch endpoint
@param {String} args.host - proxy host
@param {Number} args.port - proxy port
@param {String} args.profile - aws credentials profile
@param {Strin... | [
"Composes",
"server",
"initialization",
"options",
"from",
"CLI",
"arguments"
] | b2625106d877fea76f74b0b88ed8568a8ff61612 | https://github.com/jasonsites/proxy-es-aws/blob/b2625106d877fea76f74b0b88ed8568a8ff61612/src/http/app.js#L86-L92 | train |
jasonsites/proxy-es-aws | src/http/app.js | registerListeners | function registerListeners() {
const exit = function exit(signal) {
console.log(chalk.bgBlack.yellow(`Received ${signal} => Exiting`))
process.exit()
}
const SIGABRT = 'SIGABRT'
const SIGHUP = 'SIGHUP'
const SIGINT = 'SIGINT'
const SIGQUIT = 'SIGQUIT'
const SIGTERM = 'SIGTERM'
process.on(SIGABR... | javascript | function registerListeners() {
const exit = function exit(signal) {
console.log(chalk.bgBlack.yellow(`Received ${signal} => Exiting`))
process.exit()
}
const SIGABRT = 'SIGABRT'
const SIGHUP = 'SIGHUP'
const SIGINT = 'SIGINT'
const SIGQUIT = 'SIGQUIT'
const SIGTERM = 'SIGTERM'
process.on(SIGABR... | [
"function",
"registerListeners",
"(",
")",
"{",
"const",
"exit",
"=",
"function",
"exit",
"(",
"signal",
")",
"{",
"console",
".",
"log",
"(",
"chalk",
".",
"bgBlack",
".",
"yellow",
"(",
"`",
"${",
"signal",
"}",
"`",
")",
")",
"process",
".",
"exit... | Register process signal listeners
@return {undefined} | [
"Register",
"process",
"signal",
"listeners"
] | b2625106d877fea76f74b0b88ed8568a8ff61612 | https://github.com/jasonsites/proxy-es-aws/blob/b2625106d877fea76f74b0b88ed8568a8ff61612/src/http/app.js#L98-L114 | train |
jasonsites/proxy-es-aws | src/http/app.js | stripProxyResHeaders | function stripProxyResHeaders(res) {
return Object.entries(res.headers).reduce((memo, header) => {
const [key, val] = header
const invalid = [undefined, 'connection', 'content-encoding']
if (invalid.indexOf(key) === -1) {
memo[key] = val // eslint-disable-line
}
return memo
}, {})
} | javascript | function stripProxyResHeaders(res) {
return Object.entries(res.headers).reduce((memo, header) => {
const [key, val] = header
const invalid = [undefined, 'connection', 'content-encoding']
if (invalid.indexOf(key) === -1) {
memo[key] = val // eslint-disable-line
}
return memo
}, {})
} | [
"function",
"stripProxyResHeaders",
"(",
"res",
")",
"{",
"return",
"Object",
".",
"entries",
"(",
"res",
".",
"headers",
")",
".",
"reduce",
"(",
"(",
"memo",
",",
"header",
")",
"=>",
"{",
"const",
"[",
"key",
",",
"val",
"]",
"=",
"header",
"const... | Strip connection control and transport encoding headers from the proxy response
@param {Object} res - proxy response
@return {Object} | [
"Strip",
"connection",
"control",
"and",
"transport",
"encoding",
"headers",
"from",
"the",
"proxy",
"response"
] | b2625106d877fea76f74b0b88ed8568a8ff61612 | https://github.com/jasonsites/proxy-es-aws/blob/b2625106d877fea76f74b0b88ed8568a8ff61612/src/http/app.js#L121-L130 | train |
goddyZhao/sf-transfer | lib/sf.js | transfer | function transfer(xmlFiles, output, dir, needAppend, _callback){
/**
* If needAppend is true, output must be a file but not a directory
*/
Step(
function(){
if(typeof output === 'undefined'){
output = path.dirname(xmlFiles[0]);
}
output = output.indexOf(path.sep) === 0 ? output :... | javascript | function transfer(xmlFiles, output, dir, needAppend, _callback){
/**
* If needAppend is true, output must be a file but not a directory
*/
Step(
function(){
if(typeof output === 'undefined'){
output = path.dirname(xmlFiles[0]);
}
output = output.indexOf(path.sep) === 0 ? output :... | [
"function",
"transfer",
"(",
"xmlFiles",
",",
"output",
",",
"dir",
",",
"needAppend",
",",
"_callback",
")",
"{",
"/**\n * If needAppend is true, output must be a file but not a directory\n */",
"Step",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"typeof",
"output... | Transfer sf rules in inputs to nproxy rule file
@param {Array} xmlFiles xml files
@param {String} output output dir or file when append is true
@param {String} dir dir in the rule files
@param {Boolean} needAppend if true, the transfered rule will be appended | [
"Transfer",
"sf",
"rules",
"in",
"inputs",
"to",
"nproxy",
"rule",
"file"
] | 23d5ebf109f3673b89e2b777e956d6e3eecbdff6 | https://github.com/goddyZhao/sf-transfer/blob/23d5ebf109f3673b89e2b777e956d6e3eecbdff6/lib/sf.js#L19-L104 | train |
goddyZhao/sf-transfer | lib/sf.js | transferSingleFile | function transferSingleFile(sfXML, dir, callback){
var xmlParser;
var groups;
var responders = [];
var fileList = [];
var entry;
var responder;
var stat;
if(typeof sfXML === 'undefined'){
throw new Error('No input file specified');
}
if(!/\.xml$/.test(sfXML)){
throw new Error('Input file ... | javascript | function transferSingleFile(sfXML, dir, callback){
var xmlParser;
var groups;
var responders = [];
var fileList = [];
var entry;
var responder;
var stat;
if(typeof sfXML === 'undefined'){
throw new Error('No input file specified');
}
if(!/\.xml$/.test(sfXML)){
throw new Error('Input file ... | [
"function",
"transferSingleFile",
"(",
"sfXML",
",",
"dir",
",",
"callback",
")",
"{",
"var",
"xmlParser",
";",
"var",
"groups",
";",
"var",
"responders",
"=",
"[",
"]",
";",
"var",
"fileList",
"=",
"[",
"]",
";",
"var",
"entry",
";",
"var",
"responder... | Transfer the input xml to output js for nproxy
@param {String} sfXML file path of sf combo configuration xml file
@param {String} dir dir in the rule file | [
"Transfer",
"the",
"input",
"xml",
"to",
"output",
"js",
"for",
"nproxy"
] | 23d5ebf109f3673b89e2b777e956d6e3eecbdff6 | https://github.com/goddyZhao/sf-transfer/blob/23d5ebf109f3673b89e2b777e956d6e3eecbdff6/lib/sf.js#L112-L192 | train |
goddyZhao/sf-transfer | lib/sf.js | _getRuleAsString | function _getRuleAsString(responders, callback){
var respondersArr = [];
var respondersLen = responders.length;
var srcLen;
var fileStr;
responders.forEach(function(entry, i){
respondersArr.push(TAP + '{');
respondersArr.push(TAP + TAP + 'pattern: \'' + entry.pattern + '\',' + entry.comment);
r... | javascript | function _getRuleAsString(responders, callback){
var respondersArr = [];
var respondersLen = responders.length;
var srcLen;
var fileStr;
responders.forEach(function(entry, i){
respondersArr.push(TAP + '{');
respondersArr.push(TAP + TAP + 'pattern: \'' + entry.pattern + '\',' + entry.comment);
r... | [
"function",
"_getRuleAsString",
"(",
"responders",
",",
"callback",
")",
"{",
"var",
"respondersArr",
"=",
"[",
"]",
";",
"var",
"respondersLen",
"=",
"responders",
".",
"length",
";",
"var",
"srcLen",
";",
"var",
"fileStr",
";",
"responders",
".",
"forEach"... | Get the transferd rules as a string
@param {Object} responders the object of responder
@param {Function} callback | [
"Get",
"the",
"transferd",
"rules",
"as",
"a",
"string"
] | 23d5ebf109f3673b89e2b777e956d6e3eecbdff6 | https://github.com/goddyZhao/sf-transfer/blob/23d5ebf109f3673b89e2b777e956d6e3eecbdff6/lib/sf.js#L200-L239 | train |
goddyZhao/sf-transfer | lib/sf.js | _append | function _append(target, rules, isTargetEmpty){
var concatedRules = [];
var rulesContent;
var l = rules.length;
rules.forEach(function(rule, i){
if(i < l - 1){
concatedRules.push(rule + ',');
}else{
concatedRules.push(rule + '/*{{more}}*/');
}
});
if(isTargetEmpty){
rulesContent... | javascript | function _append(target, rules, isTargetEmpty){
var concatedRules = [];
var rulesContent;
var l = rules.length;
rules.forEach(function(rule, i){
if(i < l - 1){
concatedRules.push(rule + ',');
}else{
concatedRules.push(rule + '/*{{more}}*/');
}
});
if(isTargetEmpty){
rulesContent... | [
"function",
"_append",
"(",
"target",
",",
"rules",
",",
"isTargetEmpty",
")",
"{",
"var",
"concatedRules",
"=",
"[",
"]",
";",
"var",
"rulesContent",
";",
"var",
"l",
"=",
"rules",
".",
"length",
";",
"rules",
".",
"forEach",
"(",
"function",
"(",
"ru... | Append rules to target one by one
@param {String} target
@param {Årray} rules
@param {Boolean} isTargetEmpty whether the target is empty
@api private | [
"Append",
"rules",
"to",
"target",
"one",
"by",
"one"
] | 23d5ebf109f3673b89e2b777e956d6e3eecbdff6 | https://github.com/goddyZhao/sf-transfer/blob/23d5ebf109f3673b89e2b777e956d6e3eecbdff6/lib/sf.js#L251-L270 | train |
vesln/copycat | index.js | end | function end() {
var group = stack.pop();
if (!requests) return;
var data = JSON.stringify(requests);
var dest = path.join(options.fixtures, group + '.json');
fs.writeFileSync(dest, data, 'utf8');
requests = null;
} | javascript | function end() {
var group = stack.pop();
if (!requests) return;
var data = JSON.stringify(requests);
var dest = path.join(options.fixtures, group + '.json');
fs.writeFileSync(dest, data, 'utf8');
requests = null;
} | [
"function",
"end",
"(",
")",
"{",
"var",
"group",
"=",
"stack",
".",
"pop",
"(",
")",
";",
"if",
"(",
"!",
"requests",
")",
"return",
";",
"var",
"data",
"=",
"JSON",
".",
"stringify",
"(",
"requests",
")",
";",
"var",
"dest",
"=",
"path",
".",
... | End and store the last group.
@api public | [
"End",
"and",
"store",
"the",
"last",
"group",
"."
] | a2d7b0172d06afd5d6018fc19990863584767cf8 | https://github.com/vesln/copycat/blob/a2d7b0172d06afd5d6018fc19990863584767cf8/index.js#L61-L68 | train |
vesln/copycat | index.js | recorder | function recorder(opts, fn) {
var group = stack[stack.length - 1];
var response = null;
assert(group, 'please specify copycat group');
recordings = load(group) || [];
recordings.forEach(function(recording) {
if (!deepEqual(recording.opts, opts)) return;
response = recording;
});
if (response) {... | javascript | function recorder(opts, fn) {
var group = stack[stack.length - 1];
var response = null;
assert(group, 'please specify copycat group');
recordings = load(group) || [];
recordings.forEach(function(recording) {
if (!deepEqual(recording.opts, opts)) return;
response = recording;
});
if (response) {... | [
"function",
"recorder",
"(",
"opts",
",",
"fn",
")",
"{",
"var",
"group",
"=",
"stack",
"[",
"stack",
".",
"length",
"-",
"1",
"]",
";",
"var",
"response",
"=",
"null",
";",
"assert",
"(",
"group",
",",
"'please specify copycat group'",
")",
";",
"reco... | Request copycat.
@param {Object} options
@param {Function} fn
@api public | [
"Request",
"copycat",
"."
] | a2d7b0172d06afd5d6018fc19990863584767cf8 | https://github.com/vesln/copycat/blob/a2d7b0172d06afd5d6018fc19990863584767cf8/index.js#L78-L99 | train |
vesln/copycat | index.js | load | function load(group) {
var dest = path.join(options.fixtures, group + '.json');
var ret = null;
var json = null;
try {
json = fs.readFileSync(dest, 'utf8');
ret = JSON.parse(json);
} catch (err) {}
return ret;
} | javascript | function load(group) {
var dest = path.join(options.fixtures, group + '.json');
var ret = null;
var json = null;
try {
json = fs.readFileSync(dest, 'utf8');
ret = JSON.parse(json);
} catch (err) {}
return ret;
} | [
"function",
"load",
"(",
"group",
")",
"{",
"var",
"dest",
"=",
"path",
".",
"join",
"(",
"options",
".",
"fixtures",
",",
"group",
"+",
"'.json'",
")",
";",
"var",
"ret",
"=",
"null",
";",
"var",
"json",
"=",
"null",
";",
"try",
"{",
"json",
"="... | Load stored requests and responses for `group`.
@param {Strin} group
@returns {Array}
@api private | [
"Load",
"stored",
"requests",
"and",
"responses",
"for",
"group",
"."
] | a2d7b0172d06afd5d6018fc19990863584767cf8 | https://github.com/vesln/copycat/blob/a2d7b0172d06afd5d6018fc19990863584767cf8/index.js#L109-L120 | train |
node-neatly/neatly | lib/bootstrap.js | createRunQueue | function createRunQueue(modules) {
return modules
.map((mod) => mod._runQueue)
.reduce((acc, res) => acc.concat(res), []);
} | javascript | function createRunQueue(modules) {
return modules
.map((mod) => mod._runQueue)
.reduce((acc, res) => acc.concat(res), []);
} | [
"function",
"createRunQueue",
"(",
"modules",
")",
"{",
"return",
"modules",
".",
"map",
"(",
"(",
"mod",
")",
"=>",
"mod",
".",
"_runQueue",
")",
".",
"reduce",
"(",
"(",
"acc",
",",
"res",
")",
"=>",
"acc",
".",
"concat",
"(",
"res",
")",
",",
... | Runs recursively through modules and their dependency-modules
and creates an array with handlers to invoke later by app-instance after startup.
@param {Object} module Module instance
@return {Array} Array of run handlers. | [
"Runs",
"recursively",
"through",
"modules",
"and",
"their",
"dependency",
"-",
"modules",
"and",
"creates",
"an",
"array",
"with",
"handlers",
"to",
"invoke",
"later",
"by",
"app",
"-",
"instance",
"after",
"startup",
"."
] | 732d9729bce84013b5516fe7c239dd672d138dd8 | https://github.com/node-neatly/neatly/blob/732d9729bce84013b5516fe7c239dd672d138dd8/lib/bootstrap.js#L107-L113 | train |
rqt/github | build/api/repos/create.js | create | async function create(options) {
const {
org,
name,
description,
homepage,
license_template,
gitignore_template,
auto_init = false,
} = options
const p = org ? `orgs/${org}` : 'user'
const endpoint = `/${p}/repos`
const { body } = await this._request({
data: {
name,
... | javascript | async function create(options) {
const {
org,
name,
description,
homepage,
license_template,
gitignore_template,
auto_init = false,
} = options
const p = org ? `orgs/${org}` : 'user'
const endpoint = `/${p}/repos`
const { body } = await this._request({
data: {
name,
... | [
"async",
"function",
"create",
"(",
"options",
")",
"{",
"const",
"{",
"org",
",",
"name",
",",
"description",
",",
"homepage",
",",
"license_template",
",",
"gitignore_template",
",",
"auto_init",
"=",
"false",
",",
"}",
"=",
"options",
"const",
"p",
"=",... | Create a new repository for the authenticated user.
@param {CreateRepository} options Options to create a repository.
@param {string} [options.org] The organisation on which to create the repository (if not adding to the user account).
@param {string} options.name The name of the repository.
@param {string} [options.de... | [
"Create",
"a",
"new",
"repository",
"for",
"the",
"authenticated",
"user",
"."
] | e6d3cdd8633628cd4aba30e70d8258aa7f6f0c5a | https://github.com/rqt/github/blob/e6d3cdd8633628cd4aba30e70d8258aa7f6f0c5a/build/api/repos/create.js#L12-L38 | train |
kevinoid/promised-read | lib/timeout-error.js | TimeoutError | function TimeoutError(message) {
// Like http://www.ecma-international.org/ecma-262/6.0/#sec-error-message
if (!(this instanceof TimeoutError)) { return new TimeoutError(message); }
Error.captureStackTrace(this, TimeoutError);
if (message !== undefined) {
Object.defineProperty(this, 'message', {
value... | javascript | function TimeoutError(message) {
// Like http://www.ecma-international.org/ecma-262/6.0/#sec-error-message
if (!(this instanceof TimeoutError)) { return new TimeoutError(message); }
Error.captureStackTrace(this, TimeoutError);
if (message !== undefined) {
Object.defineProperty(this, 'message', {
value... | [
"function",
"TimeoutError",
"(",
"message",
")",
"{",
"// Like http://www.ecma-international.org/ecma-262/6.0/#sec-error-message",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"TimeoutError",
")",
")",
"{",
"return",
"new",
"TimeoutError",
"(",
"message",
")",
";",
"}",... | Constructs a TimeoutError.
@class Represents an error caused by a timeout expiring.
@constructor
@param {string=} message Human-readable description of the error. | [
"Constructs",
"a",
"TimeoutError",
"."
] | c6adf477f4a64d5142363d84f7f83f5f07b8f682 | https://github.com/kevinoid/promised-read/blob/c6adf477f4a64d5142363d84f7f83f5f07b8f682/lib/timeout-error.js#L16-L27 | train |
mdasberg/grunt-code-quality-report | tasks/code_quality_report.js | parseCoverageResults | function parseCoverageResults(src) {
var collector = new istanbul.Collector();
var utils = istanbul.utils;
var results = [];
grunt.file.expand({filter: 'isFile'}, src).forEach(function (file) {
var browser = path.dirname(file).substring(path.dirname(file)... | javascript | function parseCoverageResults(src) {
var collector = new istanbul.Collector();
var utils = istanbul.utils;
var results = [];
grunt.file.expand({filter: 'isFile'}, src).forEach(function (file) {
var browser = path.dirname(file).substring(path.dirname(file)... | [
"function",
"parseCoverageResults",
"(",
"src",
")",
"{",
"var",
"collector",
"=",
"new",
"istanbul",
".",
"Collector",
"(",
")",
";",
"var",
"utils",
"=",
"istanbul",
".",
"utils",
";",
"var",
"results",
"=",
"[",
"]",
";",
"grunt",
".",
"file",
".",
... | Parse the coverage results
@param coverage The coverage location.
@returns {{coverage: {}}} | [
"Parse",
"the",
"coverage",
"results"
] | 065f6e9356b0bbcb8d366e8ae9cbddbd623de872 | https://github.com/mdasberg/grunt-code-quality-report/blob/065f6e9356b0bbcb8d366e8ae9cbddbd623de872/tasks/code_quality_report.js#L150-L169 | train |
mdasberg/grunt-code-quality-report | tasks/code_quality_report.js | parseJshintResults | function parseJshintResults(fileName, showDetails) {
var result = {};
if (grunt.file.exists(fileName)) {
var content = grunt.file.read(fileName);
xml2js.parseString(content, {}, function (err, res) {
var consoleStatements = content.match(/(cons... | javascript | function parseJshintResults(fileName, showDetails) {
var result = {};
if (grunt.file.exists(fileName)) {
var content = grunt.file.read(fileName);
xml2js.parseString(content, {}, function (err, res) {
var consoleStatements = content.match(/(cons... | [
"function",
"parseJshintResults",
"(",
"fileName",
",",
"showDetails",
")",
"{",
"var",
"result",
"=",
"{",
"}",
";",
"if",
"(",
"grunt",
".",
"file",
".",
"exists",
"(",
"fileName",
")",
")",
"{",
"var",
"content",
"=",
"grunt",
".",
"file",
".",
"r... | Parse the jshint results.
@param fileName The filename.
@returns {{junit: {}}} | [
"Parse",
"the",
"jshint",
"results",
"."
] | 065f6e9356b0bbcb8d366e8ae9cbddbd623de872 | https://github.com/mdasberg/grunt-code-quality-report/blob/065f6e9356b0bbcb8d366e8ae9cbddbd623de872/tasks/code_quality_report.js#L176-L205 | train |
mariusc23/express-query-date | lib/parse.js | parse | function parse(obj, options) {
var result = {},
key,
value,
momentValue;
for (key in obj) {
if (obj.hasOwnProperty(key)) {
value = obj[key];
if (typeof value === 'string' || typeof value === 'number') {
momentValue = moment.call(null, value, options.formats, options.stric... | javascript | function parse(obj, options) {
var result = {},
key,
value,
momentValue;
for (key in obj) {
if (obj.hasOwnProperty(key)) {
value = obj[key];
if (typeof value === 'string' || typeof value === 'number') {
momentValue = moment.call(null, value, options.formats, options.stric... | [
"function",
"parse",
"(",
"obj",
",",
"options",
")",
"{",
"var",
"result",
"=",
"{",
"}",
",",
"key",
",",
"value",
",",
"momentValue",
";",
"for",
"(",
"key",
"in",
"obj",
")",
"{",
"if",
"(",
"obj",
".",
"hasOwnProperty",
"(",
"key",
")",
")",... | Attempts to recursively convert object properties to dates.
@param {Object} obj - Object to iterate over.
@param {Object} options - Options.
@param {Array} options.formats - Array of formats moment should accept.
@param {Boolean} options.strict - Whether moment should parse in s... | [
"Attempts",
"to",
"recursively",
"convert",
"object",
"properties",
"to",
"dates",
"."
] | 7aae8448342f13130a3b52807638c34eef882825 | https://github.com/mariusc23/express-query-date/blob/7aae8448342f13130a3b52807638c34eef882825/lib/parse.js#L13-L43 | train |
0x333333/wiki-infobox-parser-core | index.js | main | function main(content, callback) {
parser(content, function(error, result) {
if (error) {
callback(error);
} else {
callback(null, result);
}
});
} | javascript | function main(content, callback) {
parser(content, function(error, result) {
if (error) {
callback(error);
} else {
callback(null, result);
}
});
} | [
"function",
"main",
"(",
"content",
",",
"callback",
")",
"{",
"parser",
"(",
"content",
",",
"function",
"(",
"error",
",",
"result",
")",
"{",
"if",
"(",
"error",
")",
"{",
"callback",
"(",
"error",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"n... | Wiki Infobox parser main function
@method main
@param {string} content wiki text to parse
@param {function} callback callback function | [
"Wiki",
"Infobox",
"parser",
"main",
"function"
] | 74fcd4387393b80940945c05f76f2ce8fe1be769 | https://github.com/0x333333/wiki-infobox-parser-core/blob/74fcd4387393b80940945c05f76f2ce8fe1be769/index.js#L9-L17 | train |
byron-dupreez/aws-stream-consumer-core | persisting.js | toBatchStateItem | function toBatchStateItem(batch, context) {
const states = batch.states;
// const messages = batch.allMessages();
const messages = batch.messages;
const rejectedMessages = batch.rejectedMessages;
const unusableRecords = batch.unusableRecords;
// Resolve the messages' states to be saved (if any)
const mes... | javascript | function toBatchStateItem(batch, context) {
const states = batch.states;
// const messages = batch.allMessages();
const messages = batch.messages;
const rejectedMessages = batch.rejectedMessages;
const unusableRecords = batch.unusableRecords;
// Resolve the messages' states to be saved (if any)
const mes... | [
"function",
"toBatchStateItem",
"(",
"batch",
",",
"context",
")",
"{",
"const",
"states",
"=",
"batch",
".",
"states",
";",
"// const messages = batch.allMessages();",
"const",
"messages",
"=",
"batch",
".",
"messages",
";",
"const",
"rejectedMessages",
"=",
"bat... | Converts the given batch into a stream consumer batch state item to be subsequently persisted to DynamoDB.
@param {Batch} batch - the batch to be converted into a batch state item
@param {StreamProcessing} context - the context to use
@returns {BatchStateItem} the stream consumer batch state item | [
"Converts",
"the",
"given",
"batch",
"into",
"a",
"stream",
"consumer",
"batch",
"state",
"item",
"to",
"be",
"subsequently",
"persisted",
"to",
"DynamoDB",
"."
] | 9b256084297f80d373bcf483aaf68a9da176b3d7 | https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/persisting.js#L225-L254 | train |
byron-dupreez/aws-stream-consumer-core | persisting.js | toStorableMessageState | function toStorableMessageState(messageState, message, context) {
if (!messageState) {
context.warn(`Skipping save of state for message, since it has no state - message (${JSON.stringify(message)})`);
return undefined;
}
// Convert the message's state into a safely storable object to get a clean, simplif... | javascript | function toStorableMessageState(messageState, message, context) {
if (!messageState) {
context.warn(`Skipping save of state for message, since it has no state - message (${JSON.stringify(message)})`);
return undefined;
}
// Convert the message's state into a safely storable object to get a clean, simplif... | [
"function",
"toStorableMessageState",
"(",
"messageState",
",",
"message",
",",
"context",
")",
"{",
"if",
"(",
"!",
"messageState",
")",
"{",
"context",
".",
"warn",
"(",
"`",
"${",
"JSON",
".",
"stringify",
"(",
"message",
")",
"}",
"`",
")",
";",
"r... | Converts the given message state into a storable version of itself.
@param {MessageState} messageState
@param {Message} message
@param {StreamProcessing} context
@return {MessageStateItem|undefined} | [
"Converts",
"the",
"given",
"message",
"state",
"into",
"a",
"storable",
"version",
"of",
"itself",
"."
] | 9b256084297f80d373bcf483aaf68a9da176b3d7 | https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/persisting.js#L263-L299 | train |
byron-dupreez/aws-stream-consumer-core | persisting.js | toStorableUnusableRecordState | function toStorableUnusableRecordState(unusableRecordState, unusableRecord, context) {
if (!unusableRecordState) {
context.warn(`Skipping save of state for unusable record, since it has no state - record (${JSON.stringify(unusableRecord)})`);
return undefined;
}
// Convert the record's state into a safel... | javascript | function toStorableUnusableRecordState(unusableRecordState, unusableRecord, context) {
if (!unusableRecordState) {
context.warn(`Skipping save of state for unusable record, since it has no state - record (${JSON.stringify(unusableRecord)})`);
return undefined;
}
// Convert the record's state into a safel... | [
"function",
"toStorableUnusableRecordState",
"(",
"unusableRecordState",
",",
"unusableRecord",
",",
"context",
")",
"{",
"if",
"(",
"!",
"unusableRecordState",
")",
"{",
"context",
".",
"warn",
"(",
"`",
"${",
"JSON",
".",
"stringify",
"(",
"unusableRecord",
")... | Converts the given unusable record state into a storable version of itself.
@param {UnusableRecordState} unusableRecordState
@param {UnusableRecord|undefined} unusableRecord
@param {StreamProcessing} context
@return {UnusableRecordStateItem|undefined} | [
"Converts",
"the",
"given",
"unusable",
"record",
"state",
"into",
"a",
"storable",
"version",
"of",
"itself",
"."
] | 9b256084297f80d373bcf483aaf68a9da176b3d7 | https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/persisting.js#L308-L342 | train |
byron-dupreez/aws-stream-consumer-core | persisting.js | updateBatchWithPriorState | function updateBatchWithPriorState(batch, item, context) {
restoreMessageAndRejectedMessageStates(batch, item, context);
restoreUnusableRecordStates(batch, item, context);
} | javascript | function updateBatchWithPriorState(batch, item, context) {
restoreMessageAndRejectedMessageStates(batch, item, context);
restoreUnusableRecordStates(batch, item, context);
} | [
"function",
"updateBatchWithPriorState",
"(",
"batch",
",",
"item",
",",
"context",
")",
"{",
"restoreMessageAndRejectedMessageStates",
"(",
"batch",
",",
"item",
",",
"context",
")",
";",
"restoreUnusableRecordStates",
"(",
"batch",
",",
"item",
",",
"context",
"... | Updates the given batch with the previous message states, previous unusable record states and previous batch state on
the given item, which was loaded from the database.
@param {Batch} batch - the batch to update
@param {BatchStateItem} item - a previously loaded batch state item
@param context | [
"Updates",
"the",
"given",
"batch",
"with",
"the",
"previous",
"message",
"states",
"previous",
"unusable",
"record",
"states",
"and",
"previous",
"batch",
"state",
"on",
"the",
"given",
"item",
"which",
"was",
"loaded",
"from",
"the",
"database",
"."
] | 9b256084297f80d373bcf483aaf68a9da176b3d7 | https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/persisting.js#L447-L450 | train |
byron-dupreez/aws-stream-consumer-core | persisting.js | hasMessageIdentifier | function hasMessageIdentifier(msgState) {
const md5s = msgState.md5s;
return isNotBlank(msgState.eventID) || // isNotBlank(msgState.eventSeqNo) || isNotBlank(msgState.eventSubSeqNo) ||
(msgState.idVals && msgState.idVals.some(isNotBlank)) ||
((msgState.keyVals && msgState.keyVals.some(isNotBlank)) &&
... | javascript | function hasMessageIdentifier(msgState) {
const md5s = msgState.md5s;
return isNotBlank(msgState.eventID) || // isNotBlank(msgState.eventSeqNo) || isNotBlank(msgState.eventSubSeqNo) ||
(msgState.idVals && msgState.idVals.some(isNotBlank)) ||
((msgState.keyVals && msgState.keyVals.some(isNotBlank)) &&
... | [
"function",
"hasMessageIdentifier",
"(",
"msgState",
")",
"{",
"const",
"md5s",
"=",
"msgState",
".",
"md5s",
";",
"return",
"isNotBlank",
"(",
"msgState",
".",
"eventID",
")",
"||",
"// isNotBlank(msgState.eventSeqNo) || isNotBlank(msgState.eventSubSeqNo) ||",
"(",
"ms... | Returns true if the given message state has at least one non-blank identifier; otherwise false.
@param {MessageState} msgState - the tracked state of a message
@return {boolean} | [
"Returns",
"true",
"if",
"the",
"given",
"message",
"state",
"has",
"at",
"least",
"one",
"non",
"-",
"blank",
"identifier",
";",
"otherwise",
"false",
"."
] | 9b256084297f80d373bcf483aaf68a9da176b3d7 | https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/persisting.js#L457-L464 | train |
byron-dupreez/aws-stream-consumer-core | persisting.js | hasUnusableRecordIdentifier | function hasUnusableRecordIdentifier(recState) {
const md5s = recState.md5s;
return isNotBlank(recState.eventID) || // isNotBlank(recState.eventSeqNo) || isNotBlank(recState.eventSubSeqNo) ||
(md5s && (isNotBlank(md5s.userRec) || isNotBlank(md5s.rec) || isNotBlank(md5s.data)));
} | javascript | function hasUnusableRecordIdentifier(recState) {
const md5s = recState.md5s;
return isNotBlank(recState.eventID) || // isNotBlank(recState.eventSeqNo) || isNotBlank(recState.eventSubSeqNo) ||
(md5s && (isNotBlank(md5s.userRec) || isNotBlank(md5s.rec) || isNotBlank(md5s.data)));
} | [
"function",
"hasUnusableRecordIdentifier",
"(",
"recState",
")",
"{",
"const",
"md5s",
"=",
"recState",
".",
"md5s",
";",
"return",
"isNotBlank",
"(",
"recState",
".",
"eventID",
")",
"||",
"// isNotBlank(recState.eventSeqNo) || isNotBlank(recState.eventSubSeqNo) ||",
"("... | Returns true if the given unusable record state has at least one non-blank identifier; otherwise false.
@param {UnusableRecordState} recState - the tracked state of an unusable record
@return {boolean} | [
"Returns",
"true",
"if",
"the",
"given",
"unusable",
"record",
"state",
"has",
"at",
"least",
"one",
"non",
"-",
"blank",
"identifier",
";",
"otherwise",
"false",
"."
] | 9b256084297f80d373bcf483aaf68a9da176b3d7 | https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/persisting.js#L489-L493 | train |
appcelerator-archive/appc-connector-utils | lib/tools/dataValidator.js | validate | function validate (data, schema) {
if (!data || !schema) {
throw new Error('Trying to validate without passing data and schema')
}
return Joi.validate(data, schema)
} | javascript | function validate (data, schema) {
if (!data || !schema) {
throw new Error('Trying to validate without passing data and schema')
}
return Joi.validate(data, schema)
} | [
"function",
"validate",
"(",
"data",
",",
"schema",
")",
"{",
"if",
"(",
"!",
"data",
"||",
"!",
"schema",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Trying to validate without passing data and schema'",
")",
"}",
"return",
"Joi",
".",
"validate",
"(",
"data"... | Validates data based on Joi schemas
@param {Object} data the data to be validated
@param {Object} schema the object schema specified in Joi against which data is validated | [
"Validates",
"data",
"based",
"on",
"Joi",
"schemas"
] | 4af3bb7d24c5780270d7ba0ec98017b1f58f1aa8 | https://github.com/appcelerator-archive/appc-connector-utils/blob/4af3bb7d24c5780270d7ba0ec98017b1f58f1aa8/lib/tools/dataValidator.js#L13-L18 | train |
esiglabs/eslutils | build/validation.js | verifyChain | function verifyChain(certificate, chain, trustedCAs) {
if (certificate === null) return Promise.resolve(false);
return Promise.resolve().then(function () {
var certificateChainEngine = new pkijs.CertificateChainValidationEngine({
certs: chain,
trustedCerts: trustedCAs.filter(function (cert) {
... | javascript | function verifyChain(certificate, chain, trustedCAs) {
if (certificate === null) return Promise.resolve(false);
return Promise.resolve().then(function () {
var certificateChainEngine = new pkijs.CertificateChainValidationEngine({
certs: chain,
trustedCerts: trustedCAs.filter(function (cert) {
... | [
"function",
"verifyChain",
"(",
"certificate",
",",
"chain",
",",
"trustedCAs",
")",
"{",
"if",
"(",
"certificate",
"===",
"null",
")",
"return",
"Promise",
".",
"resolve",
"(",
"false",
")",
";",
"return",
"Promise",
".",
"resolve",
"(",
")",
".",
"then... | Verify if a certificate chains to some trusted CAs.
@param {pkijs.Certificate} certificate - The certificate that will be
checked.
@param {Array<pkijs.Certificate>} chain - Additional certificates in the
chain.
@param {Array<pkijs.Certificate>} trustedCAs - The trusted CAs
@return {Promise<boolean>} A promise that is r... | [
"Verify",
"if",
"a",
"certificate",
"chains",
"to",
"some",
"trusted",
"CAs",
"."
] | 00ff5967fd37c27235e25e583ee17008d4c3ce8a | https://github.com/esiglabs/eslutils/blob/00ff5967fd37c27235e25e583ee17008d4c3ce8a/build/validation.js#L24-L42 | train |
prezzemolo/accettare | index.js | getProperties | function getProperties (header) {
return header.split(',').map((split) => {
const components = split.replace(/\s+/, '').split(';');
const priorityRegex = /^q=([0-1](\.[0-9]{1,3})?)$/;
/* assign null to priority when invaild quarity values */
return {
lang: components[0],... | javascript | function getProperties (header) {
return header.split(',').map((split) => {
const components = split.replace(/\s+/, '').split(';');
const priorityRegex = /^q=([0-1](\.[0-9]{1,3})?)$/;
/* assign null to priority when invaild quarity values */
return {
lang: components[0],... | [
"function",
"getProperties",
"(",
"header",
")",
"{",
"return",
"header",
".",
"split",
"(",
"','",
")",
".",
"map",
"(",
"(",
"split",
")",
"=>",
"{",
"const",
"components",
"=",
"split",
".",
"replace",
"(",
"/",
"\\s+",
"/",
",",
"''",
")",
".",... | analyze HTTP accept-language header
@param {string} header
@return {array} | [
"analyze",
"HTTP",
"accept",
"-",
"language",
"header"
] | 8a75066f1ee69c2a6d282a424b8401208b9159d2 | https://github.com/prezzemolo/accettare/blob/8a75066f1ee69c2a6d282a424b8401208b9159d2/index.js#L45-L60 | train |
prezzemolo/accettare | index.js | matchAccept | function matchAccept (properties, langs) {
let match = null;
let priority = 0;
base: for(const lang of langs) {
for (const property of properties) {
if (property.priority === 0) {
break;
}
if (priority < property.priority){
if (la... | javascript | function matchAccept (properties, langs) {
let match = null;
let priority = 0;
base: for(const lang of langs) {
for (const property of properties) {
if (property.priority === 0) {
break;
}
if (priority < property.priority){
if (la... | [
"function",
"matchAccept",
"(",
"properties",
",",
"langs",
")",
"{",
"let",
"match",
"=",
"null",
";",
"let",
"priority",
"=",
"0",
";",
"base",
":",
"for",
"(",
"const",
"lang",
"of",
"langs",
")",
"{",
"for",
"(",
"const",
"property",
"of",
"prope... | search match by BCP47 Objects
@param {Array} properties
@param {Array} langs
@return {string} | [
"search",
"match",
"by",
"BCP47",
"Objects"
] | 8a75066f1ee69c2a6d282a424b8401208b9159d2 | https://github.com/prezzemolo/accettare/blob/8a75066f1ee69c2a6d282a424b8401208b9159d2/index.js#L68-L94 | train |
nearform/docker-container | lib/dockerBuilder.js | function() {
var stat = fs.existsSync('/var/run/docker.sock');
if (!stat) {
stat = process.env.DOCKER_HOST || false;
}
return stat;
} | javascript | function() {
var stat = fs.existsSync('/var/run/docker.sock');
if (!stat) {
stat = process.env.DOCKER_HOST || false;
}
return stat;
} | [
"function",
"(",
")",
"{",
"var",
"stat",
"=",
"fs",
".",
"existsSync",
"(",
"'/var/run/docker.sock'",
")",
";",
"if",
"(",
"!",
"stat",
")",
"{",
"stat",
"=",
"process",
".",
"env",
".",
"DOCKER_HOST",
"||",
"false",
";",
"}",
"return",
"stat",
";",... | check that docker is able to run on this system | [
"check",
"that",
"docker",
"is",
"able",
"to",
"run",
"on",
"this",
"system"
] | 724ff6a9d8d3c116f9a6b8239594c4b5cd5e8e17 | https://github.com/nearform/docker-container/blob/724ff6a9d8d3c116f9a6b8239594c4b5cd5e8e17/lib/dockerBuilder.js#L36-L42 | train | |
vmarkdown/vremark-parse | packages/vremark-toc/mdast-util-toc/lib/contents.js | contents | function contents(map, tight) {
var minDepth = Infinity;
var index = -1;
var length = map.length;
var table;
/*
* Find minimum depth.
*/
while (++index < length) {
if (map[index].depth < minDepth) {
minDepth = map[index].depth;
}
}
/*
* Norma... | javascript | function contents(map, tight) {
var minDepth = Infinity;
var index = -1;
var length = map.length;
var table;
/*
* Find minimum depth.
*/
while (++index < length) {
if (map[index].depth < minDepth) {
minDepth = map[index].depth;
}
}
/*
* Norma... | [
"function",
"contents",
"(",
"map",
",",
"tight",
")",
"{",
"var",
"minDepth",
"=",
"Infinity",
";",
"var",
"index",
"=",
"-",
"1",
";",
"var",
"length",
"=",
"map",
".",
"length",
";",
"var",
"table",
";",
"/*\n * Find minimum depth.\n */",
"while... | Transform a list of heading objects to a markdown list.
@param {Array.<Object>} map - Heading-map to insert.
@param {boolean?} [tight] - Prefer tight list-items.
@return {Object} - List node. | [
"Transform",
"a",
"list",
"of",
"heading",
"objects",
"to",
"a",
"markdown",
"list",
"."
] | d7b353dcb5d021eeceb40f3c505ece893202db7a | https://github.com/vmarkdown/vremark-parse/blob/d7b353dcb5d021eeceb40f3c505ece893202db7a/packages/vremark-toc/mdast-util-toc/lib/contents.js#L23-L66 | train |
marcojonker/data-elevator | lib/utils/command-line-utils.js | function() {
var cmdArguments = process.argv.slice(2)
var lookup = {
values: [],
keyValues: {}
};
cmdArguments.forEach(function(cmdArgument) {
var keyValue = cmdArgument.split('=');
//Flag of key value type
if(typeof keyValue[0] === 'string' && keyValue[0].ch... | javascript | function() {
var cmdArguments = process.argv.slice(2)
var lookup = {
values: [],
keyValues: {}
};
cmdArguments.forEach(function(cmdArgument) {
var keyValue = cmdArgument.split('=');
//Flag of key value type
if(typeof keyValue[0] === 'string' && keyValue[0].ch... | [
"function",
"(",
")",
"{",
"var",
"cmdArguments",
"=",
"process",
".",
"argv",
".",
"slice",
"(",
"2",
")",
"var",
"lookup",
"=",
"{",
"values",
":",
"[",
"]",
",",
"keyValues",
":",
"{",
"}",
"}",
";",
"cmdArguments",
".",
"forEach",
"(",
"functio... | Create lookup table for process arguments
@result object | [
"Create",
"lookup",
"table",
"for",
"process",
"arguments"
] | 7d56e5b2e8ca24b9576066e5265713db6452f289 | https://github.com/marcojonker/data-elevator/blob/7d56e5b2e8ca24b9576066e5265713db6452f289/lib/utils/command-line-utils.js#L25-L46 | train | |
Psychopoulet/node-promfs | lib/extends/_directoryToStream.js | _directoryToStream | function _directoryToStream (directory, separator, callback) {
if ("undefined" === typeof directory) {
throw new ReferenceError("missing \"directory\" argument");
}
else if ("string" !== typeof directory) {
throw new TypeError("\"directory\" argument is not a string");
}
else if ("" === dire... | javascript | function _directoryToStream (directory, separator, callback) {
if ("undefined" === typeof directory) {
throw new ReferenceError("missing \"directory\" argument");
}
else if ("string" !== typeof directory) {
throw new TypeError("\"directory\" argument is not a string");
}
else if ("" === dire... | [
"function",
"_directoryToStream",
"(",
"directory",
",",
"separator",
",",
"callback",
")",
"{",
"if",
"(",
"\"undefined\"",
"===",
"typeof",
"directory",
")",
"{",
"throw",
"new",
"ReferenceError",
"(",
"\"missing \\\"directory\\\" argument\"",
")",
";",
"}",
"el... | methods
Async directoryToStream
@param {string} directory : directory to work with
@param {string} separator : used to separate content (can be "")
@param {function|null} callback : operation's result
@returns {void} | [
"methods",
"Async",
"directoryToStream"
] | 016e272fc58c6ef6eae5ea551a0e8873f0ac20cc | https://github.com/Psychopoulet/node-promfs/blob/016e272fc58c6ef6eae5ea551a0e8873f0ac20cc/lib/extends/_directoryToStream.js#L23-L51 | train |
dominhhai/express-authen | index.js | requireLogin | function requireLogin (options) {
// merge with default options
options = mergeOptions({
'login': '/login',
'home': '/',
'user': 'user',
'referer': 'referer',
'excepts': []
}, options)
// add login to except page
options.excepts.push(options.login)
return function(req, res, next) {
var url = req.orig... | javascript | function requireLogin (options) {
// merge with default options
options = mergeOptions({
'login': '/login',
'home': '/',
'user': 'user',
'referer': 'referer',
'excepts': []
}, options)
// add login to except page
options.excepts.push(options.login)
return function(req, res, next) {
var url = req.orig... | [
"function",
"requireLogin",
"(",
"options",
")",
"{",
"// merge with default options",
"options",
"=",
"mergeOptions",
"(",
"{",
"'login'",
":",
"'/login'",
",",
"'home'",
":",
"'/'",
",",
"'user'",
":",
"'user'",
",",
"'referer'",
":",
"'referer'",
",",
"'exc... | Control direct page when require auth.
1. Auto redirect to login page
when non-logged in user access the required-auth page
2. Save the referer into session
@param {Object} middleware options
@login: login page path
@home: default redirected page after logged-in
@excepts: non-required auth page
@user: session' key for... | [
"Control",
"direct",
"page",
"when",
"require",
"auth",
".",
"1",
".",
"Auto",
"redirect",
"to",
"login",
"page",
"when",
"non",
"-",
"logged",
"in",
"user",
"access",
"the",
"required",
"-",
"auth",
"page",
"2",
".",
"Save",
"the",
"referer",
"into",
... | 4ad4ee97087544a17c9cd87fb15c4abb06dfefcc | https://github.com/dominhhai/express-authen/blob/4ad4ee97087544a17c9cd87fb15c4abb06dfefcc/index.js#L26-L59 | train |
realm-js/realm-router | backend.js | Dispatcher | function Dispatcher(req, res, next) {
_classCallCheck(this, Dispatcher);
this.req = req;
this.res = res;
this.next = next;
} | javascript | function Dispatcher(req, res, next) {
_classCallCheck(this, Dispatcher);
this.req = req;
this.res = res;
this.next = next;
} | [
"function",
"Dispatcher",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"_classCallCheck",
"(",
"this",
",",
"Dispatcher",
")",
";",
"this",
".",
"req",
"=",
"req",
";",
"this",
".",
"res",
"=",
"res",
";",
"this",
".",
"next",
"=",
"next",
";",
... | constructor - description
@param {type} req description
@param {type} res description
@param {type} next description
@return {type} description | [
"constructor",
"-",
"description"
] | 91c1d8b69c4b29fd5791cc98b8403cda038b544f | https://github.com/realm-js/realm-router/blob/91c1d8b69c4b29fd5791cc98b8403cda038b544f/backend.js#L113-L119 | train |
create-conform/allume | bin/allume.js | getUrlParameters | function getUrlParameters() {
var params = [ "allume" ];
location.search.substr(1).split("&").forEach(function (part) {
if (!part) return;
var item = part.split("=");
params.push(decodeURIComponent(item[0]));
});
return params;
} | javascript | function getUrlParameters() {
var params = [ "allume" ];
location.search.substr(1).split("&").forEach(function (part) {
if (!part) return;
var item = part.split("=");
params.push(decodeURIComponent(item[0]));
});
return params;
} | [
"function",
"getUrlParameters",
"(",
")",
"{",
"var",
"params",
"=",
"[",
"\"allume\"",
"]",
";",
"location",
".",
"search",
".",
"substr",
"(",
"1",
")",
".",
"split",
"(",
"\"&\"",
")",
".",
"forEach",
"(",
"function",
"(",
"part",
")",
"{",
"if",
... | getUrlParameters Returns url parameters if running inside browser, else returns an array containing one string; which is the name of the command invoked 'allume' to be compatible with CLI runtimes. | [
"getUrlParameters",
"Returns",
"url",
"parameters",
"if",
"running",
"inside",
"browser",
"else",
"returns",
"an",
"array",
"containing",
"one",
"string",
";",
"which",
"is",
"the",
"name",
"of",
"the",
"command",
"invoked",
"allume",
"to",
"be",
"compatible",
... | 5fdc87804f1e2309c155d001e64d23029c781491 | https://github.com/create-conform/allume/blob/5fdc87804f1e2309c155d001e64d23029c781491/bin/allume.js#L77-L85 | train |
create-conform/allume | bin/allume.js | getNodeParameters | function getNodeParameters() {
return typeof process !== "undefined" && process.argv && process.argv.length > 1 ? process.argv.slice(1) : null;
} | javascript | function getNodeParameters() {
return typeof process !== "undefined" && process.argv && process.argv.length > 1 ? process.argv.slice(1) : null;
} | [
"function",
"getNodeParameters",
"(",
")",
"{",
"return",
"typeof",
"process",
"!==",
"\"undefined\"",
"&&",
"process",
".",
"argv",
"&&",
"process",
".",
"argv",
".",
"length",
">",
"1",
"?",
"process",
".",
"argv",
".",
"slice",
"(",
"1",
")",
":",
"... | getNodeParameters Returns cli parameters when running from inside node.js, else returns null. | [
"getNodeParameters",
"Returns",
"cli",
"parameters",
"when",
"running",
"from",
"inside",
"node",
".",
"js",
"else",
"returns",
"null",
"."
] | 5fdc87804f1e2309c155d001e64d23029c781491 | https://github.com/create-conform/allume/blob/5fdc87804f1e2309c155d001e64d23029c781491/bin/allume.js#L106-L108 | train |
redisjs/jsr-server | lib/command/pubsub/pubsub.js | channels | function channels(req, res) {
res.send(null, this.state.pubsub.getChannels(req.args[0]));
} | javascript | function channels(req, res) {
res.send(null, this.state.pubsub.getChannels(req.args[0]));
} | [
"function",
"channels",
"(",
"req",
",",
"res",
")",
"{",
"res",
".",
"send",
"(",
"null",
",",
"this",
".",
"state",
".",
"pubsub",
".",
"getChannels",
"(",
"req",
".",
"args",
"[",
"0",
"]",
")",
")",
";",
"}"
] | Respond to the CHANNELS subcommand. | [
"Respond",
"to",
"the",
"CHANNELS",
"subcommand",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/pubsub/pubsub.js#L19-L21 | train |
redisjs/jsr-server | lib/command/pubsub/pubsub.js | numsub | function numsub(req, res) {
res.send(null, this.state.pubsub.getChannelList(req.args));
} | javascript | function numsub(req, res) {
res.send(null, this.state.pubsub.getChannelList(req.args));
} | [
"function",
"numsub",
"(",
"req",
",",
"res",
")",
"{",
"res",
".",
"send",
"(",
"null",
",",
"this",
".",
"state",
".",
"pubsub",
".",
"getChannelList",
"(",
"req",
".",
"args",
")",
")",
";",
"}"
] | Respond to the NUMSUB subcommand. | [
"Respond",
"to",
"the",
"NUMSUB",
"subcommand",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/pubsub/pubsub.js#L26-L28 | train |
redisjs/jsr-server | lib/command/pubsub/pubsub.js | validate | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var sub = info.command.sub
, cmd = sub.cmd
, args = sub.args
if(('' + cmd) === Constants.SUBCOMMAND.pubsub.channels.name) {
if(args.length > 1) {
throw UnknownSubcommand;
}
}
} | javascript | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var sub = info.command.sub
, cmd = sub.cmd
, args = sub.args
if(('' + cmd) === Constants.SUBCOMMAND.pubsub.channels.name) {
if(args.length > 1) {
throw UnknownSubcommand;
}
}
} | [
"function",
"validate",
"(",
"cmd",
",",
"args",
",",
"info",
")",
"{",
"AbstractCommand",
".",
"prototype",
".",
"validate",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"var",
"sub",
"=",
"info",
".",
"command",
".",
"sub",
",",
"cmd",
"=... | Validate the PUBSUB subcommands. | [
"Validate",
"the",
"PUBSUB",
"subcommands",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/pubsub/pubsub.js#L40-L50 | train |
Nazariglez/perenquen | lib/pixi/src/filters/gray/GrayFilter.js | GrayFilter | function GrayFilter()
{
core.AbstractFilter.call(this,
// vertex shader
null,
// fragment shader
fs.readFileSync(__dirname + '/gray.frag', 'utf8'),
// set the uniforms
{
gray: { type: '1f', value: 1 }
}
);
} | javascript | function GrayFilter()
{
core.AbstractFilter.call(this,
// vertex shader
null,
// fragment shader
fs.readFileSync(__dirname + '/gray.frag', 'utf8'),
// set the uniforms
{
gray: { type: '1f', value: 1 }
}
);
} | [
"function",
"GrayFilter",
"(",
")",
"{",
"core",
".",
"AbstractFilter",
".",
"call",
"(",
"this",
",",
"// vertex shader",
"null",
",",
"// fragment shader",
"fs",
".",
"readFileSync",
"(",
"__dirname",
"+",
"'/gray.frag'",
",",
"'utf8'",
")",
",",
"// set the... | This greyscales the palette of your Display Objects.
@class
@extends AbstractFilter
@memberof PIXI.filters | [
"This",
"greyscales",
"the",
"palette",
"of",
"your",
"Display",
"Objects",
"."
] | e023964d05afeefebdcac4e2044819fdfa3899ae | https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/filters/gray/GrayFilter.js#L12-L24 | train |
Nazariglez/perenquen | lib/pixi/src/core/textures/Texture.js | Texture | function Texture(baseTexture, frame, crop, trim, rotate)
{
EventEmitter.call(this);
/**
* Does this Texture have any frame data assigned to it?
*
* @member {boolean}
*/
this.noFrame = false;
if (!frame)
{
this.noFrame = true;
frame = new math.Rectangle(0, 0, 1, ... | javascript | function Texture(baseTexture, frame, crop, trim, rotate)
{
EventEmitter.call(this);
/**
* Does this Texture have any frame data assigned to it?
*
* @member {boolean}
*/
this.noFrame = false;
if (!frame)
{
this.noFrame = true;
frame = new math.Rectangle(0, 0, 1, ... | [
"function",
"Texture",
"(",
"baseTexture",
",",
"frame",
",",
"crop",
",",
"trim",
",",
"rotate",
")",
"{",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"/**\n * Does this Texture have any frame data assigned to it?\n *\n * @member {boolean}\n */",
... | A texture stores the information that represents an image or part of an image. It cannot be added
to the display list directly. Instead use it as the texture for a Sprite. If no frame is provided then the whole image is used.
You can directly create a texture from an image and then reuse it multiple times like this :
... | [
"A",
"texture",
"stores",
"the",
"information",
"that",
"represents",
"an",
"image",
"or",
"part",
"of",
"an",
"image",
".",
"It",
"cannot",
"be",
"added",
"to",
"the",
"display",
"list",
"directly",
".",
"Instead",
"use",
"it",
"as",
"the",
"texture",
"... | e023964d05afeefebdcac4e2044819fdfa3899ae | https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/core/textures/Texture.js#L28-L141 | train |
mobilehero-archive/aplus-babel | aplus-babel.js | plugin | function plugin(params) {
logger = params.logger;
params.dirname = params.dirname ? _.template(params.dirname)(params) : params.event.dir.resourcesPlatform;
logger.trace("running babel in directory: " + params.dirname);
_.defaults(params, {
options: {},
includes: ["**/*.js", "!backbone.js"]
});
if (params... | javascript | function plugin(params) {
logger = params.logger;
params.dirname = params.dirname ? _.template(params.dirname)(params) : params.event.dir.resourcesPlatform;
logger.trace("running babel in directory: " + params.dirname);
_.defaults(params, {
options: {},
includes: ["**/*.js", "!backbone.js"]
});
if (params... | [
"function",
"plugin",
"(",
"params",
")",
"{",
"logger",
"=",
"params",
".",
"logger",
";",
"params",
".",
"dirname",
"=",
"params",
".",
"dirname",
"?",
"_",
".",
"template",
"(",
"params",
".",
"dirname",
")",
"(",
"params",
")",
":",
"params",
"."... | Run babel tranformations on Alloy source code
@param {Object} params - parameters available for executing of Alloy+ plugin.
@param {Object} params.event - Provides a set of objects and values which may be useful for building tasks:
@param {Object} params.event.alloyConfig - Contains Alloy compiler configuration inform... | [
"Run",
"babel",
"tranformations",
"on",
"Alloy",
"source",
"code"
] | 83c8bca88e9059a60e3bc960bdfaefd7475c8042 | https://github.com/mobilehero-archive/aplus-babel/blob/83c8bca88e9059a60e3bc960bdfaefd7475c8042/aplus-babel.js#L84-L104 | train |
mobilehero-archive/aplus-babel | aplus-babel.js | transformFile | function transformFile(filepath, options) {
logger.trace("transforming file - " + filepath);
var content = fs.readFileSync(filepath, 'utf8');
var result = transformCode(content, options);
fs.writeFileSync(filepath, result);
} | javascript | function transformFile(filepath, options) {
logger.trace("transforming file - " + filepath);
var content = fs.readFileSync(filepath, 'utf8');
var result = transformCode(content, options);
fs.writeFileSync(filepath, result);
} | [
"function",
"transformFile",
"(",
"filepath",
",",
"options",
")",
"{",
"logger",
".",
"trace",
"(",
"\"transforming file - \"",
"+",
"filepath",
")",
";",
"var",
"content",
"=",
"fs",
".",
"readFileSync",
"(",
"filepath",
",",
"'utf8'",
")",
";",
"var",
"... | Transform a file with babeljs using babel config
@param {string} filepath - absolute path of the file to be transformed
@param {Object} options - babel configuration object (see http://babeljs.io/docs/usage/options/)
@param {string[]} [options.presets=[]] - List of presets (a set of plugins) to load and use..
@param {... | [
"Transform",
"a",
"file",
"with",
"babeljs",
"using",
"babel",
"config"
] | 83c8bca88e9059a60e3bc960bdfaefd7475c8042 | https://github.com/mobilehero-archive/aplus-babel/blob/83c8bca88e9059a60e3bc960bdfaefd7475c8042/aplus-babel.js#L197-L202 | train |
mobilehero-archive/aplus-babel | aplus-babel.js | transformCode | function transformCode(code, options) {
var result = babel.transform(code, options);
var modified = result.code;
return modified;
} | javascript | function transformCode(code, options) {
var result = babel.transform(code, options);
var modified = result.code;
return modified;
} | [
"function",
"transformCode",
"(",
"code",
",",
"options",
")",
"{",
"var",
"result",
"=",
"babel",
".",
"transform",
"(",
"code",
",",
"options",
")",
";",
"var",
"modified",
"=",
"result",
".",
"code",
";",
"return",
"modified",
";",
"}"
] | Transform the code with bablejs using babel config.
@param {string} code - code to transform using babeljs
@param {Object} options - babel configuration object (see http://babeljs.io/docs/usage/options/)
@param {string[]} [options.presets=[]] - List of presets (a set of plugins) to load and use..
@param {string[]} [op... | [
"Transform",
"the",
"code",
"with",
"bablejs",
"using",
"babel",
"config",
"."
] | 83c8bca88e9059a60e3bc960bdfaefd7475c8042 | https://github.com/mobilehero-archive/aplus-babel/blob/83c8bca88e9059a60e3bc960bdfaefd7475c8042/aplus-babel.js#L218-L222 | train |
benaston/kwire | dist/kwire.js | kwire | function kwire(appRoot, globalShadow) {
appRoot = appRoot == null ? {} : appRoot;
globalShadow = globalShadow || window;
if (typeof appRoot !== 'object') {
throw 'root object must be an object.'
}
if (isServerSide() ||
isUsingRequireJS() ||
rootIsAlreadyConfigured(globalShadow)) {
return;
}
... | javascript | function kwire(appRoot, globalShadow) {
appRoot = appRoot == null ? {} : appRoot;
globalShadow = globalShadow || window;
if (typeof appRoot !== 'object') {
throw 'root object must be an object.'
}
if (isServerSide() ||
isUsingRequireJS() ||
rootIsAlreadyConfigured(globalShadow)) {
return;
}
... | [
"function",
"kwire",
"(",
"appRoot",
",",
"globalShadow",
")",
"{",
"appRoot",
"=",
"appRoot",
"==",
"null",
"?",
"{",
"}",
":",
"appRoot",
";",
"globalShadow",
"=",
"globalShadow",
"||",
"window",
";",
"if",
"(",
"typeof",
"appRoot",
"!==",
"'object'",
... | Augments the window object with a
module and a require property to
emulate CommonJS in the browser.
@param {Object} appRoot The object to use as the root object for your 'modules' reqistered with kwire.
@param {Object} globalShadow An object to shadow the global object for testing purposes. | [
"Augments",
"the",
"window",
"object",
"with",
"a",
"module",
"and",
"a",
"require",
"property",
"to",
"emulate",
"CommonJS",
"in",
"the",
"browser",
"."
] | 96e852221a71a9c6b52d59b49d4d16b47e259c0c | https://github.com/benaston/kwire/blob/96e852221a71a9c6b52d59b49d4d16b47e259c0c/dist/kwire.js#L19-L80 | train |
JerryC8080/skipper-upyun | standalone/build-upyun-receiver-stream.js | getInstance | function getInstance(options) {
var bucket = options.bucket;
var upyunInstance = instances[bucket];
// If can not found instance, then new one.
if (!upyunInstance) {
instances[bucket] = upyunInstance = new UPYUN(options.bucket, options.operator, options.password, options.endpoing, options.apiVersion);
}
... | javascript | function getInstance(options) {
var bucket = options.bucket;
var upyunInstance = instances[bucket];
// If can not found instance, then new one.
if (!upyunInstance) {
instances[bucket] = upyunInstance = new UPYUN(options.bucket, options.operator, options.password, options.endpoing, options.apiVersion);
}
... | [
"function",
"getInstance",
"(",
"options",
")",
"{",
"var",
"bucket",
"=",
"options",
".",
"bucket",
";",
"var",
"upyunInstance",
"=",
"instances",
"[",
"bucket",
"]",
";",
"// If can not found instance, then new one.",
"if",
"(",
"!",
"upyunInstance",
")",
"{",... | Get upyun instance | [
"Get",
"upyun",
"instance"
] | 97a4445e3c4913d26f0c6a131386fff34ef8c76c | https://github.com/JerryC8080/skipper-upyun/blob/97a4445e3c4913d26f0c6a131386fff34ef8c76c/standalone/build-upyun-receiver-stream.js#L21-L31 | train |
JerryC8080/skipper-upyun | standalone/build-upyun-receiver-stream.js | uploadToUpyun | function uploadToUpyun(path, file, __newFile, done) {
var options = this.options;
var upyun = getInstance(options);
upyun.uploadFile(path, file, __newFile.headers['content-type'], true, function (err, data) {
if (err) {
return done(err);
}
if (!data) {
return done(new Error('Upload failed!... | javascript | function uploadToUpyun(path, file, __newFile, done) {
var options = this.options;
var upyun = getInstance(options);
upyun.uploadFile(path, file, __newFile.headers['content-type'], true, function (err, data) {
if (err) {
return done(err);
}
if (!data) {
return done(new Error('Upload failed!... | [
"function",
"uploadToUpyun",
"(",
"path",
",",
"file",
",",
"__newFile",
",",
"done",
")",
"{",
"var",
"options",
"=",
"this",
".",
"options",
";",
"var",
"upyun",
"=",
"getInstance",
"(",
"options",
")",
";",
"upyun",
".",
"uploadFile",
"(",
"path",
"... | Upload the file to remote service of upyun
@param {} path
@param {} file
@param {} __newFile
@param {} done | [
"Upload",
"the",
"file",
"to",
"remote",
"service",
"of",
"upyun"
] | 97a4445e3c4913d26f0c6a131386fff34ef8c76c | https://github.com/JerryC8080/skipper-upyun/blob/97a4445e3c4913d26f0c6a131386fff34ef8c76c/standalone/build-upyun-receiver-stream.js#L40-L56 | train |
JerryC8080/skipper-upyun | standalone/build-upyun-receiver-stream.js | buildUpyunReceiverStream | function buildUpyunReceiverStream(opts) {
var options = opts || {};
_.defaults(options, {
endpoing: 'v0',
apiVersion: 'legacy',
// Upload limit (in bytes)
// defaults to ~15MB
maxBytes: 15000000,
// Upload limit for per coming file (in bytes)
// falsy means no limit
perMaxBytes: ... | javascript | function buildUpyunReceiverStream(opts) {
var options = opts || {};
_.defaults(options, {
endpoing: 'v0',
apiVersion: 'legacy',
// Upload limit (in bytes)
// defaults to ~15MB
maxBytes: 15000000,
// Upload limit for per coming file (in bytes)
// falsy means no limit
perMaxBytes: ... | [
"function",
"buildUpyunReceiverStream",
"(",
"opts",
")",
"{",
"var",
"options",
"=",
"opts",
"||",
"{",
"}",
";",
"_",
".",
"defaults",
"(",
"options",
",",
"{",
"endpoing",
":",
"'v0'",
",",
"apiVersion",
":",
"'legacy'",
",",
"// Upload limit (in bytes)",... | A upyun receiver for Skipper that writes Upstreams to
upyun at the configured path.
@param {Object} opts
@return {Stream.Writable} | [
"A",
"upyun",
"receiver",
"for",
"Skipper",
"that",
"writes",
"Upstreams",
"to",
"upyun",
"at",
"the",
"configured",
"path",
"."
] | 97a4445e3c4913d26f0c6a131386fff34ef8c76c | https://github.com/JerryC8080/skipper-upyun/blob/97a4445e3c4913d26f0c6a131386fff34ef8c76c/standalone/build-upyun-receiver-stream.js#L105-L144 | 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.