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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
h2non/jshashes | hashes.js | binl2rstr | function binl2rstr(input) {
var i, output = '',
l = input.length * 32;
for (i = 0; i < l; i += 8) {
output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xFF);
}
return output;
} | javascript | function binl2rstr(input) {
var i, output = '',
l = input.length * 32;
for (i = 0; i < l; i += 8) {
output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xFF);
}
return output;
} | [
"function",
"binl2rstr",
"(",
"input",
")",
"{",
"var",
"i",
",",
"output",
"=",
"''",
",",
"l",
"=",
"input",
".",
"length",
"*",
"32",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"l",
";",
"i",
"+=",
"8",
")",
"{",
"output",
"+=",
"Str... | Convert an array of little-endian words to a string | [
"Convert",
"an",
"array",
"of",
"little",
"-",
"endian",
"words",
"to",
"a",
"string"
] | 88625b6c841ca3c90f8b9fefb0fedb78992017ad | https://github.com/h2non/jshashes/blob/88625b6c841ca3c90f8b9fefb0fedb78992017ad/hashes.js#L1640-L1647 | train |
h2non/jshashes | hashes.js | binl | function binl(x, len) {
var T, j, i, l,
h0 = 0x67452301,
h1 = 0xefcdab89,
h2 = 0x98badcfe,
h3 = 0x10325476,
h4 = 0xc3d2e1f0,
A1, B1, C1, D1, E1,
A2, B2, C2, D2, E2;
/* append padding */
x[len >> 5] |= 0x80 << (len % 32);
... | javascript | function binl(x, len) {
var T, j, i, l,
h0 = 0x67452301,
h1 = 0xefcdab89,
h2 = 0x98badcfe,
h3 = 0x10325476,
h4 = 0xc3d2e1f0,
A1, B1, C1, D1, E1,
A2, B2, C2, D2, E2;
/* append padding */
x[len >> 5] |= 0x80 << (len % 32);
... | [
"function",
"binl",
"(",
"x",
",",
"len",
")",
"{",
"var",
"T",
",",
"j",
",",
"i",
",",
"l",
",",
"h0",
"=",
"0x67452301",
",",
"h1",
"=",
"0xefcdab89",
",",
"h2",
"=",
"0x98badcfe",
",",
"h3",
"=",
"0x10325476",
",",
"h4",
"=",
"0xc3d2e1f0",
... | Calculate the RIPE-MD160 of an array of little-endian words, and a bit length. | [
"Calculate",
"the",
"RIPE",
"-",
"MD160",
"of",
"an",
"array",
"of",
"little",
"-",
"endian",
"words",
"and",
"a",
"bit",
"length",
"."
] | 88625b6c841ca3c90f8b9fefb0fedb78992017ad | https://github.com/h2non/jshashes/blob/88625b6c841ca3c90f8b9fefb0fedb78992017ad/hashes.js#L1653-L1703 | train |
h2non/jshashes | hashes.js | rmd160_f | function rmd160_f(j, x, y, z) {
return (0 <= j && j <= 15) ? (x ^ y ^ z) :
(16 <= j && j <= 31) ? (x & y) | (~x & z) :
(32 <= j && j <= 47) ? (x | ~y) ^ z :
(48 <= j && j <= 63) ? (x & z) | (y & ~z) :
(64 <= j && j <= 79) ? x ^ (y | ~z) :
'rmd160_f: j out of ran... | javascript | function rmd160_f(j, x, y, z) {
return (0 <= j && j <= 15) ? (x ^ y ^ z) :
(16 <= j && j <= 31) ? (x & y) | (~x & z) :
(32 <= j && j <= 47) ? (x | ~y) ^ z :
(48 <= j && j <= 63) ? (x & z) | (y & ~z) :
(64 <= j && j <= 79) ? x ^ (y | ~z) :
'rmd160_f: j out of ran... | [
"function",
"rmd160_f",
"(",
"j",
",",
"x",
",",
"y",
",",
"z",
")",
"{",
"return",
"(",
"0",
"<=",
"j",
"&&",
"j",
"<=",
"15",
")",
"?",
"(",
"x",
"^",
"y",
"^",
"z",
")",
":",
"(",
"16",
"<=",
"j",
"&&",
"j",
"<=",
"31",
")",
"?",
"... | specific algorithm methods | [
"specific",
"algorithm",
"methods"
] | 88625b6c841ca3c90f8b9fefb0fedb78992017ad | https://github.com/h2non/jshashes/blob/88625b6c841ca3c90f8b9fefb0fedb78992017ad/hashes.js#L1707-L1714 | train |
arobson/rabbot | src/amqp/queue.js | purgeADQueue | function purgeADQueue (channel, connectionName, options, messages) {
const name = options.uniqueName || options.name;
return new Promise(function (resolve, reject) {
const messageCount = messages.messages.length;
if (messageCount > 0) {
log.info(`Purge operation for queue '${options.name}' on '${conne... | javascript | function purgeADQueue (channel, connectionName, options, messages) {
const name = options.uniqueName || options.name;
return new Promise(function (resolve, reject) {
const messageCount = messages.messages.length;
if (messageCount > 0) {
log.info(`Purge operation for queue '${options.name}' on '${conne... | [
"function",
"purgeADQueue",
"(",
"channel",
",",
"connectionName",
",",
"options",
",",
"messages",
")",
"{",
"const",
"name",
"=",
"options",
".",
"uniqueName",
"||",
"options",
".",
"name",
";",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
... | purging an auto-delete queue means unsubscribing is not an option as it will cause the queue, binding and possibly upstream auto-delete exchanges to be deleted as well | [
"purging",
"an",
"auto",
"-",
"delete",
"queue",
"means",
"unsubscribing",
"is",
"not",
"an",
"option",
"as",
"it",
"will",
"cause",
"the",
"queue",
"binding",
"and",
"possibly",
"upstream",
"auto",
"-",
"delete",
"exchanges",
"to",
"be",
"deleted",
"as",
... | 80b63c08bdb32d04fd36502f24180e0c8e8f69ee | https://github.com/arobson/rabbot/blob/80b63c08bdb32d04fd36502f24180e0c8e8f69ee/src/amqp/queue.js#L205-L226 | train |
filamentgroup/criticalCSS | critical.js | replaceDecls | function replaceDecls(originalRules, criticalRule){
// find all the rules in the original CSS that have the same selectors and
// then create an array of all the associated declarations. Note that this
// works with mutiple duplicate selectors on the original CSS
var originalDecls = _.flatten(
originalRules
... | javascript | function replaceDecls(originalRules, criticalRule){
// find all the rules in the original CSS that have the same selectors and
// then create an array of all the associated declarations. Note that this
// works with mutiple duplicate selectors on the original CSS
var originalDecls = _.flatten(
originalRules
... | [
"function",
"replaceDecls",
"(",
"originalRules",
",",
"criticalRule",
")",
"{",
"// find all the rules in the original CSS that have the same selectors and",
"// then create an array of all the associated declarations. Note that this",
"// works with mutiple duplicate selectors on the original ... | create a function that can be passed to `map` for a collection of critical css rules. The function will match original rules against the selector of the critical css declarations, concatenate them together, and then keep only the unique ones | [
"create",
"a",
"function",
"that",
"can",
"be",
"passed",
"to",
"map",
"for",
"a",
"collection",
"of",
"critical",
"css",
"rules",
".",
"The",
"function",
"will",
"match",
"original",
"rules",
"against",
"the",
"selector",
"of",
"the",
"critical",
"css",
"... | 42e299907a0bd3a8113f83aef4b2fd69ca5d21e3 | https://github.com/filamentgroup/criticalCSS/blob/42e299907a0bd3a8113f83aef4b2fd69ca5d21e3/critical.js#L127-L149 | train |
d3/d3-dsv | src/dsv.js | inferColumns | function inferColumns(rows) {
var columnSet = Object.create(null),
columns = [];
rows.forEach(function(row) {
for (var column in row) {
if (!(column in columnSet)) {
columns.push(columnSet[column] = column);
}
}
});
return columns;
} | javascript | function inferColumns(rows) {
var columnSet = Object.create(null),
columns = [];
rows.forEach(function(row) {
for (var column in row) {
if (!(column in columnSet)) {
columns.push(columnSet[column] = column);
}
}
});
return columns;
} | [
"function",
"inferColumns",
"(",
"rows",
")",
"{",
"var",
"columnSet",
"=",
"Object",
".",
"create",
"(",
"null",
")",
",",
"columns",
"=",
"[",
"]",
";",
"rows",
".",
"forEach",
"(",
"function",
"(",
"row",
")",
"{",
"for",
"(",
"var",
"column",
"... | Compute unique columns in order of discovery. | [
"Compute",
"unique",
"columns",
"in",
"order",
"of",
"discovery",
"."
] | ff2d09f943c2d19d0f0fa96f9b6a39c7431ca7e8 | https://github.com/d3/d3-dsv/blob/ff2d09f943c2d19d0f0fa96f9b6a39c7431ca7e8/src/dsv.js#L21-L34 | train |
Surnet/swagger-jsdoc | lib/helpers/filterJsDocComments.js | filterJsDocComments | function filterJsDocComments(jsDocComments) {
const swaggerJsDocComments = [];
for (let i = 0; i < jsDocComments.length; i += 1) {
const jsDocComment = jsDocComments[i];
for (let j = 0; j < jsDocComment.tags.length; j += 1) {
const tag = jsDocComment.tags[j];
if (tag.title === 'swagger') {
... | javascript | function filterJsDocComments(jsDocComments) {
const swaggerJsDocComments = [];
for (let i = 0; i < jsDocComments.length; i += 1) {
const jsDocComment = jsDocComments[i];
for (let j = 0; j < jsDocComment.tags.length; j += 1) {
const tag = jsDocComment.tags[j];
if (tag.title === 'swagger') {
... | [
"function",
"filterJsDocComments",
"(",
"jsDocComments",
")",
"{",
"const",
"swaggerJsDocComments",
"=",
"[",
"]",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"jsDocComments",
".",
"length",
";",
"i",
"+=",
"1",
")",
"{",
"const",
"jsDocComment... | Filters JSDoc comments for those tagged with '@swagger'
@function
@param {array} jsDocComments - JSDoc comments
@returns {array} JSDoc comments tagged with '@swagger'
@requires js-yaml | [
"Filters",
"JSDoc",
"comments",
"for",
"those",
"tagged",
"with"
] | ece24be07458d9a4ff1b8a1020a4581624bb0f7c | https://github.com/Surnet/swagger-jsdoc/blob/ece24be07458d9a4ff1b8a1020a4581624bb0f7c/lib/helpers/filterJsDocComments.js#L10-L24 | train |
Surnet/swagger-jsdoc | lib/helpers/convertGlobPaths.js | convertGlobPaths | function convertGlobPaths(globs) {
return globs
.map(globString => glob.sync(globString))
.reduce((previous, current) => previous.concat(current), []);
} | javascript | function convertGlobPaths(globs) {
return globs
.map(globString => glob.sync(globString))
.reduce((previous, current) => previous.concat(current), []);
} | [
"function",
"convertGlobPaths",
"(",
"globs",
")",
"{",
"return",
"globs",
".",
"map",
"(",
"globString",
"=>",
"glob",
".",
"sync",
"(",
"globString",
")",
")",
".",
"reduce",
"(",
"(",
"previous",
",",
"current",
")",
"=>",
"previous",
".",
"concat",
... | Converts an array of globs to full paths
@function
@param {array} globs - Array of globs and/or normal paths
@return {array} Array of fully-qualified paths
@requires glob | [
"Converts",
"an",
"array",
"of",
"globs",
"to",
"full",
"paths"
] | ece24be07458d9a4ff1b8a1020a4581624bb0f7c | https://github.com/Surnet/swagger-jsdoc/blob/ece24be07458d9a4ff1b8a1020a4581624bb0f7c/lib/helpers/convertGlobPaths.js#L10-L14 | train |
Surnet/swagger-jsdoc | bin/swagger-jsdoc.js | createSpecification | function createSpecification(swaggerDefinition, apis, fileName) {
// Options for the swagger docs
const options = {
// Import swaggerDefinitions
swaggerDefinition,
// Path to the API docs
apis,
};
// Initialize swagger-jsdoc -> returns validated JSON or YAML swagger spec
let swaggerSpec;
co... | javascript | function createSpecification(swaggerDefinition, apis, fileName) {
// Options for the swagger docs
const options = {
// Import swaggerDefinitions
swaggerDefinition,
// Path to the API docs
apis,
};
// Initialize swagger-jsdoc -> returns validated JSON or YAML swagger spec
let swaggerSpec;
co... | [
"function",
"createSpecification",
"(",
"swaggerDefinition",
",",
"apis",
",",
"fileName",
")",
"{",
"// Options for the swagger docs",
"const",
"options",
"=",
"{",
"// Import swaggerDefinitions",
"swaggerDefinition",
",",
"// Path to the API docs",
"apis",
",",
"}",
";"... | Creates a swagger specification from a definition and a set of files.
@function
@param {object} swaggerDefinition - The swagger definition object.
@param {array} apis - List of files to extract documentation from.
@param {string} fileName - Name the output file. | [
"Creates",
"a",
"swagger",
"specification",
"from",
"a",
"definition",
"and",
"a",
"set",
"of",
"files",
"."
] | ece24be07458d9a4ff1b8a1020a4581624bb0f7c | https://github.com/Surnet/swagger-jsdoc/blob/ece24be07458d9a4ff1b8a1020a4581624bb0f7c/bin/swagger-jsdoc.js#L25-L53 | train |
Surnet/swagger-jsdoc | bin/swagger-jsdoc.js | loadSpecification | function loadSpecification(defPath, data) {
const resolvedPath = path.resolve(defPath);
const extName = path.extname(resolvedPath);
const loader = LOADERS[extName];
// Check whether the definition file is actually a usable file
if (loader === undefined) {
throw new Error('Definition file should be .js, ... | javascript | function loadSpecification(defPath, data) {
const resolvedPath = path.resolve(defPath);
const extName = path.extname(resolvedPath);
const loader = LOADERS[extName];
// Check whether the definition file is actually a usable file
if (loader === undefined) {
throw new Error('Definition file should be .js, ... | [
"function",
"loadSpecification",
"(",
"defPath",
",",
"data",
")",
"{",
"const",
"resolvedPath",
"=",
"path",
".",
"resolve",
"(",
"defPath",
")",
";",
"const",
"extName",
"=",
"path",
".",
"extname",
"(",
"resolvedPath",
")",
";",
"const",
"loader",
"=",
... | Get an object of the definition file configuration. | [
"Get",
"an",
"object",
"of",
"the",
"definition",
"file",
"configuration",
"."
] | ece24be07458d9a4ff1b8a1020a4581624bb0f7c | https://github.com/Surnet/swagger-jsdoc/blob/ece24be07458d9a4ff1b8a1020a4581624bb0f7c/bin/swagger-jsdoc.js#L77-L90 | train |
Surnet/swagger-jsdoc | lib/helpers/hasEmptyProperty.js | hasEmptyProperty | function hasEmptyProperty(obj) {
return Object.keys(obj)
.map(key => obj[key])
.every(
keyObject =>
typeof keyObject === 'object' &&
Object.keys(keyObject).every(key => !(key in keyObject))
);
} | javascript | function hasEmptyProperty(obj) {
return Object.keys(obj)
.map(key => obj[key])
.every(
keyObject =>
typeof keyObject === 'object' &&
Object.keys(keyObject).every(key => !(key in keyObject))
);
} | [
"function",
"hasEmptyProperty",
"(",
"obj",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"obj",
")",
".",
"map",
"(",
"key",
"=>",
"obj",
"[",
"key",
"]",
")",
".",
"every",
"(",
"keyObject",
"=>",
"typeof",
"keyObject",
"===",
"'object'",
"&&",
"... | Checks if there is any properties of @obj that is a empty object
@function
@param {object} obj - the object to check | [
"Checks",
"if",
"there",
"is",
"any",
"properties",
"of"
] | ece24be07458d9a4ff1b8a1020a4581624bb0f7c | https://github.com/Surnet/swagger-jsdoc/blob/ece24be07458d9a4ff1b8a1020a4581624bb0f7c/lib/helpers/hasEmptyProperty.js#L6-L14 | train |
Surnet/swagger-jsdoc | lib/helpers/parseApiFile.js | parseApiFile | function parseApiFile(file) {
const jsDocRegex = /\/\*\*([\s\S]*?)\*\//gm;
const fileContent = fs.readFileSync(file, { encoding: 'utf8' });
const ext = path.extname(file);
const yaml = [];
const jsDocComments = [];
if (ext === '.yaml' || ext === '.yml') {
yaml.push(jsYaml.safeLoad(fileContent));
} el... | javascript | function parseApiFile(file) {
const jsDocRegex = /\/\*\*([\s\S]*?)\*\//gm;
const fileContent = fs.readFileSync(file, { encoding: 'utf8' });
const ext = path.extname(file);
const yaml = [];
const jsDocComments = [];
if (ext === '.yaml' || ext === '.yml') {
yaml.push(jsYaml.safeLoad(fileContent));
} el... | [
"function",
"parseApiFile",
"(",
"file",
")",
"{",
"const",
"jsDocRegex",
"=",
"/",
"\\/\\*\\*([\\s\\S]*?)\\*\\/",
"/",
"gm",
";",
"const",
"fileContent",
"=",
"fs",
".",
"readFileSync",
"(",
"file",
",",
"{",
"encoding",
":",
"'utf8'",
"}",
")",
";",
"con... | Parses the provided API file for JSDoc comments.
@function
@param {string} file - File to be parsed
@returns {{jsdoc: array, yaml: array}} JSDoc comments and Yaml files
@requires doctrine | [
"Parses",
"the",
"provided",
"API",
"file",
"for",
"JSDoc",
"comments",
"."
] | ece24be07458d9a4ff1b8a1020a4581624bb0f7c | https://github.com/Surnet/swagger-jsdoc/blob/ece24be07458d9a4ff1b8a1020a4581624bb0f7c/lib/helpers/parseApiFile.js#L13-L36 | train |
anmonteiro/lumo | vendor/nexe/monkeypatch.js | _monkeypatch | function _monkeypatch(filePath, monkeyPatched, processor, complete) {
async.waterfall(
[
function read(next) {
fs.readFile(filePath, 'utf8', next);
},
// TODO - need to parse gyp file - this is a bit hacker
function monkeypatch(content, next) {
if (monkeyPatched(content)) ... | javascript | function _monkeypatch(filePath, monkeyPatched, processor, complete) {
async.waterfall(
[
function read(next) {
fs.readFile(filePath, 'utf8', next);
},
// TODO - need to parse gyp file - this is a bit hacker
function monkeypatch(content, next) {
if (monkeyPatched(content)) ... | [
"function",
"_monkeypatch",
"(",
"filePath",
",",
"monkeyPatched",
",",
"processor",
",",
"complete",
")",
"{",
"async",
".",
"waterfall",
"(",
"[",
"function",
"read",
"(",
"next",
")",
"{",
"fs",
".",
"readFile",
"(",
"filePath",
",",
"'utf8'",
",",
"n... | Monkey patch a file.
@param {string} filePath - path to file.
@param {function} monkeyPatched - function to process contents
@param {function} processor - TODO: detail what this is
@param {function} complete - callback
@return undefined | [
"Monkey",
"patch",
"a",
"file",
"."
] | 345bacd2c36f9648b416f74d2e41cdf55c2cc1f9 | https://github.com/anmonteiro/lumo/blob/345bacd2c36f9648b416f74d2e41cdf55c2cc1f9/vendor/nexe/monkeypatch.js#L39-L62 | train |
anmonteiro/lumo | vendor/nexe/log.js | _log | function _log() {
var args = Array.prototype.slice.call(arguments, 0),
level = args.shift();
if (!~['log', 'error', 'warn'].indexOf(level)) {
args.unshift(level);
level = 'log';
}
if (level == 'log') {
args[0] = '----> ' + args[0];
} else if (level == 'error') {
args[0] = '....> ' + colo... | javascript | function _log() {
var args = Array.prototype.slice.call(arguments, 0),
level = args.shift();
if (!~['log', 'error', 'warn'].indexOf(level)) {
args.unshift(level);
level = 'log';
}
if (level == 'log') {
args[0] = '----> ' + args[0];
} else if (level == 'error') {
args[0] = '....> ' + colo... | [
"function",
"_log",
"(",
")",
"{",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"0",
")",
",",
"level",
"=",
"args",
".",
"shift",
"(",
")",
";",
"if",
"(",
"!",
"~",
"[",
"'log'",
",",
"'erro... | standard output, takes 3 different types.
log, error, and warn
@param {any} arguments - Text to output.
@return undefined | [
"standard",
"output",
"takes",
"3",
"different",
"types",
".",
"log",
"error",
"and",
"warn"
] | 345bacd2c36f9648b416f74d2e41cdf55c2cc1f9 | https://github.com/anmonteiro/lumo/blob/345bacd2c36f9648b416f74d2e41cdf55c2cc1f9/vendor/nexe/log.js#L35-L53 | train |
anmonteiro/lumo | vendor/nexe/embed.js | embed | function embed(resourceFiles, resourceRoot) {
if (resourceFiles.length > 0) {
let buffer = 'var embeddedFiles = {\n';
for (let i = 0; i < resourceFiles.length; ++i) {
buffer +=
JSON.stringify(path.relative(resourceRoot, resourceFiles[i])) + ': "';
buffer += encode(resourceFiles[i]) + '",\n... | javascript | function embed(resourceFiles, resourceRoot) {
if (resourceFiles.length > 0) {
let buffer = 'var embeddedFiles = {\n';
for (let i = 0; i < resourceFiles.length; ++i) {
buffer +=
JSON.stringify(path.relative(resourceRoot, resourceFiles[i])) + ': "';
buffer += encode(resourceFiles[i]) + '",\n... | [
"function",
"embed",
"(",
"resourceFiles",
",",
"resourceRoot",
")",
"{",
"if",
"(",
"resourceFiles",
".",
"length",
">",
"0",
")",
"{",
"let",
"buffer",
"=",
"'var embeddedFiles = {\\n'",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"resourceFi... | Embed files.
@param {array} resourceFiles - array of files to embed.
@param {string} resourceRoot - root of resources.
@param {function} compelte - callback | [
"Embed",
"files",
"."
] | 345bacd2c36f9648b416f74d2e41cdf55c2cc1f9 | https://github.com/anmonteiro/lumo/blob/345bacd2c36f9648b416f74d2e41cdf55c2cc1f9/vendor/nexe/embed.js#L54-L69 | train |
anmonteiro/lumo | vendor/nexe/exe.js | checkOpts | function checkOpts(next) {
/* failsafe */
if (options === undefined) {
_log('error', 'no options given to .compile()');
process.exit();
}
/**
* Have we been given a custom flag for python executable?
**/
if (
options.python !== 'py... | javascript | function checkOpts(next) {
/* failsafe */
if (options === undefined) {
_log('error', 'no options given to .compile()');
process.exit();
}
/**
* Have we been given a custom flag for python executable?
**/
if (
options.python !== 'py... | [
"function",
"checkOpts",
"(",
"next",
")",
"{",
"/* failsafe */",
"if",
"(",
"options",
"===",
"undefined",
")",
"{",
"_log",
"(",
"'error'",
",",
"'no options given to .compile()'",
")",
";",
"process",
".",
"exit",
"(",
")",
";",
"}",
"/**\n * Have w... | check relevant options | [
"check",
"relevant",
"options"
] | 345bacd2c36f9648b416f74d2e41cdf55c2cc1f9 | https://github.com/anmonteiro/lumo/blob/345bacd2c36f9648b416f74d2e41cdf55c2cc1f9/vendor/nexe/exe.js#L63-L126 | train |
anmonteiro/lumo | vendor/nexe/exe.js | downloadNode | function downloadNode(next) {
_downloadNode(
version,
options.nodeTempDir,
options.nodeConfigureArgs,
options.nodeMakeArgs,
options.nodeVCBuildArgs,
next,
);
} | javascript | function downloadNode(next) {
_downloadNode(
version,
options.nodeTempDir,
options.nodeConfigureArgs,
options.nodeMakeArgs,
options.nodeVCBuildArgs,
next,
);
} | [
"function",
"downloadNode",
"(",
"next",
")",
"{",
"_downloadNode",
"(",
"version",
",",
"options",
".",
"nodeTempDir",
",",
"options",
".",
"nodeConfigureArgs",
",",
"options",
".",
"nodeMakeArgs",
",",
"options",
".",
"nodeVCBuildArgs",
",",
"next",
",",
")"... | first download node | [
"first",
"download",
"node"
] | 345bacd2c36f9648b416f74d2e41cdf55c2cc1f9 | https://github.com/anmonteiro/lumo/blob/345bacd2c36f9648b416f74d2e41cdf55c2cc1f9/vendor/nexe/exe.js#L131-L140 | train |
anmonteiro/lumo | vendor/nexe/exe.js | embedResources | function embedResources(nc, next) {
nodeCompiler = nc;
options.resourceFiles = options.resourceFiles || [];
options.resourceRoot = options.resourceRoot || '';
if (!Array.isArray(options.resourceFiles)) {
throw new Error('Bad Argument: resourceFiles is not an array');
... | javascript | function embedResources(nc, next) {
nodeCompiler = nc;
options.resourceFiles = options.resourceFiles || [];
options.resourceRoot = options.resourceRoot || '';
if (!Array.isArray(options.resourceFiles)) {
throw new Error('Bad Argument: resourceFiles is not an array');
... | [
"function",
"embedResources",
"(",
"nc",
",",
"next",
")",
"{",
"nodeCompiler",
"=",
"nc",
";",
"options",
".",
"resourceFiles",
"=",
"options",
".",
"resourceFiles",
"||",
"[",
"]",
";",
"options",
".",
"resourceRoot",
"=",
"options",
".",
"resourceRoot",
... | Embed Resources into a base64 encoded array. | [
"Embed",
"Resources",
"into",
"a",
"base64",
"encoded",
"array",
"."
] | 345bacd2c36f9648b416f74d2e41cdf55c2cc1f9 | https://github.com/anmonteiro/lumo/blob/345bacd2c36f9648b416f74d2e41cdf55c2cc1f9/vendor/nexe/exe.js#L145-L170 | train |
anmonteiro/lumo | vendor/nexe/exe.js | combineProject | function combineProject(next) {
if (options.noBundle) {
_log(
'using provided bundle %s since noBundle is true',
options.input,
);
const source = fs.readFileSync(options.input, 'utf8');
const thirdPartyMain = `
if (!process.send) {
console.log('t... | javascript | function combineProject(next) {
if (options.noBundle) {
_log(
'using provided bundle %s since noBundle is true',
options.input,
);
const source = fs.readFileSync(options.input, 'utf8');
const thirdPartyMain = `
if (!process.send) {
console.log('t... | [
"function",
"combineProject",
"(",
"next",
")",
"{",
"if",
"(",
"options",
".",
"noBundle",
")",
"{",
"_log",
"(",
"'using provided bundle %s since noBundle is true'",
",",
"options",
".",
"input",
",",
")",
";",
"const",
"source",
"=",
"fs",
".",
"readFileSyn... | Bundle the application into one script | [
"Bundle",
"the",
"application",
"into",
"one",
"script"
] | 345bacd2c36f9648b416f74d2e41cdf55c2cc1f9 | https://github.com/anmonteiro/lumo/blob/345bacd2c36f9648b416f74d2e41cdf55c2cc1f9/vendor/nexe/exe.js#L175-L202 | train |
anmonteiro/lumo | vendor/nexe/exe.js | cleanUpOldExecutable | function cleanUpOldExecutable(next) {
fs.unlink(nodeCompiler.releasePath, function(err) {
if (err) {
if (err.code === 'ENOENT') {
next();
} else {
throw err;
}
} else {
next();
}
});
} | javascript | function cleanUpOldExecutable(next) {
fs.unlink(nodeCompiler.releasePath, function(err) {
if (err) {
if (err.code === 'ENOENT') {
next();
} else {
throw err;
}
} else {
next();
}
});
} | [
"function",
"cleanUpOldExecutable",
"(",
"next",
")",
"{",
"fs",
".",
"unlink",
"(",
"nodeCompiler",
".",
"releasePath",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"if",
"(",
"err",
".",
"code",
"===",
"'ENOENT'",
")",
"{",
"n... | If an old compiled executable exists in the Release directory, delete it.
This lets us see if the build failed by checking the existence of this file later. | [
"If",
"an",
"old",
"compiled",
"executable",
"exists",
"in",
"the",
"Release",
"directory",
"delete",
"it",
".",
"This",
"lets",
"us",
"see",
"if",
"the",
"build",
"failed",
"by",
"checking",
"the",
"existence",
"of",
"this",
"file",
"later",
"."
] | 345bacd2c36f9648b416f74d2e41cdf55c2cc1f9 | https://github.com/anmonteiro/lumo/blob/345bacd2c36f9648b416f74d2e41cdf55c2cc1f9/vendor/nexe/exe.js#L245-L257 | train |
anmonteiro/lumo | vendor/nexe/exe.js | checkThatExecutableExists | function checkThatExecutableExists(next) {
fs.exists(nodeCompiler.releasePath, function(exists) {
if (!exists) {
_log(
'error',
'The release executable has not been generated. ' +
'This indicates a failure in the build process. ' +
... | javascript | function checkThatExecutableExists(next) {
fs.exists(nodeCompiler.releasePath, function(exists) {
if (!exists) {
_log(
'error',
'The release executable has not been generated. ' +
'This indicates a failure in the build process. ' +
... | [
"function",
"checkThatExecutableExists",
"(",
"next",
")",
"{",
"fs",
".",
"exists",
"(",
"nodeCompiler",
".",
"releasePath",
",",
"function",
"(",
"exists",
")",
"{",
"if",
"(",
"!",
"exists",
")",
"{",
"_log",
"(",
"'error'",
",",
"'The release executable ... | Verify that the executable was compiled successfully | [
"Verify",
"that",
"the",
"executable",
"was",
"compiled",
"successfully"
] | 345bacd2c36f9648b416f74d2e41cdf55c2cc1f9 | https://github.com/anmonteiro/lumo/blob/345bacd2c36f9648b416f74d2e41cdf55c2cc1f9/vendor/nexe/exe.js#L286-L300 | train |
anmonteiro/lumo | vendor/nexe/exe.js | copyBinaryToOutput | function copyBinaryToOutput(next) {
_log('cp %s %s', nodeCompiler.releasePath, options.output);
ncp(nodeCompiler.releasePath, options.output, function(err) {
if (err) {
_log('error', "Couldn't copy binary.");
throw err; // dump raw error object
}
_lo... | javascript | function copyBinaryToOutput(next) {
_log('cp %s %s', nodeCompiler.releasePath, options.output);
ncp(nodeCompiler.releasePath, options.output, function(err) {
if (err) {
_log('error', "Couldn't copy binary.");
throw err; // dump raw error object
}
_lo... | [
"function",
"copyBinaryToOutput",
"(",
"next",
")",
"{",
"_log",
"(",
"'cp %s %s'",
",",
"nodeCompiler",
".",
"releasePath",
",",
"options",
".",
"output",
")",
";",
"ncp",
"(",
"nodeCompiler",
".",
"releasePath",
",",
"options",
".",
"output",
",",
"functio... | Copy the compilied binary to the output specified. | [
"Copy",
"the",
"compilied",
"binary",
"to",
"the",
"output",
"specified",
"."
] | 345bacd2c36f9648b416f74d2e41cdf55c2cc1f9 | https://github.com/anmonteiro/lumo/blob/345bacd2c36f9648b416f74d2e41cdf55c2cc1f9/vendor/nexe/exe.js#L306-L317 | train |
anmonteiro/lumo | vendor/nexe/exe.js | downloadNode | function downloadNode(next) {
if (fs.existsSync(nodeFilePath)) return next();
var uri = framework;
if (framework === 'node') {
uri = 'nodejs'; // if node, use nodejs uri
} else if (framework === 'nodejs') {
framework = 'node'; // support nodejs, and node, as framewo... | javascript | function downloadNode(next) {
if (fs.existsSync(nodeFilePath)) return next();
var uri = framework;
if (framework === 'node') {
uri = 'nodejs'; // if node, use nodejs uri
} else if (framework === 'nodejs') {
framework = 'node'; // support nodejs, and node, as framewo... | [
"function",
"downloadNode",
"(",
"next",
")",
"{",
"if",
"(",
"fs",
".",
"existsSync",
"(",
"nodeFilePath",
")",
")",
"return",
"next",
"(",
")",
";",
"var",
"uri",
"=",
"framework",
";",
"if",
"(",
"framework",
"===",
"'node'",
")",
"{",
"uri",
"=",... | download node into the target directory | [
"download",
"node",
"into",
"the",
"target",
"directory"
] | 345bacd2c36f9648b416f74d2e41cdf55c2cc1f9 | https://github.com/anmonteiro/lumo/blob/345bacd2c36f9648b416f74d2e41cdf55c2cc1f9/vendor/nexe/exe.js#L372-L420 | train |
anmonteiro/lumo | vendor/nexe/exe.js | unzipNodeTarball | function unzipNodeTarball(next) {
var onError = function(err) {
console.log(err.stack);
_log('error', 'failed to extract the node source');
process.exit(1);
};
if (isWin) {
_log('extracting the node source [node-tar.gz]');
// tar-stream method ... | javascript | function unzipNodeTarball(next) {
var onError = function(err) {
console.log(err.stack);
_log('error', 'failed to extract the node source');
process.exit(1);
};
if (isWin) {
_log('extracting the node source [node-tar.gz]');
// tar-stream method ... | [
"function",
"unzipNodeTarball",
"(",
"next",
")",
"{",
"var",
"onError",
"=",
"function",
"(",
"err",
")",
"{",
"console",
".",
"log",
"(",
"err",
".",
"stack",
")",
";",
"_log",
"(",
"'error'",
",",
"'failed to extract the node source'",
")",
";",
"proces... | unzip in the same directory | [
"unzip",
"in",
"the",
"same",
"directory"
] | 345bacd2c36f9648b416f74d2e41cdf55c2cc1f9 | https://github.com/anmonteiro/lumo/blob/345bacd2c36f9648b416f74d2e41cdf55c2cc1f9/vendor/nexe/exe.js#L426-L505 | train |
anmonteiro/lumo | vendor/nexe/exe.js | _loop | function _loop(dir) {
/* eventually try every python file */
var pdir = fs.readdirSync(dir);
pdir.forEach(function(v, i) {
var stat = fs.statSync(dir + '/' + v);
if (stat.isFile()) {
// only process Makefiles and .mk targets.
... | javascript | function _loop(dir) {
/* eventually try every python file */
var pdir = fs.readdirSync(dir);
pdir.forEach(function(v, i) {
var stat = fs.statSync(dir + '/' + v);
if (stat.isFile()) {
// only process Makefiles and .mk targets.
... | [
"function",
"_loop",
"(",
"dir",
")",
"{",
"/* eventually try every python file */",
"var",
"pdir",
"=",
"fs",
".",
"readdirSync",
"(",
"dir",
")",
";",
"pdir",
".",
"forEach",
"(",
"function",
"(",
"v",
",",
"i",
")",
"{",
"var",
"stat",
"=",
"fs",
".... | local function, move to top eventually | [
"local",
"function",
"move",
"to",
"top",
"eventually"
] | 345bacd2c36f9648b416f74d2e41cdf55c2cc1f9 | https://github.com/anmonteiro/lumo/blob/345bacd2c36f9648b416f74d2e41cdf55c2cc1f9/vendor/nexe/exe.js#L602-L632 | train |
anmonteiro/lumo | vendor/nexe/exe.js | _monkeyPatchGyp | function _monkeyPatchGyp(compiler, options, complete) {
const hasNexeres = options.resourceFiles.length > 0;
const gypPath = path.join(compiler.dir, 'node.gyp');
let replacementString = "'lib/fs.js', 'lib/_third_party_main.js', ";
if (hasNexeres) {
replacementString += "'lib/nexeres.js', ";
}
_monkeyp... | javascript | function _monkeyPatchGyp(compiler, options, complete) {
const hasNexeres = options.resourceFiles.length > 0;
const gypPath = path.join(compiler.dir, 'node.gyp');
let replacementString = "'lib/fs.js', 'lib/_third_party_main.js', ";
if (hasNexeres) {
replacementString += "'lib/nexeres.js', ";
}
_monkeyp... | [
"function",
"_monkeyPatchGyp",
"(",
"compiler",
",",
"options",
",",
"complete",
")",
"{",
"const",
"hasNexeres",
"=",
"options",
".",
"resourceFiles",
".",
"length",
">",
"0",
";",
"const",
"gypPath",
"=",
"path",
".",
"join",
"(",
"compiler",
".",
"dir",... | patch the gyp file to allow our custom includes | [
"patch",
"the",
"gyp",
"file",
"to",
"allow",
"our",
"custom",
"includes"
] | 345bacd2c36f9648b416f74d2e41cdf55c2cc1f9 | https://github.com/anmonteiro/lumo/blob/345bacd2c36f9648b416f74d2e41cdf55c2cc1f9/vendor/nexe/exe.js#L758-L784 | train |
anmonteiro/lumo | vendor/nexe/exe.js | _monkeyPatchConfigure | function _monkeyPatchConfigure(compiler, complete, options) {
var configurePath = path.join(compiler.dir, 'configure.py');
var snapshotPath = options.startupSnapshot;
if (snapshotPath != null) {
_log('monkey patching configure file');
snapshotPath = path.join(process.cwd(), snapshotPath);
return _mon... | javascript | function _monkeyPatchConfigure(compiler, complete, options) {
var configurePath = path.join(compiler.dir, 'configure.py');
var snapshotPath = options.startupSnapshot;
if (snapshotPath != null) {
_log('monkey patching configure file');
snapshotPath = path.join(process.cwd(), snapshotPath);
return _mon... | [
"function",
"_monkeyPatchConfigure",
"(",
"compiler",
",",
"complete",
",",
"options",
")",
"{",
"var",
"configurePath",
"=",
"path",
".",
"join",
"(",
"compiler",
".",
"dir",
",",
"'configure.py'",
")",
";",
"var",
"snapshotPath",
"=",
"options",
".",
"star... | patch the configure file to allow for custom startup snapshots | [
"patch",
"the",
"configure",
"file",
"to",
"allow",
"for",
"custom",
"startup",
"snapshots"
] | 345bacd2c36f9648b416f74d2e41cdf55c2cc1f9 | https://github.com/anmonteiro/lumo/blob/345bacd2c36f9648b416f74d2e41cdf55c2cc1f9/vendor/nexe/exe.js#L810-L840 | train |
anmonteiro/lumo | vendor/nexe/exe.js | _monkeyPatchMainCc | function _monkeyPatchMainCc(compiler, complete) {
let finalContents;
let mainPath = path.join(compiler.dir, 'src', 'node.cc');
let mainC = fs.readFileSync(mainPath, {
encoding: 'utf8',
});
// content split, and original start/end
let constant_loc = 1;
let lines = mainC.split('\n');
let startLine =... | javascript | function _monkeyPatchMainCc(compiler, complete) {
let finalContents;
let mainPath = path.join(compiler.dir, 'src', 'node.cc');
let mainC = fs.readFileSync(mainPath, {
encoding: 'utf8',
});
// content split, and original start/end
let constant_loc = 1;
let lines = mainC.split('\n');
let startLine =... | [
"function",
"_monkeyPatchMainCc",
"(",
"compiler",
",",
"complete",
")",
"{",
"let",
"finalContents",
";",
"let",
"mainPath",
"=",
"path",
".",
"join",
"(",
"compiler",
".",
"dir",
",",
"'src'",
",",
"'node.cc'",
")",
";",
"let",
"mainC",
"=",
"fs",
".",... | Patch node.cc to not check the internal arguments. | [
"Patch",
"node",
".",
"cc",
"to",
"not",
"check",
"the",
"internal",
"arguments",
"."
] | 345bacd2c36f9648b416f74d2e41cdf55c2cc1f9 | https://github.com/anmonteiro/lumo/blob/345bacd2c36f9648b416f74d2e41cdf55c2cc1f9/vendor/nexe/exe.js#L846-L938 | train |
anmonteiro/lumo | vendor/nexe/exe.js | _getFirstDirectory | function _getFirstDirectory(dir) {
var files = glob.sync(dir + '/*');
for (var i = files.length; i--; ) {
var file = files[i];
if (fs.statSync(file).isDirectory()) return file;
}
return false;
} | javascript | function _getFirstDirectory(dir) {
var files = glob.sync(dir + '/*');
for (var i = files.length; i--; ) {
var file = files[i];
if (fs.statSync(file).isDirectory()) return file;
}
return false;
} | [
"function",
"_getFirstDirectory",
"(",
"dir",
")",
"{",
"var",
"files",
"=",
"glob",
".",
"sync",
"(",
"dir",
"+",
"'/*'",
")",
";",
"for",
"(",
"var",
"i",
"=",
"files",
".",
"length",
";",
"i",
"--",
";",
")",
"{",
"var",
"file",
"=",
"files",
... | Get the first directory of a string. | [
"Get",
"the",
"first",
"directory",
"of",
"a",
"string",
"."
] | 345bacd2c36f9648b416f74d2e41cdf55c2cc1f9 | https://github.com/anmonteiro/lumo/blob/345bacd2c36f9648b416f74d2e41cdf55c2cc1f9/vendor/nexe/exe.js#L1078-L1087 | train |
anmonteiro/lumo | vendor/nexe/exe.js | _logProgress | function _logProgress(req) {
req.on('response', function(resp) {
var len = parseInt(resp.headers['content-length'], 10),
bar = new ProgressBar('[:bar]', {
complete: '=',
incomplete: ' ',
total: len,
width: 100, // just use 100
});
req.on('data', function(chunk) {
... | javascript | function _logProgress(req) {
req.on('response', function(resp) {
var len = parseInt(resp.headers['content-length'], 10),
bar = new ProgressBar('[:bar]', {
complete: '=',
incomplete: ' ',
total: len,
width: 100, // just use 100
});
req.on('data', function(chunk) {
... | [
"function",
"_logProgress",
"(",
"req",
")",
"{",
"req",
".",
"on",
"(",
"'response'",
",",
"function",
"(",
"resp",
")",
"{",
"var",
"len",
"=",
"parseInt",
"(",
"resp",
".",
"headers",
"[",
"'content-length'",
"]",
",",
"10",
")",
",",
"bar",
"=",
... | Log the progress of a request object. | [
"Log",
"the",
"progress",
"of",
"a",
"request",
"object",
"."
] | 345bacd2c36f9648b416f74d2e41cdf55c2cc1f9 | https://github.com/anmonteiro/lumo/blob/345bacd2c36f9648b416f74d2e41cdf55c2cc1f9/vendor/nexe/exe.js#L1093-L1115 | train |
sequelize/umzug | src/helper.js | function (packageName) {
let result;
try {
result = require.resolve(packageName, { basedir: process.cwd() });
result = require(result);
} catch (e) {
try {
result = require(packageName);
} catch (e) {
result = undefined;
}
}
return result;
} | javascript | function (packageName) {
let result;
try {
result = require.resolve(packageName, { basedir: process.cwd() });
result = require(result);
} catch (e) {
try {
result = require(packageName);
} catch (e) {
result = undefined;
}
}
return result;
} | [
"function",
"(",
"packageName",
")",
"{",
"let",
"result",
";",
"try",
"{",
"result",
"=",
"require",
".",
"resolve",
"(",
"packageName",
",",
"{",
"basedir",
":",
"process",
".",
"cwd",
"(",
")",
"}",
")",
";",
"result",
"=",
"require",
"(",
"result... | Try to require module from file relative to process cwd or regular require.
@param {string} packageName - Filename relative to process' cwd or package
name to be required.
@returns {*|undefined} Required module | [
"Try",
"to",
"require",
"module",
"from",
"file",
"relative",
"to",
"process",
"cwd",
"or",
"regular",
"require",
"."
] | ebb08d65d5365a77d54b68eb87e2cc1249cb727a | https://github.com/sequelize/umzug/blob/ebb08d65d5365a77d54b68eb87e2cc1249cb727a/src/helper.js#L9-L24 | train | |
openlayers/ol-mapbox-style | webpack.config.js | getExamples | function getExamples(dirName, callback) {
const example_files = fs.readdirSync(dirName);
const entries = {};
// iterate through the list of files in the directory.
for (const filename of example_files) {
// ooo, javascript file!
if (filename.endsWith('.js')) {
// trim the entry name down to the f... | javascript | function getExamples(dirName, callback) {
const example_files = fs.readdirSync(dirName);
const entries = {};
// iterate through the list of files in the directory.
for (const filename of example_files) {
// ooo, javascript file!
if (filename.endsWith('.js')) {
// trim the entry name down to the f... | [
"function",
"getExamples",
"(",
"dirName",
",",
"callback",
")",
"{",
"const",
"example_files",
"=",
"fs",
".",
"readdirSync",
"(",
"dirName",
")",
";",
"const",
"entries",
"=",
"{",
"}",
";",
"// iterate through the list of files in the directory.",
"for",
"(",
... | Get the list of examples from the example directory.
@param {String} dirName - Name of the directory to read.
@param {Function} callback - Function to execute for each example.
@returns {undefined} Nothing. | [
"Get",
"the",
"list",
"of",
"examples",
"from",
"the",
"example",
"directory",
"."
] | 69f9032f98e7b11f17f581d6d4a6fdfcb4bea2db | https://github.com/openlayers/ol-mapbox-style/blob/69f9032f98e7b11f17f581d6d4a6fdfcb4bea2db/webpack.config.js#L14-L29 | train |
openlayers/ol-mapbox-style | webpack.config.js | getEntries | function getEntries(dirName) {
const entries = {};
getExamples(dirName, (entryName, filename) => {
entries[entryName] = filename;
});
return entries;
} | javascript | function getEntries(dirName) {
const entries = {};
getExamples(dirName, (entryName, filename) => {
entries[entryName] = filename;
});
return entries;
} | [
"function",
"getEntries",
"(",
"dirName",
")",
"{",
"const",
"entries",
"=",
"{",
"}",
";",
"getExamples",
"(",
"dirName",
",",
"(",
"entryName",
",",
"filename",
")",
"=>",
"{",
"entries",
"[",
"entryName",
"]",
"=",
"filename",
";",
"}",
")",
";",
... | Creates an object with the entry names and file names
to be transformed.
@param {String} dirName - Name of the directory to read.
@returns {Object} with webpack entry points. | [
"Creates",
"an",
"object",
"with",
"the",
"entry",
"names",
"and",
"file",
"names",
"to",
"be",
"transformed",
"."
] | 69f9032f98e7b11f17f581d6d4a6fdfcb4bea2db | https://github.com/openlayers/ol-mapbox-style/blob/69f9032f98e7b11f17f581d6d4a6fdfcb4bea2db/webpack.config.js#L38-L44 | train |
openlayers/ol-mapbox-style | webpack.config.js | getHtmlTemplates | function getHtmlTemplates(dirName) {
const html_conf = [];
// create the array of HTML plugins.
const template = path.join(dirName, '_template.html');
getExamples(dirName, (entryName, filename) => {
html_conf.push(
new HtmlWebpackPlugin({
title: entryName,
// ensure each output has a u... | javascript | function getHtmlTemplates(dirName) {
const html_conf = [];
// create the array of HTML plugins.
const template = path.join(dirName, '_template.html');
getExamples(dirName, (entryName, filename) => {
html_conf.push(
new HtmlWebpackPlugin({
title: entryName,
// ensure each output has a u... | [
"function",
"getHtmlTemplates",
"(",
"dirName",
")",
"{",
"const",
"html_conf",
"=",
"[",
"]",
";",
"// create the array of HTML plugins.",
"const",
"template",
"=",
"path",
".",
"join",
"(",
"dirName",
",",
"'_template.html'",
")",
";",
"getExamples",
"(",
"dir... | Each example needs a dedicated HTML file.
This will create a "plugin" that outputs HTML from a template.
@param {String} dirName - Name of the directory to read.
@returns {Array} specifying webpack plugins. | [
"Each",
"example",
"needs",
"a",
"dedicated",
"HTML",
"file",
".",
"This",
"will",
"create",
"a",
"plugin",
"that",
"outputs",
"HTML",
"from",
"a",
"template",
"."
] | 69f9032f98e7b11f17f581d6d4a6fdfcb4bea2db | https://github.com/openlayers/ol-mapbox-style/blob/69f9032f98e7b11f17f581d6d4a6fdfcb4bea2db/webpack.config.js#L53-L71 | train |
leonidas/transparency | examples/todomvc/architecture-examples/backbone/js/views/app.js | function() {
return {
title: this.input.val().trim(),
order: window.app.Todos.nextOrder(),
completed: false
};
} | javascript | function() {
return {
title: this.input.val().trim(),
order: window.app.Todos.nextOrder(),
completed: false
};
} | [
"function",
"(",
")",
"{",
"return",
"{",
"title",
":",
"this",
".",
"input",
".",
"val",
"(",
")",
".",
"trim",
"(",
")",
",",
"order",
":",
"window",
".",
"app",
".",
"Todos",
".",
"nextOrder",
"(",
")",
",",
"completed",
":",
"false",
"}",
"... | Generate the attributes for a new Todo item. | [
"Generate",
"the",
"attributes",
"for",
"a",
"new",
"Todo",
"item",
"."
] | 92149b83e7202423a764e1cc2ec5d78e43f77ce2 | https://github.com/leonidas/transparency/blob/92149b83e7202423a764e1cc2ec5d78e43f77ce2/examples/todomvc/architecture-examples/backbone/js/views/app.js#L99-L105 | train | |
leonidas/transparency | examples/todomvc/architecture-examples/backbone/js/views/app.js | function() {
_.each(window.app.Todos.completed(), function(todo){ todo.destroy(); });
return false;
} | javascript | function() {
_.each(window.app.Todos.completed(), function(todo){ todo.destroy(); });
return false;
} | [
"function",
"(",
")",
"{",
"_",
".",
"each",
"(",
"window",
".",
"app",
".",
"Todos",
".",
"completed",
"(",
")",
",",
"function",
"(",
"todo",
")",
"{",
"todo",
".",
"destroy",
"(",
")",
";",
"}",
")",
";",
"return",
"false",
";",
"}"
] | Clear all completed todo items, destroying their models. | [
"Clear",
"all",
"completed",
"todo",
"items",
"destroying",
"their",
"models",
"."
] | 92149b83e7202423a764e1cc2ec5d78e43f77ce2 | https://github.com/leonidas/transparency/blob/92149b83e7202423a764e1cc2ec5d78e43f77ce2/examples/todomvc/architecture-examples/backbone/js/views/app.js#L124-L127 | train | |
socib/Leaflet.TimeDimension | examples/js/example15.js | function(feature, minTime, maxTime) {
var featureStringTimes = this._getFeatureTimes(feature);
if (featureStringTimes.length == 0) {
return feature;
}
var featureTimes = [];
for (var i = 0, l = featureStringTimes.length; i < l; i++) {
var time = featureStr... | javascript | function(feature, minTime, maxTime) {
var featureStringTimes = this._getFeatureTimes(feature);
if (featureStringTimes.length == 0) {
return feature;
}
var featureTimes = [];
for (var i = 0, l = featureStringTimes.length; i < l; i++) {
var time = featureStr... | [
"function",
"(",
"feature",
",",
"minTime",
",",
"maxTime",
")",
"{",
"var",
"featureStringTimes",
"=",
"this",
".",
"_getFeatureTimes",
"(",
"feature",
")",
";",
"if",
"(",
"featureStringTimes",
".",
"length",
"==",
"0",
")",
"{",
"return",
"feature",
";"... | Do not modify features. Just return the feature if it intersects the time interval | [
"Do",
"not",
"modify",
"features",
".",
"Just",
"return",
"the",
"feature",
"if",
"it",
"intersects",
"the",
"time",
"interval"
] | 8045c2e8a62520fe647e41ab5801fe6bc7b021af | https://github.com/socib/Leaflet.TimeDimension/blob/8045c2e8a62520fe647e41ab5801fe6bc7b021af/examples/js/example15.js#L25-L43 | train | |
pillarjs/router | index.js | generateOptionsResponder | function generateOptionsResponder(res, methods) {
return function onDone(fn, err) {
if (err || methods.length === 0) {
return fn(err)
}
trySendOptionsResponse(res, methods, fn)
}
} | javascript | function generateOptionsResponder(res, methods) {
return function onDone(fn, err) {
if (err || methods.length === 0) {
return fn(err)
}
trySendOptionsResponse(res, methods, fn)
}
} | [
"function",
"generateOptionsResponder",
"(",
"res",
",",
"methods",
")",
"{",
"return",
"function",
"onDone",
"(",
"fn",
",",
"err",
")",
"{",
"if",
"(",
"err",
"||",
"methods",
".",
"length",
"===",
"0",
")",
"{",
"return",
"fn",
"(",
"err",
")",
"}... | Generate a callback that will make an OPTIONS response.
@param {OutgoingMessage} res
@param {array} methods
@private | [
"Generate",
"a",
"callback",
"that",
"will",
"make",
"an",
"OPTIONS",
"response",
"."
] | 51c56e61b40ab486a936df7d6b09db006a3e9159 | https://github.com/pillarjs/router/blob/51c56e61b40ab486a936df7d6b09db006a3e9159/index.js#L546-L554 | train |
pillarjs/router | index.js | mergeParams | function mergeParams(params, parent) {
if (typeof parent !== 'object' || !parent) {
return params
}
// make copy of parent for base
var obj = mixin({}, parent)
// simple non-numeric merging
if (!(0 in params) || !(0 in parent)) {
return mixin(obj, params)
}
var i = 0
var o = 0
// determi... | javascript | function mergeParams(params, parent) {
if (typeof parent !== 'object' || !parent) {
return params
}
// make copy of parent for base
var obj = mixin({}, parent)
// simple non-numeric merging
if (!(0 in params) || !(0 in parent)) {
return mixin(obj, params)
}
var i = 0
var o = 0
// determi... | [
"function",
"mergeParams",
"(",
"params",
",",
"parent",
")",
"{",
"if",
"(",
"typeof",
"parent",
"!==",
"'object'",
"||",
"!",
"parent",
")",
"{",
"return",
"params",
"}",
"// make copy of parent for base",
"var",
"obj",
"=",
"mixin",
"(",
"{",
"}",
",",
... | Merge params with parent params
@private | [
"Merge",
"params",
"with",
"parent",
"params"
] | 51c56e61b40ab486a936df7d6b09db006a3e9159 | https://github.com/pillarjs/router/blob/51c56e61b40ab486a936df7d6b09db006a3e9159/index.js#L616-L653 | train |
pillarjs/router | index.js | restore | function restore(fn, obj) {
var props = new Array(arguments.length - 2)
var vals = new Array(arguments.length - 2)
for (var i = 0; i < props.length; i++) {
props[i] = arguments[i + 2]
vals[i] = obj[props[i]]
}
return function(){
// restore vals
for (var i = 0; i < props.length; i++) {
... | javascript | function restore(fn, obj) {
var props = new Array(arguments.length - 2)
var vals = new Array(arguments.length - 2)
for (var i = 0; i < props.length; i++) {
props[i] = arguments[i + 2]
vals[i] = obj[props[i]]
}
return function(){
// restore vals
for (var i = 0; i < props.length; i++) {
... | [
"function",
"restore",
"(",
"fn",
",",
"obj",
")",
"{",
"var",
"props",
"=",
"new",
"Array",
"(",
"arguments",
".",
"length",
"-",
"2",
")",
"var",
"vals",
"=",
"new",
"Array",
"(",
"arguments",
".",
"length",
"-",
"2",
")",
"for",
"(",
"var",
"i... | Restore obj props after function
@private | [
"Restore",
"obj",
"props",
"after",
"function"
] | 51c56e61b40ab486a936df7d6b09db006a3e9159 | https://github.com/pillarjs/router/blob/51c56e61b40ab486a936df7d6b09db006a3e9159/index.js#L661-L678 | train |
pillarjs/router | index.js | sendOptionsResponse | function sendOptionsResponse(res, methods) {
var options = Object.create(null)
// build unique method map
for (var i = 0; i < methods.length; i++) {
options[methods[i]] = true
}
// construct the allow list
var allow = Object.keys(options).sort().join(', ')
// send response
res.setHeader('Allow', ... | javascript | function sendOptionsResponse(res, methods) {
var options = Object.create(null)
// build unique method map
for (var i = 0; i < methods.length; i++) {
options[methods[i]] = true
}
// construct the allow list
var allow = Object.keys(options).sort().join(', ')
// send response
res.setHeader('Allow', ... | [
"function",
"sendOptionsResponse",
"(",
"res",
",",
"methods",
")",
"{",
"var",
"options",
"=",
"Object",
".",
"create",
"(",
"null",
")",
"// build unique method map",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"methods",
".",
"length",
";",
"i",
... | Send an OPTIONS response.
@private | [
"Send",
"an",
"OPTIONS",
"response",
"."
] | 51c56e61b40ab486a936df7d6b09db006a3e9159 | https://github.com/pillarjs/router/blob/51c56e61b40ab486a936df7d6b09db006a3e9159/index.js#L686-L703 | train |
pillarjs/router | index.js | trySendOptionsResponse | function trySendOptionsResponse(res, methods, next) {
try {
sendOptionsResponse(res, methods)
} catch (err) {
next(err)
}
} | javascript | function trySendOptionsResponse(res, methods, next) {
try {
sendOptionsResponse(res, methods)
} catch (err) {
next(err)
}
} | [
"function",
"trySendOptionsResponse",
"(",
"res",
",",
"methods",
",",
"next",
")",
"{",
"try",
"{",
"sendOptionsResponse",
"(",
"res",
",",
"methods",
")",
"}",
"catch",
"(",
"err",
")",
"{",
"next",
"(",
"err",
")",
"}",
"}"
] | Try to send an OPTIONS response.
@private | [
"Try",
"to",
"send",
"an",
"OPTIONS",
"response",
"."
] | 51c56e61b40ab486a936df7d6b09db006a3e9159 | https://github.com/pillarjs/router/blob/51c56e61b40ab486a936df7d6b09db006a3e9159/index.js#L711-L717 | train |
SC5/sc5-styleguide | lib/modules/section-references.js | reduceModifiers | function reduceModifiers (previousValue, currentValue) {
return previousValue + currentValue[property].replace(modifierPlaceholder, currentValue.className);
} | javascript | function reduceModifiers (previousValue, currentValue) {
return previousValue + currentValue[property].replace(modifierPlaceholder, currentValue.className);
} | [
"function",
"reduceModifiers",
"(",
"previousValue",
",",
"currentValue",
")",
"{",
"return",
"previousValue",
"+",
"currentValue",
"[",
"property",
"]",
".",
"replace",
"(",
"modifierPlaceholder",
",",
"currentValue",
".",
"className",
")",
";",
"}"
] | Concat all modifiers | [
"Concat",
"all",
"modifiers"
] | f573faba05643166f5c01c5faab3a4011c4173b7 | https://github.com/SC5/sc5-styleguide/blob/f573faba05643166f5c01c5faab3a4011c4173b7/lib/modules/section-references.js#L13-L15 | train |
SC5/sc5-styleguide | lib/modules/kss-parser.js | jsonSections | function jsonSections(sections, block) {
return sections.map(function(section) {
// Temporary inserting of partial
var partial = section;
if (partial.markup() && partial.markup().toString().match(/^[^\n]+\.(html|hbs|pug)$/)) {
partial.file = partial.markup().toString();
partial.name = path.ba... | javascript | function jsonSections(sections, block) {
return sections.map(function(section) {
// Temporary inserting of partial
var partial = section;
if (partial.markup() && partial.markup().toString().match(/^[^\n]+\.(html|hbs|pug)$/)) {
partial.file = partial.markup().toString();
partial.name = path.ba... | [
"function",
"jsonSections",
"(",
"sections",
",",
"block",
")",
"{",
"return",
"sections",
".",
"map",
"(",
"function",
"(",
"section",
")",
"{",
"// Temporary inserting of partial",
"var",
"partial",
"=",
"section",
";",
"if",
"(",
"partial",
".",
"markup",
... | Parses kss.KssSection to JSON | [
"Parses",
"kss",
".",
"KssSection",
"to",
"JSON"
] | f573faba05643166f5c01c5faab3a4011c4173b7 | https://github.com/SC5/sc5-styleguide/blob/f573faba05643166f5c01c5faab3a4011c4173b7/lib/modules/kss-parser.js#L14-L39 | train |
SC5/sc5-styleguide | lib/modules/kss-parser.js | jsonModifiers | function jsonModifiers(modifiers) {
return modifiers.map(function(modifier, id) {
return {
id: id + 1,
name: modifier.name(),
description: modifier.description(),
className: modifier.className(),
markup: modifier.markup() ? modifier.markup().toString() : null
};
});
} | javascript | function jsonModifiers(modifiers) {
return modifiers.map(function(modifier, id) {
return {
id: id + 1,
name: modifier.name(),
description: modifier.description(),
className: modifier.className(),
markup: modifier.markup() ? modifier.markup().toString() : null
};
});
} | [
"function",
"jsonModifiers",
"(",
"modifiers",
")",
"{",
"return",
"modifiers",
".",
"map",
"(",
"function",
"(",
"modifier",
",",
"id",
")",
"{",
"return",
"{",
"id",
":",
"id",
"+",
"1",
",",
"name",
":",
"modifier",
".",
"name",
"(",
")",
",",
"... | Parses kss.KssModifier to JSON | [
"Parses",
"kss",
".",
"KssModifier",
"to",
"JSON"
] | f573faba05643166f5c01c5faab3a4011c4173b7 | https://github.com/SC5/sc5-styleguide/blob/f573faba05643166f5c01c5faab3a4011c4173b7/lib/modules/kss-parser.js#L42-L52 | train |
dhotson/springy | springyui.js | intersect_line_line | function intersect_line_line(p1, p2, p3, p4) {
var denom = ((p4.y - p3.y)*(p2.x - p1.x) - (p4.x - p3.x)*(p2.y - p1.y));
// lines are parallel
if (denom === 0) {
return false;
}
var ua = ((p4.x - p3.x)*(p1.y - p3.y) - (p4.y - p3.y)*(p1.x - p3.x)) / denom;
var ub = ((p2.x - p1.x)*(p1.y - p3.y) - (p2.y - ... | javascript | function intersect_line_line(p1, p2, p3, p4) {
var denom = ((p4.y - p3.y)*(p2.x - p1.x) - (p4.x - p3.x)*(p2.y - p1.y));
// lines are parallel
if (denom === 0) {
return false;
}
var ua = ((p4.x - p3.x)*(p1.y - p3.y) - (p4.y - p3.y)*(p1.x - p3.x)) / denom;
var ub = ((p2.x - p1.x)*(p1.y - p3.y) - (p2.y - ... | [
"function",
"intersect_line_line",
"(",
"p1",
",",
"p2",
",",
"p3",
",",
"p4",
")",
"{",
"var",
"denom",
"=",
"(",
"(",
"p4",
".",
"y",
"-",
"p3",
".",
"y",
")",
"*",
"(",
"p2",
".",
"x",
"-",
"p1",
".",
"x",
")",
"-",
"(",
"p4",
".",
"x"... | helpers for figuring out where to draw arrows | [
"helpers",
"for",
"figuring",
"out",
"where",
"to",
"draw",
"arrows"
] | 9654b64f85f7f35220eaafee80894d33a00ef5ac | https://github.com/dhotson/springy/blob/9654b64f85f7f35220eaafee80894d33a00ef5ac/springyui.js#L358-L374 | train |
fernando-mc/serverless-finch | lib/bucketUtils.js | emptyBucket | function emptyBucket(aws, bucketName, keyPrefix) {
return listObjectsInBucket(aws, bucketName).then(resp => {
const contents = resp.Contents;
let testPrefix = false,
prefixRegexp;
if (!contents[0]) {
return Promise.resolve();
} else {
if (keyPrefix) {
testPrefix = true;
... | javascript | function emptyBucket(aws, bucketName, keyPrefix) {
return listObjectsInBucket(aws, bucketName).then(resp => {
const contents = resp.Contents;
let testPrefix = false,
prefixRegexp;
if (!contents[0]) {
return Promise.resolve();
} else {
if (keyPrefix) {
testPrefix = true;
... | [
"function",
"emptyBucket",
"(",
"aws",
",",
"bucketName",
",",
"keyPrefix",
")",
"{",
"return",
"listObjectsInBucket",
"(",
"aws",
",",
"bucketName",
")",
".",
"then",
"(",
"resp",
"=>",
"{",
"const",
"contents",
"=",
"resp",
".",
"Contents",
";",
"let",
... | Deletes all objects in an S3 bucket
@param {Object} aws - AWS class
@param {string} bucketName - Name of bucket to be deleted | [
"Deletes",
"all",
"objects",
"in",
"an",
"S3",
"bucket"
] | ccdc24b958385f65472fad19896b14279171de09 | https://github.com/fernando-mc/serverless-finch/blob/ccdc24b958385f65472fad19896b14279171de09/lib/bucketUtils.js#L51-L76 | train |
fernando-mc/serverless-finch | lib/configure.js | configureBucket | function configureBucket(
aws,
bucketName,
indexDocument,
errorDocument,
redirectAllRequestsTo,
routingRules
) {
const params = {
Bucket: bucketName,
WebsiteConfiguration: {}
};
if (redirectAllRequestsTo) {
params.WebsiteConfiguration.RedirectAllRequestsTo = {};
params.WebsiteConfigur... | javascript | function configureBucket(
aws,
bucketName,
indexDocument,
errorDocument,
redirectAllRequestsTo,
routingRules
) {
const params = {
Bucket: bucketName,
WebsiteConfiguration: {}
};
if (redirectAllRequestsTo) {
params.WebsiteConfiguration.RedirectAllRequestsTo = {};
params.WebsiteConfigur... | [
"function",
"configureBucket",
"(",
"aws",
",",
"bucketName",
",",
"indexDocument",
",",
"errorDocument",
",",
"redirectAllRequestsTo",
",",
"routingRules",
")",
"{",
"const",
"params",
"=",
"{",
"Bucket",
":",
"bucketName",
",",
"WebsiteConfiguration",
":",
"{",
... | Sets website configuration parameters for given bucket
@param {Object} aws - AWS class
@param {string} bucketName - Name of bucket to be configured
@param {string} indexDocument - Path to index document
@param {string} errorDocument - Path to error document
@param {Object} redirectAllRequestsTo - Configuration informat... | [
"Sets",
"website",
"configuration",
"parameters",
"for",
"given",
"bucket"
] | ccdc24b958385f65472fad19896b14279171de09 | https://github.com/fernando-mc/serverless-finch/blob/ccdc24b958385f65472fad19896b14279171de09/lib/configure.js#L12-L86 | train |
fernando-mc/serverless-finch | lib/configure.js | configurePolicyForBucket | function configurePolicyForBucket(aws, bucketName, customPolicy) {
const policy = customPolicy || {
Version: '2012-10-17',
Statement: [
{
Effect: 'Allow',
Principal: {
AWS: '*'
},
Action: 's3:GetObject',
Resource: `arn:aws:s3:::${bucketName}/*`
}
... | javascript | function configurePolicyForBucket(aws, bucketName, customPolicy) {
const policy = customPolicy || {
Version: '2012-10-17',
Statement: [
{
Effect: 'Allow',
Principal: {
AWS: '*'
},
Action: 's3:GetObject',
Resource: `arn:aws:s3:::${bucketName}/*`
}
... | [
"function",
"configurePolicyForBucket",
"(",
"aws",
",",
"bucketName",
",",
"customPolicy",
")",
"{",
"const",
"policy",
"=",
"customPolicy",
"||",
"{",
"Version",
":",
"'2012-10-17'",
",",
"Statement",
":",
"[",
"{",
"Effect",
":",
"'Allow'",
",",
"Principal"... | Configures policy for given bucket
@param {Object} aws - AWS class
@param {string} bucketName - Name of bucket to be configured | [
"Configures",
"policy",
"for",
"given",
"bucket"
] | ccdc24b958385f65472fad19896b14279171de09 | https://github.com/fernando-mc/serverless-finch/blob/ccdc24b958385f65472fad19896b14279171de09/lib/configure.js#L93-L114 | train |
fernando-mc/serverless-finch | lib/configure.js | configureCorsForBucket | function configureCorsForBucket(aws, bucketName) {
const params = {
Bucket: bucketName,
CORSConfiguration: require('./resources/CORSPolicy')
};
return aws.request('S3', 'putBucketCors', params);
} | javascript | function configureCorsForBucket(aws, bucketName) {
const params = {
Bucket: bucketName,
CORSConfiguration: require('./resources/CORSPolicy')
};
return aws.request('S3', 'putBucketCors', params);
} | [
"function",
"configureCorsForBucket",
"(",
"aws",
",",
"bucketName",
")",
"{",
"const",
"params",
"=",
"{",
"Bucket",
":",
"bucketName",
",",
"CORSConfiguration",
":",
"require",
"(",
"'./resources/CORSPolicy'",
")",
"}",
";",
"return",
"aws",
".",
"request",
... | Configures CORS policy for given bucket
@param {Object} aws - AWS class
@param {string} bucketName - Name of bucket to be configured | [
"Configures",
"CORS",
"policy",
"for",
"given",
"bucket"
] | ccdc24b958385f65472fad19896b14279171de09 | https://github.com/fernando-mc/serverless-finch/blob/ccdc24b958385f65472fad19896b14279171de09/lib/configure.js#L121-L128 | train |
fernando-mc/serverless-finch | lib/upload.js | uploadDirectory | function uploadDirectory(aws, bucketName, clientRoot, headerSpec, orderSpec, keyPrefix) {
const allFiles = getFileList(clientRoot);
const filesGroupedByOrder = groupFilesByOrder(allFiles, orderSpec);
return filesGroupedByOrder.reduce((existingUploads, files) => {
return existingUploads.then(existingResults ... | javascript | function uploadDirectory(aws, bucketName, clientRoot, headerSpec, orderSpec, keyPrefix) {
const allFiles = getFileList(clientRoot);
const filesGroupedByOrder = groupFilesByOrder(allFiles, orderSpec);
return filesGroupedByOrder.reduce((existingUploads, files) => {
return existingUploads.then(existingResults ... | [
"function",
"uploadDirectory",
"(",
"aws",
",",
"bucketName",
",",
"clientRoot",
",",
"headerSpec",
",",
"orderSpec",
",",
"keyPrefix",
")",
"{",
"const",
"allFiles",
"=",
"getFileList",
"(",
"clientRoot",
")",
";",
"const",
"filesGroupedByOrder",
"=",
"groupFil... | Uploads client files to an S3 bucket
@param {Object} aws - AWS class
@param {string} bucketName - Name of bucket to be configured
@param {string} clientRoot - Full path to the root directory of client files
@param {Object[]} headerSpec - Array of header values to add to files
@param {string[]} orderSpec - Array of rege... | [
"Uploads",
"client",
"files",
"to",
"an",
"S3",
"bucket"
] | ccdc24b958385f65472fad19896b14279171de09 | https://github.com/fernando-mc/serverless-finch/blob/ccdc24b958385f65472fad19896b14279171de09/lib/upload.js#L22-L36 | train |
fernando-mc/serverless-finch | lib/upload.js | uploadFile | function uploadFile(aws, bucketName, filePath, fileKey, headers) {
const baseHeaderKeys = [
'Cache-Control',
'Content-Disposition',
'Content-Encoding',
'Content-Language',
'Content-Type',
'Expires',
'Website-Redirect-Location'
];
const fileBuffer = fs.readFileSync(filePath);
const ... | javascript | function uploadFile(aws, bucketName, filePath, fileKey, headers) {
const baseHeaderKeys = [
'Cache-Control',
'Content-Disposition',
'Content-Encoding',
'Content-Language',
'Content-Type',
'Expires',
'Website-Redirect-Location'
];
const fileBuffer = fs.readFileSync(filePath);
const ... | [
"function",
"uploadFile",
"(",
"aws",
",",
"bucketName",
",",
"filePath",
",",
"fileKey",
",",
"headers",
")",
"{",
"const",
"baseHeaderKeys",
"=",
"[",
"'Cache-Control'",
",",
"'Content-Disposition'",
",",
"'Content-Encoding'",
",",
"'Content-Language'",
",",
"'C... | Uploads a file to an S3 bucket
@param {Object} aws - AWS class
@param {string} bucketName - Name of bucket to be configured
@param {string} filePath - Full path to file to be uploaded
@param {string} clientRoot - Full path to the root directory of client files | [
"Uploads",
"a",
"file",
"to",
"an",
"S3",
"bucket"
] | ccdc24b958385f65472fad19896b14279171de09 | https://github.com/fernando-mc/serverless-finch/blob/ccdc24b958385f65472fad19896b14279171de09/lib/upload.js#L45-L77 | train |
livoras/list-diff | lib/diff.js | makeKeyIndexAndFree | function makeKeyIndexAndFree (list, key) {
var keyIndex = {}
var free = []
for (var i = 0, len = list.length; i < len; i++) {
var item = list[i]
var itemKey = getItemKey(item, key)
if (itemKey) {
keyIndex[itemKey] = i
} else {
free.push(item)
}
}
return {
keyIn... | javascript | function makeKeyIndexAndFree (list, key) {
var keyIndex = {}
var free = []
for (var i = 0, len = list.length; i < len; i++) {
var item = list[i]
var itemKey = getItemKey(item, key)
if (itemKey) {
keyIndex[itemKey] = i
} else {
free.push(item)
}
}
return {
keyIn... | [
"function",
"makeKeyIndexAndFree",
"(",
"list",
",",
"key",
")",
"{",
"var",
"keyIndex",
"=",
"{",
"}",
"var",
"free",
"=",
"[",
"]",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"list",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++"... | Convert list to key-item keyIndex object.
@param {Array} list
@param {String|Function} key | [
"Convert",
"list",
"to",
"key",
"-",
"item",
"keyIndex",
"object",
"."
] | 7a35a1607e9f7baf3ab8c43bb68d424c6c0a7ca8 | https://github.com/livoras/list-diff/blob/7a35a1607e9f7baf3ab8c43bb68d424c6c0a7ca8/lib/diff.js#L128-L144 | train |
Travelport-Ukraine/uapi-json | src/Services/Air/AirFormat.js | setIndexesForSegments | function setIndexesForSegments(
segmentsObject = null,
serviceSegmentsObject = null
) {
const segments = segmentsObject
? Object.keys(segmentsObject).map(k => segmentsObject[k])
: null;
const serviceSegments = serviceSegmentsObject
? Object.keys(serviceSegmentsObject).map(k => serviceSegmentsObject... | javascript | function setIndexesForSegments(
segmentsObject = null,
serviceSegmentsObject = null
) {
const segments = segmentsObject
? Object.keys(segmentsObject).map(k => segmentsObject[k])
: null;
const serviceSegments = serviceSegmentsObject
? Object.keys(serviceSegmentsObject).map(k => serviceSegmentsObject... | [
"function",
"setIndexesForSegments",
"(",
"segmentsObject",
"=",
"null",
",",
"serviceSegmentsObject",
"=",
"null",
")",
"{",
"const",
"segments",
"=",
"segmentsObject",
"?",
"Object",
".",
"keys",
"(",
"segmentsObject",
")",
".",
"map",
"(",
"k",
"=>",
"segme... | This function used to transform segments and service segments objects
to arrays. After that this function try to set indexes with same as in
terminal response order. So it needs to check `TravelOrder` field for that.
@param segmentsObject
@param serviceSegmentsObject
@return {*} | [
"This",
"function",
"used",
"to",
"transform",
"segments",
"and",
"service",
"segments",
"objects",
"to",
"arrays",
".",
"After",
"that",
"this",
"function",
"try",
"to",
"set",
"indexes",
"with",
"same",
"as",
"in",
"terminal",
"response",
"order",
".",
"So... | de43c1add967e7af629fe155505197dc55d637d4 | https://github.com/Travelport-Ukraine/uapi-json/blob/de43c1add967e7af629fe155505197dc55d637d4/src/Services/Air/AirFormat.js#L244-L299 | train |
expressjs/cookie-parser | index.js | cookieParser | function cookieParser (secret, options) {
var secrets = !secret || Array.isArray(secret)
? (secret || [])
: [secret]
return function cookieParser (req, res, next) {
if (req.cookies) {
return next()
}
var cookies = req.headers.cookie
req.secret = secrets[0]
req.cookies = Object.c... | javascript | function cookieParser (secret, options) {
var secrets = !secret || Array.isArray(secret)
? (secret || [])
: [secret]
return function cookieParser (req, res, next) {
if (req.cookies) {
return next()
}
var cookies = req.headers.cookie
req.secret = secrets[0]
req.cookies = Object.c... | [
"function",
"cookieParser",
"(",
"secret",
",",
"options",
")",
"{",
"var",
"secrets",
"=",
"!",
"secret",
"||",
"Array",
".",
"isArray",
"(",
"secret",
")",
"?",
"(",
"secret",
"||",
"[",
"]",
")",
":",
"[",
"secret",
"]",
"return",
"function",
"coo... | Parse Cookie header and populate `req.cookies`
with an object keyed by the cookie names.
@param {string|array} [secret] A string (or array of strings) representing cookie signing secret(s).
@param {Object} [options]
@return {Function}
@public | [
"Parse",
"Cookie",
"header",
"and",
"populate",
"req",
".",
"cookies",
"with",
"an",
"object",
"keyed",
"by",
"the",
"cookie",
"names",
"."
] | 26fd91a024c58bf2dbe0a05c6b8831b180c12d11 | https://github.com/expressjs/cookie-parser/blob/26fd91a024c58bf2dbe0a05c6b8831b180c12d11/index.js#L39-L73 | train |
expressjs/cookie-parser | index.js | JSONCookie | function JSONCookie (str) {
if (typeof str !== 'string' || str.substr(0, 2) !== 'j:') {
return undefined
}
try {
return JSON.parse(str.slice(2))
} catch (err) {
return undefined
}
} | javascript | function JSONCookie (str) {
if (typeof str !== 'string' || str.substr(0, 2) !== 'j:') {
return undefined
}
try {
return JSON.parse(str.slice(2))
} catch (err) {
return undefined
}
} | [
"function",
"JSONCookie",
"(",
"str",
")",
"{",
"if",
"(",
"typeof",
"str",
"!==",
"'string'",
"||",
"str",
".",
"substr",
"(",
"0",
",",
"2",
")",
"!==",
"'j:'",
")",
"{",
"return",
"undefined",
"}",
"try",
"{",
"return",
"JSON",
".",
"parse",
"("... | Parse JSON cookie string.
@param {String} str
@return {Object} Parsed object or undefined if not json cookie
@public | [
"Parse",
"JSON",
"cookie",
"string",
"."
] | 26fd91a024c58bf2dbe0a05c6b8831b180c12d11 | https://github.com/expressjs/cookie-parser/blob/26fd91a024c58bf2dbe0a05c6b8831b180c12d11/index.js#L83-L93 | train |
expressjs/cookie-parser | index.js | JSONCookies | function JSONCookies (obj) {
var cookies = Object.keys(obj)
var key
var val
for (var i = 0; i < cookies.length; i++) {
key = cookies[i]
val = JSONCookie(obj[key])
if (val) {
obj[key] = val
}
}
return obj
} | javascript | function JSONCookies (obj) {
var cookies = Object.keys(obj)
var key
var val
for (var i = 0; i < cookies.length; i++) {
key = cookies[i]
val = JSONCookie(obj[key])
if (val) {
obj[key] = val
}
}
return obj
} | [
"function",
"JSONCookies",
"(",
"obj",
")",
"{",
"var",
"cookies",
"=",
"Object",
".",
"keys",
"(",
"obj",
")",
"var",
"key",
"var",
"val",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"cookies",
".",
"length",
";",
"i",
"++",
")",
"{",
"ke... | Parse JSON cookies.
@param {Object} obj
@return {Object}
@public | [
"Parse",
"JSON",
"cookies",
"."
] | 26fd91a024c58bf2dbe0a05c6b8831b180c12d11 | https://github.com/expressjs/cookie-parser/blob/26fd91a024c58bf2dbe0a05c6b8831b180c12d11/index.js#L103-L118 | train |
Yaffle/EventSource | src/eventsource.js | function () {
try {
return new TextDecoder().decode(new TextEncoder().encode("test"), {stream: true}) === "test";
} catch (error) {
console.log(error);
}
return false;
} | javascript | function () {
try {
return new TextDecoder().decode(new TextEncoder().encode("test"), {stream: true}) === "test";
} catch (error) {
console.log(error);
}
return false;
} | [
"function",
"(",
")",
"{",
"try",
"{",
"return",
"new",
"TextDecoder",
"(",
")",
".",
"decode",
"(",
"new",
"TextEncoder",
"(",
")",
".",
"encode",
"(",
"\"test\"",
")",
",",
"{",
"stream",
":",
"true",
"}",
")",
"===",
"\"test\"",
";",
"}",
"catch... | Firefox < 38 throws an error with stream option | [
"Firefox",
"<",
"38",
"throws",
"an",
"error",
"with",
"stream",
"option"
] | c68b58eb7c35591af763fd704699ac8c9816defe | https://github.com/Yaffle/EventSource/blob/c68b58eb7c35591af763fd704699ac8c9816defe/src/eventsource.js#L148-L155 | train | |
john-doherty/selenium-cucumber-js | page-objects/google-search.js | function (searchQuery) {
var selector = page.googleSearch.elements.searchInput;
// return a promise so the calling function knows the task has completed
return driver.findElement(selector).sendKeys(searchQuery, selenium.Key.ENTER);
} | javascript | function (searchQuery) {
var selector = page.googleSearch.elements.searchInput;
// return a promise so the calling function knows the task has completed
return driver.findElement(selector).sendKeys(searchQuery, selenium.Key.ENTER);
} | [
"function",
"(",
"searchQuery",
")",
"{",
"var",
"selector",
"=",
"page",
".",
"googleSearch",
".",
"elements",
".",
"searchInput",
";",
"// return a promise so the calling function knows the task has completed",
"return",
"driver",
".",
"findElement",
"(",
"selector",
... | enters a search term into Google's search box and presses enter
@param {string} searchQuery
@returns {Promise} a promise to enter the search values | [
"enters",
"a",
"search",
"term",
"into",
"Google",
"s",
"search",
"box",
"and",
"presses",
"enter"
] | d29cd32ffafdc405fa5279fc9b50361d75c91e3c | https://github.com/john-doherty/selenium-cucumber-js/blob/d29cd32ffafdc405fa5279fc9b50361d75c91e3c/page-objects/google-search.js#L15-L21 | train | |
john-doherty/selenium-cucumber-js | runtime/world.js | getDriverInstance | function getDriverInstance() {
var driver;
switch (browserName || '') {
case 'firefox': {
driver = new FireFoxDriver();
}
break;
case 'phantomjs': {
driver = new PhantomJSDriver();
}
break;
case 'electron': {
... | javascript | function getDriverInstance() {
var driver;
switch (browserName || '') {
case 'firefox': {
driver = new FireFoxDriver();
}
break;
case 'phantomjs': {
driver = new PhantomJSDriver();
}
break;
case 'electron': {
... | [
"function",
"getDriverInstance",
"(",
")",
"{",
"var",
"driver",
";",
"switch",
"(",
"browserName",
"||",
"''",
")",
"{",
"case",
"'firefox'",
":",
"{",
"driver",
"=",
"new",
"FireFoxDriver",
"(",
")",
";",
"}",
"break",
";",
"case",
"'phantomjs'",
":",
... | create the selenium browser based on global var set in index.js
@returns {ThenableWebDriver} selenium web driver | [
"create",
"the",
"selenium",
"browser",
"based",
"on",
"global",
"var",
"set",
"in",
"index",
".",
"js"
] | d29cd32ffafdc405fa5279fc9b50361d75c91e3c | https://github.com/john-doherty/selenium-cucumber-js/blob/d29cd32ffafdc405fa5279fc9b50361d75c91e3c/runtime/world.js#L32-L71 | train |
john-doherty/selenium-cucumber-js | runtime/world.js | getEyesInstance | function getEyesInstance() {
if (global.eyesKey) {
var eyes = new Eyes();
// retrieve eyes api key from config file in the project root as defined by the user
eyes.setApiKey(global.eyesKey);
return eyes;
}
return null;
} | javascript | function getEyesInstance() {
if (global.eyesKey) {
var eyes = new Eyes();
// retrieve eyes api key from config file in the project root as defined by the user
eyes.setApiKey(global.eyesKey);
return eyes;
}
return null;
} | [
"function",
"getEyesInstance",
"(",
")",
"{",
"if",
"(",
"global",
".",
"eyesKey",
")",
"{",
"var",
"eyes",
"=",
"new",
"Eyes",
"(",
")",
";",
"// retrieve eyes api key from config file in the project root as defined by the user",
"eyes",
".",
"setApiKey",
"(",
"glo... | Initialize the eyes SDK and set your private API key via the config file. | [
"Initialize",
"the",
"eyes",
"SDK",
"and",
"set",
"your",
"private",
"API",
"key",
"via",
"the",
"config",
"file",
"."
] | d29cd32ffafdc405fa5279fc9b50361d75c91e3c | https://github.com/john-doherty/selenium-cucumber-js/blob/d29cd32ffafdc405fa5279fc9b50361d75c91e3c/runtime/world.js#L77-L90 | train |
john-doherty/selenium-cucumber-js | runtime/world.js | createWorld | function createWorld() {
var runtime = {
driver: null, // the browser object
eyes: null,
selenium: selenium, // the raw nodejs selenium driver
By: selenium.By, // in keeping with Java expose selenium By
by: selenium.By, // provide ... | javascript | function createWorld() {
var runtime = {
driver: null, // the browser object
eyes: null,
selenium: selenium, // the raw nodejs selenium driver
By: selenium.By, // in keeping with Java expose selenium By
by: selenium.By, // provide ... | [
"function",
"createWorld",
"(",
")",
"{",
"var",
"runtime",
"=",
"{",
"driver",
":",
"null",
",",
"// the browser object",
"eyes",
":",
"null",
",",
"selenium",
":",
"selenium",
",",
"// the raw nodejs selenium driver",
"By",
":",
"selenium",
".",
"By",
",",
... | Creates a list of variables to expose globally and therefore accessible within each step definition
@returns {void} | [
"Creates",
"a",
"list",
"of",
"variables",
"to",
"expose",
"globally",
"and",
"therefore",
"accessible",
"within",
"each",
"step",
"definition"
] | d29cd32ffafdc405fa5279fc9b50361d75c91e3c | https://github.com/john-doherty/selenium-cucumber-js/blob/d29cd32ffafdc405fa5279fc9b50361d75c91e3c/runtime/world.js#L103-L128 | train |
john-doherty/selenium-cucumber-js | runtime/world.js | importSupportObjects | function importSupportObjects() {
// import shared objects from multiple paths (after global vars have been created)
if (global.sharedObjectPaths && Array.isArray(global.sharedObjectPaths) && global.sharedObjectPaths.length > 0) {
var allDirs = {};
// first require directories into objects by... | javascript | function importSupportObjects() {
// import shared objects from multiple paths (after global vars have been created)
if (global.sharedObjectPaths && Array.isArray(global.sharedObjectPaths) && global.sharedObjectPaths.length > 0) {
var allDirs = {};
// first require directories into objects by... | [
"function",
"importSupportObjects",
"(",
")",
"{",
"// import shared objects from multiple paths (after global vars have been created)",
"if",
"(",
"global",
".",
"sharedObjectPaths",
"&&",
"Array",
".",
"isArray",
"(",
"global",
".",
"sharedObjectPaths",
")",
"&&",
"global... | Import shared objects, pages object and helpers into global scope
@returns {void} | [
"Import",
"shared",
"objects",
"pages",
"object",
"and",
"helpers",
"into",
"global",
"scope"
] | d29cd32ffafdc405fa5279fc9b50361d75c91e3c | https://github.com/john-doherty/selenium-cucumber-js/blob/d29cd32ffafdc405fa5279fc9b50361d75c91e3c/runtime/world.js#L134-L169 | train |
john-doherty/selenium-cucumber-js | runtime/helpers.js | function(url, waitInSeconds) {
// use either passed in timeout or global default
var timeout = (waitInSeconds) ? (waitInSeconds * 1000) : DEFAULT_TIMEOUT;
// load the url and wait for it to complete
return driver.get(url).then(function() {
// now wait for the body element ... | javascript | function(url, waitInSeconds) {
// use either passed in timeout or global default
var timeout = (waitInSeconds) ? (waitInSeconds * 1000) : DEFAULT_TIMEOUT;
// load the url and wait for it to complete
return driver.get(url).then(function() {
// now wait for the body element ... | [
"function",
"(",
"url",
",",
"waitInSeconds",
")",
"{",
"// use either passed in timeout or global default",
"var",
"timeout",
"=",
"(",
"waitInSeconds",
")",
"?",
"(",
"waitInSeconds",
"*",
"1000",
")",
":",
"DEFAULT_TIMEOUT",
";",
"// load the url and wait for it to c... | returns a promise that is called when the url has loaded and the body element is present
@param {string} url - url to load
@param {integer} waitInSeconds - number of seconds to wait for page to load
@returns {Promise} resolved when url has loaded otherwise rejects
@example
helpers.loadPage('http://www.google.com'); | [
"returns",
"a",
"promise",
"that",
"is",
"called",
"when",
"the",
"url",
"has",
"loaded",
"and",
"the",
"body",
"element",
"is",
"present"
] | d29cd32ffafdc405fa5279fc9b50361d75c91e3c | https://github.com/john-doherty/selenium-cucumber-js/blob/d29cd32ffafdc405fa5279fc9b50361d75c91e3c/runtime/helpers.js#L11-L22 | train | |
john-doherty/selenium-cucumber-js | runtime/helpers.js | function (htmlCssSelector, attributeName) {
// get the element from the page
return driver.findElement(by.css(htmlCssSelector)).then(function(el) {
return el.getAttribute(attributeName);
});
} | javascript | function (htmlCssSelector, attributeName) {
// get the element from the page
return driver.findElement(by.css(htmlCssSelector)).then(function(el) {
return el.getAttribute(attributeName);
});
} | [
"function",
"(",
"htmlCssSelector",
",",
"attributeName",
")",
"{",
"// get the element from the page",
"return",
"driver",
".",
"findElement",
"(",
"by",
".",
"css",
"(",
"htmlCssSelector",
")",
")",
".",
"then",
"(",
"function",
"(",
"el",
")",
"{",
"return"... | returns the value of an attribute on an element
@param {string} htmlCssSelector - HTML css selector used to find the element
@param {string} attributeName - attribute name to retrieve
@returns {string} the value of the attribute or empty string if not found
@example
helpers.getAttributeValue('body', 'class'); | [
"returns",
"the",
"value",
"of",
"an",
"attribute",
"on",
"an",
"element"
] | d29cd32ffafdc405fa5279fc9b50361d75c91e3c | https://github.com/john-doherty/selenium-cucumber-js/blob/d29cd32ffafdc405fa5279fc9b50361d75c91e3c/runtime/helpers.js#L32-L38 | train | |
john-doherty/selenium-cucumber-js | runtime/helpers.js | function(elementSelector, attributeName, waitInMilliseconds) {
// use either passed in timeout or global default
var timeout = waitInMilliseconds || DEFAULT_TIMEOUT;
// readable error message
var timeoutMessage = attributeName + ' does not exists after ' + waitInMilliseconds + ' millis... | javascript | function(elementSelector, attributeName, waitInMilliseconds) {
// use either passed in timeout or global default
var timeout = waitInMilliseconds || DEFAULT_TIMEOUT;
// readable error message
var timeoutMessage = attributeName + ' does not exists after ' + waitInMilliseconds + ' millis... | [
"function",
"(",
"elementSelector",
",",
"attributeName",
",",
"waitInMilliseconds",
")",
"{",
"// use either passed in timeout or global default",
"var",
"timeout",
"=",
"waitInMilliseconds",
"||",
"DEFAULT_TIMEOUT",
";",
"// readable error message",
"var",
"timeoutMessage",
... | Waits until a HTML attribute exists
@param {string} elementSelector - HTML element CSS selector
@param {string} attributeName - name of the attribute to inspect
@param {integer} waitInMilliseconds - number of milliseconds to wait for page to load
@returns {Promise} resolves if attribute exists within timeout, otherwise... | [
"Waits",
"until",
"a",
"HTML",
"attribute",
"exists"
] | d29cd32ffafdc405fa5279fc9b50361d75c91e3c | https://github.com/john-doherty/selenium-cucumber-js/blob/d29cd32ffafdc405fa5279fc9b50361d75c91e3c/runtime/helpers.js#L169-L188 | train | |
ktquez/vue-head | vue-head.js | function () {
if (!els.length) return
els.map(function (el) {
el.parentElement.removeChild(el)
})
els = []
} | javascript | function () {
if (!els.length) return
els.map(function (el) {
el.parentElement.removeChild(el)
})
els = []
} | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"els",
".",
"length",
")",
"return",
"els",
".",
"map",
"(",
"function",
"(",
"el",
")",
"{",
"el",
".",
"parentElement",
".",
"removeChild",
"(",
"el",
")",
"}",
")",
"els",
"=",
"[",
"]",
"}"
] | Undo elements to its previous state
@type {Function} | [
"Undo",
"elements",
"to",
"its",
"previous",
"state"
] | 0ff9d248cea22191539606e3009ab7591f6c2f11 | https://github.com/ktquez/vue-head/blob/0ff9d248cea22191539606e3009ab7591f6c2f11/vue-head.js#L63-L69 | train | |
ktquez/vue-head | vue-head.js | function (obj, el) {
var self = this
Object.keys(obj).map(function (prop) {
var sh = self.shorthand[prop] || prop
if (sh.match(/(body|undo|replace)/g)) return
if (sh === 'inner') {
el.textContent = obj[prop]
return
}
el.setAttribute(sh, obj[prop])
... | javascript | function (obj, el) {
var self = this
Object.keys(obj).map(function (prop) {
var sh = self.shorthand[prop] || prop
if (sh.match(/(body|undo|replace)/g)) return
if (sh === 'inner') {
el.textContent = obj[prop]
return
}
el.setAttribute(sh, obj[prop])
... | [
"function",
"(",
"obj",
",",
"el",
")",
"{",
"var",
"self",
"=",
"this",
"Object",
".",
"keys",
"(",
"obj",
")",
".",
"map",
"(",
"function",
"(",
"prop",
")",
"{",
"var",
"sh",
"=",
"self",
".",
"shorthand",
"[",
"prop",
"]",
"||",
"prop",
"if... | Set attributes in element
@type {Function}
@param {Object} obj
@param {HTMLElement} el
@return {HTMLElement} with defined attributes | [
"Set",
"attributes",
"in",
"element"
] | 0ff9d248cea22191539606e3009ab7591f6c2f11 | https://github.com/ktquez/vue-head/blob/0ff9d248cea22191539606e3009ab7591f6c2f11/vue-head.js#L78-L90 | train | |
ktquez/vue-head | vue-head.js | function (obj) {
if (!obj) return
diffTitle.before = opt.complement
var title = obj.inner + ' ' + (obj.separator || opt.separator) +
' ' + (obj.complement || opt.complement)
window.document.title = title.trim()
} | javascript | function (obj) {
if (!obj) return
diffTitle.before = opt.complement
var title = obj.inner + ' ' + (obj.separator || opt.separator) +
' ' + (obj.complement || opt.complement)
window.document.title = title.trim()
} | [
"function",
"(",
"obj",
")",
"{",
"if",
"(",
"!",
"obj",
")",
"return",
"diffTitle",
".",
"before",
"=",
"opt",
".",
"complement",
"var",
"title",
"=",
"obj",
".",
"inner",
"+",
"' '",
"+",
"(",
"obj",
".",
"separator",
"||",
"opt",
".",
"separator... | Change window.document title
@type {Function}
@param {Object} obj | [
"Change",
"window",
".",
"document",
"title"
] | 0ff9d248cea22191539606e3009ab7591f6c2f11 | https://github.com/ktquez/vue-head/blob/0ff9d248cea22191539606e3009ab7591f6c2f11/vue-head.js#L97-L103 | train | |
ktquez/vue-head | vue-head.js | function (arr, tag, place, update) {
var self = this
if (!arr) return
arr.map(function (obj) {
var parent = (obj.body) ? self.getPlace('body') : self.getPlace(place)
var el = window.document.getElementById(obj.id) || window.document.createElement(tag)
// Elements that will subs... | javascript | function (arr, tag, place, update) {
var self = this
if (!arr) return
arr.map(function (obj) {
var parent = (obj.body) ? self.getPlace('body') : self.getPlace(place)
var el = window.document.getElementById(obj.id) || window.document.createElement(tag)
// Elements that will subs... | [
"function",
"(",
"arr",
",",
"tag",
",",
"place",
",",
"update",
")",
"{",
"var",
"self",
"=",
"this",
"if",
"(",
"!",
"arr",
")",
"return",
"arr",
".",
"map",
"(",
"function",
"(",
"obj",
")",
"{",
"var",
"parent",
"=",
"(",
"obj",
".",
"body"... | Handle of create elements
@type {Function}
@param {Array} arr
@param {String} tag - style, link, meta, script, base
@param {String} place - Default 'head'
@param {Boolean} update | [
"Handle",
"of",
"create",
"elements"
] | 0ff9d248cea22191539606e3009ab7591f6c2f11 | https://github.com/ktquez/vue-head/blob/0ff9d248cea22191539606e3009ab7591f6c2f11/vue-head.js#L142-L163 | train | |
ktquez/vue-head | vue-head.js | VueHead | function VueHead (Vue, options) {
if (installed) return
installed = true
if (options) {
Vue.util.extend(opt, options)
}
/**
* Initializes and updates the elements in the head
* @param {Boolean} update
*/
function init (update) {
var self = this
var head = (ty... | javascript | function VueHead (Vue, options) {
if (installed) return
installed = true
if (options) {
Vue.util.extend(opt, options)
}
/**
* Initializes and updates the elements in the head
* @param {Boolean} update
*/
function init (update) {
var self = this
var head = (ty... | [
"function",
"VueHead",
"(",
"Vue",
",",
"options",
")",
"{",
"if",
"(",
"installed",
")",
"return",
"installed",
"=",
"true",
"if",
"(",
"options",
")",
"{",
"Vue",
".",
"util",
".",
"extend",
"(",
"opt",
",",
"options",
")",
"}",
"/**\n * Initiali... | Plugin | vue-head
@param {Function} Vue
@param {Object} options | [
"Plugin",
"|",
"vue",
"-",
"head"
] | 0ff9d248cea22191539606e3009ab7591f6c2f11 | https://github.com/ktquez/vue-head/blob/0ff9d248cea22191539606e3009ab7591f6c2f11/vue-head.js#L171-L245 | train |
ktquez/vue-head | vue-head.js | init | function init (update) {
var self = this
var head = (typeof self.$options.head === 'function') ? self.$options.head.bind(self)() : self.$options.head
if (!head) return
Object.keys(head).map(function (key) {
var prop = head[key]
if (!prop) return
var obj = (typeof prop ===... | javascript | function init (update) {
var self = this
var head = (typeof self.$options.head === 'function') ? self.$options.head.bind(self)() : self.$options.head
if (!head) return
Object.keys(head).map(function (key) {
var prop = head[key]
if (!prop) return
var obj = (typeof prop ===... | [
"function",
"init",
"(",
"update",
")",
"{",
"var",
"self",
"=",
"this",
"var",
"head",
"=",
"(",
"typeof",
"self",
".",
"$options",
".",
"head",
"===",
"'function'",
")",
"?",
"self",
".",
"$options",
".",
"head",
".",
"bind",
"(",
"self",
")",
"(... | Initializes and updates the elements in the head
@param {Boolean} update | [
"Initializes",
"and",
"updates",
"the",
"elements",
"in",
"the",
"head"
] | 0ff9d248cea22191539606e3009ab7591f6c2f11 | https://github.com/ktquez/vue-head/blob/0ff9d248cea22191539606e3009ab7591f6c2f11/vue-head.js#L184-L199 | train |
C2FO/fast-csv | lib/formatter/formatter.js | gatherHeaders | function gatherHeaders(item) {
var ret, i, l;
if (isHashArray(item)) {
//lets assume a multidimesional array with item 0 bing the title
i = -1;
l = item.length;
ret = [];
while (++i < l) {
ret[i] = item[i][0];
}
} else if (isArray(item)) {
... | javascript | function gatherHeaders(item) {
var ret, i, l;
if (isHashArray(item)) {
//lets assume a multidimesional array with item 0 bing the title
i = -1;
l = item.length;
ret = [];
while (++i < l) {
ret[i] = item[i][0];
}
} else if (isArray(item)) {
... | [
"function",
"gatherHeaders",
"(",
"item",
")",
"{",
"var",
"ret",
",",
"i",
",",
"l",
";",
"if",
"(",
"isHashArray",
"(",
"item",
")",
")",
"{",
"//lets assume a multidimesional array with item 0 bing the title",
"i",
"=",
"-",
"1",
";",
"l",
"=",
"item",
... | get headers from a row item | [
"get",
"headers",
"from",
"a",
"row",
"item"
] | d4e33a2b5397afe188a08df01a1a3562efe8e3a1 | https://github.com/C2FO/fast-csv/blob/d4e33a2b5397afe188a08df01a1a3562efe8e3a1/lib/formatter/formatter.js#L104-L120 | train |
C2FO/fast-csv | lib/formatter/formatter.js | transformHashData | function transformHashData(stream, item) {
var vals = [], row = [], headers = stream.headers, i = -1, headersLength = stream.headersLength;
if (stream.totalCount++) {
row.push(stream.rowDelimiter);
}
while (++i < headersLength) {
vals[i] = item[headers[i]];
}
row.push(stream.form... | javascript | function transformHashData(stream, item) {
var vals = [], row = [], headers = stream.headers, i = -1, headersLength = stream.headersLength;
if (stream.totalCount++) {
row.push(stream.rowDelimiter);
}
while (++i < headersLength) {
vals[i] = item[headers[i]];
}
row.push(stream.form... | [
"function",
"transformHashData",
"(",
"stream",
",",
"item",
")",
"{",
"var",
"vals",
"=",
"[",
"]",
",",
"row",
"=",
"[",
"]",
",",
"headers",
"=",
"stream",
".",
"headers",
",",
"i",
"=",
"-",
"1",
",",
"headersLength",
"=",
"stream",
".",
"heade... | transform an object into a CSV row | [
"transform",
"an",
"object",
"into",
"a",
"CSV",
"row"
] | d4e33a2b5397afe188a08df01a1a3562efe8e3a1 | https://github.com/C2FO/fast-csv/blob/d4e33a2b5397afe188a08df01a1a3562efe8e3a1/lib/formatter/formatter.js#L141-L151 | train |
C2FO/fast-csv | lib/formatter/formatter.js | transformArrayData | function transformArrayData(stream, item, cb) {
var row = [];
if (stream.totalCount++) {
row.push(stream.rowDelimiter);
}
row.push(stream.formatter(item));
return row.join("");
} | javascript | function transformArrayData(stream, item, cb) {
var row = [];
if (stream.totalCount++) {
row.push(stream.rowDelimiter);
}
row.push(stream.formatter(item));
return row.join("");
} | [
"function",
"transformArrayData",
"(",
"stream",
",",
"item",
",",
"cb",
")",
"{",
"var",
"row",
"=",
"[",
"]",
";",
"if",
"(",
"stream",
".",
"totalCount",
"++",
")",
"{",
"row",
".",
"push",
"(",
"stream",
".",
"rowDelimiter",
")",
";",
"}",
"row... | transform an array into a CSV row | [
"transform",
"an",
"array",
"into",
"a",
"CSV",
"row"
] | d4e33a2b5397afe188a08df01a1a3562efe8e3a1 | https://github.com/C2FO/fast-csv/blob/d4e33a2b5397afe188a08df01a1a3562efe8e3a1/lib/formatter/formatter.js#L154-L161 | train |
C2FO/fast-csv | lib/formatter/formatter.js | transformHashArrayData | function transformHashArrayData(stream, item) {
var vals = [], row = [], i = -1, headersLength = stream.headersLength;
if (stream.totalCount++) {
row.push(stream.rowDelimiter);
}
while (++i < headersLength) {
vals[i] = item[i][1];
}
row.push(stream.formatter(vals));
return ro... | javascript | function transformHashArrayData(stream, item) {
var vals = [], row = [], i = -1, headersLength = stream.headersLength;
if (stream.totalCount++) {
row.push(stream.rowDelimiter);
}
while (++i < headersLength) {
vals[i] = item[i][1];
}
row.push(stream.formatter(vals));
return ro... | [
"function",
"transformHashArrayData",
"(",
"stream",
",",
"item",
")",
"{",
"var",
"vals",
"=",
"[",
"]",
",",
"row",
"=",
"[",
"]",
",",
"i",
"=",
"-",
"1",
",",
"headersLength",
"=",
"stream",
".",
"headersLength",
";",
"if",
"(",
"stream",
".",
... | transform an array of two item arrays into a CSV row | [
"transform",
"an",
"array",
"of",
"two",
"item",
"arrays",
"into",
"a",
"CSV",
"row"
] | d4e33a2b5397afe188a08df01a1a3562efe8e3a1 | https://github.com/C2FO/fast-csv/blob/d4e33a2b5397afe188a08df01a1a3562efe8e3a1/lib/formatter/formatter.js#L164-L174 | train |
C2FO/fast-csv | lib/formatter/formatter.js | transformItem | function transformItem(stream, item) {
var ret;
if (isArray(item)) {
if (isHashArray(item)) {
ret = transformHashArrayData(stream, item);
} else {
ret = transformArrayData(stream, item);
}
} else {
ret = transformHashData(stream, item);
}
retur... | javascript | function transformItem(stream, item) {
var ret;
if (isArray(item)) {
if (isHashArray(item)) {
ret = transformHashArrayData(stream, item);
} else {
ret = transformArrayData(stream, item);
}
} else {
ret = transformHashData(stream, item);
}
retur... | [
"function",
"transformItem",
"(",
"stream",
",",
"item",
")",
"{",
"var",
"ret",
";",
"if",
"(",
"isArray",
"(",
"item",
")",
")",
"{",
"if",
"(",
"isHashArray",
"(",
"item",
")",
")",
"{",
"ret",
"=",
"transformHashArrayData",
"(",
"stream",
",",
"i... | wrapper to determin what transform to run | [
"wrapper",
"to",
"determin",
"what",
"transform",
"to",
"run"
] | d4e33a2b5397afe188a08df01a1a3562efe8e3a1 | https://github.com/C2FO/fast-csv/blob/d4e33a2b5397afe188a08df01a1a3562efe8e3a1/lib/formatter/formatter.js#L177-L189 | train |
andybelldesign/beedle | bundler.js | bundleJavaScript | async function bundleJavaScript() {
const bundle = await rollup.rollup({
input: `${__dirname}/src/beedle.js`,
plugins: [
uglify()
]
});
await bundle.write({
format: 'umd',
name: 'beedle',
file: 'beedle.js',
dir: `${__dirname}/dist/`,
}... | javascript | async function bundleJavaScript() {
const bundle = await rollup.rollup({
input: `${__dirname}/src/beedle.js`,
plugins: [
uglify()
]
});
await bundle.write({
format: 'umd',
name: 'beedle',
file: 'beedle.js',
dir: `${__dirname}/dist/`,
}... | [
"async",
"function",
"bundleJavaScript",
"(",
")",
"{",
"const",
"bundle",
"=",
"await",
"rollup",
".",
"rollup",
"(",
"{",
"input",
":",
"`",
"${",
"__dirname",
"}",
"`",
",",
"plugins",
":",
"[",
"uglify",
"(",
")",
"]",
"}",
")",
";",
"await",
"... | Bundle the JavaScript components together and smoosh them with uglify | [
"Bundle",
"the",
"JavaScript",
"components",
"together",
"and",
"smoosh",
"them",
"with",
"uglify"
] | 84f02075a8c144bfdbb877d7b615487807c742cb | https://github.com/andybelldesign/beedle/blob/84f02075a8c144bfdbb877d7b615487807c742cb/bundler.js#L7-L21 | train |
posthtml/posthtml | lib/index.js | _next | function _next (res) {
if (res && !options.skipParse) {
res = [].concat(res)
}
return next(res || result, cb)
} | javascript | function _next (res) {
if (res && !options.skipParse) {
res = [].concat(res)
}
return next(res || result, cb)
} | [
"function",
"_next",
"(",
"res",
")",
"{",
"if",
"(",
"res",
"&&",
"!",
"options",
".",
"skipParse",
")",
"{",
"res",
"=",
"[",
"]",
".",
"concat",
"(",
"res",
")",
"}",
"return",
"next",
"(",
"res",
"||",
"result",
",",
"cb",
")",
"}"
] | little helper to go to the next iteration | [
"little",
"helper",
"to",
"go",
"to",
"the",
"next",
"iteration"
] | 881d4a5b170109789a5245a379229afb4793e21a | https://github.com/posthtml/posthtml/blob/881d4a5b170109789a5245a379229afb4793e21a/lib/index.js#L165-L171 | train |
posthtml/posthtml | lib/index.js | lazyResult | function lazyResult (render, tree) {
return {
get html () {
return render(tree, tree.options)
},
tree: tree,
messages: tree.messages
}
} | javascript | function lazyResult (render, tree) {
return {
get html () {
return render(tree, tree.options)
},
tree: tree,
messages: tree.messages
}
} | [
"function",
"lazyResult",
"(",
"render",
",",
"tree",
")",
"{",
"return",
"{",
"get",
"html",
"(",
")",
"{",
"return",
"render",
"(",
"tree",
",",
"tree",
".",
"options",
")",
"}",
",",
"tree",
":",
"tree",
",",
"messages",
":",
"tree",
".",
"messa... | Wraps the PostHTMLTree within an object using a getter to render HTML on demand.
@private
@param {Function} render
@param {Array} tree
@returns {Object<{html: String, tree: Array}>} | [
"Wraps",
"the",
"PostHTMLTree",
"within",
"an",
"object",
"using",
"a",
"getter",
"to",
"render",
"HTML",
"on",
"demand",
"."
] | 881d4a5b170109789a5245a379229afb4793e21a | https://github.com/posthtml/posthtml/blob/881d4a5b170109789a5245a379229afb4793e21a/lib/index.js#L286-L294 | train |
posthtml/posthtml | lib/api.js | match | function match (expression, cb) {
return Array.isArray(expression)
? traverse(this, function (node) {
for (var i = 0; i < expression.length; i++) {
if (compare(expression[i], node)) return cb(node)
}
return node
})
: traverse(this, function (node) {
if (compare(expression,... | javascript | function match (expression, cb) {
return Array.isArray(expression)
? traverse(this, function (node) {
for (var i = 0; i < expression.length; i++) {
if (compare(expression[i], node)) return cb(node)
}
return node
})
: traverse(this, function (node) {
if (compare(expression,... | [
"function",
"match",
"(",
"expression",
",",
"cb",
")",
"{",
"return",
"Array",
".",
"isArray",
"(",
"expression",
")",
"?",
"traverse",
"(",
"this",
",",
"function",
"(",
"node",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"expressi... | Matches an expression to search for nodes in the tree
@memberof tree
@param {String|RegExp|Object|Array} expression - Matcher(s) to search
@param {Function} cb Callback
@return {Function} Callback(node)
@example
```js
export const match = (tree) => {
// Single matcher
tree.match({ tag: 'custom-tag' }, (node) => {... | [
"Matches",
"an",
"expression",
"to",
"search",
"for",
"nodes",
"in",
"the",
"tree"
] | 881d4a5b170109789a5245a379229afb4793e21a | https://github.com/posthtml/posthtml/blob/881d4a5b170109789a5245a379229afb4793e21a/lib/api.js#L81-L95 | train |
kbrsh/moon | packages/moon/src/executor/executor.js | executeCreate | function executeCreate(node) {
let element;
let children = [];
if (node.type === types.text) {
// Create a text node using the text content from the default key.
element = document.createTextNode(node.data[""]);
} else {
const nodeData = node.data;
// Create a DOM element.
element = document.createEleme... | javascript | function executeCreate(node) {
let element;
let children = [];
if (node.type === types.text) {
// Create a text node using the text content from the default key.
element = document.createTextNode(node.data[""]);
} else {
const nodeData = node.data;
// Create a DOM element.
element = document.createEleme... | [
"function",
"executeCreate",
"(",
"node",
")",
"{",
"let",
"element",
";",
"let",
"children",
"=",
"[",
"]",
";",
"if",
"(",
"node",
".",
"type",
"===",
"types",
".",
"text",
")",
"{",
"// Create a text node using the text content from the default key.",
"elemen... | Creates an old reference node from a view node.
@param {Object} node
@returns {Object} node to be used as an old node | [
"Creates",
"an",
"old",
"reference",
"node",
"from",
"a",
"view",
"node",
"."
] | 7f9e660d120ccff511970ec6f7cb60310a8493e7 | https://github.com/kbrsh/moon/blob/7f9e660d120ccff511970ec6f7cb60310a8493e7/packages/moon/src/executor/executor.js#L31-L85 | train |
kbrsh/moon | packages/moon/src/executor/executor.js | executeView | function executeView(nodes, parents, indexes) {
while (true) {
let node = nodes.pop();
const parent = parents.pop();
const index = indexes.pop();
if (node.type === types.component) {
// Execute the component to get the component view.
node = components[node.name](node.data);
// Set the root view or ... | javascript | function executeView(nodes, parents, indexes) {
while (true) {
let node = nodes.pop();
const parent = parents.pop();
const index = indexes.pop();
if (node.type === types.component) {
// Execute the component to get the component view.
node = components[node.name](node.data);
// Set the root view or ... | [
"function",
"executeView",
"(",
"nodes",
",",
"parents",
",",
"indexes",
")",
"{",
"while",
"(",
"true",
")",
"{",
"let",
"node",
"=",
"nodes",
".",
"pop",
"(",
")",
";",
"const",
"parent",
"=",
"parents",
".",
"pop",
"(",
")",
";",
"const",
"index... | Walks through the view and executes components.
@param {Array} nodes
@param {Array} parents
@param {Array} indexes | [
"Walks",
"through",
"the",
"view",
"and",
"executes",
"components",
"."
] | 7f9e660d120ccff511970ec6f7cb60310a8493e7 | https://github.com/kbrsh/moon/blob/7f9e660d120ccff511970ec6f7cb60310a8493e7/packages/moon/src/executor/executor.js#L94-L138 | train |
kbrsh/moon | packages/moon/src/executor/executor.js | executeDiff | function executeDiff(nodesOld, nodesNew, patches) {
while (true) {
const nodeOld = nodesOld.pop();
const nodeOldNode = nodeOld.node;
const nodeNew = nodesNew.pop();
// If they have the same reference (hoisted) then skip diffing.
if (nodeOldNode !== nodeNew) {
if (nodeOldNode.name !== nodeNew.name) {
... | javascript | function executeDiff(nodesOld, nodesNew, patches) {
while (true) {
const nodeOld = nodesOld.pop();
const nodeOldNode = nodeOld.node;
const nodeNew = nodesNew.pop();
// If they have the same reference (hoisted) then skip diffing.
if (nodeOldNode !== nodeNew) {
if (nodeOldNode.name !== nodeNew.name) {
... | [
"function",
"executeDiff",
"(",
"nodesOld",
",",
"nodesNew",
",",
"patches",
")",
"{",
"while",
"(",
"true",
")",
"{",
"const",
"nodeOld",
"=",
"nodesOld",
".",
"pop",
"(",
")",
";",
"const",
"nodeOldNode",
"=",
"nodeOld",
".",
"node",
";",
"const",
"n... | Finds changes between a new and old tree and creates a list of patches to
execute.
@param {Array} nodesOld
@param {Array} nodesNew
@param {Array} patches | [
"Finds",
"changes",
"between",
"a",
"new",
"and",
"old",
"tree",
"and",
"creates",
"a",
"list",
"of",
"patches",
"to",
"execute",
"."
] | 7f9e660d120ccff511970ec6f7cb60310a8493e7 | https://github.com/kbrsh/moon/blob/7f9e660d120ccff511970ec6f7cb60310a8493e7/packages/moon/src/executor/executor.js#L148-L252 | train |
kbrsh/moon | packages/moon/src/executor/executor.js | executePatch | function executePatch(patches) {
for (let i = 0; i < patches.length; i++) {
const patch = patches[i];
switch (patch.type) {
case patchTypes.updateText: {
// Update text of a node with new text.
const nodeOld = patch.nodeOld;
const nodeNew = patch.nodeNew;
nodeOld.element.textContent = nodeNew.... | javascript | function executePatch(patches) {
for (let i = 0; i < patches.length; i++) {
const patch = patches[i];
switch (patch.type) {
case patchTypes.updateText: {
// Update text of a node with new text.
const nodeOld = patch.nodeOld;
const nodeNew = patch.nodeNew;
nodeOld.element.textContent = nodeNew.... | [
"function",
"executePatch",
"(",
"patches",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"patches",
".",
"length",
";",
"i",
"++",
")",
"{",
"const",
"patch",
"=",
"patches",
"[",
"i",
"]",
";",
"switch",
"(",
"patch",
".",
"type",
... | Applies the list of patches as DOM updates.
@param {Array} patches | [
"Applies",
"the",
"list",
"of",
"patches",
"as",
"DOM",
"updates",
"."
] | 7f9e660d120ccff511970ec6f7cb60310a8493e7 | https://github.com/kbrsh/moon/blob/7f9e660d120ccff511970ec6f7cb60310a8493e7/packages/moon/src/executor/executor.js#L259-L374 | train |
kbrsh/moon | packages/moon/src/executor/executor.js | executeNext | function executeNext() {
// Get the next data update.
const dataNew = executeQueue[0];
// Merge new data into current data.
for (let key in dataNew) {
data[key] = dataNew[key];
}
// Begin executing the view.
const viewNew = viewCurrent(data);
setViewNew(viewNew);
executeView([viewNew], [null], [0]);
} | javascript | function executeNext() {
// Get the next data update.
const dataNew = executeQueue[0];
// Merge new data into current data.
for (let key in dataNew) {
data[key] = dataNew[key];
}
// Begin executing the view.
const viewNew = viewCurrent(data);
setViewNew(viewNew);
executeView([viewNew], [null], [0]);
} | [
"function",
"executeNext",
"(",
")",
"{",
"// Get the next data update.",
"const",
"dataNew",
"=",
"executeQueue",
"[",
"0",
"]",
";",
"// Merge new data into current data.",
"for",
"(",
"let",
"key",
"in",
"dataNew",
")",
"{",
"data",
"[",
"key",
"]",
"=",
"d... | Execute the next update in the execution queue. | [
"Execute",
"the",
"next",
"update",
"in",
"the",
"execution",
"queue",
"."
] | 7f9e660d120ccff511970ec6f7cb60310a8493e7 | https://github.com/kbrsh/moon/blob/7f9e660d120ccff511970ec6f7cb60310a8493e7/packages/moon/src/executor/executor.js#L379-L393 | train |
kbrsh/moon | packages/moon/src/compiler/lexer/lexer.js | scopeExpression | function scopeExpression(expression) {
return expression.replace(expressionRE, (match, name) =>
(
name === undefined ||
name[0] === "$" ||
globals.indexOf(name) !== -1
) ?
match :
"data." + name
);
} | javascript | function scopeExpression(expression) {
return expression.replace(expressionRE, (match, name) =>
(
name === undefined ||
name[0] === "$" ||
globals.indexOf(name) !== -1
) ?
match :
"data." + name
);
} | [
"function",
"scopeExpression",
"(",
"expression",
")",
"{",
"return",
"expression",
".",
"replace",
"(",
"expressionRE",
",",
"(",
"match",
",",
"name",
")",
"=>",
"(",
"name",
"===",
"undefined",
"||",
"name",
"[",
"0",
"]",
"===",
"\"$\"",
"||",
"globa... | Scope an expression to use variables within the `data` object.
@param {string} expression | [
"Scope",
"an",
"expression",
"to",
"use",
"variables",
"within",
"the",
"data",
"object",
"."
] | 7f9e660d120ccff511970ec6f7cb60310a8493e7 | https://github.com/kbrsh/moon/blob/7f9e660d120ccff511970ec6f7cb60310a8493e7/packages/moon/src/compiler/lexer/lexer.js#L76-L86 | train |
kbrsh/moon | packages/moon/src/compiler/lexer/lexer.js | lexError | function lexError(message, input, index) {
let lexMessage = message + "\n\n";
// Show input characters surrounding the source of the error.
for (
let i = Math.max(0, index - 16);
i < Math.min(index + 16, input.length);
i++
) {
lexMessage += input[i];
}
error(lexMessage);
} | javascript | function lexError(message, input, index) {
let lexMessage = message + "\n\n";
// Show input characters surrounding the source of the error.
for (
let i = Math.max(0, index - 16);
i < Math.min(index + 16, input.length);
i++
) {
lexMessage += input[i];
}
error(lexMessage);
} | [
"function",
"lexError",
"(",
"message",
",",
"input",
",",
"index",
")",
"{",
"let",
"lexMessage",
"=",
"message",
"+",
"\"\\n\\n\"",
";",
"// Show input characters surrounding the source of the error.",
"for",
"(",
"let",
"i",
"=",
"Math",
".",
"max",
"(",
"0",... | Logs a lexer error message to the console along with the surrounding
characters.
@param {string} message
@param {string} input
@param {number} index | [
"Logs",
"a",
"lexer",
"error",
"message",
"to",
"the",
"console",
"along",
"with",
"the",
"surrounding",
"characters",
"."
] | 7f9e660d120ccff511970ec6f7cb60310a8493e7 | https://github.com/kbrsh/moon/blob/7f9e660d120ccff511970ec6f7cb60310a8493e7/packages/moon/src/compiler/lexer/lexer.js#L135-L148 | train |
kbrsh/moon | packages/moon/src/compiler/parser/parser.js | ParseError | function ParseError(message, start, end, next) {
this.message = message;
this.start = start;
this.end = end;
this.next = next;
} | javascript | function ParseError(message, start, end, next) {
this.message = message;
this.start = start;
this.end = end;
this.next = next;
} | [
"function",
"ParseError",
"(",
"message",
",",
"start",
",",
"end",
",",
"next",
")",
"{",
"this",
".",
"message",
"=",
"message",
";",
"this",
".",
"start",
"=",
"start",
";",
"this",
".",
"end",
"=",
"end",
";",
"this",
".",
"next",
"=",
"next",
... | Stores an error message, a slice of tokens associated with the error, and a
related error for later reporting. | [
"Stores",
"an",
"error",
"message",
"a",
"slice",
"of",
"tokens",
"associated",
"with",
"the",
"error",
"and",
"a",
"related",
"error",
"for",
"later",
"reporting",
"."
] | 7f9e660d120ccff511970ec6f7cb60310a8493e7 | https://github.com/kbrsh/moon/blob/7f9e660d120ccff511970ec6f7cb60310a8493e7/packages/moon/src/compiler/parser/parser.js#L8-L13 | train |
scurker/currency.js | src/currency.js | currency | function currency(value, opts) {
let that = this;
if(!(that instanceof currency)) {
return new currency(value, opts);
}
let settings = Object.assign({}, defaults, opts)
, precision = pow(settings.precision)
, v = parse(value, settings);
that.intValue = v;
that.value = v / precision;
// Set... | javascript | function currency(value, opts) {
let that = this;
if(!(that instanceof currency)) {
return new currency(value, opts);
}
let settings = Object.assign({}, defaults, opts)
, precision = pow(settings.precision)
, v = parse(value, settings);
that.intValue = v;
that.value = v / precision;
// Set... | [
"function",
"currency",
"(",
"value",
",",
"opts",
")",
"{",
"let",
"that",
"=",
"this",
";",
"if",
"(",
"!",
"(",
"that",
"instanceof",
"currency",
")",
")",
"{",
"return",
"new",
"currency",
"(",
"value",
",",
"opts",
")",
";",
"}",
"let",
"setti... | Create a new instance of currency.js
@param {number|string|currency} value
@param {object} [opts] | [
"Create",
"a",
"new",
"instance",
"of",
"currency",
".",
"js"
] | 592f80f44655794efba793494a9f099308034cd9 | https://github.com/scurker/currency.js/blob/592f80f44655794efba793494a9f099308034cd9/src/currency.js#L24-L52 | train |
choerodon/choerodon-ui | scripts/sort-api-table.js | alphabetSort | function alphabetSort(nodes) {
// use toLowerCase to keep `case insensitive`
return nodes.sort((...comparison) => {
return asciiSort(...comparison.map(val => getCellValue(val).toLowerCase()));
});
} | javascript | function alphabetSort(nodes) {
// use toLowerCase to keep `case insensitive`
return nodes.sort((...comparison) => {
return asciiSort(...comparison.map(val => getCellValue(val).toLowerCase()));
});
} | [
"function",
"alphabetSort",
"(",
"nodes",
")",
"{",
"// use toLowerCase to keep `case insensitive`",
"return",
"nodes",
".",
"sort",
"(",
"(",
"...",
"comparison",
")",
"=>",
"{",
"return",
"asciiSort",
"(",
"...",
"comparison",
".",
"map",
"(",
"val",
"=>",
"... | follow the alphabet order | [
"follow",
"the",
"alphabet",
"order"
] | 1fa800a0acd6720ee33e5ea64ad547409f89195b | https://github.com/choerodon/choerodon-ui/blob/1fa800a0acd6720ee33e5ea64ad547409f89195b/scripts/sort-api-table.js#L48-L53 | train |
ethereumjs/ethereumjs-abi | lib/index.js | parseType | function parseType (type) {
var size
var ret
if (isArray(type)) {
size = parseTypeArray(type)
var subArray = type.slice(0, type.lastIndexOf('['))
subArray = parseType(subArray)
ret = {
isArray: true,
name: type,
size: size,
memoryUsage: size === 'dynamic' ? 32 : subArray.me... | javascript | function parseType (type) {
var size
var ret
if (isArray(type)) {
size = parseTypeArray(type)
var subArray = type.slice(0, type.lastIndexOf('['))
subArray = parseType(subArray)
ret = {
isArray: true,
name: type,
size: size,
memoryUsage: size === 'dynamic' ? 32 : subArray.me... | [
"function",
"parseType",
"(",
"type",
")",
"{",
"var",
"size",
"var",
"ret",
"if",
"(",
"isArray",
"(",
"type",
")",
")",
"{",
"size",
"=",
"parseTypeArray",
"(",
"type",
")",
"var",
"subArray",
"=",
"type",
".",
"slice",
"(",
"0",
",",
"type",
"."... | Parse the given type @returns: {} containing the type itself, memory usage and (including size and subArray if applicable) | [
"Parse",
"the",
"given",
"type"
] | 8431eab7b3384e65e8126a4602520b78031666fb | https://github.com/ethereumjs/ethereumjs-abi/blob/8431eab7b3384e65e8126a4602520b78031666fb/lib/index.js#L281-L329 | train |
simplecrawler/simplecrawler | lib/cookies.js | function(name, value, expires, path, domain, httponly) {
if (!name) {
throw new Error("A name is required to create a cookie.");
}
// Parse date to timestamp - consider it never expiring if timestamp is not
// passed to the function
if (expires) {
if (typeof expires !== "number") {... | javascript | function(name, value, expires, path, domain, httponly) {
if (!name) {
throw new Error("A name is required to create a cookie.");
}
// Parse date to timestamp - consider it never expiring if timestamp is not
// passed to the function
if (expires) {
if (typeof expires !== "number") {... | [
"function",
"(",
"name",
",",
"value",
",",
"expires",
",",
"path",
",",
"domain",
",",
"httponly",
")",
"{",
"if",
"(",
"!",
"name",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"A name is required to create a cookie.\"",
")",
";",
"}",
"// Parse date to times... | Creates a new cookies
@class
@param {String} name Name of the new cookie
@param {String} value Value of the new cookie
@param {String|Number} expires Expiry timestamp of the new cookie in milliseconds
@param {String} [path="/"] Limits cookie to a pa... | [
"Creates",
"a",
"new",
"cookies"
] | 2698d15b1ea9cd69285ce3f8b3825975f80f858c | https://github.com/simplecrawler/simplecrawler/blob/2698d15b1ea9cd69285ce3f8b3825975f80f858c/lib/cookies.js#L259-L282 | train | |
simplecrawler/simplecrawler | lib/cache.js | Cache | function Cache(cacheLoadParameter, cacheBackend) {
// Ensure parameters are how we want them...
cacheBackend = typeof cacheBackend === "function" ? cacheBackend : FilesystemBackend;
cacheLoadParameter = cacheLoadParameter instanceof Array ? cacheLoadParameter : [cacheLoadParameter];
// Now we can just... | javascript | function Cache(cacheLoadParameter, cacheBackend) {
// Ensure parameters are how we want them...
cacheBackend = typeof cacheBackend === "function" ? cacheBackend : FilesystemBackend;
cacheLoadParameter = cacheLoadParameter instanceof Array ? cacheLoadParameter : [cacheLoadParameter];
// Now we can just... | [
"function",
"Cache",
"(",
"cacheLoadParameter",
",",
"cacheBackend",
")",
"{",
"// Ensure parameters are how we want them...",
"cacheBackend",
"=",
"typeof",
"cacheBackend",
"===",
"\"function\"",
"?",
"cacheBackend",
":",
"FilesystemBackend",
";",
"cacheLoadParameter",
"="... | Init cache wrapper for backend... | [
"Init",
"cache",
"wrapper",
"for",
"backend",
"..."
] | 2698d15b1ea9cd69285ce3f8b3825975f80f858c | https://github.com/simplecrawler/simplecrawler/blob/2698d15b1ea9cd69285ce3f8b3825975f80f858c/lib/cache.js#L13-L24 | train |
simplecrawler/simplecrawler | lib/queue.js | compare | function compare(a, b) {
for (var key in a) {
if (a.hasOwnProperty(key)) {
if (typeof a[key] !== typeof b[key]) {
return false;
}
if (typeof a[key] === "object") {
if (!compare(a[key], b[key])) {
return false;
... | javascript | function compare(a, b) {
for (var key in a) {
if (a.hasOwnProperty(key)) {
if (typeof a[key] !== typeof b[key]) {
return false;
}
if (typeof a[key] === "object") {
if (!compare(a[key], b[key])) {
return false;
... | [
"function",
"compare",
"(",
"a",
",",
"b",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"a",
")",
"{",
"if",
"(",
"a",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"if",
"(",
"typeof",
"a",
"[",
"key",
"]",
"!==",
"typeof",
"b",
"[",
"key",... | Recursive function that compares immutable properties on two objects.
@private
@param {Object} a Source object that will be compared against
@param {Object} b Comparison object. The functions determines if all of this object's properties are the same on the first object.
@return {Boolean} Returns true if all of the pro... | [
"Recursive",
"function",
"that",
"compares",
"immutable",
"properties",
"on",
"two",
"objects",
"."
] | 2698d15b1ea9cd69285ce3f8b3825975f80f858c | https://github.com/simplecrawler/simplecrawler/blob/2698d15b1ea9cd69285ce3f8b3825975f80f858c/lib/queue.js#L16-L35 | train |
simplecrawler/simplecrawler | lib/queue.js | deepAssign | function deepAssign(object, source) {
for (var key in source) {
if (source.hasOwnProperty(key)) {
if (typeof object[key] === "object" && typeof source[key] === "object") {
deepAssign(object[key], source[key]);
} else {
object[key] = source[key];
... | javascript | function deepAssign(object, source) {
for (var key in source) {
if (source.hasOwnProperty(key)) {
if (typeof object[key] === "object" && typeof source[key] === "object") {
deepAssign(object[key], source[key]);
} else {
object[key] = source[key];
... | [
"function",
"deepAssign",
"(",
"object",
",",
"source",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"source",
")",
"{",
"if",
"(",
"source",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"if",
"(",
"typeof",
"object",
"[",
"key",
"]",
"===",
"\"o... | Recursive function that takes two objects and updates the properties on the
first object based on the ones in the second. Basically, it's a recursive
version of Object.assign. | [
"Recursive",
"function",
"that",
"takes",
"two",
"objects",
"and",
"updates",
"the",
"properties",
"on",
"the",
"first",
"object",
"based",
"on",
"the",
"ones",
"in",
"the",
"second",
".",
"Basically",
"it",
"s",
"a",
"recursive",
"version",
"of",
"Object",
... | 2698d15b1ea9cd69285ce3f8b3825975f80f858c | https://github.com/simplecrawler/simplecrawler/blob/2698d15b1ea9cd69285ce3f8b3825975f80f858c/lib/queue.js#L42-L54 | train |
simplecrawler/simplecrawler | lib/queue.js | function() {
Array.call(this);
/**
* Speeds up {@link FetchQueue.oldestUnfetchedItem} by storing the index at
* which the latest oldest unfetched queue item was found.
* @name FetchQueue._oldestUnfetchedIndex
* @private
* @type {Number}
*/
Object.defineProperty(this, "_oldestU... | javascript | function() {
Array.call(this);
/**
* Speeds up {@link FetchQueue.oldestUnfetchedItem} by storing the index at
* which the latest oldest unfetched queue item was found.
* @name FetchQueue._oldestUnfetchedIndex
* @private
* @type {Number}
*/
Object.defineProperty(this, "_oldestU... | [
"function",
"(",
")",
"{",
"Array",
".",
"call",
"(",
"this",
")",
";",
"/**\n * Speeds up {@link FetchQueue.oldestUnfetchedItem} by storing the index at\n * which the latest oldest unfetched queue item was found.\n * @name FetchQueue._oldestUnfetchedIndex\n * @private\n * ... | QueueItems represent resources in the queue that have been fetched, or will be eventually.
@typedef {Object} QueueItem
@property {Number} id A unique ID assigned by the queue when the queue item is added
@property {String} url The complete, canonical URL of the resource
@property {String} protocol The protocol of the r... | [
"QueueItems",
"represent",
"resources",
"in",
"the",
"queue",
"that",
"have",
"been",
"fetched",
"or",
"will",
"be",
"eventually",
"."
] | 2698d15b1ea9cd69285ce3f8b3825975f80f858c | https://github.com/simplecrawler/simplecrawler/blob/2698d15b1ea9cd69285ce3f8b3825975f80f858c/lib/queue.js#L86-L133 | train | |
simplecrawler/simplecrawler | lib/cache-backend-fs.js | FSBackend | function FSBackend(loadParameter) {
this.loaded = false;
this.index = [];
this.location = typeof loadParameter === "string" && loadParameter.length > 0 ? loadParameter : process.cwd() + "/cache/";
this.location = this.location.substr(this.location.length - 1) === "/" ? this.location : this.location + "/... | javascript | function FSBackend(loadParameter) {
this.loaded = false;
this.index = [];
this.location = typeof loadParameter === "string" && loadParameter.length > 0 ? loadParameter : process.cwd() + "/cache/";
this.location = this.location.substr(this.location.length - 1) === "/" ? this.location : this.location + "/... | [
"function",
"FSBackend",
"(",
"loadParameter",
")",
"{",
"this",
".",
"loaded",
"=",
"false",
";",
"this",
".",
"index",
"=",
"[",
"]",
";",
"this",
".",
"location",
"=",
"typeof",
"loadParameter",
"===",
"\"string\"",
"&&",
"loadParameter",
".",
"length",... | Constructor for filesystem cache backend | [
"Constructor",
"for",
"filesystem",
"cache",
"backend"
] | 2698d15b1ea9cd69285ce3f8b3825975f80f858c | https://github.com/simplecrawler/simplecrawler/blob/2698d15b1ea9cd69285ce3f8b3825975f80f858c/lib/cache-backend-fs.js#L23-L28 | train |
simplecrawler/simplecrawler | lib/crawler.js | function(string) {
var result = /\ssrcset\s*=\s*("|')(.*?)\1/.exec(string);
return Array.isArray(result) ? String(result[2]).split(",").map(function(string) {
return string.trim().split(/\s+/)[0];
}) : "";
} | javascript | function(string) {
var result = /\ssrcset\s*=\s*("|')(.*?)\1/.exec(string);
return Array.isArray(result) ? String(result[2]).split(",").map(function(string) {
return string.trim().split(/\s+/)[0];
}) : "";
} | [
"function",
"(",
"string",
")",
"{",
"var",
"result",
"=",
"/",
"\\ssrcset\\s*=\\s*(\"|')(.*?)\\1",
"/",
".",
"exec",
"(",
"string",
")",
";",
"return",
"Array",
".",
"isArray",
"(",
"result",
")",
"?",
"String",
"(",
"result",
"[",
"2",
"]",
")",
".",... | Find srcset links | [
"Find",
"srcset",
"links"
] | 2698d15b1ea9cd69285ce3f8b3825975f80f858c | https://github.com/simplecrawler/simplecrawler/blob/2698d15b1ea9cd69285ce3f8b3825975f80f858c/lib/crawler.js#L340-L345 | train | |
simplecrawler/simplecrawler | lib/crawler.js | isSubdomainOf | function isSubdomainOf(subdomain, host) {
// Comparisons must be case-insensitive
subdomain = subdomain.toLowerCase();
host = host.toLowerCase();
// If we're ignoring www, remove it from both
// (if www is the first domain component...)
if (crawler.ignoreWWWDom... | javascript | function isSubdomainOf(subdomain, host) {
// Comparisons must be case-insensitive
subdomain = subdomain.toLowerCase();
host = host.toLowerCase();
// If we're ignoring www, remove it from both
// (if www is the first domain component...)
if (crawler.ignoreWWWDom... | [
"function",
"isSubdomainOf",
"(",
"subdomain",
",",
"host",
")",
"{",
"// Comparisons must be case-insensitive",
"subdomain",
"=",
"subdomain",
".",
"toLowerCase",
"(",
")",
";",
"host",
"=",
"host",
".",
"toLowerCase",
"(",
")",
";",
"// If we're ignoring www, remo... | Checks if the first domain is a subdomain of the second | [
"Checks",
"if",
"the",
"first",
"domain",
"is",
"a",
"subdomain",
"of",
"the",
"second"
] | 2698d15b1ea9cd69285ce3f8b3825975f80f858c | https://github.com/simplecrawler/simplecrawler/blob/2698d15b1ea9cd69285ce3f8b3825975f80f858c/lib/crawler.js#L966-L982 | 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.