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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/dom/element.js | function( selector ) {
var removeTmpId = createTmpId( this ),
list = new CKEDITOR.dom.nodeList(
this.$.querySelectorAll( getContextualizedSelector( this, selector ) )
);
removeTmpId();
return list;
} | javascript | function( selector ) {
var removeTmpId = createTmpId( this ),
list = new CKEDITOR.dom.nodeList(
this.$.querySelectorAll( getContextualizedSelector( this, selector ) )
);
removeTmpId();
return list;
} | [
"function",
"(",
"selector",
")",
"{",
"var",
"removeTmpId",
"=",
"createTmpId",
"(",
"this",
")",
",",
"list",
"=",
"new",
"CKEDITOR",
".",
"dom",
".",
"nodeList",
"(",
"this",
".",
"$",
".",
"querySelectorAll",
"(",
"getContextualizedSelector",
"(",
"thi... | Returns list of elements within this element that match specified `selector`.
**Notes:**
* Not available in IE7.
* Returned list is not a live collection (like a result of native `querySelectorAll`).
* Unlike native `querySelectorAll` this method ensures selector contextualization. This is:
HTML: '<body><div><i>foo... | [
"Returns",
"list",
"of",
"elements",
"within",
"this",
"element",
"that",
"match",
"specified",
"selector",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/dom/element.js#L1882-L1891 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/dom/element.js | function( selector ) {
var removeTmpId = createTmpId( this ),
found = this.$.querySelector( getContextualizedSelector( this, selector ) );
removeTmpId();
return found ? new CKEDITOR.dom.element( found ) : null;
} | javascript | function( selector ) {
var removeTmpId = createTmpId( this ),
found = this.$.querySelector( getContextualizedSelector( this, selector ) );
removeTmpId();
return found ? new CKEDITOR.dom.element( found ) : null;
} | [
"function",
"(",
"selector",
")",
"{",
"var",
"removeTmpId",
"=",
"createTmpId",
"(",
"this",
")",
",",
"found",
"=",
"this",
".",
"$",
".",
"querySelector",
"(",
"getContextualizedSelector",
"(",
"this",
",",
"selector",
")",
")",
";",
"removeTmpId",
"(",... | Returns first element within this element that matches specified `selector`.
**Notes:**
* Not available in IE7.
* Unlike native `querySelectorAll` this method ensures selector contextualization. This is:
HTML: '<body><div><i>foo</i></div></body>'
Native: div.querySelector( 'body i' ) // -> <i>foo</i>
Method: di... | [
"Returns",
"first",
"element",
"within",
"this",
"element",
"that",
"matches",
"specified",
"selector",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/dom/element.js#L1910-L1917 | train | |
Mindfor/gulp-bundle-file | index.js | pushTo | function pushTo(array) {
return map(function (file, cb) {
array.push(file);
cb(null, file);
});
} | javascript | function pushTo(array) {
return map(function (file, cb) {
array.push(file);
cb(null, file);
});
} | [
"function",
"pushTo",
"(",
"array",
")",
"{",
"return",
"map",
"(",
"function",
"(",
"file",
",",
"cb",
")",
"{",
"array",
".",
"push",
"(",
"file",
")",
";",
"cb",
"(",
"null",
",",
"file",
")",
";",
"}",
")",
";",
"}"
] | pushes files from pipe to array | [
"pushes",
"files",
"from",
"pipe",
"to",
"array"
] | c4d8a80d869c528d3d7e51d0b9944dbb1bcfecf6 | https://github.com/Mindfor/gulp-bundle-file/blob/c4d8a80d869c528d3d7e51d0b9944dbb1bcfecf6/index.js#L14-L19 | train |
Mindfor/gulp-bundle-file | index.js | processBundleFile | function processBundleFile(file, bundleExt, variables, bundleHandler, errorCallback) {
// get bundle files
var lines = file.contents.toString().split('\n');
var resultFilePaths = [];
lines.forEach(function (line) {
var filePath = getFilePathFromLine(file, line, variables);
if (filePath)
resultFilePaths.push(... | javascript | function processBundleFile(file, bundleExt, variables, bundleHandler, errorCallback) {
// get bundle files
var lines = file.contents.toString().split('\n');
var resultFilePaths = [];
lines.forEach(function (line) {
var filePath = getFilePathFromLine(file, line, variables);
if (filePath)
resultFilePaths.push(... | [
"function",
"processBundleFile",
"(",
"file",
",",
"bundleExt",
",",
"variables",
",",
"bundleHandler",
",",
"errorCallback",
")",
"{",
"// get bundle files",
"var",
"lines",
"=",
"file",
".",
"contents",
".",
"toString",
"(",
")",
".",
"split",
"(",
"'\\n'",
... | creates new pipe for files from bundle | [
"creates",
"new",
"pipe",
"for",
"files",
"from",
"bundle"
] | c4d8a80d869c528d3d7e51d0b9944dbb1bcfecf6 | https://github.com/Mindfor/gulp-bundle-file/blob/c4d8a80d869c528d3d7e51d0b9944dbb1bcfecf6/index.js#L35-L57 | train |
Mindfor/gulp-bundle-file | index.js | getFilePathFromLine | function getFilePathFromLine(bundleFile, line, variables) {
// handle variables
var varRegex = /@{([^}]+)}/;
var match;
while (match = line.match(varRegex)) {
var varName = match[1];
if (!variables || typeof (variables[varName]) === 'undefined')
throw new gutil.PluginError(pluginName, bundleFile.path + ': va... | javascript | function getFilePathFromLine(bundleFile, line, variables) {
// handle variables
var varRegex = /@{([^}]+)}/;
var match;
while (match = line.match(varRegex)) {
var varName = match[1];
if (!variables || typeof (variables[varName]) === 'undefined')
throw new gutil.PluginError(pluginName, bundleFile.path + ': va... | [
"function",
"getFilePathFromLine",
"(",
"bundleFile",
",",
"line",
",",
"variables",
")",
"{",
"// handle variables",
"var",
"varRegex",
"=",
"/",
"@{([^}]+)}",
"/",
";",
"var",
"match",
";",
"while",
"(",
"match",
"=",
"line",
".",
"match",
"(",
"varRegex",... | parses file path from line in bundle file | [
"parses",
"file",
"path",
"from",
"line",
"in",
"bundle",
"file"
] | c4d8a80d869c528d3d7e51d0b9944dbb1bcfecf6 | https://github.com/Mindfor/gulp-bundle-file/blob/c4d8a80d869c528d3d7e51d0b9944dbb1bcfecf6/index.js#L60-L92 | train |
Mindfor/gulp-bundle-file | index.js | recursiveBundle | function recursiveBundle(bundleExt, variables, errorCallback) {
return through2.obj(function (file, enc, cb) {
if (!checkFile(file, cb))
return;
// standart file push to callback
if (path.extname(file.path).toLowerCase() != bundleExt)
return cb(null, file);
// bundle file should be parsed
processBund... | javascript | function recursiveBundle(bundleExt, variables, errorCallback) {
return through2.obj(function (file, enc, cb) {
if (!checkFile(file, cb))
return;
// standart file push to callback
if (path.extname(file.path).toLowerCase() != bundleExt)
return cb(null, file);
// bundle file should be parsed
processBund... | [
"function",
"recursiveBundle",
"(",
"bundleExt",
",",
"variables",
",",
"errorCallback",
")",
"{",
"return",
"through2",
".",
"obj",
"(",
"function",
"(",
"file",
",",
"enc",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"checkFile",
"(",
"file",
",",
"cb",
")"... | recursively processes files and unwraps bundle files | [
"recursively",
"processes",
"files",
"and",
"unwraps",
"bundle",
"files"
] | c4d8a80d869c528d3d7e51d0b9944dbb1bcfecf6 | https://github.com/Mindfor/gulp-bundle-file/blob/c4d8a80d869c528d3d7e51d0b9944dbb1bcfecf6/index.js#L95-L109 | train |
Mindfor/gulp-bundle-file | index.js | function (variables, bundleHandler) {
// handle if bundleHandler specified in first argument
if (!bundleHandler && typeof (variables) === 'function') {
bundleHandler = variables;
variables = null;
}
return through2.obj(function (file, enc, cb) {
if (!checkFile(file, cb))
return;
var ext = path... | javascript | function (variables, bundleHandler) {
// handle if bundleHandler specified in first argument
if (!bundleHandler && typeof (variables) === 'function') {
bundleHandler = variables;
variables = null;
}
return through2.obj(function (file, enc, cb) {
if (!checkFile(file, cb))
return;
var ext = path... | [
"function",
"(",
"variables",
",",
"bundleHandler",
")",
"{",
"// handle if bundleHandler specified in first argument",
"if",
"(",
"!",
"bundleHandler",
"&&",
"typeof",
"(",
"variables",
")",
"===",
"'function'",
")",
"{",
"bundleHandler",
"=",
"variables",
";",
"va... | concatenates files from bundle and replaces bundle file in current pipe first parameter is function that handles source stream for each bundle | [
"concatenates",
"files",
"from",
"bundle",
"and",
"replaces",
"bundle",
"file",
"in",
"current",
"pipe",
"first",
"parameter",
"is",
"function",
"that",
"handles",
"source",
"stream",
"for",
"each",
"bundle"
] | c4d8a80d869c528d3d7e51d0b9944dbb1bcfecf6 | https://github.com/Mindfor/gulp-bundle-file/blob/c4d8a80d869c528d3d7e51d0b9944dbb1bcfecf6/index.js#L127-L149 | train | |
uugolab/sycle | lib/errors/dispatch-error.js | DispatchError | function DispatchError(message) {
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.name = 'DispatchError';
this.message = message;
} | javascript | function DispatchError(message) {
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.name = 'DispatchError';
this.message = message;
} | [
"function",
"DispatchError",
"(",
"message",
")",
"{",
"Error",
".",
"call",
"(",
"this",
")",
";",
"Error",
".",
"captureStackTrace",
"(",
"this",
",",
"arguments",
".",
"callee",
")",
";",
"this",
".",
"name",
"=",
"'DispatchError'",
";",
"this",
".",
... | `DispatchError` error.
@api private | [
"DispatchError",
"error",
"."
] | 90902246537860adee22664a584c66d72826b5bb | https://github.com/uugolab/sycle/blob/90902246537860adee22664a584c66d72826b5bb/lib/errors/dispatch-error.js#L6-L11 | train |
tunnckoCore/kind-error | index.js | delegateOptional | function delegateOptional (self) {
if (hasOwn(self, 'actual') && hasOwn(self, 'expected')) {
var kindOf = tryRequire('kind-of-extra', 'kind-error')
delegate(self, {
orig: {
actual: self.actual,
expected: self.expected
},
type: {
actual: kindOf(self.actual),
ex... | javascript | function delegateOptional (self) {
if (hasOwn(self, 'actual') && hasOwn(self, 'expected')) {
var kindOf = tryRequire('kind-of-extra', 'kind-error')
delegate(self, {
orig: {
actual: self.actual,
expected: self.expected
},
type: {
actual: kindOf(self.actual),
ex... | [
"function",
"delegateOptional",
"(",
"self",
")",
"{",
"if",
"(",
"hasOwn",
"(",
"self",
",",
"'actual'",
")",
"&&",
"hasOwn",
"(",
"self",
",",
"'expected'",
")",
")",
"{",
"var",
"kindOf",
"=",
"tryRequire",
"(",
"'kind-of-extra'",
",",
"'kind-error'",
... | > Delegate additional optional properties to the `KindError` class.
If `actual` and `expected` properties given in `options` object.
@param {Object} `self`
@return {Object} | [
">",
"Delegate",
"additional",
"optional",
"properties",
"to",
"the",
"KindError",
"class",
".",
"If",
"actual",
"and",
"expected",
"properties",
"given",
"in",
"options",
"object",
"."
] | 3ab0e42a4bc6d42d8b7803027419e4f68e332027 | https://github.com/tunnckoCore/kind-error/blob/3ab0e42a4bc6d42d8b7803027419e4f68e332027/index.js#L72-L94 | train |
tunnckoCore/kind-error | index.js | messageFormat | function messageFormat (type, inspect) {
var msg = this.detailed
? 'expect %s `%s`, but %s `%s` given'
: 'expect `%s`, but `%s` given'
return this.detailed
? util.format(msg, type.expected, inspect.expected, type.actual, inspect.actual)
: util.format(msg, type.expected, type.actual)
} | javascript | function messageFormat (type, inspect) {
var msg = this.detailed
? 'expect %s `%s`, but %s `%s` given'
: 'expect `%s`, but `%s` given'
return this.detailed
? util.format(msg, type.expected, inspect.expected, type.actual, inspect.actual)
: util.format(msg, type.expected, type.actual)
} | [
"function",
"messageFormat",
"(",
"type",
",",
"inspect",
")",
"{",
"var",
"msg",
"=",
"this",
".",
"detailed",
"?",
"'expect %s `%s`, but %s `%s` given'",
":",
"'expect `%s`, but `%s` given'",
"return",
"this",
".",
"detailed",
"?",
"util",
".",
"format",
"(",
... | > Default message formatting function.
@param {Object} `type`
@param {Object} `inspect`
@return {String} | [
">",
"Default",
"message",
"formatting",
"function",
"."
] | 3ab0e42a4bc6d42d8b7803027419e4f68e332027 | https://github.com/tunnckoCore/kind-error/blob/3ab0e42a4bc6d42d8b7803027419e4f68e332027/index.js#L124-L131 | train |
wilmoore/regexp-map.js | index.js | remap | function remap (map, str) {
str = string.call(str) === '[object String]' ? str : ''
for (var key in map) {
if (str.match(new RegExp(key, 'i'))) return map[key]
}
return ''
} | javascript | function remap (map, str) {
str = string.call(str) === '[object String]' ? str : ''
for (var key in map) {
if (str.match(new RegExp(key, 'i'))) return map[key]
}
return ''
} | [
"function",
"remap",
"(",
"map",
",",
"str",
")",
"{",
"str",
"=",
"string",
".",
"call",
"(",
"str",
")",
"===",
"'[object String]'",
"?",
"str",
":",
"''",
"for",
"(",
"var",
"key",
"in",
"map",
")",
"{",
"if",
"(",
"str",
".",
"match",
"(",
... | Curried function which takes a map of `RegExp` string keys which when successfully matched given string, resolves to mapped value.
@param {Object.<string, string>} map
Map of `RegExp` strings which when matched against string successfully, resolves to mapped value.
@param {String} str
String to search.
@return {Stri... | [
"Curried",
"function",
"which",
"takes",
"a",
"map",
"of",
"RegExp",
"string",
"keys",
"which",
"when",
"successfully",
"matched",
"given",
"string",
"resolves",
"to",
"mapped",
"value",
"."
] | 2d40aad44c4cd36a2e6af0070534c599d00f7109 | https://github.com/wilmoore/regexp-map.js/blob/2d40aad44c4cd36a2e6af0070534c599d00f7109/index.js#L29-L37 | train |
danigb/music.operator | index.js | add | function add (a, b) {
var fifths = a[0] + b[0]
var octaves = a[1] === null || b[1] === null ? null : a[1] + b[1]
return [fifths, octaves]
} | javascript | function add (a, b) {
var fifths = a[0] + b[0]
var octaves = a[1] === null || b[1] === null ? null : a[1] + b[1]
return [fifths, octaves]
} | [
"function",
"add",
"(",
"a",
",",
"b",
")",
"{",
"var",
"fifths",
"=",
"a",
"[",
"0",
"]",
"+",
"b",
"[",
"0",
"]",
"var",
"octaves",
"=",
"a",
"[",
"1",
"]",
"===",
"null",
"||",
"b",
"[",
"1",
"]",
"===",
"null",
"?",
"null",
":",
"a",
... | Add two pitches. Can be used to tranpose pitches.
@param {Array} first - first pitch
@param {Array} second - second pitch
@return {Array} both pitches added
@example
operator.add([3, 0, 0], [4, 0, 0]) // => [0, 0, 1] | [
"Add",
"two",
"pitches",
".",
"Can",
"be",
"used",
"to",
"tranpose",
"pitches",
"."
] | 5da2c1528ba704dea0ca10065fda4b91aadc8b0d | https://github.com/danigb/music.operator/blob/5da2c1528ba704dea0ca10065fda4b91aadc8b0d/index.js#L178-L182 | train |
danigb/music.operator | index.js | subtract | function subtract (a, b) {
var fifths = b[0] - a[0]
var octaves = a[1] !== null && b[1] !== null ? b[1] - a[1] : null
return [fifths, octaves]
} | javascript | function subtract (a, b) {
var fifths = b[0] - a[0]
var octaves = a[1] !== null && b[1] !== null ? b[1] - a[1] : null
return [fifths, octaves]
} | [
"function",
"subtract",
"(",
"a",
",",
"b",
")",
"{",
"var",
"fifths",
"=",
"b",
"[",
"0",
"]",
"-",
"a",
"[",
"0",
"]",
"var",
"octaves",
"=",
"a",
"[",
"1",
"]",
"!==",
"null",
"&&",
"b",
"[",
"1",
"]",
"!==",
"null",
"?",
"b",
"[",
"1"... | Subtract two pitches or intervals. Can be used to find the distance between pitches.
@name subtract
@function
@param {Array} a - one pitch or interval in [pitch-array](https://github.com/danigb/pitch-array) format
@param {Array} b - the other pitch or interval in [pitch-array](https://github.com/danigb/pitch-array) fo... | [
"Subtract",
"two",
"pitches",
"or",
"intervals",
".",
"Can",
"be",
"used",
"to",
"find",
"the",
"distance",
"between",
"pitches",
"."
] | 5da2c1528ba704dea0ca10065fda4b91aadc8b0d | https://github.com/danigb/music.operator/blob/5da2c1528ba704dea0ca10065fda4b91aadc8b0d/index.js#L205-L209 | train |
queckezz/list | lib/nth.js | nth | function nth (n, array) {
return n < 0 ? array[array.length + n] : array[n]
} | javascript | function nth (n, array) {
return n < 0 ? array[array.length + n] : array[n]
} | [
"function",
"nth",
"(",
"n",
",",
"array",
")",
"{",
"return",
"n",
"<",
"0",
"?",
"array",
"[",
"array",
".",
"length",
"+",
"n",
"]",
":",
"array",
"[",
"n",
"]",
"}"
] | Returns the `n`th element in the given `array`.
@param {Int} n Index
@param {Array} array Array to operate on
@return {Any} `n`th element | [
"Returns",
"the",
"n",
"th",
"element",
"in",
"the",
"given",
"array",
"."
] | a26130020b447a1aa136f0fed3283821490f7da4 | https://github.com/queckezz/list/blob/a26130020b447a1aa136f0fed3283821490f7da4/lib/nth.js#L11-L13 | train |
YahooArchive/mojito-cli-jslint | lib/lintifier.js | scanErr | function scanErr(err, pathname) {
log.debug(err);
if ('ENOENT' === err.code) {
callback(pathname + ' does not exist.');
} else {
callback('Unexpected error.');
}
// cli does process.exit() in callback, but unit tests don't.
callback = function () {};
} | javascript | function scanErr(err, pathname) {
log.debug(err);
if ('ENOENT' === err.code) {
callback(pathname + ' does not exist.');
} else {
callback('Unexpected error.');
}
// cli does process.exit() in callback, but unit tests don't.
callback = function () {};
} | [
"function",
"scanErr",
"(",
"err",
",",
"pathname",
")",
"{",
"log",
".",
"debug",
"(",
"err",
")",
";",
"if",
"(",
"'ENOENT'",
"===",
"err",
".",
"code",
")",
"{",
"callback",
"(",
"pathname",
"+",
"' does not exist.'",
")",
";",
"}",
"else",
"{",
... | scanfs error callback | [
"scanfs",
"error",
"callback"
] | cc6f90352534689a9e8c524c4cce825215bb5186 | https://github.com/YahooArchive/mojito-cli-jslint/blob/cc6f90352534689a9e8c524c4cce825215bb5186/lib/lintifier.js#L21-L31 | train |
gropox/golos-addons | golos.js | getCurrentServerTimeAndBlock | async function getCurrentServerTimeAndBlock() {
await retrieveDynGlobProps();
if(props.time) {
lastCommitedBlock = props.last_irreversible_block_num;
trace("lastCommitedBlock = " + lastCommitedBlock + ", headBlock = " + props.head_block_number);
return {
time : Date.parse(pr... | javascript | async function getCurrentServerTimeAndBlock() {
await retrieveDynGlobProps();
if(props.time) {
lastCommitedBlock = props.last_irreversible_block_num;
trace("lastCommitedBlock = " + lastCommitedBlock + ", headBlock = " + props.head_block_number);
return {
time : Date.parse(pr... | [
"async",
"function",
"getCurrentServerTimeAndBlock",
"(",
")",
"{",
"await",
"retrieveDynGlobProps",
"(",
")",
";",
"if",
"(",
"props",
".",
"time",
")",
"{",
"lastCommitedBlock",
"=",
"props",
".",
"last_irreversible_block_num",
";",
"trace",
"(",
"\"lastCommited... | time in milliseconds | [
"time",
"in",
"milliseconds"
] | 14b132e7aa89d82db12cf2614faaddbec7e1cb9f | https://github.com/gropox/golos-addons/blob/14b132e7aa89d82db12cf2614faaddbec7e1cb9f/golos.js#L37-L49 | train |
guileen/node-formconv | scheme.js | filter | function filter(obj) {
var result = {}, fieldDefine, value;
for(var field in options) {
fieldDefine = options[field];
value = obj[field];
if(!fieldDefine.private && value !== undefined) {
result[field] = value;
}
}
return result;
} | javascript | function filter(obj) {
var result = {}, fieldDefine, value;
for(var field in options) {
fieldDefine = options[field];
value = obj[field];
if(!fieldDefine.private && value !== undefined) {
result[field] = value;
}
}
return result;
} | [
"function",
"filter",
"(",
"obj",
")",
"{",
"var",
"result",
"=",
"{",
"}",
",",
"fieldDefine",
",",
"value",
";",
"for",
"(",
"var",
"field",
"in",
"options",
")",
"{",
"fieldDefine",
"=",
"options",
"[",
"field",
"]",
";",
"value",
"=",
"obj",
"[... | filter private fields | [
"filter",
"private",
"fields"
] | b2eb725a4fd5643540c59c8ce27a78a8a8c91335 | https://github.com/guileen/node-formconv/blob/b2eb725a4fd5643540c59c8ce27a78a8a8c91335/scheme.js#L124-L134 | train |
hpcloud/hpcloud-js | lib/objectstorage/container.js | Container | function Container(name, token, url) {
this._name = name;
this._url = url;
this._token = token;
this.isNew = false;
} | javascript | function Container(name, token, url) {
this._name = name;
this._url = url;
this._token = token;
this.isNew = false;
} | [
"function",
"Container",
"(",
"name",
",",
"token",
",",
"url",
")",
"{",
"this",
".",
"_name",
"=",
"name",
";",
"this",
".",
"_url",
"=",
"url",
";",
"this",
".",
"_token",
"=",
"token",
";",
"this",
".",
"isNew",
"=",
"false",
";",
"}"
] | Create a new container.
When a new container is created, no check is done against the server
to ensure that the container exists. Thus, it is possible to have a
local container object that does not point to a legitimate
server-side container.
@class Container
@constructor
@param {String} name The name of the contain... | [
"Create",
"a",
"new",
"container",
"."
] | c457ea3ee6a21e361d1af0af70d64622b6910208 | https://github.com/hpcloud/hpcloud-js/blob/c457ea3ee6a21e361d1af0af70d64622b6910208/lib/objectstorage/container.js#L58-L63 | train |
ForbesLindesay-Unmaintained/sauce-test | lib/wait-for-job-to-finish.js | waitForJobToFinish | function waitForJobToFinish(driver, options) {
return new Promise(function (resolve, reject) {
var start = Date.now();
var timingOut = false;
function check() {
var checkedForExceptions;
if (options.allowExceptions) {
checkedForExceptions = Promise.resolve(null);
} else {
... | javascript | function waitForJobToFinish(driver, options) {
return new Promise(function (resolve, reject) {
var start = Date.now();
var timingOut = false;
function check() {
var checkedForExceptions;
if (options.allowExceptions) {
checkedForExceptions = Promise.resolve(null);
} else {
... | [
"function",
"waitForJobToFinish",
"(",
"driver",
",",
"options",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"var",
"start",
"=",
"Date",
".",
"now",
"(",
")",
";",
"var",
"timingOut",
"=",
"false",
"... | Wait for a driver that has a running job to finish its job
@option {Boolean} allowExceptions Set to `true` to skip the check for `window.onerror`
@option {String|Function} testComplete A function to test if the job is complete
@option {String} timeout The timeout (gets passed to ms)
@param... | [
"Wait",
"for",
"a",
"driver",
"that",
"has",
"a",
"running",
"job",
"to",
"finish",
"its",
"job"
] | 7c671b3321dc63aefc00c1c8d49e943ead2e7f5e | https://github.com/ForbesLindesay-Unmaintained/sauce-test/blob/7c671b3321dc63aefc00c1c8d49e943ead2e7f5e/lib/wait-for-job-to-finish.js#L20-L62 | train |
Tjatse/range | index.js | Range | function Range(){
if (!(this instanceof Range)) {
return new Range();
}
// maximize int.
var max = Math.pow(2, 32) - 1;
// default options.
this.options = {
min: -max,
max: max,
res: {
range : /^[\s\d\-~,]+$/,
blank : /\s+/g,
number : /^\-?\d+$/,
min2num: /^~\-?\d+... | javascript | function Range(){
if (!(this instanceof Range)) {
return new Range();
}
// maximize int.
var max = Math.pow(2, 32) - 1;
// default options.
this.options = {
min: -max,
max: max,
res: {
range : /^[\s\d\-~,]+$/,
blank : /\s+/g,
number : /^\-?\d+$/,
min2num: /^~\-?\d+... | [
"function",
"Range",
"(",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Range",
")",
")",
"{",
"return",
"new",
"Range",
"(",
")",
";",
"}",
"// maximize int.",
"var",
"max",
"=",
"Math",
".",
"pow",
"(",
"2",
",",
"32",
")",
"-",
"1",
... | Range parser.
@returns {Range}
@constructor | [
"Range",
"parser",
"."
] | ad806642189ca7df22f8b0d16432a3ca68e071c7 | https://github.com/Tjatse/range/blob/ad806642189ca7df22f8b0d16432a3ca68e071c7/index.js#L11-L33 | train |
Tjatse/range | index.js | function(s, opts){
var r = s.split('~').map(function(d){
return parseFloat(d);
});
// number at position 1 must greater than position 0.
if (r[0] > r[1]) {
return r.reverse();
}
return r;
} | javascript | function(s, opts){
var r = s.split('~').map(function(d){
return parseFloat(d);
});
// number at position 1 must greater than position 0.
if (r[0] > r[1]) {
return r.reverse();
}
return r;
} | [
"function",
"(",
"s",
",",
"opts",
")",
"{",
"var",
"r",
"=",
"s",
".",
"split",
"(",
"'~'",
")",
".",
"map",
"(",
"function",
"(",
"d",
")",
"{",
"return",
"parseFloat",
"(",
"d",
")",
";",
"}",
")",
";",
"// number at position 1 must greater than p... | String like `1~2`, `5~8`, it means a range from a specific number to another.
@param {String} s
@param {Object} opts
@returns {*} | [
"String",
"like",
"1~2",
"5~8",
"it",
"means",
"a",
"range",
"from",
"a",
"specific",
"number",
"to",
"another",
"."
] | ad806642189ca7df22f8b0d16432a3ca68e071c7 | https://github.com/Tjatse/range/blob/ad806642189ca7df22f8b0d16432a3ca68e071c7/index.js#L146-L155 | train | |
jkroso/rename-variables | index.js | rename | function rename(node, it, to){
switch (node.type) {
case 'VariableDeclaration':
return node.declarations.forEach(function(dec){
if (dec.id.name == it) dec.id.name = to
if (dec.init) rename(dec.init, it, to)
})
case 'FunctionDeclaration':
if (node.id.name == it) node.id.name =... | javascript | function rename(node, it, to){
switch (node.type) {
case 'VariableDeclaration':
return node.declarations.forEach(function(dec){
if (dec.id.name == it) dec.id.name = to
if (dec.init) rename(dec.init, it, to)
})
case 'FunctionDeclaration':
if (node.id.name == it) node.id.name =... | [
"function",
"rename",
"(",
"node",
",",
"it",
",",
"to",
")",
"{",
"switch",
"(",
"node",
".",
"type",
")",
"{",
"case",
"'VariableDeclaration'",
":",
"return",
"node",
".",
"declarations",
".",
"forEach",
"(",
"function",
"(",
"dec",
")",
"{",
"if",
... | rename all references to `it` in or below `nodes`'s
scope to `to`
@param {AST} node
@param {String} it
@param {String} to | [
"rename",
"all",
"references",
"to",
"it",
"in",
"or",
"below",
"nodes",
"s",
"scope",
"to",
"to"
] | b1ade439b857367f27f7b85bd1b024a6b01bc4be | https://github.com/jkroso/rename-variables/blob/b1ade439b857367f27f7b85bd1b024a6b01bc4be/index.js#L14-L39 | train |
jkroso/rename-variables | index.js | freshVars | function freshVars(node){
switch (node.type) {
case 'VariableDeclaration':
return node.declarations.map(function(n){ return n.id })
case 'FunctionExpression': return [] // early exit
case 'FunctionDeclaration':
return [node.id]
}
return children(node)
.map(freshVars)
.reduce(concat... | javascript | function freshVars(node){
switch (node.type) {
case 'VariableDeclaration':
return node.declarations.map(function(n){ return n.id })
case 'FunctionExpression': return [] // early exit
case 'FunctionDeclaration':
return [node.id]
}
return children(node)
.map(freshVars)
.reduce(concat... | [
"function",
"freshVars",
"(",
"node",
")",
"{",
"switch",
"(",
"node",
".",
"type",
")",
"{",
"case",
"'VariableDeclaration'",
":",
"return",
"node",
".",
"declarations",
".",
"map",
"(",
"function",
"(",
"n",
")",
"{",
"return",
"n",
".",
"id",
"}",
... | get all declared variables within `node`'s scope
@param {AST} node
@return {Array} | [
"get",
"all",
"declared",
"variables",
"within",
"node",
"s",
"scope"
] | b1ade439b857367f27f7b85bd1b024a6b01bc4be | https://github.com/jkroso/rename-variables/blob/b1ade439b857367f27f7b85bd1b024a6b01bc4be/index.js#L48-L59 | train |
kfranqueiro/node-irssi-log-parser | Parser.js | function (filename) {
var resume = filename === true; // should only ever be set by resume calls
var fd = this._fd = resume ? this._fd : fs.openSync(filename, 'r');
var buffer = new Buffer(4096);
var bytesRead;
var current = '';
var remainder = resume ? this._remainder : '';
while (!this._paused && (byte... | javascript | function (filename) {
var resume = filename === true; // should only ever be set by resume calls
var fd = this._fd = resume ? this._fd : fs.openSync(filename, 'r');
var buffer = new Buffer(4096);
var bytesRead;
var current = '';
var remainder = resume ? this._remainder : '';
while (!this._paused && (byte... | [
"function",
"(",
"filename",
")",
"{",
"var",
"resume",
"=",
"filename",
"===",
"true",
";",
"// should only ever be set by resume calls",
"var",
"fd",
"=",
"this",
".",
"_fd",
"=",
"resume",
"?",
"this",
".",
"_fd",
":",
"fs",
".",
"openSync",
"(",
"filen... | Parses the given log file.
@param {string} filename File to parse | [
"Parses",
"the",
"given",
"log",
"file",
"."
] | 7088868462a636b2473b2b0efdb3c1002c26b43c | https://github.com/kfranqueiro/node-irssi-log-parser/blob/7088868462a636b2473b2b0efdb3c1002c26b43c/Parser.js#L301-L323 | train | |
llucbrell/audrey2 | index.js | init | function init(){
//modules load
terminal.colors.default= chalk.white.bold;
terminal.default="";
//set the colors of the terminal
checkUserColors(terminal.colors);
bool=true;
//to control the view properties and colors
properties= Object.getOwnPropertyNames(terminal);
colors=Object.getOwnPropertyNames(terminal.colors);
... | javascript | function init(){
//modules load
terminal.colors.default= chalk.white.bold;
terminal.default="";
//set the colors of the terminal
checkUserColors(terminal.colors);
bool=true;
//to control the view properties and colors
properties= Object.getOwnPropertyNames(terminal);
colors=Object.getOwnPropertyNames(terminal.colors);
... | [
"function",
"init",
"(",
")",
"{",
"//modules load",
"terminal",
".",
"colors",
".",
"default",
"=",
"chalk",
".",
"white",
".",
"bold",
";",
"terminal",
".",
"default",
"=",
"\"\"",
";",
"//set the colors of the terminal",
"checkUserColors",
"(",
"terminal",
... | to reinit the audrey view when is updated | [
"to",
"reinit",
"the",
"audrey",
"view",
"when",
"is",
"updated"
] | eb683b25a6b1b05a9f832e85707fb7274542a1e5 | https://github.com/llucbrell/audrey2/blob/eb683b25a6b1b05a9f832e85707fb7274542a1e5/index.js#L154-L164 | train |
llucbrell/audrey2 | index.js | fertilise | function fertilise(objectName, value, color, blockPos){
if(!blockPos) throw new Error("incorrect call to fertilise method");
var name= objectName.slice(2);
terminal[name]=value;
terminal.colors[name]=color;
setOnBlock(objectName, blockPos);
checkUserColors(terminal.colors);
init();
} | javascript | function fertilise(objectName, value, color, blockPos){
if(!blockPos) throw new Error("incorrect call to fertilise method");
var name= objectName.slice(2);
terminal[name]=value;
terminal.colors[name]=color;
setOnBlock(objectName, blockPos);
checkUserColors(terminal.colors);
init();
} | [
"function",
"fertilise",
"(",
"objectName",
",",
"value",
",",
"color",
",",
"blockPos",
")",
"{",
"if",
"(",
"!",
"blockPos",
")",
"throw",
"new",
"Error",
"(",
"\"incorrect call to fertilise method\"",
")",
";",
"var",
"name",
"=",
"objectName",
".",
"slic... | by name, value,color block | [
"by",
"name",
"value",
"color",
"block"
] | eb683b25a6b1b05a9f832e85707fb7274542a1e5 | https://github.com/llucbrell/audrey2/blob/eb683b25a6b1b05a9f832e85707fb7274542a1e5/index.js#L203-L211 | train |
llucbrell/audrey2 | index.js | checkUserColors | function checkUserColors(colorUser){
if(terminal.colors){
for(var name in colorUser){
colorUser[name]= setUserColor(colorUser[name]);
}
}
else{
throw new Error("There is no colors object defined");
}
} | javascript | function checkUserColors(colorUser){
if(terminal.colors){
for(var name in colorUser){
colorUser[name]= setUserColor(colorUser[name]);
}
}
else{
throw new Error("There is no colors object defined");
}
} | [
"function",
"checkUserColors",
"(",
"colorUser",
")",
"{",
"if",
"(",
"terminal",
".",
"colors",
")",
"{",
"for",
"(",
"var",
"name",
"in",
"colorUser",
")",
"{",
"colorUser",
"[",
"name",
"]",
"=",
"setUserColor",
"(",
"colorUser",
"[",
"name",
"]",
"... | FUNCTIONS FOR THE CLI RESPONSE.. check if there is defined object colors if not, throw error | [
"FUNCTIONS",
"FOR",
"THE",
"CLI",
"RESPONSE",
"..",
"check",
"if",
"there",
"is",
"defined",
"object",
"colors",
"if",
"not",
"throw",
"error"
] | eb683b25a6b1b05a9f832e85707fb7274542a1e5 | https://github.com/llucbrell/audrey2/blob/eb683b25a6b1b05a9f832e85707fb7274542a1e5/index.js#L215-L224 | train |
llucbrell/audrey2 | index.js | setOnBlock | function setOnBlock(objectName, blockPos){
switch(blockPos){//check where to add in the structure
case 'header':
terminal.header.push(objectName);
break;
case 'body':
terminal.body.push(objectName);
break;
case 'footer':
terminal.footer.push(objectName);
break;
}
} | javascript | function setOnBlock(objectName, blockPos){
switch(blockPos){//check where to add in the structure
case 'header':
terminal.header.push(objectName);
break;
case 'body':
terminal.body.push(objectName);
break;
case 'footer':
terminal.footer.push(objectName);
break;
}
} | [
"function",
"setOnBlock",
"(",
"objectName",
",",
"blockPos",
")",
"{",
"switch",
"(",
"blockPos",
")",
"{",
"//check where to add in the structure",
"case",
"'header'",
":",
"terminal",
".",
"header",
".",
"push",
"(",
"objectName",
")",
";",
"break",
";",
"c... | adds new object to list of print | [
"adds",
"new",
"object",
"to",
"list",
"of",
"print"
] | eb683b25a6b1b05a9f832e85707fb7274542a1e5 | https://github.com/llucbrell/audrey2/blob/eb683b25a6b1b05a9f832e85707fb7274542a1e5/index.js#L226-L238 | train |
llucbrell/audrey2 | index.js | checkColors | function checkColors(name){
var colors=Object.getOwnPropertyNames(terminal.colors);
var bul=false; // boolean to control if its defined the property
for(var i=0; i<colors.length; i++){//iterate over prop names
if(colors[i] === name){//if it is
bul=true;
}
}
if(bul!==true){//if its finded the s... | javascript | function checkColors(name){
var colors=Object.getOwnPropertyNames(terminal.colors);
var bul=false; // boolean to control if its defined the property
for(var i=0; i<colors.length; i++){//iterate over prop names
if(colors[i] === name){//if it is
bul=true;
}
}
if(bul!==true){//if its finded the s... | [
"function",
"checkColors",
"(",
"name",
")",
"{",
"var",
"colors",
"=",
"Object",
".",
"getOwnPropertyNames",
"(",
"terminal",
".",
"colors",
")",
";",
"var",
"bul",
"=",
"false",
";",
"// boolean to control if its defined the property",
"for",
"(",
"var",
"i",
... | checks the colors in printBrand | [
"checks",
"the",
"colors",
"in",
"printBrand"
] | eb683b25a6b1b05a9f832e85707fb7274542a1e5 | https://github.com/llucbrell/audrey2/blob/eb683b25a6b1b05a9f832e85707fb7274542a1e5/index.js#L269-L282 | train |
llucbrell/audrey2 | index.js | checkProperties | function checkProperties(name){
var bul=false; // boolean to control if its defined the property
for(var i=0; i<properties.length; i++){//iterate over prop names
if(properties[i] === name){//if it is
bul=true;
}
}
if(bul!==true){// it isn't finded the statement of the tag
throw new Error('Not... | javascript | function checkProperties(name){
var bul=false; // boolean to control if its defined the property
for(var i=0; i<properties.length; i++){//iterate over prop names
if(properties[i] === name){//if it is
bul=true;
}
}
if(bul!==true){// it isn't finded the statement of the tag
throw new Error('Not... | [
"function",
"checkProperties",
"(",
"name",
")",
"{",
"var",
"bul",
"=",
"false",
";",
"// boolean to control if its defined the property",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"properties",
".",
"length",
";",
"i",
"++",
")",
"{",
"//iterate ove... | control if the view has the correct properties if not throw error | [
"control",
"if",
"the",
"view",
"has",
"the",
"correct",
"properties",
"if",
"not",
"throw",
"error"
] | eb683b25a6b1b05a9f832e85707fb7274542a1e5 | https://github.com/llucbrell/audrey2/blob/eb683b25a6b1b05a9f832e85707fb7274542a1e5/index.js#L470-L481 | train |
llucbrell/audrey2 | index.js | aError | function aError(errorObject){
if(!terminal.symbolProgress) terminal.symbolProgress="? ";
if(errorObject.aux){
if(!terminal.colors.aux) terminal.colors.aux= chalk.white;
console.log(terminal.colors.error(terminal.symbolProgress+" Error: "+errorObject.message)+ " " +terminal.colors.aux(errorObject.aux));
... | javascript | function aError(errorObject){
if(!terminal.symbolProgress) terminal.symbolProgress="? ";
if(errorObject.aux){
if(!terminal.colors.aux) terminal.colors.aux= chalk.white;
console.log(terminal.colors.error(terminal.symbolProgress+" Error: "+errorObject.message)+ " " +terminal.colors.aux(errorObject.aux));
... | [
"function",
"aError",
"(",
"errorObject",
")",
"{",
"if",
"(",
"!",
"terminal",
".",
"symbolProgress",
")",
"terminal",
".",
"symbolProgress",
"=",
"\"? \"",
";",
"if",
"(",
"errorObject",
".",
"aux",
")",
"{",
"if",
"(",
"!",
"terminal",
".",
"colors",
... | FUNCTIONS FOR PRINTING ON SCREEN print error message for debug | [
"FUNCTIONS",
"FOR",
"PRINTING",
"ON",
"SCREEN",
"print",
"error",
"message",
"for",
"debug"
] | eb683b25a6b1b05a9f832e85707fb7274542a1e5 | https://github.com/llucbrell/audrey2/blob/eb683b25a6b1b05a9f832e85707fb7274542a1e5/index.js#L486-L497 | train |
llucbrell/audrey2 | index.js | aSuccess | function aSuccess(errorObject){
if(!terminal.symbolProgress) terminal.symbolProgress="? ";
if(errorObject.aux){
if(!terminal.colors.aux) terminal.colors.aux= chalk.white;
console.log(terminal.colors.success(terminal.symbolProgress+" Success: "+errorObject.message) +" " +terminal.colors.aux(errorObject.aux));... | javascript | function aSuccess(errorObject){
if(!terminal.symbolProgress) terminal.symbolProgress="? ";
if(errorObject.aux){
if(!terminal.colors.aux) terminal.colors.aux= chalk.white;
console.log(terminal.colors.success(terminal.symbolProgress+" Success: "+errorObject.message) +" " +terminal.colors.aux(errorObject.aux));... | [
"function",
"aSuccess",
"(",
"errorObject",
")",
"{",
"if",
"(",
"!",
"terminal",
".",
"symbolProgress",
")",
"terminal",
".",
"symbolProgress",
"=",
"\"? \"",
";",
"if",
"(",
"errorObject",
".",
"aux",
")",
"{",
"if",
"(",
"!",
"terminal",
".",
"colors"... | print success error for debug | [
"print",
"success",
"error",
"for",
"debug"
] | eb683b25a6b1b05a9f832e85707fb7274542a1e5 | https://github.com/llucbrell/audrey2/blob/eb683b25a6b1b05a9f832e85707fb7274542a1e5/index.js#L499-L510 | train |
llucbrell/audrey2 | index.js | aWarning | function aWarning(errorObject){
if(!terminal.symbolProgress) terminal.symbolProgress="? ";
if(errorObject.aux){
if(!terminal.colors.aux) terminal.colors.aux= chalk.white;
console.log(terminal.colors.warning(terminal.symbolProgress+" Warning: "+errorObject.message)+" " +terminal.colors.aux(errorObject.aux));... | javascript | function aWarning(errorObject){
if(!terminal.symbolProgress) terminal.symbolProgress="? ";
if(errorObject.aux){
if(!terminal.colors.aux) terminal.colors.aux= chalk.white;
console.log(terminal.colors.warning(terminal.symbolProgress+" Warning: "+errorObject.message)+" " +terminal.colors.aux(errorObject.aux));... | [
"function",
"aWarning",
"(",
"errorObject",
")",
"{",
"if",
"(",
"!",
"terminal",
".",
"symbolProgress",
")",
"terminal",
".",
"symbolProgress",
"=",
"\"? \"",
";",
"if",
"(",
"errorObject",
".",
"aux",
")",
"{",
"if",
"(",
"!",
"terminal",
".",
"colors"... | print warning error for debug | [
"print",
"warning",
"error",
"for",
"debug"
] | eb683b25a6b1b05a9f832e85707fb7274542a1e5 | https://github.com/llucbrell/audrey2/blob/eb683b25a6b1b05a9f832e85707fb7274542a1e5/index.js#L512-L523 | train |
transomjs/transom-scaffold | lib/scaffoldHandler.js | addStaticAssetRoute | function addStaticAssetRoute(server, scaffold) {
assert(scaffold.path, `TransomScaffold staticRoute requires "path" to be specified.`);
const contentFolder = scaffold.folder || path.sep;
const serveStatic = scaffold.serveStatic || restify.plugins.serveStatic;
const defaultAsset = scaffo... | javascript | function addStaticAssetRoute(server, scaffold) {
assert(scaffold.path, `TransomScaffold staticRoute requires "path" to be specified.`);
const contentFolder = scaffold.folder || path.sep;
const serveStatic = scaffold.serveStatic || restify.plugins.serveStatic;
const defaultAsset = scaffo... | [
"function",
"addStaticAssetRoute",
"(",
"server",
",",
"scaffold",
")",
"{",
"assert",
"(",
"scaffold",
".",
"path",
",",
"`",
"`",
")",
";",
"const",
"contentFolder",
"=",
"scaffold",
".",
"folder",
"||",
"path",
".",
"sep",
";",
"const",
"serveStatic",
... | Add a GET route to the server to handle static assets.
@param {*} server - Restify server instance
@param {*} scaffold - Object from the staticRoutes array. | [
"Add",
"a",
"GET",
"route",
"to",
"the",
"server",
"to",
"handle",
"static",
"assets",
"."
] | 07550492282f972438b9af4d52c0befa4ba3b454 | https://github.com/transomjs/transom-scaffold/blob/07550492282f972438b9af4d52c0befa4ba3b454/lib/scaffoldHandler.js#L15-L36 | train |
transomjs/transom-scaffold | lib/scaffoldHandler.js | addRedirectRoute | function addRedirectRoute(server, scaffold) {
assert(scaffold.path && scaffold.target, `TransomScaffold redirectRoute requires 'path' and 'target' to be specified.`);
server.get(scaffold.path, function (req, res, next) {
res.redirect(scaffold.target, next);
});
} | javascript | function addRedirectRoute(server, scaffold) {
assert(scaffold.path && scaffold.target, `TransomScaffold redirectRoute requires 'path' and 'target' to be specified.`);
server.get(scaffold.path, function (req, res, next) {
res.redirect(scaffold.target, next);
});
} | [
"function",
"addRedirectRoute",
"(",
"server",
",",
"scaffold",
")",
"{",
"assert",
"(",
"scaffold",
".",
"path",
"&&",
"scaffold",
".",
"target",
",",
"`",
"`",
")",
";",
"server",
".",
"get",
"(",
"scaffold",
".",
"path",
",",
"function",
"(",
"req",... | Add a GET route that redirects to another URI.
@param {*} server - Restify server instance
@param {*} scaffold - Object from the redirectRoutes array. | [
"Add",
"a",
"GET",
"route",
"that",
"redirects",
"to",
"another",
"URI",
"."
] | 07550492282f972438b9af4d52c0befa4ba3b454 | https://github.com/transomjs/transom-scaffold/blob/07550492282f972438b9af4d52c0befa4ba3b454/lib/scaffoldHandler.js#L44-L50 | train |
transomjs/transom-scaffold | lib/scaffoldHandler.js | addTemplateRoute | function addTemplateRoute(server, scaffold) {
server.get(scaffold.path, function (req, res, next) {
const transomTemplate = server.registry.get(scaffold.templateHandler);
const contentType = scaffold.contentType || 'text/html';
const p = new Promise(function (resolve, reject... | javascript | function addTemplateRoute(server, scaffold) {
server.get(scaffold.path, function (req, res, next) {
const transomTemplate = server.registry.get(scaffold.templateHandler);
const contentType = scaffold.contentType || 'text/html';
const p = new Promise(function (resolve, reject... | [
"function",
"addTemplateRoute",
"(",
"server",
",",
"scaffold",
")",
"{",
"server",
".",
"get",
"(",
"scaffold",
".",
"path",
",",
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"const",
"transomTemplate",
"=",
"server",
".",
"registry",
".",... | Add a GET route that is handled with a template.
@param {*} server - Restify server instance
@param {*} scaffold | [
"Add",
"a",
"GET",
"route",
"that",
"is",
"handled",
"with",
"a",
"template",
"."
] | 07550492282f972438b9af4d52c0befa4ba3b454 | https://github.com/transomjs/transom-scaffold/blob/07550492282f972438b9af4d52c0befa4ba3b454/lib/scaffoldHandler.js#L58-L78 | train |
joelahoover/nomv | index.js | resolveNodeSkel | function resolveNodeSkel(index, nodeName) {
var idx = +graph.nameToIndex[nodeName];
argh = [idx, +index]
if(Number.isNaN(idx)) {
throw "Unable to get index for node '" + nodeName + "'. (Is the node name misspelled?)";
}
if(index !== undefined && idx > +index) {
throw "Unable to get index... | javascript | function resolveNodeSkel(index, nodeName) {
var idx = +graph.nameToIndex[nodeName];
argh = [idx, +index]
if(Number.isNaN(idx)) {
throw "Unable to get index for node '" + nodeName + "'. (Is the node name misspelled?)";
}
if(index !== undefined && idx > +index) {
throw "Unable to get index... | [
"function",
"resolveNodeSkel",
"(",
"index",
",",
"nodeName",
")",
"{",
"var",
"idx",
"=",
"+",
"graph",
".",
"nameToIndex",
"[",
"nodeName",
"]",
";",
"argh",
"=",
"[",
"idx",
",",
"+",
"index",
"]",
"if",
"(",
"Number",
".",
"isNaN",
"(",
"idx",
... | Helper function to lookup a node | [
"Helper",
"function",
"to",
"lookup",
"a",
"node"
] | 69a1a86882f500d52839f544538014460709ba9e | https://github.com/joelahoover/nomv/blob/69a1a86882f500d52839f544538014460709ba9e/index.js#L585-L598 | train |
joelahoover/nomv | index.js | resolveValueOrNodeSkel | function resolveValueOrNodeSkel(index, val, valDefault) {
switch (typeof(val)) {
case "string":
return resolveNodeSkel(index, val);
case "undefined":
if (valDefault === undefined) {
throw "Unable to get value'" + val + "'";
}
return () => valDefault;
defau... | javascript | function resolveValueOrNodeSkel(index, val, valDefault) {
switch (typeof(val)) {
case "string":
return resolveNodeSkel(index, val);
case "undefined":
if (valDefault === undefined) {
throw "Unable to get value'" + val + "'";
}
return () => valDefault;
defau... | [
"function",
"resolveValueOrNodeSkel",
"(",
"index",
",",
"val",
",",
"valDefault",
")",
"{",
"switch",
"(",
"typeof",
"(",
"val",
")",
")",
"{",
"case",
"\"string\"",
":",
"return",
"resolveNodeSkel",
"(",
"index",
",",
"val",
")",
";",
"case",
"\"undefine... | Helper function for getting either a value or data from another node, or return the default | [
"Helper",
"function",
"for",
"getting",
"either",
"a",
"value",
"or",
"data",
"from",
"another",
"node",
"or",
"return",
"the",
"default"
] | 69a1a86882f500d52839f544538014460709ba9e | https://github.com/joelahoover/nomv/blob/69a1a86882f500d52839f544538014460709ba9e/index.js#L602-L614 | train |
joelahoover/nomv | index.js | initialize | function initialize() {
var scene = ds = exports.ds = {
"time": 0,
"song": null,
"graph": null,
"shaders": {},
"textures": {},
"texturesToLoad": 0,
"audio": { "loaded": false, "playing": false },
"isLoaded": function() {
return this.graph !== null && this.texturesToLoad === 0 && ... | javascript | function initialize() {
var scene = ds = exports.ds = {
"time": 0,
"song": null,
"graph": null,
"shaders": {},
"textures": {},
"texturesToLoad": 0,
"audio": { "loaded": false, "playing": false },
"isLoaded": function() {
return this.graph !== null && this.texturesToLoad === 0 && ... | [
"function",
"initialize",
"(",
")",
"{",
"var",
"scene",
"=",
"ds",
"=",
"exports",
".",
"ds",
"=",
"{",
"\"time\"",
":",
"0",
",",
"\"song\"",
":",
"null",
",",
"\"graph\"",
":",
"null",
",",
"\"shaders\"",
":",
"{",
"}",
",",
"\"textures\"",
":",
... | Scene object for debugging | [
"Scene",
"object",
"for",
"debugging"
] | 69a1a86882f500d52839f544538014460709ba9e | https://github.com/joelahoover/nomv/blob/69a1a86882f500d52839f544538014460709ba9e/index.js#L876-L898 | train |
dimitrievski/sumov | lib/index.js | sumObjectValues | function sumObjectValues(object, depth, level = 1) {
let sum = 0;
for (const i in object) {
const value = object[i];
if (isNumber(value)) {
sum += parseFloat(value);
} else if (isObject(value) && (depth < 1 || depth > level)) {
sum += sumObjectValues(value, depth,... | javascript | function sumObjectValues(object, depth, level = 1) {
let sum = 0;
for (const i in object) {
const value = object[i];
if (isNumber(value)) {
sum += parseFloat(value);
} else if (isObject(value) && (depth < 1 || depth > level)) {
sum += sumObjectValues(value, depth,... | [
"function",
"sumObjectValues",
"(",
"object",
",",
"depth",
",",
"level",
"=",
"1",
")",
"{",
"let",
"sum",
"=",
"0",
";",
"for",
"(",
"const",
"i",
"in",
"object",
")",
"{",
"const",
"value",
"=",
"object",
"[",
"i",
"]",
";",
"if",
"(",
"isNumb... | Recursive function that computes the sum
of all numeric values in an object
@param {Object} object
@param {Integer} depth
@param {Integer} level
@returns {Number} | [
"Recursive",
"function",
"that",
"computes",
"the",
"sum",
"of",
"all",
"numeric",
"values",
"in",
"an",
"object"
] | bdbdae19305f9c7e86c2a9124b64d664c0893fab | https://github.com/dimitrievski/sumov/blob/bdbdae19305f9c7e86c2a9124b64d664c0893fab/lib/index.js#L37-L49 | train |
dimitrievski/sumov | lib/index.js | sumov | function sumov(object, depth = 0) {
if (isNumber(object)) {
return parseFloat(object);
} else if (isObject(object) && Number.isInteger(depth)) {
return sumObjectValues(object, depth);
}
return 0;
} | javascript | function sumov(object, depth = 0) {
if (isNumber(object)) {
return parseFloat(object);
} else if (isObject(object) && Number.isInteger(depth)) {
return sumObjectValues(object, depth);
}
return 0;
} | [
"function",
"sumov",
"(",
"object",
",",
"depth",
"=",
"0",
")",
"{",
"if",
"(",
"isNumber",
"(",
"object",
")",
")",
"{",
"return",
"parseFloat",
"(",
"object",
")",
";",
"}",
"else",
"if",
"(",
"isObject",
"(",
"object",
")",
"&&",
"Number",
".",... | Computes the sum of all numeric values in an object
@param {Object} object
@param {Integer} depth
@returns {Number}
@example
sumov({a: 2, b: ["2", null, [], {a: {a: -1.0}}], c: {quick: "maths"}});
// => 3
//sum up to 2 levels
sumov({a: 2, b: ["2", null, [], {a: {a: -1.0}}], c: {quick: "maths"}}, 2);
// => 4 | [
"Computes",
"the",
"sum",
"of",
"all",
"numeric",
"values",
"in",
"an",
"object"
] | bdbdae19305f9c7e86c2a9124b64d664c0893fab | https://github.com/dimitrievski/sumov/blob/bdbdae19305f9c7e86c2a9124b64d664c0893fab/lib/index.js#L66-L73 | train |
thiagodp/shuffle-obj-arrays | index.js | shuffleObjArrays | function shuffleObjArrays( map, options ) {
var newMap = !! options && true === options.copy ? {} : map;
var copyNonArrays = !! options && true === options.copy && true === ( options.copyNonArrays || options.copyNonArray );
var values = null;
for ( var key in map ) {
values = map[ key ];
... | javascript | function shuffleObjArrays( map, options ) {
var newMap = !! options && true === options.copy ? {} : map;
var copyNonArrays = !! options && true === options.copy && true === ( options.copyNonArrays || options.copyNonArray );
var values = null;
for ( var key in map ) {
values = map[ key ];
... | [
"function",
"shuffleObjArrays",
"(",
"map",
",",
"options",
")",
"{",
"var",
"newMap",
"=",
"!",
"!",
"options",
"&&",
"true",
"===",
"options",
".",
"copy",
"?",
"{",
"}",
":",
"map",
";",
"var",
"copyNonArrays",
"=",
"!",
"!",
"options",
"&&",
"tru... | Shuffles the arrays of the given map.
@param {object} map Maps string => array of values, e.g. `{ "foo": [ "x", "y" ], "bar": [ "a", "b", "c" ] }`.
@param {object} options All the options from [shuffle-array](https://github.com/pazguille/shuffle-array) plus:
- `copyNonArrays`: boolean -> If you want to copy non-array ... | [
"Shuffles",
"the",
"arrays",
"of",
"the",
"given",
"map",
"."
] | 1ef61c75a37fd3e6ba95935ea936b2811c72dd03 | https://github.com/thiagodp/shuffle-obj-arrays/blob/1ef61c75a37fd3e6ba95935ea936b2811c72dd03/index.js#L21-L34 | train |
mdp/dotp-crypt | lib/tweetnacl-fast.js | crypto_stream_salsa20_xor | function crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {
var z = new Uint8Array(16), x = new Uint8Array(64);
var u, i;
for (i = 0; i < 16; i++) z[i] = 0;
for (i = 0; i < 8; i++) z[i] = n[i];
while (b >= 64) {
crypto_core_salsa20(x,z,k,sigma);
for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];
... | javascript | function crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {
var z = new Uint8Array(16), x = new Uint8Array(64);
var u, i;
for (i = 0; i < 16; i++) z[i] = 0;
for (i = 0; i < 8; i++) z[i] = n[i];
while (b >= 64) {
crypto_core_salsa20(x,z,k,sigma);
for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];
... | [
"function",
"crypto_stream_salsa20_xor",
"(",
"c",
",",
"cpos",
",",
"m",
",",
"mpos",
",",
"b",
",",
"n",
",",
"k",
")",
"{",
"var",
"z",
"=",
"new",
"Uint8Array",
"(",
"16",
")",
",",
"x",
"=",
"new",
"Uint8Array",
"(",
"64",
")",
";",
"var",
... | "expand 32-byte k" | [
"expand",
"32",
"-",
"byte",
"k"
] | d8b99a3d0e4dafbeeee4926138b398a7f52ee4e8 | https://github.com/mdp/dotp-crypt/blob/d8b99a3d0e4dafbeeee4926138b398a7f52ee4e8/lib/tweetnacl-fast.js#L397-L420 | train |
nomocas/yamvish | lib/interpolable.js | handler | function handler(instance, context, func, index, callback) {
return function() {
var old = instance.results[index];
instance.results[index] = tryExpr(func, context);
if (old === instance.results[index])
return;
if (instance.dependenciesCount === 1 || !Interpolable.allowDelayedUpdate)
callback(instance.ou... | javascript | function handler(instance, context, func, index, callback) {
return function() {
var old = instance.results[index];
instance.results[index] = tryExpr(func, context);
if (old === instance.results[index])
return;
if (instance.dependenciesCount === 1 || !Interpolable.allowDelayedUpdate)
callback(instance.ou... | [
"function",
"handler",
"(",
"instance",
",",
"context",
",",
"func",
",",
"index",
",",
"callback",
")",
"{",
"return",
"function",
"(",
")",
"{",
"var",
"old",
"=",
"instance",
".",
"results",
"[",
"index",
"]",
";",
"instance",
".",
"results",
"[",
... | produce context's subscibtion event handler | [
"produce",
"context",
"s",
"subscibtion",
"event",
"handler"
] | 017a536bb6bafddf1b31c0c7af6f723be58e9f0e | https://github.com/nomocas/yamvish/blob/017a536bb6bafddf1b31c0c7af6f723be58e9f0e/lib/interpolable.js#L77-L93 | train |
nomocas/yamvish | lib/interpolable.js | directOutput | function directOutput(context) {
var o = tryExpr(this.parts[1].func, context);
return (typeof o === 'undefined' && !this._strict) ? '' : o;
} | javascript | function directOutput(context) {
var o = tryExpr(this.parts[1].func, context);
return (typeof o === 'undefined' && !this._strict) ? '' : o;
} | [
"function",
"directOutput",
"(",
"context",
")",
"{",
"var",
"o",
"=",
"tryExpr",
"(",
"this",
".",
"parts",
"[",
"1",
"]",
".",
"func",
",",
"context",
")",
";",
"return",
"(",
"typeof",
"o",
"===",
"'undefined'",
"&&",
"!",
"this",
".",
"_strict",
... | special case when interpolable is composed of only one expression with no text decoration return expr result directly | [
"special",
"case",
"when",
"interpolable",
"is",
"composed",
"of",
"only",
"one",
"expression",
"with",
"no",
"text",
"decoration",
"return",
"expr",
"result",
"directly"
] | 017a536bb6bafddf1b31c0c7af6f723be58e9f0e | https://github.com/nomocas/yamvish/blob/017a536bb6bafddf1b31c0c7af6f723be58e9f0e/lib/interpolable.js#L97-L100 | train |
nomocas/yamvish | lib/interpolable.js | function(context, callback, binds) {
var instance = new Instance(this);
var count = 0,
binded = false;
for (var i = 1, len = this.parts.length; i < len; i = i + 2) {
var block = this.parts[i];
if (block.binded) {
binded = true;
var h = handler(instance, context, block.func, count, callback),
... | javascript | function(context, callback, binds) {
var instance = new Instance(this);
var count = 0,
binded = false;
for (var i = 1, len = this.parts.length; i < len; i = i + 2) {
var block = this.parts[i];
if (block.binded) {
binded = true;
var h = handler(instance, context, block.func, count, callback),
... | [
"function",
"(",
"context",
",",
"callback",
",",
"binds",
")",
"{",
"var",
"instance",
"=",
"new",
"Instance",
"(",
"this",
")",
";",
"var",
"count",
"=",
"0",
",",
"binded",
"=",
"false",
";",
"for",
"(",
"var",
"i",
"=",
"1",
",",
"len",
"=",
... | produce instance and bind to context | [
"produce",
"instance",
"and",
"bind",
"to",
"context"
] | 017a536bb6bafddf1b31c0c7af6f723be58e9f0e | https://github.com/nomocas/yamvish/blob/017a536bb6bafddf1b31c0c7af6f723be58e9f0e/lib/interpolable.js#L191-L209 | train | |
nomocas/yamvish | lib/interpolable.js | function(context) {
if (this.directOutput)
return this.directOutput(context);
var out = "",
odd = true,
parts = this.parts;
for (var j = 0, len = parts.length; j < len; ++j) {
if (odd)
out += parts[j];
else {
var r = tryExpr(parts[j].func, context);
if (typeof r === 'undefined') {
... | javascript | function(context) {
if (this.directOutput)
return this.directOutput(context);
var out = "",
odd = true,
parts = this.parts;
for (var j = 0, len = parts.length; j < len; ++j) {
if (odd)
out += parts[j];
else {
var r = tryExpr(parts[j].func, context);
if (typeof r === 'undefined') {
... | [
"function",
"(",
"context",
")",
"{",
"if",
"(",
"this",
".",
"directOutput",
")",
"return",
"this",
".",
"directOutput",
"(",
"context",
")",
";",
"var",
"out",
"=",
"\"\"",
",",
"odd",
"=",
"true",
",",
"parts",
"=",
"this",
".",
"parts",
";",
"f... | output interpolable with given context | [
"output",
"interpolable",
"with",
"given",
"context"
] | 017a536bb6bafddf1b31c0c7af6f723be58e9f0e | https://github.com/nomocas/yamvish/blob/017a536bb6bafddf1b31c0c7af6f723be58e9f0e/lib/interpolable.js#L211-L232 | train | |
doowb/base-tree | index.js | tree | function tree(app, options) {
var opts = extend({}, options);
var node = {
label: getLabel(app, opts),
metadata: getMetadata(app, opts)
};
// get the names of the children to lookup
var names = arrayify(opts.names || ['nodes']);
return names.reduce(function(acc, name) {
var children = app[name]... | javascript | function tree(app, options) {
var opts = extend({}, options);
var node = {
label: getLabel(app, opts),
metadata: getMetadata(app, opts)
};
// get the names of the children to lookup
var names = arrayify(opts.names || ['nodes']);
return names.reduce(function(acc, name) {
var children = app[name]... | [
"function",
"tree",
"(",
"app",
",",
"options",
")",
"{",
"var",
"opts",
"=",
"extend",
"(",
"{",
"}",
",",
"options",
")",
";",
"var",
"node",
"=",
"{",
"label",
":",
"getLabel",
"(",
"app",
",",
"opts",
")",
",",
"metadata",
":",
"getMetadata",
... | Default tree building function. Gets the label and metadata properties for the current `app` and
recursively generates the child nodes and child trees if possible.
This method may be overriden by passing a `.tree` function on options.
@param {Object} `app` Current application to build a node and tree from.
@param {... | [
"Default",
"tree",
"building",
"function",
".",
"Gets",
"the",
"label",
"and",
"metadata",
"properties",
"for",
"the",
"current",
"app",
"and",
"recursively",
"generates",
"the",
"child",
"nodes",
"and",
"child",
"trees",
"if",
"possible",
"."
] | 32f9fd3015460512a5f4013990048827329146ee | https://github.com/doowb/base-tree/blob/32f9fd3015460512a5f4013990048827329146ee/index.js#L78-L112 | train |
doowb/base-tree | index.js | getLabel | function getLabel(app, options) {
if (typeof options.getLabel === 'function') {
return options.getLabel(app, options);
}
return app.full_name || app.nickname || app.name;
} | javascript | function getLabel(app, options) {
if (typeof options.getLabel === 'function') {
return options.getLabel(app, options);
}
return app.full_name || app.nickname || app.name;
} | [
"function",
"getLabel",
"(",
"app",
",",
"options",
")",
"{",
"if",
"(",
"typeof",
"options",
".",
"getLabel",
"===",
"'function'",
")",
"{",
"return",
"options",
".",
"getLabel",
"(",
"app",
",",
"options",
")",
";",
"}",
"return",
"app",
".",
"full_n... | Figure out a label to add for a node in the tree.
@param {Object} `app` Current node/app being iterated over
@param {Object} `options` Pass `getLabel` on options to handle yourself.
@return {String} label to be shown
@api public
@name options.getLabel | [
"Figure",
"out",
"a",
"label",
"to",
"add",
"for",
"a",
"node",
"in",
"the",
"tree",
"."
] | 32f9fd3015460512a5f4013990048827329146ee | https://github.com/doowb/base-tree/blob/32f9fd3015460512a5f4013990048827329146ee/index.js#L124-L129 | train |
homerjam/angular-modal-service2 | angular-modal-service2.js | function(template, templateUrl) {
var deferred = $q.defer();
if (template) {
deferred.resolve(template);
} else if (templateUrl) {
// Check to see if the template has already been loaded.
var cachedTemplate = $templateCache.get(templateUrl);
... | javascript | function(template, templateUrl) {
var deferred = $q.defer();
if (template) {
deferred.resolve(template);
} else if (templateUrl) {
// Check to see if the template has already been loaded.
var cachedTemplate = $templateCache.get(templateUrl);
... | [
"function",
"(",
"template",
",",
"templateUrl",
")",
"{",
"var",
"deferred",
"=",
"$q",
".",
"defer",
"(",
")",
";",
"if",
"(",
"template",
")",
"{",
"deferred",
".",
"resolve",
"(",
"template",
")",
";",
"}",
"else",
"if",
"(",
"templateUrl",
")",
... | Returns a promise which gets the template, either from the template parameter or via a request to the templateUrl parameter. | [
"Returns",
"a",
"promise",
"which",
"gets",
"the",
"template",
"either",
"from",
"the",
"template",
"parameter",
"or",
"via",
"a",
"request",
"to",
"the",
"templateUrl",
"parameter",
"."
] | 9d8fc0f590cdea198a214a1a7bf088f3abfc3a99 | https://github.com/homerjam/angular-modal-service2/blob/9d8fc0f590cdea198a214a1a7bf088f3abfc3a99/angular-modal-service2.js#L20-L52 | train | |
johnwebbcole/gulp-openjscad-standalone | docs/openjscad.js | function(e) {
this.touch.cur = 'dragging';
var delta = 0;
if (this.touch.lastY && (e.gesture.direction == 'up' || e.gesture.direction == 'down')) {
//tilt
delta = e.gesture.deltaY - this.touch.lastY;
this.angleX += delta;
} else if (this.touch.lastX && (e.gesture.direction == 'left' ||... | javascript | function(e) {
this.touch.cur = 'dragging';
var delta = 0;
if (this.touch.lastY && (e.gesture.direction == 'up' || e.gesture.direction == 'down')) {
//tilt
delta = e.gesture.deltaY - this.touch.lastY;
this.angleX += delta;
} else if (this.touch.lastX && (e.gesture.direction == 'left' ||... | [
"function",
"(",
"e",
")",
"{",
"this",
".",
"touch",
".",
"cur",
"=",
"'dragging'",
";",
"var",
"delta",
"=",
"0",
";",
"if",
"(",
"this",
".",
"touch",
".",
"lastY",
"&&",
"(",
"e",
".",
"gesture",
".",
"direction",
"==",
"'up'",
"||",
"e",
"... | pan & tilt with one finger | [
"pan",
"&",
"tilt",
"with",
"one",
"finger"
] | 0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c | https://github.com/johnwebbcole/gulp-openjscad-standalone/blob/0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c/docs/openjscad.js#L421-L437 | train | |
johnwebbcole/gulp-openjscad-standalone | docs/openjscad.js | function(e) {
this.touch.cur = 'shifting';
var factor = 5e-3;
var delta = 0;
if (this.touch.lastY && (e.gesture.direction == 'up' || e.gesture.direction == 'down')) {
this.touch.shiftControl
.removeClass('shift-horizontal')
.addClass('shift-vertical')
.css('top', e.g... | javascript | function(e) {
this.touch.cur = 'shifting';
var factor = 5e-3;
var delta = 0;
if (this.touch.lastY && (e.gesture.direction == 'up' || e.gesture.direction == 'down')) {
this.touch.shiftControl
.removeClass('shift-horizontal')
.addClass('shift-vertical')
.css('top', e.g... | [
"function",
"(",
"e",
")",
"{",
"this",
".",
"touch",
".",
"cur",
"=",
"'shifting'",
";",
"var",
"factor",
"=",
"5e-3",
";",
"var",
"delta",
"=",
"0",
";",
"if",
"(",
"this",
".",
"touch",
".",
"lastY",
"&&",
"(",
"e",
".",
"gesture",
".",
"dir... | shift after 0.5s touch&hold | [
"shift",
"after",
"0",
".",
"5s",
"touch&hold"
] | 0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c | https://github.com/johnwebbcole/gulp-openjscad-standalone/blob/0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c/docs/openjscad.js#L440-L467 | train | |
johnwebbcole/gulp-openjscad-standalone | docs/openjscad.js | function(initial_csg) {
var csg = initial_csg.canonicalized();
var mesh = new GL.Mesh({ normals: true, colors: true });
var meshes = [ mesh ];
var vertexTag2Index = {};
var vertices = [];
var colors = [];
var triangles = [];
// set to true if we want to use interpolated vertex normals
... | javascript | function(initial_csg) {
var csg = initial_csg.canonicalized();
var mesh = new GL.Mesh({ normals: true, colors: true });
var meshes = [ mesh ];
var vertexTag2Index = {};
var vertices = [];
var colors = [];
var triangles = [];
// set to true if we want to use interpolated vertex normals
... | [
"function",
"(",
"initial_csg",
")",
"{",
"var",
"csg",
"=",
"initial_csg",
".",
"canonicalized",
"(",
")",
";",
"var",
"mesh",
"=",
"new",
"GL",
".",
"Mesh",
"(",
"{",
"normals",
":",
"true",
",",
"colors",
":",
"true",
"}",
")",
";",
"var",
"mesh... | Convert from CSG solid to an array of GL.Mesh objects limiting the number of vertices per mesh to less than 2^16 | [
"Convert",
"from",
"CSG",
"solid",
"to",
"an",
"array",
"of",
"GL",
".",
"Mesh",
"objects",
"limiting",
"the",
"number",
"of",
"vertices",
"per",
"mesh",
"to",
"less",
"than",
"2^16"
] | 0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c | https://github.com/johnwebbcole/gulp-openjscad-standalone/blob/0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c/docs/openjscad.js#L581-L661 | train | |
johnwebbcole/gulp-openjscad-standalone | docs/openjscad.js | function(err, objs) {
that.worker = null;
if(err) {
that.setError(err);
that.setStatus("Error.");
that.state = 3; // incomplete
} else {
that.setCurrentObjects(objs);
that.setStatus("Ready.");
that.state = 2; // complete
}
... | javascript | function(err, objs) {
that.worker = null;
if(err) {
that.setError(err);
that.setStatus("Error.");
that.state = 3; // incomplete
} else {
that.setCurrentObjects(objs);
that.setStatus("Ready.");
that.state = 2; // complete
}
... | [
"function",
"(",
"err",
",",
"objs",
")",
"{",
"that",
".",
"worker",
"=",
"null",
";",
"if",
"(",
"err",
")",
"{",
"that",
".",
"setError",
"(",
"err",
")",
";",
"that",
".",
"setStatus",
"(",
"\"Error.\"",
")",
";",
"that",
".",
"state",
"=",
... | handle the results | [
"handle",
"the",
"results"
] | 0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c | https://github.com/johnwebbcole/gulp-openjscad-standalone/blob/0727d09fc2b6b20a0e7dac4d2bb44e706c1b442c/docs/openjscad.js#L1306-L1318 | train | |
catbee/appstate | src/appstate.js | runBranch | function runBranch (index, options) {
var { tree, signal, start, promise } = options;
var currentBranch = tree.branches[index];
if (!currentBranch && tree.branches === signal.branches) {
if (tree.branches[index - 1]) {
tree.branches[index - 1].duration = Date.now() - start;
}
signal.isExecutin... | javascript | function runBranch (index, options) {
var { tree, signal, start, promise } = options;
var currentBranch = tree.branches[index];
if (!currentBranch && tree.branches === signal.branches) {
if (tree.branches[index - 1]) {
tree.branches[index - 1].duration = Date.now() - start;
}
signal.isExecutin... | [
"function",
"runBranch",
"(",
"index",
",",
"options",
")",
"{",
"var",
"{",
"tree",
",",
"signal",
",",
"start",
",",
"promise",
"}",
"=",
"options",
";",
"var",
"currentBranch",
"=",
"tree",
".",
"branches",
"[",
"index",
"]",
";",
"if",
"(",
"!",
... | Run tree branch, or resolve signal
if no more branches in recursion.
@param {Number} index
@param {Object} options
@param {Object} options.tree
@param {Object} options.args
@param {Object} options.signal
@param {Object} options.promise
@param {Date} options.start
@param {Baobab} options.state
@param {Object} options.... | [
"Run",
"tree",
"branch",
"or",
"resolve",
"signal",
"if",
"no",
"more",
"branches",
"in",
"recursion",
"."
] | 44c404f18e6c2716452567d91a5231a53d67e892 | https://github.com/catbee/appstate/blob/44c404f18e6c2716452567d91a5231a53d67e892/src/appstate.js#L72-L99 | train |
catbee/appstate | src/appstate.js | runAsyncBranch | function runAsyncBranch (index, currentBranch, options) {
var { tree, args, signal, state, promise, start, services } = options;
var promises = currentBranch
.map(action => {
var actionFunc = tree.actions[action.actionIndex];
var actionArgs = createActionArgs(args, action, state, true);
var o... | javascript | function runAsyncBranch (index, currentBranch, options) {
var { tree, args, signal, state, promise, start, services } = options;
var promises = currentBranch
.map(action => {
var actionFunc = tree.actions[action.actionIndex];
var actionArgs = createActionArgs(args, action, state, true);
var o... | [
"function",
"runAsyncBranch",
"(",
"index",
",",
"currentBranch",
",",
"options",
")",
"{",
"var",
"{",
"tree",
",",
"args",
",",
"signal",
",",
"state",
",",
"promise",
",",
"start",
",",
"services",
"}",
"=",
"options",
";",
"var",
"promises",
"=",
"... | Run async branch
@param {Number} index
@param {Object} currentBranch
@param {Object} options
@param {Object} options.tree
@param {Object} options.args
@param {Object} options.signal
@param {Object} options.promise
@param {Date} options.start
@param {Baobab} options.state
@param {Object} options.services
@returns {Pro... | [
"Run",
"async",
"branch"
] | 44c404f18e6c2716452567d91a5231a53d67e892 | https://github.com/catbee/appstate/blob/44c404f18e6c2716452567d91a5231a53d67e892/src/appstate.js#L115-L172 | train |
catbee/appstate | src/appstate.js | runSyncBranch | function runSyncBranch (index, currentBranch, options) {
var { args, tree, signal, state, start, promise, services } = options;
try {
var action = currentBranch;
var actionFunc = tree.actions[action.actionIndex];
var actionArgs = createActionArgs(args, action, state, false);
var outputs = action.ou... | javascript | function runSyncBranch (index, currentBranch, options) {
var { args, tree, signal, state, start, promise, services } = options;
try {
var action = currentBranch;
var actionFunc = tree.actions[action.actionIndex];
var actionArgs = createActionArgs(args, action, state, false);
var outputs = action.ou... | [
"function",
"runSyncBranch",
"(",
"index",
",",
"currentBranch",
",",
"options",
")",
"{",
"var",
"{",
"args",
",",
"tree",
",",
"signal",
",",
"state",
",",
"start",
",",
"promise",
",",
"services",
"}",
"=",
"options",
";",
"try",
"{",
"var",
"action... | Run sync branch
@param {Number} index
@param {Object} currentBranch
@param {Object} options
@param {Object} options.tree
@param {Object} options.args
@param {Object} options.signal
@param {Object} options.promise
@param {Date} options.start
@param {Baobab} options.state
@param {Object} options.services
@returns {Prom... | [
"Run",
"sync",
"branch"
] | 44c404f18e6c2716452567d91a5231a53d67e892 | https://github.com/catbee/appstate/blob/44c404f18e6c2716452567d91a5231a53d67e892/src/appstate.js#L188-L234 | train |
catbee/appstate | src/appstate.js | addOutputs | function addOutputs (next, outputs) {
if (Array.isArray(outputs)) {
outputs.forEach(key => {
next[key] = next.bind(null, key);
});
}
return next;
} | javascript | function addOutputs (next, outputs) {
if (Array.isArray(outputs)) {
outputs.forEach(key => {
next[key] = next.bind(null, key);
});
}
return next;
} | [
"function",
"addOutputs",
"(",
"next",
",",
"outputs",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"outputs",
")",
")",
"{",
"outputs",
".",
"forEach",
"(",
"key",
"=>",
"{",
"next",
"[",
"key",
"]",
"=",
"next",
".",
"bind",
"(",
"null",
... | Add output paths to next function.
Outputs takes from branches tree object.
@example:
var actions = [
syncAction,
[
asyncAction,
{
custom1: [custom1SyncAction],
custom2: [custom2SyncAction]
}
]
];
function asyncAction ({}, state, output) {
if ( ... ) {
output.custom1();
} else {
output.custom2();
}
}
@param {Functio... | [
"Add",
"output",
"paths",
"to",
"next",
"function",
"."
] | 44c404f18e6c2716452567d91a5231a53d67e892 | https://github.com/catbee/appstate/blob/44c404f18e6c2716452567d91a5231a53d67e892/src/appstate.js#L264-L272 | train |
catbee/appstate | src/appstate.js | createNextFunction | function createNextFunction (action, resolver) {
return function next (...args) {
var path = typeof args[0] === 'string' ? args[0] : null;
var arg = path ? args[1] : args[0];
var result = {
path: path ? path : action.defaultOutput,
args: arg
};
if (resolver) {
resolver(result);... | javascript | function createNextFunction (action, resolver) {
return function next (...args) {
var path = typeof args[0] === 'string' ? args[0] : null;
var arg = path ? args[1] : args[0];
var result = {
path: path ? path : action.defaultOutput,
args: arg
};
if (resolver) {
resolver(result);... | [
"function",
"createNextFunction",
"(",
"action",
",",
"resolver",
")",
"{",
"return",
"function",
"next",
"(",
"...",
"args",
")",
"{",
"var",
"path",
"=",
"typeof",
"args",
"[",
"0",
"]",
"===",
"'string'",
"?",
"args",
"[",
"0",
"]",
":",
"null",
"... | Create next function in signal chain.
It's unified method for async and sync actions.
@param {Function} action
@param {Function} [resolver]
@returns {Function} | [
"Create",
"next",
"function",
"in",
"signal",
"chain",
".",
"It",
"s",
"unified",
"method",
"for",
"async",
"and",
"sync",
"actions",
"."
] | 44c404f18e6c2716452567d91a5231a53d67e892 | https://github.com/catbee/appstate/blob/44c404f18e6c2716452567d91a5231a53d67e892/src/appstate.js#L281-L297 | train |
catbee/appstate | src/appstate.js | getStateMutatorsAndAccessors | function getStateMutatorsAndAccessors (state, action, isAsync) {
var mutators = [
'apply',
'concat',
'deepMerge',
'push',
'merge',
'unset',
'set',
'splice',
'unshift'
];
var accessors = [
'get',
'exists'
];
var methods = [];
if (isAsync) {
methods = methods... | javascript | function getStateMutatorsAndAccessors (state, action, isAsync) {
var mutators = [
'apply',
'concat',
'deepMerge',
'push',
'merge',
'unset',
'set',
'splice',
'unshift'
];
var accessors = [
'get',
'exists'
];
var methods = [];
if (isAsync) {
methods = methods... | [
"function",
"getStateMutatorsAndAccessors",
"(",
"state",
",",
"action",
",",
"isAsync",
")",
"{",
"var",
"mutators",
"=",
"[",
"'apply'",
",",
"'concat'",
",",
"'deepMerge'",
",",
"'push'",
",",
"'merge'",
",",
"'unset'",
",",
"'set'",
",",
"'splice'",
",",... | Get state mutators and accessors
Each mutation will save in action descriptor.
This method allow add ability
to gather information about call every function.
@param {Object} state
@param {Object} action
@param {Boolean} isAsync
@return {Object} | [
"Get",
"state",
"mutators",
"and",
"accessors",
"Each",
"mutation",
"will",
"save",
"in",
"action",
"descriptor",
".",
"This",
"method",
"allow",
"add",
"ability",
"to",
"gather",
"information",
"about",
"call",
"every",
"function",
"."
] | 44c404f18e6c2716452567d91a5231a53d67e892 | https://github.com/catbee/appstate/blob/44c404f18e6c2716452567d91a5231a53d67e892/src/appstate.js#L352-L407 | train |
catbee/appstate | src/appstate.js | staticTree | function staticTree (signalActions) {
var actions = [];
var branches = transformBranch(signalActions, [], [], actions, false);
return { actions, branches };
} | javascript | function staticTree (signalActions) {
var actions = [];
var branches = transformBranch(signalActions, [], [], actions, false);
return { actions, branches };
} | [
"function",
"staticTree",
"(",
"signalActions",
")",
"{",
"var",
"actions",
"=",
"[",
"]",
";",
"var",
"branches",
"=",
"transformBranch",
"(",
"signalActions",
",",
"[",
"]",
",",
"[",
"]",
",",
"actions",
",",
"false",
")",
";",
"return",
"{",
"actio... | Transform signal actions to static tree.
Every function will be exposed as object definition,
that will store meta information and function call results.
@param {Array} signalActions
@returns {{ actions: [], branches: [] }} | [
"Transform",
"signal",
"actions",
"to",
"static",
"tree",
".",
"Every",
"function",
"will",
"be",
"exposed",
"as",
"object",
"definition",
"that",
"will",
"store",
"meta",
"information",
"and",
"function",
"call",
"results",
"."
] | 44c404f18e6c2716452567d91a5231a53d67e892 | https://github.com/catbee/appstate/blob/44c404f18e6c2716452567d91a5231a53d67e892/src/appstate.js#L416-L420 | train |
catbee/appstate | src/appstate.js | transformBranch | function transformBranch (action, ...args) {
return Array.isArray(action) ?
transformAsyncBranch.apply(null, [action, ...args]) :
transformSyncBranch.apply(null, [action, ...args]);
} | javascript | function transformBranch (action, ...args) {
return Array.isArray(action) ?
transformAsyncBranch.apply(null, [action, ...args]) :
transformSyncBranch.apply(null, [action, ...args]);
} | [
"function",
"transformBranch",
"(",
"action",
",",
"...",
"args",
")",
"{",
"return",
"Array",
".",
"isArray",
"(",
"action",
")",
"?",
"transformAsyncBranch",
".",
"apply",
"(",
"null",
",",
"[",
"action",
",",
"...",
"args",
"]",
")",
":",
"transformSy... | Transform tree branch
@param {Function} action
@param {Array} args
@param {Array|Function} args.parentAction
@param {Array} args.path
@param {Array} args.actions
@param {Boolean} args.isSync
@return {Object} | [
"Transform",
"tree",
"branch"
] | 44c404f18e6c2716452567d91a5231a53d67e892 | https://github.com/catbee/appstate/blob/44c404f18e6c2716452567d91a5231a53d67e892/src/appstate.js#L432-L436 | train |
catbee/appstate | src/appstate.js | transformAsyncBranch | function transformAsyncBranch (action, parentAction, path, actions, isSync) {
action = action.slice();
isSync = !isSync;
return action
.map((subAction, index) => {
path.push(index);
var result = transformBranch(subAction, action, path, actions, isSync);
path.pop();
return result;
}... | javascript | function transformAsyncBranch (action, parentAction, path, actions, isSync) {
action = action.slice();
isSync = !isSync;
return action
.map((subAction, index) => {
path.push(index);
var result = transformBranch(subAction, action, path, actions, isSync);
path.pop();
return result;
}... | [
"function",
"transformAsyncBranch",
"(",
"action",
",",
"parentAction",
",",
"path",
",",
"actions",
",",
"isSync",
")",
"{",
"action",
"=",
"action",
".",
"slice",
"(",
")",
";",
"isSync",
"=",
"!",
"isSync",
";",
"return",
"action",
".",
"map",
"(",
... | Transform action to async branch
@param {Function} action
@param {Array|Function} parentAction
@param {Array} path
@param {Array} actions
@param {Boolean} isSync
@returns {*} | [
"Transform",
"action",
"to",
"async",
"branch"
] | 44c404f18e6c2716452567d91a5231a53d67e892 | https://github.com/catbee/appstate/blob/44c404f18e6c2716452567d91a5231a53d67e892/src/appstate.js#L447-L458 | train |
catbee/appstate | src/appstate.js | transformSyncBranch | function transformSyncBranch (action, parentAction, path, actions, isSync) {
var branch = {
name: getFunctionName(action),
args: {},
output: null,
duration: 0,
mutations: [],
isAsync: !isSync,
outputPath: null,
isExecuting: false,
hasExecuted: false,
path: path.slice(),
out... | javascript | function transformSyncBranch (action, parentAction, path, actions, isSync) {
var branch = {
name: getFunctionName(action),
args: {},
output: null,
duration: 0,
mutations: [],
isAsync: !isSync,
outputPath: null,
isExecuting: false,
hasExecuted: false,
path: path.slice(),
out... | [
"function",
"transformSyncBranch",
"(",
"action",
",",
"parentAction",
",",
"path",
",",
"actions",
",",
"isSync",
")",
"{",
"var",
"branch",
"=",
"{",
"name",
":",
"getFunctionName",
"(",
"action",
")",
",",
"args",
":",
"{",
"}",
",",
"output",
":",
... | Transform action to sync branch
@param {Function} action
@param {Array|Function} parentAction
@param {Array} path
@param {Array} actions
@param {Boolean} isSync
@returns {{
name: *, args: {}, output: null, duration: number,
mutations: Array, isAsync: boolean, outputPath: null,
isExecuting: boolean, hasExecuted: boolean... | [
"Transform",
"action",
"to",
"sync",
"branch"
] | 44c404f18e6c2716452567d91a5231a53d67e892 | https://github.com/catbee/appstate/blob/44c404f18e6c2716452567d91a5231a53d67e892/src/appstate.js#L474-L505 | train |
catbee/appstate | src/appstate.js | analyze | function analyze (actions) {
if (!Array.isArray(actions)) {
throw new Error('State: Signal actions should be array');
}
actions.forEach((action, index) => {
if (typeof action === 'undefined' || typeof action === 'string') {
throw new Error(
`
State: Action number "${index}" in s... | javascript | function analyze (actions) {
if (!Array.isArray(actions)) {
throw new Error('State: Signal actions should be array');
}
actions.forEach((action, index) => {
if (typeof action === 'undefined' || typeof action === 'string') {
throw new Error(
`
State: Action number "${index}" in s... | [
"function",
"analyze",
"(",
"actions",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"actions",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'State: Signal actions should be array'",
")",
";",
"}",
"actions",
".",
"forEach",
"(",
"(",
"action",
... | Analyze actions for errors
@param {Array} actions | [
"Analyze",
"actions",
"for",
"errors"
] | 44c404f18e6c2716452567d91a5231a53d67e892 | https://github.com/catbee/appstate/blob/44c404f18e6c2716452567d91a5231a53d67e892/src/appstate.js#L511-L534 | train |
catbee/appstate | src/appstate.js | getFunctionName | function getFunctionName (fn) {
var name = fn.toString();
name = name.substr('function '.length);
name = name.substr(0, name.indexOf('('));
return name;
} | javascript | function getFunctionName (fn) {
var name = fn.toString();
name = name.substr('function '.length);
name = name.substr(0, name.indexOf('('));
return name;
} | [
"function",
"getFunctionName",
"(",
"fn",
")",
"{",
"var",
"name",
"=",
"fn",
".",
"toString",
"(",
")",
";",
"name",
"=",
"name",
".",
"substr",
"(",
"'function '",
".",
"length",
")",
";",
"name",
"=",
"name",
".",
"substr",
"(",
"0",
",",
"name"... | Get function name
@param {Function} fn
@returns {String} | [
"Get",
"function",
"name"
] | 44c404f18e6c2716452567d91a5231a53d67e892 | https://github.com/catbee/appstate/blob/44c404f18e6c2716452567d91a5231a53d67e892/src/appstate.js#L554-L559 | train |
porkchop/leetcoin-js | lib/leetcoin.js | Player | function Player(params) {
this.platformID = this.key = params.key;
this.kills = params.kills;
this.deaths = params.deaths;
this.name = params.name;
this.rank = params.rank;
this.weapon = params.weapon;
} | javascript | function Player(params) {
this.platformID = this.key = params.key;
this.kills = params.kills;
this.deaths = params.deaths;
this.name = params.name;
this.rank = params.rank;
this.weapon = params.weapon;
} | [
"function",
"Player",
"(",
"params",
")",
"{",
"this",
".",
"platformID",
"=",
"this",
".",
"key",
"=",
"params",
".",
"key",
";",
"this",
".",
"kills",
"=",
"params",
".",
"kills",
";",
"this",
".",
"deaths",
"=",
"params",
".",
"deaths",
";",
"th... | a leetcoin player | [
"a",
"leetcoin",
"player"
] | 86e086dbd90753cdd4bb8d56f79aa7d04228c30a | https://github.com/porkchop/leetcoin-js/blob/86e086dbd90753cdd4bb8d56f79aa7d04228c30a/lib/leetcoin.js#L37-L44 | train |
posttool/currentcms | lib/cms.js | Cms | function Cms(module, with_app) {
if (!module)
throw new Error('Requires a module');
if (!module.config)
throw new Error('Module requires config');
if (!module.config.name)
logger.info('No name specified in config. Calling it null.')
if (!module.config.mongoConnectString)
throw new Error('Config ... | javascript | function Cms(module, with_app) {
if (!module)
throw new Error('Requires a module');
if (!module.config)
throw new Error('Module requires config');
if (!module.config.name)
logger.info('No name specified in config. Calling it null.')
if (!module.config.mongoConnectString)
throw new Error('Config ... | [
"function",
"Cms",
"(",
"module",
",",
"with_app",
")",
"{",
"if",
"(",
"!",
"module",
")",
"throw",
"new",
"Error",
"(",
"'Requires a module'",
")",
";",
"if",
"(",
"!",
"module",
".",
"config",
")",
"throw",
"new",
"Error",
"(",
"'Module requires confi... | Construct the Cms with a module. Cms ready modules must export at least `models` and `config`.
@constructor | [
"Construct",
"the",
"Cms",
"with",
"a",
"module",
".",
"Cms",
"ready",
"modules",
"must",
"export",
"at",
"least",
"models",
"and",
"config",
"."
] | 9afc9f907bad3b018d961af66c3abb33cd82b051 | https://github.com/posttool/currentcms/blob/9afc9f907bad3b018d961af66c3abb33cd82b051/lib/cms.js#L31-L65 | train |
activethread/vulpejs | lib/mongoose/paginate.js | handlePromise | function handlePromise(query, q, model, resultsPerPage) {
return Promise.all([
query.exec(),
model.count(q).exec()
]).spread(function(results, count) {
return [
results,
Math.ceil(count / resultsPerPage) || 1,
count
]
});
} | javascript | function handlePromise(query, q, model, resultsPerPage) {
return Promise.all([
query.exec(),
model.count(q).exec()
]).spread(function(results, count) {
return [
results,
Math.ceil(count / resultsPerPage) || 1,
count
]
});
} | [
"function",
"handlePromise",
"(",
"query",
",",
"q",
",",
"model",
",",
"resultsPerPage",
")",
"{",
"return",
"Promise",
".",
"all",
"(",
"[",
"query",
".",
"exec",
"(",
")",
",",
"model",
".",
"count",
"(",
"q",
")",
".",
"exec",
"(",
")",
"]",
... | Return a promise with results
@method handlePromise
@param {Object} query - mongoose query object
@param {Object} q - query
@param {Object} model - mongoose model
@param {Number} resultsPerPage
@returns {Promise} | [
"Return",
"a",
"promise",
"with",
"results"
] | cba9529ebb13892b2c7d07219c7fa69137151fbd | https://github.com/activethread/vulpejs/blob/cba9529ebb13892b2c7d07219c7fa69137151fbd/lib/mongoose/paginate.js#L67-L78 | train |
activethread/vulpejs | lib/mongoose/paginate.js | handleCallback | function handleCallback(query, q, model, resultsPerPage, callback) {
return async.parallel({
results: function(callback) {
query.exec(callback);
},
count: function(callback) {
model.count(q, function(err, count) {
callback(err, count);
});
}
}, function(error, data) {
i... | javascript | function handleCallback(query, q, model, resultsPerPage, callback) {
return async.parallel({
results: function(callback) {
query.exec(callback);
},
count: function(callback) {
model.count(q, function(err, count) {
callback(err, count);
});
}
}, function(error, data) {
i... | [
"function",
"handleCallback",
"(",
"query",
",",
"q",
",",
"model",
",",
"resultsPerPage",
",",
"callback",
")",
"{",
"return",
"async",
".",
"parallel",
"(",
"{",
"results",
":",
"function",
"(",
"callback",
")",
"{",
"query",
".",
"exec",
"(",
"callbac... | Call callback function passed with results
@method handleCallback
@param {Object} query - mongoose query object
@param {Object} q - query
@param {Object} model - mongoose model
@param {Number} resultsPerPage
@param {Function} callback
@returns {void} | [
"Call",
"callback",
"function",
"passed",
"with",
"results"
] | cba9529ebb13892b2c7d07219c7fa69137151fbd | https://github.com/activethread/vulpejs/blob/cba9529ebb13892b2c7d07219c7fa69137151fbd/lib/mongoose/paginate.js#L92-L108 | train |
wesleytodd/foreach-in-dir | index.js | foreachInDir | function foreachInDir (dirpath, fnc, done) {
// Read the files
fs.readdir(dirpath, function (err, files) {
// Return error
if (err) {
return done(err);
}
// Process each file
parallel(files.map(function (f) {
return fnc.bind(null, f);
}), done);
});
} | javascript | function foreachInDir (dirpath, fnc, done) {
// Read the files
fs.readdir(dirpath, function (err, files) {
// Return error
if (err) {
return done(err);
}
// Process each file
parallel(files.map(function (f) {
return fnc.bind(null, f);
}), done);
});
} | [
"function",
"foreachInDir",
"(",
"dirpath",
",",
"fnc",
",",
"done",
")",
"{",
"// Read the files",
"fs",
".",
"readdir",
"(",
"dirpath",
",",
"function",
"(",
"err",
",",
"files",
")",
"{",
"// Return error",
"if",
"(",
"err",
")",
"{",
"return",
"done"... | Execute a callback for each file in a directory | [
"Execute",
"a",
"callback",
"for",
"each",
"file",
"in",
"a",
"directory"
] | 1215c889d45681804c8d31a13721bad242655002 | https://github.com/wesleytodd/foreach-in-dir/blob/1215c889d45681804c8d31a13721bad242655002/index.js#L12-L25 | train |
melvincarvalho/rdf-shell | rdf.js | rdf | function rdf(argv, callback) {
var command = argv[2];
var exec;
if (!command) {
console.log('rdf help for command list');
process.exit(-1);
}
try {
exec = require('./bin/' + command + '.js');
} catch (err) {
console.error(command + ': command not found');
process.exit(-1);
}
argv.... | javascript | function rdf(argv, callback) {
var command = argv[2];
var exec;
if (!command) {
console.log('rdf help for command list');
process.exit(-1);
}
try {
exec = require('./bin/' + command + '.js');
} catch (err) {
console.error(command + ': command not found');
process.exit(-1);
}
argv.... | [
"function",
"rdf",
"(",
"argv",
",",
"callback",
")",
"{",
"var",
"command",
"=",
"argv",
"[",
"2",
"]",
";",
"var",
"exec",
";",
"if",
"(",
"!",
"command",
")",
"{",
"console",
".",
"log",
"(",
"'rdf help for command list'",
")",
";",
"process",
"."... | rdf calls child script
@param {string} argv[2] command
@callback {bin~cb} callback | [
"rdf",
"calls",
"child",
"script"
] | bf2015f6f333855e69a18ce3ec9e917bbddfb425 | https://github.com/melvincarvalho/rdf-shell/blob/bf2015f6f333855e69a18ce3ec9e917bbddfb425/rdf.js#L9-L29 | train |
melvincarvalho/rdf-shell | rdf.js | bin | function bin() {
rdf(process.argv, function(err, res) {
if (Array.isArray(res)) {
for (var i=0; i<res.length; i++) {
console.log(res[i]);
}
} else {
console.log(res);
}
});
} | javascript | function bin() {
rdf(process.argv, function(err, res) {
if (Array.isArray(res)) {
for (var i=0; i<res.length; i++) {
console.log(res[i]);
}
} else {
console.log(res);
}
});
} | [
"function",
"bin",
"(",
")",
"{",
"rdf",
"(",
"process",
".",
"argv",
",",
"function",
"(",
"err",
",",
"res",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"res",
")",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"res",
... | rdf as a command | [
"rdf",
"as",
"a",
"command"
] | bf2015f6f333855e69a18ce3ec9e917bbddfb425 | https://github.com/melvincarvalho/rdf-shell/blob/bf2015f6f333855e69a18ce3ec9e917bbddfb425/rdf.js#L35-L45 | train |
mwaylabs/update-manager | update-manager.js | update | function update(options) {
var reqOpt = {
host: url.parse(options.updateVersionURL).host,
uri: url.parse(options.updateVersionURL),
path: url.parse(options.updateVersionURL).pathname,
port: options.port
};
options.error = options.error || function () {
};
options.su... | javascript | function update(options) {
var reqOpt = {
host: url.parse(options.updateVersionURL).host,
uri: url.parse(options.updateVersionURL),
path: url.parse(options.updateVersionURL).pathname,
port: options.port
};
options.error = options.error || function () {
};
options.su... | [
"function",
"update",
"(",
"options",
")",
"{",
"var",
"reqOpt",
"=",
"{",
"host",
":",
"url",
".",
"parse",
"(",
"options",
".",
"updateVersionURL",
")",
".",
"host",
",",
"uri",
":",
"url",
".",
"parse",
"(",
"options",
".",
"updateVersionURL",
")",
... | parses the given URL and passes to handler
@param {options} contains URL to the remote version-file | [
"parses",
"the",
"given",
"URL",
"and",
"passes",
"to",
"handler"
] | 50aac6759f8697c7bd89611df3c8065a8493cdde | https://github.com/mwaylabs/update-manager/blob/50aac6759f8697c7bd89611df3c8065a8493cdde/update-manager.js#L17-L35 | train |
deepjs/deep-restful | lib/collection.js | function(start, end, query) {
//console.log("deep.store.Collection.range : ", start, end, query);
var res = null;
var total = 0;
query = query || "";
return deep.when(this.get(query))
.done(function(res) {
total = res.length;
if (typeof start === 'string')
start = parseInt(st... | javascript | function(start, end, query) {
//console.log("deep.store.Collection.range : ", start, end, query);
var res = null;
var total = 0;
query = query || "";
return deep.when(this.get(query))
.done(function(res) {
total = res.length;
if (typeof start === 'string')
start = parseInt(st... | [
"function",
"(",
"start",
",",
"end",
",",
"query",
")",
"{",
"//console.log(\"deep.store.Collection.range : \", start, end, query);",
"var",
"res",
"=",
"null",
";",
"var",
"total",
"=",
"0",
";",
"query",
"=",
"query",
"||",
"\"\"",
";",
"return",
"deep",
".... | select a range in collection
@method range
@param {Number} start
@param {Number} end
@return {deep.NodesChain} a chain that hold the selected range and has injected values as success object. | [
"select",
"a",
"range",
"in",
"collection"
] | 44c5e1e5526a821522ab5e3004f66ffc7840f551 | https://github.com/deepjs/deep-restful/blob/44c5e1e5526a821522ab5e3004f66ffc7840f551/lib/collection.js#L189-L207 | train | |
erktime/express-jslint-reporter | reporter.js | function (lintFile) {
var deferred = new Deferred();
parseJslintXml(lintFile, function (err, lintErrors) {
if (lintErrors) {
deferred.resolve(lintErrors);
} else {
if (err && err.code === 'ENOENT') {
console.warn('No jslint xml file found at:', lintFile);
} else if (err) {
... | javascript | function (lintFile) {
var deferred = new Deferred();
parseJslintXml(lintFile, function (err, lintErrors) {
if (lintErrors) {
deferred.resolve(lintErrors);
} else {
if (err && err.code === 'ENOENT') {
console.warn('No jslint xml file found at:', lintFile);
} else if (err) {
... | [
"function",
"(",
"lintFile",
")",
"{",
"var",
"deferred",
"=",
"new",
"Deferred",
"(",
")",
";",
"parseJslintXml",
"(",
"lintFile",
",",
"function",
"(",
"err",
",",
"lintErrors",
")",
"{",
"if",
"(",
"lintErrors",
")",
"{",
"deferred",
".",
"resolve",
... | Get the lint errors from an jslint xml file.o
@param {String} lintFile The path of the jslint xml file.
@return {Deferred} A promise object. It will resolve only if there are jslint errors found. | [
"Get",
"the",
"lint",
"errors",
"from",
"an",
"jslint",
"xml",
"file",
".",
"o"
] | eaafd8c095655db57ef6bc2a5edbc860cafb1e35 | https://github.com/erktime/express-jslint-reporter/blob/eaafd8c095655db57ef6bc2a5edbc860cafb1e35/reporter.js#L41-L58 | train | |
erktime/express-jslint-reporter | reporter.js | function (lintFile, callback) {
fs.readFile(lintFile, function (err, data) {
if (err) {
callback(err);
} else {
var parser = new xml2js.Parser({
mergeAttrs: true
});
parser.parseString(data, function (err, result) {
if (err) {
callback(err);
} else if ... | javascript | function (lintFile, callback) {
fs.readFile(lintFile, function (err, data) {
if (err) {
callback(err);
} else {
var parser = new xml2js.Parser({
mergeAttrs: true
});
parser.parseString(data, function (err, result) {
if (err) {
callback(err);
} else if ... | [
"function",
"(",
"lintFile",
",",
"callback",
")",
"{",
"fs",
".",
"readFile",
"(",
"lintFile",
",",
"function",
"(",
"err",
",",
"data",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"}",
"else",
"{",
"var",
"parser",
"... | Parse a jslint xml report.
@param {String} lintFile The path of the jslint xml file.
@param {Function} callback The function to invoke when the file is read. The callback will
be called with the following params: callback(err, lintErrors). | [
"Parse",
"a",
"jslint",
"xml",
"report",
"."
] | eaafd8c095655db57ef6bc2a5edbc860cafb1e35 | https://github.com/erktime/express-jslint-reporter/blob/eaafd8c095655db57ef6bc2a5edbc860cafb1e35/reporter.js#L66-L85 | train | |
erktime/express-jslint-reporter | reporter.js | function (req, res, lintErrors) {
var html = template({
lintErrors: lintErrors
});
res.end(html);
} | javascript | function (req, res, lintErrors) {
var html = template({
lintErrors: lintErrors
});
res.end(html);
} | [
"function",
"(",
"req",
",",
"res",
",",
"lintErrors",
")",
"{",
"var",
"html",
"=",
"template",
"(",
"{",
"lintErrors",
":",
"lintErrors",
"}",
")",
";",
"res",
".",
"end",
"(",
"html",
")",
";",
"}"
] | Render the error report.
@param {Request} req The incoming request.
@param {Response} res The outgoing response.
@param {Array} lintErrors The jslint errors to render. | [
"Render",
"the",
"error",
"report",
"."
] | eaafd8c095655db57ef6bc2a5edbc860cafb1e35 | https://github.com/erktime/express-jslint-reporter/blob/eaafd8c095655db57ef6bc2a5edbc860cafb1e35/reporter.js#L93-L98 | train | |
RnbWd/parse-browserify | lib/promise.js | function(predicate, asyncFunction) {
if (predicate()) {
return asyncFunction().then(function() {
return Parse.Promise._continueWhile(predicate, asyncFunction);
});
}
return Parse.Promise.as();
} | javascript | function(predicate, asyncFunction) {
if (predicate()) {
return asyncFunction().then(function() {
return Parse.Promise._continueWhile(predicate, asyncFunction);
});
}
return Parse.Promise.as();
} | [
"function",
"(",
"predicate",
",",
"asyncFunction",
")",
"{",
"if",
"(",
"predicate",
"(",
")",
")",
"{",
"return",
"asyncFunction",
"(",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"Parse",
".",
"Promise",
".",
"_continueWhile",
"(",
"... | Runs the given asyncFunction repeatedly, as long as the predicate
function returns a truthy value. Stops repeating if asyncFunction returns
a rejected promise.
@param {Function} predicate should return false when ready to stop.
@param {Function} asyncFunction should return a Promise. | [
"Runs",
"the",
"given",
"asyncFunction",
"repeatedly",
"as",
"long",
"as",
"the",
"predicate",
"function",
"returns",
"a",
"truthy",
"value",
".",
"Stops",
"repeating",
"if",
"asyncFunction",
"returns",
"a",
"rejected",
"promise",
"."
] | c19c1b798e4010a552e130b1a9ce3b5d084dc101 | https://github.com/RnbWd/parse-browserify/blob/c19c1b798e4010a552e130b1a9ce3b5d084dc101/lib/promise.js#L144-L151 | train | |
RnbWd/parse-browserify | lib/promise.js | function(resolvedCallback, rejectedCallback) {
var promise = new Parse.Promise();
var wrappedResolvedCallback = function() {
var result = arguments;
if (resolvedCallback) {
result = [resolvedCallback.apply(this, result)];
}
if (result.length === 1 && Parse.Promise.... | javascript | function(resolvedCallback, rejectedCallback) {
var promise = new Parse.Promise();
var wrappedResolvedCallback = function() {
var result = arguments;
if (resolvedCallback) {
result = [resolvedCallback.apply(this, result)];
}
if (result.length === 1 && Parse.Promise.... | [
"function",
"(",
"resolvedCallback",
",",
"rejectedCallback",
")",
"{",
"var",
"promise",
"=",
"new",
"Parse",
".",
"Promise",
"(",
")",
";",
"var",
"wrappedResolvedCallback",
"=",
"function",
"(",
")",
"{",
"var",
"result",
"=",
"arguments",
";",
"if",
"(... | Adds callbacks to be called when this promise is fulfilled. Returns a new
Promise that will be fulfilled when the callback is complete. It allows
chaining. If the callback itself returns a Promise, then the one returned
by "then" will not be fulfilled until that one returned by the callback
is fulfilled.
@param {Functi... | [
"Adds",
"callbacks",
"to",
"be",
"called",
"when",
"this",
"promise",
"is",
"fulfilled",
".",
"Returns",
"a",
"new",
"Promise",
"that",
"will",
"be",
"fulfilled",
"when",
"the",
"callback",
"is",
"complete",
".",
"It",
"allows",
"chaining",
".",
"If",
"the... | c19c1b798e4010a552e130b1a9ce3b5d084dc101 | https://github.com/RnbWd/parse-browserify/blob/c19c1b798e4010a552e130b1a9ce3b5d084dc101/lib/promise.js#L212-L261 | train | |
RnbWd/parse-browserify | lib/promise.js | function(optionsOrCallback, model) {
var options;
if (_.isFunction(optionsOrCallback)) {
var callback = optionsOrCallback;
options = {
success: function(result) {
callback(result, null);
},
error: function(error) {
callback(null, error);
... | javascript | function(optionsOrCallback, model) {
var options;
if (_.isFunction(optionsOrCallback)) {
var callback = optionsOrCallback;
options = {
success: function(result) {
callback(result, null);
},
error: function(error) {
callback(null, error);
... | [
"function",
"(",
"optionsOrCallback",
",",
"model",
")",
"{",
"var",
"options",
";",
"if",
"(",
"_",
".",
"isFunction",
"(",
"optionsOrCallback",
")",
")",
"{",
"var",
"callback",
"=",
"optionsOrCallback",
";",
"options",
"=",
"{",
"success",
":",
"functio... | Run the given callbacks after this promise is fulfilled.
@param optionsOrCallback {} A Backbone-style options callback, or a
callback function. If this is an options object and contains a "model"
attributes, that will be passed to error callbacks as the first argument.
@param model {} If truthy, this will be passed as ... | [
"Run",
"the",
"given",
"callbacks",
"after",
"this",
"promise",
"is",
"fulfilled",
"."
] | c19c1b798e4010a552e130b1a9ce3b5d084dc101 | https://github.com/RnbWd/parse-browserify/blob/c19c1b798e4010a552e130b1a9ce3b5d084dc101/lib/promise.js#L295-L335 | train | |
mercmobily/simpledblayer-tingo | TingoMixin.js | function( s ){
if( s.match(/\./ ) ){
var l = s.split( /\./ );
for( var i = 0; i < l.length-1; i++ ){
l[ i ] = '_children.' + l[ i ];
}
return l.join( '.' );
} else {
return s;
}
} | javascript | function( s ){
if( s.match(/\./ ) ){
var l = s.split( /\./ );
for( var i = 0; i < l.length-1; i++ ){
l[ i ] = '_children.' + l[ i ];
}
return l.join( '.' );
} else {
return s;
}
} | [
"function",
"(",
"s",
")",
"{",
"if",
"(",
"s",
".",
"match",
"(",
"/",
"\\.",
"/",
")",
")",
"{",
"var",
"l",
"=",
"s",
".",
"split",
"(",
"/",
"\\.",
"/",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"l",
".",
"length",
... | If there are ".", then some children records are being referenced. The actual way they are placed in the record is in _children; so, add _children where needed. | [
"If",
"there",
"are",
".",
"then",
"some",
"children",
"records",
"are",
"being",
"referenced",
".",
"The",
"actual",
"way",
"they",
"are",
"placed",
"in",
"the",
"record",
"is",
"in",
"_children",
";",
"so",
"add",
"_children",
"where",
"needed",
"."
] | 1cd5ac89b0825343b6045ddd40ef45f138a86b0a | https://github.com/mercmobily/simpledblayer-tingo/blob/1cd5ac89b0825343b6045ddd40ef45f138a86b0a/TingoMixin.js#L97-L110 | train | |
mercmobily/simpledblayer-tingo | TingoMixin.js | function( filters, fieldPrefix, selectorWithoutBells ){
return {
querySelector: this._makeMongoConditions( filters.conditions || {}, fieldPrefix, selectorWithoutBells ),
sortHash: this._makeMongoSortHash( filters.sort || {}, fieldPrefix )
};
} | javascript | function( filters, fieldPrefix, selectorWithoutBells ){
return {
querySelector: this._makeMongoConditions( filters.conditions || {}, fieldPrefix, selectorWithoutBells ),
sortHash: this._makeMongoSortHash( filters.sort || {}, fieldPrefix )
};
} | [
"function",
"(",
"filters",
",",
"fieldPrefix",
",",
"selectorWithoutBells",
")",
"{",
"return",
"{",
"querySelector",
":",
"this",
".",
"_makeMongoConditions",
"(",
"filters",
".",
"conditions",
"||",
"{",
"}",
",",
"fieldPrefix",
",",
"selectorWithoutBells",
"... | Make parameters for queries. It's the equivalent of what would be an SQL creator for a SQL layer | [
"Make",
"parameters",
"for",
"queries",
".",
"It",
"s",
"the",
"equivalent",
"of",
"what",
"would",
"be",
"an",
"SQL",
"creator",
"for",
"a",
"SQL",
"layer"
] | 1cd5ac89b0825343b6045ddd40ef45f138a86b0a | https://github.com/mercmobily/simpledblayer-tingo/blob/1cd5ac89b0825343b6045ddd40ef45f138a86b0a/TingoMixin.js#L158-L163 | train | |
mercmobily/simpledblayer-tingo | TingoMixin.js | function( cb ){
if( ! self.positionField ){
cb( null );
} else {
// If repositioning is required, do it
if( self.positionField ){
var where, beforeId;
if( ! options.position ){
where = 'e... | javascript | function( cb ){
if( ! self.positionField ){
cb( null );
} else {
// If repositioning is required, do it
if( self.positionField ){
var where, beforeId;
if( ! options.position ){
where = 'e... | [
"function",
"(",
"cb",
")",
"{",
"if",
"(",
"!",
"self",
".",
"positionField",
")",
"{",
"cb",
"(",
"null",
")",
";",
"}",
"else",
"{",
"// If repositioning is required, do it",
"if",
"(",
"self",
".",
"positionField",
")",
"{",
"var",
"where",
",",
"b... | This will get called shortly. Bypasses straight to callback or calls reposition with right parameters and then calls callback | [
"This",
"will",
"get",
"called",
"shortly",
".",
"Bypasses",
"straight",
"to",
"callback",
"or",
"calls",
"reposition",
"with",
"right",
"parameters",
"and",
"then",
"calls",
"callback"
] | 1cd5ac89b0825343b6045ddd40ef45f138a86b0a | https://github.com/mercmobily/simpledblayer-tingo/blob/1cd5ac89b0825343b6045ddd40ef45f138a86b0a/TingoMixin.js#L904-L921 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/button/plugin.js | function( state ) {
if ( this._.state == state )
return false;
this._.state = state;
var element = CKEDITOR.document.getById( this._.id );
if ( element ) {
element.setState( state, 'cke_button' );
state == CKEDITOR.TRISTATE_DISABLED ?
element.setAttribute( 'aria-disabled', t... | javascript | function( state ) {
if ( this._.state == state )
return false;
this._.state = state;
var element = CKEDITOR.document.getById( this._.id );
if ( element ) {
element.setState( state, 'cke_button' );
state == CKEDITOR.TRISTATE_DISABLED ?
element.setAttribute( 'aria-disabled', t... | [
"function",
"(",
"state",
")",
"{",
"if",
"(",
"this",
".",
"_",
".",
"state",
"==",
"state",
")",
"return",
"false",
";",
"this",
".",
"_",
".",
"state",
"=",
"state",
";",
"var",
"element",
"=",
"CKEDITOR",
".",
"document",
".",
"getById",
"(",
... | Sets the button state.
@param {Number} state Indicates the button state. One of {@link CKEDITOR#TRISTATE_ON},
{@link CKEDITOR#TRISTATE_OFF}, or {@link CKEDITOR#TRISTATE_DISABLED}. | [
"Sets",
"the",
"button",
"state",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/button/plugin.js#L287-L316 | train | |
nodys/htmly | lib/transform.js | rPath | function rPath (htmlyFile, sourceFilepath) {
htmlyFile = pathResolve(__dirname, htmlyFile)
htmlyFile = pathRelative(dirname(sourceFilepath), htmlyFile)
htmlyFile = slash(htmlyFile)
if (!/^(\.|\/)/.test(htmlyFile)) {
return './' + htmlyFile
} else {
return htmlyFile
}
} | javascript | function rPath (htmlyFile, sourceFilepath) {
htmlyFile = pathResolve(__dirname, htmlyFile)
htmlyFile = pathRelative(dirname(sourceFilepath), htmlyFile)
htmlyFile = slash(htmlyFile)
if (!/^(\.|\/)/.test(htmlyFile)) {
return './' + htmlyFile
} else {
return htmlyFile
}
} | [
"function",
"rPath",
"(",
"htmlyFile",
",",
"sourceFilepath",
")",
"{",
"htmlyFile",
"=",
"pathResolve",
"(",
"__dirname",
",",
"htmlyFile",
")",
"htmlyFile",
"=",
"pathRelative",
"(",
"dirname",
"(",
"sourceFilepath",
")",
",",
"htmlyFile",
")",
"htmlyFile",
... | Generate a relative path to a htmly file, relative to source file
@param {string} htmlyFile
Path relative to current module
@param {string} sourceFilepath
The source filepath
@return {string}
A relative path to htmlyFile from a transformed source | [
"Generate",
"a",
"relative",
"path",
"to",
"a",
"htmly",
"file",
"relative",
"to",
"source",
"file"
] | 770560274167b7efd78cf56544ec72f52efb3fb8 | https://github.com/nodys/htmly/blob/770560274167b7efd78cf56544ec72f52efb3fb8/lib/transform.js#L72-L81 | train |
hillscottc/nostra | src/word_library.js | warning | function warning() {
let sentence = "";
const avoidList = getWords("avoid_list");
const avoid = nu.chooseFrom(avoidList);
const rnum = Math.floor(Math.random() * 10);
if (rnum <= 3) {
sentence = `You would be well advised to avoid ${avoid}`;
} else if (rnum <= 6){
sentence = `Avoid ${avoid} at all c... | javascript | function warning() {
let sentence = "";
const avoidList = getWords("avoid_list");
const avoid = nu.chooseFrom(avoidList);
const rnum = Math.floor(Math.random() * 10);
if (rnum <= 3) {
sentence = `You would be well advised to avoid ${avoid}`;
} else if (rnum <= 6){
sentence = `Avoid ${avoid} at all c... | [
"function",
"warning",
"(",
")",
"{",
"let",
"sentence",
"=",
"\"\"",
";",
"const",
"avoidList",
"=",
"getWords",
"(",
"\"avoid_list\"",
")",
";",
"const",
"avoid",
"=",
"nu",
".",
"chooseFrom",
"(",
"avoidList",
")",
";",
"const",
"rnum",
"=",
"Math",
... | Warns of what to avoid
@returns {*} | [
"Warns",
"of",
"what",
"to",
"avoid"
] | 1801c8e19f7fab91dd29fea07195789d41624915 | https://github.com/hillscottc/nostra/blob/1801c8e19f7fab91dd29fea07195789d41624915/src/word_library.js#L209-L224 | train |
ottopecz/talentcomposer | lib/util.js | getIterableObjectEntries | function getIterableObjectEntries(obj) {
let index = 0;
const propKeys = Reflect.ownKeys(obj);
return {
[Symbol.iterator]() {
return this;
},
next() {
if (index < propKeys.length) {
const key = propKeys[index];
index += 1;
return {"value": [key, obj[key]]};
... | javascript | function getIterableObjectEntries(obj) {
let index = 0;
const propKeys = Reflect.ownKeys(obj);
return {
[Symbol.iterator]() {
return this;
},
next() {
if (index < propKeys.length) {
const key = propKeys[index];
index += 1;
return {"value": [key, obj[key]]};
... | [
"function",
"getIterableObjectEntries",
"(",
"obj",
")",
"{",
"let",
"index",
"=",
"0",
";",
"const",
"propKeys",
"=",
"Reflect",
".",
"ownKeys",
"(",
"obj",
")",
";",
"return",
"{",
"[",
"Symbol",
".",
"iterator",
"]",
"(",
")",
"{",
"return",
"this",... | Creates an iterable based on an object literal
@param {Object} obj The source object which own keys should be iterable
@returns {Object} The iterable with the own keys | [
"Creates",
"an",
"iterable",
"based",
"on",
"an",
"object",
"literal"
] | 440c73248ccb6538c7805ada6a8feb5b3ae4a973 | https://github.com/ottopecz/talentcomposer/blob/440c73248ccb6538c7805ada6a8feb5b3ae4a973/lib/util.js#L6-L28 | train |
ottopecz/talentcomposer | lib/util.js | findWhere | function findWhere(arr, key, value) {
return arr.find(elem => {
for (const [k, v] of getIterableObjectEntries(elem)) {
if (k === key && v === value) {
return true;
}
}
});
} | javascript | function findWhere(arr, key, value) {
return arr.find(elem => {
for (const [k, v] of getIterableObjectEntries(elem)) {
if (k === key && v === value) {
return true;
}
}
});
} | [
"function",
"findWhere",
"(",
"arr",
",",
"key",
",",
"value",
")",
"{",
"return",
"arr",
".",
"find",
"(",
"elem",
"=>",
"{",
"for",
"(",
"const",
"[",
"k",
",",
"v",
"]",
"of",
"getIterableObjectEntries",
"(",
"elem",
")",
")",
"{",
"if",
"(",
... | Returns the object where the given own key exists and equal with value
@param {Array.<Object>} arr The source array of objects
@param {string} key The name of the own key to filter with
@param {*} value The value of the key to filter with
@returns {Object} The found object specified by the key value pair | [
"Returns",
"the",
"object",
"where",
"the",
"given",
"own",
"key",
"exists",
"and",
"equal",
"with",
"value"
] | 440c73248ccb6538c7805ada6a8feb5b3ae4a973 | https://github.com/ottopecz/talentcomposer/blob/440c73248ccb6538c7805ada6a8feb5b3ae4a973/lib/util.js#L37-L48 | train |
ottopecz/talentcomposer | lib/util.js | findWhereKey | function findWhereKey(arr, key) {
return arr.find(elem => {
for (const [k] of getIterableObjectEntries(elem)) {
if (k === key) {
return true;
}
}
});
} | javascript | function findWhereKey(arr, key) {
return arr.find(elem => {
for (const [k] of getIterableObjectEntries(elem)) {
if (k === key) {
return true;
}
}
});
} | [
"function",
"findWhereKey",
"(",
"arr",
",",
"key",
")",
"{",
"return",
"arr",
".",
"find",
"(",
"elem",
"=>",
"{",
"for",
"(",
"const",
"[",
"k",
"]",
"of",
"getIterableObjectEntries",
"(",
"elem",
")",
")",
"{",
"if",
"(",
"k",
"===",
"key",
")",... | Returns the object where the given own key exists
@param {Array.<Object>} arr The source array of objects
@param {string} key The name of the own key to filter with
@returns {Object} The found object specified by the name of the given own key | [
"Returns",
"the",
"object",
"where",
"the",
"given",
"own",
"key",
"exists"
] | 440c73248ccb6538c7805ada6a8feb5b3ae4a973 | https://github.com/ottopecz/talentcomposer/blob/440c73248ccb6538c7805ada6a8feb5b3ae4a973/lib/util.js#L56-L67 | train |
bmustiata/promised-node | lib/promised-node.js | load | function load(module) {
var toTransform,
transformedModule = {};
if (typeof module === "string") {
toTransform = require(module);
} else {
toTransform = module;
}
for (var item in toTransform) {
// transform only sync/async methods to promiseable since having utility meth... | javascript | function load(module) {
var toTransform,
transformedModule = {};
if (typeof module === "string") {
toTransform = require(module);
} else {
toTransform = module;
}
for (var item in toTransform) {
// transform only sync/async methods to promiseable since having utility meth... | [
"function",
"load",
"(",
"module",
")",
"{",
"var",
"toTransform",
",",
"transformedModule",
"=",
"{",
"}",
";",
"if",
"(",
"typeof",
"module",
"===",
"\"string\"",
")",
"{",
"toTransform",
"=",
"require",
"(",
"module",
")",
";",
"}",
"else",
"{",
"to... | Load a module transforming all the async methods that have callbacks
into promises enabled functions.
@param {string|object} module The module name, or the object to transform its functions.
@return {object} Loaded module with methods transformed. | [
"Load",
"a",
"module",
"transforming",
"all",
"the",
"async",
"methods",
"that",
"have",
"callbacks",
"into",
"promises",
"enabled",
"functions",
"."
] | 0f39c6dc5a06a3d347053a99b5311836df8258fb | https://github.com/bmustiata/promised-node/blob/0f39c6dc5a06a3d347053a99b5311836df8258fb/lib/promised-node.js#L9-L30 | train |
bmustiata/promised-node | lib/promised-node.js | rebuildAsPromise | function rebuildAsPromise(_thisObject, name, fn) {
// if is a regular function, that has an async correspondent also make it promiseable
if (!isFunctionAsync(_thisObject, name, fn)) {
return function() {
var that = this,
args = arguments;
return blinkts.lang.prom... | javascript | function rebuildAsPromise(_thisObject, name, fn) {
// if is a regular function, that has an async correspondent also make it promiseable
if (!isFunctionAsync(_thisObject, name, fn)) {
return function() {
var that = this,
args = arguments;
return blinkts.lang.prom... | [
"function",
"rebuildAsPromise",
"(",
"_thisObject",
",",
"name",
",",
"fn",
")",
"{",
"// if is a regular function, that has an async correspondent also make it promiseable",
"if",
"(",
"!",
"isFunctionAsync",
"(",
"_thisObject",
",",
"name",
",",
"fn",
")",
")",
"{",
... | Takes the current function and wraps it around a promise. | [
"Takes",
"the",
"current",
"function",
"and",
"wraps",
"it",
"around",
"a",
"promise",
"."
] | 0f39c6dc5a06a3d347053a99b5311836df8258fb | https://github.com/bmustiata/promised-node/blob/0f39c6dc5a06a3d347053a99b5311836df8258fb/lib/promised-node.js#L54-L92 | train |
clusterpoint/nodejs-client-api | lib/reply.js | function(err, res) {
if (err) return callback(err);
self._rawResponse = res;
if (!res || !res['cps:reply']) return callback(new Error("Invalid reply"));
self.seconds = res['cps:reply']['cps:seconds'];
if (res['cps:reply']['cps:content']) {
var content = res['cps:reply... | javascript | function(err, res) {
if (err) return callback(err);
self._rawResponse = res;
if (!res || !res['cps:reply']) return callback(new Error("Invalid reply"));
self.seconds = res['cps:reply']['cps:seconds'];
if (res['cps:reply']['cps:content']) {
var content = res['cps:reply... | [
"function",
"(",
"err",
",",
"res",
")",
"{",
"if",
"(",
"err",
")",
"return",
"callback",
"(",
"err",
")",
";",
"self",
".",
"_rawResponse",
"=",
"res",
";",
"if",
"(",
"!",
"res",
"||",
"!",
"res",
"[",
"'cps:reply'",
"]",
")",
"return",
"callb... | Merges response content into objects variables, so it can be easily accessible | [
"Merges",
"response",
"content",
"into",
"objects",
"variables",
"so",
"it",
"can",
"be",
"easily",
"accessible"
] | ca9322eab3d11f7cc43ce0e6f6e2403f5b3712a0 | https://github.com/clusterpoint/nodejs-client-api/blob/ca9322eab3d11f7cc43ce0e6f6e2403f5b3712a0/lib/reply.js#L20-L31 | train | |
byu-oit/fully-typed | bin/number.js | TypedNumber | function TypedNumber (config) {
const number = this;
// validate min
if (config.hasOwnProperty('min') && !util.isNumber(config.min)) {
const message = util.propertyErrorMessage('min', config.min, 'Must be a number.');
throw Error(message);
}
// validate max
if (config.hasOwnPro... | javascript | function TypedNumber (config) {
const number = this;
// validate min
if (config.hasOwnProperty('min') && !util.isNumber(config.min)) {
const message = util.propertyErrorMessage('min', config.min, 'Must be a number.');
throw Error(message);
}
// validate max
if (config.hasOwnPro... | [
"function",
"TypedNumber",
"(",
"config",
")",
"{",
"const",
"number",
"=",
"this",
";",
"// validate min",
"if",
"(",
"config",
".",
"hasOwnProperty",
"(",
"'min'",
")",
"&&",
"!",
"util",
".",
"isNumber",
"(",
"config",
".",
"min",
")",
")",
"{",
"co... | Create a TypedNumber instance.
@param {object} config
@returns {TypedNumber}
@augments Typed
@constructor | [
"Create",
"a",
"TypedNumber",
"instance",
"."
] | ed6b3ed88ffc72990acffb765232eaaee261afef | https://github.com/byu-oit/fully-typed/blob/ed6b3ed88ffc72990acffb765232eaaee261afef/bin/number.js#L29-L106 | train |
soajs/grunt-soajs | lib/swagger/swagger.js | recursiveMapping | function recursiveMapping(source) {
if (source.type === 'array') {
if (source.items['$ref'] || source.items.type === 'object') {
source.items = mapSimpleField(source.items);
}
else if (source.items.type === 'object') {
recursiveMapping(source.items);
}
else mapSimpleField(source);
}
... | javascript | function recursiveMapping(source) {
if (source.type === 'array') {
if (source.items['$ref'] || source.items.type === 'object') {
source.items = mapSimpleField(source.items);
}
else if (source.items.type === 'object') {
recursiveMapping(source.items);
}
else mapSimpleField(source);
}
... | [
"function",
"recursiveMapping",
"(",
"source",
")",
"{",
"if",
"(",
"source",
".",
"type",
"===",
"'array'",
")",
"{",
"if",
"(",
"source",
".",
"items",
"[",
"'$ref'",
"]",
"||",
"source",
".",
"items",
".",
"type",
"===",
"'object'",
")",
"{",
"sou... | loop through one common field recursively constructing and populating all its children imfv | [
"loop",
"through",
"one",
"common",
"field",
"recursively",
"constructing",
"and",
"populating",
"all",
"its",
"children",
"imfv"
] | 89b9583d2b62229430f4d710107c285149174a87 | https://github.com/soajs/grunt-soajs/blob/89b9583d2b62229430f4d710107c285149174a87/lib/swagger/swagger.js#L337-L370 | train |
soajs/grunt-soajs | lib/swagger/swagger.js | function (yamlContent, context, callback) {
var jsonAPISchema;
try {
jsonAPISchema = yamljs.parse(yamlContent);
}
catch (e) {
return callback({"code": 851, "msg": e.message});
}
try {
swagger.validateYaml(jsonAPISchema);
}
catch (e) {
return callback({"code": 173, "msg": e.message});
... | javascript | function (yamlContent, context, callback) {
var jsonAPISchema;
try {
jsonAPISchema = yamljs.parse(yamlContent);
}
catch (e) {
return callback({"code": 851, "msg": e.message});
}
try {
swagger.validateYaml(jsonAPISchema);
}
catch (e) {
return callback({"code": 173, "msg": e.message});
... | [
"function",
"(",
"yamlContent",
",",
"context",
",",
"callback",
")",
"{",
"var",
"jsonAPISchema",
";",
"try",
"{",
"jsonAPISchema",
"=",
"yamljs",
".",
"parse",
"(",
"yamlContent",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"return",
"callback",
"(",
... | parse the yaml and generate a config.js content from it
@param cb
@returns {*} | [
"parse",
"the",
"yaml",
"and",
"generate",
"a",
"config",
".",
"js",
"content",
"from",
"it"
] | 89b9583d2b62229430f4d710107c285149174a87 | https://github.com/soajs/grunt-soajs/blob/89b9583d2b62229430f4d710107c285149174a87/lib/swagger/swagger.js#L402-L438 | train | |
soajs/grunt-soajs | lib/swagger/swagger.js | function (yamlJson) {
if (typeof yamlJson !== 'object') {
throw new Error("Yaml file was converted to a string");
}
if (!yamlJson.paths || Object.keys(yamlJson.paths).length === 0) {
throw new Error("Yaml file is missing api schema");
}
//loop in path
for (var onePath in yamlJson.paths) {
//l... | javascript | function (yamlJson) {
if (typeof yamlJson !== 'object') {
throw new Error("Yaml file was converted to a string");
}
if (!yamlJson.paths || Object.keys(yamlJson.paths).length === 0) {
throw new Error("Yaml file is missing api schema");
}
//loop in path
for (var onePath in yamlJson.paths) {
//l... | [
"function",
"(",
"yamlJson",
")",
"{",
"if",
"(",
"typeof",
"yamlJson",
"!==",
"'object'",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Yaml file was converted to a string\"",
")",
";",
"}",
"if",
"(",
"!",
"yamlJson",
".",
"paths",
"||",
"Object",
".",
"key... | validate that parsed yaml content has the minimum required fields
@param yamlJson | [
"validate",
"that",
"parsed",
"yaml",
"content",
"has",
"the",
"minimum",
"required",
"fields"
] | 89b9583d2b62229430f4d710107c285149174a87 | https://github.com/soajs/grunt-soajs/blob/89b9583d2b62229430f4d710107c285149174a87/lib/swagger/swagger.js#L444-L462 | train | |
soajs/grunt-soajs | lib/swagger/swagger.js | function (obj) {
if (typeof obj !== "object" || obj === null) {
return obj;
}
if (obj instanceof Date) {
return new Date(obj.getTime());
}
if (obj instanceof RegExp) {
return new RegExp(obj);
}
if (obj instanceof Array && Object.keys(obj).every(function (k) {
return !isNaN(k);
}))... | javascript | function (obj) {
if (typeof obj !== "object" || obj === null) {
return obj;
}
if (obj instanceof Date) {
return new Date(obj.getTime());
}
if (obj instanceof RegExp) {
return new RegExp(obj);
}
if (obj instanceof Array && Object.keys(obj).every(function (k) {
return !isNaN(k);
}))... | [
"function",
"(",
"obj",
")",
"{",
"if",
"(",
"typeof",
"obj",
"!==",
"\"object\"",
"||",
"obj",
"===",
"null",
")",
"{",
"return",
"obj",
";",
"}",
"if",
"(",
"obj",
"instanceof",
"Date",
")",
"{",
"return",
"new",
"Date",
"(",
"obj",
".",
"getTime... | clone a javascript object with type casting
@param obj
@returns {*} | [
"clone",
"a",
"javascript",
"object",
"with",
"type",
"casting"
] | 89b9583d2b62229430f4d710107c285149174a87 | https://github.com/soajs/grunt-soajs/blob/89b9583d2b62229430f4d710107c285149174a87/lib/swagger/swagger.js#L469-L494 | train | |
soajs/grunt-soajs | lib/swagger/swagger.js | function (serviceInfo) {
var config = {
"type": "service",
"prerequisites": {
"cpu": " ",
"memory": " "
},
"swagger": true,
"injection": true,
"serviceName": serviceInfo.serviceName,
"serviceGroup": serviceInfo.serviceGroup,
"serviceVersion": serviceInfo.serviceVersion,
"servicePort... | javascript | function (serviceInfo) {
var config = {
"type": "service",
"prerequisites": {
"cpu": " ",
"memory": " "
},
"swagger": true,
"injection": true,
"serviceName": serviceInfo.serviceName,
"serviceGroup": serviceInfo.serviceGroup,
"serviceVersion": serviceInfo.serviceVersion,
"servicePort... | [
"function",
"(",
"serviceInfo",
")",
"{",
"var",
"config",
"=",
"{",
"\"type\"",
":",
"\"service\"",
",",
"\"prerequisites\"",
":",
"{",
"\"cpu\"",
":",
"\" \"",
",",
"\"memory\"",
":",
"\" \"",
"}",
",",
"\"swagger\"",
":",
"true",
",",
"\"injection\"",
"... | map variables to meet the service configuration object schema
@param serviceInfo
@returns {{type: string, prerequisites: {cpu: string, memory: string}, swagger: boolean, dbs, serviceName, serviceGroup, serviceVersion, servicePort, requestTimeout, requestTimeoutRenewal, extKeyRequired, oauth, session, errors: {}, schema... | [
"map",
"variables",
"to",
"meet",
"the",
"service",
"configuration",
"object",
"schema"
] | 89b9583d2b62229430f4d710107c285149174a87 | https://github.com/soajs/grunt-soajs/blob/89b9583d2b62229430f4d710107c285149174a87/lib/swagger/swagger.js#L501-L540 | train | |
soajs/grunt-soajs | lib/swagger/swagger.js | function (yamlJson, cb) {
let all_apis = {};
let all_errors = {};
let paths = reformatPaths(yamlJson.paths);
let definitions = yamlJson.definitions;
let parameters = yamlJson.parameters;
let convertedDefinitions = {};
let convertedParameters = {};
// convert definitions first
if (definitio... | javascript | function (yamlJson, cb) {
let all_apis = {};
let all_errors = {};
let paths = reformatPaths(yamlJson.paths);
let definitions = yamlJson.definitions;
let parameters = yamlJson.parameters;
let convertedDefinitions = {};
let convertedParameters = {};
// convert definitions first
if (definitio... | [
"function",
"(",
"yamlJson",
",",
"cb",
")",
"{",
"let",
"all_apis",
"=",
"{",
"}",
";",
"let",
"all_errors",
"=",
"{",
"}",
";",
"let",
"paths",
"=",
"reformatPaths",
"(",
"yamlJson",
".",
"paths",
")",
";",
"let",
"definitions",
"=",
"yamlJson",
".... | map apis to meet service configuraiton schema from a parsed swagger yaml json object
@param yamlJson
@param cb
@returns {*} | [
"map",
"apis",
"to",
"meet",
"service",
"configuraiton",
"schema",
"from",
"a",
"parsed",
"swagger",
"yaml",
"json",
"object"
] | 89b9583d2b62229430f4d710107c285149174a87 | https://github.com/soajs/grunt-soajs/blob/89b9583d2b62229430f4d710107c285149174a87/lib/swagger/swagger.js#L548-L614 | 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.