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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
bertez/quenda | dist/quenda.js | function(step) {
if (!step) {
throw new Error('Not enough arguments');
}
if (Array.isArray(step)) {
step.forEach(function(s) {
this.add(s);
}, this);
} else {
if (step.nextDelay && step.... | javascript | function(step) {
if (!step) {
throw new Error('Not enough arguments');
}
if (Array.isArray(step)) {
step.forEach(function(s) {
this.add(s);
}, this);
} else {
if (step.nextDelay && step.... | [
"function",
"(",
"step",
")",
"{",
"if",
"(",
"!",
"step",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Not enough arguments'",
")",
";",
"}",
"if",
"(",
"Array",
".",
"isArray",
"(",
"step",
")",
")",
"{",
"step",
".",
"forEach",
"(",
"function",
"("... | Adds a new step to this queue
@param {Object} Step definition
@return {Object} This queue instance | [
"Adds",
"a",
"new",
"step",
"to",
"this",
"queue"
] | 63d9adf3e5c22b9417b6fefd4d78f2cce58afbb3 | https://github.com/bertez/quenda/blob/63d9adf3e5c22b9417b6fefd4d78f2cce58afbb3/dist/quenda.js#L28-L58 | train | |
bertez/quenda | dist/quenda.js | function(index) {
var step;
if (!this.steps[index]) {
if (this.config.loop && this._loops < this.config.maxLoops) {
this._loops++;
step = this.steps[this._current = 0];
} else {
return false;
... | javascript | function(index) {
var step;
if (!this.steps[index]) {
if (this.config.loop && this._loops < this.config.maxLoops) {
this._loops++;
step = this.steps[this._current = 0];
} else {
return false;
... | [
"function",
"(",
"index",
")",
"{",
"var",
"step",
";",
"if",
"(",
"!",
"this",
".",
"steps",
"[",
"index",
"]",
")",
"{",
"if",
"(",
"this",
".",
"config",
".",
"loop",
"&&",
"this",
".",
"_loops",
"<",
"this",
".",
"config",
".",
"maxLoops",
... | Executes one element of the queue
@param {number} index the element index | [
"Executes",
"one",
"element",
"of",
"the",
"queue"
] | 63d9adf3e5c22b9417b6fefd4d78f2cce58afbb3 | https://github.com/bertez/quenda/blob/63d9adf3e5c22b9417b6fefd4d78f2cce58afbb3/dist/quenda.js#L118-L156 | train | |
bertez/quenda | dist/quenda.js | function(nextDelay) {
var delay = nextDelay || this.config.defaultDelay;
if (delay && this._playing) {
this._currentTimeout = setTimeout(function() {
this._executeStep(++this._current);
}.bind(this), delay);
}
} | javascript | function(nextDelay) {
var delay = nextDelay || this.config.defaultDelay;
if (delay && this._playing) {
this._currentTimeout = setTimeout(function() {
this._executeStep(++this._current);
}.bind(this), delay);
}
} | [
"function",
"(",
"nextDelay",
")",
"{",
"var",
"delay",
"=",
"nextDelay",
"||",
"this",
".",
"config",
".",
"defaultDelay",
";",
"if",
"(",
"delay",
"&&",
"this",
".",
"_playing",
")",
"{",
"this",
".",
"_currentTimeout",
"=",
"setTimeout",
"(",
"functio... | Sets the execution timeout of the next element in the queue
@param {number} nextDelay the delay in ms | [
"Sets",
"the",
"execution",
"timeout",
"of",
"the",
"next",
"element",
"in",
"the",
"queue"
] | 63d9adf3e5c22b9417b6fefd4d78f2cce58afbb3 | https://github.com/bertez/quenda/blob/63d9adf3e5c22b9417b6fefd4d78f2cce58afbb3/dist/quenda.js#L161-L169 | train | |
bertez/quenda | dist/quenda.js | function(images, callback) {
var loaded = 0;
images.forEach(function(src) {
var image = new Image();
image.onload = function() {
++loaded;
loaded === images.length && callback();
};
image.src ... | javascript | function(images, callback) {
var loaded = 0;
images.forEach(function(src) {
var image = new Image();
image.onload = function() {
++loaded;
loaded === images.length && callback();
};
image.src ... | [
"function",
"(",
"images",
",",
"callback",
")",
"{",
"var",
"loaded",
"=",
"0",
";",
"images",
".",
"forEach",
"(",
"function",
"(",
"src",
")",
"{",
"var",
"image",
"=",
"new",
"Image",
"(",
")",
";",
"image",
".",
"onload",
"=",
"function",
"(",... | Handles the image preload
@param {Array} images array of image urls
@param {Function} callback callback to execute after all the images are loaded | [
"Handles",
"the",
"image",
"preload"
] | 63d9adf3e5c22b9417b6fefd4d78f2cce58afbb3 | https://github.com/bertez/quenda/blob/63d9adf3e5c22b9417b6fefd4d78f2cce58afbb3/dist/quenda.js#L175-L185 | train | |
bertez/quenda | dist/quenda.js | function(config, name) {
if (config && config !== Object(config)) {
throw new Error('Config object should be a key/value object.');
}
var defaultConfig = {
loop: false,
maxLoops: Infinity
};
var instance = Obje... | javascript | function(config, name) {
if (config && config !== Object(config)) {
throw new Error('Config object should be a key/value object.');
}
var defaultConfig = {
loop: false,
maxLoops: Infinity
};
var instance = Obje... | [
"function",
"(",
"config",
",",
"name",
")",
"{",
"if",
"(",
"config",
"&&",
"config",
"!==",
"Object",
"(",
"config",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Config object should be a key/value object.'",
")",
";",
"}",
"var",
"defaultConfig",
"=",
... | Create a new queue
@param {Object} [config] The queue configuration
@param {[type]} [name] The queue name
@return {[type]} The queue instance | [
"Create",
"a",
"new",
"queue"
] | 63d9adf3e5c22b9417b6fefd4d78f2cce58afbb3 | https://github.com/bertez/quenda/blob/63d9adf3e5c22b9417b6fefd4d78f2cce58afbb3/dist/quenda.js#L230-L255 | train | |
cli-kit/cli-help | lib/doc/doc.js | function(program) {
this.cli = program;
this.cmd = this.cli;
if(process.env.CLI_TOOLKIT_HELP_CMD) {
var alias = this.cli.finder.getCommandByName;
var cmd = alias(process.env.CLI_TOOLKIT_HELP_CMD, this.cli.commands());
if(cmd) {
this.cmd = cmd;
}
}
this.eol = eol;
this.format = fmt.TEXT... | javascript | function(program) {
this.cli = program;
this.cmd = this.cli;
if(process.env.CLI_TOOLKIT_HELP_CMD) {
var alias = this.cli.finder.getCommandByName;
var cmd = alias(process.env.CLI_TOOLKIT_HELP_CMD, this.cli.commands());
if(cmd) {
this.cmd = cmd;
}
}
this.eol = eol;
this.format = fmt.TEXT... | [
"function",
"(",
"program",
")",
"{",
"this",
".",
"cli",
"=",
"program",
";",
"this",
".",
"cmd",
"=",
"this",
".",
"cli",
";",
"if",
"(",
"process",
".",
"env",
".",
"CLI_TOOLKIT_HELP_CMD",
")",
"{",
"var",
"alias",
"=",
"this",
".",
"cli",
".",
... | Abstract super class for help documents.
@param program The program instance. | [
"Abstract",
"super",
"class",
"for",
"help",
"documents",
"."
] | 09613efdd753452b466d4deb7c5391c4926e3f04 | https://github.com/cli-kit/cli-help/blob/09613efdd753452b466d4deb7c5391c4926e3f04/lib/doc/doc.js#L27-L87 | train | |
Nazariglez/perenquen | lib/pixi/src/core/renderers/webgl/filters/AbstractFilter.js | AbstractFilter | function AbstractFilter(vertexSrc, fragmentSrc, uniforms)
{
/**
* An array of shaders
* @member {Shader[]}
* @private
*/
this.shaders = [];
/**
* The extra padding that the filter might need
* @member {number}
*/
this.padding = 0;
/**
* The uniforms as an o... | javascript | function AbstractFilter(vertexSrc, fragmentSrc, uniforms)
{
/**
* An array of shaders
* @member {Shader[]}
* @private
*/
this.shaders = [];
/**
* The extra padding that the filter might need
* @member {number}
*/
this.padding = 0;
/**
* The uniforms as an o... | [
"function",
"AbstractFilter",
"(",
"vertexSrc",
",",
"fragmentSrc",
",",
"uniforms",
")",
"{",
"/**\n * An array of shaders\n * @member {Shader[]}\n * @private\n */",
"this",
".",
"shaders",
"=",
"[",
"]",
";",
"/**\n * The extra padding that the filter might ... | This is the base class for creating a PIXI filter. Currently only WebGL supports filters.
If you want to make a custom filter this should be your base class.
@class
@memberof PIXI
@param vertexSrc {string|string[]} The vertex shader source as an array of strings.
@param fragmentSrc {string|string[]} The fragment shade... | [
"This",
"is",
"the",
"base",
"class",
"for",
"creating",
"a",
"PIXI",
"filter",
".",
"Currently",
"only",
"WebGL",
"supports",
"filters",
".",
"If",
"you",
"want",
"to",
"make",
"a",
"custom",
"filter",
"this",
"should",
"be",
"your",
"base",
"class",
".... | e023964d05afeefebdcac4e2044819fdfa3899ae | https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/core/renderers/webgl/filters/AbstractFilter.js#L13-L55 | train |
sourcegraph/defnode.js | defnode.js | function(type, node) {
return seen.indexOf(node) == -1 && ((type == 'AssignmentExpression' && node.right == expr) || (type == 'VariableDeclarator' && node.init == expr));
} | javascript | function(type, node) {
return seen.indexOf(node) == -1 && ((type == 'AssignmentExpression' && node.right == expr) || (type == 'VariableDeclarator' && node.init == expr));
} | [
"function",
"(",
"type",
",",
"node",
")",
"{",
"return",
"seen",
".",
"indexOf",
"(",
"node",
")",
"==",
"-",
"1",
"&&",
"(",
"(",
"type",
"==",
"'AssignmentExpression'",
"&&",
"node",
".",
"right",
"==",
"expr",
")",
"||",
"(",
"type",
"==",
"'Va... | Traverse to parent AssignmentExpressions to return all names in chained assignments. | [
"Traverse",
"to",
"parent",
"AssignmentExpressions",
"to",
"return",
"all",
"names",
"in",
"chained",
"assignments",
"."
] | 8808c966b813d1887f9aaf40643f5a196aafa71d | https://github.com/sourcegraph/defnode.js/blob/8808c966b813d1887f9aaf40643f5a196aafa71d/defnode.js#L170-L172 | train | |
creationix/culvert | wrap-node-socket.js | wrapNodeSocket | function wrapNodeSocket(socket, reportError) {
// Data traveling from node socket to consumer
var incoming = makeChannel();
// Data traveling from consumer to node socket
var outgoing = makeChannel();
var onDrain2 = wrapHandler(onReadable, onError);
onTake = wrapHandler(onTake, onError);
var paused = fa... | javascript | function wrapNodeSocket(socket, reportError) {
// Data traveling from node socket to consumer
var incoming = makeChannel();
// Data traveling from consumer to node socket
var outgoing = makeChannel();
var onDrain2 = wrapHandler(onReadable, onError);
onTake = wrapHandler(onTake, onError);
var paused = fa... | [
"function",
"wrapNodeSocket",
"(",
"socket",
",",
"reportError",
")",
"{",
"// Data traveling from node socket to consumer",
"var",
"incoming",
"=",
"makeChannel",
"(",
")",
";",
"// Data traveling from consumer to node socket",
"var",
"outgoing",
"=",
"makeChannel",
"(",
... | Given a duplex node stream, return a culvert duplex channel. | [
"Given",
"a",
"duplex",
"node",
"stream",
"return",
"a",
"culvert",
"duplex",
"channel",
"."
] | 42b83894041cd7f8ee3993af0df65c1afe17b2c5 | https://github.com/creationix/culvert/blob/42b83894041cd7f8ee3993af0df65c1afe17b2c5/wrap-node-socket.js#L6-L78 | train |
tylerwalters/aias | dist/aias.js | request | function request (type, url, data) {
return new Promise(function (fulfill, reject) {
// Set ajax to correct XHR type. Source: https://gist.github.com/jed/993585
var Xhr = window.XMLHttpRequest||ActiveXObject,
req = new Xhr('MSXML2.XMLHTTP.3.0');
req.open(type, url, true);
req.setRequestHeader('Conte... | javascript | function request (type, url, data) {
return new Promise(function (fulfill, reject) {
// Set ajax to correct XHR type. Source: https://gist.github.com/jed/993585
var Xhr = window.XMLHttpRequest||ActiveXObject,
req = new Xhr('MSXML2.XMLHTTP.3.0');
req.open(type, url, true);
req.setRequestHeader('Conte... | [
"function",
"request",
"(",
"type",
",",
"url",
",",
"data",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"fulfill",
",",
"reject",
")",
"{",
"// Set ajax to correct XHR type. Source: https://gist.github.com/jed/993585",
"var",
"Xhr",
"=",
"window",
... | Attempts to parse the response as JSON otherwise returns it untouched.
@param {string} type The HTTP verb to be used.
@param {string} url The url for the XHR request.
@param {object} data Optional. The data to be passed with a POST or PUT request.
@memberof aias | [
"Attempts",
"to",
"parse",
"the",
"response",
"as",
"JSON",
"otherwise",
"returns",
"it",
"untouched",
"."
] | 798011b6e3585296a8ead80f74b1f9f05ce02cdf | https://github.com/tylerwalters/aias/blob/798011b6e3585296a8ead80f74b1f9f05ce02cdf/dist/aias.js#L38-L59 | train |
PointSource/cordova-browsersync-primitives | startBrowserSync.js | monkeyPatch | function monkeyPatch() {
var script = function() {
window.__karma__ = true;
(function patch() {
if (typeof window.__bs === 'undefined') {
window.setTimeout(patch, 500);
} else {
var oldCanSync = window.__bs.prototype.canSync;
window.__bs.prototype.canSync = function(data, optPath) {
data.url... | javascript | function monkeyPatch() {
var script = function() {
window.__karma__ = true;
(function patch() {
if (typeof window.__bs === 'undefined') {
window.setTimeout(patch, 500);
} else {
var oldCanSync = window.__bs.prototype.canSync;
window.__bs.prototype.canSync = function(data, optPath) {
data.url... | [
"function",
"monkeyPatch",
"(",
")",
"{",
"var",
"script",
"=",
"function",
"(",
")",
"{",
"window",
".",
"__karma__",
"=",
"true",
";",
"(",
"function",
"patch",
"(",
")",
"{",
"if",
"(",
"typeof",
"window",
".",
"__bs",
"===",
"'undefined'",
")",
"... | Private function that adds the code snippet to deal with reloading
files when they are served from platform folders | [
"Private",
"function",
"that",
"adds",
"the",
"code",
"snippet",
"to",
"deal",
"with",
"reloading",
"files",
"when",
"they",
"are",
"served",
"from",
"platform",
"folders"
] | 2117d846d45d1d4a8978847ef6fd1708f33f0e20 | https://github.com/PointSource/cordova-browsersync-primitives/blob/2117d846d45d1d4a8978847ef6fd1708f33f0e20/startBrowserSync.js#L12-L28 | train |
PointSource/cordova-browsersync-primitives | startBrowserSync.js | startBrowserSync | function startBrowserSync(cordovaDir, platforms, opts, cb) {
var defaults = {
logFileChanges: true,
logConnections: true,
open: false,
snippetOptions: {
rule: {
match: /<\/body>/i,
fn: function(snippet, match) {
return monkeyPatch() + snippet + match;
}
}
},
minify: false,
watchOpt... | javascript | function startBrowserSync(cordovaDir, platforms, opts, cb) {
var defaults = {
logFileChanges: true,
logConnections: true,
open: false,
snippetOptions: {
rule: {
match: /<\/body>/i,
fn: function(snippet, match) {
return monkeyPatch() + snippet + match;
}
}
},
minify: false,
watchOpt... | [
"function",
"startBrowserSync",
"(",
"cordovaDir",
",",
"platforms",
",",
"opts",
",",
"cb",
")",
"{",
"var",
"defaults",
"=",
"{",
"logFileChanges",
":",
"true",
",",
"logConnections",
":",
"true",
",",
"open",
":",
"false",
",",
"snippetOptions",
":",
"{... | Starts the browser sync server.
@param {String} cordovaDir - File path to the root of the cordova project (where the platforms/ directory can be found)
@param {Array} platforms - Array of strings, each of which is a Cordova platform name to serve.
@param {Object} opts - Options Object to be passed to browserSync. If th... | [
"Starts",
"the",
"browser",
"sync",
"server",
"."
] | 2117d846d45d1d4a8978847ef6fd1708f33f0e20 | https://github.com/PointSource/cordova-browsersync-primitives/blob/2117d846d45d1d4a8978847ef6fd1708f33f0e20/startBrowserSync.js#L38-L92 | train |
danillouz/product-hunt | src/index.js | productHunt | function productHunt() {
let queryParams = { };
return {
/**
* Sets the request query parameters to fetch the
* most popular products from Product Hunt.
*
* @return {Object} `productHunt` module
*/
popular() {
queryParams.filter = 'popular';
return this;
},
/**
* Sets the request q... | javascript | function productHunt() {
let queryParams = { };
return {
/**
* Sets the request query parameters to fetch the
* most popular products from Product Hunt.
*
* @return {Object} `productHunt` module
*/
popular() {
queryParams.filter = 'popular';
return this;
},
/**
* Sets the request q... | [
"function",
"productHunt",
"(",
")",
"{",
"let",
"queryParams",
"=",
"{",
"}",
";",
"return",
"{",
"/**\n\t\t * Sets the request query parameters to fetch the\n\t\t * most popular products from Product Hunt.\n\t\t *\n\t\t * @return {Object} `productHunt` module\n\t\t */",
"popular",
"(... | Creates interface to build requests to retrieve products
from the public Product Hunt API.
@return {Object} `productHunt` module | [
"Creates",
"interface",
"to",
"build",
"requests",
"to",
"retrieve",
"products",
"from",
"the",
"public",
"Product",
"Hunt",
"API",
"."
] | de7196db39365874055ad363cf3736de6de13856 | https://github.com/danillouz/product-hunt/blob/de7196db39365874055ad363cf3736de6de13856/src/index.js#L17-L107 | train |
LaxarJS/karma-laxar | lib/index.js | readRequireConfig | function readRequireConfig( file ) {
'use strict';
var config = fs.readFileSync( file );
/*jshint -W054*/
var evaluate = new Function( 'var window = this;' + config + '; return require || window.require;' );
return evaluate.call( {} );
} | javascript | function readRequireConfig( file ) {
'use strict';
var config = fs.readFileSync( file );
/*jshint -W054*/
var evaluate = new Function( 'var window = this;' + config + '; return require || window.require;' );
return evaluate.call( {} );
} | [
"function",
"readRequireConfig",
"(",
"file",
")",
"{",
"'use strict'",
";",
"var",
"config",
"=",
"fs",
".",
"readFileSync",
"(",
"file",
")",
";",
"/*jshint -W054*/",
"var",
"evaluate",
"=",
"new",
"Function",
"(",
"'var window = this;'",
"+",
"config",
"+",... | Evaluate the require_config.js file and return the configuration. | [
"Evaluate",
"the",
"require_config",
".",
"js",
"file",
"and",
"return",
"the",
"configuration",
"."
] | 959680d5ae6336bb0ca86ce77eab70fde087ae9b | https://github.com/LaxarJS/karma-laxar/blob/959680d5ae6336bb0ca86ce77eab70fde087ae9b/lib/index.js#L23-L29 | train |
ctrees/msfeature | lib/utils/detect-series.js | _detect | function _detect(eachFn, arr, iterator, mainCallback) {
eachFn(arr, function (x, index, callback) {
iterator(x, function (v, result) {
if (v) {
mainCallback(result || x);
mainCallback = async.noop;
} else {
callback();
}
});
}, function () {
mainCallback();
})... | javascript | function _detect(eachFn, arr, iterator, mainCallback) {
eachFn(arr, function (x, index, callback) {
iterator(x, function (v, result) {
if (v) {
mainCallback(result || x);
mainCallback = async.noop;
} else {
callback();
}
});
}, function () {
mainCallback();
})... | [
"function",
"_detect",
"(",
"eachFn",
",",
"arr",
",",
"iterator",
",",
"mainCallback",
")",
"{",
"eachFn",
"(",
"arr",
",",
"function",
"(",
"x",
",",
"index",
",",
"callback",
")",
"{",
"iterator",
"(",
"x",
",",
"function",
"(",
"v",
",",
"result"... | From async.js, modified to return an optional result.
@param eachFn
@param arr
@param iterator
@param mainCallback
@private | [
"From",
"async",
".",
"js",
"modified",
"to",
"return",
"an",
"optional",
"result",
"."
] | 5ee14fe11ade502ab2b47467717094ea9ea7b6ec | https://github.com/ctrees/msfeature/blob/5ee14fe11ade502ab2b47467717094ea9ea7b6ec/lib/utils/detect-series.js#L20-L33 | train |
tolokoban/ToloFrameWork | ker/mod/tfw.pointer-events.js | getCurrentTarget | function getCurrentTarget( slot ) {
if( !G.target ) return null;
for( var i = 0 ; i < G.target.length ; i++ ) {
var target = G.target[i];
if( !slot || typeof target.slots[slot] === 'function' ) return target;
}
return null;
} | javascript | function getCurrentTarget( slot ) {
if( !G.target ) return null;
for( var i = 0 ; i < G.target.length ; i++ ) {
var target = G.target[i];
if( !slot || typeof target.slots[slot] === 'function' ) return target;
}
return null;
} | [
"function",
"getCurrentTarget",
"(",
"slot",
")",
"{",
"if",
"(",
"!",
"G",
".",
"target",
")",
"return",
"null",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"G",
".",
"target",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"target"... | Return the first taget listening on this `slot`. | [
"Return",
"the",
"first",
"taget",
"listening",
"on",
"this",
"slot",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/tfw.pointer-events.js#L359-L366 | train |
MeldCE/skemer | src/lib/skemer.js | validateNew | function validateNew(options) {
options = validateOptions(options);
//console.log('options after validation', util.inspect(options, {depth: null}));
//return;
//console.log('skemer.validateAdd called', arguments);
return validateData.apply(this, [options,
undefined].concat(Array.prototype.slice.call(... | javascript | function validateNew(options) {
options = validateOptions(options);
//console.log('options after validation', util.inspect(options, {depth: null}));
//return;
//console.log('skemer.validateAdd called', arguments);
return validateData.apply(this, [options,
undefined].concat(Array.prototype.slice.call(... | [
"function",
"validateNew",
"(",
"options",
")",
"{",
"options",
"=",
"validateOptions",
"(",
"options",
")",
";",
"//console.log('options after validation', util.inspect(options, {depth: null}));",
"//return;",
"//console.log('skemer.validateAdd called', arguments);",
"return",
"va... | Validate and merge new data based on the given schema.
@param {Object} options An object containing the validation
[`options`]{@link #options}, including the [`schema`]{@link #schema}
@param {...*} newData Data to validate, merge and return
@returns {*} Validated and merged data | [
"Validate",
"and",
"merge",
"new",
"data",
"based",
"on",
"the",
"given",
"schema",
"."
] | 9ef7b00c7c96db5d13c368180b2f660e571de44c | https://github.com/MeldCE/skemer/blob/9ef7b00c7c96db5d13c368180b2f660e571de44c/src/lib/skemer.js#L740-L749 | train |
MeldCE/skemer | src/lib/skemer.js | function () {
return validateData.apply(this, [this.options,
undefined].concat(Array.prototype.slice.call(arguments)));
} | javascript | function () {
return validateData.apply(this, [this.options,
undefined].concat(Array.prototype.slice.call(arguments)));
} | [
"function",
"(",
")",
"{",
"return",
"validateData",
".",
"apply",
"(",
"this",
",",
"[",
"this",
".",
"options",
",",
"undefined",
"]",
".",
"concat",
"(",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
")",
")",
";",
... | Validate and merge new data based on the stored schema.
@param {...*} newData Data to validate, merge and return. If no data is
given, a variable containing any default values, if configured,
will be returned.
@returns {*} Validated and merged data | [
"Validate",
"and",
"merge",
"new",
"data",
"based",
"on",
"the",
"stored",
"schema",
"."
] | 9ef7b00c7c96db5d13c368180b2f660e571de44c | https://github.com/MeldCE/skemer/blob/9ef7b00c7c96db5d13c368180b2f660e571de44c/src/lib/skemer.js#L955-L958 | train | |
redisjs/jsr-server | lib/command/server/slowlog.js | reset | function reset(req, res) {
this.state.slowlog.reset();
res.send(null, Constants.OK);
} | javascript | function reset(req, res) {
this.state.slowlog.reset();
res.send(null, Constants.OK);
} | [
"function",
"reset",
"(",
"req",
",",
"res",
")",
"{",
"this",
".",
"state",
".",
"slowlog",
".",
"reset",
"(",
")",
";",
"res",
".",
"send",
"(",
"null",
",",
"Constants",
".",
"OK",
")",
";",
"}"
] | Respond to the RESET subcommand. | [
"Respond",
"to",
"the",
"RESET",
"subcommand",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/slowlog.js#L34-L37 | train |
redisjs/jsr-server | lib/command/server/slowlog.js | validate | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var sub = info.command.sub
, scmd = ('' + sub.cmd)
, args = sub.args
, amount;
if(scmd === Constants.SUBCOMMAND.slowlog.get.name && args.length) {
if(args.length > 1) {
throw new CommandArgLength... | javascript | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var sub = info.command.sub
, scmd = ('' + sub.cmd)
, args = sub.args
, amount;
if(scmd === Constants.SUBCOMMAND.slowlog.get.name && args.length) {
if(args.length > 1) {
throw new CommandArgLength... | [
"function",
"validate",
"(",
"cmd",
",",
"args",
",",
"info",
")",
"{",
"AbstractCommand",
".",
"prototype",
".",
"validate",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"var",
"sub",
"=",
"info",
".",
"command",
".",
"sub",
",",
"scmd",
"... | Validate the SLOWLOG subcommands. | [
"Validate",
"the",
"SLOWLOG",
"subcommands",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/slowlog.js#L42-L59 | train |
freeqaz/sassify-object | sassify.js | sassifyFn | function sassifyFn(rawObject) {
var sassified = '';
Object.keys(rawObject).forEach(function iterateVariables(key) {
var variable = rawObject[key];
var stringified = JSON.stringify(variable);
// Trim off double quotes for CSS variables.
stringified = stringified.substring(1, stringified.length - 1... | javascript | function sassifyFn(rawObject) {
var sassified = '';
Object.keys(rawObject).forEach(function iterateVariables(key) {
var variable = rawObject[key];
var stringified = JSON.stringify(variable);
// Trim off double quotes for CSS variables.
stringified = stringified.substring(1, stringified.length - 1... | [
"function",
"sassifyFn",
"(",
"rawObject",
")",
"{",
"var",
"sassified",
"=",
"''",
";",
"Object",
".",
"keys",
"(",
"rawObject",
")",
".",
"forEach",
"(",
"function",
"iterateVariables",
"(",
"key",
")",
"{",
"var",
"variable",
"=",
"rawObject",
"[",
"k... | Converts a single-depth javascript object into SASS variables.
@param {Object} rawObject Object to convert to SASS variables.
@returns {string} Sass content with variables defined. | [
"Converts",
"a",
"single",
"-",
"depth",
"javascript",
"object",
"into",
"SASS",
"variables",
"."
] | a828e884dd7b588d7b7cf3f7b4c7302a7d9b789f | https://github.com/freeqaz/sassify-object/blob/a828e884dd7b588d7b7cf3f7b4c7302a7d9b789f/sassify.js#L10-L25 | train |
andrewscwei/requiem | src/helpers/noval.js | noval | function noval(value, recursive) {
assertType(recursive, 'boolean', true, 'Invalid parameter: recursive');
if (recursive === undefined) recursive = false;
if (value === undefined || value === null) {
return true;
}
else if (typeof value === 'string') {
return (value === '');
}
else if (recursive... | javascript | function noval(value, recursive) {
assertType(recursive, 'boolean', true, 'Invalid parameter: recursive');
if (recursive === undefined) recursive = false;
if (value === undefined || value === null) {
return true;
}
else if (typeof value === 'string') {
return (value === '');
}
else if (recursive... | [
"function",
"noval",
"(",
"value",
",",
"recursive",
")",
"{",
"assertType",
"(",
"recursive",
",",
"'boolean'",
",",
"true",
",",
"'Invalid parameter: recursive'",
")",
";",
"if",
"(",
"recursive",
"===",
"undefined",
")",
"recursive",
"=",
"false",
";",
"i... | Checks if a given value is equal to null. Option to specify recursion, which
would further evaluate inner elements, such as when an Array or Object is
specified.
@param {*} value - Value to evaluate.
@param {boolean} [recursive=false] - Specifies whether to recursively
evaluate the supplied value's inner
values (i.e. ... | [
"Checks",
"if",
"a",
"given",
"value",
"is",
"equal",
"to",
"null",
".",
"Option",
"to",
"specify",
"recursion",
"which",
"would",
"further",
"evaluate",
"inner",
"elements",
"such",
"as",
"when",
"an",
"Array",
"or",
"Object",
"is",
"specified",
"."
] | c4182bfffc9841c6de5718f689ad3c2060511777 | https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/helpers/noval.js#L21-L51 | train |
Psychopoulet/node-promfs | lib/extends/_filesToStream.js | _readContent | function _readContent (files, writeStream, separator) {
return 0 >= files.length ? Promise.resolve() : Promise.resolve().then(() => {
const file = files.shift().trim();
return isFileProm(file).then((exists) => {
const isPattern = -1 < separator.indexOf("{{filename}}");
return !exists ? _readCo... | javascript | function _readContent (files, writeStream, separator) {
return 0 >= files.length ? Promise.resolve() : Promise.resolve().then(() => {
const file = files.shift().trim();
return isFileProm(file).then((exists) => {
const isPattern = -1 < separator.indexOf("{{filename}}");
return !exists ? _readCo... | [
"function",
"_readContent",
"(",
"files",
",",
"writeStream",
",",
"separator",
")",
"{",
"return",
"0",
">=",
"files",
".",
"length",
"?",
"Promise",
".",
"resolve",
"(",
")",
":",
"Promise",
".",
"resolve",
"(",
")",
".",
"then",
"(",
"(",
")",
"=>... | methods
Specific to "filesToString" method, read all files content
@param {Array} files : files to read
@param {stream.Transform} writeStream : stream to send data
@param {string} separator : used to separate content (can be "")
@returns {Promise} Operation's result | [
"methods",
"Specific",
"to",
"filesToString",
"method",
"read",
"all",
"files",
"content"
] | 016e272fc58c6ef6eae5ea551a0e8873f0ac20cc | https://github.com/Psychopoulet/node-promfs/blob/016e272fc58c6ef6eae5ea551a0e8873f0ac20cc/lib/extends/_filesToStream.js#L24-L92 | train |
redisjs/jsr-store | lib/command/hash.js | hsetnx | function hsetnx(key, field, value, req) {
var val = this.getKey(key, req)
, exists = this.hexists(key, field, req);
if(!val) {
val = new HashMap();
this.setKey(key, val, undefined, undefined, undefined, req);
}
if(!exists) {
// set on the hashmap
val.setKey(field, value);
}
return exists... | javascript | function hsetnx(key, field, value, req) {
var val = this.getKey(key, req)
, exists = this.hexists(key, field, req);
if(!val) {
val = new HashMap();
this.setKey(key, val, undefined, undefined, undefined, req);
}
if(!exists) {
// set on the hashmap
val.setKey(field, value);
}
return exists... | [
"function",
"hsetnx",
"(",
"key",
",",
"field",
",",
"value",
",",
"req",
")",
"{",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
",",
"exists",
"=",
"this",
".",
"hexists",
"(",
"key",
",",
"field",
",",
"req",
")",
";... | Sets field in the hash stored at key to value, only
if field does not yet exist. | [
"Sets",
"field",
"in",
"the",
"hash",
"stored",
"at",
"key",
"to",
"value",
"only",
"if",
"field",
"does",
"not",
"yet",
"exist",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/hash.js#L34-L46 | train |
redisjs/jsr-store | lib/command/hash.js | hget | function hget(key, field, req) {
// get at db level
var val = this.getKey(key, req);
if(!val) return null;
// get at hash level
val = val.getKey(field)
if(!val) return null;
return val;
} | javascript | function hget(key, field, req) {
// get at db level
var val = this.getKey(key, req);
if(!val) return null;
// get at hash level
val = val.getKey(field)
if(!val) return null;
return val;
} | [
"function",
"hget",
"(",
"key",
",",
"field",
",",
"req",
")",
"{",
"// get at db level",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
";",
"if",
"(",
"!",
"val",
")",
"return",
"null",
";",
"// get at hash level",
"val",
"=... | Get the value of a hash field. | [
"Get",
"the",
"value",
"of",
"a",
"hash",
"field",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/hash.js#L51-L59 | train |
redisjs/jsr-store | lib/command/hash.js | hexists | function hexists(key, field, req) {
var val = this.getKey(key, req);
if(!val) return 0;
return val.keyExists(field);
} | javascript | function hexists(key, field, req) {
var val = this.getKey(key, req);
if(!val) return 0;
return val.keyExists(field);
} | [
"function",
"hexists",
"(",
"key",
",",
"field",
",",
"req",
")",
"{",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
";",
"if",
"(",
"!",
"val",
")",
"return",
"0",
";",
"return",
"val",
".",
"keyExists",
"(",
"field",
... | Determine if a hash field exists. | [
"Determine",
"if",
"a",
"hash",
"field",
"exists",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/hash.js#L64-L68 | train |
redisjs/jsr-store | lib/command/hash.js | hgetall | function hgetall(key, req) {
var val = this.getKey(key, req)
, list = [];
if(!val) return list;
val.getKeys().forEach(function(k) {
list.push(k, '' + val.getKey(k));
});
return list;
} | javascript | function hgetall(key, req) {
var val = this.getKey(key, req)
, list = [];
if(!val) return list;
val.getKeys().forEach(function(k) {
list.push(k, '' + val.getKey(k));
});
return list;
} | [
"function",
"hgetall",
"(",
"key",
",",
"req",
")",
"{",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
",",
"list",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"val",
")",
"return",
"list",
";",
"val",
".",
"getKeys",
"(",
")... | Get all the fields and values in a hash. | [
"Get",
"all",
"the",
"fields",
"and",
"values",
"in",
"a",
"hash",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/hash.js#L73-L82 | train |
redisjs/jsr-store | lib/command/hash.js | hkeys | function hkeys(key, req) {
var val = this.getKey(key, req);
if(!val) return [];
return val.getKeys();
} | javascript | function hkeys(key, req) {
var val = this.getKey(key, req);
if(!val) return [];
return val.getKeys();
} | [
"function",
"hkeys",
"(",
"key",
",",
"req",
")",
"{",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
";",
"if",
"(",
"!",
"val",
")",
"return",
"[",
"]",
";",
"return",
"val",
".",
"getKeys",
"(",
")",
";",
"}"
] | Get all the fields in a hash. | [
"Get",
"all",
"the",
"fields",
"in",
"a",
"hash",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/hash.js#L87-L91 | train |
redisjs/jsr-store | lib/command/hash.js | hlen | function hlen(key, req) {
var val = this.getKey(key, req);
if(!val) return 0;
return val.hlen();
} | javascript | function hlen(key, req) {
var val = this.getKey(key, req);
if(!val) return 0;
return val.hlen();
} | [
"function",
"hlen",
"(",
"key",
",",
"req",
")",
"{",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
";",
"if",
"(",
"!",
"val",
")",
"return",
"0",
";",
"return",
"val",
".",
"hlen",
"(",
")",
";",
"}"
] | Get the number of fields in a hash. | [
"Get",
"the",
"number",
"of",
"fields",
"in",
"a",
"hash",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/hash.js#L96-L100 | train |
redisjs/jsr-store | lib/command/hash.js | hdel | function hdel(key /* field-1, field-N, req */) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length - 1] === 'object'
? args.pop() : null
, val = this.getKey(key, req)
, deleted = 0
, i;
// nothing at key
if(!val) return 0;
for(i = 0;i < args.length;i++) {
deleted ... | javascript | function hdel(key /* field-1, field-N, req */) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length - 1] === 'object'
? args.pop() : null
, val = this.getKey(key, req)
, deleted = 0
, i;
// nothing at key
if(!val) return 0;
for(i = 0;i < args.length;i++) {
deleted ... | [
"function",
"hdel",
"(",
"key",
"/* field-1, field-N, req */",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
",",
"req",
"=",
"typeof",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
"===",
"'object'",
"?",
... | Delete one or more hash fields. | [
"Delete",
"one",
"or",
"more",
"hash",
"fields",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/hash.js#L118-L138 | train |
redisjs/jsr-store | lib/command/hash.js | hmget | function hmget(key /* field-1, field-N, req */) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length - 1] === 'object'
? args.pop() : null
, val = this.getKey(key, req)
, value
, list = []
, i;
for(i = 0;i < args.length;i++) {
if(!val) {
list.push(null);
... | javascript | function hmget(key /* field-1, field-N, req */) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length - 1] === 'object'
? args.pop() : null
, val = this.getKey(key, req)
, value
, list = []
, i;
for(i = 0;i < args.length;i++) {
if(!val) {
list.push(null);
... | [
"function",
"hmget",
"(",
"key",
"/* field-1, field-N, req */",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
",",
"req",
"=",
"typeof",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
"===",
"'object'",
"?",
... | Returns the values associated with the specified fields in
the hash stored at key. | [
"Returns",
"the",
"values",
"associated",
"with",
"the",
"specified",
"fields",
"in",
"the",
"hash",
"stored",
"at",
"key",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/hash.js#L144-L161 | train |
redisjs/jsr-store | lib/command/hash.js | hmset | function hmset(key /* field-1, value-1, field-N, value-N, req */) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length - 1] === 'object'
? args.pop() : null
, val = this.getKey(key, req)
, i;
if(!val) {
val = new HashMap();
this.setKey(key, val, undefined, undefined, un... | javascript | function hmset(key /* field-1, value-1, field-N, value-N, req */) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length - 1] === 'object'
? args.pop() : null
, val = this.getKey(key, req)
, i;
if(!val) {
val = new HashMap();
this.setKey(key, val, undefined, undefined, un... | [
"function",
"hmset",
"(",
"key",
"/* field-1, value-1, field-N, value-N, req */",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
",",
"req",
"=",
"typeof",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
"===",
"'... | Sets the specified fields to their respective values in
the hash stored at key. | [
"Sets",
"the",
"specified",
"fields",
"to",
"their",
"respective",
"values",
"in",
"the",
"hash",
"stored",
"at",
"key",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/hash.js#L167-L182 | train |
redisjs/jsr-store | lib/command/hash.js | hincrbyfloat | function hincrbyfloat(key, field, amount, req) {
var map = this.getKey(key, req)
, val;
if(!map) {
map = new HashMap();
this.setKey(key, map, undefined, undefined, undefined, req);
}
val = utils.strtofloat(map.getKey(field));
amount = utils.strtofloat(amount);
val += amount;
map.setKey(field, ... | javascript | function hincrbyfloat(key, field, amount, req) {
var map = this.getKey(key, req)
, val;
if(!map) {
map = new HashMap();
this.setKey(key, map, undefined, undefined, undefined, req);
}
val = utils.strtofloat(map.getKey(field));
amount = utils.strtofloat(amount);
val += amount;
map.setKey(field, ... | [
"function",
"hincrbyfloat",
"(",
"key",
",",
"field",
",",
"amount",
",",
"req",
")",
"{",
"var",
"map",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
",",
"val",
";",
"if",
"(",
"!",
"map",
")",
"{",
"map",
"=",
"new",
"HashMap",
"(... | Increment the specified field of hash stored at key, and
representing a floating point number, by the specified increment. | [
"Increment",
"the",
"specified",
"field",
"of",
"hash",
"stored",
"at",
"key",
"and",
"representing",
"a",
"floating",
"point",
"number",
"by",
"the",
"specified",
"increment",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/hash.js#L188-L203 | train |
redisjs/jsr-store | lib/command/hash.js | hincrby | function hincrby(key, field, amount, req) {
var map = this.getKey(key, req)
, val;
if(!map) {
map = new HashMap();
this.setKey(key, map, undefined, undefined, undefined, req);
}
val = utils.strtoint(map.getKey(field));
amount = utils.strtoint(amount);
val += amount;
map.setKey(field, val);
r... | javascript | function hincrby(key, field, amount, req) {
var map = this.getKey(key, req)
, val;
if(!map) {
map = new HashMap();
this.setKey(key, map, undefined, undefined, undefined, req);
}
val = utils.strtoint(map.getKey(field));
amount = utils.strtoint(amount);
val += amount;
map.setKey(field, val);
r... | [
"function",
"hincrby",
"(",
"key",
",",
"field",
",",
"amount",
",",
"req",
")",
"{",
"var",
"map",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
",",
"val",
";",
"if",
"(",
"!",
"map",
")",
"{",
"map",
"=",
"new",
"HashMap",
"(",
... | Increments the number stored at field in the
hash stored at key by increment. | [
"Increments",
"the",
"number",
"stored",
"at",
"field",
"in",
"the",
"hash",
"stored",
"at",
"key",
"by",
"increment",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/hash.js#L209-L221 | train |
nanowizard/vec23 | src/Vec3.js | function(v) {
if (v instanceof Vec3) {
return new Vec3(this.x + v.x, this.y + v.y, this.z + v.z);
}
else if(v instanceof Vec2){
return new Vec3(this.x + v.x, this.y + v.y, this.z);
}
else if(typeof v === 'number') {
return new Vec3(this.x + v, ... | javascript | function(v) {
if (v instanceof Vec3) {
return new Vec3(this.x + v.x, this.y + v.y, this.z + v.z);
}
else if(v instanceof Vec2){
return new Vec3(this.x + v.x, this.y + v.y, this.z);
}
else if(typeof v === 'number') {
return new Vec3(this.x + v, ... | [
"function",
"(",
"v",
")",
"{",
"if",
"(",
"v",
"instanceof",
"Vec3",
")",
"{",
"return",
"new",
"Vec3",
"(",
"this",
".",
"x",
"+",
"v",
".",
"x",
",",
"this",
".",
"y",
"+",
"v",
".",
"y",
",",
"this",
".",
"z",
"+",
"v",
".",
"z",
")",... | Adds the vector to a vector or Number and returns a new vector.
@memberof Vec3#
@param {Vec3|Vec2|Number} v vector or Number to add.
@returns {Vec3} resulting vector | [
"Adds",
"the",
"vector",
"to",
"a",
"vector",
"or",
"Number",
"and",
"returns",
"a",
"new",
"vector",
"."
] | e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364 | https://github.com/nanowizard/vec23/blob/e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364/src/Vec3.js#L38-L51 | train | |
nanowizard/vec23 | src/Vec3.js | function() {
return {
theta: Math.atan2(this.z, this.x),
phi: Math.asin(this.y / this.length())
};
} | javascript | function() {
return {
theta: Math.atan2(this.z, this.x),
phi: Math.asin(this.y / this.length())
};
} | [
"function",
"(",
")",
"{",
"return",
"{",
"theta",
":",
"Math",
".",
"atan2",
"(",
"this",
".",
"z",
",",
"this",
".",
"x",
")",
",",
"phi",
":",
"Math",
".",
"asin",
"(",
"this",
".",
"y",
"/",
"this",
".",
"length",
"(",
")",
")",
"}",
";... | Computes the theta & phi angles of the vector.
@memberof Vec3#
@returns {object} ret
@returns {Number} ret.theta - angle from the xz plane
@returns {Number} ret.phi - angle from the y axis | [
"Computes",
"the",
"theta",
"&",
"phi",
"angles",
"of",
"the",
"vector",
"."
] | e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364 | https://github.com/nanowizard/vec23/blob/e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364/src/Vec3.js#L359-L364 | train | |
nanowizard/vec23 | src/Vec3.js | function(dec) {
if(!dec){
dec = 2;
}
return '{x: ' + this.x.toFixed(dec) + ', y: ' + this.y.toFixed(dec) + ', z: ' + this.z.toFixed(dec) + '}';
} | javascript | function(dec) {
if(!dec){
dec = 2;
}
return '{x: ' + this.x.toFixed(dec) + ', y: ' + this.y.toFixed(dec) + ', z: ' + this.z.toFixed(dec) + '}';
} | [
"function",
"(",
"dec",
")",
"{",
"if",
"(",
"!",
"dec",
")",
"{",
"dec",
"=",
"2",
";",
"}",
"return",
"'{x: '",
"+",
"this",
".",
"x",
".",
"toFixed",
"(",
"dec",
")",
"+",
"', y: '",
"+",
"this",
".",
"y",
".",
"toFixed",
"(",
"dec",
")",
... | Converts the vector to a string representation.
@memberof Vec3#
@param {Number} [dec=2] - number of decimal places to round to (default is 2)
@returns {string} string of the form {x: <x value>, y: <y value>, z: <z value>} | [
"Converts",
"the",
"vector",
"to",
"a",
"string",
"representation",
"."
] | e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364 | https://github.com/nanowizard/vec23/blob/e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364/src/Vec3.js#L399-L404 | train | |
nanowizard/vec23 | src/Vec3.js | function() {
return new Vec3(Math.round(this.x), Math.round(this.y), Math.round(this.z));
} | javascript | function() {
return new Vec3(Math.round(this.x), Math.round(this.y), Math.round(this.z));
} | [
"function",
"(",
")",
"{",
"return",
"new",
"Vec3",
"(",
"Math",
".",
"round",
"(",
"this",
".",
"x",
")",
",",
"Math",
".",
"round",
"(",
"this",
".",
"y",
")",
",",
"Math",
".",
"round",
"(",
"this",
".",
"z",
")",
")",
";",
"}"
] | Creates a new vector with each of the current x, y and z components rounded to the nearest whole Number.
@memberof Vec3#
@returns {Vec3} | [
"Creates",
"a",
"new",
"vector",
"with",
"each",
"of",
"the",
"current",
"x",
"y",
"and",
"z",
"components",
"rounded",
"to",
"the",
"nearest",
"whole",
"Number",
"."
] | e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364 | https://github.com/nanowizard/vec23/blob/e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364/src/Vec3.js#L418-L420 | train | |
nanowizard/vec23 | src/Vec3.js | function(m){
return new Vec3(
this.x*m[0][0]+this.y*m[0][1]+this.z*m[0][2],
this.x*m[1][0]+this.y*m[1][1]+this.z*m[1][2],
this.x*m[2][0]+this.y*m[2][1]+this.z*m[2][2]
);
} | javascript | function(m){
return new Vec3(
this.x*m[0][0]+this.y*m[0][1]+this.z*m[0][2],
this.x*m[1][0]+this.y*m[1][1]+this.z*m[1][2],
this.x*m[2][0]+this.y*m[2][1]+this.z*m[2][2]
);
} | [
"function",
"(",
"m",
")",
"{",
"return",
"new",
"Vec3",
"(",
"this",
".",
"x",
"*",
"m",
"[",
"0",
"]",
"[",
"0",
"]",
"+",
"this",
".",
"y",
"*",
"m",
"[",
"0",
"]",
"[",
"1",
"]",
"+",
"this",
".",
"z",
"*",
"m",
"[",
"0",
"]",
"["... | Creates a new vector converting the vector to a new coordinate frame.
@memberof Vec3#
@param {Array} m - Coordinate system matrix of the form [[xx,xy,xz],[yx,yy,yz],[zx,zy,zz]]
@returns {Vec3} | [
"Creates",
"a",
"new",
"vector",
"converting",
"the",
"vector",
"to",
"a",
"new",
"coordinate",
"frame",
"."
] | e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364 | https://github.com/nanowizard/vec23/blob/e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364/src/Vec3.js#L454-L460 | train | |
nanowizard/vec23 | src/Vec3.js | function(m){
var x = this.x;
var y = this.y;
var z = this.z;
this.x = x*m[0][0]+y*m[0][1]+z*m[0][2];
this.y = x*m[1][0]+y*m[1][1]+z*m[1][2];
this.z = x*m[2][0]+y*m[2][1]+z*m[2][2];
return this;
} | javascript | function(m){
var x = this.x;
var y = this.y;
var z = this.z;
this.x = x*m[0][0]+y*m[0][1]+z*m[0][2];
this.y = x*m[1][0]+y*m[1][1]+z*m[1][2];
this.z = x*m[2][0]+y*m[2][1]+z*m[2][2];
return this;
} | [
"function",
"(",
"m",
")",
"{",
"var",
"x",
"=",
"this",
".",
"x",
";",
"var",
"y",
"=",
"this",
".",
"y",
";",
"var",
"z",
"=",
"this",
".",
"z",
";",
"this",
".",
"x",
"=",
"x",
"*",
"m",
"[",
"0",
"]",
"[",
"0",
"]",
"+",
"y",
"*",... | Converts this vector to a new coordinate frame.
@memberof Vec3#
@param {Array} m - Coordinate system matrix of the form [[Xx,Xy,Xz],[Yx,Yy,Yz],[Zx,Zy,Zz]]
@returns {Vec3} | [
"Converts",
"this",
"vector",
"to",
"a",
"new",
"coordinate",
"frame",
"."
] | e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364 | https://github.com/nanowizard/vec23/blob/e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364/src/Vec3.js#L467-L475 | train | |
nanowizard/vec23 | src/Vec3.js | function(p){
return new Vec3(Math.pow(this.x, p), Math.pow(this.y, p), Math.pow(this.z, p));
} | javascript | function(p){
return new Vec3(Math.pow(this.x, p), Math.pow(this.y, p), Math.pow(this.z, p));
} | [
"function",
"(",
"p",
")",
"{",
"return",
"new",
"Vec3",
"(",
"Math",
".",
"pow",
"(",
"this",
".",
"x",
",",
"p",
")",
",",
"Math",
".",
"pow",
"(",
"this",
".",
"y",
",",
"p",
")",
",",
"Math",
".",
"pow",
"(",
"this",
".",
"z",
",",
"p... | Raises each component of the vector to the power p and returns a new vector.
@memberof Vec3#
@returns {Vec3} | [
"Raises",
"each",
"component",
"of",
"the",
"vector",
"to",
"the",
"power",
"p",
"and",
"returns",
"a",
"new",
"vector",
"."
] | e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364 | https://github.com/nanowizard/vec23/blob/e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364/src/Vec3.js#L588-L590 | train | |
vkiding/judpack-lib | src/cordova/info.js | execSpawn | function execSpawn(command, args, resultMsg, errorMsg) {
return superspawn.spawn(command, args).then(function(result) {
return resultMsg + result;
}, function(error) {
return errorMsg + error;
});
} | javascript | function execSpawn(command, args, resultMsg, errorMsg) {
return superspawn.spawn(command, args).then(function(result) {
return resultMsg + result;
}, function(error) {
return errorMsg + error;
});
} | [
"function",
"execSpawn",
"(",
"command",
",",
"args",
",",
"resultMsg",
",",
"errorMsg",
")",
"{",
"return",
"superspawn",
".",
"spawn",
"(",
"command",
",",
"args",
")",
".",
"then",
"(",
"function",
"(",
"result",
")",
"{",
"return",
"resultMsg",
"+",
... | Execute using a child_process exec, for any async command | [
"Execute",
"using",
"a",
"child_process",
"exec",
"for",
"any",
"async",
"command"
] | 8657cecfec68221109279106adca8dbc81f430f4 | https://github.com/vkiding/judpack-lib/blob/8657cecfec68221109279106adca8dbc81f430f4/src/cordova/info.js#L33-L39 | train |
stuartpb/aname-poll | index.js | finishQuerying | function finishQuerying(domain, err, records) {
// Set time until our next query
var expiration = Date.now() + ttl * 1000;
// If there was an error querying the domain
if (err) {
// If the domain was not found
if (err.code == 'ENOTFOUND') {
// If we have a function to handle missing... | javascript | function finishQuerying(domain, err, records) {
// Set time until our next query
var expiration = Date.now() + ttl * 1000;
// If there was an error querying the domain
if (err) {
// If the domain was not found
if (err.code == 'ENOTFOUND') {
// If we have a function to handle missing... | [
"function",
"finishQuerying",
"(",
"domain",
",",
"err",
",",
"records",
")",
"{",
"// Set time until our next query",
"var",
"expiration",
"=",
"Date",
".",
"now",
"(",
")",
"+",
"ttl",
"*",
"1000",
";",
"// If there was an error querying the domain",
"if",
"(",
... | Handle the record response from a query | [
"Handle",
"the",
"record",
"response",
"from",
"a",
"query"
] | c2efeef173ca1577922fb6c0a770fd169bfac058 | https://github.com/stuartpb/aname-poll/blob/c2efeef173ca1577922fb6c0a770fd169bfac058/index.js#L26-L97 | train |
stuartpb/aname-poll | index.js | finishProcessing | function finishProcessing(err) {
if (err) return cb(err);
db.eval(hmz, 2, 'processing_domains', 'expiring_domains',
domain, next);
} | javascript | function finishProcessing(err) {
if (err) return cb(err);
db.eval(hmz, 2, 'processing_domains', 'expiring_domains',
domain, next);
} | [
"function",
"finishProcessing",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"return",
"cb",
"(",
"err",
")",
";",
"db",
".",
"eval",
"(",
"hmz",
",",
"2",
",",
"'processing_domains'",
",",
"'expiring_domains'",
",",
"domain",
",",
"next",
")",
";",
... | Mark that we've finished processing records | [
"Mark",
"that",
"we",
"ve",
"finished",
"processing",
"records"
] | c2efeef173ca1577922fb6c0a770fd169bfac058 | https://github.com/stuartpb/aname-poll/blob/c2efeef173ca1577922fb6c0a770fd169bfac058/index.js#L92-L96 | train |
stuartpb/aname-poll | index.js | iface | function iface(end) {
if (end) {
return db.quit(next);
} else {
// Get all the domains whose records expired some time before now
db.eval(scoreRange,2,'expiring_domains','querying_domains',
'-inf', Date.now(), function (err, res) {
if (err) return cb(err);
// Query ... | javascript | function iface(end) {
if (end) {
return db.quit(next);
} else {
// Get all the domains whose records expired some time before now
db.eval(scoreRange,2,'expiring_domains','querying_domains',
'-inf', Date.now(), function (err, res) {
if (err) return cb(err);
// Query ... | [
"function",
"iface",
"(",
"end",
")",
"{",
"if",
"(",
"end",
")",
"{",
"return",
"db",
".",
"quit",
"(",
"next",
")",
";",
"}",
"else",
"{",
"// Get all the domains whose records expired some time before now",
"db",
".",
"eval",
"(",
"scoreRange",
",",
"2",
... | The interface interval function we return | [
"The",
"interface",
"interval",
"function",
"we",
"return"
] | c2efeef173ca1577922fb6c0a770fd169bfac058 | https://github.com/stuartpb/aname-poll/blob/c2efeef173ca1577922fb6c0a770fd169bfac058/index.js#L100-L115 | train |
nusmodifications/nusmoderator | lib/academicCalendar.js | getAcadSem | function getAcadSem(acadWeekNumber) {
var earliestSupportedWeek = 1;
var lastWeekofSem1 = 23;
var lastWeekofSem2 = 40;
var lastWeekofSpecialSem1 = 46;
var lastWeekofSpecialSem2 = 52;
if (acadWeekNumber >= earliestSupportedWeek && acadWeekNumber <= lastWeekofSem1) {
return sem1;
} else if (acadWeekNum... | javascript | function getAcadSem(acadWeekNumber) {
var earliestSupportedWeek = 1;
var lastWeekofSem1 = 23;
var lastWeekofSem2 = 40;
var lastWeekofSpecialSem1 = 46;
var lastWeekofSpecialSem2 = 52;
if (acadWeekNumber >= earliestSupportedWeek && acadWeekNumber <= lastWeekofSem1) {
return sem1;
} else if (acadWeekNum... | [
"function",
"getAcadSem",
"(",
"acadWeekNumber",
")",
"{",
"var",
"earliestSupportedWeek",
"=",
"1",
";",
"var",
"lastWeekofSem1",
"=",
"23",
";",
"var",
"lastWeekofSem2",
"=",
"40",
";",
"var",
"lastWeekofSpecialSem1",
"=",
"46",
";",
"var",
"lastWeekofSpecialS... | Computes the current academic semester.
Expects a week number of a year.
@param {Number} acadWeekNumber - 3
@return {String} semester - "Semester 1" | [
"Computes",
"the",
"current",
"academic",
"semester",
".",
"Expects",
"a",
"week",
"number",
"of",
"a",
"year",
"."
] | 828d80ac47de090b0db3ab0b99cd68363f0fc263 | https://github.com/nusmodifications/nusmoderator/blob/828d80ac47de090b0db3ab0b99cd68363f0fc263/lib/academicCalendar.js#L55-L74 | train |
nusmodifications/nusmoderator | lib/academicCalendar.js | getAcadWeekName | function getAcadWeekName(acadWeekNumber) {
switch (acadWeekNumber) {
case 7:
return {
weekType: 'Recess',
weekNumber: null
};
case 15:
return {
weekType: 'Reading',
weekNumber: null
};
case 16:
case 17:
return {
weekType: 'Examinati... | javascript | function getAcadWeekName(acadWeekNumber) {
switch (acadWeekNumber) {
case 7:
return {
weekType: 'Recess',
weekNumber: null
};
case 15:
return {
weekType: 'Reading',
weekNumber: null
};
case 16:
case 17:
return {
weekType: 'Examinati... | [
"function",
"getAcadWeekName",
"(",
"acadWeekNumber",
")",
"{",
"switch",
"(",
"acadWeekNumber",
")",
"{",
"case",
"7",
":",
"return",
"{",
"weekType",
":",
"'Recess'",
",",
"weekNumber",
":",
"null",
"}",
";",
"case",
"15",
":",
"return",
"{",
"weekType",... | Computes the current academic week of the semester
Expects a week number of a semester.
@param {Number} acadWeekNumber - 3
@return {String} semester - "Recess" | "Reading" | "Examination" | [
"Computes",
"the",
"current",
"academic",
"week",
"of",
"the",
"semester",
"Expects",
"a",
"week",
"number",
"of",
"a",
"semester",
"."
] | 828d80ac47de090b0db3ab0b99cd68363f0fc263 | https://github.com/nusmodifications/nusmoderator/blob/828d80ac47de090b0db3ab0b99cd68363f0fc263/lib/academicCalendar.js#L82-L119 | train |
nusmodifications/nusmoderator | lib/academicCalendar.js | getAcadWeekInfo | function getAcadWeekInfo(date) {
var currentAcad = getAcadYear(date);
var acadYear = currentAcad.year;
var acadYearStartDate = currentAcad.startDate;
var acadWeekNumber = Math.ceil((date.getTime() - acadYearStartDate.getTime() + 1) / oneWeekDuration);
var semester = getAcadSem(acadWeekNumber);
var weekTyp... | javascript | function getAcadWeekInfo(date) {
var currentAcad = getAcadYear(date);
var acadYear = currentAcad.year;
var acadYearStartDate = currentAcad.startDate;
var acadWeekNumber = Math.ceil((date.getTime() - acadYearStartDate.getTime() + 1) / oneWeekDuration);
var semester = getAcadSem(acadWeekNumber);
var weekTyp... | [
"function",
"getAcadWeekInfo",
"(",
"date",
")",
"{",
"var",
"currentAcad",
"=",
"getAcadYear",
"(",
"date",
")",
";",
"var",
"acadYear",
"=",
"currentAcad",
".",
"year",
";",
"var",
"acadYearStartDate",
"=",
"currentAcad",
".",
"startDate",
";",
"var",
"aca... | Computes the current academic week and return in an object of acad date components
@param {Date} date
@return {Object} {
year: "15/16",
sem: 'Semester 1'|'Semester 2'|'Special Sem 1'|'Special Sem 2',
type: 'Instructional'|'Reading'|'Examination'|'Recess'|'Vacation'|'Orientation',
num: <weekNum>
} | [
"Computes",
"the",
"current",
"academic",
"week",
"and",
"return",
"in",
"an",
"object",
"of",
"acad",
"date",
"components"
] | 828d80ac47de090b0db3ab0b99cd68363f0fc263 | https://github.com/nusmodifications/nusmoderator/blob/828d80ac47de090b0db3ab0b99cd68363f0fc263/lib/academicCalendar.js#L131-L187 | train |
redisjs/jsr-server | lib/command/server/lastsave.js | execute | function execute(req, res) {
// stored in milliseconds but this command returns seconds
res.send(null, Math.round(this.state.lastsave / 1000));
} | javascript | function execute(req, res) {
// stored in milliseconds but this command returns seconds
res.send(null, Math.round(this.state.lastsave / 1000));
} | [
"function",
"execute",
"(",
"req",
",",
"res",
")",
"{",
"// stored in milliseconds but this command returns seconds",
"res",
".",
"send",
"(",
"null",
",",
"Math",
".",
"round",
"(",
"this",
".",
"state",
".",
"lastsave",
"/",
"1000",
")",
")",
";",
"}"
] | Respond to the LASTSAVE command. | [
"Respond",
"to",
"the",
"LASTSAVE",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/lastsave.js#L17-L20 | train |
vkiding/judpack-lib | src/util/promise-util.js | Q_chainmap_graceful | function Q_chainmap_graceful(args, func, failureCallback) {
return Q.when().then(function(inValue) {
return args.reduce(function(soFar, arg) {
return soFar.then(function(val) {
return func(arg, val);
}).fail(function(err) {
if (failureCallback) {
... | javascript | function Q_chainmap_graceful(args, func, failureCallback) {
return Q.when().then(function(inValue) {
return args.reduce(function(soFar, arg) {
return soFar.then(function(val) {
return func(arg, val);
}).fail(function(err) {
if (failureCallback) {
... | [
"function",
"Q_chainmap_graceful",
"(",
"args",
",",
"func",
",",
"failureCallback",
")",
"{",
"return",
"Q",
".",
"when",
"(",
")",
".",
"then",
"(",
"function",
"(",
"inValue",
")",
"{",
"return",
"args",
".",
"reduce",
"(",
"function",
"(",
"soFar",
... | Behaves similar to Q_chainmap but gracefully handles failures. When a promise in the chain is rejected, it will call the failureCallback and then continue the processing, instead of stopping | [
"Behaves",
"similar",
"to",
"Q_chainmap",
"but",
"gracefully",
"handles",
"failures",
".",
"When",
"a",
"promise",
"in",
"the",
"chain",
"is",
"rejected",
"it",
"will",
"call",
"the",
"failureCallback",
"and",
"then",
"continue",
"the",
"processing",
"instead",
... | 8657cecfec68221109279106adca8dbc81f430f4 | https://github.com/vkiding/judpack-lib/blob/8657cecfec68221109279106adca8dbc81f430f4/src/util/promise-util.js#L38-L50 | train |
aimingoo/redpoll | Distributed.js | isValueObject | function isValueObject(obj) {
return (obj instanceof Number) || (obj instanceof String) || (obj instanceof Boolean) || (obj === null);
} | javascript | function isValueObject(obj) {
return (obj instanceof Number) || (obj instanceof String) || (obj instanceof Boolean) || (obj === null);
} | [
"function",
"isValueObject",
"(",
"obj",
")",
"{",
"return",
"(",
"obj",
"instanceof",
"Number",
")",
"||",
"(",
"obj",
"instanceof",
"String",
")",
"||",
"(",
"obj",
"instanceof",
"Boolean",
")",
"||",
"(",
"obj",
"===",
"null",
")",
";",
"}"
] | package classes of value types | [
"package",
"classes",
"of",
"value",
"types"
] | c14afc6792154374490d6753ba90fdd76cb6f5c3 | https://github.com/aimingoo/redpoll/blob/c14afc6792154374490d6753ba90fdd76cb6f5c3/Distributed.js#L50-L52 | train |
aimingoo/redpoll | Distributed.js | enter | function enter(f, rejected) {
return function() {
try {
return Promise.resolve(f.apply(this, arguments)).catch(rejected)
}
catch(e) { return rejected(e) }
}
} | javascript | function enter(f, rejected) {
return function() {
try {
return Promise.resolve(f.apply(this, arguments)).catch(rejected)
}
catch(e) { return rejected(e) }
}
} | [
"function",
"enter",
"(",
"f",
",",
"rejected",
")",
"{",
"return",
"function",
"(",
")",
"{",
"try",
"{",
"return",
"Promise",
".",
"resolve",
"(",
"f",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
")",
".",
"catch",
"(",
"rejected",
")",
"}"... | enter a sub-processes with privated rejected method | [
"enter",
"a",
"sub",
"-",
"processes",
"with",
"privated",
"rejected",
"method"
] | c14afc6792154374490d6753ba90fdd76cb6f5c3 | https://github.com/aimingoo/redpoll/blob/c14afc6792154374490d6753ba90fdd76cb6f5c3/Distributed.js#L106-L113 | train |
aimingoo/redpoll | Distributed.js | internal_parse_scope | function internal_parse_scope(center, distributionScope) {
// "?" or "*" is filted by this.require()
if (distributionScope.length < 4) return this.require(":::");
// systemPart:pathPart:scopePart
// - rx_tokens = /^([^:]+):(.*):([^:]+)$/ -> m[0],m[1],m[2]
var rx_tokens = /^(.*):([^:]+)$/, m = distributionScope.... | javascript | function internal_parse_scope(center, distributionScope) {
// "?" or "*" is filted by this.require()
if (distributionScope.length < 4) return this.require(":::");
// systemPart:pathPart:scopePart
// - rx_tokens = /^([^:]+):(.*):([^:]+)$/ -> m[0],m[1],m[2]
var rx_tokens = /^(.*):([^:]+)$/, m = distributionScope.... | [
"function",
"internal_parse_scope",
"(",
"center",
",",
"distributionScope",
")",
"{",
"// \"?\" or \"*\" is filted by this.require()",
"if",
"(",
"distributionScope",
".",
"length",
"<",
"4",
")",
"return",
"this",
".",
"require",
"(",
"\":::\"",
")",
";",
"// syst... | internal distribution scope praser | [
"internal",
"distribution",
"scope",
"praser"
] | c14afc6792154374490d6753ba90fdd76cb6f5c3 | https://github.com/aimingoo/redpoll/blob/c14afc6792154374490d6753ba90fdd76cb6f5c3/Distributed.js#L367-L381 | train |
sendanor/nor-nopg | src/schema/v0011.js | function(db) {
function check_javascript_function(js, plv8, ERROR) {
var fun;
try {
// We'll check only positive input
if(js) {
fun = (new Function('return (' + js + ')'))();
if(! (fun && (fun instanceof Function)) ) {
throw TypeError("Input is not valid JavaScript function: " + (typeof ... | javascript | function(db) {
function check_javascript_function(js, plv8, ERROR) {
var fun;
try {
// We'll check only positive input
if(js) {
fun = (new Function('return (' + js + ')'))();
if(! (fun && (fun instanceof Function)) ) {
throw TypeError("Input is not valid JavaScript function: " + (typeof ... | [
"function",
"(",
"db",
")",
"{",
"function",
"check_javascript_function",
"(",
"js",
",",
"plv8",
",",
"ERROR",
")",
"{",
"var",
"fun",
";",
"try",
"{",
"// We'll check only positive input",
"if",
"(",
"js",
")",
"{",
"fun",
"=",
"(",
"new",
"Function",
... | Function for checking that only valid javascript goes into types.validator column | [
"Function",
"for",
"checking",
"that",
"only",
"valid",
"javascript",
"goes",
"into",
"types",
".",
"validator",
"column"
] | 0d99b86c1a1996b5828b56de8de23700df8bbc0c | https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/schema/v0011.js#L6-L24 | train | |
transomjs/transom-server-functions | release.js | exec | function exec(cmd) {
const ret = shell.exec(cmd, {
silent: true
});
if (ret.code != 0) {
console.error("Error:", ret.stdout, ret.stderr);
process.exit(1);
}
return ret;
} | javascript | function exec(cmd) {
const ret = shell.exec(cmd, {
silent: true
});
if (ret.code != 0) {
console.error("Error:", ret.stdout, ret.stderr);
process.exit(1);
}
return ret;
} | [
"function",
"exec",
"(",
"cmd",
")",
"{",
"const",
"ret",
"=",
"shell",
".",
"exec",
"(",
"cmd",
",",
"{",
"silent",
":",
"true",
"}",
")",
";",
"if",
"(",
"ret",
".",
"code",
"!=",
"0",
")",
"{",
"console",
".",
"error",
"(",
"\"Error:\"",
","... | Run commands quietly, log output and exit only on errors. | [
"Run",
"commands",
"quietly",
"log",
"output",
"and",
"exit",
"only",
"on",
"errors",
"."
] | 68577950f5964031929f6b7360240bdcda65f004 | https://github.com/transomjs/transom-server-functions/blob/68577950f5964031929f6b7360240bdcda65f004/release.js#L29-L39 | train |
haraldrudell/apprunner | lib/rqs.js | shutdown | function shutdown() {
var timer
for (var id in requests)
if (timer = requests[id].timer) {
clearTimeout(timer)
requests[id].timer = null
}
} | javascript | function shutdown() {
var timer
for (var id in requests)
if (timer = requests[id].timer) {
clearTimeout(timer)
requests[id].timer = null
}
} | [
"function",
"shutdown",
"(",
")",
"{",
"var",
"timer",
"for",
"(",
"var",
"id",
"in",
"requests",
")",
"if",
"(",
"timer",
"=",
"requests",
"[",
"id",
"]",
".",
"timer",
")",
"{",
"clearTimeout",
"(",
"timer",
")",
"requests",
"[",
"id",
"]",
".",
... | clear all timers | [
"clear",
"all",
"timers"
] | 8d7dead166c919d160b429e00c49a62027994c33 | https://github.com/haraldrudell/apprunner/blob/8d7dead166c919d160b429e00c49a62027994c33/lib/rqs.js#L219-L227 | train |
nestorivan/flex-grill | gulpfile.js | sassTranspiler | function sassTranspiler(path) {
return function () {
return gulp.src(path)
.pipe(sass({outputStyle: 'compressed'}))
.pipe(autoprefixer({
browsers: ['last 2 versions']
}))
.pipe(gulp.dest('dist'));
}
} | javascript | function sassTranspiler(path) {
return function () {
return gulp.src(path)
.pipe(sass({outputStyle: 'compressed'}))
.pipe(autoprefixer({
browsers: ['last 2 versions']
}))
.pipe(gulp.dest('dist'));
}
} | [
"function",
"sassTranspiler",
"(",
"path",
")",
"{",
"return",
"function",
"(",
")",
"{",
"return",
"gulp",
".",
"src",
"(",
"path",
")",
".",
"pipe",
"(",
"sass",
"(",
"{",
"outputStyle",
":",
"'compressed'",
"}",
")",
")",
".",
"pipe",
"(",
"autopr... | Compiles the sass files to css.
@param {Array} path array of file paths | [
"Compiles",
"the",
"sass",
"files",
"to",
"css",
"."
] | c4f1c5b085560b8cf1390eac8971d36f060580d1 | https://github.com/nestorivan/flex-grill/blob/c4f1c5b085560b8cf1390eac8971d36f060580d1/gulpfile.js#L15-L24 | train |
alexpods/ClazzJS | src/components/meta/Property/Converters.js | function(object, converters, property) {
var self = this;
object.__addSetter(property, this.SETTER_NAME , this.SETTER_WEIGHT, function(value, fields) {
return self.apply(value, converters, property, fields, this);
});
} | javascript | function(object, converters, property) {
var self = this;
object.__addSetter(property, this.SETTER_NAME , this.SETTER_WEIGHT, function(value, fields) {
return self.apply(value, converters, property, fields, this);
});
} | [
"function",
"(",
"object",
",",
"converters",
",",
"property",
")",
"{",
"var",
"self",
"=",
"this",
";",
"object",
".",
"__addSetter",
"(",
"property",
",",
"this",
".",
"SETTER_NAME",
",",
"this",
".",
"SETTER_WEIGHT",
",",
"function",
"(",
"value",
",... | Add converters setter to object
@param {object} object Object to which constraints will be applied
@param {object} converters Hash of converters
@param {string} property Property name
@this {metaProcessor} | [
"Add",
"converters",
"setter",
"to",
"object"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Property/Converters.js#L19-L25 | train | |
alexpods/ClazzJS | src/components/meta/Property/Converters.js | function(value, converters, property, fields, object) {
_.each(converters, function(converter) {
value = converter.call(object, value, fields, property);
});
return value;
} | javascript | function(value, converters, property, fields, object) {
_.each(converters, function(converter) {
value = converter.call(object, value, fields, property);
});
return value;
} | [
"function",
"(",
"value",
",",
"converters",
",",
"property",
",",
"fields",
",",
"object",
")",
"{",
"_",
".",
"each",
"(",
"converters",
",",
"function",
"(",
"converter",
")",
"{",
"value",
"=",
"converter",
".",
"call",
"(",
"object",
",",
"value",... | Applies property converters to object
@param {*} value Property value
@param {object} converters Hash of property converters
@param {string} property Property name
@param {array} fields Property fields
@param {object} object Object
@returns {*} value Converted property value
@this {met... | [
"Applies",
"property",
"converters",
"to",
"object"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Property/Converters.js#L40-L48 | train | |
PanthR/panthrMath | panthrMath/distributions/f.js | rf | function rf(df1, df2) {
var rchisqRatio;
rchisqRatio = function(d) { return chisq.rchisq(d)() / d; };
if (df1 <= 0 || df2 <= 0) { return function() { return NaN; }; }
return function() {
return rchisqRatio(df1) / rchisqRatio(df2);
};
} | javascript | function rf(df1, df2) {
var rchisqRatio;
rchisqRatio = function(d) { return chisq.rchisq(d)() / d; };
if (df1 <= 0 || df2 <= 0) { return function() { return NaN; }; }
return function() {
return rchisqRatio(df1) / rchisqRatio(df2);
};
} | [
"function",
"rf",
"(",
"df1",
",",
"df2",
")",
"{",
"var",
"rchisqRatio",
";",
"rchisqRatio",
"=",
"function",
"(",
"d",
")",
"{",
"return",
"chisq",
".",
"rchisq",
"(",
"d",
")",
"(",
")",
"/",
"d",
";",
"}",
";",
"if",
"(",
"df1",
"<=",
"0",
... | Returns a random variate from the F distribution, computed as a ratio
of chi square variates.
Expects `df1` and `df2` to be positive.
@fullName rf(df1, df2)()
@memberof f | [
"Returns",
"a",
"random",
"variate",
"from",
"the",
"F",
"distribution",
"computed",
"as",
"a",
"ratio",
"of",
"chi",
"square",
"variates",
"."
] | 54d249ca9903a9535f963da711bd3a87fb229c0b | https://github.com/PanthR/panthrMath/blob/54d249ca9903a9535f963da711bd3a87fb229c0b/panthrMath/distributions/f.js#L186-L196 | train |
energimolnet/energimolnet-ng | src/models/subscribers.js | _subscribersDelete | function _subscribersDelete(id, revokeMeters) {
return Api.request({
method: 'DELETE',
url: makeUrl([this._config.default, id]),
data: {
revoke_meters: revokeMeters || false
},
headers: {
'Content-Type': 'application/json;charset=UTF-8'
}
});
} | javascript | function _subscribersDelete(id, revokeMeters) {
return Api.request({
method: 'DELETE',
url: makeUrl([this._config.default, id]),
data: {
revoke_meters: revokeMeters || false
},
headers: {
'Content-Type': 'application/json;charset=UTF-8'
}
});
} | [
"function",
"_subscribersDelete",
"(",
"id",
",",
"revokeMeters",
")",
"{",
"return",
"Api",
".",
"request",
"(",
"{",
"method",
":",
"'DELETE'",
",",
"url",
":",
"makeUrl",
"(",
"[",
"this",
".",
"_config",
".",
"default",
",",
"id",
"]",
")",
",",
... | Revoke meters argument determines whether the meters shared through a subscription shouldshould be revoked. Default is false | [
"Revoke",
"meters",
"argument",
"determines",
"whether",
"the",
"meters",
"shared",
"through",
"a",
"subscription",
"shouldshould",
"be",
"revoked",
".",
"Default",
"is",
"false"
] | 7249c7a52aa6878d462a429c3aacb33d43bf9484 | https://github.com/energimolnet/energimolnet-ng/blob/7249c7a52aa6878d462a429c3aacb33d43bf9484/src/models/subscribers.js#L26-L37 | train |
johvin/adjust-md-for-publish | index.js | parseDocToTree | function parseDocToTree(doc, defaultTitle) {
// save the parsed tree
const tree = [];
const lines = doc.split('\n');
let line, m;
// 保存一个文档区域
let section = null;
let parentSection = null;
// if in a ``` block
let inBlock = false;
// little trick,如果第一行不是 #,则增加一个 #
if (!/^#(?!#)/.test(lines[0])) {... | javascript | function parseDocToTree(doc, defaultTitle) {
// save the parsed tree
const tree = [];
const lines = doc.split('\n');
let line, m;
// 保存一个文档区域
let section = null;
let parentSection = null;
// if in a ``` block
let inBlock = false;
// little trick,如果第一行不是 #,则增加一个 #
if (!/^#(?!#)/.test(lines[0])) {... | [
"function",
"parseDocToTree",
"(",
"doc",
",",
"defaultTitle",
")",
"{",
"// save the parsed tree",
"const",
"tree",
"=",
"[",
"]",
";",
"const",
"lines",
"=",
"doc",
".",
"split",
"(",
"'\\n'",
")",
";",
"let",
"line",
",",
"m",
";",
"// 保存一个文档区域",
"let... | parse a md document to an abstract document tree | [
"parse",
"a",
"md",
"document",
"to",
"an",
"abstract",
"document",
"tree"
] | 234026a000943f0f93e8df6b8d0e893addd91ddc | https://github.com/johvin/adjust-md-for-publish/blob/234026a000943f0f93e8df6b8d0e893addd91ddc/index.js#L44-L95 | train |
johvin/adjust-md-for-publish | index.js | treeDFS | function treeDFS(tree, callback) {
for (let it of tree.slice()) {
callback(it, tree);
if (typeof it === 'object') {
treeDFS(it.children, callback);
}
}
} | javascript | function treeDFS(tree, callback) {
for (let it of tree.slice()) {
callback(it, tree);
if (typeof it === 'object') {
treeDFS(it.children, callback);
}
}
} | [
"function",
"treeDFS",
"(",
"tree",
",",
"callback",
")",
"{",
"for",
"(",
"let",
"it",
"of",
"tree",
".",
"slice",
"(",
")",
")",
"{",
"callback",
"(",
"it",
",",
"tree",
")",
";",
"if",
"(",
"typeof",
"it",
"===",
"'object'",
")",
"{",
"treeDFS... | traverse tree with dfs | [
"traverse",
"tree",
"with",
"dfs"
] | 234026a000943f0f93e8df6b8d0e893addd91ddc | https://github.com/johvin/adjust-md-for-publish/blob/234026a000943f0f93e8df6b8d0e893addd91ddc/index.js#L98-L105 | train |
johvin/adjust-md-for-publish | index.js | treeToDoc | function treeToDoc(tree) {
if (tree.length === 0) return '';
return tree.map((it) => {
if (typeof it === 'object') {
return `${'#'.repeat(it.level)} ${it.title}\n${treeToDoc(it.children)}`;
}
return it;
}).join('\n');
} | javascript | function treeToDoc(tree) {
if (tree.length === 0) return '';
return tree.map((it) => {
if (typeof it === 'object') {
return `${'#'.repeat(it.level)} ${it.title}\n${treeToDoc(it.children)}`;
}
return it;
}).join('\n');
} | [
"function",
"treeToDoc",
"(",
"tree",
")",
"{",
"if",
"(",
"tree",
".",
"length",
"===",
"0",
")",
"return",
"''",
";",
"return",
"tree",
".",
"map",
"(",
"(",
"it",
")",
"=>",
"{",
"if",
"(",
"typeof",
"it",
"===",
"'object'",
")",
"{",
"return"... | convert an abstract md tree to document | [
"convert",
"an",
"abstract",
"md",
"tree",
"to",
"document"
] | 234026a000943f0f93e8df6b8d0e893addd91ddc | https://github.com/johvin/adjust-md-for-publish/blob/234026a000943f0f93e8df6b8d0e893addd91ddc/index.js#L108-L117 | train |
vkiding/judpack-lib | src/plugman/install.js | callEngineScripts | function callEngineScripts(engines, project_dir) {
return Q.all(
engines.map(function(engine){
// CB-5192; on Windows scriptSrc doesn't have file extension so we shouldn't check whether the script exists
var scriptPath = engine.scriptSrc ? '"' + engine.scriptSrc + '"' : null;
... | javascript | function callEngineScripts(engines, project_dir) {
return Q.all(
engines.map(function(engine){
// CB-5192; on Windows scriptSrc doesn't have file extension so we shouldn't check whether the script exists
var scriptPath = engine.scriptSrc ? '"' + engine.scriptSrc + '"' : null;
... | [
"function",
"callEngineScripts",
"(",
"engines",
",",
"project_dir",
")",
"{",
"return",
"Q",
".",
"all",
"(",
"engines",
".",
"map",
"(",
"function",
"(",
"engine",
")",
"{",
"// CB-5192; on Windows scriptSrc doesn't have file extension so we shouldn't check whether the ... | exec engine scripts in order to get the current engine version Returns a promise for the array of engines. | [
"exec",
"engine",
"scripts",
"in",
"order",
"to",
"get",
"the",
"current",
"engine",
"version",
"Returns",
"a",
"promise",
"for",
"the",
"array",
"of",
"engines",
"."
] | 8657cecfec68221109279106adca8dbc81f430f4 | https://github.com/vkiding/judpack-lib/blob/8657cecfec68221109279106adca8dbc81f430f4/src/plugman/install.js#L194-L234 | train |
ChrisAckerman/needy | needy.js | defineProperties | function defineProperties(target, options/*, source, ...*/)
{
if (options == null)
options = {};
var i = 2,
max = arguments.length,
source, prop;
for (; i < max; ++i)
{
source = arguments[i];
if (!(source instanceof Object))
continue;
for (prop in source)
{
if (source[prop] == n... | javascript | function defineProperties(target, options/*, source, ...*/)
{
if (options == null)
options = {};
var i = 2,
max = arguments.length,
source, prop;
for (; i < max; ++i)
{
source = arguments[i];
if (!(source instanceof Object))
continue;
for (prop in source)
{
if (source[prop] == n... | [
"function",
"defineProperties",
"(",
"target",
",",
"options",
"/*, source, ...*/",
")",
"{",
"if",
"(",
"options",
"==",
"null",
")",
"options",
"=",
"{",
"}",
";",
"var",
"i",
"=",
"2",
",",
"max",
"=",
"arguments",
".",
"length",
",",
"source",
",",... | Define multiple properties with similar configuration values. | [
"Define",
"multiple",
"properties",
"with",
"similar",
"configuration",
"values",
"."
] | 44df50a3c41b65550e5dc90dc1f5fc73a36c5a51 | https://github.com/ChrisAckerman/needy/blob/44df50a3c41b65550e5dc90dc1f5fc73a36c5a51/needy.js#L21-L51 | train |
ChrisAckerman/needy | needy.js | setProperties | function setProperties(target/*, source, ...*/)
{
var i = 1,
max = arguments.length,
source, prop;
for (; i < max; ++i)
{
source = arguments[i];
if (!(source instanceof Object))
continue;
for (prop in source)
{
if (source[prop] == null)
continue;
target[prop] = source[prop];... | javascript | function setProperties(target/*, source, ...*/)
{
var i = 1,
max = arguments.length,
source, prop;
for (; i < max; ++i)
{
source = arguments[i];
if (!(source instanceof Object))
continue;
for (prop in source)
{
if (source[prop] == null)
continue;
target[prop] = source[prop];... | [
"function",
"setProperties",
"(",
"target",
"/*, source, ...*/",
")",
"{",
"var",
"i",
"=",
"1",
",",
"max",
"=",
"arguments",
".",
"length",
",",
"source",
",",
"prop",
";",
"for",
"(",
";",
"i",
"<",
"max",
";",
"++",
"i",
")",
"{",
"source",
"="... | Copy non-null properties from all sources, to the target | [
"Copy",
"non",
"-",
"null",
"properties",
"from",
"all",
"sources",
"to",
"the",
"target"
] | 44df50a3c41b65550e5dc90dc1f5fc73a36c5a51 | https://github.com/ChrisAckerman/needy/blob/44df50a3c41b65550e5dc90dc1f5fc73a36c5a51/needy.js#L54-L76 | train |
ChrisAckerman/needy | needy.js | extendClass | function extendClass(parent, constructor)
{
var anonymous = function() {};
anonymous.prototype = parent.prototype;
constructor.prototype = new anonymous();
constructor.constructor = constructor;
defineProperties.apply(null, [constructor.prototype, { configurable: false }].concat(Array.prototype.slice.call(a... | javascript | function extendClass(parent, constructor)
{
var anonymous = function() {};
anonymous.prototype = parent.prototype;
constructor.prototype = new anonymous();
constructor.constructor = constructor;
defineProperties.apply(null, [constructor.prototype, { configurable: false }].concat(Array.prototype.slice.call(a... | [
"function",
"extendClass",
"(",
"parent",
",",
"constructor",
")",
"{",
"var",
"anonymous",
"=",
"function",
"(",
")",
"{",
"}",
";",
"anonymous",
".",
"prototype",
"=",
"parent",
".",
"prototype",
";",
"constructor",
".",
"prototype",
"=",
"new",
"anonymo... | Simple JavaScript inheritance. Nothing fancy. | [
"Simple",
"JavaScript",
"inheritance",
".",
"Nothing",
"fancy",
"."
] | 44df50a3c41b65550e5dc90dc1f5fc73a36c5a51 | https://github.com/ChrisAckerman/needy/blob/44df50a3c41b65550e5dc90dc1f5fc73a36c5a51/needy.js#L79-L93 | train |
ChrisAckerman/needy | needy.js | dethrow | function dethrow(fn)
{
try
{
/* jshint validthis: true */
return fn.apply(this, Array.prototype.slice.call(arguments, 1));
}
catch (e) {}
} | javascript | function dethrow(fn)
{
try
{
/* jshint validthis: true */
return fn.apply(this, Array.prototype.slice.call(arguments, 1));
}
catch (e) {}
} | [
"function",
"dethrow",
"(",
"fn",
")",
"{",
"try",
"{",
"/* jshint validthis: true */",
"return",
"fn",
".",
"apply",
"(",
"this",
",",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
")",
";",
"}",
"catch",
"(",
... | Call a function ignoring any exceptions that it throws. | [
"Call",
"a",
"function",
"ignoring",
"any",
"exceptions",
"that",
"it",
"throws",
"."
] | 44df50a3c41b65550e5dc90dc1f5fc73a36c5a51 | https://github.com/ChrisAckerman/needy/blob/44df50a3c41b65550e5dc90dc1f5fc73a36c5a51/needy.js#L96-L104 | train |
ChrisAckerman/needy | needy.js | portable | function portable(obj, fn)
{
if (typeof fn === 'string')
fn = obj[fn];
return function()
{
return fn.apply(obj, arguments);
};
} | javascript | function portable(obj, fn)
{
if (typeof fn === 'string')
fn = obj[fn];
return function()
{
return fn.apply(obj, arguments);
};
} | [
"function",
"portable",
"(",
"obj",
",",
"fn",
")",
"{",
"if",
"(",
"typeof",
"fn",
"===",
"'string'",
")",
"fn",
"=",
"obj",
"[",
"fn",
"]",
";",
"return",
"function",
"(",
")",
"{",
"return",
"fn",
".",
"apply",
"(",
"obj",
",",
"arguments",
")... | Permantently override the "this" value of a function. | [
"Permantently",
"override",
"the",
"this",
"value",
"of",
"a",
"function",
"."
] | 44df50a3c41b65550e5dc90dc1f5fc73a36c5a51 | https://github.com/ChrisAckerman/needy/blob/44df50a3c41b65550e5dc90dc1f5fc73a36c5a51/needy.js#L117-L126 | train |
ChrisAckerman/needy | needy.js | isValidPath | function isValidPath(path, allowDots)
{
if (typeof path !== 'string')
return false;
if (!path)
return false;
if (!/^([a-z]:[\/\\])?[a-z0-9_~\/\.\-]+$/i.test(path))
return false;
if (!allowDots && /^\.{1,2}$/.test(path))
return false;
return true;
} | javascript | function isValidPath(path, allowDots)
{
if (typeof path !== 'string')
return false;
if (!path)
return false;
if (!/^([a-z]:[\/\\])?[a-z0-9_~\/\.\-]+$/i.test(path))
return false;
if (!allowDots && /^\.{1,2}$/.test(path))
return false;
return true;
} | [
"function",
"isValidPath",
"(",
"path",
",",
"allowDots",
")",
"{",
"if",
"(",
"typeof",
"path",
"!==",
"'string'",
")",
"return",
"false",
";",
"if",
"(",
"!",
"path",
")",
"return",
"false",
";",
"if",
"(",
"!",
"/",
"^([a-z]:[\\/\\\\])?[a-z0-9_~\\/\\.\\... | Make sure a path is a string, isn't empty, contains valid characters, and optionally isn't a dot path. | [
"Make",
"sure",
"a",
"path",
"is",
"a",
"string",
"isn",
"t",
"empty",
"contains",
"valid",
"characters",
"and",
"optionally",
"isn",
"t",
"a",
"dot",
"path",
"."
] | 44df50a3c41b65550e5dc90dc1f5fc73a36c5a51 | https://github.com/ChrisAckerman/needy/blob/44df50a3c41b65550e5dc90dc1f5fc73a36c5a51/needy.js#L202-L214 | train |
ChrisAckerman/needy | needy.js | csv | function csv(array)
{
if (!(array instanceof Array) || array.length === 0)
return '';
array = array.slice(0);
var i = array.length;
while (i--)
array[i] = '"' + (''+array[i]).replace(/(\\|")/g, '\\$1') + '"';
return array.join(', ');
} | javascript | function csv(array)
{
if (!(array instanceof Array) || array.length === 0)
return '';
array = array.slice(0);
var i = array.length;
while (i--)
array[i] = '"' + (''+array[i]).replace(/(\\|")/g, '\\$1') + '"';
return array.join(', ');
} | [
"function",
"csv",
"(",
"array",
")",
"{",
"if",
"(",
"!",
"(",
"array",
"instanceof",
"Array",
")",
"||",
"array",
".",
"length",
"===",
"0",
")",
"return",
"''",
";",
"array",
"=",
"array",
".",
"slice",
"(",
"0",
")",
";",
"var",
"i",
"=",
"... | Return a quoted CSV string. | [
"Return",
"a",
"quoted",
"CSV",
"string",
"."
] | 44df50a3c41b65550e5dc90dc1f5fc73a36c5a51 | https://github.com/ChrisAckerman/needy/blob/44df50a3c41b65550e5dc90dc1f5fc73a36c5a51/needy.js#L217-L229 | train |
chronicled/open-registry-utils | lib/urn.js | function(encoded) {
if (encoded instanceof Array) {
encoded = encoded.map(function(chunk) {return chunk.replace(/^0x/g, '')}).join('');
}
// Each symbol is 4 bits
var result = [];
var nextIndex = 0;
while (nextIndex < encoded.length) {
var schemaLength = parseInt(enc... | javascript | function(encoded) {
if (encoded instanceof Array) {
encoded = encoded.map(function(chunk) {return chunk.replace(/^0x/g, '')}).join('');
}
// Each symbol is 4 bits
var result = [];
var nextIndex = 0;
while (nextIndex < encoded.length) {
var schemaLength = parseInt(enc... | [
"function",
"(",
"encoded",
")",
"{",
"if",
"(",
"encoded",
"instanceof",
"Array",
")",
"{",
"encoded",
"=",
"encoded",
".",
"map",
"(",
"function",
"(",
"chunk",
")",
"{",
"return",
"chunk",
".",
"replace",
"(",
"/",
"^0x",
"/",
"g",
",",
"''",
")... | Accepts both chunks array and hex string | [
"Accepts",
"both",
"chunks",
"array",
"and",
"hex",
"string"
] | b0a9a35a72f57c0280b78b6d2ef81582407632f1 | https://github.com/chronicled/open-registry-utils/blob/b0a9a35a72f57c0280b78b6d2ef81582407632f1/lib/urn.js#L195-L220 | train | |
BrightContext/node-sdk | bcc_socket.js | openSocket | function openSocket (sessionInfo, callback) {
var socketUrl, socketInfo, socket_endpoint, new_socket;
_log(sessionInfo);
socketUrl = sessionInfo.endpoints.socket[0];
socketInfo = url.parse(socketUrl);
_log(socketInfo);
socket_endpoint = socketUrl + me.setting.apiroot + '/feed/ws?s... | javascript | function openSocket (sessionInfo, callback) {
var socketUrl, socketInfo, socket_endpoint, new_socket;
_log(sessionInfo);
socketUrl = sessionInfo.endpoints.socket[0];
socketInfo = url.parse(socketUrl);
_log(socketInfo);
socket_endpoint = socketUrl + me.setting.apiroot + '/feed/ws?s... | [
"function",
"openSocket",
"(",
"sessionInfo",
",",
"callback",
")",
"{",
"var",
"socketUrl",
",",
"socketInfo",
",",
"socket_endpoint",
",",
"new_socket",
";",
"_log",
"(",
"sessionInfo",
")",
";",
"socketUrl",
"=",
"sessionInfo",
".",
"endpoints",
".",
"socke... | connect to first available socket endpoint | [
"connect",
"to",
"first",
"available",
"socket",
"endpoint"
] | db9dfb4faa649236eee8c4099d79ecfc21ef9b19 | https://github.com/BrightContext/node-sdk/blob/db9dfb4faa649236eee8c4099d79ecfc21ef9b19/bcc_socket.js#L147-L164 | train |
HelloCodeMing/spiderer | lib/index.js | initialize | function initialize(options) {
// log
config.logfile = options.logfile || 'logs/spider.log';
log4js.configure({
appenders: [
{ type: 'console', category: 'console'},
{ type: 'dateFile',
filename: config.logfile,
pattern: 'yyyy-MM-dd',
category: 'default'
}
],
replaceConsole: true
})... | javascript | function initialize(options) {
// log
config.logfile = options.logfile || 'logs/spider.log';
log4js.configure({
appenders: [
{ type: 'console', category: 'console'},
{ type: 'dateFile',
filename: config.logfile,
pattern: 'yyyy-MM-dd',
category: 'default'
}
],
replaceConsole: true
})... | [
"function",
"initialize",
"(",
"options",
")",
"{",
"// log",
"config",
".",
"logfile",
"=",
"options",
".",
"logfile",
"||",
"'logs/spider.log'",
";",
"log4js",
".",
"configure",
"(",
"{",
"appenders",
":",
"[",
"{",
"type",
":",
"'console'",
",",
"catego... | Initialize the spider, with some configurations.
options.filter
options.startURLS
options.interval
options.logfile
options.timeout | [
"Initialize",
"the",
"spider",
"with",
"some",
"configurations",
".",
"options",
".",
"filter",
"options",
".",
"startURLS",
"options",
".",
"interval",
"options",
".",
"logfile",
"options",
".",
"timeout"
] | 6659a68f04c154f6d5b3edb46b6049ac7732964b | https://github.com/HelloCodeMing/spiderer/blob/6659a68f04c154f6d5b3edb46b6049ac7732964b/lib/index.js#L97-L139 | train |
gethuman/pancakes-recipe | middleware/mw.ssl.js | init | function init(ctx) {
var server = ctx.server;
server.ext('onRequest', checkIfSSL);
return new Q(ctx);
} | javascript | function init(ctx) {
var server = ctx.server;
server.ext('onRequest', checkIfSSL);
return new Q(ctx);
} | [
"function",
"init",
"(",
"ctx",
")",
"{",
"var",
"server",
"=",
"ctx",
".",
"server",
";",
"server",
".",
"ext",
"(",
"'onRequest'",
",",
"checkIfSSL",
")",
";",
"return",
"new",
"Q",
"(",
"ctx",
")",
";",
"}"
] | Add middleware for doing redirects | [
"Add",
"middleware",
"for",
"doing",
"redirects"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.ssl.js#L46-L50 | train |
scrapjs/typling-core | lib/signature.js | parse | function parse (strip, associate) {
var signature = strip.split('->')
if (signature.length !== 2) return null
// Param types:
var params = signature[0].split(',')
for (var i = params.length; i--;) {
var p = params[i].trim()
if (p === '*') params[i] = null
else params[i] = p
}
// Return type:... | javascript | function parse (strip, associate) {
var signature = strip.split('->')
if (signature.length !== 2) return null
// Param types:
var params = signature[0].split(',')
for (var i = params.length; i--;) {
var p = params[i].trim()
if (p === '*') params[i] = null
else params[i] = p
}
// Return type:... | [
"function",
"parse",
"(",
"strip",
",",
"associate",
")",
"{",
"var",
"signature",
"=",
"strip",
".",
"split",
"(",
"'->'",
")",
"if",
"(",
"signature",
".",
"length",
"!==",
"2",
")",
"return",
"null",
"// Param types:",
"var",
"params",
"=",
"signature... | exports.parse = parse exports.generate = generate Parse a signature strip into a signature object | [
"exports",
".",
"parse",
"=",
"parse",
"exports",
".",
"generate",
"=",
"generate",
"Parse",
"a",
"signature",
"strip",
"into",
"a",
"signature",
"object"
] | 89168c7a70835c86fd7c1e4ed138ec588323c79c | https://github.com/scrapjs/typling-core/blob/89168c7a70835c86fd7c1e4ed138ec588323c79c/lib/signature.js#L6-L25 | train |
msecret/perf-hunter | build/index.js | require | function require(name, jumped){
if (cache[name]) return cache[name].exports;
if (modules[name]) return call(name, require);
throw new Error('cannot find module "' + name + '"');
} | javascript | function require(name, jumped){
if (cache[name]) return cache[name].exports;
if (modules[name]) return call(name, require);
throw new Error('cannot find module "' + name + '"');
} | [
"function",
"require",
"(",
"name",
",",
"jumped",
")",
"{",
"if",
"(",
"cache",
"[",
"name",
"]",
")",
"return",
"cache",
"[",
"name",
"]",
".",
"exports",
";",
"if",
"(",
"modules",
"[",
"name",
"]",
")",
"return",
"call",
"(",
"name",
",",
"re... | Require `name`.
@param {String} name
@param {Boolean} jumped
@api public | [
"Require",
"name",
"."
] | 61ccd794e8744eb6438f7c08bf49dae5d90cc4f5 | https://github.com/msecret/perf-hunter/blob/61ccd794e8744eb6438f7c08bf49dae5d90cc4f5/build/index.js#L17-L21 | train |
msecret/perf-hunter | build/index.js | call | function call(id, require){
var m = { exports: {} };
var mod = modules[id];
var name = mod[2];
var fn = mod[0];
fn.call(m.exports, function(req){
var dep = modules[id][1][req];
return require(dep || req);
}, m, m.exports, outer, modules, cache, entries);
// store to cache after... | javascript | function call(id, require){
var m = { exports: {} };
var mod = modules[id];
var name = mod[2];
var fn = mod[0];
fn.call(m.exports, function(req){
var dep = modules[id][1][req];
return require(dep || req);
}, m, m.exports, outer, modules, cache, entries);
// store to cache after... | [
"function",
"call",
"(",
"id",
",",
"require",
")",
"{",
"var",
"m",
"=",
"{",
"exports",
":",
"{",
"}",
"}",
";",
"var",
"mod",
"=",
"modules",
"[",
"id",
"]",
";",
"var",
"name",
"=",
"mod",
"[",
"2",
"]",
";",
"var",
"fn",
"=",
"mod",
"[... | Call module `id` and cache it.
@param {Number} id
@param {Function} require
@return {Function}
@api private | [
"Call",
"module",
"id",
"and",
"cache",
"it",
"."
] | 61ccd794e8744eb6438f7c08bf49dae5d90cc4f5 | https://github.com/msecret/perf-hunter/blob/61ccd794e8744eb6438f7c08bf49dae5d90cc4f5/build/index.js#L32-L50 | train |
msecret/perf-hunter | build/index.js | function() {
// Walk all of the elements in the DOM (try to only do this once)
var elements = doc.getElementsByTagName('*');
var re = /url\((http.*)\)/ig;
for (var i = 0; i < elements.length; i++) {
var el = elements[i];
var style = win.getComputedStyle(el);
// check for Images
... | javascript | function() {
// Walk all of the elements in the DOM (try to only do this once)
var elements = doc.getElementsByTagName('*');
var re = /url\((http.*)\)/ig;
for (var i = 0; i < elements.length; i++) {
var el = elements[i];
var style = win.getComputedStyle(el);
// check for Images
... | [
"function",
"(",
")",
"{",
"// Walk all of the elements in the DOM (try to only do this once)",
"var",
"elements",
"=",
"doc",
".",
"getElementsByTagName",
"(",
"'*'",
")",
";",
"var",
"re",
"=",
"/",
"url\\((http.*)\\)",
"/",
"ig",
";",
"for",
"(",
"var",
"i",
... | Get the visible rectangles for elements that we care about | [
"Get",
"the",
"visible",
"rectangles",
"for",
"elements",
"that",
"we",
"care",
"about"
] | 61ccd794e8744eb6438f7c08bf49dae5d90cc4f5 | https://github.com/msecret/perf-hunter/blob/61ccd794e8744eb6438f7c08bf49dae5d90cc4f5/build/index.js#L209-L244 | train | |
vkiding/judpack-lib | src/hooks/Context.js | Context | function Context(hook, opts) {
var prop;
this.hook = hook;
//create new object, to avoid affecting input opts in other places
//For example context.opts.plugin = Object is done, then it affects by reference
this.opts = {};
for (prop in opts) {
if (opts.hasOwnProperty(prop)) {
this.o... | javascript | function Context(hook, opts) {
var prop;
this.hook = hook;
//create new object, to avoid affecting input opts in other places
//For example context.opts.plugin = Object is done, then it affects by reference
this.opts = {};
for (prop in opts) {
if (opts.hasOwnProperty(prop)) {
this.o... | [
"function",
"Context",
"(",
"hook",
",",
"opts",
")",
"{",
"var",
"prop",
";",
"this",
".",
"hook",
"=",
"hook",
";",
"//create new object, to avoid affecting input opts in other places",
"//For example context.opts.plugin = Object is done, then it affects by reference",
"this"... | Creates hook script context
@constructor
@param {String} hook The hook type
@param {Object} opts Hook options
@returns {Object} | [
"Creates",
"hook",
"script",
"context"
] | 8657cecfec68221109279106adca8dbc81f430f4 | https://github.com/vkiding/judpack-lib/blob/8657cecfec68221109279106adca8dbc81f430f4/src/hooks/Context.js#L29-L43 | train |
tolokoban/ToloFrameWork | ker/mod/wdg.area.js | grow | function grow(area, min, max) {
if( typeof min !== 'undefined' ) {
min = parseInt( min );
if( isNaN( min ) ) min = 2;
}
if( typeof max !== 'undefined' ) {
max = parseInt( max );
if( isNaN( max ) ) max = 8;
}
if( max < min ) max = min;
var text = area.value;
var lines = 1;
var index = -1... | javascript | function grow(area, min, max) {
if( typeof min !== 'undefined' ) {
min = parseInt( min );
if( isNaN( min ) ) min = 2;
}
if( typeof max !== 'undefined' ) {
max = parseInt( max );
if( isNaN( max ) ) max = 8;
}
if( max < min ) max = min;
var text = area.value;
var lines = 1;
var index = -1... | [
"function",
"grow",
"(",
"area",
",",
"min",
",",
"max",
")",
"{",
"if",
"(",
"typeof",
"min",
"!==",
"'undefined'",
")",
"{",
"min",
"=",
"parseInt",
"(",
"min",
")",
";",
"if",
"(",
"isNaN",
"(",
"min",
")",
")",
"min",
"=",
"2",
";",
"}",
... | Check the number of rows regarding the inner text. | [
"Check",
"the",
"number",
"of",
"rows",
"regarding",
"the",
"inner",
"text",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/wdg.area.js#L113-L134 | train |
jeswin-unmaintained/isotropy-koa-context-in-browser | lib/request.js | function(field){
var req = this.req;
field = field.toLowerCase();
switch (field) {
case 'referer':
case 'referrer':
return req.headers.referrer || req.headers.referer || '';
default:
return req.headers[fi... | javascript | function(field){
var req = this.req;
field = field.toLowerCase();
switch (field) {
case 'referer':
case 'referrer':
return req.headers.referrer || req.headers.referer || '';
default:
return req.headers[fi... | [
"function",
"(",
"field",
")",
"{",
"var",
"req",
"=",
"this",
".",
"req",
";",
"field",
"=",
"field",
".",
"toLowerCase",
"(",
")",
";",
"switch",
"(",
"field",
")",
"{",
"case",
"'referer'",
":",
"case",
"'referrer'",
":",
"return",
"req",
".",
"... | Return request header.
The `Referrer` header field is special-cased,
both `Referrer` and `Referer` are interchangeable.
Examples:
this.get('Content-Type');
// => "text/plain"
this.get('content-type');
// => "text/plain"
this.get('Something');
// => undefined
@param {String} field
@return {String}
@api public | [
"Return",
"request",
"header",
"."
] | 033a3ac0fd65ba6ac2b4ce715b3da54f873eed6f | https://github.com/jeswin-unmaintained/isotropy-koa-context-in-browser/blob/033a3ac0fd65ba6ac2b4ce715b3da54f873eed6f/lib/request.js#L561-L571 | train | |
bleupen/glib | lib/index.js | logToConsole | function logToConsole(tags, message) {
if (enabled) {
if (arguments.length < 2) {
message = tags;
tags = [];
}
if (!util.isArray(tags)) tags = [];
var text = new Date().getTime() + ', ';
if (tags.length > 0) {
text = text + tags[0] + ', '... | javascript | function logToConsole(tags, message) {
if (enabled) {
if (arguments.length < 2) {
message = tags;
tags = [];
}
if (!util.isArray(tags)) tags = [];
var text = new Date().getTime() + ', ';
if (tags.length > 0) {
text = text + tags[0] + ', '... | [
"function",
"logToConsole",
"(",
"tags",
",",
"message",
")",
"{",
"if",
"(",
"enabled",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"<",
"2",
")",
"{",
"message",
"=",
"tags",
";",
"tags",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"!",
"util",
... | Default console logger for use outside of hapi container
@param tags
@param message | [
"Default",
"console",
"logger",
"for",
"use",
"outside",
"of",
"hapi",
"container"
] | f47c6694761821197d790f617127b47f4e3be60f | https://github.com/bleupen/glib/blob/f47c6694761821197d790f617127b47f4e3be60f/lib/index.js#L13-L29 | train |
bleupen/glib | lib/index.js | parseTags | function parseTags(tags) {
if (tags.length > 0 && util.isArray(tags[0])) {
tags = tags[0];
}
return tags;
} | javascript | function parseTags(tags) {
if (tags.length > 0 && util.isArray(tags[0])) {
tags = tags[0];
}
return tags;
} | [
"function",
"parseTags",
"(",
"tags",
")",
"{",
"if",
"(",
"tags",
".",
"length",
">",
"0",
"&&",
"util",
".",
"isArray",
"(",
"tags",
"[",
"0",
"]",
")",
")",
"{",
"tags",
"=",
"tags",
"[",
"0",
"]",
";",
"}",
"return",
"tags",
";",
"}"
] | Assists with parsing var-arg'ed tags
@param tags
@return {*} | [
"Assists",
"with",
"parsing",
"var",
"-",
"arg",
"ed",
"tags"
] | f47c6694761821197d790f617127b47f4e3be60f | https://github.com/bleupen/glib/blob/f47c6694761821197d790f617127b47f4e3be60f/lib/index.js#L36-L42 | train |
bleupen/glib | lib/index.js | Logger | function Logger(tags) {
tags = parseTags(Array.prototype.slice.call(arguments));
if (!(this instanceof Logger)) {
return new Logger(tags);
}
this.tags = tags;
} | javascript | function Logger(tags) {
tags = parseTags(Array.prototype.slice.call(arguments));
if (!(this instanceof Logger)) {
return new Logger(tags);
}
this.tags = tags;
} | [
"function",
"Logger",
"(",
"tags",
")",
"{",
"tags",
"=",
"parseTags",
"(",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
")",
";",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Logger",
")",
")",
"{",
"return",
"new",
... | Logger constructor. may be invoked directly or as a constructor
@param {string[]=} tags an array of default tags to include with log messages
@return {Logger} a new logger instance
@constructor | [
"Logger",
"constructor",
".",
"may",
"be",
"invoked",
"directly",
"or",
"as",
"a",
"constructor"
] | f47c6694761821197d790f617127b47f4e3be60f | https://github.com/bleupen/glib/blob/f47c6694761821197d790f617127b47f4e3be60f/lib/index.js#L50-L58 | train |
sbugert/dishwasher | lib/dishwasher.js | rinse | function rinse (pageobj, finalarray, maps) {
// Map where data will be inserted
var map = maps.pagemap();
// Render data in temp object
// var ruffian = plates.bind(partials[pageobj.mastertemplate], pageobj, map);
var ruffian = partials[pageobj.mastertemplate];
// Render plates' simple case scenario
//... | javascript | function rinse (pageobj, finalarray, maps) {
// Map where data will be inserted
var map = maps.pagemap();
// Render data in temp object
// var ruffian = plates.bind(partials[pageobj.mastertemplate], pageobj, map);
var ruffian = partials[pageobj.mastertemplate];
// Render plates' simple case scenario
//... | [
"function",
"rinse",
"(",
"pageobj",
",",
"finalarray",
",",
"maps",
")",
"{",
"// Map where data will be inserted",
"var",
"map",
"=",
"maps",
".",
"pagemap",
"(",
")",
";",
"// Render data in temp object",
"// var ruffian = plates.bind(partials[pageobj.mastertemplate], pa... | This gets an object an an array of objects. The object defines how the data in the array is renderd | [
"This",
"gets",
"an",
"object",
"an",
"an",
"array",
"of",
"objects",
".",
"The",
"object",
"defines",
"how",
"the",
"data",
"in",
"the",
"array",
"is",
"renderd"
] | 5c8f5fb78977cc1ffd6f9b2884297d99490bbddf | https://github.com/sbugert/dishwasher/blob/5c8f5fb78977cc1ffd6f9b2884297d99490bbddf/lib/dishwasher.js#L10-L60 | train |
sbugert/dishwasher | lib/dishwasher.js | insertMultiFragment | function insertMultiFragment (collection, index, array) {
// Only get the objects with the correct collection value
var filtered = finalarray.filter(function (element) {
return element.collection === collection;
});
// Map data with corresponding partials
var map = maps.multimap(collection)
... | javascript | function insertMultiFragment (collection, index, array) {
// Only get the objects with the correct collection value
var filtered = finalarray.filter(function (element) {
return element.collection === collection;
});
// Map data with corresponding partials
var map = maps.multimap(collection)
... | [
"function",
"insertMultiFragment",
"(",
"collection",
",",
"index",
",",
"array",
")",
"{",
"// Only get the objects with the correct collection value",
"var",
"filtered",
"=",
"finalarray",
".",
"filter",
"(",
"function",
"(",
"element",
")",
"{",
"return",
"element"... | This filters and renders collections of data from the array of objects | [
"This",
"filters",
"and",
"renders",
"collections",
"of",
"data",
"from",
"the",
"array",
"of",
"objects"
] | 5c8f5fb78977cc1ffd6f9b2884297d99490bbddf | https://github.com/sbugert/dishwasher/blob/5c8f5fb78977cc1ffd6f9b2884297d99490bbddf/lib/dishwasher.js#L29-L40 | train |
sbugert/dishwasher | lib/dishwasher.js | insertSingleFragment | function insertSingleFragment () {
for (var i = 0; i < finalarray.length; i++) {
// Check whether the object belongs to a collection or not
if (finalarray[i].collection === 'none') {
var singlepartial = finalarray[i].partial
, singledest = finalarray[i].destination
, map = m... | javascript | function insertSingleFragment () {
for (var i = 0; i < finalarray.length; i++) {
// Check whether the object belongs to a collection or not
if (finalarray[i].collection === 'none') {
var singlepartial = finalarray[i].partial
, singledest = finalarray[i].destination
, map = m... | [
"function",
"insertSingleFragment",
"(",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"finalarray",
".",
"length",
";",
"i",
"++",
")",
"{",
"// Check whether the object belongs to a collection or not",
"if",
"(",
"finalarray",
"[",
"i",
"]",
"... | This filters and renders objects which do not belong to a collection | [
"This",
"filters",
"and",
"renders",
"objects",
"which",
"do",
"not",
"belong",
"to",
"a",
"collection"
] | 5c8f5fb78977cc1ffd6f9b2884297d99490bbddf | https://github.com/sbugert/dishwasher/blob/5c8f5fb78977cc1ffd6f9b2884297d99490bbddf/lib/dishwasher.js#L43-L56 | train |
sbugert/dishwasher | lib/dishwasher.js | readPartials | function readPartials(userDir, cwd) {
if (cwd) {
userDir = path.join(cwd, userDir);
}
// Use working directory of process if not specified
else {
userDir = path.join(path.dirname(process.argv[1]), userDir);
}
partials = {};
var filenames = fs.readdirSync(userDir);
for (var i = 0; i < filenames.l... | javascript | function readPartials(userDir, cwd) {
if (cwd) {
userDir = path.join(cwd, userDir);
}
// Use working directory of process if not specified
else {
userDir = path.join(path.dirname(process.argv[1]), userDir);
}
partials = {};
var filenames = fs.readdirSync(userDir);
for (var i = 0; i < filenames.l... | [
"function",
"readPartials",
"(",
"userDir",
",",
"cwd",
")",
"{",
"if",
"(",
"cwd",
")",
"{",
"userDir",
"=",
"path",
".",
"join",
"(",
"cwd",
",",
"userDir",
")",
";",
"}",
"// Use working directory of process if not specified",
"else",
"{",
"userDir",
"=",... | Read all partials from disk | [
"Read",
"all",
"partials",
"from",
"disk"
] | 5c8f5fb78977cc1ffd6f9b2884297d99490bbddf | https://github.com/sbugert/dishwasher/blob/5c8f5fb78977cc1ffd6f9b2884297d99490bbddf/lib/dishwasher.js#L63-L79 | train |
alejonext/humanquery | lib/compile.js | compile | function compile(node) {
switch (node.type) {
case 'field':
var obj = {};
obj[node.name] = node.value;
return obj;
case 'op':
var obj = {};
var op = '$' + node.op;
obj[op] = [
compile(node.left),
compile(node.right)
];
return obj;
}
} | javascript | function compile(node) {
switch (node.type) {
case 'field':
var obj = {};
obj[node.name] = node.value;
return obj;
case 'op':
var obj = {};
var op = '$' + node.op;
obj[op] = [
compile(node.left),
compile(node.right)
];
return obj;
}
} | [
"function",
"compile",
"(",
"node",
")",
"{",
"switch",
"(",
"node",
".",
"type",
")",
"{",
"case",
"'field'",
":",
"var",
"obj",
"=",
"{",
"}",
";",
"obj",
"[",
"node",
".",
"name",
"]",
"=",
"node",
".",
"value",
";",
"return",
"obj",
";",
"c... | Compile `node` to a mongo query.
@param {Object} node
@return {Object}
@api public | [
"Compile",
"node",
"to",
"a",
"mongo",
"query",
"."
] | f3dbc46379122f40bf9336991e9856a82fc95310 | https://github.com/alejonext/humanquery/blob/f3dbc46379122f40bf9336991e9856a82fc95310/lib/compile.js#L16-L34 | train |
MakerCollider/node-red-contrib-smartnode-hook | html/scripts/jquery.blockUI.js | remove | function remove(el, opts) {
var count;
var full = (el == window);
var $el = $(el);
var data = $el.data('blockUI.history');
var to = $el.data('blockUI.timeout');
if (to) {
clearTimeout(to);
$el.removeData('blockUI.timeout');
}
opts = $.extend({}, $.blockUI.defaults, opts || {});
bind(0... | javascript | function remove(el, opts) {
var count;
var full = (el == window);
var $el = $(el);
var data = $el.data('blockUI.history');
var to = $el.data('blockUI.timeout');
if (to) {
clearTimeout(to);
$el.removeData('blockUI.timeout');
}
opts = $.extend({}, $.blockUI.defaults, opts || {});
bind(0... | [
"function",
"remove",
"(",
"el",
",",
"opts",
")",
"{",
"var",
"count",
";",
"var",
"full",
"=",
"(",
"el",
"==",
"window",
")",
";",
"var",
"$el",
"=",
"$",
"(",
"el",
")",
";",
"var",
"data",
"=",
"$el",
".",
"data",
"(",
"'blockUI.history'",
... | remove the block | [
"remove",
"the",
"block"
] | 245c267e832968bad880ca009929043e82c7bc25 | https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/jquery.blockUI.js#L457-L501 | train |
MakerCollider/node-red-contrib-smartnode-hook | html/scripts/jquery.blockUI.js | reset | function reset(els,data,opts,el) {
var $el = $(el);
if ( $el.data('blockUI.isBlocked') )
return;
els.each(function(i,o) {
// remove via DOM calls so we don't lose event handlers
if (this.parentNode)
this.parentNode.removeChild(this);
});
if (data && data.el) {
data.el.style.display... | javascript | function reset(els,data,opts,el) {
var $el = $(el);
if ( $el.data('blockUI.isBlocked') )
return;
els.each(function(i,o) {
// remove via DOM calls so we don't lose event handlers
if (this.parentNode)
this.parentNode.removeChild(this);
});
if (data && data.el) {
data.el.style.display... | [
"function",
"reset",
"(",
"els",
",",
"data",
",",
"opts",
",",
"el",
")",
"{",
"var",
"$el",
"=",
"$",
"(",
"el",
")",
";",
"if",
"(",
"$el",
".",
"data",
"(",
"'blockUI.isBlocked'",
")",
")",
"return",
";",
"els",
".",
"each",
"(",
"function",
... | move blocking element back into the DOM where it started | [
"move",
"blocking",
"element",
"back",
"into",
"the",
"DOM",
"where",
"it",
"started"
] | 245c267e832968bad880ca009929043e82c7bc25 | https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/jquery.blockUI.js#L504-L535 | train |
kvonflotow/local-json | index.js | watchFile | function watchFile( file )
{
// make sure file is at least something
if ( !file || '' === file )
{
return
}
// make sure it's a string
file = file.toString()
if ( watchers.hasOwnProperty( file ) )
{... | javascript | function watchFile( file )
{
// make sure file is at least something
if ( !file || '' === file )
{
return
}
// make sure it's a string
file = file.toString()
if ( watchers.hasOwnProperty( file ) )
{... | [
"function",
"watchFile",
"(",
"file",
")",
"{",
"// make sure file is at least something",
"if",
"(",
"!",
"file",
"||",
"''",
"===",
"file",
")",
"{",
"return",
"}",
"// make sure it's a string",
"file",
"=",
"file",
".",
"toString",
"(",
")",
"if",
"(",
"w... | pass the full path of the file | [
"pass",
"the",
"full",
"path",
"of",
"the",
"file"
] | e29e2e63c554b64fe911629b87ddb2c81a68e1ea | https://github.com/kvonflotow/local-json/blob/e29e2e63c554b64fe911629b87ddb2c81a68e1ea/index.js#L29-L124 | train |
IonicaBizau/name-it | lib/index.js | NameIt | function NameIt(input) {
var res = {
_: []
, }
, foos = Object.keys(NameIt)
, i = 0
;
for (; i < foos.length; ++i) {
res._.push(res[foos[i]] = NameIt[foos[i]](input));
}
return res;
} | javascript | function NameIt(input) {
var res = {
_: []
, }
, foos = Object.keys(NameIt)
, i = 0
;
for (; i < foos.length; ++i) {
res._.push(res[foos[i]] = NameIt[foos[i]](input));
}
return res;
} | [
"function",
"NameIt",
"(",
"input",
")",
"{",
"var",
"res",
"=",
"{",
"_",
":",
"[",
"]",
",",
"}",
",",
"foos",
"=",
"Object",
".",
"keys",
"(",
"NameIt",
")",
",",
"i",
"=",
"0",
";",
"for",
"(",
";",
"i",
"<",
"foos",
".",
"length",
";",... | NameIt
Generates names for input keywords.
@name NameIt
@function
@param {String} input The keyword to generate names for.
@return {Object} An object containing the name results:
- `_` (Array): An array of strings containing all the name results.
It also contains fields generated from method names (e.g. `y`, `er`, `... | [
"NameIt",
"Generates",
"names",
"for",
"input",
"keywords",
"."
] | 9276ac740707e6d6089c274651a465e7fff4e9d0 | https://github.com/IonicaBizau/name-it/blob/9276ac740707e6d6089c274651a465e7fff4e9d0/lib/index.js#L29-L42 | train |
wordijp/flexi-require | lib/internal/module-utils.js | mergeIfNeed | function mergeIfNeed(rtarget, o) {
for (var key in o) {
if (!rtarget[key]) {
rtarget[key] = o[key];
}
}
return rtarget;
} | javascript | function mergeIfNeed(rtarget, o) {
for (var key in o) {
if (!rtarget[key]) {
rtarget[key] = o[key];
}
}
return rtarget;
} | [
"function",
"mergeIfNeed",
"(",
"rtarget",
",",
"o",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"o",
")",
"{",
"if",
"(",
"!",
"rtarget",
"[",
"key",
"]",
")",
"{",
"rtarget",
"[",
"key",
"]",
"=",
"o",
"[",
"key",
"]",
";",
"}",
"}",
"return"... | merge this function's cache | [
"merge",
"this",
"function",
"s",
"cache"
] | f62a7141fd97f4a5b47c9808a5c4a3349aeccb43 | https://github.com/wordijp/flexi-require/blob/f62a7141fd97f4a5b47c9808a5c4a3349aeccb43/lib/internal/module-utils.js#L34-L41 | train |
me-ventures/microservice-toolkit | src/logger.js | setHandlers | function setHandlers(enableException, enableUnhandled) {
if(enableException === true) {
process.on('uncaughtException', UncaughtExceptionHandler);
}
if(enableUnhandled === true) {
process.on('unhandledRejection', unhandledRejectionHandler);
}
} | javascript | function setHandlers(enableException, enableUnhandled) {
if(enableException === true) {
process.on('uncaughtException', UncaughtExceptionHandler);
}
if(enableUnhandled === true) {
process.on('unhandledRejection', unhandledRejectionHandler);
}
} | [
"function",
"setHandlers",
"(",
"enableException",
",",
"enableUnhandled",
")",
"{",
"if",
"(",
"enableException",
"===",
"true",
")",
"{",
"process",
".",
"on",
"(",
"'uncaughtException'",
",",
"UncaughtExceptionHandler",
")",
";",
"}",
"if",
"(",
"enableUnhand... | Set handlers for the uncaughtException and unhandledRejection events in nodejs.
@param enableException boolean
@param enableUnhandled boolean | [
"Set",
"handlers",
"for",
"the",
"uncaughtException",
"and",
"unhandledRejection",
"events",
"in",
"nodejs",
"."
] | 9aedc9542dffdc274a5142515bd22e92833220d2 | https://github.com/me-ventures/microservice-toolkit/blob/9aedc9542dffdc274a5142515bd22e92833220d2/src/logger.js#L79-L87 | train |
me-ventures/microservice-toolkit | src/logger.js | UncaughtExceptionHandler | function UncaughtExceptionHandler(error) {
// Call module.exports.crit here so that we can intercept the call in the tests
module.exports.crit(`Unhandled exception: ${error.message}`);
module.exports.crit(error.stack.toString());
process.exit(1);
} | javascript | function UncaughtExceptionHandler(error) {
// Call module.exports.crit here so that we can intercept the call in the tests
module.exports.crit(`Unhandled exception: ${error.message}`);
module.exports.crit(error.stack.toString());
process.exit(1);
} | [
"function",
"UncaughtExceptionHandler",
"(",
"error",
")",
"{",
"// Call module.exports.crit here so that we can intercept the call in the tests",
"module",
".",
"exports",
".",
"crit",
"(",
"`",
"${",
"error",
".",
"message",
"}",
"`",
")",
";",
"module",
".",
"expor... | Handler for the uncaught exception event inside nodejs. It will print out a critical error message and will then
exit the application. | [
"Handler",
"for",
"the",
"uncaught",
"exception",
"event",
"inside",
"nodejs",
".",
"It",
"will",
"print",
"out",
"a",
"critical",
"error",
"message",
"and",
"will",
"then",
"exit",
"the",
"application",
"."
] | 9aedc9542dffdc274a5142515bd22e92833220d2 | https://github.com/me-ventures/microservice-toolkit/blob/9aedc9542dffdc274a5142515bd22e92833220d2/src/logger.js#L93-L98 | train |
me-ventures/microservice-toolkit | src/logger.js | unhandledRejectionHandler | function unhandledRejectionHandler(error) {
let reasonString = error.message || error.msg || JSON.stringify(error);
module.exports.crit(`Unhandled Promise Rejection - reason: [${reasonString}]`);
module.exports.crit(error.stack.toString());
} | javascript | function unhandledRejectionHandler(error) {
let reasonString = error.message || error.msg || JSON.stringify(error);
module.exports.crit(`Unhandled Promise Rejection - reason: [${reasonString}]`);
module.exports.crit(error.stack.toString());
} | [
"function",
"unhandledRejectionHandler",
"(",
"error",
")",
"{",
"let",
"reasonString",
"=",
"error",
".",
"message",
"||",
"error",
".",
"msg",
"||",
"JSON",
".",
"stringify",
"(",
"error",
")",
";",
"module",
".",
"exports",
".",
"crit",
"(",
"`",
"${"... | Handler for the unhandledRejection event. Will print out a warning message using the log system. | [
"Handler",
"for",
"the",
"unhandledRejection",
"event",
".",
"Will",
"print",
"out",
"a",
"warning",
"message",
"using",
"the",
"log",
"system",
"."
] | 9aedc9542dffdc274a5142515bd22e92833220d2 | https://github.com/me-ventures/microservice-toolkit/blob/9aedc9542dffdc274a5142515bd22e92833220d2/src/logger.js#L103-L108 | train |
redisjs/jsr-error | lib/index.js | StoreError | function StoreError(type, message) {
this.name = StoreError.name;
Error.call(this);
type = type || ERR;
message = type + ' ' + (message || 'unknown internal error');
if(arguments.length > 2) {
var args = [message].concat([].slice.call(arguments, 2));
message = util.format.apply(util, args);
}
this... | javascript | function StoreError(type, message) {
this.name = StoreError.name;
Error.call(this);
type = type || ERR;
message = type + ' ' + (message || 'unknown internal error');
if(arguments.length > 2) {
var args = [message].concat([].slice.call(arguments, 2));
message = util.format.apply(util, args);
}
this... | [
"function",
"StoreError",
"(",
"type",
",",
"message",
")",
"{",
"this",
".",
"name",
"=",
"StoreError",
".",
"name",
";",
"Error",
".",
"call",
"(",
"this",
")",
";",
"type",
"=",
"type",
"||",
"ERR",
";",
"message",
"=",
"type",
"+",
"' '",
"+",
... | Abstract error super class. | [
"Abstract",
"error",
"super",
"class",
"."
] | f27ff57f90683895643d0ecc44feaf9bf8a18ae3 | https://github.com/redisjs/jsr-error/blob/f27ff57f90683895643d0ecc44feaf9bf8a18ae3/lib/index.js#L15-L25 | 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.