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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
icanjs/grid-filter | src/grid-filter.js | function (item) {
if($.isEmptyObject(item)){
var tempObj={ id: $('input:first', el).val(), name: $('input:first', el).val()};
return [tempObj];
}else{
return item;
}
} | javascript | function (item) {
if($.isEmptyObject(item)){
var tempObj={ id: $('input:first', el).val(), name: $('input:first', el).val()};
return [tempObj];
}else{
return item;
}
} | [
"function",
"(",
"item",
")",
"{",
"if",
"(",
"$",
".",
"isEmptyObject",
"(",
"item",
")",
")",
"{",
"var",
"tempObj",
"=",
"{",
"id",
":",
"$",
"(",
"'input:first'",
",",
"el",
")",
".",
"val",
"(",
")",
",",
"name",
":",
"$",
"(",
"'input:fir... | onResult is used to pre-process suggestions.
In our case we want to show current item if there is no results. | [
"onResult",
"is",
"used",
"to",
"pre",
"-",
"process",
"suggestions",
".",
"In",
"our",
"case",
"we",
"want",
"to",
"show",
"current",
"item",
"if",
"there",
"is",
"no",
"results",
"."
] | 48d9ce876cdc6ef459fcae70ac67b23229e85a5a | https://github.com/icanjs/grid-filter/blob/48d9ce876cdc6ef459fcae70ac67b23229e85a5a/src/grid-filter.js#L44-L51 | train | |
icanjs/grid-filter | src/grid-filter.js | function (item) {
// Check if it already exists in the suggestions list. Duplicates aren't allowed.
var exists = false;
for(var j = 0; j < suggestions.length; j++){
if(suggestions[j].attr('name').toLowerCase() === item.name.toLowerCase()){
exists=true;
... | javascript | function (item) {
// Check if it already exists in the suggestions list. Duplicates aren't allowed.
var exists = false;
for(var j = 0; j < suggestions.length; j++){
if(suggestions[j].attr('name').toLowerCase() === item.name.toLowerCase()){
exists=true;
... | [
"function",
"(",
"item",
")",
"{",
"// Check if it already exists in the suggestions list. Duplicates aren't allowed.",
"var",
"exists",
"=",
"false",
";",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"suggestions",
".",
"length",
";",
"j",
"++",
")",
"{",
... | onAdd is used to maintain the suggestion dropdown box and the searchTerms in the scope.
It is called internally by the jquery.tokenInput plugin when either the enter key
is pressed in the input box or a selection is made in the suggestions dropdown. | [
"onAdd",
"is",
"used",
"to",
"maintain",
"the",
"suggestion",
"dropdown",
"box",
"and",
"the",
"searchTerms",
"in",
"the",
"scope",
".",
"It",
"is",
"called",
"internally",
"by",
"the",
"jquery",
".",
"tokenInput",
"plugin",
"when",
"either",
"the",
"enter",... | 48d9ce876cdc6ef459fcae70ac67b23229e85a5a | https://github.com/icanjs/grid-filter/blob/48d9ce876cdc6ef459fcae70ac67b23229e85a5a/src/grid-filter.js#L58-L75 | train | |
icanjs/grid-filter | src/grid-filter.js | function (item) {
var searchTerms = self.viewModel.attr('searchTerms').attr(),
searchTerm = item && (item.id || item.name || item);
searchTerms.splice(searchTerms.indexOf(searchTerm), 1);
// We are using searchTerms's setter to execute the filter, so have to set the pro... | javascript | function (item) {
var searchTerms = self.viewModel.attr('searchTerms').attr(),
searchTerm = item && (item.id || item.name || item);
searchTerms.splice(searchTerms.indexOf(searchTerm), 1);
// We are using searchTerms's setter to execute the filter, so have to set the pro... | [
"function",
"(",
"item",
")",
"{",
"var",
"searchTerms",
"=",
"self",
".",
"viewModel",
".",
"attr",
"(",
"'searchTerms'",
")",
".",
"attr",
"(",
")",
",",
"searchTerm",
"=",
"item",
"&&",
"(",
"item",
".",
"id",
"||",
"item",
".",
"name",
"||",
"i... | onDelete is used to remove items from searchTerms in the scope. It is called internally
by the jquery.tokenInput plugin when a tag gets removed from the input box. | [
"onDelete",
"is",
"used",
"to",
"remove",
"items",
"from",
"searchTerms",
"in",
"the",
"scope",
".",
"It",
"is",
"called",
"internally",
"by",
"the",
"jquery",
".",
"tokenInput",
"plugin",
"when",
"a",
"tag",
"gets",
"removed",
"from",
"the",
"input",
"box... | 48d9ce876cdc6ef459fcae70ac67b23229e85a5a | https://github.com/icanjs/grid-filter/blob/48d9ce876cdc6ef459fcae70ac67b23229e85a5a/src/grid-filter.js#L81-L87 | train | |
Pocketbrain/native-ads-web-ad-library | src/page.js | xPath | function xPath(xPathString) {
var xResult = document.evaluate(xPathString, document, null, 0, null);
var xNodes = [];
var xRes = xResult.iterateNext();
while (xRes) {
xNodes.push(xRes);
xRes = xResult.iterateNext();
}
return xNodes;
} | javascript | function xPath(xPathString) {
var xResult = document.evaluate(xPathString, document, null, 0, null);
var xNodes = [];
var xRes = xResult.iterateNext();
while (xRes) {
xNodes.push(xRes);
xRes = xResult.iterateNext();
}
return xNodes;
} | [
"function",
"xPath",
"(",
"xPathString",
")",
"{",
"var",
"xResult",
"=",
"document",
".",
"evaluate",
"(",
"xPathString",
",",
"document",
",",
"null",
",",
"0",
",",
"null",
")",
";",
"var",
"xNodes",
"=",
"[",
"]",
";",
"var",
"xRes",
"=",
"xResul... | Evaluates xPath on a page
@param {string} xPathString - The Xpath string to evaluate
@returns {Array.<HTMLElement>} - An array of the found HTML elements | [
"Evaluates",
"xPath",
"on",
"a",
"page"
] | aafee1c42e0569ee77f334fc2c4eb71eb146957e | https://github.com/Pocketbrain/native-ads-web-ad-library/blob/aafee1c42e0569ee77f334fc2c4eb71eb146957e/src/page.js#L25-L35 | train |
Pocketbrain/native-ads-web-ad-library | src/page.js | execWaitReadyFunctions | function execWaitReadyFunctions() {
if (isReady()) {
logger.info('Page is ready. Executing ' + callbacksOnReady.length + ' functions that are waiting.');
for (var i = 0; i < callbacksOnReady.length; i++) {
var callback = callbacksOnReady[i];
callback();
}
}
} | javascript | function execWaitReadyFunctions() {
if (isReady()) {
logger.info('Page is ready. Executing ' + callbacksOnReady.length + ' functions that are waiting.');
for (var i = 0; i < callbacksOnReady.length; i++) {
var callback = callbacksOnReady[i];
callback();
}
}
} | [
"function",
"execWaitReadyFunctions",
"(",
")",
"{",
"if",
"(",
"isReady",
"(",
")",
")",
"{",
"logger",
".",
"info",
"(",
"'Page is ready. Executing '",
"+",
"callbacksOnReady",
".",
"length",
"+",
"' functions that are waiting.'",
")",
";",
"for",
"(",
"var",
... | Execute all the functions that are waiting for the page to finish loading | [
"Execute",
"all",
"the",
"functions",
"that",
"are",
"waiting",
"for",
"the",
"page",
"to",
"finish",
"loading"
] | aafee1c42e0569ee77f334fc2c4eb71eb146957e | https://github.com/Pocketbrain/native-ads-web-ad-library/blob/aafee1c42e0569ee77f334fc2c4eb71eb146957e/src/page.js#L52-L60 | train |
Pocketbrain/native-ads-web-ad-library | src/page.js | whenReady | function whenReady(funcToExecute) {
if (isReady()) {
logger.info('Page is already loaded, instantly executing!');
funcToExecute();
return;
}
logger.info('Waiting for page to be ready');
callbacksOnReady.push(funcToExecute);
} | javascript | function whenReady(funcToExecute) {
if (isReady()) {
logger.info('Page is already loaded, instantly executing!');
funcToExecute();
return;
}
logger.info('Waiting for page to be ready');
callbacksOnReady.push(funcToExecute);
} | [
"function",
"whenReady",
"(",
"funcToExecute",
")",
"{",
"if",
"(",
"isReady",
"(",
")",
")",
"{",
"logger",
".",
"info",
"(",
"'Page is already loaded, instantly executing!'",
")",
";",
"funcToExecute",
"(",
")",
";",
"return",
";",
"}",
"logger",
".",
"inf... | Returns a promise that resolves when the page is ready
@param funcToExecute - The function to execute when the page is loaded | [
"Returns",
"a",
"promise",
"that",
"resolves",
"when",
"the",
"page",
"is",
"ready"
] | aafee1c42e0569ee77f334fc2c4eb71eb146957e | https://github.com/Pocketbrain/native-ads-web-ad-library/blob/aafee1c42e0569ee77f334fc2c4eb71eb146957e/src/page.js#L75-L84 | train |
Pocketbrain/native-ads-web-ad-library | src/page.js | function (adUnitSettings) {
var containers = adUnitSettings.containers;
var adContainers = [];
for (var i = 0; i < containers.length; i++) {
var container = containers[i];
var containerXPath = container.xPath;
var adContainerElements = xPath(containerXPath)... | javascript | function (adUnitSettings) {
var containers = adUnitSettings.containers;
var adContainers = [];
for (var i = 0; i < containers.length; i++) {
var container = containers[i];
var containerXPath = container.xPath;
var adContainerElements = xPath(containerXPath)... | [
"function",
"(",
"adUnitSettings",
")",
"{",
"var",
"containers",
"=",
"adUnitSettings",
".",
"containers",
";",
"var",
"adContainers",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"containers",
".",
"length",
";",
"i",
"++",
... | Gets the adcontainers on the page from the container xPath
@param adUnitSettings the settings for the adUnit to get the container of
@returns {Array.<Object>} the AdContainer object or null if not found | [
"Gets",
"the",
"adcontainers",
"on",
"the",
"page",
"from",
"the",
"container",
"xPath"
] | aafee1c42e0569ee77f334fc2c4eb71eb146957e | https://github.com/Pocketbrain/native-ads-web-ad-library/blob/aafee1c42e0569ee77f334fc2c4eb71eb146957e/src/page.js#L100-L124 | train | |
andreypopp/es6-destructuring-jstransform | visitors.js | render | function render(expr, traverse, path, state) {
if (isString(expr)) {
utils.append(expr, state);
} else if (Array.isArray(expr)) {
expr.forEach(function(w) {
render(w, traverse, path, state);
});
} else {
utils.move(expr.range[0], state);
traverse(expr, path, state);
utils.catchup(exp... | javascript | function render(expr, traverse, path, state) {
if (isString(expr)) {
utils.append(expr, state);
} else if (Array.isArray(expr)) {
expr.forEach(function(w) {
render(w, traverse, path, state);
});
} else {
utils.move(expr.range[0], state);
traverse(expr, path, state);
utils.catchup(exp... | [
"function",
"render",
"(",
"expr",
",",
"traverse",
",",
"path",
",",
"state",
")",
"{",
"if",
"(",
"isString",
"(",
"expr",
")",
")",
"{",
"utils",
".",
"append",
"(",
"expr",
",",
"state",
")",
";",
"}",
"else",
"if",
"(",
"Array",
".",
"isArra... | Render an expression
This is a helper which can render AST nodes, sting values or arrays which can
contain both of the types.
@param {Node|String|Array} expr Expression to render
@param {Function} traverse
@param {Object} path
@param {Object} state | [
"Render",
"an",
"expression"
] | c0f238286a323fa9d009e4da9ccb54f99e9efb0b | https://github.com/andreypopp/es6-destructuring-jstransform/blob/c0f238286a323fa9d009e4da9ccb54f99e9efb0b/visitors.js#L17-L29 | train |
andreypopp/es6-destructuring-jstransform | visitors.js | renderExpressionMemoized | function renderExpressionMemoized(expr, traverse, path, state) {
var evaluated;
if (expr.type === Syntax.Identifier) {
evaluated = expr.name;
} else if (isString(expr)) {
evaluated = expr;
} else {
evaluated = genID('var');
utils.append(evaluated + ' = ', state);
render(expr, traverse, path,... | javascript | function renderExpressionMemoized(expr, traverse, path, state) {
var evaluated;
if (expr.type === Syntax.Identifier) {
evaluated = expr.name;
} else if (isString(expr)) {
evaluated = expr;
} else {
evaluated = genID('var');
utils.append(evaluated + ' = ', state);
render(expr, traverse, path,... | [
"function",
"renderExpressionMemoized",
"(",
"expr",
",",
"traverse",
",",
"path",
",",
"state",
")",
"{",
"var",
"evaluated",
";",
"if",
"(",
"expr",
".",
"type",
"===",
"Syntax",
".",
"Identifier",
")",
"{",
"evaluated",
"=",
"expr",
".",
"name",
";",
... | Render expression into a variable declaration and return its id.
If we destructure is an identifier (or a string) we use its "value"
directly, otherwise we cache it in variable declaration to prevent extra
"effectful" evaluations.
@param {Node|String|Array} expr Expression to render
@param {Function} traverse
@param ... | [
"Render",
"expression",
"into",
"a",
"variable",
"declaration",
"and",
"return",
"its",
"id",
"."
] | c0f238286a323fa9d009e4da9ccb54f99e9efb0b | https://github.com/andreypopp/es6-destructuring-jstransform/blob/c0f238286a323fa9d009e4da9ccb54f99e9efb0b/visitors.js#L43-L57 | train |
andreypopp/es6-destructuring-jstransform | visitors.js | renderDesructuration | function renderDesructuration(pattern, expr, traverse, path, state) {
utils.catchupNewlines(pattern.range[1], state);
var id;
if (pattern.type === Syntax.ObjectPattern && pattern.properties.length === 1) {
id = expr;
} else if (pattern.type === Syntax.ArrayPattern && pattern.elements.length === 1) {
i... | javascript | function renderDesructuration(pattern, expr, traverse, path, state) {
utils.catchupNewlines(pattern.range[1], state);
var id;
if (pattern.type === Syntax.ObjectPattern && pattern.properties.length === 1) {
id = expr;
} else if (pattern.type === Syntax.ArrayPattern && pattern.elements.length === 1) {
i... | [
"function",
"renderDesructuration",
"(",
"pattern",
",",
"expr",
",",
"traverse",
",",
"path",
",",
"state",
")",
"{",
"utils",
".",
"catchupNewlines",
"(",
"pattern",
".",
"range",
"[",
"1",
"]",
",",
"state",
")",
";",
"var",
"id",
";",
"if",
"(",
... | Render destructuration of the `expr` using provided `pattern`.
@param {Node} pattern Pattern to use for destructuration
@param {Node|String|Array} expr Expression to destructure
@param {Function} traverse
@param {Object} path
@param {Object} state | [
"Render",
"destructuration",
"of",
"the",
"expr",
"using",
"provided",
"pattern",
"."
] | c0f238286a323fa9d009e4da9ccb54f99e9efb0b | https://github.com/andreypopp/es6-destructuring-jstransform/blob/c0f238286a323fa9d009e4da9ccb54f99e9efb0b/visitors.js#L68-L118 | train |
phated/grunt-enyo | tasks/init/bootplate/root/enyo/source/touch/gesture.js | function(inPositions) {
var p = inPositions;
// yay math!, rad -> deg
var a = Math.asin(p.y / p.h) * (180 / Math.PI);
// fix for range limits of asin (-90 to 90)
// Quadrants II and III
if (p.x < 0) {
a = 180 - a;
}
// Quadrant IV
if (p.x > 0 && p.y < 0) {
a += 360;
}
return a;
... | javascript | function(inPositions) {
var p = inPositions;
// yay math!, rad -> deg
var a = Math.asin(p.y / p.h) * (180 / Math.PI);
// fix for range limits of asin (-90 to 90)
// Quadrants II and III
if (p.x < 0) {
a = 180 - a;
}
// Quadrant IV
if (p.x > 0 && p.y < 0) {
a += 360;
}
return a;
... | [
"function",
"(",
"inPositions",
")",
"{",
"var",
"p",
"=",
"inPositions",
";",
"// yay math!, rad -> deg",
"var",
"a",
"=",
"Math",
".",
"asin",
"(",
"p",
".",
"y",
"/",
"p",
".",
"h",
")",
"*",
"(",
"180",
"/",
"Math",
".",
"PI",
")",
";",
"// f... | find rotation angle | [
"find",
"rotation",
"angle"
] | d2990ee4cd85eea8db4108c43086c6d8c3c90c30 | https://github.com/phated/grunt-enyo/blob/d2990ee4cd85eea8db4108c43086c6d8c3c90c30/tasks/init/bootplate/root/enyo/source/touch/gesture.js#L81-L95 | train | |
phated/grunt-enyo | tasks/init/bootplate/root/enyo/source/touch/gesture.js | function(inPositions) {
// the least recent touch and the most recent touch determine the bounding box of the gesture event
var p = inPositions;
// center the first touch as 0,0
return {
magnitude: p.h,
xcenter: Math.abs(Math.round(p.fx + (p.x / 2))),
ycenter: Math.abs(Math.round(p.fy + (p.y / 2... | javascript | function(inPositions) {
// the least recent touch and the most recent touch determine the bounding box of the gesture event
var p = inPositions;
// center the first touch as 0,0
return {
magnitude: p.h,
xcenter: Math.abs(Math.round(p.fx + (p.x / 2))),
ycenter: Math.abs(Math.round(p.fy + (p.y / 2... | [
"function",
"(",
"inPositions",
")",
"{",
"// the least recent touch and the most recent touch determine the bounding box of the gesture event",
"var",
"p",
"=",
"inPositions",
";",
"// center the first touch as 0,0",
"return",
"{",
"magnitude",
":",
"p",
".",
"h",
",",
"xcen... | find bounding box | [
"find",
"bounding",
"box"
] | d2990ee4cd85eea8db4108c43086c6d8c3c90c30 | https://github.com/phated/grunt-enyo/blob/d2990ee4cd85eea8db4108c43086c6d8c3c90c30/tasks/init/bootplate/root/enyo/source/touch/gesture.js#L97-L106 | train | |
phated/grunt-enyo | tasks/init/enyo/root/enyo/source/kernel/Component.js | function(inInfos, inCommonInfo) {
if (inInfos) {
var cs = [];
for (var i=0, ci; (ci=inInfos[i]); i++) {
cs.push(this._createComponent(ci, inCommonInfo));
}
return cs;
}
} | javascript | function(inInfos, inCommonInfo) {
if (inInfos) {
var cs = [];
for (var i=0, ci; (ci=inInfos[i]); i++) {
cs.push(this._createComponent(ci, inCommonInfo));
}
return cs;
}
} | [
"function",
"(",
"inInfos",
",",
"inCommonInfo",
")",
"{",
"if",
"(",
"inInfos",
")",
"{",
"var",
"cs",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"ci",
";",
"(",
"ci",
"=",
"inInfos",
"[",
"i",
"]",
")",
";",
"i",
"++",
")"... | Creates Components as defined by the array of configurations _inInfo_.
Each configuration in _inInfo_ is combined with _inCommonInfo_ as
described in _createComponent_.
_createComponents_ returns an array of references to the created components.
ask foo to create components _bar_ and _zot_, but set the owner of
both ... | [
"Creates",
"Components",
"as",
"defined",
"by",
"the",
"array",
"of",
"configurations",
"_inInfo_",
".",
"Each",
"configuration",
"in",
"_inInfo_",
"is",
"combined",
"with",
"_inCommonInfo_",
"as",
"described",
"in",
"_createComponent_",
"."
] | d2990ee4cd85eea8db4108c43086c6d8c3c90c30 | https://github.com/phated/grunt-enyo/blob/d2990ee4cd85eea8db4108c43086c6d8c3c90c30/tasks/init/enyo/root/enyo/source/kernel/Component.js#L249-L257 | train | |
phated/grunt-enyo | tasks/init/enyo/root/enyo/source/kernel/Component.js | function(inMethodName, inEvent, inSender) {
var fn = inMethodName && this[inMethodName];
if (fn) {
return fn.call(this, inSender || this, inEvent);
}
} | javascript | function(inMethodName, inEvent, inSender) {
var fn = inMethodName && this[inMethodName];
if (fn) {
return fn.call(this, inSender || this, inEvent);
}
} | [
"function",
"(",
"inMethodName",
",",
"inEvent",
",",
"inSender",
")",
"{",
"var",
"fn",
"=",
"inMethodName",
"&&",
"this",
"[",
"inMethodName",
"]",
";",
"if",
"(",
"fn",
")",
"{",
"return",
"fn",
".",
"call",
"(",
"this",
",",
"inSender",
"||",
"th... | Dispatch the event to named delegate inMethodName, if it exists.
Sub-kinds may re-route dispatches.
Note that both 'handlers' events and events delegated from owned controls
arrive here. If you need to handle these differently, you may
need to also override dispatchEvent. | [
"Dispatch",
"the",
"event",
"to",
"named",
"delegate",
"inMethodName",
"if",
"it",
"exists",
".",
"Sub",
"-",
"kinds",
"may",
"re",
"-",
"route",
"dispatches",
".",
"Note",
"that",
"both",
"handlers",
"events",
"and",
"events",
"delegated",
"from",
"owned",
... | d2990ee4cd85eea8db4108c43086c6d8c3c90c30 | https://github.com/phated/grunt-enyo/blob/d2990ee4cd85eea8db4108c43086c6d8c3c90c30/tasks/init/enyo/root/enyo/source/kernel/Component.js#L384-L389 | train | |
phated/grunt-enyo | tasks/init/enyo/root/enyo/source/kernel/Component.js | function(inMessageName, inMessage, inSender) {
//this.log(inMessageName, (inSender || this).name, "=>", this.name);
if (this.dispatchEvent(inMessageName, inMessage, inSender)) {
return true;
}
this.waterfallDown(inMessageName, inMessage, inSender || this);
} | javascript | function(inMessageName, inMessage, inSender) {
//this.log(inMessageName, (inSender || this).name, "=>", this.name);
if (this.dispatchEvent(inMessageName, inMessage, inSender)) {
return true;
}
this.waterfallDown(inMessageName, inMessage, inSender || this);
} | [
"function",
"(",
"inMessageName",
",",
"inMessage",
",",
"inSender",
")",
"{",
"//this.log(inMessageName, (inSender || this).name, \"=>\", this.name);\r",
"if",
"(",
"this",
".",
"dispatchEvent",
"(",
"inMessageName",
",",
"inMessage",
",",
"inSender",
")",
")",
"{",
... | Sends a message to myself and my descendants. | [
"Sends",
"a",
"message",
"to",
"myself",
"and",
"my",
"descendants",
"."
] | d2990ee4cd85eea8db4108c43086c6d8c3c90c30 | https://github.com/phated/grunt-enyo/blob/d2990ee4cd85eea8db4108c43086c6d8c3c90c30/tasks/init/enyo/root/enyo/source/kernel/Component.js#L393-L399 | train | |
skerit/creatures | lib/creatures_application.js | restoreState | function restoreState(top_err) {
if (previous_state === true) {
that.pause(function madePaused(err) {
// Ignore errors?
callback(top_err);
});
} else {
callback(top_err);
}
} | javascript | function restoreState(top_err) {
if (previous_state === true) {
that.pause(function madePaused(err) {
// Ignore errors?
callback(top_err);
});
} else {
callback(top_err);
}
} | [
"function",
"restoreState",
"(",
"top_err",
")",
"{",
"if",
"(",
"previous_state",
"===",
"true",
")",
"{",
"that",
".",
"pause",
"(",
"function",
"madePaused",
"(",
"err",
")",
"{",
"// Ignore errors?",
"callback",
"(",
"top_err",
")",
";",
"}",
")",
";... | Function to restate paused state | [
"Function",
"to",
"restate",
"paused",
"state"
] | 019c2f00ef9f1bc9bdfd30470676248b0d82dfda | https://github.com/skerit/creatures/blob/019c2f00ef9f1bc9bdfd30470676248b0d82dfda/lib/creatures_application.js#L1536-L1545 | train |
skerit/creatures | lib/creatures_application.js | done | function done(err) {
that._gcw = 'done_get_creatures';
bomb.defuse();
// Unsee the 'getting_creatures' event
that.unsee('getting_creatures');
// Call next on the next tick (in case we call back with an error)
Blast.nextTick(next);
if (err) {
that.log('error', 'Error getting creatures: ' + ... | javascript | function done(err) {
that._gcw = 'done_get_creatures';
bomb.defuse();
// Unsee the 'getting_creatures' event
that.unsee('getting_creatures');
// Call next on the next tick (in case we call back with an error)
Blast.nextTick(next);
if (err) {
that.log('error', 'Error getting creatures: ' + ... | [
"function",
"done",
"(",
"err",
")",
"{",
"that",
".",
"_gcw",
"=",
"'done_get_creatures'",
";",
"bomb",
".",
"defuse",
"(",
")",
";",
"// Unsee the 'getting_creatures' event",
"that",
".",
"unsee",
"(",
"'getting_creatures'",
")",
";",
"// Call next on the next t... | Function that'll call next on the queue & the callback | [
"Function",
"that",
"ll",
"call",
"next",
"on",
"the",
"queue",
"&",
"the",
"callback"
] | 019c2f00ef9f1bc9bdfd30470676248b0d82dfda | https://github.com/skerit/creatures/blob/019c2f00ef9f1bc9bdfd30470676248b0d82dfda/lib/creatures_application.js#L1768-L1796 | train |
nodys/htmly | support/updatedoc.js | flux | function flux (path) {
return function (done) {
fs.createReadStream(resolve(__dirname, path))
.pipe(docflux())
.pipe(docflux.markdown({depth: DEPTH, indent: INDENT}))
.pipe(concat(function (data) {
done(null, data.toString())
}))
}
} | javascript | function flux (path) {
return function (done) {
fs.createReadStream(resolve(__dirname, path))
.pipe(docflux())
.pipe(docflux.markdown({depth: DEPTH, indent: INDENT}))
.pipe(concat(function (data) {
done(null, data.toString())
}))
}
} | [
"function",
"flux",
"(",
"path",
")",
"{",
"return",
"function",
"(",
"done",
")",
"{",
"fs",
".",
"createReadStream",
"(",
"resolve",
"(",
"__dirname",
",",
"path",
")",
")",
".",
"pipe",
"(",
"docflux",
"(",
")",
")",
".",
"pipe",
"(",
"docflux",
... | Return a docflux transformer function
@param {String} path
Code source to read (relative path)
@return {Function}
Function for async.js | [
"Return",
"a",
"docflux",
"transformer",
"function"
] | 770560274167b7efd78cf56544ec72f52efb3fb8 | https://github.com/nodys/htmly/blob/770560274167b7efd78cf56544ec72f52efb3fb8/support/updatedoc.js#L38-L47 | train |
Endare/node-bb10 | lib/PushInitiator.js | PushInitiator | function PushInitiator(applicationId, password, contentProviderId, evaluation) {
this.applicationId = applicationId;
this.authToken = new Buffer(applicationId + ':' + password).toString('base64');
this.contentProviderId = contentProviderId;
this.isEvaluation = evaluation || false;
} | javascript | function PushInitiator(applicationId, password, contentProviderId, evaluation) {
this.applicationId = applicationId;
this.authToken = new Buffer(applicationId + ':' + password).toString('base64');
this.contentProviderId = contentProviderId;
this.isEvaluation = evaluation || false;
} | [
"function",
"PushInitiator",
"(",
"applicationId",
",",
"password",
",",
"contentProviderId",
",",
"evaluation",
")",
"{",
"this",
".",
"applicationId",
"=",
"applicationId",
";",
"this",
".",
"authToken",
"=",
"new",
"Buffer",
"(",
"applicationId",
"+",
"':'",
... | Creats a new PushInitiator object that can be used to push messages to the Push Protocol Gateway.
@param {Object} applicationId The unique application identifier provided by BlackBerry.
@param {Object} password The server side password provided by BlackBerry.
@param {Object} contentProviderId The CPID number provided ... | [
"Creats",
"a",
"new",
"PushInitiator",
"object",
"that",
"can",
"be",
"used",
"to",
"push",
"messages",
"to",
"the",
"Push",
"Protocol",
"Gateway",
"."
] | 69ac4806d1c02b0c7f4735f15f3ba3adc61b9617 | https://github.com/Endare/node-bb10/blob/69ac4806d1c02b0c7f4735f15f3ba3adc61b9617/lib/PushInitiator.js#L30-L35 | train |
shinuza/captain-core | lib/models/tags.js | findById | function findById(id, cb) {
db.getClient(function(err, client, done) {
client.query(SELECT_ID, [id], function(err, r) {
var result = r && r.rows[0];
if(!err && !result) err = new exceptions.NotFound();
if(err) {
cb(err);
done(err);
} else {
cb(null, result);
... | javascript | function findById(id, cb) {
db.getClient(function(err, client, done) {
client.query(SELECT_ID, [id], function(err, r) {
var result = r && r.rows[0];
if(!err && !result) err = new exceptions.NotFound();
if(err) {
cb(err);
done(err);
} else {
cb(null, result);
... | [
"function",
"findById",
"(",
"id",
",",
"cb",
")",
"{",
"db",
".",
"getClient",
"(",
"function",
"(",
"err",
",",
"client",
",",
"done",
")",
"{",
"client",
".",
"query",
"(",
"SELECT_ID",
",",
"[",
"id",
"]",
",",
"function",
"(",
"err",
",",
"r... | Finds a tag by `id`
`cb` is passed the matching tag or exceptions.NotFound
@param {Number} id
@param {Function} cb | [
"Finds",
"a",
"tag",
"by",
"id"
] | 02f3a404cdfca608e8726bbacc33e32fec484b21 | https://github.com/shinuza/captain-core/blob/02f3a404cdfca608e8726bbacc33e32fec484b21/lib/models/tags.js#L84-L98 | train |
shinuza/captain-core | lib/models/tags.js | create | function create(body, cb) {
var validates = Schema(body);
if(!validates) {
return cb(new exceptions.BadRequest());
}
body.slug = string.slugify(body.title);
var q = qb.insert(body);
db.getClient(function(err, client, done) {
client.query(q[0], q[1], function(err, r) {
if(err) {
if(e... | javascript | function create(body, cb) {
var validates = Schema(body);
if(!validates) {
return cb(new exceptions.BadRequest());
}
body.slug = string.slugify(body.title);
var q = qb.insert(body);
db.getClient(function(err, client, done) {
client.query(q[0], q[1], function(err, r) {
if(err) {
if(e... | [
"function",
"create",
"(",
"body",
",",
"cb",
")",
"{",
"var",
"validates",
"=",
"Schema",
"(",
"body",
")",
";",
"if",
"(",
"!",
"validates",
")",
"{",
"return",
"cb",
"(",
"new",
"exceptions",
".",
"BadRequest",
"(",
")",
")",
";",
"}",
"body",
... | Creates a new tag.
`cb` is passed the newly created tag, or:
* exceptions.BadRequest: if the `body` does not satisfy the schema
* exceptions.AlreadyExists: if a tag with the same slug already exists
@param {Object} body
@param {Function} cb | [
"Creates",
"a",
"new",
"tag",
"."
] | 02f3a404cdfca608e8726bbacc33e32fec484b21 | https://github.com/shinuza/captain-core/blob/02f3a404cdfca608e8726bbacc33e32fec484b21/lib/models/tags.js#L113-L137 | train |
shinuza/captain-core | lib/models/tags.js | all | function all(options, cb) {
var q
, page = Number(options.page) || 1
, limit = Number(options.limit) || conf.objects_by_page
, offset = (page - 1) * limit;
count(function(err, count) {
if(err) { return cb(err); }
q = select('LEFT JOIN');
q += ' LIMIT ' + limit + ' OFFSET ' + offset;
d... | javascript | function all(options, cb) {
var q
, page = Number(options.page) || 1
, limit = Number(options.limit) || conf.objects_by_page
, offset = (page - 1) * limit;
count(function(err, count) {
if(err) { return cb(err); }
q = select('LEFT JOIN');
q += ' LIMIT ' + limit + ' OFFSET ' + offset;
d... | [
"function",
"all",
"(",
"options",
",",
"cb",
")",
"{",
"var",
"q",
",",
"page",
"=",
"Number",
"(",
"options",
".",
"page",
")",
"||",
"1",
",",
"limit",
"=",
"Number",
"(",
"options",
".",
"limit",
")",
"||",
"conf",
".",
"objects_by_page",
",",
... | Finds all tags
@param {Object} options
@param {Function} cb | [
"Finds",
"all",
"tags"
] | 02f3a404cdfca608e8726bbacc33e32fec484b21 | https://github.com/shinuza/captain-core/blob/02f3a404cdfca608e8726bbacc33e32fec484b21/lib/models/tags.js#L212-L242 | train |
MikeyBurkman/eggnog | src/context.js | nodeJsGlobalResolverFn | function nodeJsGlobalResolverFn(normalizedId) {
var globalId = normalizedId.id;
var x = global[globalId];
if (!x) {
var msg = 'Could not find global Node module [' + globalId + ']';
throw new Error(buildMissingDepMsg(msg, globalId, Object.keys(global)));
}
return x;
} | javascript | function nodeJsGlobalResolverFn(normalizedId) {
var globalId = normalizedId.id;
var x = global[globalId];
if (!x) {
var msg = 'Could not find global Node module [' + globalId + ']';
throw new Error(buildMissingDepMsg(msg, globalId, Object.keys(global)));
}
return x;
} | [
"function",
"nodeJsGlobalResolverFn",
"(",
"normalizedId",
")",
"{",
"var",
"globalId",
"=",
"normalizedId",
".",
"id",
";",
"var",
"x",
"=",
"global",
"[",
"globalId",
"]",
";",
"if",
"(",
"!",
"x",
")",
"{",
"var",
"msg",
"=",
"'Could not find global Nod... | Returns a variable that available in the list of globals | [
"Returns",
"a",
"variable",
"that",
"available",
"in",
"the",
"list",
"of",
"globals"
] | bdd64778e2d791b479cdf18bce81654fc9671f31 | https://github.com/MikeyBurkman/eggnog/blob/bdd64778e2d791b479cdf18bce81654fc9671f31/src/context.js#L253-L261 | train |
MikeyBurkman/eggnog | src/context.js | nodeModulesResolverFn | function nodeModulesResolverFn(normalizedId) {
if (!nodeModulesAt) {
throw new Error('Before you can load external dependencies, you must specify where node_modules can be found by ' +
'setting the \'nodeModulesAt\' option when creating the context');
}
var extId = normalizedId.id;
var modulePath = pat... | javascript | function nodeModulesResolverFn(normalizedId) {
if (!nodeModulesAt) {
throw new Error('Before you can load external dependencies, you must specify where node_modules can be found by ' +
'setting the \'nodeModulesAt\' option when creating the context');
}
var extId = normalizedId.id;
var modulePath = pat... | [
"function",
"nodeModulesResolverFn",
"(",
"normalizedId",
")",
"{",
"if",
"(",
"!",
"nodeModulesAt",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Before you can load external dependencies, you must specify where node_modules can be found by '",
"+",
"'setting the \\'nodeModulesAt\\'... | Requires modules from the node_modules directory | [
"Requires",
"modules",
"from",
"the",
"node_modules",
"directory"
] | bdd64778e2d791b479cdf18bce81654fc9671f31 | https://github.com/MikeyBurkman/eggnog/blob/bdd64778e2d791b479cdf18bce81654fc9671f31/src/context.js#L269-L292 | train |
timkuijsten/node-idb-readable-stream | index.js | idbReadableStream | function idbReadableStream(db, storeName, opts) {
if (typeof db !== 'object') throw new TypeError('db must be an object')
if (typeof storeName !== 'string') throw new TypeError('storeName must be a string')
if (opts == null) opts = {}
if (typeof opts !== 'object') throw new TypeError('opts must be an object')
... | javascript | function idbReadableStream(db, storeName, opts) {
if (typeof db !== 'object') throw new TypeError('db must be an object')
if (typeof storeName !== 'string') throw new TypeError('storeName must be a string')
if (opts == null) opts = {}
if (typeof opts !== 'object') throw new TypeError('opts must be an object')
... | [
"function",
"idbReadableStream",
"(",
"db",
",",
"storeName",
",",
"opts",
")",
"{",
"if",
"(",
"typeof",
"db",
"!==",
"'object'",
")",
"throw",
"new",
"TypeError",
"(",
"'db must be an object'",
")",
"if",
"(",
"typeof",
"storeName",
"!==",
"'string'",
")",... | Iterate over an IndexedDB object store with a readable stream.
@param {IDBDatabase} db - IndexedDB instance
@param {String} storeName - name of the object store to iterate over
@param {Object} [opts]
Options:
@param {IDBKeyRange} opts.range - a valid IndexedDB key range
@param {IDBCursorDirection} opts.direction - on... | [
"Iterate",
"over",
"an",
"IndexedDB",
"object",
"store",
"with",
"a",
"readable",
"stream",
"."
] | b37424e5404ee631cccf563414cce0de1f867f8e | https://github.com/timkuijsten/node-idb-readable-stream/blob/b37424e5404ee631cccf563414cce0de1f867f8e/index.js#L38-L134 | train |
melvincarvalho/rdf-shell | bin/ls.js | bin | function bin(argv) {
var uri = argv[2]
if (!uri) {
console.error('uri is required')
}
shell.ls(uri, function(err, arr) {
for (i=0; i<arr.length; i++) {
console.log(arr[i])
}
})
} | javascript | function bin(argv) {
var uri = argv[2]
if (!uri) {
console.error('uri is required')
}
shell.ls(uri, function(err, arr) {
for (i=0; i<arr.length; i++) {
console.log(arr[i])
}
})
} | [
"function",
"bin",
"(",
"argv",
")",
"{",
"var",
"uri",
"=",
"argv",
"[",
"2",
"]",
"if",
"(",
"!",
"uri",
")",
"{",
"console",
".",
"error",
"(",
"'uri is required'",
")",
"}",
"shell",
".",
"ls",
"(",
"uri",
",",
"function",
"(",
"err",
",",
... | list the contents of a directory
@param {[type]} argv [description]
@return {[type]} [description] | [
"list",
"the",
"contents",
"of",
"a",
"directory"
] | bf2015f6f333855e69a18ce3ec9e917bbddfb425 | https://github.com/melvincarvalho/rdf-shell/blob/bf2015f6f333855e69a18ce3ec9e917bbddfb425/bin/ls.js#L10-L20 | train |
intervolga/bem-utils | lib/file-exist.js | fileExist | function fileExist(fileName) {
return new Promise((resolve, reject) => {
fs.stat(fileName, (err, stats) => {
if (err === null && stats.isFile()) {
resolve(fileName);
} else {
resolve(false);
}
});
});
} | javascript | function fileExist(fileName) {
return new Promise((resolve, reject) => {
fs.stat(fileName, (err, stats) => {
if (err === null && stats.isFile()) {
resolve(fileName);
} else {
resolve(false);
}
});
});
} | [
"function",
"fileExist",
"(",
"fileName",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"fs",
".",
"stat",
"(",
"fileName",
",",
"(",
"err",
",",
"stats",
")",
"=>",
"{",
"if",
"(",
"err",
"===",
"null",
... | Promisified "file exist" check
@param {String} fileName
@return {Promise} resolves to fileName if exist, false otherwise | [
"Promisified",
"file",
"exist",
"check"
] | 3b81bb9bc408275486175326dc7f35c563a46563 | https://github.com/intervolga/bem-utils/blob/3b81bb9bc408275486175326dc7f35c563a46563/lib/file-exist.js#L9-L19 | train |
iamchenxin/tagged-literals | lib/sql.js | SQL | function SQL(strs) {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
var values = [];
var text = strs.reduce(function (prev, curr, i) {
var arg = args[i - 1];
if (arg instanceof InsertValue) {
return... | javascript | function SQL(strs) {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
var values = [];
var text = strs.reduce(function (prev, curr, i) {
var arg = args[i - 1];
if (arg instanceof InsertValue) {
return... | [
"function",
"SQL",
"(",
"strs",
")",
"{",
"for",
"(",
"var",
"_len",
"=",
"arguments",
".",
"length",
",",
"args",
"=",
"Array",
"(",
"_len",
">",
"1",
"?",
"_len",
"-",
"1",
":",
"0",
")",
",",
"_key",
"=",
"1",
";",
"_key",
"<",
"_len",
";"... | for postgres sql | [
"for",
"postgres",
"sql"
] | 932f803ff4006be76a49fa12675f3fad1092c517 | https://github.com/iamchenxin/tagged-literals/blob/932f803ff4006be76a49fa12675f3fad1092c517/lib/sql.js#L26-L46 | train |
tunnckoCore/async-simple-iterator | index.js | AsyncSimpleIterator | function AsyncSimpleIterator (options) {
if (!(this instanceof AsyncSimpleIterator)) {
return new AsyncSimpleIterator(options)
}
this.defaultOptions(options)
AppBase.call(this)
this.on = utils.emitter.compose.call(this, 'on', this.options)
this.off = utils.emitter.compose.call(this, 'off', this.options)... | javascript | function AsyncSimpleIterator (options) {
if (!(this instanceof AsyncSimpleIterator)) {
return new AsyncSimpleIterator(options)
}
this.defaultOptions(options)
AppBase.call(this)
this.on = utils.emitter.compose.call(this, 'on', this.options)
this.off = utils.emitter.compose.call(this, 'off', this.options)... | [
"function",
"AsyncSimpleIterator",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"AsyncSimpleIterator",
")",
")",
"{",
"return",
"new",
"AsyncSimpleIterator",
"(",
"options",
")",
"}",
"this",
".",
"defaultOptions",
"(",
"options",
")",
... | > Initialize `AsyncSimpleIterator` with `options`.
**Example**
```js
var ctrl = require('async')
var AsyncSimpleIterator = require('async-simple-iterator').AsyncSimpleIterator
var fs = require('fs')
var base = new AsyncSimpleIterator({
settle: true,
beforeEach: function (val) {
console.log('before each:', val)
},
er... | [
">",
"Initialize",
"AsyncSimpleIterator",
"with",
"options",
"."
] | c08b8b7f431c9013961a7d7255ee6a4e38d293ed | https://github.com/tunnckoCore/async-simple-iterator/blob/c08b8b7f431c9013961a7d7255ee6a4e38d293ed/index.js#L52-L62 | train |
TribeMedia/tribemedia-kurento-client-elements-js | lib/complexTypes/MediaProfileSpecType.js | checkMediaProfileSpecType | function checkMediaProfileSpecType(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('WEBM|MP4|WEBM_VIDEO_ONLY|WEBM_AUDIO_ONLY|MP4_VIDEO_ONLY|MP4_AUDIO_ONLY'))
throw SyntaxError(key+' param is not one of [WEBM|MP4|WEBM_VIDEO_ON... | javascript | function checkMediaProfileSpecType(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('WEBM|MP4|WEBM_VIDEO_ONLY|WEBM_AUDIO_ONLY|MP4_VIDEO_ONLY|MP4_AUDIO_ONLY'))
throw SyntaxError(key+' param is not one of [WEBM|MP4|WEBM_VIDEO_ON... | [
"function",
"checkMediaProfileSpecType",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"typeof",
"value",
"!=",
"'string'",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param should be a String, not '",
"+",
"typeof",
"value",
")",
";",
"if",
"(",
"!",
... | Media Profile.
Currently WEBM and MP4 are supported.
@typedef elements/complexTypes.MediaProfileSpecType
@type {(WEBM|MP4|WEBM_VIDEO_ONLY|WEBM_AUDIO_ONLY|MP4_VIDEO_ONLY|MP4_AUDIO_ONLY)}
Checker for {@link elements/complexTypes.MediaProfileSpecType}
@memberof module:elements/complexTypes
@param {external:String} k... | [
"Media",
"Profile",
".",
"Currently",
"WEBM",
"and",
"MP4",
"are",
"supported",
"."
] | 1a5570f05bf8c2c25bbeceb4f96cb2770f634de9 | https://github.com/TribeMedia/tribemedia-kurento-client-elements-js/blob/1a5570f05bf8c2c25bbeceb4f96cb2770f634de9/lib/complexTypes/MediaProfileSpecType.js#L38-L45 | train |
uugolab/sycle | lib/sycle.js | createApplication | function createApplication(options) {
options = options || {};
var sapp = new Application();
sapp.sycle = sycle;
if (options.loadBuiltinModels) {
sapp.phase(require('./boot/builtin-models')());
}
return sapp;
} | javascript | function createApplication(options) {
options = options || {};
var sapp = new Application();
sapp.sycle = sycle;
if (options.loadBuiltinModels) {
sapp.phase(require('./boot/builtin-models')());
}
return sapp;
} | [
"function",
"createApplication",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"sapp",
"=",
"new",
"Application",
"(",
")",
";",
"sapp",
".",
"sycle",
"=",
"sycle",
";",
"if",
"(",
"options",
".",
"loadBuiltinModels",
... | Create an sycle application.
@param options
@returns {Application}
@api public | [
"Create",
"an",
"sycle",
"application",
"."
] | 90902246537860adee22664a584c66d72826b5bb | https://github.com/uugolab/sycle/blob/90902246537860adee22664a584c66d72826b5bb/lib/sycle.js#L15-L26 | train |
arpinum-oss/js-promising | benchmarks/queue.js | enqueueAll | function enqueueAll() {
for (let i = 0; i < count - 1; i++) {
enqueue();
}
return enqueue();
function enqueue() {
return queue.enqueue(() => new Date());
}
} | javascript | function enqueueAll() {
for (let i = 0; i < count - 1; i++) {
enqueue();
}
return enqueue();
function enqueue() {
return queue.enqueue(() => new Date());
}
} | [
"function",
"enqueueAll",
"(",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"count",
"-",
"1",
";",
"i",
"++",
")",
"{",
"enqueue",
"(",
")",
";",
"}",
"return",
"enqueue",
"(",
")",
";",
"function",
"enqueue",
"(",
")",
"{",
"r... | 100000 functions enqueued in 798 ms | [
"100000",
"functions",
"enqueued",
"in",
"798",
"ms"
] | 710712e7d2b1429bda92d21c420d79d16cc6160a | https://github.com/arpinum-oss/js-promising/blob/710712e7d2b1429bda92d21c420d79d16cc6160a/benchmarks/queue.js#L13-L22 | train |
zoopdoop/zoopinator | lib/zoopinator.js | bakeFolder | function bakeFolder(source, dest) {
var args = createArgs(source, dest, {});
wrapFunction('BakeFolder', args, function () {
args.files = fs.readdirSync(args.source);
args.filters = [filterHidden];
wrapFunction('FilterFiles', args, function () {
args.filters.forEach(function (filter) {
... | javascript | function bakeFolder(source, dest) {
var args = createArgs(source, dest, {});
wrapFunction('BakeFolder', args, function () {
args.files = fs.readdirSync(args.source);
args.filters = [filterHidden];
wrapFunction('FilterFiles', args, function () {
args.filters.forEach(function (filter) {
... | [
"function",
"bakeFolder",
"(",
"source",
",",
"dest",
")",
"{",
"var",
"args",
"=",
"createArgs",
"(",
"source",
",",
"dest",
",",
"{",
"}",
")",
";",
"wrapFunction",
"(",
"'BakeFolder'",
",",
"args",
",",
"function",
"(",
")",
"{",
"args",
".",
"fil... | processes all the files in a folder | [
"processes",
"all",
"the",
"files",
"in",
"a",
"folder"
] | 64526031b6657eec4e00dfd5cf3ec2dc0a4ddf01 | https://github.com/zoopdoop/zoopinator/blob/64526031b6657eec4e00dfd5cf3ec2dc0a4ddf01/lib/zoopinator.js#L125-L170 | train |
camshaft/pack-n-stack | lib/proto.js | defaults | function defaults(route, name, handle) {
if (typeof route === 'function') {
handle = route;
name = handle.name;
route = '/';
}
else if (typeof name === 'function') {
handle = name;
name = handle.name;
}
// A name needs to be provided
if (!name) throw new NameError();
// wrap sub-apps... | javascript | function defaults(route, name, handle) {
if (typeof route === 'function') {
handle = route;
name = handle.name;
route = '/';
}
else if (typeof name === 'function') {
handle = name;
name = handle.name;
}
// A name needs to be provided
if (!name) throw new NameError();
// wrap sub-apps... | [
"function",
"defaults",
"(",
"route",
",",
"name",
",",
"handle",
")",
"{",
"if",
"(",
"typeof",
"route",
"===",
"'function'",
")",
"{",
"handle",
"=",
"route",
";",
"name",
"=",
"handle",
".",
"name",
";",
"route",
"=",
"'/'",
";",
"}",
"else",
"i... | Default the parameters
@api private | [
"Default",
"the",
"parameters"
] | ec5fe9a4cb9895b89e137e966a4eaffb7931881c | https://github.com/camshaft/pack-n-stack/blob/ec5fe9a4cb9895b89e137e966a4eaffb7931881c/lib/proto.js#L224-L258 | train |
camshaft/pack-n-stack | lib/proto.js | NameError | function NameError(message) {
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.name = 'Middleware Name Error';
this.message = message || 'The argument must be a named function or supply a name';
} | javascript | function NameError(message) {
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.name = 'Middleware Name Error';
this.message = message || 'The argument must be a named function or supply a name';
} | [
"function",
"NameError",
"(",
"message",
")",
"{",
"Error",
".",
"call",
"(",
"this",
")",
";",
"Error",
".",
"captureStackTrace",
"(",
"this",
",",
"arguments",
".",
"callee",
")",
";",
"this",
".",
"name",
"=",
"'Middleware Name Error'",
";",
"this",
"... | errors
Define an error for middleware not being named | [
"errors",
"Define",
"an",
"error",
"for",
"middleware",
"not",
"being",
"named"
] | ec5fe9a4cb9895b89e137e966a4eaffb7931881c | https://github.com/camshaft/pack-n-stack/blob/ec5fe9a4cb9895b89e137e966a4eaffb7931881c/lib/proto.js#L265-L270 | train |
camshaft/pack-n-stack | lib/proto.js | ExistsError | function ExistsError(name, message) {
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.name = 'Middleware Exists Error';
this.message = message || 'Middleware named ' + name + ' already exists. Provide an alternative name.';
} | javascript | function ExistsError(name, message) {
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.name = 'Middleware Exists Error';
this.message = message || 'Middleware named ' + name + ' already exists. Provide an alternative name.';
} | [
"function",
"ExistsError",
"(",
"name",
",",
"message",
")",
"{",
"Error",
".",
"call",
"(",
"this",
")",
";",
"Error",
".",
"captureStackTrace",
"(",
"this",
",",
"arguments",
".",
"callee",
")",
";",
"this",
".",
"name",
"=",
"'Middleware Exists Error'",... | Define an error for middleware already in the stack | [
"Define",
"an",
"error",
"for",
"middleware",
"already",
"in",
"the",
"stack"
] | ec5fe9a4cb9895b89e137e966a4eaffb7931881c | https://github.com/camshaft/pack-n-stack/blob/ec5fe9a4cb9895b89e137e966a4eaffb7931881c/lib/proto.js#L276-L281 | train |
camshaft/pack-n-stack | lib/proto.js | NotFoundError | function NotFoundError(name) {
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.name = 'Middleware Not Found Error';
this.message = name + ' not found in the current stack';
} | javascript | function NotFoundError(name) {
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.name = 'Middleware Not Found Error';
this.message = name + ' not found in the current stack';
} | [
"function",
"NotFoundError",
"(",
"name",
")",
"{",
"Error",
".",
"call",
"(",
"this",
")",
";",
"Error",
".",
"captureStackTrace",
"(",
"this",
",",
"arguments",
".",
"callee",
")",
";",
"this",
".",
"name",
"=",
"'Middleware Not Found Error'",
";",
"this... | Define an error for middleware not found in the stack | [
"Define",
"an",
"error",
"for",
"middleware",
"not",
"found",
"in",
"the",
"stack"
] | ec5fe9a4cb9895b89e137e966a4eaffb7931881c | https://github.com/camshaft/pack-n-stack/blob/ec5fe9a4cb9895b89e137e966a4eaffb7931881c/lib/proto.js#L287-L292 | train |
AndreasMadsen/immortal | lib/core/process.js | Process | function Process(settings) {
// save arguments
this.settings = settings;
// build args
this.args = [settings.file].concat(settings.args || []);
// build env
this.env = helpers.mergeObject({}, settings.env || process.env);
if (settings.options) {
this.env.spawnOptions = JSON.stringify... | javascript | function Process(settings) {
// save arguments
this.settings = settings;
// build args
this.args = [settings.file].concat(settings.args || []);
// build env
this.env = helpers.mergeObject({}, settings.env || process.env);
if (settings.options) {
this.env.spawnOptions = JSON.stringify... | [
"function",
"Process",
"(",
"settings",
")",
"{",
"// save arguments",
"this",
".",
"settings",
"=",
"settings",
";",
"// build args",
"this",
".",
"args",
"=",
"[",
"settings",
".",
"file",
"]",
".",
"concat",
"(",
"settings",
".",
"args",
"||",
"[",
"]... | this constrcutor will spawn a new process using a option object | [
"this",
"constrcutor",
"will",
"spawn",
"a",
"new",
"process",
"using",
"a",
"option",
"object"
] | c1ab5a4287a543fdfd980604a9e9927d663a9ef2 | https://github.com/AndreasMadsen/immortal/blob/c1ab5a4287a543fdfd980604a9e9927d663a9ef2/lib/core/process.js#L17-L48 | train |
AndreasMadsen/immortal | lib/core/process.js | function () {
var suicide = self.suicide;
self.suicide = false;
self.alive = false;
self.emit('stop', suicide);
} | javascript | function () {
var suicide = self.suicide;
self.suicide = false;
self.alive = false;
self.emit('stop', suicide);
} | [
"function",
"(",
")",
"{",
"var",
"suicide",
"=",
"self",
".",
"suicide",
";",
"self",
".",
"suicide",
"=",
"false",
";",
"self",
".",
"alive",
"=",
"false",
";",
"self",
".",
"emit",
"(",
"'stop'",
",",
"suicide",
")",
";",
"}"
] | handle process stdio close event | [
"handle",
"process",
"stdio",
"close",
"event"
] | c1ab5a4287a543fdfd980604a9e9927d663a9ef2 | https://github.com/AndreasMadsen/immortal/blob/c1ab5a4287a543fdfd980604a9e9927d663a9ef2/lib/core/process.js#L134-L139 | train | |
AndreasMadsen/immortal | lib/core/process.js | forceClose | function forceClose(channel) {
if (!channel) return;
var destroyer = setTimeout(function () {
channel.destroy();
}, 200);
channel.once('close', function () {
clearTimeout(destroyer);
});
} | javascript | function forceClose(channel) {
if (!channel) return;
var destroyer = setTimeout(function () {
channel.destroy();
}, 200);
channel.once('close', function () {
clearTimeout(destroyer);
});
} | [
"function",
"forceClose",
"(",
"channel",
")",
"{",
"if",
"(",
"!",
"channel",
")",
"return",
";",
"var",
"destroyer",
"=",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"channel",
".",
"destroy",
"(",
")",
";",
"}",
",",
"200",
")",
";",
"channel",
... | close all streams | [
"close",
"all",
"streams"
] | c1ab5a4287a543fdfd980604a9e9927d663a9ef2 | https://github.com/AndreasMadsen/immortal/blob/c1ab5a4287a543fdfd980604a9e9927d663a9ef2/lib/core/process.js#L166-L176 | train |
AndreasMadsen/immortal | lib/core/process.js | interceptDeath | function interceptDeath(process, events) {
var closeEvent = helpers.support.close;
// all channels are closed
process.once(closeEvent ? 'close' : 'exit', events.close);
// the process died
if (closeEvent) {
process.once('exit', events.exit);
} else {
// intercept internal onexit c... | javascript | function interceptDeath(process, events) {
var closeEvent = helpers.support.close;
// all channels are closed
process.once(closeEvent ? 'close' : 'exit', events.close);
// the process died
if (closeEvent) {
process.once('exit', events.exit);
} else {
// intercept internal onexit c... | [
"function",
"interceptDeath",
"(",
"process",
",",
"events",
")",
"{",
"var",
"closeEvent",
"=",
"helpers",
".",
"support",
".",
"close",
";",
"// all channels are closed",
"process",
".",
"once",
"(",
"closeEvent",
"?",
"'close'",
":",
"'exit'",
",",
"events"... | An helper function there will intercept internal exit event if necessary | [
"An",
"helper",
"function",
"there",
"will",
"intercept",
"internal",
"exit",
"event",
"if",
"necessary"
] | c1ab5a4287a543fdfd980604a9e9927d663a9ef2 | https://github.com/AndreasMadsen/immortal/blob/c1ab5a4287a543fdfd980604a9e9927d663a9ef2/lib/core/process.js#L204-L222 | train |
DearDesi/desirae | lib/browser-adapters.js | hashsum | function hashsum(hash, str) {
// you have to convert from string to array buffer
var ab
// you have to represent the algorithm as an object
, algo = { name: algos[hash] }
;
if ('string' === typeof str) {
ab = str2ab(str);
} else {
ab = str;
}
... | javascript | function hashsum(hash, str) {
// you have to convert from string to array buffer
var ab
// you have to represent the algorithm as an object
, algo = { name: algos[hash] }
;
if ('string' === typeof str) {
ab = str2ab(str);
} else {
ab = str;
}
... | [
"function",
"hashsum",
"(",
"hash",
",",
"str",
")",
"{",
"// you have to convert from string to array buffer",
"var",
"ab",
"// you have to represent the algorithm as an object ",
",",
"algo",
"=",
"{",
"name",
":",
"algos",
"[",
"hash",
"]",
"}",
";",
"if",
"(",
... | a more general convenience function | [
"a",
"more",
"general",
"convenience",
"function"
] | 7b043c898d668b07c39a154e215ddfa55444a5f2 | https://github.com/DearDesi/desirae/blob/7b043c898d668b07c39a154e215ddfa55444a5f2/lib/browser-adapters.js#L26-L49 | train |
DearDesi/desirae | lib/browser-adapters.js | ab2hex | function ab2hex(ab) {
var dv = new DataView(ab)
, i
, len
, hex = ''
, c
;
for (i = 0, len = dv.byteLength; i < len; i += 1) {
c = dv.getUint8(i).toString(16);
if (c.length < 2) {
c = '0' + c;
}
hex += c;
}
ret... | javascript | function ab2hex(ab) {
var dv = new DataView(ab)
, i
, len
, hex = ''
, c
;
for (i = 0, len = dv.byteLength; i < len; i += 1) {
c = dv.getUint8(i).toString(16);
if (c.length < 2) {
c = '0' + c;
}
hex += c;
}
ret... | [
"function",
"ab2hex",
"(",
"ab",
")",
"{",
"var",
"dv",
"=",
"new",
"DataView",
"(",
"ab",
")",
",",
"i",
",",
"len",
",",
"hex",
"=",
"''",
",",
"c",
";",
"for",
"(",
"i",
"=",
"0",
",",
"len",
"=",
"dv",
".",
"byteLength",
";",
"i",
"<",
... | convert from arraybuffer to hex | [
"convert",
"from",
"arraybuffer",
"to",
"hex"
] | 7b043c898d668b07c39a154e215ddfa55444a5f2 | https://github.com/DearDesi/desirae/blob/7b043c898d668b07c39a154e215ddfa55444a5f2/lib/browser-adapters.js#L52-L71 | train |
DearDesi/desirae | lib/browser-adapters.js | str2ab | function str2ab(stringToEncode, insertBom) {
stringToEncode = stringToEncode.replace(/\r\n/g,"\n");
var utftext = []
, n
, c
;
if (true === insertBom) {
utftext[0] = 0xef;
utftext[1] = 0xbb;
utftext[2] = 0xbf;
}
for (n = 0; n < stringT... | javascript | function str2ab(stringToEncode, insertBom) {
stringToEncode = stringToEncode.replace(/\r\n/g,"\n");
var utftext = []
, n
, c
;
if (true === insertBom) {
utftext[0] = 0xef;
utftext[1] = 0xbb;
utftext[2] = 0xbf;
}
for (n = 0; n < stringT... | [
"function",
"str2ab",
"(",
"stringToEncode",
",",
"insertBom",
")",
"{",
"stringToEncode",
"=",
"stringToEncode",
".",
"replace",
"(",
"/",
"\\r\\n",
"/",
"g",
",",
"\"\\n\"",
")",
";",
"var",
"utftext",
"=",
"[",
"]",
",",
"n",
",",
"c",
";",
"if",
... | convert from string to arraybuffer | [
"convert",
"from",
"string",
"to",
"arraybuffer"
] | 7b043c898d668b07c39a154e215ddfa55444a5f2 | https://github.com/DearDesi/desirae/blob/7b043c898d668b07c39a154e215ddfa55444a5f2/lib/browser-adapters.js#L74-L107 | train |
espadrine/fleau | fleau.js | escapeCurly | function escapeCurly (text, escapes) {
var newText = text.slice (0, escapes[0]);
for (var i = 0; i < escapes.length; i += 3) {
var from = escapes[i];
var to = escapes[i + 1];
var type = escapes[i + 2];
// Which escape do we have here?
if (type === 0) { newText += '{{';
} else { ... | javascript | function escapeCurly (text, escapes) {
var newText = text.slice (0, escapes[0]);
for (var i = 0; i < escapes.length; i += 3) {
var from = escapes[i];
var to = escapes[i + 1];
var type = escapes[i + 2];
// Which escape do we have here?
if (type === 0) { newText += '{{';
} else { ... | [
"function",
"escapeCurly",
"(",
"text",
",",
"escapes",
")",
"{",
"var",
"newText",
"=",
"text",
".",
"slice",
"(",
"0",
",",
"escapes",
"[",
"0",
"]",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"escapes",
".",
"length",
";",
"i... | Return a text where all escapes as defined in the toplevel function are indeed escaped. | [
"Return",
"a",
"text",
"where",
"all",
"escapes",
"as",
"defined",
"in",
"the",
"toplevel",
"function",
"are",
"indeed",
"escaped",
"."
] | 31b5f7783347deac4527a63afa522bc2e2ca8849 | https://github.com/espadrine/fleau/blob/31b5f7783347deac4527a63afa522bc2e2ca8849/fleau.js#L90-L103 | train |
espadrine/fleau | fleau.js | function(input, output, literal, cb) {
var text = '';
input.on ('data', function gatherer (data) {
text += '' + data; // Converting to UTF-8 string.
});
input.on ('end', function writer () {
try {
var write = function(data) { output.write(data); };
template(text)(write, literal);
} cat... | javascript | function(input, output, literal, cb) {
var text = '';
input.on ('data', function gatherer (data) {
text += '' + data; // Converting to UTF-8 string.
});
input.on ('end', function writer () {
try {
var write = function(data) { output.write(data); };
template(text)(write, literal);
} cat... | [
"function",
"(",
"input",
",",
"output",
",",
"literal",
",",
"cb",
")",
"{",
"var",
"text",
"=",
"''",
";",
"input",
".",
"on",
"(",
"'data'",
",",
"function",
"gatherer",
"(",
"data",
")",
"{",
"text",
"+=",
"''",
"+",
"data",
";",
"// Converting... | Main entry point. input and output are two streams, one readable, the other writable. | [
"Main",
"entry",
"point",
".",
"input",
"and",
"output",
"are",
"two",
"streams",
"one",
"readable",
"the",
"other",
"writable",
"."
] | 31b5f7783347deac4527a63afa522bc2e2ca8849 | https://github.com/espadrine/fleau/blob/31b5f7783347deac4527a63afa522bc2e2ca8849/fleau.js#L138-L158 | train | |
espadrine/fleau | fleau.js | function(input) {
var code = 'var $_isidentifier = ' + $_isidentifier.toString() + ';\n' +
// FIXME: could we remove that eval?
'eval((' + literaltovar.toString() + ')($_scope));\n';
code += 'var $_parsers = {\n';
var parsernames = Object.keys(parsers);
for (var i = 0; i < parsernames.length; i++) {
... | javascript | function(input) {
var code = 'var $_isidentifier = ' + $_isidentifier.toString() + ';\n' +
// FIXME: could we remove that eval?
'eval((' + literaltovar.toString() + ')($_scope));\n';
code += 'var $_parsers = {\n';
var parsernames = Object.keys(parsers);
for (var i = 0; i < parsernames.length; i++) {
... | [
"function",
"(",
"input",
")",
"{",
"var",
"code",
"=",
"'var $_isidentifier = '",
"+",
"$_isidentifier",
".",
"toString",
"(",
")",
"+",
"';\\n'",
"+",
"// FIXME: could we remove that eval?",
"'eval(('",
"+",
"literaltovar",
".",
"toString",
"(",
")",
"+",
"')(... | Like template, with a timeout and sandbox. | [
"Like",
"template",
"with",
"a",
"timeout",
"and",
"sandbox",
"."
] | 31b5f7783347deac4527a63afa522bc2e2ca8849 | https://github.com/espadrine/fleau/blob/31b5f7783347deac4527a63afa522bc2e2ca8849/fleau.js#L177-L205 | train | |
espadrine/fleau | fleau.js | function(input) {
var code = 'var $_parsers = {\n';
var parsernames = Object.keys(parsers);
for (var i = 0; i < parsernames.length; i++) {
code += ' ' + JSON.stringify(parsernames[i]) + ': ' +
parsers[parsernames[i]].toString() + ',\n';
};
code += '}\n';
code += compile(input) + '\nif (typeof $_e... | javascript | function(input) {
var code = 'var $_parsers = {\n';
var parsernames = Object.keys(parsers);
for (var i = 0; i < parsernames.length; i++) {
code += ' ' + JSON.stringify(parsernames[i]) + ': ' +
parsers[parsernames[i]].toString() + ',\n';
};
code += '}\n';
code += compile(input) + '\nif (typeof $_e... | [
"function",
"(",
"input",
")",
"{",
"var",
"code",
"=",
"'var $_parsers = {\\n'",
";",
"var",
"parsernames",
"=",
"Object",
".",
"keys",
"(",
"parsers",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"parsernames",
".",
"length",
";",
"i"... | string is a template. Return a function that takes a scope and returns a readable stream. | [
"string",
"is",
"a",
"template",
".",
"Return",
"a",
"function",
"that",
"takes",
"a",
"scope",
"and",
"returns",
"a",
"readable",
"stream",
"."
] | 31b5f7783347deac4527a63afa522bc2e2ca8849 | https://github.com/espadrine/fleau/blob/31b5f7783347deac4527a63afa522bc2e2ca8849/fleau.js#L209-L252 | train | |
Pocketbrain/native-ads-web-ad-library | src/ads/adManager.js | function (applicationId, deviceDetails, environment) {
if(!applicationId) {
logger.wtf('No applicationID specified');
}
this.applicationId = applicationId;
this.deviceDetails = deviceDetails;
this.environment = environment;
this._currentAds = [];
this._loadingAds = [];
this.... | javascript | function (applicationId, deviceDetails, environment) {
if(!applicationId) {
logger.wtf('No applicationID specified');
}
this.applicationId = applicationId;
this.deviceDetails = deviceDetails;
this.environment = environment;
this._currentAds = [];
this._loadingAds = [];
this.... | [
"function",
"(",
"applicationId",
",",
"deviceDetails",
",",
"environment",
")",
"{",
"if",
"(",
"!",
"applicationId",
")",
"{",
"logger",
".",
"wtf",
"(",
"'No applicationID specified'",
")",
";",
"}",
"this",
".",
"applicationId",
"=",
"applicationId",
";",
... | Creates a new instance of the adManager
@param applicationId - The ID of the application to receive ads for
@param deviceDetails - Details about the current users' device
@param environment - Environment specific functions.
@constructor | [
"Creates",
"a",
"new",
"instance",
"of",
"the",
"adManager"
] | aafee1c42e0569ee77f334fc2c4eb71eb146957e | https://github.com/Pocketbrain/native-ads-web-ad-library/blob/aafee1c42e0569ee77f334fc2c4eb71eb146957e/src/ads/adManager.js#L21-L32 | train | |
juttle/juttle-gmail-adapter | create_oauth_token.js | getNewToken | function getNewToken(credentials, oauth2Client, callback) {
var authUrl = oauth2Client.generateAuthUrl({
access_type: 'offline',
scope: SCOPES
});
console.log('Authorize this app by visiting this url: ', authUrl);
var rl = readline.createInterface({
input: process.stdin,
... | javascript | function getNewToken(credentials, oauth2Client, callback) {
var authUrl = oauth2Client.generateAuthUrl({
access_type: 'offline',
scope: SCOPES
});
console.log('Authorize this app by visiting this url: ', authUrl);
var rl = readline.createInterface({
input: process.stdin,
... | [
"function",
"getNewToken",
"(",
"credentials",
",",
"oauth2Client",
",",
"callback",
")",
"{",
"var",
"authUrl",
"=",
"oauth2Client",
".",
"generateAuthUrl",
"(",
"{",
"access_type",
":",
"'offline'",
",",
"scope",
":",
"SCOPES",
"}",
")",
";",
"console",
".... | Get and store new token after prompting for user authorization, and then
execute the given callback with the authorized OAuth2 client.
@param {Object} credentials The authorization client credentials.
@param {google.auth.OAuth2} oauth2Client The OAuth2 client to get token for.
@param {getEventsCallback} callback The c... | [
"Get",
"and",
"store",
"new",
"token",
"after",
"prompting",
"for",
"user",
"authorization",
"and",
"then",
"execute",
"the",
"given",
"callback",
"with",
"the",
"authorized",
"OAuth2",
"client",
"."
] | f535da123962c5b8e48ba4a2113469fed69248e3 | https://github.com/juttle/juttle-gmail-adapter/blob/f535da123962c5b8e48ba4a2113469fed69248e3/create_oauth_token.js#L56-L78 | train |
juttle/juttle-gmail-adapter | create_oauth_token.js | listLabels | function listLabels(auth) {
var gmail = google.gmail('v1');
gmail.users.labels.list({
auth: auth,
userId: 'me',
}, function(err, response) {
if (err) {
console.log('The API returned an error: ' + err);
return;
}
var labels = response.labels;
... | javascript | function listLabels(auth) {
var gmail = google.gmail('v1');
gmail.users.labels.list({
auth: auth,
userId: 'me',
}, function(err, response) {
if (err) {
console.log('The API returned an error: ' + err);
return;
}
var labels = response.labels;
... | [
"function",
"listLabels",
"(",
"auth",
")",
"{",
"var",
"gmail",
"=",
"google",
".",
"gmail",
"(",
"'v1'",
")",
";",
"gmail",
".",
"users",
".",
"labels",
".",
"list",
"(",
"{",
"auth",
":",
"auth",
",",
"userId",
":",
"'me'",
",",
"}",
",",
"fun... | Lists the labels in the user's account.
@param {google.auth.OAuth2} auth An authorized OAuth2 client. | [
"Lists",
"the",
"labels",
"in",
"the",
"user",
"s",
"account",
"."
] | f535da123962c5b8e48ba4a2113469fed69248e3 | https://github.com/juttle/juttle-gmail-adapter/blob/f535da123962c5b8e48ba4a2113469fed69248e3/create_oauth_token.js#L110-L131 | train |
juju/maraca | lib/delta-handlers.js | processDeltas | function processDeltas(deltas) {
let updates = {
changed: {},
removed: {}
};
deltas.forEach(delta => {
const entityType = delta[0];
const changeType = delta[1];
const entity = delta[2];
const key = _getEntityKey(entityType, entity);
if (!key) {
// We don't know how to manage this... | javascript | function processDeltas(deltas) {
let updates = {
changed: {},
removed: {}
};
deltas.forEach(delta => {
const entityType = delta[0];
const changeType = delta[1];
const entity = delta[2];
const key = _getEntityKey(entityType, entity);
if (!key) {
// We don't know how to manage this... | [
"function",
"processDeltas",
"(",
"deltas",
")",
"{",
"let",
"updates",
"=",
"{",
"changed",
":",
"{",
"}",
",",
"removed",
":",
"{",
"}",
"}",
";",
"deltas",
".",
"forEach",
"(",
"delta",
"=>",
"{",
"const",
"entityType",
"=",
"delta",
"[",
"0",
"... | Get the consolidated updates from the deltas.
@param {Array} deltas - The list of deltas.
@returns {Object} return - The delta updates.
@returns {Object} return.changed - The entities to change.
@returns {Object} return.removed - The entities to remove. | [
"Get",
"the",
"consolidated",
"updates",
"from",
"the",
"deltas",
"."
] | 0f245c6e09ef215fb4726bf7650320be2f49b6a0 | https://github.com/juju/maraca/blob/0f245c6e09ef215fb4726bf7650320be2f49b6a0/lib/delta-handlers.js#L13-L35 | train |
juju/maraca | lib/delta-handlers.js | _getEntityKey | function _getEntityKey(entityType, entity) {
switch (entityType) {
case 'remote-application':
case 'application':
case 'unit':
return entity.name;
case 'machine':
case 'relation':
return entity.id;
case 'annotation':
return entity.tag;
default:
// This is an unknown... | javascript | function _getEntityKey(entityType, entity) {
switch (entityType) {
case 'remote-application':
case 'application':
case 'unit':
return entity.name;
case 'machine':
case 'relation':
return entity.id;
case 'annotation':
return entity.tag;
default:
// This is an unknown... | [
"function",
"_getEntityKey",
"(",
"entityType",
",",
"entity",
")",
"{",
"switch",
"(",
"entityType",
")",
"{",
"case",
"'remote-application'",
":",
"case",
"'application'",
":",
"case",
"'unit'",
":",
"return",
"entity",
".",
"name",
";",
"case",
"'machine'",... | Get the identifier for the entity based upon its type.
@param {String} entityType - The type of entity.
@param {Object} entity - The entity details.
@returns {String} The entity key. | [
"Get",
"the",
"identifier",
"for",
"the",
"entity",
"based",
"upon",
"its",
"type",
"."
] | 0f245c6e09ef215fb4726bf7650320be2f49b6a0 | https://github.com/juju/maraca/blob/0f245c6e09ef215fb4726bf7650320be2f49b6a0/lib/delta-handlers.js#L43-L59 | train |
juju/maraca | lib/delta-handlers.js | _parseEntity | function _parseEntity(entityType, entity) {
switch (entityType) {
case 'remote-application':
return parsers.parseRemoteApplication(entity);
case 'application':
return parsers.parseApplication(entity);
case 'unit':
return parsers.parseUnit(entity);
case 'machine':
return parsers... | javascript | function _parseEntity(entityType, entity) {
switch (entityType) {
case 'remote-application':
return parsers.parseRemoteApplication(entity);
case 'application':
return parsers.parseApplication(entity);
case 'unit':
return parsers.parseUnit(entity);
case 'machine':
return parsers... | [
"function",
"_parseEntity",
"(",
"entityType",
",",
"entity",
")",
"{",
"switch",
"(",
"entityType",
")",
"{",
"case",
"'remote-application'",
":",
"return",
"parsers",
".",
"parseRemoteApplication",
"(",
"entity",
")",
";",
"case",
"'application'",
":",
"return... | Parse the entity response into a friendly format.
@param {String} entityType - The type of entity.
@param {Object} entity - The entity details.
@returns {Object} The parsed entity. | [
"Parse",
"the",
"entity",
"response",
"into",
"a",
"friendly",
"format",
"."
] | 0f245c6e09ef215fb4726bf7650320be2f49b6a0 | https://github.com/juju/maraca/blob/0f245c6e09ef215fb4726bf7650320be2f49b6a0/lib/delta-handlers.js#L81-L100 | train |
meepobrother/meepo-loader | demo/assets/meepo.libs/masonry/masonry.pkgd.js | getMilliseconds | function getMilliseconds( time ) {
if ( typeof time == 'number' ) {
return time;
}
var matches = time.match( /(^\d*\.?\d*)(\w*)/ );
var num = matches && matches[1];
var unit = matches && matches[2];
if ( !num.length ) {
return 0;
}
num = parseFloat( num );
var mult = msUnits[ unit ] || 1;
re... | javascript | function getMilliseconds( time ) {
if ( typeof time == 'number' ) {
return time;
}
var matches = time.match( /(^\d*\.?\d*)(\w*)/ );
var num = matches && matches[1];
var unit = matches && matches[2];
if ( !num.length ) {
return 0;
}
num = parseFloat( num );
var mult = msUnits[ unit ] || 1;
re... | [
"function",
"getMilliseconds",
"(",
"time",
")",
"{",
"if",
"(",
"typeof",
"time",
"==",
"'number'",
")",
"{",
"return",
"time",
";",
"}",
"var",
"matches",
"=",
"time",
".",
"match",
"(",
"/",
"(^\\d*\\.?\\d*)(\\w*)",
"/",
")",
";",
"var",
"num",
"=",... | munge time-like parameter into millisecond number '0.4s' -> 40 | [
"munge",
"time",
"-",
"like",
"parameter",
"into",
"millisecond",
"number",
"0",
".",
"4s",
"-",
">",
"40"
] | c0acb052d3c31b15d1b9cbb7b82659df78d50094 | https://github.com/meepobrother/meepo-loader/blob/c0acb052d3c31b15d1b9cbb7b82659df78d50094/demo/assets/meepo.libs/masonry/masonry.pkgd.js#L2239-L2252 | train |
helinjiang/babel-d | lib/babel-compile.js | compileFile | function compileFile(srcFullPath, saveOutFullPath, onlyCopy) {
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var content = fs.readFileSync(srcFullPath, 'utf8');
//when get file content empty, maybe file is locked
if (!content) {
return;
}
// only copy file cont... | javascript | function compileFile(srcFullPath, saveOutFullPath, onlyCopy) {
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var content = fs.readFileSync(srcFullPath, 'utf8');
//when get file content empty, maybe file is locked
if (!content) {
return;
}
// only copy file cont... | [
"function",
"compileFile",
"(",
"srcFullPath",
",",
"saveOutFullPath",
",",
"onlyCopy",
")",
"{",
"var",
"options",
"=",
"arguments",
".",
"length",
">",
"3",
"&&",
"arguments",
"[",
"3",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"3",
"]",
":",
"{"... | compile single file
@param {String} srcFullPath
@param {String} saveOutFullPath
@param {Boolean} [onlyCopy]
@param {Object} [options]
@param {String} [options.debug] only for debug | [
"compile",
"single",
"file"
] | 12e05f8702f850f7427416489097c50b93093abb | https://github.com/helinjiang/babel-d/blob/12e05f8702f850f7427416489097c50b93093abb/lib/babel-compile.js#L118-L158 | train |
helinjiang/babel-d | lib/babel-compile.js | getFiles | function getFiles(paths) {
var result = fileUtil.getAllFiles(paths);
var files = result.map(function (item) {
return item.relativePath;
// return path.join(item.basePath, item.relativePath);
});
return files;
} | javascript | function getFiles(paths) {
var result = fileUtil.getAllFiles(paths);
var files = result.map(function (item) {
return item.relativePath;
// return path.join(item.basePath, item.relativePath);
});
return files;
} | [
"function",
"getFiles",
"(",
"paths",
")",
"{",
"var",
"result",
"=",
"fileUtil",
".",
"getAllFiles",
"(",
"paths",
")",
";",
"var",
"files",
"=",
"result",
".",
"map",
"(",
"function",
"(",
"item",
")",
"{",
"return",
"item",
".",
"relativePath",
";",... | get all files
@param paths | [
"get",
"all",
"files"
] | 12e05f8702f850f7427416489097c50b93093abb | https://github.com/helinjiang/babel-d/blob/12e05f8702f850f7427416489097c50b93093abb/lib/babel-compile.js#L175-L184 | train |
byu-oit/fully-typed | bin/one-of.js | TypedOneOf | function TypedOneOf (config) {
const oneOf = this;
// validate oneOf
if (!config.hasOwnProperty('oneOf')) {
throw Error('Invalid configuration. Missing required one-of property: oneOf. Must be an array of schema configurations.');
}
if (!Array.isArray(config.oneOf) || config.oneOf.filter(v ... | javascript | function TypedOneOf (config) {
const oneOf = this;
// validate oneOf
if (!config.hasOwnProperty('oneOf')) {
throw Error('Invalid configuration. Missing required one-of property: oneOf. Must be an array of schema configurations.');
}
if (!Array.isArray(config.oneOf) || config.oneOf.filter(v ... | [
"function",
"TypedOneOf",
"(",
"config",
")",
"{",
"const",
"oneOf",
"=",
"this",
";",
"// validate oneOf",
"if",
"(",
"!",
"config",
".",
"hasOwnProperty",
"(",
"'oneOf'",
")",
")",
"{",
"throw",
"Error",
"(",
"'Invalid configuration. Missing required one-of prop... | Create a TypedOneOf instance.
@param {object} config
@returns {TypedOneOf}
@augments Typed
@constructor | [
"Create",
"a",
"TypedOneOf",
"instance",
"."
] | ed6b3ed88ffc72990acffb765232eaaee261afef | https://github.com/byu-oit/fully-typed/blob/ed6b3ed88ffc72990acffb765232eaaee261afef/bin/one-of.js#L29-L67 | train |
melvincarvalho/rdf-shell | bin/mv.js | bin | function bin (argv) {
program.version(pkg.version)
.usage('[options] <sourceURI> <destURI>')
.parse(argv)
var sourceURI = program.args[0]
var destURI = program.args[1]
if (!sourceURI || !destURI) {
program.help()
}
shell.mv(sourceURI, destURI, function (err, res, uri) {
if (!err) {
debu... | javascript | function bin (argv) {
program.version(pkg.version)
.usage('[options] <sourceURI> <destURI>')
.parse(argv)
var sourceURI = program.args[0]
var destURI = program.args[1]
if (!sourceURI || !destURI) {
program.help()
}
shell.mv(sourceURI, destURI, function (err, res, uri) {
if (!err) {
debu... | [
"function",
"bin",
"(",
"argv",
")",
"{",
"program",
".",
"version",
"(",
"pkg",
".",
"version",
")",
".",
"usage",
"(",
"'[options] <sourceURI> <destURI>'",
")",
".",
"parse",
"(",
"argv",
")",
"var",
"sourceURI",
"=",
"program",
".",
"args",
"[",
"0",
... | mv as a command.
@param {Array} argv Arguments | [
"mv",
"as",
"a",
"command",
"."
] | bf2015f6f333855e69a18ce3ec9e917bbddfb425 | https://github.com/melvincarvalho/rdf-shell/blob/bf2015f6f333855e69a18ce3ec9e917bbddfb425/bin/mv.js#L12-L31 | train |
waka/node-bowl | lib/watcher.js | function(evt) {
if (evt !== 'change' && evt !== 'rename') {
return;
}
fs.stat(file, function(err, current) {
if (err) {
self.logger_.error(err.message);
self.emit('error.watch', err.message);
return;
}
if (current.size !== prev.size || +current.mtime > +prev.m... | javascript | function(evt) {
if (evt !== 'change' && evt !== 'rename') {
return;
}
fs.stat(file, function(err, current) {
if (err) {
self.logger_.error(err.message);
self.emit('error.watch', err.message);
return;
}
if (current.size !== prev.size || +current.mtime > +prev.m... | [
"function",
"(",
"evt",
")",
"{",
"if",
"(",
"evt",
"!==",
"'change'",
"&&",
"evt",
"!==",
"'rename'",
")",
"{",
"return",
";",
"}",
"fs",
".",
"stat",
"(",
"file",
",",
"function",
"(",
"err",
",",
"current",
")",
"{",
"if",
"(",
"err",
")",
"... | filename is not supported when MacOSX | [
"filename",
"is",
"not",
"supported",
"when",
"MacOSX"
] | 671e8b16371a279e23b65bb9b2ff9dae047b6644 | https://github.com/waka/node-bowl/blob/671e8b16371a279e23b65bb9b2ff9dae047b6644/lib/watcher.js#L166-L182 | train | |
matterial/oknow | oknow.js | function(fn, syntheticArgs) {
var $this = this;
syntheticArgs = syntheticArgs || [];
/**
* Ensure to have it in the next event loop for better async
*/
var processResponder = function() {
try {
if (fn) {
/**
* Insert a done() or ok() argument to other needed arguments
*/
synth... | javascript | function(fn, syntheticArgs) {
var $this = this;
syntheticArgs = syntheticArgs || [];
/**
* Ensure to have it in the next event loop for better async
*/
var processResponder = function() {
try {
if (fn) {
/**
* Insert a done() or ok() argument to other needed arguments
*/
synth... | [
"function",
"(",
"fn",
",",
"syntheticArgs",
")",
"{",
"var",
"$this",
"=",
"this",
";",
"syntheticArgs",
"=",
"syntheticArgs",
"||",
"[",
"]",
";",
"/**\n\t\t * Ensure to have it in the next event loop for better async\n\t\t */",
"var",
"processResponder",
"=",
"functi... | Executes a given function with provided arguments, and then calls the next one in queue
@param {Function} fn Function to execute
@param {Array} syntheticArgs Arguments to be passed to the function called
@return {Promise} Returns self object for chaining | [
"Executes",
"a",
"given",
"function",
"with",
"provided",
"arguments",
"and",
"then",
"calls",
"the",
"next",
"one",
"in",
"queue"
] | 71008691603c776f534eb53fb73a3a0eb137a52a | https://github.com/matterial/oknow/blob/71008691603c776f534eb53fb73a3a0eb137a52a/oknow.js#L47-L96 | train | |
matterial/oknow | oknow.js | function() {
try {
if (fn) {
/**
* Insert a done() or ok() argument to other needed arguments
*/
syntheticArgs.unshift(function() {
/**
* Call the next in queue
*/
$this.next.apply($this, arguments);
});
/**
* Call the function finally
*/
... | javascript | function() {
try {
if (fn) {
/**
* Insert a done() or ok() argument to other needed arguments
*/
syntheticArgs.unshift(function() {
/**
* Call the next in queue
*/
$this.next.apply($this, arguments);
});
/**
* Call the function finally
*/
... | [
"function",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"fn",
")",
"{",
"/**\n\t\t\t\t\t * Insert a done() or ok() argument to other needed arguments\n\t\t\t\t\t */",
"syntheticArgs",
".",
"unshift",
"(",
"function",
"(",
")",
"{",
"/**\n\t\t\t\t\t\t * Call the next in queue\n\t\t\... | Ensure to have it in the next event loop for better async | [
"Ensure",
"to",
"have",
"it",
"in",
"the",
"next",
"event",
"loop",
"for",
"better",
"async"
] | 71008691603c776f534eb53fb73a3a0eb137a52a | https://github.com/matterial/oknow/blob/71008691603c776f534eb53fb73a3a0eb137a52a/oknow.js#L53-L86 | train | |
matterial/oknow | oknow.js | function(err) {
/**
* If err is an Error object, break the chain and call catch
*/
if (err && (err.constructor.name === "Error" || err.constructor.name === "TypeError") && this.onCatch) {
this.onCatch(err);
return;
}
var nextFn = this.fnStack.shift();
if (nextFn) {
/**
* Ensure arguments a... | javascript | function(err) {
/**
* If err is an Error object, break the chain and call catch
*/
if (err && (err.constructor.name === "Error" || err.constructor.name === "TypeError") && this.onCatch) {
this.onCatch(err);
return;
}
var nextFn = this.fnStack.shift();
if (nextFn) {
/**
* Ensure arguments a... | [
"function",
"(",
"err",
")",
"{",
"/**\n\t\t * If err is an Error object, break the chain and call catch\n\t\t */",
"if",
"(",
"err",
"&&",
"(",
"err",
".",
"constructor",
".",
"name",
"===",
"\"Error\"",
"||",
"err",
".",
"constructor",
".",
"name",
"===",
"\"TypeE... | Calls the next function in queue, or calls the function passed in `catch` if error occurs
@param {Error} err Error object optionally passed
@return {Promise} Return self for chaining | [
"Calls",
"the",
"next",
"function",
"in",
"queue",
"or",
"calls",
"the",
"function",
"passed",
"in",
"catch",
"if",
"error",
"occurs"
] | 71008691603c776f534eb53fb73a3a0eb137a52a | https://github.com/matterial/oknow/blob/71008691603c776f534eb53fb73a3a0eb137a52a/oknow.js#L111-L128 | train | |
4ndr01d3/js-components | biojs-rest-jsdas/src/jsdas.js | function(xml, command, version) {
var formatVersion = version || JSDAS.Formats.current;
var format = JSDAS.Formats[formatVersion][command];
var json = JSDAS.Parser.parseElement(xml, format);
return json;
} | javascript | function(xml, command, version) {
var formatVersion = version || JSDAS.Formats.current;
var format = JSDAS.Formats[formatVersion][command];
var json = JSDAS.Parser.parseElement(xml, format);
return json;
} | [
"function",
"(",
"xml",
",",
"command",
",",
"version",
")",
"{",
"var",
"formatVersion",
"=",
"version",
"||",
"JSDAS",
".",
"Formats",
".",
"current",
";",
"var",
"format",
"=",
"JSDAS",
".",
"Formats",
"[",
"formatVersion",
"]",
"[",
"command",
"]",
... | Private methods Given a valid DAS XML, it returns its translation to JSON | [
"Private",
"methods",
"Given",
"a",
"valid",
"DAS",
"XML",
"it",
"returns",
"its",
"translation",
"to",
"JSON"
] | d6abbc49a79fe89ba9b1b1ef2307790693900440 | https://github.com/4ndr01d3/js-components/blob/d6abbc49a79fe89ba9b1b1ef2307790693900440/biojs-rest-jsdas/src/jsdas.js#L27-L32 | train | |
4ndr01d3/js-components | biojs-rest-jsdas/src/jsdas.js | function(xml, format) {
var out = {};
//The Document object does not have all the functionality of a standard node (i.e. it can't have attributes).
//So, if we are in the Document element, move to its ¿¿only?? child, the root.
if(xml.nodeType == 9) { //detect the Document node type
xml = xml.firstChild;
... | javascript | function(xml, format) {
var out = {};
//The Document object does not have all the functionality of a standard node (i.e. it can't have attributes).
//So, if we are in the Document element, move to its ¿¿only?? child, the root.
if(xml.nodeType == 9) { //detect the Document node type
xml = xml.firstChild;
... | [
"function",
"(",
"xml",
",",
"format",
")",
"{",
"var",
"out",
"=",
"{",
"}",
";",
"//The Document object does not have all the functionality of a standard node (i.e. it can't have attributes).",
"//So, if we are in the Document element, move to its ¿¿only?? child, the root.",
"if",
... | true to raise an error if a mandatory element is not present Private functions (actually not really private. just not API documented | [
"true",
"to",
"raise",
"an",
"error",
"if",
"a",
"mandatory",
"element",
"is",
"not",
"present",
"Private",
"functions",
"(",
"actually",
"not",
"really",
"private",
".",
"just",
"not",
"API",
"documented"
] | d6abbc49a79fe89ba9b1b1ef2307790693900440 | https://github.com/4ndr01d3/js-components/blob/d6abbc49a79fe89ba9b1b1ef2307790693900440/biojs-rest-jsdas/src/jsdas.js#L2222-L2289 | train | |
4ndr01d3/js-components | biojs-rest-jsdas/src/jsdas.js | function(url, callback, errorcallback){
if (!this.initialized) {
this.initialize();
}
var xmlloader = JSDAS.XMLLoader; //get a reference to myself
var usingCORS = true;
var xhr = this.xhrCORS('GET', url);
if(!xhr) { //if the browser is not CORS capable, fallback to proxy if available
if(this.pro... | javascript | function(url, callback, errorcallback){
if (!this.initialized) {
this.initialize();
}
var xmlloader = JSDAS.XMLLoader; //get a reference to myself
var usingCORS = true;
var xhr = this.xhrCORS('GET', url);
if(!xhr) { //if the browser is not CORS capable, fallback to proxy if available
if(this.pro... | [
"function",
"(",
"url",
",",
"callback",
",",
"errorcallback",
")",
"{",
"if",
"(",
"!",
"this",
".",
"initialized",
")",
"{",
"this",
".",
"initialize",
"(",
")",
";",
"}",
"var",
"xmlloader",
"=",
"JSDAS",
".",
"XMLLoader",
";",
"//get a reference to m... | This function loads an external XML using a proxy on the server to comply with the SOP
@param {Object} url
@param {Object} callback | [
"This",
"function",
"loads",
"an",
"external",
"XML",
"using",
"a",
"proxy",
"on",
"the",
"server",
"to",
"comply",
"with",
"the",
"SOP"
] | d6abbc49a79fe89ba9b1b1ef2307790693900440 | https://github.com/4ndr01d3/js-components/blob/d6abbc49a79fe89ba9b1b1ef2307790693900440/biojs-rest-jsdas/src/jsdas.js#L2374-L2458 | train | |
4ndr01d3/js-components | biojs-rest-jsdas/src/jsdas.js | function(xhr){
if (xhr && (xhr.readyState == 4)) {
if (xmlloader.httpSuccess(xhr)) {
processResponse(xhr);
}
else { //if it failed, it mighht be that the source has no CORS enabled. In such case, fallback to proxy before erroring
if(usingCORS && xmlloader.proxyURL) { //if it failed when using C... | javascript | function(xhr){
if (xhr && (xhr.readyState == 4)) {
if (xmlloader.httpSuccess(xhr)) {
processResponse(xhr);
}
else { //if it failed, it mighht be that the source has no CORS enabled. In such case, fallback to proxy before erroring
if(usingCORS && xmlloader.proxyURL) { //if it failed when using C... | [
"function",
"(",
"xhr",
")",
"{",
"if",
"(",
"xhr",
"&&",
"(",
"xhr",
".",
"readyState",
"==",
"4",
")",
")",
"{",
"if",
"(",
"xmlloader",
".",
"httpSuccess",
"(",
"xhr",
")",
")",
"{",
"processResponse",
"(",
"xhr",
")",
";",
"}",
"else",
"{",
... | necessary so the closures get the variable | [
"necessary",
"so",
"the",
"closures",
"get",
"the",
"variable"
] | d6abbc49a79fe89ba9b1b1ef2307790693900440 | https://github.com/4ndr01d3/js-components/blob/d6abbc49a79fe89ba9b1b1ef2307790693900440/biojs-rest-jsdas/src/jsdas.js#L2399-L2419 | train | |
epii-io/epii-node-render | recipe/view.js | writeLaunchCode | function writeLaunchCode(config) {
var { name, stub } = config.holder
if (!name || !stub) {
throw new Error('invalid name or stub')
}
var code = `
;(function () {
var root = document.getElementById('${name}');
if (!root) throw new Error('undefined ${stub} root');
var view = window.${st... | javascript | function writeLaunchCode(config) {
var { name, stub } = config.holder
if (!name || !stub) {
throw new Error('invalid name or stub')
}
var code = `
;(function () {
var root = document.getElementById('${name}');
if (!root) throw new Error('undefined ${stub} root');
var view = window.${st... | [
"function",
"writeLaunchCode",
"(",
"config",
")",
"{",
"var",
"{",
"name",
",",
"stub",
"}",
"=",
"config",
".",
"holder",
"if",
"(",
"!",
"name",
"||",
"!",
"stub",
")",
"{",
"throw",
"new",
"Error",
"(",
"'invalid name or stub'",
")",
"}",
"var",
... | write launch code
@param {Object} config | [
"write",
"launch",
"code"
] | e8afa57066251e173b3a6455d47218c95f30f563 | https://github.com/epii-io/epii-node-render/blob/e8afa57066251e173b3a6455d47218c95f30f563/recipe/view.js#L49-L66 | train |
mattdesl/simplex-sampler | index.js | NoiseSampler | function NoiseSampler(size) {
if (!size)
throw "no size specified to NoiseSampler";
this.size = size;
this.scale = 1;
this.offset = 0;
this.smooth = true;
this.seamless = false;
// this.scales = [
// 10, 0.1, 0.2, 1
// ];
... | javascript | function NoiseSampler(size) {
if (!size)
throw "no size specified to NoiseSampler";
this.size = size;
this.scale = 1;
this.offset = 0;
this.smooth = true;
this.seamless = false;
// this.scales = [
// 10, 0.1, 0.2, 1
// ];
... | [
"function",
"NoiseSampler",
"(",
"size",
")",
"{",
"if",
"(",
"!",
"size",
")",
"throw",
"\"no size specified to NoiseSampler\"",
";",
"this",
".",
"size",
"=",
"size",
";",
"this",
".",
"scale",
"=",
"1",
";",
"this",
".",
"offset",
"=",
"0",
";",
"th... | Samples a 1-component texture, noise in this case | [
"Samples",
"a",
"1",
"-",
"component",
"texture",
"noise",
"in",
"this",
"case"
] | 5900d05b77f876b2d54b88d3017c31b8d4a77587 | https://github.com/mattdesl/simplex-sampler/blob/5900d05b77f876b2d54b88d3017c31b8d4a77587/index.js#L21-L46 | train |
mattdesl/simplex-sampler | index.js | function(x, y) {
//avoid negatives
if (this.seamless) {
x = (x%this.size + this.size)%this.size
y = (y%this.size + this.size)%this.size
} else {
x = clamp(x, 0, this.size)
y = clamp(y, 0, this.size)
}
if (this.smooth)
r... | javascript | function(x, y) {
//avoid negatives
if (this.seamless) {
x = (x%this.size + this.size)%this.size
y = (y%this.size + this.size)%this.size
} else {
x = clamp(x, 0, this.size)
y = clamp(y, 0, this.size)
}
if (this.smooth)
r... | [
"function",
"(",
"x",
",",
"y",
")",
"{",
"//avoid negatives",
"if",
"(",
"this",
".",
"seamless",
")",
"{",
"x",
"=",
"(",
"x",
"%",
"this",
".",
"size",
"+",
"this",
".",
"size",
")",
"%",
"this",
".",
"size",
"y",
"=",
"(",
"y",
"%",
"this... | returns a float, -1 to 1 | [
"returns",
"a",
"float",
"-",
"1",
"to",
"1"
] | 5900d05b77f876b2d54b88d3017c31b8d4a77587 | https://github.com/mattdesl/simplex-sampler/blob/5900d05b77f876b2d54b88d3017c31b8d4a77587/index.js#L99-L113 | train | |
darkobits/interface | src/interface.js | is | function is (constructor, value) {
return value !== null && (value.constructor === constructor || value instanceof constructor);
} | javascript | function is (constructor, value) {
return value !== null && (value.constructor === constructor || value instanceof constructor);
} | [
"function",
"is",
"(",
"constructor",
",",
"value",
")",
"{",
"return",
"value",
"!==",
"null",
"&&",
"(",
"value",
".",
"constructor",
"===",
"constructor",
"||",
"value",
"instanceof",
"constructor",
")",
";",
"}"
] | Determines if 'value' is an instance of 'constructor'.
@private
@param {object} constructor
@param {*} value
@return {boolean} | [
"Determines",
"if",
"value",
"is",
"an",
"instance",
"of",
"constructor",
"."
] | 819aec7ca45484cdd53208864d8fdaad96dad3c2 | https://github.com/darkobits/interface/blob/819aec7ca45484cdd53208864d8fdaad96dad3c2/src/interface.js#L20-L22 | train |
usco/usco-stl-parser | dist/utils.js | isDataBinaryRobust | function isDataBinaryRobust(data) {
// console.log('data is binary ?')
var patternVertex = /vertex[\s]+([\-+]?[0-9]+\.?[0-9]*([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+/g;
var text = ensureString(data);
var isBinary = patternVertex.exec(t... | javascript | function isDataBinaryRobust(data) {
// console.log('data is binary ?')
var patternVertex = /vertex[\s]+([\-+]?[0-9]+\.?[0-9]*([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+/g;
var text = ensureString(data);
var isBinary = patternVertex.exec(t... | [
"function",
"isDataBinaryRobust",
"(",
"data",
")",
"{",
"// console.log('data is binary ?')",
"var",
"patternVertex",
"=",
"/",
"vertex[\\s]+([\\-+]?[0-9]+\\.?[0-9]*([eE][\\-+]?[0-9]+)?)+[\\s]+([\\-+]?[0-9]*\\.?[0-9]+([eE][\\-+]?[0-9]+)?)+[\\s]+([\\-+]?[0-9]*\\.?[0-9]+([eE][\\-+]?[0-9]+)?)+",... | a more robust version of the above, that does NOT require the whole file | [
"a",
"more",
"robust",
"version",
"of",
"the",
"above",
"that",
"does",
"NOT",
"require",
"the",
"whole",
"file"
] | 49eb402f124723d8f74cc67f24a7017c2b99bca4 | https://github.com/usco/usco-stl-parser/blob/49eb402f124723d8f74cc67f24a7017c2b99bca4/dist/utils.js#L53-L59 | train |
Industryswarm/isnode-mod-data | lib/mongodb/mongodb-core/lib/auth/scram.js | function(err, r) {
if (err) {
numberOfValidConnections = numberOfValidConnections - 1;
errorObject = err;
return false;
} else if (r.result['$err']) {
errorObject = r.result;
return false;
} else if (r.result['errmsg']) {
errorObject = r.result;
... | javascript | function(err, r) {
if (err) {
numberOfValidConnections = numberOfValidConnections - 1;
errorObject = err;
return false;
} else if (r.result['$err']) {
errorObject = r.result;
return false;
} else if (r.result['errmsg']) {
errorObject = r.result;
... | [
"function",
"(",
"err",
",",
"r",
")",
"{",
"if",
"(",
"err",
")",
"{",
"numberOfValidConnections",
"=",
"numberOfValidConnections",
"-",
"1",
";",
"errorObject",
"=",
"err",
";",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"r",
".",
"result",
"[",... | Handle the error | [
"Handle",
"the",
"error"
] | 5adc639b88a0d72cbeef23a6b5df7f4540745089 | https://github.com/Industryswarm/isnode-mod-data/blob/5adc639b88a0d72cbeef23a6b5df7f4540745089/lib/mongodb/mongodb-core/lib/auth/scram.js#L205-L221 | train | |
dak0rn/espressojs | index.js | function(options) {
Configurable.call(this);
this._resources = [];
this._serializer = require(__dirname + '/lib/Serializer');
this.setAll( _.extend({}, defaults, options) );
// List of IDs used to find duplicate handlers fast
this._ids = {
// id: handler
... | javascript | function(options) {
Configurable.call(this);
this._resources = [];
this._serializer = require(__dirname + '/lib/Serializer');
this.setAll( _.extend({}, defaults, options) );
// List of IDs used to find duplicate handlers fast
this._ids = {
// id: handler
... | [
"function",
"(",
"options",
")",
"{",
"Configurable",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"_resources",
"=",
"[",
"]",
";",
"this",
".",
"_serializer",
"=",
"require",
"(",
"__dirname",
"+",
"'/lib/Serializer'",
")",
";",
"this",
".",
"set... | espressojs constructor function
@param {object} options Optional options object | [
"espressojs",
"constructor",
"function"
] | 7f8e015f31113215abbe9988ae7f2c7dd5d8572b | https://github.com/dak0rn/espressojs/blob/7f8e015f31113215abbe9988ae7f2c7dd5d8572b/index.js#L22-L40 | train | |
jshanley/motivejs | dist/motive.cjs.js | makeValidation | function makeValidation(name, exp, parser) {
return function (input) {
if (typeof input !== 'string') {
throw new TypeError('Cannot validate ' + name + '. Input must be a string.');
}
var validate = function () {
return input.match(exp) ? true : false;
};
... | javascript | function makeValidation(name, exp, parser) {
return function (input) {
if (typeof input !== 'string') {
throw new TypeError('Cannot validate ' + name + '. Input must be a string.');
}
var validate = function () {
return input.match(exp) ? true : false;
};
... | [
"function",
"makeValidation",
"(",
"name",
",",
"exp",
",",
"parser",
")",
"{",
"return",
"function",
"(",
"input",
")",
"{",
"if",
"(",
"typeof",
"input",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'Cannot validate '",
"+",
"name",
... | this makes a validation function for a string type defined by 'name' | [
"this",
"makes",
"a",
"validation",
"function",
"for",
"a",
"string",
"type",
"defined",
"by",
"name"
] | ba11720e0580da4657374dc47b177be15a723f6a | https://github.com/jshanley/motivejs/blob/ba11720e0580da4657374dc47b177be15a723f6a/dist/motive.cjs.js#L49-L68 | train |
bestander/pong-mmo-server | game/socket/pongSocket.js | pipeEvents | function pipeEvents(source, destination, event) {
source.on(event, function (data) {
destination.emit(event, data);
});
} | javascript | function pipeEvents(source, destination, event) {
source.on(event, function (data) {
destination.emit(event, data);
});
} | [
"function",
"pipeEvents",
"(",
"source",
",",
"destination",
",",
"event",
")",
"{",
"source",
".",
"on",
"(",
"event",
",",
"function",
"(",
"data",
")",
"{",
"destination",
".",
"emit",
"(",
"event",
",",
"data",
")",
";",
"}",
")",
";",
"}"
] | pipe specific events from source event emitter to destination event emitter
@param source event emitter
@param destination event emitter
@param event event name | [
"pipe",
"specific",
"events",
"from",
"source",
"event",
"emitter",
"to",
"destination",
"event",
"emitter"
] | 7a54644bbf8b224f5010a30bacc98778201fe01c | https://github.com/bestander/pong-mmo-server/blob/7a54644bbf8b224f5010a30bacc98778201fe01c/game/socket/pongSocket.js#L70-L74 | train |
danmasta/env | index.js | get | function get(key) {
let val = process.env[key];
return val in types ? types[val] : util.isNumeric(val) ? parseFloat(val) : val;
} | javascript | function get(key) {
let val = process.env[key];
return val in types ? types[val] : util.isNumeric(val) ? parseFloat(val) : val;
} | [
"function",
"get",
"(",
"key",
")",
"{",
"let",
"val",
"=",
"process",
".",
"env",
"[",
"key",
"]",
";",
"return",
"val",
"in",
"types",
"?",
"types",
"[",
"val",
"]",
":",
"util",
".",
"isNumeric",
"(",
"val",
")",
"?",
"parseFloat",
"(",
"val",... | get env variable, converts to native type | [
"get",
"env",
"variable",
"converts",
"to",
"native",
"type"
] | cd6df18f4f837797d47cd96bcfb125c0264685a7 | https://github.com/danmasta/env/blob/cd6df18f4f837797d47cd96bcfb125c0264685a7/index.js#L12-L18 | train |
danmasta/env | index.js | set | function set(key, val) {
return process.env[key] = (process.env[key] === undefined ? val : process.env[key]);
} | javascript | function set(key, val) {
return process.env[key] = (process.env[key] === undefined ? val : process.env[key]);
} | [
"function",
"set",
"(",
"key",
",",
"val",
")",
"{",
"return",
"process",
".",
"env",
"[",
"key",
"]",
"=",
"(",
"process",
".",
"env",
"[",
"key",
"]",
"===",
"undefined",
"?",
"val",
":",
"process",
".",
"env",
"[",
"key",
"]",
")",
";",
"}"
... | sets environment variable if it does not exist already env variables are stringified when set | [
"sets",
"environment",
"variable",
"if",
"it",
"does",
"not",
"exist",
"already",
"env",
"variables",
"are",
"stringified",
"when",
"set"
] | cd6df18f4f837797d47cd96bcfb125c0264685a7 | https://github.com/danmasta/env/blob/cd6df18f4f837797d47cd96bcfb125c0264685a7/index.js#L22-L24 | train |
danmasta/env | index.js | load | function load(file) {
let contents = null;
file = path.resolve(file);
// handle .env files
if (constants.REGEX.envfile.test(file)) {
contents = util.parse(fs.readFileSync(file, 'utf8'));
// handle .js/.json files
} else {
contents = require(file);
}
return env(conten... | javascript | function load(file) {
let contents = null;
file = path.resolve(file);
// handle .env files
if (constants.REGEX.envfile.test(file)) {
contents = util.parse(fs.readFileSync(file, 'utf8'));
// handle .js/.json files
} else {
contents = require(file);
}
return env(conten... | [
"function",
"load",
"(",
"file",
")",
"{",
"let",
"contents",
"=",
"null",
";",
"file",
"=",
"path",
".",
"resolve",
"(",
"file",
")",
";",
"// handle .env files",
"if",
"(",
"constants",
".",
"REGEX",
".",
"envfile",
".",
"test",
"(",
"file",
")",
"... | load a file's contents and add to env | [
"load",
"a",
"file",
"s",
"contents",
"and",
"add",
"to",
"env"
] | cd6df18f4f837797d47cd96bcfb125c0264685a7 | https://github.com/danmasta/env/blob/cd6df18f4f837797d47cd96bcfb125c0264685a7/index.js#L50-L67 | train |
danmasta/env | index.js | init | function init(){
// set NODE_ENV to --env value
if (argv.env) {
set('NODE_ENV', argv.env);
}
// load evironment files
['./.env', './config/.env', './env', './config/env'].map(file => {
try {
load(file);
} catch(err) {
if (env('DEBUG')) {
... | javascript | function init(){
// set NODE_ENV to --env value
if (argv.env) {
set('NODE_ENV', argv.env);
}
// load evironment files
['./.env', './config/.env', './env', './config/env'].map(file => {
try {
load(file);
} catch(err) {
if (env('DEBUG')) {
... | [
"function",
"init",
"(",
")",
"{",
"// set NODE_ENV to --env value",
"if",
"(",
"argv",
".",
"env",
")",
"{",
"set",
"(",
"'NODE_ENV'",
",",
"argv",
".",
"env",
")",
";",
"}",
"// load evironment files",
"[",
"'./.env'",
",",
"'./config/.env'",
",",
"'./env'... | attempt to load env configuration files | [
"attempt",
"to",
"load",
"env",
"configuration",
"files"
] | cd6df18f4f837797d47cd96bcfb125c0264685a7 | https://github.com/danmasta/env/blob/cd6df18f4f837797d47cd96bcfb125c0264685a7/index.js#L70-L101 | train |
jchartrand/CWRC-WriterLayout | src/modules/structureTree.js | _expandParentsForNode | function _expandParentsForNode(node) {
// get the actual parent nodes in the editor
var parents = [];
$(node).parentsUntil('#tinymce').each(function(index, el) {
parents.push(el.id);
});
parents.reverse();
// TODO handling for readonly mode where only... | javascript | function _expandParentsForNode(node) {
// get the actual parent nodes in the editor
var parents = [];
$(node).parentsUntil('#tinymce').each(function(index, el) {
parents.push(el.id);
});
parents.reverse();
// TODO handling for readonly mode where only... | [
"function",
"_expandParentsForNode",
"(",
"node",
")",
"{",
"// get the actual parent nodes in the editor",
"var",
"parents",
"=",
"[",
"]",
";",
"$",
"(",
"node",
")",
".",
"parentsUntil",
"(",
"'#tinymce'",
")",
".",
"each",
"(",
"function",
"(",
"index",
",... | Expands the parents of a particular node
@param {element} node A node that exists in the editor | [
"Expands",
"the",
"parents",
"of",
"a",
"particular",
"node"
] | 4a4b75af695043bc276efd3a9e5eb7e836c52d6e | https://github.com/jchartrand/CWRC-WriterLayout/blob/4a4b75af695043bc276efd3a9e5eb7e836c52d6e/src/modules/structureTree.js#L148-L167 | train |
jchartrand/CWRC-WriterLayout | src/modules/structureTree.js | selectNode | function selectNode($node, selectContents, multiselect, external) {
var id = $node.attr('name');
_removeCustomClasses();
// clear other selections if not multiselect
if (!multiselect) {
if (tree.currentlySelectedNodes.indexOf(id) != -1) {
tre... | javascript | function selectNode($node, selectContents, multiselect, external) {
var id = $node.attr('name');
_removeCustomClasses();
// clear other selections if not multiselect
if (!multiselect) {
if (tree.currentlySelectedNodes.indexOf(id) != -1) {
tre... | [
"function",
"selectNode",
"(",
"$node",
",",
"selectContents",
",",
"multiselect",
",",
"external",
")",
"{",
"var",
"id",
"=",
"$node",
".",
"attr",
"(",
"'name'",
")",
";",
"_removeCustomClasses",
"(",
")",
";",
"// clear other selections if not multiselect",
... | Performs actual selection of a tree node
@param {Element} $node A jquery node (LI) in the tree
@param {Boolean} selectContents True to select contents
@param {Boolean} multiselect True if ctrl or select was held when selecting
@param {Boolean} external True if selectNode came from outside structureTree, i.e. tree.selec... | [
"Performs",
"actual",
"selection",
"of",
"a",
"tree",
"node"
] | 4a4b75af695043bc276efd3a9e5eb7e836c52d6e | https://github.com/jchartrand/CWRC-WriterLayout/blob/4a4b75af695043bc276efd3a9e5eb7e836c52d6e/src/modules/structureTree.js#L243-L300 | train |
themouette/screenstory | lib/runner/resolveWdOptions.js | resolveCapabilities | function resolveCapabilities(capabilities, capabilitiesDictionary) {
if (typeof capabilities !== "string") {
// we do not know how to parse non string capabilities, let's assume it
// is selenium compliant capabilities and return it.
return capabilities;
}
// try to parse as a JSON ... | javascript | function resolveCapabilities(capabilities, capabilitiesDictionary) {
if (typeof capabilities !== "string") {
// we do not know how to parse non string capabilities, let's assume it
// is selenium compliant capabilities and return it.
return capabilities;
}
// try to parse as a JSON ... | [
"function",
"resolveCapabilities",
"(",
"capabilities",
",",
"capabilitiesDictionary",
")",
"{",
"if",
"(",
"typeof",
"capabilities",
"!==",
"\"string\"",
")",
"{",
"// we do not know how to parse non string capabilities, let's assume it",
"// is selenium compliant capabilities and... | Actual resolution for capabilities. | [
"Actual",
"resolution",
"for",
"capabilities",
"."
] | 0c847f5514a55e7c2f59728565591d4bb5788915 | https://github.com/themouette/screenstory/blob/0c847f5514a55e7c2f59728565591d4bb5788915/lib/runner/resolveWdOptions.js#L110-L132 | train |
codeactual/sinon-doublist-fs | lib/sinon-doublist-fs/index.js | sinonDoublistFs | function sinonDoublistFs(test) {
if (module.exports.trace) {
nodeConsole = require('long-con').create();
log = nodeConsole
.set('nlFirst', true)
.set('time', false)
.set('traceDepth', true)
.create(null, console.log); // eslint-disable-line no-console
nodeConsole.traceMethods('File... | javascript | function sinonDoublistFs(test) {
if (module.exports.trace) {
nodeConsole = require('long-con').create();
log = nodeConsole
.set('nlFirst', true)
.set('time', false)
.set('traceDepth', true)
.create(null, console.log); // eslint-disable-line no-console
nodeConsole.traceMethods('File... | [
"function",
"sinonDoublistFs",
"(",
"test",
")",
"{",
"if",
"(",
"module",
".",
"exports",
".",
"trace",
")",
"{",
"nodeConsole",
"=",
"require",
"(",
"'long-con'",
")",
".",
"create",
"(",
")",
";",
"log",
"=",
"nodeConsole",
".",
"set",
"(",
"'nlFirs... | Init `fs` stubs.
@param {object|string} test Test context *OR* name of supported test runner
- `{object}` Context object including `sandbox` from prior `sinonDoublist()` call
- `{string}` Named runner will be configured to automatically set-up/tear-down.
- Supported runners: 'mocha' | [
"Init",
"fs",
"stubs",
"."
] | 7f32af1bba609bccf26ec2ce333dca27efc6f78f | https://github.com/codeactual/sinon-doublist-fs/blob/7f32af1bba609bccf26ec2ce333dca27efc6f78f/lib/sinon-doublist-fs/index.js#L39-L69 | train |
codeactual/sinon-doublist-fs | lib/sinon-doublist-fs/index.js | FileStub | function FileStub() {
this.settings = {
name: '',
buffer: new Buffer(0),
readdir: false,
parentName: '',
stats: {
dev: 2114,
ino: 48064969,
mode: 33188,
nlink: 1,
uid: 85,
gid: 100,
rdev: 0,
size: 0,
blksize: 4096,
blocks: 0,
atime:... | javascript | function FileStub() {
this.settings = {
name: '',
buffer: new Buffer(0),
readdir: false,
parentName: '',
stats: {
dev: 2114,
ino: 48064969,
mode: 33188,
nlink: 1,
uid: 85,
gid: 100,
rdev: 0,
size: 0,
blksize: 4096,
blocks: 0,
atime:... | [
"function",
"FileStub",
"(",
")",
"{",
"this",
".",
"settings",
"=",
"{",
"name",
":",
"''",
",",
"buffer",
":",
"new",
"Buffer",
"(",
"0",
")",
",",
"readdir",
":",
"false",
",",
"parentName",
":",
"''",
",",
"stats",
":",
"{",
"dev",
":",
"2114... | FileStub constructor.
An entry in the map of stubbed files/directories.
Usage:
const stub = new FileStub();
stub
.set('name', '/path/to/file')
.stat('size', 50)
.stat('gid', 2000)
.make();
Configuration:
- `{string} name` Absolute path w/out trailing slash
- Trailing slashes will be dropped.
- `{boolean|array} rea... | [
"FileStub",
"constructor",
"."
] | 7f32af1bba609bccf26ec2ce333dca27efc6f78f | https://github.com/codeactual/sinon-doublist-fs/blob/7f32af1bba609bccf26ec2ce333dca27efc6f78f/lib/sinon-doublist-fs/index.js#L533-L555 | train |
codeactual/sinon-doublist-fs | lib/sinon-doublist-fs/index.js | intermediatePaths | function intermediatePaths(sparse) {
const dense = {};
[].concat(sparse).forEach(function forEachPath(path) {
path = rtrimSlash(path);
dense[path] = {}; // Store as keys to omit dupes
const curParts = trimSlash(path).split('/');
const gapParts = [];
curParts.forEach(function forEachPart(part) {
... | javascript | function intermediatePaths(sparse) {
const dense = {};
[].concat(sparse).forEach(function forEachPath(path) {
path = rtrimSlash(path);
dense[path] = {}; // Store as keys to omit dupes
const curParts = trimSlash(path).split('/');
const gapParts = [];
curParts.forEach(function forEachPart(part) {
... | [
"function",
"intermediatePaths",
"(",
"sparse",
")",
"{",
"const",
"dense",
"=",
"{",
"}",
";",
"[",
"]",
".",
"concat",
"(",
"sparse",
")",
".",
"forEach",
"(",
"function",
"forEachPath",
"(",
"path",
")",
"{",
"path",
"=",
"rtrimSlash",
"(",
"path",
... | Given an array files and directories, in any order and relationship,
return an object describing how to build file trees that contain them
all with no directory gaps.
Ex. given just '/path/to/file.js', it include '/path' and '/to' in the
results.
@param {string|array} sparse Normalized, absolute paths
@return {object... | [
"Given",
"an",
"array",
"files",
"and",
"directories",
"in",
"any",
"order",
"and",
"relationship",
"return",
"an",
"object",
"describing",
"how",
"to",
"build",
"file",
"trees",
"that",
"contain",
"them",
"all",
"with",
"no",
"directory",
"gaps",
"."
] | 7f32af1bba609bccf26ec2ce333dca27efc6f78f | https://github.com/codeactual/sinon-doublist-fs/blob/7f32af1bba609bccf26ec2ce333dca27efc6f78f/lib/sinon-doublist-fs/index.js#L764-L795 | train |
elidoran/node-use | lib/index.js | withOptions | function withOptions(scope, defaultOptions) {
return function(plugin, options) {
return scope.use(this, scope, plugin, scope.combine(defaultOptions, options))
}
} | javascript | function withOptions(scope, defaultOptions) {
return function(plugin, options) {
return scope.use(this, scope, plugin, scope.combine(defaultOptions, options))
}
} | [
"function",
"withOptions",
"(",
"scope",
",",
"defaultOptions",
")",
"{",
"return",
"function",
"(",
"plugin",
",",
"options",
")",
"{",
"return",
"scope",
".",
"use",
"(",
"this",
",",
"scope",
",",
"plugin",
",",
"scope",
".",
"combine",
"(",
"defaultO... | create a closure to hold the provided `scope` and `defaultOptions`. | [
"create",
"a",
"closure",
"to",
"hold",
"the",
"provided",
"scope",
"and",
"defaultOptions",
"."
] | 72349bad08f253dc226cbd031a1495ae44bd733c | https://github.com/elidoran/node-use/blob/72349bad08f253dc226cbd031a1495ae44bd733c/lib/index.js#L61-L65 | train |
adiwidjaja/frontend-pagebuilder | js/tinymce/plugins/help/plugin.js | function (o) {
var r = [];
for (var i in o) {
if (o.hasOwnProperty(i)) {
r.push(i);
}
}
return r;
} | javascript | function (o) {
var r = [];
for (var i in o) {
if (o.hasOwnProperty(i)) {
r.push(i);
}
}
return r;
} | [
"function",
"(",
"o",
")",
"{",
"var",
"r",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"in",
"o",
")",
"{",
"if",
"(",
"o",
".",
"hasOwnProperty",
"(",
"i",
")",
")",
"{",
"r",
".",
"push",
"(",
"i",
")",
";",
"}",
"}",
"return",
"r",
... | This technically means that 'each' and 'find' on IE8 iterate through the object twice. This code doesn't run on IE8 much, so it's an acceptable tradeoff. If it becomes a problem we can always duplicate the feature detection inside each and find as well. | [
"This",
"technically",
"means",
"that",
"each",
"and",
"find",
"on",
"IE8",
"iterate",
"through",
"the",
"object",
"twice",
".",
"This",
"code",
"doesn",
"t",
"run",
"on",
"IE8",
"much",
"so",
"it",
"s",
"an",
"acceptable",
"tradeoff",
".",
"If",
"it",
... | a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f | https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/plugins/help/plugin.js#L825-L833 | train | |
commenthol/hashtree | hashtree.js | splitKeys | function splitKeys (keys) {
if (typeof(keys) === 'string') {
return keys.replace(/^\s*\.\s*/,'')
.replace(/(?:\s*\.\s*)+/g, '.')
.split('.');
}
else if (Array.isArray(keys)) {
return [].concat(keys);
}
return;
} | javascript | function splitKeys (keys) {
if (typeof(keys) === 'string') {
return keys.replace(/^\s*\.\s*/,'')
.replace(/(?:\s*\.\s*)+/g, '.')
.split('.');
}
else if (Array.isArray(keys)) {
return [].concat(keys);
}
return;
} | [
"function",
"splitKeys",
"(",
"keys",
")",
"{",
"if",
"(",
"typeof",
"(",
"keys",
")",
"===",
"'string'",
")",
"{",
"return",
"keys",
".",
"replace",
"(",
"/",
"^\\s*\\.\\s*",
"/",
",",
"''",
")",
".",
"replace",
"(",
"/",
"(?:\\s*\\.\\s*)+",
"/",
"g... | Normalize and split `keys` for `get` and `set` method.
Splits by "."
@param {String|Array} keys
@api private | [
"Normalize",
"and",
"split",
"keys",
"for",
"get",
"and",
"set",
"method",
".",
"Splits",
"by",
"."
] | eb66d5b72af17ded1913f5abb9b49ebfb2b000c1 | https://github.com/commenthol/hashtree/blob/eb66d5b72af17ded1913f5abb9b49ebfb2b000c1/hashtree.js#L477-L487 | train |
commenthol/hashtree | hashtree.js | Ops | function Ops (ref, key) {
this.ref = ref;
this.key = key;
if (this.ref[this.key] === undefined) {
this.ref[this.key] = 0;
}
this._toNumber();
this.isNumber = (typeof this.ref[this.key] === 'number');
this.isBoolean = (typeof this.ref[this.key] === 'boolean');
this.isString = (typeof this.ref[this.k... | javascript | function Ops (ref, key) {
this.ref = ref;
this.key = key;
if (this.ref[this.key] === undefined) {
this.ref[this.key] = 0;
}
this._toNumber();
this.isNumber = (typeof this.ref[this.key] === 'number');
this.isBoolean = (typeof this.ref[this.key] === 'boolean');
this.isString = (typeof this.ref[this.k... | [
"function",
"Ops",
"(",
"ref",
",",
"key",
")",
"{",
"this",
".",
"ref",
"=",
"ref",
";",
"this",
".",
"key",
"=",
"key",
";",
"if",
"(",
"this",
".",
"ref",
"[",
"this",
".",
"key",
"]",
"===",
"undefined",
")",
"{",
"this",
".",
"ref",
"[",... | Helper class for hashTree.use
@param {Object} ref : reference in object
@param {String} key : key for value to change | [
"Helper",
"class",
"for",
"hashTree",
".",
"use"
] | eb66d5b72af17ded1913f5abb9b49ebfb2b000c1 | https://github.com/commenthol/hashtree/blob/eb66d5b72af17ded1913f5abb9b49ebfb2b000c1/hashtree.js#L494-L508 | train |
sreenaths/em-tgraph | addon/utils/tip.js | _createList | function _createList(list) {
var listContent = [];
if(list) {
listContent.push("<table>");
Ember.$.each(list, function (property, value) {
listContent.push(
"<tr><td>",
property,
"</td><td>",
value,
"</td></tr>"
);
});
listContent.push("</table>"... | javascript | function _createList(list) {
var listContent = [];
if(list) {
listContent.push("<table>");
Ember.$.each(list, function (property, value) {
listContent.push(
"<tr><td>",
property,
"</td><td>",
value,
"</td></tr>"
);
});
listContent.push("</table>"... | [
"function",
"_createList",
"(",
"list",
")",
"{",
"var",
"listContent",
"=",
"[",
"]",
";",
"if",
"(",
"list",
")",
"{",
"listContent",
".",
"push",
"(",
"\"<table>\"",
")",
";",
"Ember",
".",
"$",
".",
"each",
"(",
"list",
",",
"function",
"(",
"p... | Last node over which tooltip was displayed
Converts the provided list object into a tabular form.
@param list {Object} : An object with properties to be displayed as key value pairs
{
propertyName1: "property value 1",
..
propertyNameN: "property value N",
} | [
"Last",
"node",
"over",
"which",
"tooltip",
"was",
"displayed",
"Converts",
"the",
"provided",
"list",
"object",
"into",
"a",
"tabular",
"form",
"."
] | 8d6a8f46b911a165ac16561731735ab762954996 | https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/tip.js#L25-L44 | train |
sreenaths/em-tgraph | addon/utils/tip.js | _setData | function _setData(data) {
_element.find('.tip-title').html(data.title || "");
_element.find('.tip-text').html(data.text || "");
_element.find('.tip-text')[data.text ? 'show' : 'hide']();
_element.find('.tip-list').html(_createList(data.kvList) || "");
} | javascript | function _setData(data) {
_element.find('.tip-title').html(data.title || "");
_element.find('.tip-text').html(data.text || "");
_element.find('.tip-text')[data.text ? 'show' : 'hide']();
_element.find('.tip-list').html(_createList(data.kvList) || "");
} | [
"function",
"_setData",
"(",
"data",
")",
"{",
"_element",
".",
"find",
"(",
"'.tip-title'",
")",
".",
"html",
"(",
"data",
".",
"title",
"||",
"\"\"",
")",
";",
"_element",
".",
"find",
"(",
"'.tip-text'",
")",
".",
"html",
"(",
"data",
".",
"text",... | Tip supports 3 visual entities in the tooltip. Title, description text and a list.
_setData sets all these based on the passed data object
@param data {Object} An object of the format
{
title: "tip title",
text: "tip description text",
kvList: {
propertyName1: "property value 1",
..
propertyNameN: "property value N",
}... | [
"Tip",
"supports",
"3",
"visual",
"entities",
"in",
"the",
"tooltip",
".",
"Title",
"description",
"text",
"and",
"a",
"list",
".",
"_setData",
"sets",
"all",
"these",
"based",
"on",
"the",
"passed",
"data",
"object"
] | 8d6a8f46b911a165ac16561731735ab762954996 | https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/tip.js#L60-L65 | train |
sreenaths/em-tgraph | addon/utils/tip.js | function (tipElement, svg) {
_element = tipElement;
_bubble = _element.find('.bubble');
_svg = svg;
_svgPoint = svg[0].createSVGPoint();
} | javascript | function (tipElement, svg) {
_element = tipElement;
_bubble = _element.find('.bubble');
_svg = svg;
_svgPoint = svg[0].createSVGPoint();
} | [
"function",
"(",
"tipElement",
",",
"svg",
")",
"{",
"_element",
"=",
"tipElement",
";",
"_bubble",
"=",
"_element",
".",
"find",
"(",
"'.bubble'",
")",
";",
"_svg",
"=",
"svg",
";",
"_svgPoint",
"=",
"svg",
"[",
"0",
"]",
".",
"createSVGPoint",
"(",
... | Set the tip defaults
@param tipElement {$} jQuery reference to the tooltip DOM element.
The element must contain 3 children with class tip-title, tip-text & tip-list.
@param svg {$} jQuery reference to svg html element | [
"Set",
"the",
"tip",
"defaults"
] | 8d6a8f46b911a165ac16561731735ab762954996 | https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/tip.js#L74-L79 | train | |
sreenaths/em-tgraph | addon/utils/tip.js | function (node, data, event) {
var point = data.position || (node.getScreenCTM ? _svgPoint.matrixTransform(
node.getScreenCTM()
) : {
x: event.x,
y: event.y
}),
windMid = _window.height() >> 1,
winWidth = _window.width(),
showAbove = point.y < ... | javascript | function (node, data, event) {
var point = data.position || (node.getScreenCTM ? _svgPoint.matrixTransform(
node.getScreenCTM()
) : {
x: event.x,
y: event.y
}),
windMid = _window.height() >> 1,
winWidth = _window.width(),
showAbove = point.y < ... | [
"function",
"(",
"node",
",",
"data",
",",
"event",
")",
"{",
"var",
"point",
"=",
"data",
".",
"position",
"||",
"(",
"node",
".",
"getScreenCTM",
"?",
"_svgPoint",
".",
"matrixTransform",
"(",
"node",
".",
"getScreenCTM",
"(",
")",
")",
":",
"{",
"... | Display a tooltip over an svg element.
@param node {SVG Element} Svg element over which tooltip must be displayed.
@param data {Object} An object of the format
{
title: "tip title",
text: "tip description text",
kvList: {
propertyName1: "property value 1",
..
propertyNameN: "property value N",
}
}
@param event {MouseEv... | [
"Display",
"a",
"tooltip",
"over",
"an",
"svg",
"element",
"."
] | 8d6a8f46b911a165ac16561731735ab762954996 | https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/tip.js#L100-L153 | train | |
mongodb-js/mocha-evergreen-reporter | index.js | report | function report(test) {
return {
test_file: test.file + ': ' + test.fullTitle(),
start: test.start,
end: test.end,
exit_code: test.exit_code,
elapsed: test.duration / 1000,
error: errorJSON(test.err || {}),
url: test.url,
status: test.state
};
} | javascript | function report(test) {
return {
test_file: test.file + ': ' + test.fullTitle(),
start: test.start,
end: test.end,
exit_code: test.exit_code,
elapsed: test.duration / 1000,
error: errorJSON(test.err || {}),
url: test.url,
status: test.state
};
} | [
"function",
"report",
"(",
"test",
")",
"{",
"return",
"{",
"test_file",
":",
"test",
".",
"file",
"+",
"': '",
"+",
"test",
".",
"fullTitle",
"(",
")",
",",
"start",
":",
"test",
".",
"start",
",",
"end",
":",
"test",
".",
"end",
",",
"exit_code",... | Return an object with all of the relevant information for the test.
@api private
@param {Object} test
@return {Object} | [
"Return",
"an",
"object",
"with",
"all",
"of",
"the",
"relevant",
"information",
"for",
"the",
"test",
"."
] | b4b25074acf49cb74740688b4afeb161c5e2a64f | https://github.com/mongodb-js/mocha-evergreen-reporter/blob/b4b25074acf49cb74740688b4afeb161c5e2a64f/index.js#L158-L169 | train |
mongodb-js/mocha-evergreen-reporter | index.js | writeLogs | function writeLogs(test, dirName) {
var logs =
test.fullTitle() +
'\n' +
test.file +
'\nStart: ' +
test.start +
'\nEnd: ' +
test.end +
'\nElapsed: ' +
test.duration +
'\nStatus: ' +
test.state;
if (test.state === 'fail') {
logs += '\nError: ' + test.err.stack;
}
m... | javascript | function writeLogs(test, dirName) {
var logs =
test.fullTitle() +
'\n' +
test.file +
'\nStart: ' +
test.start +
'\nEnd: ' +
test.end +
'\nElapsed: ' +
test.duration +
'\nStatus: ' +
test.state;
if (test.state === 'fail') {
logs += '\nError: ' + test.err.stack;
}
m... | [
"function",
"writeLogs",
"(",
"test",
",",
"dirName",
")",
"{",
"var",
"logs",
"=",
"test",
".",
"fullTitle",
"(",
")",
"+",
"'\\n'",
"+",
"test",
".",
"file",
"+",
"'\\nStart: '",
"+",
"test",
".",
"start",
"+",
"'\\nEnd: '",
"+",
"test",
".",
"end"... | Writes logs to a file in the specified directory
@param {test} test
@param {string} dirName | [
"Writes",
"logs",
"to",
"a",
"file",
"in",
"the",
"specified",
"directory"
] | b4b25074acf49cb74740688b4afeb161c5e2a64f | https://github.com/mongodb-js/mocha-evergreen-reporter/blob/b4b25074acf49cb74740688b4afeb161c5e2a64f/index.js#L176-L195 | train |
MCluck90/clairvoyant | src/compiler.js | generateFileName | function generateFileName(className) {
return className
.replace(/component/gi, '')
.replace(/system/gi, '')
.replace('2D', '2d')
.replace('3D', '3d')
.replace(/^[A-Z]/, function(c) {
return c.toLowerCase();
})
.replace(/[A-Z]/g, function(c) {
... | javascript | function generateFileName(className) {
return className
.replace(/component/gi, '')
.replace(/system/gi, '')
.replace('2D', '2d')
.replace('3D', '3d')
.replace(/^[A-Z]/, function(c) {
return c.toLowerCase();
})
.replace(/[A-Z]/g, function(c) {
... | [
"function",
"generateFileName",
"(",
"className",
")",
"{",
"return",
"className",
".",
"replace",
"(",
"/",
"component",
"/",
"gi",
",",
"''",
")",
".",
"replace",
"(",
"/",
"system",
"/",
"gi",
",",
"''",
")",
".",
"replace",
"(",
"'2D'",
",",
"'2d... | Generates a filename based on the class name given
@param {string} className
@returns {string} | [
"Generates",
"a",
"filename",
"based",
"on",
"the",
"class",
"name",
"given"
] | 4c347499c5fe0f561a53e180d141884b1fa8c21b | https://github.com/MCluck90/clairvoyant/blob/4c347499c5fe0f561a53e180d141884b1fa8c21b/src/compiler.js#L17-L29 | train |
MCluck90/clairvoyant | src/compiler.js | function(ast, reporter, version) {
this.ast = ast;
this.reporter = reporter;
this.psykickVersion = 'psykick' + version;
// Store the Templates so the Systems can access them later
this._templatesByName = {};
} | javascript | function(ast, reporter, version) {
this.ast = ast;
this.reporter = reporter;
this.psykickVersion = 'psykick' + version;
// Store the Templates so the Systems can access them later
this._templatesByName = {};
} | [
"function",
"(",
"ast",
",",
"reporter",
",",
"version",
")",
"{",
"this",
".",
"ast",
"=",
"ast",
";",
"this",
".",
"reporter",
"=",
"reporter",
";",
"this",
".",
"psykickVersion",
"=",
"'psykick'",
"+",
"version",
";",
"// Store the Templates so the System... | Compiles the AST into actual code
@param {AST} ast
@param {Reporter} reporter
@param {string} version
@constructor | [
"Compiles",
"the",
"AST",
"into",
"actual",
"code"
] | 4c347499c5fe0f561a53e180d141884b1fa8c21b | https://github.com/MCluck90/clairvoyant/blob/4c347499c5fe0f561a53e180d141884b1fa8c21b/src/compiler.js#L38-L45 | train | |
enbock/corejs-w3c | src/core.js | CoreEvent | function CoreEvent(typeArg, detail) {
if (detail == undefined) {
detail = {};
}
/**
* Error:
* Failed to construct 'CustomEvent': Please use the 'new' operator, this
* DOM object constructor cannot be called as a function.
*
* In reason of that the browser did not allow to extend CustomEvent i... | javascript | function CoreEvent(typeArg, detail) {
if (detail == undefined) {
detail = {};
}
/**
* Error:
* Failed to construct 'CustomEvent': Please use the 'new' operator, this
* DOM object constructor cannot be called as a function.
*
* In reason of that the browser did not allow to extend CustomEvent i... | [
"function",
"CoreEvent",
"(",
"typeArg",
",",
"detail",
")",
"{",
"if",
"(",
"detail",
"==",
"undefined",
")",
"{",
"detail",
"=",
"{",
"}",
";",
"}",
"/**\r\n\t * Error:\r\n\t * Failed to construct 'CustomEvent': Please use the 'new' operator, this \r\n\t * DOM object cons... | CoreJS events.
@constructor
@param {String} typeArg - Is a String representing the name of the event.
@param {(Object|String|Number)} [detail] - Data to transport over the event. | [
"CoreJS",
"events",
"."
] | ae6b78f17152b1e8ddf1c0031b4f54cb0e419d04 | https://github.com/enbock/corejs-w3c/blob/ae6b78f17152b1e8ddf1c0031b4f54cb0e419d04/src/core.js#L132-L145 | train |
enbock/corejs-w3c | src/core.js | Ajax | function Ajax(method, url, sendData) {
DOMEventListener.call(this);
/**
* Request object.
*
* @access protected
* @type {XMLHttpRequest}
*/
this._request = new Ajax.XHRSystem();
/**
* Method of the request.
*
* @access protected
* @type {String}
*/
this._method = method;
... | javascript | function Ajax(method, url, sendData) {
DOMEventListener.call(this);
/**
* Request object.
*
* @access protected
* @type {XMLHttpRequest}
*/
this._request = new Ajax.XHRSystem();
/**
* Method of the request.
*
* @access protected
* @type {String}
*/
this._method = method;
... | [
"function",
"Ajax",
"(",
"method",
",",
"url",
",",
"sendData",
")",
"{",
"DOMEventListener",
".",
"call",
"(",
"this",
")",
";",
"/**\r\n\t * Request object.\r\n\t *\r\n\t * @access protected\r\n\t * @type {XMLHttpRequest}\r\n\t */",
"this",
".",
"_request",
"=",
"new",
... | Asynchronous JavaScript and XML.
Wrapper to equalize and simplify the usage for AJAX calls.
@constructor
@param {String} method - Type of request (get, post, put, ...).
@param {String} url - Request address.
@param {(Object|String)} sendData - Data to send. | [
"Asynchronous",
"JavaScript",
"and",
"XML",
".",
"Wrapper",
"to",
"equalize",
"and",
"simplify",
"the",
"usage",
"for",
"AJAX",
"calls",
"."
] | ae6b78f17152b1e8ddf1c0031b4f54cb0e419d04 | https://github.com/enbock/corejs-w3c/blob/ae6b78f17152b1e8ddf1c0031b4f54cb0e419d04/src/core.js#L162-L244 | 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.