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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
altshift/altshift | lib/altshift/core/class.js | function () {
var prefix = '%(',
suffix = ')',
data = this.data,
output = '',
dataKey;
output = this.__message__;
for (dataKey in data) {
if (data.hasOwnProperty(dataKey)) {
output = output.replace(prefix + dataKey + s... | javascript | function () {
var prefix = '%(',
suffix = ')',
data = this.data,
output = '',
dataKey;
output = this.__message__;
for (dataKey in data) {
if (data.hasOwnProperty(dataKey)) {
output = output.replace(prefix + dataKey + s... | [
"function",
"(",
")",
"{",
"var",
"prefix",
"=",
"'%('",
",",
"suffix",
"=",
"')'",
",",
"data",
"=",
"this",
".",
"data",
",",
"output",
"=",
"''",
",",
"dataKey",
";",
"output",
"=",
"this",
".",
"__message__",
";",
"for",
"(",
"dataKey",
"in",
... | Return formatted message
@return {string} | [
"Return",
"formatted",
"message"
] | 5c051157e6f558636c8e12081b6707caa66249de | https://github.com/altshift/altshift/blob/5c051157e6f558636c8e12081b6707caa66249de/lib/altshift/core/class.js#L301-L319 | train | |
altshift/altshift | lib/altshift/core/class.js | function (full) {
var output, data;
output = this.name + '[' + this.code + ']: ';
output += this.message;
if (full) {
output += '\n';
output += this.stack.toString();
}
return output;
} | javascript | function (full) {
var output, data;
output = this.name + '[' + this.code + ']: ';
output += this.message;
if (full) {
output += '\n';
output += this.stack.toString();
}
return output;
} | [
"function",
"(",
"full",
")",
"{",
"var",
"output",
",",
"data",
";",
"output",
"=",
"this",
".",
"name",
"+",
"'['",
"+",
"this",
".",
"code",
"+",
"']: '",
";",
"output",
"+=",
"this",
".",
"message",
";",
"if",
"(",
"full",
")",
"{",
"output",... | Return string formatted representation
@param {boolean} full
@return {string} | [
"Return",
"string",
"formatted",
"representation"
] | 5c051157e6f558636c8e12081b6707caa66249de | https://github.com/altshift/altshift/blob/5c051157e6f558636c8e12081b6707caa66249de/lib/altshift/core/class.js#L327-L337 | train | |
ArtOfCode-/nails | src/handlers.js | setView | function setView({ action, config, route, routes, method }) {
const ws = route.ws;
return exports.getView(action, config).then(view => {
routes[ws ? 'ws' : route.type].push({
action,
method,
view,
match: new Route(route.url),
});
});
} | javascript | function setView({ action, config, route, routes, method }) {
const ws = route.ws;
return exports.getView(action, config).then(view => {
routes[ws ? 'ws' : route.type].push({
action,
method,
view,
match: new Route(route.url),
});
});
} | [
"function",
"setView",
"(",
"{",
"action",
",",
"config",
",",
"route",
",",
"routes",
",",
"method",
"}",
")",
"{",
"const",
"ws",
"=",
"route",
".",
"ws",
";",
"return",
"exports",
".",
"getView",
"(",
"action",
",",
"config",
")",
".",
"then",
"... | Set the view for a specific route
@private
@returns {Promise} Could the view be loaded? | [
"Set",
"the",
"view",
"for",
"a",
"specific",
"route"
] | 1ba9158742ba72bc727ad5c881035ee9d99b700c | https://github.com/ArtOfCode-/nails/blob/1ba9158742ba72bc727ad5c881035ee9d99b700c/src/handlers.js#L27-L37 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/dom/rangelist.js | function() {
var rangeList = this,
bookmark = CKEDITOR.dom.walker.bookmark(),
bookmarks = [],
current;
return {
/**
* Retrieves the next range in the list.
*
* @member CKEDITOR.dom.rangeListIterator
* @param {Boolean} [mergeConsequent=false] Whether join two adjacent
* ra... | javascript | function() {
var rangeList = this,
bookmark = CKEDITOR.dom.walker.bookmark(),
bookmarks = [],
current;
return {
/**
* Retrieves the next range in the list.
*
* @member CKEDITOR.dom.rangeListIterator
* @param {Boolean} [mergeConsequent=false] Whether join two adjacent
* ra... | [
"function",
"(",
")",
"{",
"var",
"rangeList",
"=",
"this",
",",
"bookmark",
"=",
"CKEDITOR",
".",
"dom",
".",
"walker",
".",
"bookmark",
"(",
")",
",",
"bookmarks",
"=",
"[",
"]",
",",
"current",
";",
"return",
"{",
"/**\n\t\t\t\t * Retrieves the next ran... | Creates an instance of the rangeList iterator, it should be used
only when the ranges processing could be DOM intrusive, which
means it may pollute and break other ranges in this list.
Otherwise, it's enough to just iterate over this array in a for loop.
@returns {CKEDITOR.dom.rangeListIterator} | [
"Creates",
"an",
"instance",
"of",
"the",
"rangeList",
"iterator",
"it",
"should",
"be",
"used",
"only",
"when",
"the",
"ranges",
"processing",
"could",
"be",
"DOM",
"intrusive",
"which",
"means",
"it",
"may",
"pollute",
"and",
"break",
"other",
"ranges",
"i... | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/dom/rangelist.js#L39-L116 | train | |
frisb/fdboost | lib/enhance/encoding/adapters/index.js | function(typeCode) {
switch (typeCode) {
case this.types.undefined:
return this.Undefined;
case this.types.string:
return this.String;
case this.types.integer:
return this.Integer;
case this.types.double:
return this.Double;... | javascript | function(typeCode) {
switch (typeCode) {
case this.types.undefined:
return this.Undefined;
case this.types.string:
return this.String;
case this.types.integer:
return this.Integer;
case this.types.double:
return this.Double;... | [
"function",
"(",
"typeCode",
")",
"{",
"switch",
"(",
"typeCode",
")",
"{",
"case",
"this",
".",
"types",
".",
"undefined",
":",
"return",
"this",
".",
"Undefined",
";",
"case",
"this",
".",
"types",
".",
"string",
":",
"return",
"this",
".",
"String",... | Get an Adapter for typeCode
@method
@param {integer} typeCode Type code.
@return {AbstractAdapter} AbstractAdapter extension | [
"Get",
"an",
"Adapter",
"for",
"typeCode"
] | 66cfb6552940aa92f35dbb1cf4d0695d842205c2 | https://github.com/frisb/fdboost/blob/66cfb6552940aa92f35dbb1cf4d0695d842205c2/lib/enhance/encoding/adapters/index.js#L30-L55 | train | |
forfuturellc/svc-fbr | src/lib/utils.js | addType | function addType(descriptor) {
if (!(descriptor instanceof fs.Stats)) {
return descriptor;
}
[
"isFile", "isDirectory", "isBlockDevice", "isCharacterDevice",
"isSymbolicLink", "isFIFO", "isSocket",
].forEach(function(funcName) {
if (descriptor[funcName]()) {
descriptor[funcName] = true;
... | javascript | function addType(descriptor) {
if (!(descriptor instanceof fs.Stats)) {
return descriptor;
}
[
"isFile", "isDirectory", "isBlockDevice", "isCharacterDevice",
"isSymbolicLink", "isFIFO", "isSocket",
].forEach(function(funcName) {
if (descriptor[funcName]()) {
descriptor[funcName] = true;
... | [
"function",
"addType",
"(",
"descriptor",
")",
"{",
"if",
"(",
"!",
"(",
"descriptor",
"instanceof",
"fs",
".",
"Stats",
")",
")",
"{",
"return",
"descriptor",
";",
"}",
"[",
"\"isFile\"",
",",
"\"isDirectory\"",
",",
"\"isBlockDevice\"",
",",
"\"isCharacter... | Add type to all stat objects in a descriptor
@param {fs.Stats} stats
@return {fs.Stats} | [
"Add",
"type",
"to",
"all",
"stat",
"objects",
"in",
"a",
"descriptor"
] | 8c07c71d6423d1dbd4f903a032dea0bfec63894e | https://github.com/forfuturellc/svc-fbr/blob/8c07c71d6423d1dbd4f903a032dea0bfec63894e/src/lib/utils.js#L26-L46 | train |
forfuturellc/svc-fbr | src/lib/utils.js | getArgs | function getArgs(userArgs, defaultArgs, userCallback) {
let args = { };
let callback = userCallback || function() { };
defaultArgs.unshift(args);
_.assign.apply(null, defaultArgs);
if (_.isPlainObject(userArgs)) {
_.merge(args, userArgs);
} else {
callback = userArgs;
}
return {
options: a... | javascript | function getArgs(userArgs, defaultArgs, userCallback) {
let args = { };
let callback = userCallback || function() { };
defaultArgs.unshift(args);
_.assign.apply(null, defaultArgs);
if (_.isPlainObject(userArgs)) {
_.merge(args, userArgs);
} else {
callback = userArgs;
}
return {
options: a... | [
"function",
"getArgs",
"(",
"userArgs",
",",
"defaultArgs",
",",
"userCallback",
")",
"{",
"let",
"args",
"=",
"{",
"}",
";",
"let",
"callback",
"=",
"userCallback",
"||",
"function",
"(",
")",
"{",
"}",
";",
"defaultArgs",
".",
"unshift",
"(",
"args",
... | Get arguments passed by user curated with configurations
@param {Object} userArgs - arguments from user
@param {Object[]} defaultArgs - default arguments to use
@param {Function} userCallback - callback passed by user | [
"Get",
"arguments",
"passed",
"by",
"user",
"curated",
"with",
"configurations"
] | 8c07c71d6423d1dbd4f903a032dea0bfec63894e | https://github.com/forfuturellc/svc-fbr/blob/8c07c71d6423d1dbd4f903a032dea0bfec63894e/src/lib/utils.js#L56-L72 | train |
wigy/chronicles_of_grunt | lib/file-filter.js | removeDuplicates | function removeDuplicates(files, duplicates) {
var i;
var ret = [];
var found = {};
if (duplicates) {
for (i=0; i < duplicates.length; i++) {
found[duplicates[i].dst] = true;
}
}
for (i=0; i < files.length; i++) {
if (... | javascript | function removeDuplicates(files, duplicates) {
var i;
var ret = [];
var found = {};
if (duplicates) {
for (i=0; i < duplicates.length; i++) {
found[duplicates[i].dst] = true;
}
}
for (i=0; i < files.length; i++) {
if (... | [
"function",
"removeDuplicates",
"(",
"files",
",",
"duplicates",
")",
"{",
"var",
"i",
";",
"var",
"ret",
"=",
"[",
"]",
";",
"var",
"found",
"=",
"{",
"}",
";",
"if",
"(",
"duplicates",
")",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"dupl... | Scan file specs and remove duplicates.
@param files {Array} List of resolved file specs.
@param duplicates {Array} Optional list of resolved file specs to consider duplicates. | [
"Scan",
"file",
"specs",
"and",
"remove",
"duplicates",
"."
] | c5f089a6f391a0ca625fcb81ef51907713471bb3 | https://github.com/wigy/chronicles_of_grunt/blob/c5f089a6f391a0ca625fcb81ef51907713471bb3/lib/file-filter.js#L164-L182 | train |
wigy/chronicles_of_grunt | lib/file-filter.js | flatten | function flatten(files) {
var ret = [];
for (var i=0; i < files.length; i++) {
ret.push(files[i].dst);
}
return ret;
} | javascript | function flatten(files) {
var ret = [];
for (var i=0; i < files.length; i++) {
ret.push(files[i].dst);
}
return ret;
} | [
"function",
"flatten",
"(",
"files",
")",
"{",
"var",
"ret",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"files",
".",
"length",
";",
"i",
"++",
")",
"{",
"ret",
".",
"push",
"(",
"files",
"[",
"i",
"]",
".",
"dst",... | Collect destination files from file spec list. | [
"Collect",
"destination",
"files",
"from",
"file",
"spec",
"list",
"."
] | c5f089a6f391a0ca625fcb81ef51907713471bb3 | https://github.com/wigy/chronicles_of_grunt/blob/c5f089a6f391a0ca625fcb81ef51907713471bb3/lib/file-filter.js#L187-L193 | train |
wigy/chronicles_of_grunt | lib/file-filter.js | prefixDest | function prefixDest(prefix, files) {
for (var i = 0; i < files.length; i++) {
files[i].dst = prefix + files[i].dst;
}
return files;
} | javascript | function prefixDest(prefix, files) {
for (var i = 0; i < files.length; i++) {
files[i].dst = prefix + files[i].dst;
}
return files;
} | [
"function",
"prefixDest",
"(",
"prefix",
",",
"files",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"files",
".",
"length",
";",
"i",
"++",
")",
"{",
"files",
"[",
"i",
"]",
".",
"dst",
"=",
"prefix",
"+",
"files",
"[",
"i",
"]"... | Add a directory prefix to all destinations in the file list. | [
"Add",
"a",
"directory",
"prefix",
"to",
"all",
"destinations",
"in",
"the",
"file",
"list",
"."
] | c5f089a6f391a0ca625fcb81ef51907713471bb3 | https://github.com/wigy/chronicles_of_grunt/blob/c5f089a6f391a0ca625fcb81ef51907713471bb3/lib/file-filter.js#L198-L203 | train |
wigy/chronicles_of_grunt | lib/file-filter.js | filesInRepository | function filesInRepository(dir) {
var ignoreDirs = cog.getOption('ignore_dirs');
// TODO: Allow an array and move to config.
var ignoreFiles = /~$/;
var files = glob.sync(dir ? dir + '/*' : '*');
var ret = [];
for (var i = 0; i < files.length; i++) {
if (fs.ls... | javascript | function filesInRepository(dir) {
var ignoreDirs = cog.getOption('ignore_dirs');
// TODO: Allow an array and move to config.
var ignoreFiles = /~$/;
var files = glob.sync(dir ? dir + '/*' : '*');
var ret = [];
for (var i = 0; i < files.length; i++) {
if (fs.ls... | [
"function",
"filesInRepository",
"(",
"dir",
")",
"{",
"var",
"ignoreDirs",
"=",
"cog",
".",
"getOption",
"(",
"'ignore_dirs'",
")",
";",
"// TODO: Allow an array and move to config.",
"var",
"ignoreFiles",
"=",
"/",
"~$",
"/",
";",
"var",
"files",
"=",
"glob",
... | Perform recursive lookup for files in the repository.
@return {Array} A list of files in the repository ignoring files of not interest. | [
"Perform",
"recursive",
"lookup",
"for",
"files",
"in",
"the",
"repository",
"."
] | c5f089a6f391a0ca625fcb81ef51907713471bb3 | https://github.com/wigy/chronicles_of_grunt/blob/c5f089a6f391a0ca625fcb81ef51907713471bb3/lib/file-filter.js#L210-L230 | train |
wigy/chronicles_of_grunt | lib/file-filter.js | excludeFiles | function excludeFiles(list, regex) {
var ret = [];
for (var i=0; i < list.length; i++) {
if (!regex.test(list[i].dst)) {
ret.push(list[i]);
}
}
return ret;
} | javascript | function excludeFiles(list, regex) {
var ret = [];
for (var i=0; i < list.length; i++) {
if (!regex.test(list[i].dst)) {
ret.push(list[i]);
}
}
return ret;
} | [
"function",
"excludeFiles",
"(",
"list",
",",
"regex",
")",
"{",
"var",
"ret",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"list",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"regex",
".",
"test",
"(",
... | Remove specs whose destination matches to the given regex pattern. | [
"Remove",
"specs",
"whose",
"destination",
"matches",
"to",
"the",
"given",
"regex",
"pattern",
"."
] | c5f089a6f391a0ca625fcb81ef51907713471bb3 | https://github.com/wigy/chronicles_of_grunt/blob/c5f089a6f391a0ca625fcb81ef51907713471bb3/lib/file-filter.js#L235-L243 | train |
wigy/chronicles_of_grunt | lib/file-filter.js | srcFiles | function srcFiles() {
return removeDuplicates(configFiles().concat(libFiles()).concat(modelFiles()).concat(srcDataFiles()).concat(codeFiles()));
} | javascript | function srcFiles() {
return removeDuplicates(configFiles().concat(libFiles()).concat(modelFiles()).concat(srcDataFiles()).concat(codeFiles()));
} | [
"function",
"srcFiles",
"(",
")",
"{",
"return",
"removeDuplicates",
"(",
"configFiles",
"(",
")",
".",
"concat",
"(",
"libFiles",
"(",
")",
")",
".",
"concat",
"(",
"modelFiles",
"(",
")",
")",
".",
"concat",
"(",
"srcDataFiles",
"(",
")",
")",
".",
... | Find all source code files for the actual application. | [
"Find",
"all",
"source",
"code",
"files",
"for",
"the",
"actual",
"application",
"."
] | c5f089a6f391a0ca625fcb81ef51907713471bb3 | https://github.com/wigy/chronicles_of_grunt/blob/c5f089a6f391a0ca625fcb81ef51907713471bb3/lib/file-filter.js#L359-L361 | train |
wigy/chronicles_of_grunt | lib/file-filter.js | otherNonJsFiles | function otherNonJsFiles() {
return removeDuplicates(files(cog.getConfig('src.other'), 'other'), srcFiles().concat(otherJsFiles().concat(appIndexFiles())));
} | javascript | function otherNonJsFiles() {
return removeDuplicates(files(cog.getConfig('src.other'), 'other'), srcFiles().concat(otherJsFiles().concat(appIndexFiles())));
} | [
"function",
"otherNonJsFiles",
"(",
")",
"{",
"return",
"removeDuplicates",
"(",
"files",
"(",
"cog",
".",
"getConfig",
"(",
"'src.other'",
")",
",",
"'other'",
")",
",",
"srcFiles",
"(",
")",
".",
"concat",
"(",
"otherJsFiles",
"(",
")",
".",
"concat",
... | Find other files that are not Javascript. | [
"Find",
"other",
"files",
"that",
"are",
"not",
"Javascript",
"."
] | c5f089a6f391a0ca625fcb81ef51907713471bb3 | https://github.com/wigy/chronicles_of_grunt/blob/c5f089a6f391a0ca625fcb81ef51907713471bb3/lib/file-filter.js#L387-L389 | train |
wigy/chronicles_of_grunt | lib/file-filter.js | includeJsFiles | function includeJsFiles() {
if (cog.getOption('include_only_external')) {
return extLibFiles().concat(generatedJsFiles());
}
if (cog.getOption('compile_typescript')) {
return extLibFiles().concat(generatedJsFiles());
}
return extLibFiles().concat(srcFiles(... | javascript | function includeJsFiles() {
if (cog.getOption('include_only_external')) {
return extLibFiles().concat(generatedJsFiles());
}
if (cog.getOption('compile_typescript')) {
return extLibFiles().concat(generatedJsFiles());
}
return extLibFiles().concat(srcFiles(... | [
"function",
"includeJsFiles",
"(",
")",
"{",
"if",
"(",
"cog",
".",
"getOption",
"(",
"'include_only_external'",
")",
")",
"{",
"return",
"extLibFiles",
"(",
")",
".",
"concat",
"(",
"generatedJsFiles",
"(",
")",
")",
";",
"}",
"if",
"(",
"cog",
".",
"... | Find all code files needed to include in HTML index. | [
"Find",
"all",
"code",
"files",
"needed",
"to",
"include",
"in",
"HTML",
"index",
"."
] | c5f089a6f391a0ca625fcb81ef51907713471bb3 | https://github.com/wigy/chronicles_of_grunt/blob/c5f089a6f391a0ca625fcb81ef51907713471bb3/lib/file-filter.js#L450-L458 | train |
wigy/chronicles_of_grunt | lib/file-filter.js | allJavascriptFiles | function allJavascriptFiles() {
return srcFiles().concat(otherJsFiles()).concat(unitTestFiles()).concat(unitTestHelperFiles()).concat(taskFiles()).concat(commonJsFiles());
} | javascript | function allJavascriptFiles() {
return srcFiles().concat(otherJsFiles()).concat(unitTestFiles()).concat(unitTestHelperFiles()).concat(taskFiles()).concat(commonJsFiles());
} | [
"function",
"allJavascriptFiles",
"(",
")",
"{",
"return",
"srcFiles",
"(",
")",
".",
"concat",
"(",
"otherJsFiles",
"(",
")",
")",
".",
"concat",
"(",
"unitTestFiles",
"(",
")",
")",
".",
"concat",
"(",
"unitTestHelperFiles",
"(",
")",
")",
".",
"concat... | Find all Javascript based work files. | [
"Find",
"all",
"Javascript",
"based",
"work",
"files",
"."
] | c5f089a6f391a0ca625fcb81ef51907713471bb3 | https://github.com/wigy/chronicles_of_grunt/blob/c5f089a6f391a0ca625fcb81ef51907713471bb3/lib/file-filter.js#L572-L574 | train |
wigy/chronicles_of_grunt | lib/file-filter.js | workTextFiles | function workTextFiles() {
return indexFiles().concat(srcFiles()).concat(allTestFiles()).concat(otherJsFiles()).concat(otherNonJsFiles()).concat(taskFiles()).concat(cssFiles())
.concat(toolsShellFiles()).concat(commonJsFiles()).concat(htmlTemplateFiles()).concat(pythonFiles()).concat(textDataFiles()... | javascript | function workTextFiles() {
return indexFiles().concat(srcFiles()).concat(allTestFiles()).concat(otherJsFiles()).concat(otherNonJsFiles()).concat(taskFiles()).concat(cssFiles())
.concat(toolsShellFiles()).concat(commonJsFiles()).concat(htmlTemplateFiles()).concat(pythonFiles()).concat(textDataFiles()... | [
"function",
"workTextFiles",
"(",
")",
"{",
"return",
"indexFiles",
"(",
")",
".",
"concat",
"(",
"srcFiles",
"(",
")",
")",
".",
"concat",
"(",
"allTestFiles",
"(",
")",
")",
".",
"concat",
"(",
"otherJsFiles",
"(",
")",
")",
".",
"concat",
"(",
"ot... | Find all text based work files. | [
"Find",
"all",
"text",
"based",
"work",
"files",
"."
] | c5f089a6f391a0ca625fcb81ef51907713471bb3 | https://github.com/wigy/chronicles_of_grunt/blob/c5f089a6f391a0ca625fcb81ef51907713471bb3/lib/file-filter.js#L628-L631 | train |
wigy/chronicles_of_grunt | lib/file-filter.js | generatedJsFiles | function generatedJsFiles(what) {
var ret = [];
if ((!what || what === 'templates') && cog.getOption('template')) {
ret.push({src: null, dst: cog.getOption('template')});
}
if (cog.getOption('compile_typescript')) {
var src = srcTypescriptFiles();
for ... | javascript | function generatedJsFiles(what) {
var ret = [];
if ((!what || what === 'templates') && cog.getOption('template')) {
ret.push({src: null, dst: cog.getOption('template')});
}
if (cog.getOption('compile_typescript')) {
var src = srcTypescriptFiles();
for ... | [
"function",
"generatedJsFiles",
"(",
"what",
")",
"{",
"var",
"ret",
"=",
"[",
"]",
";",
"if",
"(",
"(",
"!",
"what",
"||",
"what",
"===",
"'templates'",
")",
"&&",
"cog",
".",
"getOption",
"(",
"'template'",
")",
")",
"{",
"ret",
".",
"push",
"(",... | List of files that are generated Javascript files. | [
"List",
"of",
"files",
"that",
"are",
"generated",
"Javascript",
"files",
"."
] | c5f089a6f391a0ca625fcb81ef51907713471bb3 | https://github.com/wigy/chronicles_of_grunt/blob/c5f089a6f391a0ca625fcb81ef51907713471bb3/lib/file-filter.js#L650-L665 | train |
wigy/chronicles_of_grunt | lib/file-filter.js | fileCategoryMap | function fileCategoryMap() {
// Go over every file lookup function we export.
var exports = module.exports(grunt);
// This list of categories must contain all non-overlapping file categories.
var categories = ['extLibFiles', 'extLibMapFiles', 'extCssFiles', 'extFontFiles', 'fontFiles',
... | javascript | function fileCategoryMap() {
// Go over every file lookup function we export.
var exports = module.exports(grunt);
// This list of categories must contain all non-overlapping file categories.
var categories = ['extLibFiles', 'extLibMapFiles', 'extCssFiles', 'extFontFiles', 'fontFiles',
... | [
"function",
"fileCategoryMap",
"(",
")",
"{",
"// Go over every file lookup function we export.",
"var",
"exports",
"=",
"module",
".",
"exports",
"(",
"grunt",
")",
";",
"// This list of categories must contain all non-overlapping file categories.",
"var",
"categories",
"=",
... | Build complete map of known files.
Note that when adding new file categories, this function must be updated and all
new non-overlapping (i.e. atomic) categories needs to be added here. | [
"Build",
"complete",
"map",
"of",
"known",
"files",
"."
] | c5f089a6f391a0ca625fcb81ef51907713471bb3 | https://github.com/wigy/chronicles_of_grunt/blob/c5f089a6f391a0ca625fcb81ef51907713471bb3/lib/file-filter.js#L708-L735 | train |
intervolga/bemjson-loader | lib/validate-bemjson.js | validateBemJson | function validateBemJson(bemJson, fileName) {
let errors = [];
if (Array.isArray(bemJson)) {
bemJson.forEach((childBemJson) => {
errors = errors.concat(validateBemJson(childBemJson, fileName));
});
} else if (bemJson instanceof Object) {
Object.keys(bemJson).forEach((key) => {
const child... | javascript | function validateBemJson(bemJson, fileName) {
let errors = [];
if (Array.isArray(bemJson)) {
bemJson.forEach((childBemJson) => {
errors = errors.concat(validateBemJson(childBemJson, fileName));
});
} else if (bemJson instanceof Object) {
Object.keys(bemJson).forEach((key) => {
const child... | [
"function",
"validateBemJson",
"(",
"bemJson",
",",
"fileName",
")",
"{",
"let",
"errors",
"=",
"[",
"]",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",
"bemJson",
")",
")",
"{",
"bemJson",
".",
"forEach",
"(",
"(",
"childBemJson",
")",
"=>",
"{",
"er... | Validate BEM JSON
@param {Object} bemJson
@param {String} fileName
@return {Array} of validation errors | [
"Validate",
"BEM",
"JSON"
] | c4ff680ee07ab939d400f241859fe608411fd8de | https://github.com/intervolga/bemjson-loader/blob/c4ff680ee07ab939d400f241859fe608411fd8de/lib/validate-bemjson.js#L8-L25 | train |
intervolga/bemjson-loader | lib/validate-bemjson.js | extractBemJsonNode | function extractBemJsonNode(bemJson) {
let result = JSON.parse(JSON.stringify(bemJson));
Object.keys(result).forEach((key) => {
result[key] = result[key].toString();
});
return JSON.stringify(result, null, 2);
} | javascript | function extractBemJsonNode(bemJson) {
let result = JSON.parse(JSON.stringify(bemJson));
Object.keys(result).forEach((key) => {
result[key] = result[key].toString();
});
return JSON.stringify(result, null, 2);
} | [
"function",
"extractBemJsonNode",
"(",
"bemJson",
")",
"{",
"let",
"result",
"=",
"JSON",
".",
"parse",
"(",
"JSON",
".",
"stringify",
"(",
"bemJson",
")",
")",
";",
"Object",
".",
"keys",
"(",
"result",
")",
".",
"forEach",
"(",
"(",
"key",
")",
"=>... | Strips all child nodes from BemJson node for print puproses
@param {Object} bemJson
@return {Object} | [
"Strips",
"all",
"child",
"nodes",
"from",
"BemJson",
"node",
"for",
"print",
"puproses"
] | c4ff680ee07ab939d400f241859fe608411fd8de | https://github.com/intervolga/bemjson-loader/blob/c4ff680ee07ab939d400f241859fe608411fd8de/lib/validate-bemjson.js#L98-L106 | train |
codenothing/munit | lib/queue.js | function(){
var copy = [];
// Handle recursive loops
if ( queue.running ) {
queue.waiting = true;
return;
}
// Mark queue as running, then search for
queue.running = true;
munit.each( queue.modules, function( assert, index ) {
if ( ! queue.objects.length ) {
return false;
}
else if (... | javascript | function(){
var copy = [];
// Handle recursive loops
if ( queue.running ) {
queue.waiting = true;
return;
}
// Mark queue as running, then search for
queue.running = true;
munit.each( queue.modules, function( assert, index ) {
if ( ! queue.objects.length ) {
return false;
}
else if (... | [
"function",
"(",
")",
"{",
"var",
"copy",
"=",
"[",
"]",
";",
"// Handle recursive loops",
"if",
"(",
"queue",
".",
"running",
")",
"{",
"queue",
".",
"waiting",
"=",
"true",
";",
"return",
";",
"}",
"// Mark queue as running, then search for ",
"queue",
"."... | Runs through queued modules and finds objects to run them with | [
"Runs",
"through",
"queued",
"modules",
"and",
"finds",
"objects",
"to",
"run",
"them",
"with"
] | aedf3f31aafc05441970eec49eeeb81174c14033 | https://github.com/codenothing/munit/blob/aedf3f31aafc05441970eec49eeeb81174c14033/lib/queue.js#L58-L111 | train | |
andreypopp/stream-recreate | index.js | recreate | function recreate(makeStream, options) {
if (options === undefined && isObject(makeStream)) {
options = makeStream;
makeStream = options.makeStream;
}
options = options || {};
if (options.connect === undefined) {
options.connect = true;
}
var connectedEvent = options.connectedEvent || 'open';... | javascript | function recreate(makeStream, options) {
if (options === undefined && isObject(makeStream)) {
options = makeStream;
makeStream = options.makeStream;
}
options = options || {};
if (options.connect === undefined) {
options.connect = true;
}
var connectedEvent = options.connectedEvent || 'open';... | [
"function",
"recreate",
"(",
"makeStream",
",",
"options",
")",
"{",
"if",
"(",
"options",
"===",
"undefined",
"&&",
"isObject",
"(",
"makeStream",
")",
")",
"{",
"options",
"=",
"makeStream",
";",
"makeStream",
"=",
"options",
".",
"makeStream",
";",
"}",... | Create wrapper stream which takes care of recreating logic.
@param {Function} makeStream a function which returns a stream
@param {Object} | [
"Create",
"wrapper",
"stream",
"which",
"takes",
"care",
"of",
"recreating",
"logic",
"."
] | ed814ceb3e6d8c943f9cff919f64a426a196399a | https://github.com/andreypopp/stream-recreate/blob/ed814ceb3e6d8c943f9cff919f64a426a196399a/index.js#L19-L104 | train |
shama/grunt-net | tasks/net.js | createServer | function createServer() {
grunt.log.ok('Registered as a grunt-net server [' + host + ':' + port + '].');
dnode({ spawn: spawn }).listen(host, port);
} | javascript | function createServer() {
grunt.log.ok('Registered as a grunt-net server [' + host + ':' + port + '].');
dnode({ spawn: spawn }).listen(host, port);
} | [
"function",
"createServer",
"(",
")",
"{",
"grunt",
".",
"log",
".",
"ok",
"(",
"'Registered as a grunt-net server ['",
"+",
"host",
"+",
"':'",
"+",
"port",
"+",
"'].'",
")",
";",
"dnode",
"(",
"{",
"spawn",
":",
"spawn",
"}",
")",
".",
"listen",
"(",... | create a server | [
"create",
"a",
"server"
] | 19fc0969e14e5db3207dd42b2ac1d76464e7da86 | https://github.com/shama/grunt-net/blob/19fc0969e14e5db3207dd42b2ac1d76464e7da86/tasks/net.js#L39-L42 | train |
je3f0o/jeefo_preprocessor | src/preprocessor.js | function (token) {
var pp = new JavascriptPreprocessor(this.parser, this.compiler, this.actions, this.scope, this.state);
if (token) {
pp.code = this.get_code(this.code, token);
}
return pp;
} | javascript | function (token) {
var pp = new JavascriptPreprocessor(this.parser, this.compiler, this.actions, this.scope, this.state);
if (token) {
pp.code = this.get_code(this.code, token);
}
return pp;
} | [
"function",
"(",
"token",
")",
"{",
"var",
"pp",
"=",
"new",
"JavascriptPreprocessor",
"(",
"this",
".",
"parser",
",",
"this",
".",
"compiler",
",",
"this",
".",
"actions",
",",
"this",
".",
"scope",
",",
"this",
".",
"state",
")",
";",
"if",
"(",
... | Utils {{{1 | [
"Utils",
"{{{",
"1"
] | 77050d8b2c1856a29a04d6de4fa602d05357175b | https://github.com/je3f0o/jeefo_preprocessor/blob/77050d8b2c1856a29a04d6de4fa602d05357175b/src/preprocessor.js#L26-L32 | train | |
je3f0o/jeefo_preprocessor | src/preprocessor.js | function (action) {
if (action) {
switch (action.type) {
case "replace" :
this.code = `${ this.code.substr(0, action.start) }${ action.value }${ this.code.substr(action.end) }`;
return true;
case "remove" :
this.code = `${ this.code.substr(0, action.start) }${ this.code.substr(action.end) }`... | javascript | function (action) {
if (action) {
switch (action.type) {
case "replace" :
this.code = `${ this.code.substr(0, action.start) }${ action.value }${ this.code.substr(action.end) }`;
return true;
case "remove" :
this.code = `${ this.code.substr(0, action.start) }${ this.code.substr(action.end) }`... | [
"function",
"(",
"action",
")",
"{",
"if",
"(",
"action",
")",
"{",
"switch",
"(",
"action",
".",
"type",
")",
"{",
"case",
"\"replace\"",
":",
"this",
".",
"code",
"=",
"`",
"${",
"this",
".",
"code",
".",
"substr",
"(",
"0",
",",
"action",
".",... | Actions {{{1 | [
"Actions",
"{{{",
"1"
] | 77050d8b2c1856a29a04d6de4fa602d05357175b | https://github.com/je3f0o/jeefo_preprocessor/blob/77050d8b2c1856a29a04d6de4fa602d05357175b/src/preprocessor.js#L39-L50 | train | |
je3f0o/jeefo_preprocessor | src/preprocessor.js | function (name, definition, is_return) {
var pp = this.$new(),
code = `PP.define("${ name }", ${ definition.toString() }, ${ is_return });`;
pp.scope = this.scope;
pp.process("[IN MEMORY]", code);
} | javascript | function (name, definition, is_return) {
var pp = this.$new(),
code = `PP.define("${ name }", ${ definition.toString() }, ${ is_return });`;
pp.scope = this.scope;
pp.process("[IN MEMORY]", code);
} | [
"function",
"(",
"name",
",",
"definition",
",",
"is_return",
")",
"{",
"var",
"pp",
"=",
"this",
".",
"$new",
"(",
")",
",",
"code",
"=",
"`",
"${",
"name",
"}",
"${",
"definition",
".",
"toString",
"(",
")",
"}",
"${",
"is_return",
"}",
"`",
";... | Define {{{1 | [
"Define",
"{{{",
"1"
] | 77050d8b2c1856a29a04d6de4fa602d05357175b | https://github.com/je3f0o/jeefo_preprocessor/blob/77050d8b2c1856a29a04d6de4fa602d05357175b/src/preprocessor.js#L70-L76 | train | |
je3f0o/jeefo_preprocessor | src/preprocessor.js | function (code, tokens) {
var actions = [], i = 0;
this.code = code;
for (; i < tokens.length; ++i) {
actions[i] = this.actions.invoke(this, tokens[i]);
}
i = actions.length;
while (i--) {
this.action(actions[i]);
}
return this.code;
} | javascript | function (code, tokens) {
var actions = [], i = 0;
this.code = code;
for (; i < tokens.length; ++i) {
actions[i] = this.actions.invoke(this, tokens[i]);
}
i = actions.length;
while (i--) {
this.action(actions[i]);
}
return this.code;
} | [
"function",
"(",
"code",
",",
"tokens",
")",
"{",
"var",
"actions",
"=",
"[",
"]",
",",
"i",
"=",
"0",
";",
"this",
".",
"code",
"=",
"code",
";",
"for",
"(",
";",
"i",
"<",
"tokens",
".",
"length",
";",
"++",
"i",
")",
"{",
"actions",
"[",
... | Processor {{{1 | [
"Processor",
"{{{",
"1"
] | 77050d8b2c1856a29a04d6de4fa602d05357175b | https://github.com/je3f0o/jeefo_preprocessor/blob/77050d8b2c1856a29a04d6de4fa602d05357175b/src/preprocessor.js#L138-L153 | train | |
je3f0o/jeefo_preprocessor | src/preprocessor.js | function (code) {
try {
return this.parser.parse(code);
} catch(e) {
console.log("E", e);
console.log(code);
process.exit();
}
} | javascript | function (code) {
try {
return this.parser.parse(code);
} catch(e) {
console.log("E", e);
console.log(code);
process.exit();
}
} | [
"function",
"(",
"code",
")",
"{",
"try",
"{",
"return",
"this",
".",
"parser",
".",
"parse",
"(",
"code",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"console",
".",
"log",
"(",
"\"E\"",
",",
"e",
")",
";",
"console",
".",
"log",
"(",
"code",
... | Parser {{{1 | [
"Parser",
"{{{",
"1"
] | 77050d8b2c1856a29a04d6de4fa602d05357175b | https://github.com/je3f0o/jeefo_preprocessor/blob/77050d8b2c1856a29a04d6de4fa602d05357175b/src/preprocessor.js#L160-L168 | train | |
bvalosek/sack | lib/Container.js | callNew | function callNew(T, args)
{
return new (Function.prototype.bind.apply(T, [null].concat(args)));
} | javascript | function callNew(T, args)
{
return new (Function.prototype.bind.apply(T, [null].concat(args)));
} | [
"function",
"callNew",
"(",
"T",
",",
"args",
")",
"{",
"return",
"new",
"(",
"Function",
".",
"prototype",
".",
"bind",
".",
"apply",
"(",
"T",
",",
"[",
"null",
"]",
".",
"concat",
"(",
"args",
")",
")",
")",
";",
"}"
] | Give us a way to instantiate a new class with an array of args
@private | [
"Give",
"us",
"a",
"way",
"to",
"instantiate",
"a",
"new",
"class",
"with",
"an",
"array",
"of",
"args"
] | 65e2ab133b6c40400c200c2e071052dea6b23c24 | https://github.com/bvalosek/sack/blob/65e2ab133b6c40400c200c2e071052dea6b23c24/lib/Container.js#L222-L225 | train |
patgrasso/parsey | lib/parser.js | earley | function earley(tokens, grammar) {
let states = Array.apply(null, Array(tokens.length + 1)).map(() => []);
var i, j;
let rulePairs = grammar.map((rule) => ({
name : rule.lhs.name,
rule : rule,
position: 0,
origin : 0
}));
[].push.apply(states[0], rulePairs);
for (i = 0; i <= token... | javascript | function earley(tokens, grammar) {
let states = Array.apply(null, Array(tokens.length + 1)).map(() => []);
var i, j;
let rulePairs = grammar.map((rule) => ({
name : rule.lhs.name,
rule : rule,
position: 0,
origin : 0
}));
[].push.apply(states[0], rulePairs);
for (i = 0; i <= token... | [
"function",
"earley",
"(",
"tokens",
",",
"grammar",
")",
"{",
"let",
"states",
"=",
"Array",
".",
"apply",
"(",
"null",
",",
"Array",
"(",
"tokens",
".",
"length",
"+",
"1",
")",
")",
".",
"map",
"(",
"(",
")",
"=>",
"[",
"]",
")",
";",
"var",... | Parses the input tokens using the earley top-down chart parsing algorithm
to product a set of states, each containing a list of earley items
@function earley
@memberof module:lib/parser
@param {string[]} tokens - Sequence of symbols to be parsed
@param {Rule[]|CFG} grammar - Set of rules that define a language
@return... | [
"Parses",
"the",
"input",
"tokens",
"using",
"the",
"earley",
"top",
"-",
"down",
"chart",
"parsing",
"algorithm",
"to",
"product",
"a",
"set",
"of",
"states",
"each",
"containing",
"a",
"list",
"of",
"earley",
"items"
] | d28b3f330ee03b5c273f1ce5871a5b86dac79fb0 | https://github.com/patgrasso/parsey/blob/d28b3f330ee03b5c273f1ce5871a5b86dac79fb0/lib/parser.js#L64-L86 | train |
patgrasso/parsey | lib/parser.js | removeUnfinishedItems | function removeUnfinishedItems(states) {
return states.map((state) => state.filter((earleyItem) => {
return earleyItem.position >= earleyItem.rule.length;
}));
} | javascript | function removeUnfinishedItems(states) {
return states.map((state) => state.filter((earleyItem) => {
return earleyItem.position >= earleyItem.rule.length;
}));
} | [
"function",
"removeUnfinishedItems",
"(",
"states",
")",
"{",
"return",
"states",
".",
"map",
"(",
"(",
"state",
")",
"=>",
"state",
".",
"filter",
"(",
"(",
"earleyItem",
")",
"=>",
"{",
"return",
"earleyItem",
".",
"position",
">=",
"earleyItem",
".",
... | Removes earley items from each state that failed to completely parse through.
In other words, removes earley items whose position is less than the length
of its rule
@function removeUnfinishedItems
@param {state[]} states - Set of lists of earley items
@return {state[]} Set of lists of completed earley items | [
"Removes",
"earley",
"items",
"from",
"each",
"state",
"that",
"failed",
"to",
"completely",
"parse",
"through",
".",
"In",
"other",
"words",
"removes",
"earley",
"items",
"whose",
"position",
"is",
"less",
"than",
"the",
"length",
"of",
"its",
"rule"
] | d28b3f330ee03b5c273f1ce5871a5b86dac79fb0 | https://github.com/patgrasso/parsey/blob/d28b3f330ee03b5c273f1ce5871a5b86dac79fb0/lib/parser.js#L206-L210 | train |
patgrasso/parsey | lib/parser.js | swap | function swap(states) {
let newStates = Array.apply(null, Array(states.length)).map(() => []);
states.forEach((state, i) => {
state.forEach((earleyItem) => {
newStates[earleyItem.origin].push(earleyItem);
earleyItem.origin = i;
});
});
return newStates;
} | javascript | function swap(states) {
let newStates = Array.apply(null, Array(states.length)).map(() => []);
states.forEach((state, i) => {
state.forEach((earleyItem) => {
newStates[earleyItem.origin].push(earleyItem);
earleyItem.origin = i;
});
});
return newStates;
} | [
"function",
"swap",
"(",
"states",
")",
"{",
"let",
"newStates",
"=",
"Array",
".",
"apply",
"(",
"null",
",",
"Array",
"(",
"states",
".",
"length",
")",
")",
".",
"map",
"(",
"(",
")",
"=>",
"[",
"]",
")",
";",
"states",
".",
"forEach",
"(",
... | Places earley items in the states in which they originated, as opposed to the
states in which they finished parsing, and set their `origin` properties to
the state in which they finished.
This allows a depth-first search of the chart to move forwards through the
graph, which is more intuitive than having to move backw... | [
"Places",
"earley",
"items",
"in",
"the",
"states",
"in",
"which",
"they",
"originated",
"as",
"opposed",
"to",
"the",
"states",
"in",
"which",
"they",
"finished",
"parsing",
"and",
"set",
"their",
"origin",
"properties",
"to",
"the",
"state",
"in",
"which",... | d28b3f330ee03b5c273f1ce5871a5b86dac79fb0 | https://github.com/patgrasso/parsey/blob/d28b3f330ee03b5c273f1ce5871a5b86dac79fb0/lib/parser.js#L227-L237 | train |
patgrasso/parsey | lib/parser.js | dfsHelper | function dfsHelper(states, root, state, depth, tokens) {
var edges;
// Base case: we finished the root rule
if (state === root.origin && depth === root.rule.length) {
return [];
}
// If the current production symbol is a terminal
if (root.rule[depth] instanceof RegExp) {
if (root.rule[depth].test(... | javascript | function dfsHelper(states, root, state, depth, tokens) {
var edges;
// Base case: we finished the root rule
if (state === root.origin && depth === root.rule.length) {
return [];
}
// If the current production symbol is a terminal
if (root.rule[depth] instanceof RegExp) {
if (root.rule[depth].test(... | [
"function",
"dfsHelper",
"(",
"states",
",",
"root",
",",
"state",
",",
"depth",
",",
"tokens",
")",
"{",
"var",
"edges",
";",
"// Base case: we finished the root rule",
"if",
"(",
"state",
"===",
"root",
".",
"origin",
"&&",
"depth",
"===",
"root",
".",
"... | Recursive function that explores a specific earley item, constructs the parse
tree for it, then sends it up the chimney!
@function dfsHelper
@param {state[]} states - Set of lists of earley items
@param {earleyItem} root - Current earley item being explored, a tree for
which is to be constructed
@param {number} state ... | [
"Recursive",
"function",
"that",
"explores",
"a",
"specific",
"earley",
"item",
"constructs",
"the",
"parse",
"tree",
"for",
"it",
"then",
"sends",
"it",
"up",
"the",
"chimney!"
] | d28b3f330ee03b5c273f1ce5871a5b86dac79fb0 | https://github.com/patgrasso/parsey/blob/d28b3f330ee03b5c273f1ce5871a5b86dac79fb0/lib/parser.js#L309-L366 | train |
tests-always-included/ddq-backend-mock | lib/ddq-backend-mock.js | remove | function remove(ddqBackendInstance, recordId, callback) {
// Note, this is not what we want.
// it does not handle the times when the
// isProcessing flag is true.
ddqBackendInstance.deleteData(recordId);
ddqBackendInstance.checkAndEmitData();
callback();
} | javascript | function remove(ddqBackendInstance, recordId, callback) {
// Note, this is not what we want.
// it does not handle the times when the
// isProcessing flag is true.
ddqBackendInstance.deleteData(recordId);
ddqBackendInstance.checkAndEmitData();
callback();
} | [
"function",
"remove",
"(",
"ddqBackendInstance",
",",
"recordId",
",",
"callback",
")",
"{",
"// Note, this is not what we want.",
"// it does not handle the times when the",
"// isProcessing flag is true.",
"ddqBackendInstance",
".",
"deleteData",
"(",
"recordId",
")",
";",
... | Removes the message from stored data.
@param {Object} ddqBackendInstance
@param {string} recordId
@param {Function} callback | [
"Removes",
"the",
"message",
"from",
"stored",
"data",
"."
] | 7d3cbf25a4533db9dac68193ac0af648ee38a435 | https://github.com/tests-always-included/ddq-backend-mock/blob/7d3cbf25a4533db9dac68193ac0af648ee38a435/lib/ddq-backend-mock.js#L59-L66 | train |
tests-always-included/ddq-backend-mock | lib/ddq-backend-mock.js | requeue | function requeue(ddqBackendInstance, recordId, callback) {
var record;
record = ddqBackendInstance.getRecord(recordId);
record.isProcessing = false;
record.requeued = true;
callback();
} | javascript | function requeue(ddqBackendInstance, recordId, callback) {
var record;
record = ddqBackendInstance.getRecord(recordId);
record.isProcessing = false;
record.requeued = true;
callback();
} | [
"function",
"requeue",
"(",
"ddqBackendInstance",
",",
"recordId",
",",
"callback",
")",
"{",
"var",
"record",
";",
"record",
"=",
"ddqBackendInstance",
".",
"getRecord",
"(",
"recordId",
")",
";",
"record",
".",
"isProcessing",
"=",
"false",
";",
"record",
... | Sets the record to be requeued so another listener can pick it up
and try to process the message again.
@param {Object} ddqBackendInstance
@param {string} recordId
@param {Function} callback | [
"Sets",
"the",
"record",
"to",
"be",
"requeued",
"so",
"another",
"listener",
"can",
"pick",
"it",
"up",
"and",
"try",
"to",
"process",
"the",
"message",
"again",
"."
] | 7d3cbf25a4533db9dac68193ac0af648ee38a435 | https://github.com/tests-always-included/ddq-backend-mock/blob/7d3cbf25a4533db9dac68193ac0af648ee38a435/lib/ddq-backend-mock.js#L77-L84 | train |
binder-project/binder-health-checker | lib/cli.js | Command | function Command (name, cli, action) {
if (!(this instanceof Command)) {
return new Command(name, cli, action)
}
this.name = name
this.cli = cli
this.action = action
} | javascript | function Command (name, cli, action) {
if (!(this instanceof Command)) {
return new Command(name, cli, action)
}
this.name = name
this.cli = cli
this.action = action
} | [
"function",
"Command",
"(",
"name",
",",
"cli",
",",
"action",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Command",
")",
")",
"{",
"return",
"new",
"Command",
"(",
"name",
",",
"cli",
",",
"action",
")",
"}",
"this",
".",
"name",
"=",
... | The argument-parsing and action components of a CLI command are separated so that the CLI
can both be imported from other modules and launched via PM2 | [
"The",
"argument",
"-",
"parsing",
"and",
"action",
"components",
"of",
"a",
"CLI",
"command",
"are",
"separated",
"so",
"that",
"the",
"CLI",
"can",
"both",
"be",
"imported",
"from",
"other",
"modules",
"and",
"launched",
"via",
"PM2"
] | 7c6c7973464c42a67b7f860ca6cceb40f29c1e5e | https://github.com/binder-project/binder-health-checker/blob/7c6c7973464c42a67b7f860ca6cceb40f29c1e5e/lib/cli.js#L13-L20 | train |
peerigon/alamid-sorted-array | lib/sortedArray.js | sortedArray | function sortedArray(arr, comparator1, comparator2, comparator3) {
var _ = {};
arr = arr || [];
if (typeof arr._sortedArray === "object") {
throw new Error("(sortedArray) Cannot extend array: Special key _sortedArray is already defined. Did you apply it twice?");
}
arr._sortedArray = _;
... | javascript | function sortedArray(arr, comparator1, comparator2, comparator3) {
var _ = {};
arr = arr || [];
if (typeof arr._sortedArray === "object") {
throw new Error("(sortedArray) Cannot extend array: Special key _sortedArray is already defined. Did you apply it twice?");
}
arr._sortedArray = _;
... | [
"function",
"sortedArray",
"(",
"arr",
",",
"comparator1",
",",
"comparator2",
",",
"comparator3",
")",
"{",
"var",
"_",
"=",
"{",
"}",
";",
"arr",
"=",
"arr",
"||",
"[",
"]",
";",
"if",
"(",
"typeof",
"arr",
".",
"_sortedArray",
"===",
"\"object\"",
... | Turns an array or every object with an array-like interface into a sorted array that maintains the sort order.
This is basically achieved by replacing the original mutator methods with versions that respect the order.
If the supplied array has a comparator-function, this function will be used for comparison.
You may ... | [
"Turns",
"an",
"array",
"or",
"every",
"object",
"with",
"an",
"array",
"-",
"like",
"interface",
"into",
"a",
"sorted",
"array",
"that",
"maintains",
"the",
"sort",
"order",
".",
"This",
"is",
"basically",
"achieved",
"by",
"replacing",
"the",
"original",
... | 59d58fd3b94d26c873c2a4ba2ecd18758309bd0b | https://github.com/peerigon/alamid-sorted-array/blob/59d58fd3b94d26c873c2a4ba2ecd18758309bd0b/lib/sortedArray.js#L21-L60 | train |
peerigon/alamid-sorted-array | lib/sortedArray.js | indexOf | function indexOf(element, fromIndex) {
/* jshint validthis:true */
var arr = toArray(this),
index;
if (fromIndex) {
arr = arr.slice(fromIndex);
}
index = binarySearch(arr, element, this.comparator);
if (index < 0) {
return -1;
} else {
return index;
}
} | javascript | function indexOf(element, fromIndex) {
/* jshint validthis:true */
var arr = toArray(this),
index;
if (fromIndex) {
arr = arr.slice(fromIndex);
}
index = binarySearch(arr, element, this.comparator);
if (index < 0) {
return -1;
} else {
return index;
}
} | [
"function",
"indexOf",
"(",
"element",
",",
"fromIndex",
")",
"{",
"/* jshint validthis:true */",
"var",
"arr",
"=",
"toArray",
"(",
"this",
")",
",",
"index",
";",
"if",
"(",
"fromIndex",
")",
"{",
"arr",
"=",
"arr",
".",
"slice",
"(",
"fromIndex",
")",... | Works like Array.prototype.indexOf but uses a faster binary search.
Same signature as Array.prototype.indexOf
@see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf | [
"Works",
"like",
"Array",
".",
"prototype",
".",
"indexOf",
"but",
"uses",
"a",
"faster",
"binary",
"search",
"."
] | 59d58fd3b94d26c873c2a4ba2ecd18758309bd0b | https://github.com/peerigon/alamid-sorted-array/blob/59d58fd3b94d26c873c2a4ba2ecd18758309bd0b/lib/sortedArray.js#L109-L125 | train |
peerigon/alamid-sorted-array | lib/sortedArray.js | reverse | function reverse() {
/* jshint validthis:true */
var _ = this._sortedArray,
reversed = _.reversed;
if (reversed) {
this.comparator = this.comparator.original;
} else {
this.comparator = getInversionOf(this.comparator);
}
_.reversed = !reversed;
_.reverse.call(this);... | javascript | function reverse() {
/* jshint validthis:true */
var _ = this._sortedArray,
reversed = _.reversed;
if (reversed) {
this.comparator = this.comparator.original;
} else {
this.comparator = getInversionOf(this.comparator);
}
_.reversed = !reversed;
_.reverse.call(this);... | [
"function",
"reverse",
"(",
")",
"{",
"/* jshint validthis:true */",
"var",
"_",
"=",
"this",
".",
"_sortedArray",
",",
"reversed",
"=",
"_",
".",
"reversed",
";",
"if",
"(",
"reversed",
")",
"{",
"this",
".",
"comparator",
"=",
"this",
".",
"comparator",
... | Works like Array.prototype.reverse.
Please note that this function wraps the current arr.comparator in order to invert the result. Reverting it back
removes the wrapper.
Same signature as Array.prototype.reverse
@see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse | [
"Works",
"like",
"Array",
".",
"prototype",
".",
"reverse",
"."
] | 59d58fd3b94d26c873c2a4ba2ecd18758309bd0b | https://github.com/peerigon/alamid-sorted-array/blob/59d58fd3b94d26c873c2a4ba2ecd18758309bd0b/lib/sortedArray.js#L167-L180 | train |
peerigon/alamid-sorted-array | lib/sortedArray.js | sortedIndex | function sortedIndex(element) {
/* jshint validthis:true */
var index = binarySearch(toArray(this), element, this.comparator);
if (index < 0) {
// binarySearch decreases the negative index by one because otherwise the index 0 would stand for two results
// @see https://github.com/darkskyapp... | javascript | function sortedIndex(element) {
/* jshint validthis:true */
var index = binarySearch(toArray(this), element, this.comparator);
if (index < 0) {
// binarySearch decreases the negative index by one because otherwise the index 0 would stand for two results
// @see https://github.com/darkskyapp... | [
"function",
"sortedIndex",
"(",
"element",
")",
"{",
"/* jshint validthis:true */",
"var",
"index",
"=",
"binarySearch",
"(",
"toArray",
"(",
"this",
")",
",",
"element",
",",
"this",
".",
"comparator",
")",
";",
"if",
"(",
"index",
"<",
"0",
")",
"{",
"... | Returns the index where the given element would be inserted.
@param {*} element
@returns {Number} | [
"Returns",
"the",
"index",
"where",
"the",
"given",
"element",
"would",
"be",
"inserted",
"."
] | 59d58fd3b94d26c873c2a4ba2ecd18758309bd0b | https://github.com/peerigon/alamid-sorted-array/blob/59d58fd3b94d26c873c2a4ba2ecd18758309bd0b/lib/sortedArray.js#L188-L199 | train |
peerigon/alamid-sorted-array | lib/sortedArray.js | pushSingle | function pushSingle(arr, element) {
var index = arr.sortedIndex(element),
_ = arr._sortedArray;
// original push and unshift are faster than splice
if (index === 0) {
_.unshift.call(arr, element);
} else if (index === arr.length) {
_.push.call(arr, element);
} else {
... | javascript | function pushSingle(arr, element) {
var index = arr.sortedIndex(element),
_ = arr._sortedArray;
// original push and unshift are faster than splice
if (index === 0) {
_.unshift.call(arr, element);
} else if (index === arr.length) {
_.push.call(arr, element);
} else {
... | [
"function",
"pushSingle",
"(",
"arr",
",",
"element",
")",
"{",
"var",
"index",
"=",
"arr",
".",
"sortedIndex",
"(",
"element",
")",
",",
"_",
"=",
"arr",
".",
"_sortedArray",
";",
"// original push and unshift are faster than splice",
"if",
"(",
"index",
"===... | Performs a push of a single element. Used by push, unshift, splice.
@private
@param {Array} arr
@param {*} element | [
"Performs",
"a",
"push",
"of",
"a",
"single",
"element",
".",
"Used",
"by",
"push",
"unshift",
"splice",
"."
] | 59d58fd3b94d26c873c2a4ba2ecd18758309bd0b | https://github.com/peerigon/alamid-sorted-array/blob/59d58fd3b94d26c873c2a4ba2ecd18758309bd0b/lib/sortedArray.js#L208-L220 | train |
peerigon/alamid-sorted-array | lib/sortedArray.js | getInversionOf | function getInversionOf(comparator) {
function inversion(a, b) {
return -comparator(a, b);
}
inversion.original = comparator;
return inversion;
} | javascript | function getInversionOf(comparator) {
function inversion(a, b) {
return -comparator(a, b);
}
inversion.original = comparator;
return inversion;
} | [
"function",
"getInversionOf",
"(",
"comparator",
")",
"{",
"function",
"inversion",
"(",
"a",
",",
"b",
")",
"{",
"return",
"-",
"comparator",
"(",
"a",
",",
"b",
")",
";",
"}",
"inversion",
".",
"original",
"=",
"comparator",
";",
"return",
"inversion",... | Inverts the given comparator so the array will be sorted reversed.
The original comparator is saved so it can be restored.
@private
@param {Function} comparator
@returns {Function} | [
"Inverts",
"the",
"given",
"comparator",
"so",
"the",
"array",
"will",
"be",
"sorted",
"reversed",
".",
"The",
"original",
"comparator",
"is",
"saved",
"so",
"it",
"can",
"be",
"restored",
"."
] | 59d58fd3b94d26c873c2a4ba2ecd18758309bd0b | https://github.com/peerigon/alamid-sorted-array/blob/59d58fd3b94d26c873c2a4ba2ecd18758309bd0b/lib/sortedArray.js#L230-L238 | train |
peerigon/alamid-sorted-array | lib/sortedArray.js | multipleComparators | function multipleComparators(comparators) {
return function applyComparators(a, b) {
var i,
result;
for (i = 0; i < comparators.length; i++) {
result = comparators[i](a, b);
if (result !== 0) {
return result;
}
}
retur... | javascript | function multipleComparators(comparators) {
return function applyComparators(a, b) {
var i,
result;
for (i = 0; i < comparators.length; i++) {
result = comparators[i](a, b);
if (result !== 0) {
return result;
}
}
retur... | [
"function",
"multipleComparators",
"(",
"comparators",
")",
"{",
"return",
"function",
"applyComparators",
"(",
"a",
",",
"b",
")",
"{",
"var",
"i",
",",
"result",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"comparators",
".",
"length",
";",
"i",
... | Returns a single comparator which tries all given comparators one after another
and stops if one of them returned another value than 0.
If the end is reached the defaultComparator is applied.
@private
@param {Array} comparators
@returns {Function} | [
"Returns",
"a",
"single",
"comparator",
"which",
"tries",
"all",
"given",
"comparators",
"one",
"after",
"another",
"and",
"stops",
"if",
"one",
"of",
"them",
"returned",
"another",
"value",
"than",
"0",
"."
] | 59d58fd3b94d26c873c2a4ba2ecd18758309bd0b | https://github.com/peerigon/alamid-sorted-array/blob/59d58fd3b94d26c873c2a4ba2ecd18758309bd0b/lib/sortedArray.js#L299-L313 | train |
phated/grunt-enyo | tasks/init/enyo/root/enyo/source/dom/Control.js | function(inName, inValue) {
this.attributes[inName] = inValue;
if (this.hasNode()) {
this.attributeToNode(inName, inValue);
}
this.invalidateTags();
} | javascript | function(inName, inValue) {
this.attributes[inName] = inValue;
if (this.hasNode()) {
this.attributeToNode(inName, inValue);
}
this.invalidateTags();
} | [
"function",
"(",
"inName",
",",
"inValue",
")",
"{",
"this",
".",
"attributes",
"[",
"inName",
"]",
"=",
"inValue",
";",
"if",
"(",
"this",
".",
"hasNode",
"(",
")",
")",
"{",
"this",
".",
"attributeToNode",
"(",
"inName",
",",
"inValue",
")",
";",
... | Sets the value of an attribute on this object. Pass null _inValue_ to remove an attribute.
set the tabIndex attribute for this DomNode
this.setAttribute("tabIndex", 3);
...
remove the index attribute
this.setAttribute("index", null); | [
"Sets",
"the",
"value",
"of",
"an",
"attribute",
"on",
"this",
"object",
".",
"Pass",
"null",
"_inValue_",
"to",
"remove",
"an",
"attribute",
"."
] | d2990ee4cd85eea8db4108c43086c6d8c3c90c30 | https://github.com/phated/grunt-enyo/blob/d2990ee4cd85eea8db4108c43086c6d8c3c90c30/tasks/init/enyo/root/enyo/source/dom/Control.js#L177-L183 | train | |
phated/grunt-enyo | tasks/init/enyo/root/enyo/source/dom/Control.js | function(inClass) {
if (inClass && !this.hasClass(inClass)) {
var c = this.getClassAttribute();
this.setClassAttribute(c + (c ? " " : "") + inClass);
}
} | javascript | function(inClass) {
if (inClass && !this.hasClass(inClass)) {
var c = this.getClassAttribute();
this.setClassAttribute(c + (c ? " " : "") + inClass);
}
} | [
"function",
"(",
"inClass",
")",
"{",
"if",
"(",
"inClass",
"&&",
"!",
"this",
".",
"hasClass",
"(",
"inClass",
")",
")",
"{",
"var",
"c",
"=",
"this",
".",
"getClassAttribute",
"(",
")",
";",
"this",
".",
"setClassAttribute",
"(",
"c",
"+",
"(",
"... | Adds CSS class name _inClass_ to the _class_ attribute of this object.
add the highlight class to this object
this.addClass("highlight"); | [
"Adds",
"CSS",
"class",
"name",
"_inClass_",
"to",
"the",
"_class_",
"attribute",
"of",
"this",
"object",
"."
] | d2990ee4cd85eea8db4108c43086c6d8c3c90c30 | https://github.com/phated/grunt-enyo/blob/d2990ee4cd85eea8db4108c43086c6d8c3c90c30/tasks/init/enyo/root/enyo/source/dom/Control.js#L235-L240 | train | |
phated/grunt-enyo | tasks/init/enyo/root/enyo/source/dom/Control.js | function(inClass) {
if (inClass && this.hasClass(inClass)) {
var c = this.getClassAttribute();
c = (" " + c + " ").replace(" " + inClass + " ", " ").slice(1, -1);
this.setClassAttribute(c);
}
} | javascript | function(inClass) {
if (inClass && this.hasClass(inClass)) {
var c = this.getClassAttribute();
c = (" " + c + " ").replace(" " + inClass + " ", " ").slice(1, -1);
this.setClassAttribute(c);
}
} | [
"function",
"(",
"inClass",
")",
"{",
"if",
"(",
"inClass",
"&&",
"this",
".",
"hasClass",
"(",
"inClass",
")",
")",
"{",
"var",
"c",
"=",
"this",
".",
"getClassAttribute",
"(",
")",
";",
"c",
"=",
"(",
"\" \"",
"+",
"c",
"+",
"\" \"",
")",
".",
... | Removes substring _inClass_ from the _class_ attribute of this object.
_inClass_ must have no leading or trailing spaces.
Using a compound class name is supported, but the name is treated atomically.
For example, given "a b c", removeClass("a b") will produce "c", but removeClass("a c") will produce "a b c".
remove ... | [
"Removes",
"substring",
"_inClass_",
"from",
"the",
"_class_",
"attribute",
"of",
"this",
"object",
"."
] | d2990ee4cd85eea8db4108c43086c6d8c3c90c30 | https://github.com/phated/grunt-enyo/blob/d2990ee4cd85eea8db4108c43086c6d8c3c90c30/tasks/init/enyo/root/enyo/source/dom/Control.js#L252-L258 | train | |
phated/grunt-enyo | tasks/init/enyo/root/enyo/source/dom/Control.js | function(inParentNode) {
// clean up render flags and memoizations
this.teardownRender();
// inParentNode can be a string id or a node reference
var pn = enyo.dom.byId(inParentNode);
if (pn == document.body) {
this.setupBodyFitting();
} else if (this.fit) {
this.addClass("enyo-fit enyo-clip");
}
/... | javascript | function(inParentNode) {
// clean up render flags and memoizations
this.teardownRender();
// inParentNode can be a string id or a node reference
var pn = enyo.dom.byId(inParentNode);
if (pn == document.body) {
this.setupBodyFitting();
} else if (this.fit) {
this.addClass("enyo-fit enyo-clip");
}
/... | [
"function",
"(",
"inParentNode",
")",
"{",
"// clean up render flags and memoizations",
"this",
".",
"teardownRender",
"(",
")",
";",
"// inParentNode can be a string id or a node reference",
"var",
"pn",
"=",
"enyo",
".",
"dom",
".",
"byId",
"(",
"inParentNode",
")",
... | Renders this object into the DOM node referenced by _inParentNode_.
If rendering into the document body element, appropriate styles will
be used to have it expand to fill the whole window. | [
"Renders",
"this",
"object",
"into",
"the",
"DOM",
"node",
"referenced",
"by",
"_inParentNode_",
".",
"If",
"rendering",
"into",
"the",
"document",
"body",
"element",
"appropriate",
"styles",
"will",
"be",
"used",
"to",
"have",
"it",
"expand",
"to",
"fill",
... | d2990ee4cd85eea8db4108c43086c6d8c3c90c30 | https://github.com/phated/grunt-enyo/blob/d2990ee4cd85eea8db4108c43086c6d8c3c90c30/tasks/init/enyo/root/enyo/source/dom/Control.js#L365-L381 | train | |
phated/grunt-enyo | tasks/init/enyo/root/enyo/source/dom/Control.js | function(inBounds, inUnit) {
var s = this.domStyles, unit = inUnit || "px";
var extents = ["width", "height", "left", "top", "right", "bottom"];
for (var i=0, b, e; e=extents[i]; i++) {
b = inBounds[e];
if (b || b === 0) {
s[e] = b + (!enyo.isString(b) ? unit : '');
}
}
this.domStylesChanged();
... | javascript | function(inBounds, inUnit) {
var s = this.domStyles, unit = inUnit || "px";
var extents = ["width", "height", "left", "top", "right", "bottom"];
for (var i=0, b, e; e=extents[i]; i++) {
b = inBounds[e];
if (b || b === 0) {
s[e] = b + (!enyo.isString(b) ? unit : '');
}
}
this.domStylesChanged();
... | [
"function",
"(",
"inBounds",
",",
"inUnit",
")",
"{",
"var",
"s",
"=",
"this",
".",
"domStyles",
",",
"unit",
"=",
"inUnit",
"||",
"\"px\"",
";",
"var",
"extents",
"=",
"[",
"\"width\"",
",",
"\"height\"",
",",
"\"left\"",
",",
"\"top\"",
",",
"\"right... | Sets any or all of geometry style properties _width_, _height_, _left_, _top_, _right_ and _bottom_.
Values may be specified as strings (with units specified), or as numbers when a unit is provided in _inUnit_.
this.setBounds({width: 100, height: 100}, "px"); // adds style properties like "width: 100px; height: 100px... | [
"Sets",
"any",
"or",
"all",
"of",
"geometry",
"style",
"properties",
"_width_",
"_height_",
"_left_",
"_top_",
"_right_",
"and",
"_bottom_",
"."
] | d2990ee4cd85eea8db4108c43086c6d8c3c90c30 | https://github.com/phated/grunt-enyo/blob/d2990ee4cd85eea8db4108c43086c6d8c3c90c30/tasks/init/enyo/root/enyo/source/dom/Control.js#L452-L462 | train | |
phated/grunt-enyo | tasks/init/enyo/root/enyo/source/dom/Control.js | function(inName, inValue) {
if (inValue === null || inValue === false || inValue === "") {
this.node.removeAttribute(inName);
} else {
this.node.setAttribute(inName, inValue);
}
} | javascript | function(inName, inValue) {
if (inValue === null || inValue === false || inValue === "") {
this.node.removeAttribute(inName);
} else {
this.node.setAttribute(inName, inValue);
}
} | [
"function",
"(",
"inName",
",",
"inValue",
")",
"{",
"if",
"(",
"inValue",
"===",
"null",
"||",
"inValue",
"===",
"false",
"||",
"inValue",
"===",
"\"\"",
")",
"{",
"this",
".",
"node",
".",
"removeAttribute",
"(",
"inName",
")",
";",
"}",
"else",
"{... | DOM, aka direct-to-node, rendering | [
"DOM",
"aka",
"direct",
"-",
"to",
"-",
"node",
"rendering"
] | d2990ee4cd85eea8db4108c43086c6d8c3c90c30 | https://github.com/phated/grunt-enyo/blob/d2990ee4cd85eea8db4108c43086c6d8c3c90c30/tasks/init/enyo/root/enyo/source/dom/Control.js#L566-L572 | train | |
tunnckoCore/simple-get-stream | index.js | simpleGetStream | function simpleGetStream (opts) {
var stream = through2()
stream.req = simpleGet.call(this, opts, function callback (err, res) {
stream.res = res
if (err) return stream.emit('error', err)
res.pipe(stream)
})
return stream
} | javascript | function simpleGetStream (opts) {
var stream = through2()
stream.req = simpleGet.call(this, opts, function callback (err, res) {
stream.res = res
if (err) return stream.emit('error', err)
res.pipe(stream)
})
return stream
} | [
"function",
"simpleGetStream",
"(",
"opts",
")",
"{",
"var",
"stream",
"=",
"through2",
"(",
")",
"stream",
".",
"req",
"=",
"simpleGet",
".",
"call",
"(",
"this",
",",
"opts",
",",
"function",
"callback",
"(",
"err",
",",
"res",
")",
"{",
"stream",
... | > Request a page and return a response stream
**Example**
```js
const request = require('simple-get-stream')
const stream = request('http://www.tunnckocore.tk')
stream.once('error', console.error)
stream.pipe(process.stdout) // => html content of the page
```
@name simpleGetStream
@param {String|Object} `<opts>` ... | [
">",
"Request",
"a",
"page",
"and",
"return",
"a",
"response",
"stream"
] | bb68e95e1411bcf866fb202980bbf399a5899b04 | https://github.com/tunnckoCore/simple-get-stream/blob/bb68e95e1411bcf866fb202980bbf399a5899b04/index.js#L31-L39 | train |
fibo/multidim-array-index | multidim-array-index.js | multiDimArrayIndex | function multiDimArrayIndex (dimensions, indices) {
// Check that indices fit inside dimensions shape.
for (var i = 0; i < dimensions.length; i++) {
if (indices[i] > dimensions[i]) {
throw new TypeError(error.outOfBoundIndex)
}
}
var order = dimensions.length
// Handle order 1
if (order === ... | javascript | function multiDimArrayIndex (dimensions, indices) {
// Check that indices fit inside dimensions shape.
for (var i = 0; i < dimensions.length; i++) {
if (indices[i] > dimensions[i]) {
throw new TypeError(error.outOfBoundIndex)
}
}
var order = dimensions.length
// Handle order 1
if (order === ... | [
"function",
"multiDimArrayIndex",
"(",
"dimensions",
",",
"indices",
")",
"{",
"// Check that indices fit inside dimensions shape.",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"dimensions",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"indices",
... | Maps multidimensional array indices to monodimensional array index
Given
dimensions d_1, d_2, d_3 .. d_n
and
indices i_1, i_2, i_3 .. i_n
index is computed by formula
index = i_n + i_(n-1) * d_n + i_(n-2) * d_n * d_(n-1) + ... + i_2 * d_n * d_(n-1) * ... * d_3 + i_1 * d_n * ... * d_2
@param {Array} dimensions
@para... | [
"Maps",
"multidimensional",
"array",
"indices",
"to",
"monodimensional",
"array",
"index"
] | d212ed0ea234311453d5187fd34c1e61726d1e6d | https://github.com/fibo/multidim-array-index/blob/d212ed0ea234311453d5187fd34c1e61726d1e6d/multidim-array-index.js#L36-L61 | train |
angeloocana/joj-core | dist/Board.js | hasPositionByBoardSize | function hasPositionByBoardSize(boardSize, position) {
return position && position.x >= 0 && position.y >= 0 && boardSize.y > position.y && boardSize.x > position.x;
} | javascript | function hasPositionByBoardSize(boardSize, position) {
return position && position.x >= 0 && position.y >= 0 && boardSize.y > position.y && boardSize.x > position.x;
} | [
"function",
"hasPositionByBoardSize",
"(",
"boardSize",
",",
"position",
")",
"{",
"return",
"position",
"&&",
"position",
".",
"x",
">=",
"0",
"&&",
"position",
".",
"y",
">=",
"0",
"&&",
"boardSize",
".",
"y",
">",
"position",
".",
"y",
"&&",
"boardSiz... | Checks if position exists in this board size | [
"Checks",
"if",
"position",
"exists",
"in",
"this",
"board",
"size"
] | 14bc7801c004271cefafff6cc0abb0c3173c805a | https://github.com/angeloocana/joj-core/blob/14bc7801c004271cefafff6cc0abb0c3173c805a/dist/Board.js#L27-L29 | train |
angeloocana/joj-core | dist/Board.js | mapBoard | function mapBoard(board, func) {
return board.map(function (col) {
return col.map(function (p) {
return func(p);
});
});
} | javascript | function mapBoard(board, func) {
return board.map(function (col) {
return col.map(function (p) {
return func(p);
});
});
} | [
"function",
"mapBoard",
"(",
"board",
",",
"func",
")",
"{",
"return",
"board",
".",
"map",
"(",
"function",
"(",
"col",
")",
"{",
"return",
"col",
".",
"map",
"(",
"function",
"(",
"p",
")",
"{",
"return",
"func",
"(",
"p",
")",
";",
"}",
")",
... | Map some function in all board positions and return a new board | [
"Map",
"some",
"function",
"in",
"all",
"board",
"positions",
"and",
"return",
"a",
"new",
"board"
] | 14bc7801c004271cefafff6cc0abb0c3173c805a | https://github.com/angeloocana/joj-core/blob/14bc7801c004271cefafff6cc0abb0c3173c805a/dist/Board.js#L39-L45 | train |
angeloocana/joj-core | dist/Board.js | getBoardWithPieces | function getBoardWithPieces(board, pieces) {
return mapBoard(board, function (p) {
var x = p.x,
y = p.y;
var piece = Position.getPositionFromPositions(pieces, p);
return piece ? { x: x, y: y, isBlack: piece.isBlack } : { x: x, y: y };
});
} | javascript | function getBoardWithPieces(board, pieces) {
return mapBoard(board, function (p) {
var x = p.x,
y = p.y;
var piece = Position.getPositionFromPositions(pieces, p);
return piece ? { x: x, y: y, isBlack: piece.isBlack } : { x: x, y: y };
});
} | [
"function",
"getBoardWithPieces",
"(",
"board",
",",
"pieces",
")",
"{",
"return",
"mapBoard",
"(",
"board",
",",
"function",
"(",
"p",
")",
"{",
"var",
"x",
"=",
"p",
".",
"x",
",",
"y",
"=",
"p",
".",
"y",
";",
"var",
"piece",
"=",
"Position",
... | Takes a board and return a new board with pieces. | [
"Takes",
"a",
"board",
"and",
"return",
"a",
"new",
"board",
"with",
"pieces",
"."
] | 14bc7801c004271cefafff6cc0abb0c3173c805a | https://github.com/angeloocana/joj-core/blob/14bc7801c004271cefafff6cc0abb0c3173c805a/dist/Board.js#L111-L119 | train |
angeloocana/joj-core | dist/Board.js | getStartWhiteBlack | function getStartWhiteBlack(x, whiteY) {
return [{ x: x, y: 0, isBlack: true }, { x: x, y: whiteY, isBlack: false }];
} | javascript | function getStartWhiteBlack(x, whiteY) {
return [{ x: x, y: 0, isBlack: true }, { x: x, y: whiteY, isBlack: false }];
} | [
"function",
"getStartWhiteBlack",
"(",
"x",
",",
"whiteY",
")",
"{",
"return",
"[",
"{",
"x",
":",
"x",
",",
"y",
":",
"0",
",",
"isBlack",
":",
"true",
"}",
",",
"{",
"x",
":",
"x",
",",
"y",
":",
"whiteY",
",",
"isBlack",
":",
"false",
"}",
... | Get start white and black pieces. | [
"Get",
"start",
"white",
"and",
"black",
"pieces",
"."
] | 14bc7801c004271cefafff6cc0abb0c3173c805a | https://github.com/angeloocana/joj-core/blob/14bc7801c004271cefafff6cc0abb0c3173c805a/dist/Board.js#L123-L125 | train |
angeloocana/joj-core | dist/Board.js | addStartPieces | function addStartPieces(x, whiteY, positions) {
return x < 0 ? positions : addStartPieces(x - 1, whiteY, positions.concat(getStartWhiteBlack(x, whiteY)));
} | javascript | function addStartPieces(x, whiteY, positions) {
return x < 0 ? positions : addStartPieces(x - 1, whiteY, positions.concat(getStartWhiteBlack(x, whiteY)));
} | [
"function",
"addStartPieces",
"(",
"x",
",",
"whiteY",
",",
"positions",
")",
"{",
"return",
"x",
"<",
"0",
"?",
"positions",
":",
"addStartPieces",
"(",
"x",
"-",
"1",
",",
"whiteY",
",",
"positions",
".",
"concat",
"(",
"getStartWhiteBlack",
"(",
"x",
... | Add start pieces recursively | [
"Add",
"start",
"pieces",
"recursively"
] | 14bc7801c004271cefafff6cc0abb0c3173c805a | https://github.com/angeloocana/joj-core/blob/14bc7801c004271cefafff6cc0abb0c3173c805a/dist/Board.js#L129-L131 | train |
angeloocana/joj-core | dist/Board.js | getPositionFromBoard | function getPositionFromBoard(board, position) {
try {
return board[position.y][position.x];
} catch (e) {
throw new Error('Error getting position');
}
} | javascript | function getPositionFromBoard(board, position) {
try {
return board[position.y][position.x];
} catch (e) {
throw new Error('Error getting position');
}
} | [
"function",
"getPositionFromBoard",
"(",
"board",
",",
"position",
")",
"{",
"try",
"{",
"return",
"board",
"[",
"position",
".",
"y",
"]",
"[",
"position",
".",
"x",
"]",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Error g... | Gets board position from x and y coordinates.
@param board board to get the position.
@param position desired x,y position. | [
"Gets",
"board",
"position",
"from",
"x",
"and",
"y",
"coordinates",
"."
] | 14bc7801c004271cefafff6cc0abb0c3173c805a | https://github.com/angeloocana/joj-core/blob/14bc7801c004271cefafff6cc0abb0c3173c805a/dist/Board.js#L160-L166 | train |
angeloocana/joj-core | dist/Board.js | getAllNearPositions | function getAllNearPositions(position) {
return [[-1, -1], [0, -1], [1, -1], [-1, 0], [1, 0], [-1, 1], [0, 1], [1, 1] // Below positions
].map(function (toAdd) {
return {
x: position.x + toAdd[0],
y: position.y + toAdd[1]
};
});
} | javascript | function getAllNearPositions(position) {
return [[-1, -1], [0, -1], [1, -1], [-1, 0], [1, 0], [-1, 1], [0, 1], [1, 1] // Below positions
].map(function (toAdd) {
return {
x: position.x + toAdd[0],
y: position.y + toAdd[1]
};
});
} | [
"function",
"getAllNearPositions",
"(",
"position",
")",
"{",
"return",
"[",
"[",
"-",
"1",
",",
"-",
"1",
"]",
",",
"[",
"0",
",",
"-",
"1",
"]",
",",
"[",
"1",
",",
"-",
"1",
"]",
",",
"[",
"-",
"1",
",",
"0",
"]",
",",
"[",
"1",
",",
... | Get all valid and invalid near positions. | [
"Get",
"all",
"valid",
"and",
"invalid",
"near",
"positions",
"."
] | 14bc7801c004271cefafff6cc0abb0c3173c805a | https://github.com/angeloocana/joj-core/blob/14bc7801c004271cefafff6cc0abb0c3173c805a/dist/Board.js#L272-L280 | train |
angeloocana/joj-core | dist/Board.js | getNearPositions | function getNearPositions(board, position) {
var nearPositions = _getNearPositions(getBoardSize(board), Position.getXAndY(position));
return getPositionsFromBoard(board, nearPositions);
} | javascript | function getNearPositions(board, position) {
var nearPositions = _getNearPositions(getBoardSize(board), Position.getXAndY(position));
return getPositionsFromBoard(board, nearPositions);
} | [
"function",
"getNearPositions",
"(",
"board",
",",
"position",
")",
"{",
"var",
"nearPositions",
"=",
"_getNearPositions",
"(",
"getBoardSize",
"(",
"board",
")",
",",
"Position",
".",
"getXAndY",
"(",
"position",
")",
")",
";",
"return",
"getPositionsFromBoard"... | Get all near positions from the given board instance. | [
"Get",
"all",
"near",
"positions",
"from",
"the",
"given",
"board",
"instance",
"."
] | 14bc7801c004271cefafff6cc0abb0c3173c805a | https://github.com/angeloocana/joj-core/blob/14bc7801c004271cefafff6cc0abb0c3173c805a/dist/Board.js#L293-L296 | train |
angeloocana/joj-core | dist/Board.js | getEmptyNearPositions | function getEmptyNearPositions(board, position) {
return getNearPositions(board, position).filter(function (p) {
return Position.hasNoPiece(p);
});
} | javascript | function getEmptyNearPositions(board, position) {
return getNearPositions(board, position).filter(function (p) {
return Position.hasNoPiece(p);
});
} | [
"function",
"getEmptyNearPositions",
"(",
"board",
",",
"position",
")",
"{",
"return",
"getNearPositions",
"(",
"board",
",",
"position",
")",
".",
"filter",
"(",
"function",
"(",
"p",
")",
"{",
"return",
"Position",
".",
"hasNoPiece",
"(",
"p",
")",
";",... | Get empty near positions | [
"Get",
"empty",
"near",
"positions"
] | 14bc7801c004271cefafff6cc0abb0c3173c805a | https://github.com/angeloocana/joj-core/blob/14bc7801c004271cefafff6cc0abb0c3173c805a/dist/Board.js#L300-L304 | train |
angeloocana/joj-core | dist/Board.js | getNotEmptyNearPositions | function getNotEmptyNearPositions(board, position) {
return getNearPositions(board, position).filter(function (p) {
return Position.hasPiece(p);
});
} | javascript | function getNotEmptyNearPositions(board, position) {
return getNearPositions(board, position).filter(function (p) {
return Position.hasPiece(p);
});
} | [
"function",
"getNotEmptyNearPositions",
"(",
"board",
",",
"position",
")",
"{",
"return",
"getNearPositions",
"(",
"board",
",",
"position",
")",
".",
"filter",
"(",
"function",
"(",
"p",
")",
"{",
"return",
"Position",
".",
"hasPiece",
"(",
"p",
")",
";"... | Get not empty near positions | [
"Get",
"not",
"empty",
"near",
"positions"
] | 14bc7801c004271cefafff6cc0abb0c3173c805a | https://github.com/angeloocana/joj-core/blob/14bc7801c004271cefafff6cc0abb0c3173c805a/dist/Board.js#L308-L312 | train |
angeloocana/joj-core | dist/Board.js | getJumpXY | function getJumpXY(from, toJump) {
return {
x: getJump(from.x, toJump.x),
y: getJump(from.y, toJump.y)
};
} | javascript | function getJumpXY(from, toJump) {
return {
x: getJump(from.x, toJump.x),
y: getJump(from.y, toJump.y)
};
} | [
"function",
"getJumpXY",
"(",
"from",
",",
"toJump",
")",
"{",
"return",
"{",
"x",
":",
"getJump",
"(",
"from",
".",
"x",
",",
"toJump",
".",
"x",
")",
",",
"y",
":",
"getJump",
"(",
"from",
".",
"y",
",",
"toJump",
".",
"y",
")",
"}",
";",
"... | Returns the target position from a jump. | [
"Returns",
"the",
"target",
"position",
"from",
"a",
"jump",
"."
] | 14bc7801c004271cefafff6cc0abb0c3173c805a | https://github.com/angeloocana/joj-core/blob/14bc7801c004271cefafff6cc0abb0c3173c805a/dist/Board.js#L322-L327 | train |
angeloocana/joj-core | dist/Board.js | getBoardWhereCanIGo | function getBoardWhereCanIGo(board, from) {
var positions = getPositionsWhereCanIGo(board, from);
return mapBoard(board, function (position) {
return Position.setICanGoHere(positions, position);
});
} | javascript | function getBoardWhereCanIGo(board, from) {
var positions = getPositionsWhereCanIGo(board, from);
return mapBoard(board, function (position) {
return Position.setICanGoHere(positions, position);
});
} | [
"function",
"getBoardWhereCanIGo",
"(",
"board",
",",
"from",
")",
"{",
"var",
"positions",
"=",
"getPositionsWhereCanIGo",
"(",
"board",
",",
"from",
")",
";",
"return",
"mapBoard",
"(",
"board",
",",
"function",
"(",
"position",
")",
"{",
"return",
"Positi... | Get board with checked where can I go positions | [
"Get",
"board",
"with",
"checked",
"where",
"can",
"I",
"go",
"positions"
] | 14bc7801c004271cefafff6cc0abb0c3173c805a | https://github.com/angeloocana/joj-core/blob/14bc7801c004271cefafff6cc0abb0c3173c805a/dist/Board.js#L341-L346 | train |
angeloocana/joj-core | dist/Board.js | getPiecesFromBoard | function getPiecesFromBoard(board) {
var initialPieces = {
white: [],
black: []
};
return board.reduce(function (piecesRow, row) {
return row.reduce(function (pieces, position) {
if (Position.hasBlackPiece(position)) pieces.black = pieces.black.concat(position);else if (P... | javascript | function getPiecesFromBoard(board) {
var initialPieces = {
white: [],
black: []
};
return board.reduce(function (piecesRow, row) {
return row.reduce(function (pieces, position) {
if (Position.hasBlackPiece(position)) pieces.black = pieces.black.concat(position);else if (P... | [
"function",
"getPiecesFromBoard",
"(",
"board",
")",
"{",
"var",
"initialPieces",
"=",
"{",
"white",
":",
"[",
"]",
",",
"black",
":",
"[",
"]",
"}",
";",
"return",
"board",
".",
"reduce",
"(",
"function",
"(",
"piecesRow",
",",
"row",
")",
"{",
"ret... | Takes a board and return white and black pieces.
Used to calculate score from a board.
returns { white: [{x,y}], black: [{x,y}] } | [
"Takes",
"a",
"board",
"and",
"return",
"white",
"and",
"black",
"pieces",
".",
"Used",
"to",
"calculate",
"score",
"from",
"a",
"board",
"."
] | 14bc7801c004271cefafff6cc0abb0c3173c805a | https://github.com/angeloocana/joj-core/blob/14bc7801c004271cefafff6cc0abb0c3173c805a/dist/Board.js#L353-L364 | train |
mgesmundo/authorify-client | lib/mixin/WithPayload.js | function(sessionId) {
if (sessionId) {
if (sessionId.length < 24) {
throw new CError('sid length undersized').log();
}
if (sessionId.length > 128) {
throw new CError('sid length exceeded').log();
}
this._sid = sessionId;
}
} | javascript | function(sessionId) {
if (sessionId) {
if (sessionId.length < 24) {
throw new CError('sid length undersized').log();
}
if (sessionId.length > 128) {
throw new CError('sid length exceeded').log();
}
this._sid = sessionId;
}
} | [
"function",
"(",
"sessionId",
")",
"{",
"if",
"(",
"sessionId",
")",
"{",
"if",
"(",
"sessionId",
".",
"length",
"<",
"24",
")",
"{",
"throw",
"new",
"CError",
"(",
"'sid length undersized'",
")",
".",
"log",
"(",
")",
";",
"}",
"if",
"(",
"sessionId... | Set the session identifier
@param {String} sid The session identifier | [
"Set",
"the",
"session",
"identifier"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/lib/mixin/WithPayload.js#L72-L82 | train | |
D-Mobilelab/http-francis | src/main.js | getImageRaw | function getImageRaw(options, _onProgress = () => {}){
return new Promise((resolve, reject) => {
var request = new XMLHttpRequest();
request.open('GET', options.url, true);
request.responseType = options.responseType || 'blob';
function transferComplete(){
var res... | javascript | function getImageRaw(options, _onProgress = () => {}){
return new Promise((resolve, reject) => {
var request = new XMLHttpRequest();
request.open('GET', options.url, true);
request.responseType = options.responseType || 'blob';
function transferComplete(){
var res... | [
"function",
"getImageRaw",
"(",
"options",
",",
"_onProgress",
"=",
"(",
")",
"=>",
"{",
"}",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"var",
"request",
"=",
"new",
"XMLHttpRequest",
"(",
")",
";",
"re... | getImageRaw from a specific url
@param {Object} options - the options object
@param {String} options.url - http or whatever
@param {String} [options.responseType="blob"] - possible values arraybuffer|blob
@param {String} [options.mimeType="image/jpeg"] - possible values "image/png"|"image/jpeg" used only if "blob" is ... | [
"getImageRaw",
"from",
"a",
"specific",
"url"
] | bb303b4aaad810014939d1fd237982a4dcceed4c | https://github.com/D-Mobilelab/http-francis/blob/bb303b4aaad810014939d1fd237982a4dcceed4c/src/main.js#L253-L288 | train |
D-Mobilelab/http-francis | src/main.js | JSONPRequest | function JSONPRequest(url, timeout = 3000){
var self = this;
self.timeout = timeout;
self.called = false;
if (window.document) {
var ts = Date.now();
self.scriptTag = window.document.createElement('script');
// url += '&callback=window.__jsonpHandler_' + ts;
var _url = ''... | javascript | function JSONPRequest(url, timeout = 3000){
var self = this;
self.timeout = timeout;
self.called = false;
if (window.document) {
var ts = Date.now();
self.scriptTag = window.document.createElement('script');
// url += '&callback=window.__jsonpHandler_' + ts;
var _url = ''... | [
"function",
"JSONPRequest",
"(",
"url",
",",
"timeout",
"=",
"3000",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"timeout",
"=",
"timeout",
";",
"self",
".",
"called",
"=",
"false",
";",
"if",
"(",
"window",
".",
"document",
")",
"{",
"... | Make a jsonp request, remember only GET
The function create a tag script and append a callback param in querystring.
The promise will be reject after 3s if the url fail to respond
@example
<pre>
request = new JSONPRequest("http://www.someapi.com/asd?somequery=1");
request.then((data) => {});
</pre>
@param {String} url... | [
"Make",
"a",
"jsonp",
"request",
"remember",
"only",
"GET",
"The",
"function",
"create",
"a",
"tag",
"script",
"and",
"append",
"a",
"callback",
"param",
"in",
"querystring",
".",
"The",
"promise",
"will",
"be",
"reject",
"after",
"3s",
"if",
"the",
"url",... | bb303b4aaad810014939d1fd237982a4dcceed4c | https://github.com/D-Mobilelab/http-francis/blob/bb303b4aaad810014939d1fd237982a4dcceed4c/src/main.js#L304-L341 | train |
segmentio/clear-globals | lib/index.js | copy | function copy(source, target) {
for (var name in source) {
if (source.hasOwnProperty(name)) {
target[name] = source[name];
}
}
} | javascript | function copy(source, target) {
for (var name in source) {
if (source.hasOwnProperty(name)) {
target[name] = source[name];
}
}
} | [
"function",
"copy",
"(",
"source",
",",
"target",
")",
"{",
"for",
"(",
"var",
"name",
"in",
"source",
")",
"{",
"if",
"(",
"source",
".",
"hasOwnProperty",
"(",
"name",
")",
")",
"{",
"target",
"[",
"name",
"]",
"=",
"source",
"[",
"name",
"]",
... | Reset properties on object.
@param {Object} source
@param {Object} target
@api private | [
"Reset",
"properties",
"on",
"object",
"."
] | 2ad614b42ed3d8a6fda293b40c8e5cf42397468a | https://github.com/segmentio/clear-globals/blob/2ad614b42ed3d8a6fda293b40c8e5cf42397468a/lib/index.js#L51-L57 | train |
viskan/node-hacontrol | index.js | function(localPath, globalPath)
{
if (!(this instanceof HAControl))
{
return new HAControl(localPath, globalPath);
}
this.localHa = true;
this.globalHa = true;
this.localPath = localPath;
this.globalPath = globalPath;
} | javascript | function(localPath, globalPath)
{
if (!(this instanceof HAControl))
{
return new HAControl(localPath, globalPath);
}
this.localHa = true;
this.globalHa = true;
this.localPath = localPath;
this.globalPath = globalPath;
} | [
"function",
"(",
"localPath",
",",
"globalPath",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"HAControl",
")",
")",
"{",
"return",
"new",
"HAControl",
"(",
"localPath",
",",
"globalPath",
")",
";",
"}",
"this",
".",
"localHa",
"=",
"true",
";"... | Simple service for fetching HAControl status.
@constructor
@author Ulrik Augustsson
@author Anton Johansson | [
"Simple",
"service",
"for",
"fetching",
"HAControl",
"status",
"."
] | dd409246bf8cd00ad2faa94273d71b5fcbf4515b | https://github.com/viskan/node-hacontrol/blob/dd409246bf8cd00ad2faa94273d71b5fcbf4515b/index.js#L13-L25 | train | |
ponycode/pony-config | index.js | _keySourceHintFrom | function _keySourceHintFrom( method, source, environment ){
var hints = [];
if( method ) hints.push( method );
if( source ) hints.push( source );
if( environment ) hints.push( "WHEN " + environment );
return hints.join(' ');
} | javascript | function _keySourceHintFrom( method, source, environment ){
var hints = [];
if( method ) hints.push( method );
if( source ) hints.push( source );
if( environment ) hints.push( "WHEN " + environment );
return hints.join(' ');
} | [
"function",
"_keySourceHintFrom",
"(",
"method",
",",
"source",
",",
"environment",
")",
"{",
"var",
"hints",
"=",
"[",
"]",
";",
"if",
"(",
"method",
")",
"hints",
".",
"push",
"(",
"method",
")",
";",
"if",
"(",
"source",
")",
"hints",
".",
"push",... | construct a source hint for the ConfigStore
Hints are stored in the config to indicate source of applied changes
@param method
@param source
@param environment
@return {string}
@private | [
"construct",
"a",
"source",
"hint",
"for",
"the",
"ConfigStore",
"Hints",
"are",
"stored",
"in",
"the",
"config",
"to",
"indicate",
"source",
"of",
"applied",
"changes"
] | 171d69aea32d7b60481f4523d5eac13d549a05fe | https://github.com/ponycode/pony-config/blob/171d69aea32d7b60481f4523d5eac13d549a05fe/index.js#L239-L246 | train |
ngageoint/eslint-plugin-opensphere | util.js | isGoogCallExpression | function isGoogCallExpression(node, name) {
const callee = node.callee;
return callee && callee.type === 'MemberExpression' &&
callee.object.type === 'Identifier' && callee.object.name === 'goog' &&
callee.property.type === 'Identifier' && !callee.property.computed &&
callee.property.name === name... | javascript | function isGoogCallExpression(node, name) {
const callee = node.callee;
return callee && callee.type === 'MemberExpression' &&
callee.object.type === 'Identifier' && callee.object.name === 'goog' &&
callee.property.type === 'Identifier' && !callee.property.computed &&
callee.property.name === name... | [
"function",
"isGoogCallExpression",
"(",
"node",
",",
"name",
")",
"{",
"const",
"callee",
"=",
"node",
".",
"callee",
";",
"return",
"callee",
"&&",
"callee",
".",
"type",
"===",
"'MemberExpression'",
"&&",
"callee",
".",
"object",
".",
"type",
"===",
"'I... | If a node represents a goog call expression.
@param {!AST.Node} node The node.
@param {string} name The name.
@return {boolean} | [
"If",
"a",
"node",
"represents",
"a",
"goog",
"call",
"expression",
"."
] | 3d1804b49a0349aeba0eb694e45266fb2cb2d83b | https://github.com/ngageoint/eslint-plugin-opensphere/blob/3d1804b49a0349aeba0eb694e45266fb2cb2d83b/util.js#L9-L15 | train |
ngageoint/eslint-plugin-opensphere | util.js | isGoogStatement | function isGoogStatement(node, name) {
return node.expression && node.expression.type === 'CallExpression' &&
isGoogCallExpression(node.expression, name);
} | javascript | function isGoogStatement(node, name) {
return node.expression && node.expression.type === 'CallExpression' &&
isGoogCallExpression(node.expression, name);
} | [
"function",
"isGoogStatement",
"(",
"node",
",",
"name",
")",
"{",
"return",
"node",
".",
"expression",
"&&",
"node",
".",
"expression",
".",
"type",
"===",
"'CallExpression'",
"&&",
"isGoogCallExpression",
"(",
"node",
".",
"expression",
",",
"name",
")",
"... | If a node represents a goog statement.
@param {!AST.Node} node The node.
@param {string} name The name.
@return {boolean} | [
"If",
"a",
"node",
"represents",
"a",
"goog",
"statement",
"."
] | 3d1804b49a0349aeba0eb694e45266fb2cb2d83b | https://github.com/ngageoint/eslint-plugin-opensphere/blob/3d1804b49a0349aeba0eb694e45266fb2cb2d83b/util.js#L23-L26 | train |
ibm-watson-data-lab/--deprecated--simple-data-pipe-connector-reddit | lib/index.js | function () {
logger.info('Records sent to Tone Analyzer: ' + amaStats.processed_record_count);
// these records could be fetched using other API calls
logger.info('Records missing (no comment text available): ' + amaStats.missing_record_count);
logger.info('Maximum processed comment thread depth: '... | javascript | function () {
logger.info('Records sent to Tone Analyzer: ' + amaStats.processed_record_count);
// these records could be fetched using other API calls
logger.info('Records missing (no comment text available): ' + amaStats.missing_record_count);
logger.info('Maximum processed comment thread depth: '... | [
"function",
"(",
")",
"{",
"logger",
".",
"info",
"(",
"'Records sent to Tone Analyzer: '",
"+",
"amaStats",
".",
"processed_record_count",
")",
";",
"// these records could be fetched using other API calls",
"logger",
".",
"info",
"(",
"'Records missing (no comment text avai... | local helper function; displays processing statistics` | [
"local",
"helper",
"function",
";",
"displays",
"processing",
"statistics"
] | df7188d9a8519f14d095ab7db5bee913e92804c2 | https://github.com/ibm-watson-data-lab/--deprecated--simple-data-pipe-connector-reddit/blob/df7188d9a8519f14d095ab7db5bee913e92804c2/lib/index.js#L337-L349 | train | |
amercier/broccoli-file-size | src/lib/index.js | listFiles | function listFiles(dir, callback) {
return new Promise((resolveThis, reject) => {
walk.walk(dir, { followLinks: true })
.on('file', (root, stats, next) => {
const destDir = relative(dir, root);
const relativePath = destDir ? join(destDir, stats.name) : stats.name;
resolve(relativePath).then(... | javascript | function listFiles(dir, callback) {
return new Promise((resolveThis, reject) => {
walk.walk(dir, { followLinks: true })
.on('file', (root, stats, next) => {
const destDir = relative(dir, root);
const relativePath = destDir ? join(destDir, stats.name) : stats.name;
resolve(relativePath).then(... | [
"function",
"listFiles",
"(",
"dir",
",",
"callback",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolveThis",
",",
"reject",
")",
"=>",
"{",
"walk",
".",
"walk",
"(",
"dir",
",",
"{",
"followLinks",
":",
"true",
"}",
")",
".",
"on",
"(",
"'f... | Lists files of a directory recursively. Follows symbolic links.
@param {String} dir Directory to scan
@param {Function()} callback Callback executed when a file is found. Can return a Promise.
@return {Promise} A new promise that is resolved once the given directory
has been scanned entirely and all callbacks have comp... | [
"Lists",
"files",
"of",
"a",
"directory",
"recursively",
".",
"Follows",
"symbolic",
"links",
"."
] | 35785685f00629ad362b413285cf8e355369005a | https://github.com/amercier/broccoli-file-size/blob/35785685f00629ad362b413285cf8e355369005a/src/lib/index.js#L23-L34 | train |
amercier/broccoli-file-size | src/lib/index.js | symlinkOrCopySync | function symlinkOrCopySync(dir, target) {
try {
symlinkOrCopy.sync(dir, target);
} catch (e) {
if (existsSync(target)) {
rimraf.sync(target);
}
symlinkOrCopy.sync(dir, target);
}
} | javascript | function symlinkOrCopySync(dir, target) {
try {
symlinkOrCopy.sync(dir, target);
} catch (e) {
if (existsSync(target)) {
rimraf.sync(target);
}
symlinkOrCopy.sync(dir, target);
}
} | [
"function",
"symlinkOrCopySync",
"(",
"dir",
",",
"target",
")",
"{",
"try",
"{",
"symlinkOrCopy",
".",
"sync",
"(",
"dir",
",",
"target",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"if",
"(",
"existsSync",
"(",
"target",
")",
")",
"{",
"rimraf",
... | Symlink or copy a directory
@param {String} dir Path to an existing
@param {String} target Path of the symlink to create | [
"Symlink",
"or",
"copy",
"a",
"directory"
] | 35785685f00629ad362b413285cf8e355369005a | https://github.com/amercier/broccoli-file-size/blob/35785685f00629ad362b413285cf8e355369005a/src/lib/index.js#L41-L50 | train |
rhyolight/github-data | lib/tree.js | Tree | function Tree(source, parent, githubClient) {
this.gh = githubClient;
this.sha = source.sha;
this.parent = parent;
this.truncated = source.truncated;
this.objects = _.cloneDeep(source.tree);
this._source = source;
} | javascript | function Tree(source, parent, githubClient) {
this.gh = githubClient;
this.sha = source.sha;
this.parent = parent;
this.truncated = source.truncated;
this.objects = _.cloneDeep(source.tree);
this._source = source;
} | [
"function",
"Tree",
"(",
"source",
",",
"parent",
",",
"githubClient",
")",
"{",
"this",
".",
"gh",
"=",
"githubClient",
";",
"this",
".",
"sha",
"=",
"source",
".",
"sha",
";",
"this",
".",
"parent",
"=",
"parent",
";",
"this",
".",
"truncated",
"="... | A git tree object.
@class Tree
@param source {Object} JSON response from API, used to build.
@param parent {Object} Expected to be {{#crossLink "Tree"}}{{/crossLink}} or
{{#crossLink "Commit"}}{{/crossLink}}.
@param githubClient {Object} GitHub API Client object.
@constructor | [
"A",
"git",
"tree",
"object",
"."
] | 5d6a3fc0e7ecfeaec03e4815b0940c2d9ce07d64 | https://github.com/rhyolight/github-data/blob/5d6a3fc0e7ecfeaec03e4815b0940c2d9ce07d64/lib/tree.js#L21-L28 | train |
ugate/releasebot | releasebot.js | task | function task() {
// make sure the release task has been initialized
init.apply(this, arguments);
var name, desc, deps, cb;
for (var i = 0; i < arguments.length; i++) {
if (typeof arguments[i] === 'string') {
if (name) {
desc = arguments[i];
} else {
name = arguments[i];
}
} else if (typeof arg... | javascript | function task() {
// make sure the release task has been initialized
init.apply(this, arguments);
var name, desc, deps, cb;
for (var i = 0; i < arguments.length; i++) {
if (typeof arguments[i] === 'string') {
if (name) {
desc = arguments[i];
} else {
name = arguments[i];
}
} else if (typeof arg... | [
"function",
"task",
"(",
")",
"{",
"// make sure the release task has been initialized",
"init",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"var",
"name",
",",
"desc",
",",
"deps",
",",
"cb",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
... | Registers a task runner neutral API for a task. If using Grunt "registerTask"
is executed. If using Gulp "task" is executed. In either case the arguments
are passed in the expected order regardless of how they are passed into this
function.
@returns the return value from the task runner API | [
"Registers",
"a",
"task",
"runner",
"neutral",
"API",
"for",
"a",
"task",
".",
"If",
"using",
"Grunt",
"registerTask",
"is",
"executed",
".",
"If",
"using",
"Gulp",
"task",
"is",
"executed",
".",
"In",
"either",
"case",
"the",
"arguments",
"are",
"passed",... | 1a2ff42796e77f47f9590992c014fee461aad80b | https://github.com/ugate/releasebot/blob/1a2ff42796e77f47f9590992c014fee461aad80b/releasebot.js#L86-L120 | train |
ugate/releasebot | releasebot.js | taskCallback | function taskCallback(fn) {
return fn.length ? taskAsyncCb : taskSyncCb;
function taskAsyncCb(cb) {
return taskCb(this || {}, arguments, fn, cb, true);
}
function taskSyncCb() {
return taskCb(this || {}, arguments, fn, null, false);
}
function taskCb(cxt, args, fn, done, isAsync) {
cxt.done = isAsync && typ... | javascript | function taskCallback(fn) {
return fn.length ? taskAsyncCb : taskSyncCb;
function taskAsyncCb(cb) {
return taskCb(this || {}, arguments, fn, cb, true);
}
function taskSyncCb() {
return taskCb(this || {}, arguments, fn, null, false);
}
function taskCb(cxt, args, fn, done, isAsync) {
cxt.done = isAsync && typ... | [
"function",
"taskCallback",
"(",
"fn",
")",
"{",
"return",
"fn",
".",
"length",
"?",
"taskAsyncCb",
":",
"taskSyncCb",
";",
"function",
"taskAsyncCb",
"(",
"cb",
")",
"{",
"return",
"taskCb",
"(",
"this",
"||",
"{",
"}",
",",
"arguments",
",",
"fn",
",... | Creates a task callback function that will wrap the passed callback that the
task runner requires to ensure consistent option behavior between different
task runners. When the specified function contains arguments the wrapper will
assume that the associated task will be executed in an asynchronous fashion.
Relies on th... | [
"Creates",
"a",
"task",
"callback",
"function",
"that",
"will",
"wrap",
"the",
"passed",
"callback",
"that",
"the",
"task",
"runner",
"requires",
"to",
"ensure",
"consistent",
"option",
"behavior",
"between",
"different",
"task",
"runners",
".",
"When",
"the",
... | 1a2ff42796e77f47f9590992c014fee461aad80b | https://github.com/ugate/releasebot/blob/1a2ff42796e77f47f9590992c014fee461aad80b/releasebot.js#L134-L167 | train |
ugate/releasebot | releasebot.js | processTemplate | function processTemplate(val, data) {
if (rbot.env.usingGrunt) {
return rbot.env.taskRunner.template.process(val, data);
}
// TODO : add gulp template processing
if (!val) {
return val;
}
return val;
} | javascript | function processTemplate(val, data) {
if (rbot.env.usingGrunt) {
return rbot.env.taskRunner.template.process(val, data);
}
// TODO : add gulp template processing
if (!val) {
return val;
}
return val;
} | [
"function",
"processTemplate",
"(",
"val",
",",
"data",
")",
"{",
"if",
"(",
"rbot",
".",
"env",
".",
"usingGrunt",
")",
"{",
"return",
"rbot",
".",
"env",
".",
"taskRunner",
".",
"template",
".",
"process",
"(",
"val",
",",
"data",
")",
";",
"}",
... | Processes a value using the passed data
@param val
the value
@param data
the object that contains the template data to use
@returns the processed value | [
"Processes",
"a",
"value",
"using",
"the",
"passed",
"data"
] | 1a2ff42796e77f47f9590992c014fee461aad80b | https://github.com/ugate/releasebot/blob/1a2ff42796e77f47f9590992c014fee461aad80b/releasebot.js#L193-L202 | train |
AndreasMadsen/immortal | lib/executables/pump.js | function (emits, message, daemonPid) {
var monitor = new Monitor(message, options, daemonPid, shutdown, child, function () {
// emit events before starting child
Object.keys(emits).forEach(function (name) {
// skip the process event until the child spawns
if (name === 'process') return;... | javascript | function (emits, message, daemonPid) {
var monitor = new Monitor(message, options, daemonPid, shutdown, child, function () {
// emit events before starting child
Object.keys(emits).forEach(function (name) {
// skip the process event until the child spawns
if (name === 'process') return;... | [
"function",
"(",
"emits",
",",
"message",
",",
"daemonPid",
")",
"{",
"var",
"monitor",
"=",
"new",
"Monitor",
"(",
"message",
",",
"options",
",",
"daemonPid",
",",
"shutdown",
",",
"child",
",",
"function",
"(",
")",
"{",
"// emit events before starting ch... | first create monitor object, the callback is executed when the monitor constructor call this.ready | [
"first",
"create",
"monitor",
"object",
"the",
"callback",
"is",
"executed",
"when",
"the",
"monitor",
"constructor",
"call",
"this",
".",
"ready"
] | c1ab5a4287a543fdfd980604a9e9927d663a9ef2 | https://github.com/AndreasMadsen/immortal/blob/c1ab5a4287a543fdfd980604a9e9927d663a9ef2/lib/executables/pump.js#L54-L90 | train | |
RnbWd/parse-browserify | lib/user.js | function(other) {
if (other.getSessionToken()) {
this._sessionToken = other.getSessionToken();
}
Parse.User.__super__._mergeFromObject.call(this, other);
} | javascript | function(other) {
if (other.getSessionToken()) {
this._sessionToken = other.getSessionToken();
}
Parse.User.__super__._mergeFromObject.call(this, other);
} | [
"function",
"(",
"other",
")",
"{",
"if",
"(",
"other",
".",
"getSessionToken",
"(",
")",
")",
"{",
"this",
".",
"_sessionToken",
"=",
"other",
".",
"getSessionToken",
"(",
")",
";",
"}",
"Parse",
".",
"User",
".",
"__super__",
".",
"_mergeFromObject",
... | Instance Methods
Merges another object's attributes into this object. | [
"Instance",
"Methods",
"Merges",
"another",
"object",
"s",
"attributes",
"into",
"this",
"object",
"."
] | c19c1b798e4010a552e130b1a9ce3b5d084dc101 | https://github.com/RnbWd/parse-browserify/blob/c19c1b798e4010a552e130b1a9ce3b5d084dc101/lib/user.js#L24-L29 | train | |
RnbWd/parse-browserify | lib/user.js | function(attrs) {
if (attrs.sessionToken) {
this._sessionToken = attrs.sessionToken;
delete attrs.sessionToken;
}
Parse.User.__super__._mergeMagicFields.call(this, attrs);
} | javascript | function(attrs) {
if (attrs.sessionToken) {
this._sessionToken = attrs.sessionToken;
delete attrs.sessionToken;
}
Parse.User.__super__._mergeMagicFields.call(this, attrs);
} | [
"function",
"(",
"attrs",
")",
"{",
"if",
"(",
"attrs",
".",
"sessionToken",
")",
"{",
"this",
".",
"_sessionToken",
"=",
"attrs",
".",
"sessionToken",
";",
"delete",
"attrs",
".",
"sessionToken",
";",
"}",
"Parse",
".",
"User",
".",
"__super__",
".",
... | Internal method to handle special fields in a _User response. | [
"Internal",
"method",
"to",
"handle",
"special",
"fields",
"in",
"a",
"_User",
"response",
"."
] | c19c1b798e4010a552e130b1a9ce3b5d084dc101 | https://github.com/RnbWd/parse-browserify/blob/c19c1b798e4010a552e130b1a9ce3b5d084dc101/lib/user.js#L34-L40 | train | |
RnbWd/parse-browserify | lib/user.js | function(provider, options) {
var authType;
if (_.isString(provider)) {
authType = provider;
provider = Parse.User._authProviders[provider];
} else {
authType = provider.getAuthType();
}
var newOptions = _.clone(options);
var self = this;
newOptions.auth... | javascript | function(provider, options) {
var authType;
if (_.isString(provider)) {
authType = provider;
provider = Parse.User._authProviders[provider];
} else {
authType = provider.getAuthType();
}
var newOptions = _.clone(options);
var self = this;
newOptions.auth... | [
"function",
"(",
"provider",
",",
"options",
")",
"{",
"var",
"authType",
";",
"if",
"(",
"_",
".",
"isString",
"(",
"provider",
")",
")",
"{",
"authType",
"=",
"provider",
";",
"provider",
"=",
"Parse",
".",
"User",
".",
"_authProviders",
"[",
"provid... | Unlinks a user from a service. | [
"Unlinks",
"a",
"user",
"from",
"a",
"service",
"."
] | c19c1b798e4010a552e130b1a9ce3b5d084dc101 | https://github.com/RnbWd/parse-browserify/blob/c19c1b798e4010a552e130b1a9ce3b5d084dc101/lib/user.js#L170-L188 | train | |
RnbWd/parse-browserify | lib/user.js | function(email, options) {
options = options || {};
var request = Parse._request({
route: "requestPasswordReset",
method: "POST",
useMasterKey: options.useMasterKey,
data: { email: email }
});
return request._thenRunCallbacks(options);
} | javascript | function(email, options) {
options = options || {};
var request = Parse._request({
route: "requestPasswordReset",
method: "POST",
useMasterKey: options.useMasterKey,
data: { email: email }
});
return request._thenRunCallbacks(options);
} | [
"function",
"(",
"email",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"request",
"=",
"Parse",
".",
"_request",
"(",
"{",
"route",
":",
"\"requestPasswordReset\"",
",",
"method",
":",
"\"POST\"",
",",
"useMasterKey",
... | Requests a password reset email to be sent to the specified email address
associated with the user account. This email allows the user to securely
reset their password on the Parse site.
<p>Calls options.success or options.error on completion.</p>
@param {String} email The email address associated with the user that
... | [
"Requests",
"a",
"password",
"reset",
"email",
"to",
"be",
"sent",
"to",
"the",
"specified",
"email",
"address",
"associated",
"with",
"the",
"user",
"account",
".",
"This",
"email",
"allows",
"the",
"user",
"to",
"securely",
"reset",
"their",
"password",
"o... | c19c1b798e4010a552e130b1a9ce3b5d084dc101 | https://github.com/RnbWd/parse-browserify/blob/c19c1b798e4010a552e130b1a9ce3b5d084dc101/lib/user.js#L560-L569 | train | |
RnbWd/parse-browserify | lib/user.js | function() {
if (Parse.User._currentUser) {
return Parse.User._currentUser;
}
if (Parse.User._currentUserMatchesDisk) {
return Parse.User._currentUser;
}
// Load the user from local storage.
Parse.User._currentUserMatchesDisk = true;
var userData = P... | javascript | function() {
if (Parse.User._currentUser) {
return Parse.User._currentUser;
}
if (Parse.User._currentUserMatchesDisk) {
return Parse.User._currentUser;
}
// Load the user from local storage.
Parse.User._currentUserMatchesDisk = true;
var userData = P... | [
"function",
"(",
")",
"{",
"if",
"(",
"Parse",
".",
"User",
".",
"_currentUser",
")",
"{",
"return",
"Parse",
".",
"User",
".",
"_currentUser",
";",
"}",
"if",
"(",
"Parse",
".",
"User",
".",
"_currentUserMatchesDisk",
")",
"{",
"return",
"Parse",
".",... | Retrieves the currently logged in ParseUser with a valid session,
either from memory or localStorage, if necessary.
@return {Parse.Object} The currently logged in Parse.User. | [
"Retrieves",
"the",
"currently",
"logged",
"in",
"ParseUser",
"with",
"a",
"valid",
"session",
"either",
"from",
"memory",
"or",
"localStorage",
"if",
"necessary",
"."
] | c19c1b798e4010a552e130b1a9ce3b5d084dc101 | https://github.com/RnbWd/parse-browserify/blob/c19c1b798e4010a552e130b1a9ce3b5d084dc101/lib/user.js#L576-L609 | train | |
codenothing/munit | lib/spy.js | function(){
spy.history = [];
spy.args = [];
spy.count = 0;
spy.scope = null;
spy.trace = null;
return spy;
} | javascript | function(){
spy.history = [];
spy.args = [];
spy.count = 0;
spy.scope = null;
spy.trace = null;
return spy;
} | [
"function",
"(",
")",
"{",
"spy",
".",
"history",
"=",
"[",
"]",
";",
"spy",
".",
"args",
"=",
"[",
"]",
";",
"spy",
".",
"count",
"=",
"0",
";",
"spy",
".",
"scope",
"=",
"null",
";",
"spy",
".",
"trace",
"=",
"null",
";",
"return",
"spy",
... | Resets history and counters | [
"Resets",
"history",
"and",
"counters"
] | aedf3f31aafc05441970eec49eeeb81174c14033 | https://github.com/codenothing/munit/blob/aedf3f31aafc05441970eec49eeeb81174c14033/lib/spy.js#L115-L123 | train | |
codenothing/munit | lib/spy.js | function(){
if ( spy.wrapped ) {
spy._module[ spy._method ] = spy.original;
spy.wrapped = false;
}
return spy;
} | javascript | function(){
if ( spy.wrapped ) {
spy._module[ spy._method ] = spy.original;
spy.wrapped = false;
}
return spy;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"spy",
".",
"wrapped",
")",
"{",
"spy",
".",
"_module",
"[",
"spy",
".",
"_method",
"]",
"=",
"spy",
".",
"original",
";",
"spy",
".",
"wrapped",
"=",
"false",
";",
"}",
"return",
"spy",
";",
"}"
] | Restores the original method back | [
"Restores",
"the",
"original",
"method",
"back"
] | aedf3f31aafc05441970eec49eeeb81174c14033 | https://github.com/codenothing/munit/blob/aedf3f31aafc05441970eec49eeeb81174c14033/lib/spy.js#L126-L133 | train | |
codenothing/munit | lib/spy.js | SpyCall | function SpyCall( scope, args, spy ) {
var self = this;
if ( ! ( self instanceof SpyCall ) ) {
return new SpyCall( args );
}
self.scope = scope;
self.args = args;
self.time = new Date();
self.order = spy.assert._spyOrder++;
self.overall = Spy.overall++;
self.trace = ( new Error( "" ) ).stack;
} | javascript | function SpyCall( scope, args, spy ) {
var self = this;
if ( ! ( self instanceof SpyCall ) ) {
return new SpyCall( args );
}
self.scope = scope;
self.args = args;
self.time = new Date();
self.order = spy.assert._spyOrder++;
self.overall = Spy.overall++;
self.trace = ( new Error( "" ) ).stack;
} | [
"function",
"SpyCall",
"(",
"scope",
",",
"args",
",",
"spy",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"!",
"(",
"self",
"instanceof",
"SpyCall",
")",
")",
"{",
"return",
"new",
"SpyCall",
"(",
"args",
")",
";",
"}",
"self",
".",
"sc... | Call History Object | [
"Call",
"History",
"Object"
] | aedf3f31aafc05441970eec49eeeb81174c14033 | https://github.com/codenothing/munit/blob/aedf3f31aafc05441970eec49eeeb81174c14033/lib/spy.js#L139-L152 | train |
pinyin/outline | vendor/transformation-matrix/translate.js | translate | function translate(tx) {
var ty = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
return {
a: 1, c: 0, e: tx,
b: 0, d: 1, f: ty
};
} | javascript | function translate(tx) {
var ty = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
return {
a: 1, c: 0, e: tx,
b: 0, d: 1, f: ty
};
} | [
"function",
"translate",
"(",
"tx",
")",
"{",
"var",
"ty",
"=",
"arguments",
".",
"length",
">",
"1",
"&&",
"arguments",
"[",
"1",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"1",
"]",
":",
"0",
";",
"return",
"{",
"a",
":",
"1",
",",
"c",
... | Calculate a translate matrix
@param tx Translation on axis x
@param [ty = 0] Translation on axis y
@returns {{a: number, b: number, c: number, e: number, d: number, f: number}} Affine matrix | [
"Calculate",
"a",
"translate",
"matrix"
] | e49f05d2f8ab384f5b1d71b2b10875cd48d41051 | https://github.com/pinyin/outline/blob/e49f05d2f8ab384f5b1d71b2b10875cd48d41051/vendor/transformation-matrix/translate.js#L14-L21 | train |
amandeepmittal/rainbow-log | index.js | log | function log(msg) {
process.stdout.write(time + ' ');
console.log(colors.log(msg));
} | javascript | function log(msg) {
process.stdout.write(time + ' ');
console.log(colors.log(msg));
} | [
"function",
"log",
"(",
"msg",
")",
"{",
"process",
".",
"stdout",
".",
"write",
"(",
"time",
"+",
"' '",
")",
";",
"console",
".",
"log",
"(",
"colors",
".",
"log",
"(",
"msg",
")",
")",
";",
"}"
] | console functions nodejs supports | [
"console",
"functions",
"nodejs",
"supports"
] | fb7153c36c1a27addf564512f68f2b67ec62e8f6 | https://github.com/amandeepmittal/rainbow-log/blob/fb7153c36c1a27addf564512f68f2b67ec62e8f6/index.js#L24-L27 | train |
joneit/overrider | index.js | mixInTo | function mixInTo(target) {
var descriptor;
for (var key in this) {
if ((descriptor = Object.getOwnPropertyDescriptor(this, key))) {
Object.defineProperty(target, key, descriptor);
}
}
return target;
} | javascript | function mixInTo(target) {
var descriptor;
for (var key in this) {
if ((descriptor = Object.getOwnPropertyDescriptor(this, key))) {
Object.defineProperty(target, key, descriptor);
}
}
return target;
} | [
"function",
"mixInTo",
"(",
"target",
")",
"{",
"var",
"descriptor",
";",
"for",
"(",
"var",
"key",
"in",
"this",
")",
"{",
"if",
"(",
"(",
"descriptor",
"=",
"Object",
".",
"getOwnPropertyDescriptor",
"(",
"this",
",",
"key",
")",
")",
")",
"{",
"Ob... | Mix `this` members into `target`.
@example
// A. Simple usage (using .call):
var mixInTo = require('overrider').mixInTo;
var target = { a: 1 }, source = { b: 2 };
target === overrider.mixInTo.call(source, target); // true
// target object now has both a and b; source object untouched
@example
// B. Semantic usage (wh... | [
"Mix",
"this",
"members",
"into",
"target",
"."
] | 57c406d3c9e62c2cf4d4231b029bd868f8fe0c47 | https://github.com/joneit/overrider/blob/57c406d3c9e62c2cf4d4231b029bd868f8fe0c47/index.js#L50-L58 | train |
joneit/overrider | index.js | mixIn | function mixIn(source) {
var descriptor;
for (var key in source) {
if ((descriptor = Object.getOwnPropertyDescriptor(source, key))) {
Object.defineProperty(this, key, descriptor);
}
}
return this;
} | javascript | function mixIn(source) {
var descriptor;
for (var key in source) {
if ((descriptor = Object.getOwnPropertyDescriptor(source, key))) {
Object.defineProperty(this, key, descriptor);
}
}
return this;
} | [
"function",
"mixIn",
"(",
"source",
")",
"{",
"var",
"descriptor",
";",
"for",
"(",
"var",
"key",
"in",
"source",
")",
"{",
"if",
"(",
"(",
"descriptor",
"=",
"Object",
".",
"getOwnPropertyDescriptor",
"(",
"source",
",",
"key",
")",
")",
")",
"{",
"... | Mix `source` members into `this`.
@example
// A. Simple usage (using .call):
var mixIn = require('overrider').mixIn;
var target = { a: 1 }, source = { b: 2 };
target === overrider.mixIn.call(target, source) // true
// target object now has both a and b; source object untouched
@example
// B. Semantic usage (when the ... | [
"Mix",
"source",
"members",
"into",
"this",
"."
] | 57c406d3c9e62c2cf4d4231b029bd868f8fe0c47 | https://github.com/joneit/overrider/blob/57c406d3c9e62c2cf4d4231b029bd868f8fe0c47/index.js#L82-L90 | train |
mallocator/docker-cli-proxy | lib/index.js | cleanObject | function cleanObject(obj) {
if (obj instanceof Object) {
Object.keys(obj).forEach((key) => (obj[key] == null) && delete obj[key]);
}
return obj;
} | javascript | function cleanObject(obj) {
if (obj instanceof Object) {
Object.keys(obj).forEach((key) => (obj[key] == null) && delete obj[key]);
}
return obj;
} | [
"function",
"cleanObject",
"(",
"obj",
")",
"{",
"if",
"(",
"obj",
"instanceof",
"Object",
")",
"{",
"Object",
".",
"keys",
"(",
"obj",
")",
".",
"forEach",
"(",
"(",
"key",
")",
"=>",
"(",
"obj",
"[",
"key",
"]",
"==",
"null",
")",
"&&",
"delete... | Removes any properties from an object that resolve to null.
@param {Object} obj | [
"Removes",
"any",
"properties",
"from",
"an",
"object",
"that",
"resolve",
"to",
"null",
"."
] | 6dcd85e3eaaccac9318feab797eeec272d790b97 | https://github.com/mallocator/docker-cli-proxy/blob/6dcd85e3eaaccac9318feab797eeec272d790b97/lib/index.js#L29-L34 | train |
mallocator/docker-cli-proxy | lib/index.js | getDockerfileContext | function getDockerfileContext(context) {
const fs = require('fs');
let files = [];
let dockerfile = exports.resolveDockerfile(context);
let file = fs.readFileSync(dockerfile, {encoding: 'utf8'});
for (let line of file.split('\n')) {
if (line.match(/^\s*(ADD|COPY).*$/)) {
let entries = line.split(' '... | javascript | function getDockerfileContext(context) {
const fs = require('fs');
let files = [];
let dockerfile = exports.resolveDockerfile(context);
let file = fs.readFileSync(dockerfile, {encoding: 'utf8'});
for (let line of file.split('\n')) {
if (line.match(/^\s*(ADD|COPY).*$/)) {
let entries = line.split(' '... | [
"function",
"getDockerfileContext",
"(",
"context",
")",
"{",
"const",
"fs",
"=",
"require",
"(",
"'fs'",
")",
";",
"let",
"files",
"=",
"[",
"]",
";",
"let",
"dockerfile",
"=",
"exports",
".",
"resolveDockerfile",
"(",
"context",
")",
";",
"let",
"file"... | Parses a Dockerfile and looks for sources that may be needed to build this image.
@param context
@returns {{context: *, src: *[]}} | [
"Parses",
"a",
"Dockerfile",
"and",
"looks",
"for",
"sources",
"that",
"may",
"be",
"needed",
"to",
"build",
"this",
"image",
"."
] | 6dcd85e3eaaccac9318feab797eeec272d790b97 | https://github.com/mallocator/docker-cli-proxy/blob/6dcd85e3eaaccac9318feab797eeec272d790b97/lib/index.js#L58-L94 | train |
nomocas/yamvish | lib/output-engine/string.js | tagOutput | function tagOutput(descriptor, innerDescriptor, name) {
var out = '<' + name + innerDescriptor.attributes;
if (innerDescriptor.style)
out += ' style="' + innerDescriptor.style + '"';
if (innerDescriptor.classes)
out += ' class="' + innerDescriptor.classes + '"';
if (innerDescriptor.children)
descriptor.childr... | javascript | function tagOutput(descriptor, innerDescriptor, name) {
var out = '<' + name + innerDescriptor.attributes;
if (innerDescriptor.style)
out += ' style="' + innerDescriptor.style + '"';
if (innerDescriptor.classes)
out += ' class="' + innerDescriptor.classes + '"';
if (innerDescriptor.children)
descriptor.childr... | [
"function",
"tagOutput",
"(",
"descriptor",
",",
"innerDescriptor",
",",
"name",
")",
"{",
"var",
"out",
"=",
"'<'",
"+",
"name",
"+",
"innerDescriptor",
".",
"attributes",
";",
"if",
"(",
"innerDescriptor",
".",
"style",
")",
"out",
"+=",
"' style=\"'",
"... | produce final html tag representation | [
"produce",
"final",
"html",
"tag",
"representation"
] | 017a536bb6bafddf1b31c0c7af6f723be58e9f0e | https://github.com/nomocas/yamvish/blob/017a536bb6bafddf1b31c0c7af6f723be58e9f0e/lib/output-engine/string.js#L38-L52 | train |
MaiaVictor/dattata | canvasImage.js | function(width, height){
var canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
var context = canvas.getContext("2d");
var imageData = context.getImageData(0, 0, width, height);
var buffer = new ArrayBuffer(width*height*4);
var buffer8 = new Uint8Clamped... | javascript | function(width, height){
var canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
var context = canvas.getContext("2d");
var imageData = context.getImageData(0, 0, width, height);
var buffer = new ArrayBuffer(width*height*4);
var buffer8 = new Uint8Clamped... | [
"function",
"(",
"width",
",",
"height",
")",
"{",
"var",
"canvas",
"=",
"document",
".",
"createElement",
"(",
"\"canvas\"",
")",
";",
"canvas",
".",
"width",
"=",
"width",
";",
"canvas",
".",
"height",
"=",
"height",
";",
"var",
"context",
"=",
"canv... | Uint, Uint -> CanvasImage | [
"Uint",
"Uint",
"-",
">",
"CanvasImage"
] | 890d83b89b7193ce8863bb9ac9b296b3510e8db9 | https://github.com/MaiaVictor/dattata/blob/890d83b89b7193ce8863bb9ac9b296b3510e8db9/canvasImage.js#L3-L20 | train | |
skenqbx/file-emitter | lib/file-emitter.js | FileEmitter | function FileEmitter(folder, opt_options) {
if (!(this instanceof FileEmitter)) {
return new FileEmitter(folder, opt_options);
}
events.EventEmitter.call(this);
opt_options = opt_options || {};
this.root = path.resolve(process.cwd(), folder);
// flags & options
this.buffer = opt_options.buffer || fa... | javascript | function FileEmitter(folder, opt_options) {
if (!(this instanceof FileEmitter)) {
return new FileEmitter(folder, opt_options);
}
events.EventEmitter.call(this);
opt_options = opt_options || {};
this.root = path.resolve(process.cwd(), folder);
// flags & options
this.buffer = opt_options.buffer || fa... | [
"function",
"FileEmitter",
"(",
"folder",
",",
"opt_options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"FileEmitter",
")",
")",
"{",
"return",
"new",
"FileEmitter",
"(",
"folder",
",",
"opt_options",
")",
";",
"}",
"events",
".",
"EventEmitter"... | file-emitter
**opt_options**
- `{boolean} buffer` Load each file into a buffer before emitting, defaults to `false`
- `{number} maxBufferSize` The max size of a file buffer, defaults to `10485760` (=10MiB)
- `{boolean} incremental` When `true` each `file` event has to be acknowledged by calling `fe.next()`
- `{boolean... | [
"file",
"-",
"emitter"
] | a17e03dbb251bd79772101a94a1e6b116b01f1f7 | https://github.com/skenqbx/file-emitter/blob/a17e03dbb251bd79772101a94a1e6b116b01f1f7/lib/file-emitter.js#L31-L73 | train |
gmalysa/flux-link | coverage.js | reportCoverage | function reportCoverage(cov) {
// Stats
print('\n [bold]{Test Coverage}\n');
var sep = ' +------------------------------------------+----------+------+------+--------+',
lastSep = ' +----------+------+------+--------+';
result = sep+'\n';
result ... | javascript | function reportCoverage(cov) {
// Stats
print('\n [bold]{Test Coverage}\n');
var sep = ' +------------------------------------------+----------+------+------+--------+',
lastSep = ' +----------+------+------+--------+';
result = sep+'\n';
result ... | [
"function",
"reportCoverage",
"(",
"cov",
")",
"{",
"// Stats",
"print",
"(",
"'\\n [bold]{Test Coverage}\\n'",
")",
";",
"var",
"sep",
"=",
"' +------------------------------------------+----------+------+------+--------+'",
",",
"lastSep",
"=",
"' ... | Report test coverage.
@param {Object} cov | [
"Report",
"test",
"coverage",
"."
] | 567ac39a1f4a74f85465a58fb6fd96d64b1b765f | https://github.com/gmalysa/flux-link/blob/567ac39a1f4a74f85465a58fb6fd96d64b1b765f/coverage.js#L154-L193 | train |
gmalysa/flux-link | coverage.js | populateCoverage | function populateCoverage(cov) {
cov.LOC =
cov.SLOC =
cov.totalFiles =
cov.totalHits =
cov.totalMisses =
cov.coverage = 0;
for (var name in cov) {
var file = cov[name];
if (Array.isArray(file)) {
// Stats
++cov.totalFiles;
cov.totalHits += ... | javascript | function populateCoverage(cov) {
cov.LOC =
cov.SLOC =
cov.totalFiles =
cov.totalHits =
cov.totalMisses =
cov.coverage = 0;
for (var name in cov) {
var file = cov[name];
if (Array.isArray(file)) {
// Stats
++cov.totalFiles;
cov.totalHits += ... | [
"function",
"populateCoverage",
"(",
"cov",
")",
"{",
"cov",
".",
"LOC",
"=",
"cov",
".",
"SLOC",
"=",
"cov",
".",
"totalFiles",
"=",
"cov",
".",
"totalHits",
"=",
"cov",
".",
"totalMisses",
"=",
"cov",
".",
"coverage",
"=",
"0",
";",
"for",
"(",
"... | Populate code coverage data.
@param {Object} cov | [
"Populate",
"code",
"coverage",
"data",
"."
] | 567ac39a1f4a74f85465a58fb6fd96d64b1b765f | https://github.com/gmalysa/flux-link/blob/567ac39a1f4a74f85465a58fb6fd96d64b1b765f/coverage.js#L200-L235 | 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.