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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
jeanamarante/catena | tasks/catena.js | recurseSrcDirectories | function recurseSrcDirectories (grunt, fileData, options) {
let promises = [];
// Ignore everything except directories and Javascript files.
// Store function in array for recursive-readdir module.
let ignoreCallback = [(file, stats) => !(stats.isDirectory() || path.extname(file) === '.js')];
for ... | javascript | function recurseSrcDirectories (grunt, fileData, options) {
let promises = [];
// Ignore everything except directories and Javascript files.
// Store function in array for recursive-readdir module.
let ignoreCallback = [(file, stats) => !(stats.isDirectory() || path.extname(file) === '.js')];
for ... | [
"function",
"recurseSrcDirectories",
"(",
"grunt",
",",
"fileData",
",",
"options",
")",
"{",
"let",
"promises",
"=",
"[",
"]",
";",
"// Ignore everything except directories and Javascript files.",
"// Store function in array for recursive-readdir module.",
"let",
"ignoreCallba... | Find all Javascript files in src directories.
@function recurseSrcDirectories
@param {Object} grunt
@param {Object} fileData
@param {Object} options
@api private | [
"Find",
"all",
"Javascript",
"files",
"in",
"src",
"directories",
"."
] | c7762332f71c0fd7cfafba8d1e3cd66053529954 | https://github.com/jeanamarante/catena/blob/c7762332f71c0fd7cfafba8d1e3cd66053529954/tasks/catena.js#L236-L251 | train |
jeanamarante/catena | tasks/catena.js | streamMatches | function streamMatches (grunt, fileData, options, matches, flattenedMatches) {
// Run optional tasks after we stream matches to dest.
stream.createWriteStream(fileData.dest, () => {
require('./dev/test')(grunt, fileData, options, throwAsyncError).performTests();
if (options.deploy) {
... | javascript | function streamMatches (grunt, fileData, options, matches, flattenedMatches) {
// Run optional tasks after we stream matches to dest.
stream.createWriteStream(fileData.dest, () => {
require('./dev/test')(grunt, fileData, options, throwAsyncError).performTests();
if (options.deploy) {
... | [
"function",
"streamMatches",
"(",
"grunt",
",",
"fileData",
",",
"options",
",",
"matches",
",",
"flattenedMatches",
")",
"{",
"// Run optional tasks after we stream matches to dest.",
"stream",
".",
"createWriteStream",
"(",
"fileData",
".",
"dest",
",",
"(",
")",
... | Iterate all matches and stream them into the dest file.
@function streamMatches
@param {Object} grunt
@param {Object} fileData
@param {Object} options
@param {Array} matches
@param {Array} flattenedMatches
@api private | [
"Iterate",
"all",
"matches",
"and",
"stream",
"them",
"into",
"the",
"dest",
"file",
"."
] | c7762332f71c0fd7cfafba8d1e3cd66053529954 | https://github.com/jeanamarante/catena/blob/c7762332f71c0fd7cfafba8d1e3cd66053529954/tasks/catena.js#L265-L285 | train |
sagiegurari/js-project-commons | lib/grunt/helper.js | function (buildConfig) {
var configFile;
var suffix = 'karma';
if (buildConfig.nodeProject) {
suffix = 'mocha';
}
configFile = path.join(currentDirectory, '../lint/eslint/eslintrc-' + suffix + '.js');
return configFile;
} | javascript | function (buildConfig) {
var configFile;
var suffix = 'karma';
if (buildConfig.nodeProject) {
suffix = 'mocha';
}
configFile = path.join(currentDirectory, '../lint/eslint/eslintrc-' + suffix + '.js');
return configFile;
} | [
"function",
"(",
"buildConfig",
")",
"{",
"var",
"configFile",
";",
"var",
"suffix",
"=",
"'karma'",
";",
"if",
"(",
"buildConfig",
".",
"nodeProject",
")",
"{",
"suffix",
"=",
"'mocha'",
";",
"}",
"configFile",
"=",
"path",
".",
"join",
"(",
"currentDir... | Returns the eslint test sources config file location.
@function
@memberof! GruntTaskHelper
@private
@param {Object} buildConfig - The grunt buildConfig data
@returns {String} The eslint test sources config file location | [
"Returns",
"the",
"eslint",
"test",
"sources",
"config",
"file",
"location",
"."
] | 42dd07a8a3b2c49db71f489e08b94ac7279007a3 | https://github.com/sagiegurari/js-project-commons/blob/42dd07a8a3b2c49db71f489e08b94ac7279007a3/lib/grunt/helper.js#L75-L85 | train | |
sagiegurari/js-project-commons | lib/grunt/helper.js | function (buildConfig, config) {
var testConfig = extend(true, {}, config || {}, {
nomen: true,
unparam: true,
predef: [
'it',
'describe'
]
});
if (!buildConfig.nodeProject) {
testConfig.predef.push('ang... | javascript | function (buildConfig, config) {
var testConfig = extend(true, {}, config || {}, {
nomen: true,
unparam: true,
predef: [
'it',
'describe'
]
});
if (!buildConfig.nodeProject) {
testConfig.predef.push('ang... | [
"function",
"(",
"buildConfig",
",",
"config",
")",
"{",
"var",
"testConfig",
"=",
"extend",
"(",
"true",
",",
"{",
"}",
",",
"config",
"||",
"{",
"}",
",",
"{",
"nomen",
":",
"true",
",",
"unparam",
":",
"true",
",",
"predef",
":",
"[",
"'it'",
... | Returns the jslint test config.
@function
@memberof! GruntTaskHelper
@private
@param {Object} buildConfig - The grunt buildConfig data
@param {Object} config - The JSLint config used for non test files
@returns {Object} The JSLint config | [
"Returns",
"the",
"jslint",
"test",
"config",
"."
] | 42dd07a8a3b2c49db71f489e08b94ac7279007a3 | https://github.com/sagiegurari/js-project-commons/blob/42dd07a8a3b2c49db71f489e08b94ac7279007a3/lib/grunt/helper.js#L127-L142 | train | |
sagiegurari/js-project-commons | lib/grunt/helper.js | function (buildConfig, options) {
options = options || {};
var includeLib = options.includeLib;
if (includeLib === undefined) {
includeLib = true;
}
var src = [];
if (includeLib) {
if (buildConfig.nodeProject) {
src = src.concat([... | javascript | function (buildConfig, options) {
options = options || {};
var includeLib = options.includeLib;
if (includeLib === undefined) {
includeLib = true;
}
var src = [];
if (includeLib) {
if (buildConfig.nodeProject) {
src = src.concat([... | [
"function",
"(",
"buildConfig",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"includeLib",
"=",
"options",
".",
"includeLib",
";",
"if",
"(",
"includeLib",
"===",
"undefined",
")",
"{",
"includeLib",
"=",
"true",
";",
... | Returns the project sources paths.
@function
@memberof! GruntTaskHelper
@private
@param {Object} buildConfig - The grunt buildConfig data
@param {Object} [options] - Any optional options
@param {Boolean} [options.includeLib=false] - True if to include the main library files
@param {Boolean} [options.includeBuild=false... | [
"Returns",
"the",
"project",
"sources",
"paths",
"."
] | 42dd07a8a3b2c49db71f489e08b94ac7279007a3 | https://github.com/sagiegurari/js-project-commons/blob/42dd07a8a3b2c49db71f489e08b94ac7279007a3/lib/grunt/helper.js#L156-L185 | train | |
tianjianchn/javascript-packages | packages/wx-abc/lib/pay.js | xml2json | function xml2json(method, body){
body = util.xml2json(body);
if(body.return_code!=='SUCCESS'){
throw new Error(util.format('api error to call %s: %s', method, body.return_msg));
}
if(body.result_code!=='SUCCESS'){
throw new Error(util.format('business error to call %s: %s %s', method, body.err_c... | javascript | function xml2json(method, body){
body = util.xml2json(body);
if(body.return_code!=='SUCCESS'){
throw new Error(util.format('api error to call %s: %s', method, body.return_msg));
}
if(body.result_code!=='SUCCESS'){
throw new Error(util.format('business error to call %s: %s %s', method, body.err_c... | [
"function",
"xml2json",
"(",
"method",
",",
"body",
")",
"{",
"body",
"=",
"util",
".",
"xml2json",
"(",
"body",
")",
";",
"if",
"(",
"body",
".",
"return_code",
"!==",
"'SUCCESS'",
")",
"{",
"throw",
"new",
"Error",
"(",
"util",
".",
"format",
"(",
... | convert response xml to json | [
"convert",
"response",
"xml",
"to",
"json"
] | 3abe85edbfe323939c84c1d02128d74d6374bcde | https://github.com/tianjianchn/javascript-packages/blob/3abe85edbfe323939c84c1d02128d74d6374bcde/packages/wx-abc/lib/pay.js#L134-L144 | train |
jeanamarante/catena | tasks/client-side/class-properties.js | referenceParentNode | function referenceParentNode () {
// If nodeName is an empty string, then reference the parent of the root child.
if (isEmptyString(nodeName)) {
nodeName = this.$parentName;
// Even though super might be invoked in different constructors,
// the s... | javascript | function referenceParentNode () {
// If nodeName is an empty string, then reference the parent of the root child.
if (isEmptyString(nodeName)) {
nodeName = this.$parentName;
// Even though super might be invoked in different constructors,
// the s... | [
"function",
"referenceParentNode",
"(",
")",
"{",
"// If nodeName is an empty string, then reference the parent of the root child.",
"if",
"(",
"isEmptyString",
"(",
"nodeName",
")",
")",
"{",
"nodeName",
"=",
"this",
".",
"$parentName",
";",
"// Even though super might be in... | Check in which node the super chain is at.
@function referenceParentNode
@api private | [
"Check",
"in",
"which",
"node",
"the",
"super",
"chain",
"is",
"at",
"."
] | c7762332f71c0fd7cfafba8d1e3cd66053529954 | https://github.com/jeanamarante/catena/blob/c7762332f71c0fd7cfafba8d1e3cd66053529954/tasks/client-side/class-properties.js#L41-L69 | train |
jeanamarante/catena | tasks/client-side/class-properties.js | applyParentNode | function applyParentNode (args) {
if (isEmptyString(nodeName)) { return undefined; }
let nextParentName = CLASS[nodeName].prototype.$parentName;
// Keep reference of the node's name just in case the chain gets reset.
let tmpName = nodeName;
// If there are ... | javascript | function applyParentNode (args) {
if (isEmptyString(nodeName)) { return undefined; }
let nextParentName = CLASS[nodeName].prototype.$parentName;
// Keep reference of the node's name just in case the chain gets reset.
let tmpName = nodeName;
// If there are ... | [
"function",
"applyParentNode",
"(",
"args",
")",
"{",
"if",
"(",
"isEmptyString",
"(",
"nodeName",
")",
")",
"{",
"return",
"undefined",
";",
"}",
"let",
"nextParentName",
"=",
"CLASS",
"[",
"nodeName",
"]",
".",
"prototype",
".",
"$parentName",
";",
"// K... | If the current node has parent, apply current node to
parent's constructor.
@function applyParentNode
@param {Array} args
@api private | [
"If",
"the",
"current",
"node",
"has",
"parent",
"apply",
"current",
"node",
"to",
"parent",
"s",
"constructor",
"."
] | c7762332f71c0fd7cfafba8d1e3cd66053529954 | https://github.com/jeanamarante/catena/blob/c7762332f71c0fd7cfafba8d1e3cd66053529954/tasks/client-side/class-properties.js#L80-L94 | train |
abukurov/morph-expressions | src/abstract-syntax-tree.js | get | function get(resource, path) {
const [head, ...tail] = path.split('.');
return resource && head ? get(resource[head], tail.join('.')) : resource;
} | javascript | function get(resource, path) {
const [head, ...tail] = path.split('.');
return resource && head ? get(resource[head], tail.join('.')) : resource;
} | [
"function",
"get",
"(",
"resource",
",",
"path",
")",
"{",
"const",
"[",
"head",
",",
"...",
"tail",
"]",
"=",
"path",
".",
"split",
"(",
"'.'",
")",
";",
"return",
"resource",
"&&",
"head",
"?",
"get",
"(",
"resource",
"[",
"head",
"]",
",",
"ta... | Get object deep propery
@return {Function} compiled node
@private | [
"Get",
"object",
"deep",
"propery"
] | e8b96e50c1ba9d97ca22ee2bb6d9af6de466f9ca | https://github.com/abukurov/morph-expressions/blob/e8b96e50c1ba9d97ca22ee2bb6d9af6de466f9ca/src/abstract-syntax-tree.js#L8-L12 | train |
abukurov/morph-expressions | src/abstract-syntax-tree.js | createIdentifierNode | function createIdentifierNode(name) {
return (scope, opts) => {
const property = get(opts.properties, name);
return property ? property(scope) : get(scope, name);
};
} | javascript | function createIdentifierNode(name) {
return (scope, opts) => {
const property = get(opts.properties, name);
return property ? property(scope) : get(scope, name);
};
} | [
"function",
"createIdentifierNode",
"(",
"name",
")",
"{",
"return",
"(",
"scope",
",",
"opts",
")",
"=>",
"{",
"const",
"property",
"=",
"get",
"(",
"opts",
".",
"properties",
",",
"name",
")",
";",
"return",
"property",
"?",
"property",
"(",
"scope",
... | Create identifier tree node
@return {Function} compiled node
@private | [
"Create",
"identifier",
"tree",
"node"
] | e8b96e50c1ba9d97ca22ee2bb6d9af6de466f9ca | https://github.com/abukurov/morph-expressions/blob/e8b96e50c1ba9d97ca22ee2bb6d9af6de466f9ca/src/abstract-syntax-tree.js#L28-L34 | train |
abukurov/morph-expressions | src/abstract-syntax-tree.js | createOperatorNode | function createOperatorNode(operand, nodes = []) {
return (scope, opts) => {
const args = nodes.map(node => node(scope, opts));
if (typeof operand === 'function') {
return operand(...args);
}
const operator = get(opts.functions, operand);
if (!operator) {
throw new ReferenceError(`F... | javascript | function createOperatorNode(operand, nodes = []) {
return (scope, opts) => {
const args = nodes.map(node => node(scope, opts));
if (typeof operand === 'function') {
return operand(...args);
}
const operator = get(opts.functions, operand);
if (!operator) {
throw new ReferenceError(`F... | [
"function",
"createOperatorNode",
"(",
"operand",
",",
"nodes",
"=",
"[",
"]",
")",
"{",
"return",
"(",
"scope",
",",
"opts",
")",
"=>",
"{",
"const",
"args",
"=",
"nodes",
".",
"map",
"(",
"node",
"=>",
"node",
"(",
"scope",
",",
"opts",
")",
")",... | Create operator tree node
@return {Function} compiled node
@private | [
"Create",
"operator",
"tree",
"node"
] | e8b96e50c1ba9d97ca22ee2bb6d9af6de466f9ca | https://github.com/abukurov/morph-expressions/blob/e8b96e50c1ba9d97ca22ee2bb6d9af6de466f9ca/src/abstract-syntax-tree.js#L41-L57 | train |
abukurov/morph-expressions | src/abstract-syntax-tree.js | processLogicalOr | function processLogicalOr(tokenizer, scope) {
let node = processLogicalAnd(tokenizer, scope);
while (tokenizer.token.match(types.LOGICAL_OR)) {
node = createOperatorNode(tokenizer.token.value, [node, processLogicalAnd(tokenizer.skipToken(), scope)]);
}
return node;
} | javascript | function processLogicalOr(tokenizer, scope) {
let node = processLogicalAnd(tokenizer, scope);
while (tokenizer.token.match(types.LOGICAL_OR)) {
node = createOperatorNode(tokenizer.token.value, [node, processLogicalAnd(tokenizer.skipToken(), scope)]);
}
return node;
} | [
"function",
"processLogicalOr",
"(",
"tokenizer",
",",
"scope",
")",
"{",
"let",
"node",
"=",
"processLogicalAnd",
"(",
"tokenizer",
",",
"scope",
")",
";",
"while",
"(",
"tokenizer",
".",
"token",
".",
"match",
"(",
"types",
".",
"LOGICAL_OR",
")",
")",
... | Process logical OR operator
@return {Function} compiled node
@private | [
"Process",
"logical",
"OR",
"operator"
] | e8b96e50c1ba9d97ca22ee2bb6d9af6de466f9ca | https://github.com/abukurov/morph-expressions/blob/e8b96e50c1ba9d97ca22ee2bb6d9af6de466f9ca/src/abstract-syntax-tree.js#L64-L72 | train |
abukurov/morph-expressions | src/abstract-syntax-tree.js | processLogicalAnd | function processLogicalAnd(tokenizer, scope) {
let node = processLogicalEquality(tokenizer, scope);
while (tokenizer.token.match(types.LOGICAL_AND)) {
node = createOperatorNode(tokenizer.token.value, [node, processLogicalEquality(tokenizer.skipToken(), scope)]);
}
return node;
} | javascript | function processLogicalAnd(tokenizer, scope) {
let node = processLogicalEquality(tokenizer, scope);
while (tokenizer.token.match(types.LOGICAL_AND)) {
node = createOperatorNode(tokenizer.token.value, [node, processLogicalEquality(tokenizer.skipToken(), scope)]);
}
return node;
} | [
"function",
"processLogicalAnd",
"(",
"tokenizer",
",",
"scope",
")",
"{",
"let",
"node",
"=",
"processLogicalEquality",
"(",
"tokenizer",
",",
"scope",
")",
";",
"while",
"(",
"tokenizer",
".",
"token",
".",
"match",
"(",
"types",
".",
"LOGICAL_AND",
")",
... | Process logical AND operator
@return {Function} compiled node
@private | [
"Process",
"logical",
"AND",
"operator"
] | e8b96e50c1ba9d97ca22ee2bb6d9af6de466f9ca | https://github.com/abukurov/morph-expressions/blob/e8b96e50c1ba9d97ca22ee2bb6d9af6de466f9ca/src/abstract-syntax-tree.js#L79-L87 | train |
abukurov/morph-expressions | src/abstract-syntax-tree.js | processAddSubtract | function processAddSubtract(tokenizer, scope) {
let node = processMultiplyDivide(tokenizer, scope);
while (tokenizer.token.match(types.ADD_SUBTRACT)) {
node = createOperatorNode(tokenizer.token.value, [node, processMultiplyDivide(tokenizer.skipToken(), scope)]);
}
return node;
} | javascript | function processAddSubtract(tokenizer, scope) {
let node = processMultiplyDivide(tokenizer, scope);
while (tokenizer.token.match(types.ADD_SUBTRACT)) {
node = createOperatorNode(tokenizer.token.value, [node, processMultiplyDivide(tokenizer.skipToken(), scope)]);
}
return node;
} | [
"function",
"processAddSubtract",
"(",
"tokenizer",
",",
"scope",
")",
"{",
"let",
"node",
"=",
"processMultiplyDivide",
"(",
"tokenizer",
",",
"scope",
")",
";",
"while",
"(",
"tokenizer",
".",
"token",
".",
"match",
"(",
"types",
".",
"ADD_SUBTRACT",
")",
... | Process math Add or Subtract operators
@return {Function} compiled node
@private | [
"Process",
"math",
"Add",
"or",
"Subtract",
"operators"
] | e8b96e50c1ba9d97ca22ee2bb6d9af6de466f9ca | https://github.com/abukurov/morph-expressions/blob/e8b96e50c1ba9d97ca22ee2bb6d9af6de466f9ca/src/abstract-syntax-tree.js#L124-L132 | train |
abukurov/morph-expressions | src/abstract-syntax-tree.js | processMultiplyDivide | function processMultiplyDivide(tokenizer, scope) {
let node = processUnary(tokenizer, scope);
while (tokenizer.token.match(types.MULTIPLY_DIVIDE)) {
node = createOperatorNode(tokenizer.token.value, [node, processUnary(tokenizer.skipToken(), scope)]);
}
return node;
} | javascript | function processMultiplyDivide(tokenizer, scope) {
let node = processUnary(tokenizer, scope);
while (tokenizer.token.match(types.MULTIPLY_DIVIDE)) {
node = createOperatorNode(tokenizer.token.value, [node, processUnary(tokenizer.skipToken(), scope)]);
}
return node;
} | [
"function",
"processMultiplyDivide",
"(",
"tokenizer",
",",
"scope",
")",
"{",
"let",
"node",
"=",
"processUnary",
"(",
"tokenizer",
",",
"scope",
")",
";",
"while",
"(",
"tokenizer",
".",
"token",
".",
"match",
"(",
"types",
".",
"MULTIPLY_DIVIDE",
")",
"... | Process math Multiply, Divide or Modulus operators
@return {Function} compiled node
@privateR | [
"Process",
"math",
"Multiply",
"Divide",
"or",
"Modulus",
"operators"
] | e8b96e50c1ba9d97ca22ee2bb6d9af6de466f9ca | https://github.com/abukurov/morph-expressions/blob/e8b96e50c1ba9d97ca22ee2bb6d9af6de466f9ca/src/abstract-syntax-tree.js#L139-L147 | train |
abukurov/morph-expressions | src/abstract-syntax-tree.js | processUnary | function processUnary(tokenizer, scope) {
const unaryAddSubtract = {
'-': value => -value,
'+': value => value
};
if (tokenizer.token.match(types.ADD_SUBTRACT)) {
return createOperatorNode(unaryAddSubtract[tokenizer.token.lexeme], [processUnary(tokenizer.skipToken(), scope)]);
}
if (tokenizer.to... | javascript | function processUnary(tokenizer, scope) {
const unaryAddSubtract = {
'-': value => -value,
'+': value => value
};
if (tokenizer.token.match(types.ADD_SUBTRACT)) {
return createOperatorNode(unaryAddSubtract[tokenizer.token.lexeme], [processUnary(tokenizer.skipToken(), scope)]);
}
if (tokenizer.to... | [
"function",
"processUnary",
"(",
"tokenizer",
",",
"scope",
")",
"{",
"const",
"unaryAddSubtract",
"=",
"{",
"'-'",
":",
"value",
"=>",
"-",
"value",
",",
"'+'",
":",
"value",
"=>",
"value",
"}",
";",
"if",
"(",
"tokenizer",
".",
"token",
".",
"match",... | Process Unary plus and minus, and negation operators
@return {Function} compiled node
@private | [
"Process",
"Unary",
"plus",
"and",
"minus",
"and",
"negation",
"operators"
] | e8b96e50c1ba9d97ca22ee2bb6d9af6de466f9ca | https://github.com/abukurov/morph-expressions/blob/e8b96e50c1ba9d97ca22ee2bb6d9af6de466f9ca/src/abstract-syntax-tree.js#L154-L169 | train |
abukurov/morph-expressions | src/abstract-syntax-tree.js | processIdentifiers | function processIdentifiers(tokenizer, scope) {
let params = [];
if (tokenizer.token.match(types.IDENTIFIER)) {
const keys = [tokenizer.token.value];
tokenizer.skipToken();
while (tokenizer.token.match(types.DOT, types.OPEN_SQUARE_BRACKET)) {
const token = tokenizer.token;
tokenizer.skip... | javascript | function processIdentifiers(tokenizer, scope) {
let params = [];
if (tokenizer.token.match(types.IDENTIFIER)) {
const keys = [tokenizer.token.value];
tokenizer.skipToken();
while (tokenizer.token.match(types.DOT, types.OPEN_SQUARE_BRACKET)) {
const token = tokenizer.token;
tokenizer.skip... | [
"function",
"processIdentifiers",
"(",
"tokenizer",
",",
"scope",
")",
"{",
"let",
"params",
"=",
"[",
"]",
";",
"if",
"(",
"tokenizer",
".",
"token",
".",
"match",
"(",
"types",
".",
"IDENTIFIER",
")",
")",
"{",
"const",
"keys",
"=",
"[",
"tokenizer",... | Process custom identifiers and functions
@return {Function} compiled node
@private | [
"Process",
"custom",
"identifiers",
"and",
"functions"
] | e8b96e50c1ba9d97ca22ee2bb6d9af6de466f9ca | https://github.com/abukurov/morph-expressions/blob/e8b96e50c1ba9d97ca22ee2bb6d9af6de466f9ca/src/abstract-syntax-tree.js#L176-L239 | train |
abukurov/morph-expressions | src/abstract-syntax-tree.js | processConstants | function processConstants(tokenizer, scope) {
if (tokenizer.token.match(types.CONSTANT)) {
const node = createConstantNode(tokenizer.token.value);
tokenizer.skipToken();
return node;
}
return processParentheses(tokenizer, scope);
} | javascript | function processConstants(tokenizer, scope) {
if (tokenizer.token.match(types.CONSTANT)) {
const node = createConstantNode(tokenizer.token.value);
tokenizer.skipToken();
return node;
}
return processParentheses(tokenizer, scope);
} | [
"function",
"processConstants",
"(",
"tokenizer",
",",
"scope",
")",
"{",
"if",
"(",
"tokenizer",
".",
"token",
".",
"match",
"(",
"types",
".",
"CONSTANT",
")",
")",
"{",
"const",
"node",
"=",
"createConstantNode",
"(",
"tokenizer",
".",
"token",
".",
"... | Process numeric, and string, and predefined constants
@return {Function} compiled node
@private | [
"Process",
"numeric",
"and",
"string",
"and",
"predefined",
"constants"
] | e8b96e50c1ba9d97ca22ee2bb6d9af6de466f9ca | https://github.com/abukurov/morph-expressions/blob/e8b96e50c1ba9d97ca22ee2bb6d9af6de466f9ca/src/abstract-syntax-tree.js#L246-L256 | train |
abukurov/morph-expressions | src/abstract-syntax-tree.js | processParentheses | function processParentheses(tokenizer, scope) {
if (tokenizer.token.match(types.CLOSE_PARENTHESES)) {
throw new SyntaxError('Unexpected end of expression');
}
if (tokenizer.token.match(types.OPEN_PARENTHESES)) {
const node = processLogicalOr(tokenizer.skipToken(), scope);
if (!tokenizer.token.match(... | javascript | function processParentheses(tokenizer, scope) {
if (tokenizer.token.match(types.CLOSE_PARENTHESES)) {
throw new SyntaxError('Unexpected end of expression');
}
if (tokenizer.token.match(types.OPEN_PARENTHESES)) {
const node = processLogicalOr(tokenizer.skipToken(), scope);
if (!tokenizer.token.match(... | [
"function",
"processParentheses",
"(",
"tokenizer",
",",
"scope",
")",
"{",
"if",
"(",
"tokenizer",
".",
"token",
".",
"match",
"(",
"types",
".",
"CLOSE_PARENTHESES",
")",
")",
"{",
"throw",
"new",
"SyntaxError",
"(",
"'Unexpected end of expression'",
")",
";... | Process parentheses expressions
@return {Function} compiled node
@private | [
"Process",
"parentheses",
"expressions"
] | e8b96e50c1ba9d97ca22ee2bb6d9af6de466f9ca | https://github.com/abukurov/morph-expressions/blob/e8b96e50c1ba9d97ca22ee2bb6d9af6de466f9ca/src/abstract-syntax-tree.js#L263-L280 | train |
kadamwhite/mbtapi | api.js | makeMBTAPI | function makeMBTAPI( config ) {
if ( ! config.apiKey || typeof config.apiKey !== 'string' ) {
throw new Error( 'An MBTA API key must be provided' );
}
config.apiRoot = config.apiRoot || 'http://realtime.mbta.com/developer/api/v2/';
return _.mapValues( methods, function( args, key ) {
// makeQueryHandle... | javascript | function makeMBTAPI( config ) {
if ( ! config.apiKey || typeof config.apiKey !== 'string' ) {
throw new Error( 'An MBTA API key must be provided' );
}
config.apiRoot = config.apiRoot || 'http://realtime.mbta.com/developer/api/v2/';
return _.mapValues( methods, function( args, key ) {
// makeQueryHandle... | [
"function",
"makeMBTAPI",
"(",
"config",
")",
"{",
"if",
"(",
"!",
"config",
".",
"apiKey",
"||",
"typeof",
"config",
".",
"apiKey",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'An MBTA API key must be provided'",
")",
";",
"}",
"config",
"... | Create and return an MBTAPI interface object
@method create
@param {Object} config Configuration object
@param {String} config.apiKey A developer.mbta.com API key
@param {String} [config.apiRoot] An alternative API endpoint to query
@return {MBTAPI} A configured MBTAPI instance | [
"Create",
"and",
"return",
"an",
"MBTAPI",
"interface",
"object"
] | 9abb3966dad5db4117ba84966ecc98321c717428 | https://github.com/kadamwhite/mbtapi/blob/9abb3966dad5db4117ba84966ecc98321c717428/api.js#L21-L31 | train |
jkroso/serialize-svg-path | index.js | serialize | function serialize(path){
return path.reduce(function(str, seg){
return str + seg[0] + seg.slice(1).join(',')
}, '')
} | javascript | function serialize(path){
return path.reduce(function(str, seg){
return str + seg[0] + seg.slice(1).join(',')
}, '')
} | [
"function",
"serialize",
"(",
"path",
")",
"{",
"return",
"path",
".",
"reduce",
"(",
"function",
"(",
"str",
",",
"seg",
")",
"{",
"return",
"str",
"+",
"seg",
"[",
"0",
"]",
"+",
"seg",
".",
"slice",
"(",
"1",
")",
".",
"join",
"(",
"','",
")... | convert `path` to a string
@param {Array} path
@return {String} | [
"convert",
"path",
"to",
"a",
"string"
] | be1f9d1b83828be1520cd4e26666f37f2a6e3da5 | https://github.com/jkroso/serialize-svg-path/blob/be1f9d1b83828be1520cd4e26666f37f2a6e3da5/index.js#L11-L15 | train |
Lokiedu/grapheme-utils | index.js | slice | function slice(str, beginSlice, endSlice) {
return GraphemeBreaker.break(str)
.slice(beginSlice, endSlice)
.join('');
} | javascript | function slice(str, beginSlice, endSlice) {
return GraphemeBreaker.break(str)
.slice(beginSlice, endSlice)
.join('');
} | [
"function",
"slice",
"(",
"str",
",",
"beginSlice",
",",
"endSlice",
")",
"{",
"return",
"GraphemeBreaker",
".",
"break",
"(",
"str",
")",
".",
"slice",
"(",
"beginSlice",
",",
"endSlice",
")",
".",
"join",
"(",
"''",
")",
";",
"}"
] | Extracts a section of a string and returns a new string. | [
"Extracts",
"a",
"section",
"of",
"a",
"string",
"and",
"returns",
"a",
"new",
"string",
"."
] | 66ca45a0a094507eb319ba594c9a4030128dc776 | https://github.com/Lokiedu/grapheme-utils/blob/66ca45a0a094507eb319ba594c9a4030128dc776/index.js#L7-L11 | train |
ThatDevCompany/that-build-library | src/utils/private.js | zipFolder | function zipFolder(zip, ffs, root, dir) {
dir = dir || '';
let files = ffs.readdirSync(root + (dir ? '/' + dir : ''));
files.forEach(file => {
if (['.ts', '.js.map'].some(e => file.endsWith(e))) {
return;
}
let stat = ffs.statSync(root + (dir ? '/' + dir : '') + '/' + fil... | javascript | function zipFolder(zip, ffs, root, dir) {
dir = dir || '';
let files = ffs.readdirSync(root + (dir ? '/' + dir : ''));
files.forEach(file => {
if (['.ts', '.js.map'].some(e => file.endsWith(e))) {
return;
}
let stat = ffs.statSync(root + (dir ? '/' + dir : '') + '/' + fil... | [
"function",
"zipFolder",
"(",
"zip",
",",
"ffs",
",",
"root",
",",
"dir",
")",
"{",
"dir",
"=",
"dir",
"||",
"''",
";",
"let",
"files",
"=",
"ffs",
".",
"readdirSync",
"(",
"root",
"+",
"(",
"dir",
"?",
"'/'",
"+",
"dir",
":",
"''",
")",
")",
... | PRIVATE Zip Folder | [
"PRIVATE",
"Zip",
"Folder"
] | 865aaac49531fa9793a055a4df8e9b1b41e71753 | https://github.com/ThatDevCompany/that-build-library/blob/865aaac49531fa9793a055a4df8e9b1b41e71753/src/utils/private.js#L6-L21 | train |
ThatDevCompany/that-build-library | src/utils/private.js | zipFile | function zipFile(zip, ffs, root, dir, file) {
dir = dir || '';
let zipfolder = dir ? zip.folder(dir) : zip;
const data = ffs.readFileSync(root + (dir ? '/' + dir : '') + '/' + file);
zipfolder.file(file, data);
} | javascript | function zipFile(zip, ffs, root, dir, file) {
dir = dir || '';
let zipfolder = dir ? zip.folder(dir) : zip;
const data = ffs.readFileSync(root + (dir ? '/' + dir : '') + '/' + file);
zipfolder.file(file, data);
} | [
"function",
"zipFile",
"(",
"zip",
",",
"ffs",
",",
"root",
",",
"dir",
",",
"file",
")",
"{",
"dir",
"=",
"dir",
"||",
"''",
";",
"let",
"zipfolder",
"=",
"dir",
"?",
"zip",
".",
"folder",
"(",
"dir",
")",
":",
"zip",
";",
"const",
"data",
"="... | PRIVATE Zip File | [
"PRIVATE",
"Zip",
"File"
] | 865aaac49531fa9793a055a4df8e9b1b41e71753 | https://github.com/ThatDevCompany/that-build-library/blob/865aaac49531fa9793a055a4df8e9b1b41e71753/src/utils/private.js#L26-L31 | train |
ThatDevCompany/that-build-library | src/utils/private.js | checkFolder | function checkFolder(ffs, fld) {
let fldBits = fld.split('/'), mkfld = '';
fldBits.forEach(toBit => {
mkfld = mkfld ? mkfld + '/' + toBit : toBit;
if (mkfld && !ffs.existsSync(mkfld)) {
ffs.mkdirSync(mkfld);
}
});
} | javascript | function checkFolder(ffs, fld) {
let fldBits = fld.split('/'), mkfld = '';
fldBits.forEach(toBit => {
mkfld = mkfld ? mkfld + '/' + toBit : toBit;
if (mkfld && !ffs.existsSync(mkfld)) {
ffs.mkdirSync(mkfld);
}
});
} | [
"function",
"checkFolder",
"(",
"ffs",
",",
"fld",
")",
"{",
"let",
"fldBits",
"=",
"fld",
".",
"split",
"(",
"'/'",
")",
",",
"mkfld",
"=",
"''",
";",
"fldBits",
".",
"forEach",
"(",
"toBit",
"=>",
"{",
"mkfld",
"=",
"mkfld",
"?",
"mkfld",
"+",
... | PRIVATE Check Folder | [
"PRIVATE",
"Check",
"Folder"
] | 865aaac49531fa9793a055a4df8e9b1b41e71753 | https://github.com/ThatDevCompany/that-build-library/blob/865aaac49531fa9793a055a4df8e9b1b41e71753/src/utils/private.js#L36-L44 | train |
ThatDevCompany/that-build-library | src/utils/private.js | copyFolder | function copyFolder(ffs, from, to) {
checkFolder(ffs, to);
let tasks = [];
ffs.readdirSync(from).forEach(child => {
if (ffs.statSync(from + '/' + child).isDirectory()) {
copyFolder(ffs, from + '/' + child, to + '/' + child);
}
else {
copyFile(ffs, from + '/' +... | javascript | function copyFolder(ffs, from, to) {
checkFolder(ffs, to);
let tasks = [];
ffs.readdirSync(from).forEach(child => {
if (ffs.statSync(from + '/' + child).isDirectory()) {
copyFolder(ffs, from + '/' + child, to + '/' + child);
}
else {
copyFile(ffs, from + '/' +... | [
"function",
"copyFolder",
"(",
"ffs",
",",
"from",
",",
"to",
")",
"{",
"checkFolder",
"(",
"ffs",
",",
"to",
")",
";",
"let",
"tasks",
"=",
"[",
"]",
";",
"ffs",
".",
"readdirSync",
"(",
"from",
")",
".",
"forEach",
"(",
"child",
"=>",
"{",
"if"... | PRIVATE Copy Folder | [
"PRIVATE",
"Copy",
"Folder"
] | 865aaac49531fa9793a055a4df8e9b1b41e71753 | https://github.com/ThatDevCompany/that-build-library/blob/865aaac49531fa9793a055a4df8e9b1b41e71753/src/utils/private.js#L49-L60 | train |
cliffano/ae86 | lib/engine.js | _process | function _process(templates, params, cb) {
var _templates = _.extend(templates, {}), // process template copies, not the originals
tasks = {};
_.keys(_templates).forEach(function (key) {
tasks[key] = function (cb) {
_templates[key].process(params, function (data) {
cb(null, data);... | javascript | function _process(templates, params, cb) {
var _templates = _.extend(templates, {}), // process template copies, not the originals
tasks = {};
_.keys(_templates).forEach(function (key) {
tasks[key] = function (cb) {
_templates[key].process(params, function (data) {
cb(null, data);... | [
"function",
"_process",
"(",
"templates",
",",
"params",
",",
"cb",
")",
"{",
"var",
"_templates",
"=",
"_",
".",
"extend",
"(",
"templates",
",",
"{",
"}",
")",
",",
"// process template copies, not the originals",
"tasks",
"=",
"{",
"}",
";",
"_",
".",
... | merge a set of params to a set of templates | [
"merge",
"a",
"set",
"of",
"params",
"to",
"a",
"set",
"of",
"templates"
] | 7687e438a93638231bf7d2bebe1e8b062082a9a3 | https://github.com/cliffano/ae86/blob/7687e438a93638231bf7d2bebe1e8b062082a9a3/lib/engine.js#L73-L88 | train |
deathcap/cjs2es6export | cjs2es6export.js | function(node) {
if (node.type !== 'AssignmentExpression') return false;
return node.left.type === 'MemberExpression' &&
node.left.object.type === 'Identifier' && node.left.object.name === 'module' &&
node.left.property.type === 'Identifier' && node.left.property.name === 'exports';
// TODO: de... | javascript | function(node) {
if (node.type !== 'AssignmentExpression') return false;
return node.left.type === 'MemberExpression' &&
node.left.object.type === 'Identifier' && node.left.object.name === 'module' &&
node.left.property.type === 'Identifier' && node.left.property.name === 'exports';
// TODO: de... | [
"function",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"type",
"!==",
"'AssignmentExpression'",
")",
"return",
"false",
";",
"return",
"node",
".",
"left",
".",
"type",
"===",
"'MemberExpression'",
"&&",
"node",
".",
"left",
".",
"object",
".",
"type... | module.exports = | [
"module",
".",
"exports",
"="
] | 4a13b039f58ed4fbe2f823bdab5f25675832cb72 | https://github.com/deathcap/cjs2es6export/blob/4a13b039f58ed4fbe2f823bdab5f25675832cb72/cjs2es6export.js#L17-L24 | train | |
jdborowy/grunt-remove-logging-calls | tasks/lib/removeloggingcalls.js | function(rootNode) {
// queue to compute de breadth first search
var queue = [rootNode];
var nodes = [rootNode];
while (queue.length !== 0) {
// fetch child nodes of the first node of the queue
var currentNode = queue.shift();
for (var property in cu... | javascript | function(rootNode) {
// queue to compute de breadth first search
var queue = [rootNode];
var nodes = [rootNode];
while (queue.length !== 0) {
// fetch child nodes of the first node of the queue
var currentNode = queue.shift();
for (var property in cu... | [
"function",
"(",
"rootNode",
")",
"{",
"// queue to compute de breadth first search",
"var",
"queue",
"=",
"[",
"rootNode",
"]",
";",
"var",
"nodes",
"=",
"[",
"rootNode",
"]",
";",
"while",
"(",
"queue",
".",
"length",
"!==",
"0",
")",
"{",
"// fetch child ... | Compute the breadth first search on syntax tree to get the list of nodes
@param {Node} rootNode the root node of the tree
@return {Node[]} the list of all the tree nodes | [
"Compute",
"the",
"breadth",
"first",
"search",
"on",
"syntax",
"tree",
"to",
"get",
"the",
"list",
"of",
"nodes"
] | bf6ae6fbb778cede015dc96dbba0a18a6e0a90e4 | https://github.com/jdborowy/grunt-remove-logging-calls/blob/bf6ae6fbb778cede015dc96dbba0a18a6e0a90e4/tasks/lib/removeloggingcalls.js#L19-L49 | train | |
jdborowy/grunt-remove-logging-calls | tasks/lib/removeloggingcalls.js | function(nodes, methods) {
var segmentsToBlank = [];
for (var i = 0, ii = nodes.length; i < ii; ++i) {
// checks if the statement is a CallExpression
if (nodes[i].type === 'CallExpression' &&
nodes[i].callee.type === 'MemberExpression') {
var ... | javascript | function(nodes, methods) {
var segmentsToBlank = [];
for (var i = 0, ii = nodes.length; i < ii; ++i) {
// checks if the statement is a CallExpression
if (nodes[i].type === 'CallExpression' &&
nodes[i].callee.type === 'MemberExpression') {
var ... | [
"function",
"(",
"nodes",
",",
"methods",
")",
"{",
"var",
"segmentsToBlank",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"ii",
"=",
"nodes",
".",
"length",
";",
"i",
"<",
"ii",
";",
"++",
"i",
")",
"{",
"// checks if the statement i... | Identify nodes that relate to console statements
@param {Node[]} nodes the list of nodes
@param {Node[]} methods the methods to identify
@param {String[]} methods the properties (functions) to catch for blanking | [
"Identify",
"nodes",
"that",
"relate",
"to",
"console",
"statements"
] | bf6ae6fbb778cede015dc96dbba0a18a6e0a90e4 | https://github.com/jdborowy/grunt-remove-logging-calls/blob/bf6ae6fbb778cede015dc96dbba0a18a6e0a90e4/tasks/lib/removeloggingcalls.js#L57-L86 | train | |
jdborowy/grunt-remove-logging-calls | tasks/lib/removeloggingcalls.js | function(segments) {
var previousSegment = [-1, -1];
var segmentIndicesToRemove = [];
var cleanedSegmentArray = [];
var i, ii;
for (i = 0, ii = segments.length; i < ii; ++i) {
if (!(previousSegment[0] <= segments[i][0] &&
previousSegment[1] >= segm... | javascript | function(segments) {
var previousSegment = [-1, -1];
var segmentIndicesToRemove = [];
var cleanedSegmentArray = [];
var i, ii;
for (i = 0, ii = segments.length; i < ii; ++i) {
if (!(previousSegment[0] <= segments[i][0] &&
previousSegment[1] >= segm... | [
"function",
"(",
"segments",
")",
"{",
"var",
"previousSegment",
"=",
"[",
"-",
"1",
",",
"-",
"1",
"]",
";",
"var",
"segmentIndicesToRemove",
"=",
"[",
"]",
";",
"var",
"cleanedSegmentArray",
"=",
"[",
"]",
";",
"var",
"i",
",",
"ii",
";",
"for",
... | Remove segments that are nested in other
@param {Node[]} node the console calls nodes | [
"Remove",
"segments",
"that",
"are",
"nested",
"in",
"other"
] | bf6ae6fbb778cede015dc96dbba0a18a6e0a90e4 | https://github.com/jdborowy/grunt-remove-logging-calls/blob/bf6ae6fbb778cede015dc96dbba0a18a6e0a90e4/tasks/lib/removeloggingcalls.js#L92-L109 | train | |
bodenr/expose | lib/expose.js | importModule | function importModule(module, scope, fn) {
debug("Importing module: " + module);
var imports = require(module),
name = path.basename(module, path.extname(module));
if (isPlainObject(imports)) {
var keys = Object.keys(imports), key, len = keys.length;
for (var i = 0; i < len; i++) {... | javascript | function importModule(module, scope, fn) {
debug("Importing module: " + module);
var imports = require(module),
name = path.basename(module, path.extname(module));
if (isPlainObject(imports)) {
var keys = Object.keys(imports), key, len = keys.length;
for (var i = 0; i < len; i++) {... | [
"function",
"importModule",
"(",
"module",
",",
"scope",
",",
"fn",
")",
"{",
"debug",
"(",
"\"Importing module: \"",
"+",
"module",
")",
";",
"var",
"imports",
"=",
"require",
"(",
"module",
")",
",",
"name",
"=",
"path",
".",
"basename",
"(",
"module",... | Import a module into the given scope there by
`require`ing the module and copying its exports
into the given scope object.
@param {String} module The path to the module to require.
@param {Object} scope The namespace to import the modules exports into.
@param {Function} fn The optional callback function to invoke for ... | [
"Import",
"a",
"module",
"into",
"the",
"given",
"scope",
"there",
"by",
"require",
"ing",
"the",
"module",
"and",
"copying",
"its",
"exports",
"into",
"the",
"given",
"scope",
"object",
"."
] | 7801e2fdbca8fd6445e76365ef7011bcac1b6cfa | https://github.com/bodenr/expose/blob/7801e2fdbca8fd6445e76365ef7011bcac1b6cfa/lib/expose.js#L156-L179 | train |
bodenr/expose | lib/expose.js | load | function load(target, opts) {
target = path.resolve(target);
debug("Load enter: " + target);
if (fs.statSync(target).isDirectory()) {
var files = fs.readdirSync(target), len = files.length, file;
for (var i = 0; i < len; i++) {
file = files[i];
var fullPath = target... | javascript | function load(target, opts) {
target = path.resolve(target);
debug("Load enter: " + target);
if (fs.statSync(target).isDirectory()) {
var files = fs.readdirSync(target), len = files.length, file;
for (var i = 0; i < len; i++) {
file = files[i];
var fullPath = target... | [
"function",
"load",
"(",
"target",
",",
"opts",
")",
"{",
"target",
"=",
"path",
".",
"resolve",
"(",
"target",
")",
";",
"debug",
"(",
"\"Load enter: \"",
"+",
"target",
")",
";",
"if",
"(",
"fs",
".",
"statSync",
"(",
"target",
")",
".",
"isDirecto... | Perform importing on the given target based on the
given options. The target can be a directory to
walk or it can be a file.
The `opts` passed in should be the same format
as those built with `defaultOpts`.
@param {String} target The file or dir to target.
@param {Object} opts The options to use for importing.
@api p... | [
"Perform",
"importing",
"on",
"the",
"given",
"target",
"based",
"on",
"the",
"given",
"options",
".",
"The",
"target",
"can",
"be",
"a",
"directory",
"to",
"walk",
"or",
"it",
"can",
"be",
"a",
"file",
"."
] | 7801e2fdbca8fd6445e76365ef7011bcac1b6cfa | https://github.com/bodenr/expose/blob/7801e2fdbca8fd6445e76365ef7011bcac1b6cfa/lib/expose.js#L205-L225 | train |
bodenr/expose | lib/expose.js | asRegExps | function asRegExps(array) {
var array = asArray(array), len = array.length;
for (var i = 0; i < len; i++) {
if (!(array[i] instanceof RegExp)) {
array[i] = new RegExp(array[i]);
}
}
return array;
} | javascript | function asRegExps(array) {
var array = asArray(array), len = array.length;
for (var i = 0; i < len; i++) {
if (!(array[i] instanceof RegExp)) {
array[i] = new RegExp(array[i]);
}
}
return array;
} | [
"function",
"asRegExps",
"(",
"array",
")",
"{",
"var",
"array",
"=",
"asArray",
"(",
"array",
")",
",",
"len",
"=",
"array",
".",
"length",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!"... | Validates each item in the array is a `RegExp` instance
and if not it creates a new `RegExp` for the item and
stores it in the array index.
@param array
@returns
@api private | [
"Validates",
"each",
"item",
"in",
"the",
"array",
"is",
"a",
"RegExp",
"instance",
"and",
"if",
"not",
"it",
"creates",
"a",
"new",
"RegExp",
"for",
"the",
"item",
"and",
"stores",
"it",
"in",
"the",
"array",
"index",
"."
] | 7801e2fdbca8fd6445e76365ef7011bcac1b6cfa | https://github.com/bodenr/expose/blob/7801e2fdbca8fd6445e76365ef7011bcac1b6cfa/lib/expose.js#L292-L300 | train |
bodenr/expose | lib/expose.js | defaultOpts | function defaultOpts(opts, parentId) {
var targets = opts.targets && opts.targets.length
? asArray(opts.targets)
: [defaultTarget(parentId)];
return mixin({targets: targets,
grep: [/\.js$/],
ungrep: opts.ungrep && opts.ungrep.length
? asArray(... | javascript | function defaultOpts(opts, parentId) {
var targets = opts.targets && opts.targets.length
? asArray(opts.targets)
: [defaultTarget(parentId)];
return mixin({targets: targets,
grep: [/\.js$/],
ungrep: opts.ungrep && opts.ungrep.length
? asArray(... | [
"function",
"defaultOpts",
"(",
"opts",
",",
"parentId",
")",
"{",
"var",
"targets",
"=",
"opts",
".",
"targets",
"&&",
"opts",
".",
"targets",
".",
"length",
"?",
"asArray",
"(",
"opts",
".",
"targets",
")",
":",
"[",
"defaultTarget",
"(",
"parentId",
... | Returns the default options for this module merged
with the given options passed to this function.
The defaults are as follows:
- grep: any file ending in `.js`
- ungrep: any path including `node_modules`
- scope: an empty object
- recurse: true
- targets: return value from `defaultTargets()`
@param {Object} opts The... | [
"Returns",
"the",
"default",
"options",
"for",
"this",
"module",
"merged",
"with",
"the",
"given",
"options",
"passed",
"to",
"this",
"function",
"."
] | 7801e2fdbca8fd6445e76365ef7011bcac1b6cfa | https://github.com/bodenr/expose/blob/7801e2fdbca8fd6445e76365ef7011bcac1b6cfa/lib/expose.js#L319-L332 | train |
bodenr/expose | lib/expose.js | defaultUngrep | function defaultUngrep(targets) {
if (targets && targets.length) {
var ungreps = [], target, len = targets.length;
for (var i = 0; i < len; i++) {
target = targets[i];
target = '(?:^' + path.dirname(target) + sep + '){1}';
target += '(?:/?.*/?)*' + NM_SEG;
... | javascript | function defaultUngrep(targets) {
if (targets && targets.length) {
var ungreps = [], target, len = targets.length;
for (var i = 0; i < len; i++) {
target = targets[i];
target = '(?:^' + path.dirname(target) + sep + '){1}';
target += '(?:/?.*/?)*' + NM_SEG;
... | [
"function",
"defaultUngrep",
"(",
"targets",
")",
"{",
"if",
"(",
"targets",
"&&",
"targets",
".",
"length",
")",
"{",
"var",
"ungreps",
"=",
"[",
"]",
",",
"target",
",",
"len",
"=",
"targets",
".",
"length",
";",
"for",
"(",
"var",
"i",
"=",
"0",... | Build default ungrep pattern based on targets.
@param {Array} targets
@returns {Array} The default ungrep regex in an array.
@api private | [
"Build",
"default",
"ungrep",
"pattern",
"based",
"on",
"targets",
"."
] | 7801e2fdbca8fd6445e76365ef7011bcac1b6cfa | https://github.com/bodenr/expose/blob/7801e2fdbca8fd6445e76365ef7011bcac1b6cfa/lib/expose.js#L365-L378 | train |
amida-tech/blue-button-pim | lib/candidates.js | compare | function compare(data, candidates, shim, at, mt) {
var results = [];
var i;
for (i = 0; i < candidates.length; i++) {
var candidate = candidates[i];
if (shim) {
candidate = shim(candidate);
}
//compare candidate with patient
var s = score(data, candidat... | javascript | function compare(data, candidates, shim, at, mt) {
var results = [];
var i;
for (i = 0; i < candidates.length; i++) {
var candidate = candidates[i];
if (shim) {
candidate = shim(candidate);
}
//compare candidate with patient
var s = score(data, candidat... | [
"function",
"compare",
"(",
"data",
",",
"candidates",
",",
"shim",
",",
"at",
",",
"mt",
")",
"{",
"var",
"results",
"=",
"[",
"]",
";",
"var",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"candidates",
".",
"length",
";",
"i",
"++",
... | runs through array of candidates and compare them with patient's data returns list of matches and flagged candidates | [
"runs",
"through",
"array",
"of",
"candidates",
"and",
"compare",
"them",
"with",
"patient",
"s",
"data",
"returns",
"list",
"of",
"matches",
"and",
"flagged",
"candidates"
] | 329dcc5fa5f3d877c2b675e8e0d689a8ef25a895 | https://github.com/amida-tech/blue-button-pim/blob/329dcc5fa5f3d877c2b675e8e0d689a8ef25a895/lib/candidates.js#L11-L36 | train |
aaronabramov/esfmt | package/newlines.js | newLineAfterCompositeExpressions | function newLineAfterCompositeExpressions(previous) {
if (previous.type === 'ExpressionStatement') {
var expression = previous.expression;
switch (expression.type) {
case 'AssignmentExpression':
case 'BinaryExpression':
return NEED_EXTRA_NEWLINE_AFTER[express... | javascript | function newLineAfterCompositeExpressions(previous) {
if (previous.type === 'ExpressionStatement') {
var expression = previous.expression;
switch (expression.type) {
case 'AssignmentExpression':
case 'BinaryExpression':
return NEED_EXTRA_NEWLINE_AFTER[express... | [
"function",
"newLineAfterCompositeExpressions",
"(",
"previous",
")",
"{",
"if",
"(",
"previous",
".",
"type",
"===",
"'ExpressionStatement'",
")",
"{",
"var",
"expression",
"=",
"previous",
".",
"expression",
";",
"switch",
"(",
"expression",
".",
"type",
")",
... | Returns true if newline is needed after the composite expression
Examples:
1. Assignment expression
a.b.c = function() {
return 4;
}
2. a + function() {
return 2;
} | [
"Returns",
"true",
"if",
"newline",
"is",
"needed",
"after",
"the",
"composite",
"expression"
] | 8e05fa01d777d504f965ba484c287139a00b5b00 | https://github.com/aaronabramov/esfmt/blob/8e05fa01d777d504f965ba484c287139a00b5b00/package/newlines.js#L98-L105 | train |
tianjianchn/javascript-packages | packages/frm/src/record/construct.js | getPrototype | function getPrototype(model) {
if (model.__recordPrototype) return model.__recordPrototype;
const mrProto = Object.assign({}, proto);// eslint-disable-line no-use-before-define
const extraProperties = {};
Object.keys(model.def.fields).forEach((fieldName) => {
extraProperties[fieldName] = {
enumerable... | javascript | function getPrototype(model) {
if (model.__recordPrototype) return model.__recordPrototype;
const mrProto = Object.assign({}, proto);// eslint-disable-line no-use-before-define
const extraProperties = {};
Object.keys(model.def.fields).forEach((fieldName) => {
extraProperties[fieldName] = {
enumerable... | [
"function",
"getPrototype",
"(",
"model",
")",
"{",
"if",
"(",
"model",
".",
"__recordPrototype",
")",
"return",
"model",
".",
"__recordPrototype",
";",
"const",
"mrProto",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"proto",
")",
";",
"// eslint-dis... | get model specified record prototype | [
"get",
"model",
"specified",
"record",
"prototype"
] | 3abe85edbfe323939c84c1d02128d74d6374bcde | https://github.com/tianjianchn/javascript-packages/blob/3abe85edbfe323939c84c1d02128d74d6374bcde/packages/frm/src/record/construct.js#L47-L67 | train |
ciberch/node-express-boilerplate | lib/authentication.js | normalizeUserData | function normalizeUserData() {
function handler(req, res, next) {
if (req.session && !req.session.user && req.session.auth && req.session.auth.loggedIn) {
var user = {};
if (req.session.auth.github) {
user.image = 'http://1.gravatar.com/avatar/'+req.session.auth.github.user.gravatar_id+'?s=48';
u... | javascript | function normalizeUserData() {
function handler(req, res, next) {
if (req.session && !req.session.user && req.session.auth && req.session.auth.loggedIn) {
var user = {};
if (req.session.auth.github) {
user.image = 'http://1.gravatar.com/avatar/'+req.session.auth.github.user.gravatar_id+'?s=48';
u... | [
"function",
"normalizeUserData",
"(",
")",
"{",
"function",
"handler",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"if",
"(",
"req",
".",
"session",
"&&",
"!",
"req",
".",
"session",
".",
"user",
"&&",
"req",
".",
"session",
".",
"auth",
"&&",
"... | Fetch and format data so we have an easy object with user data to work with. | [
"Fetch",
"and",
"format",
"data",
"so",
"we",
"have",
"an",
"easy",
"object",
"with",
"user",
"data",
"to",
"work",
"with",
"."
] | 0f617063e56a5b1041f6eca374f1ff009b9747cf | https://github.com/ciberch/node-express-boilerplate/blob/0f617063e56a5b1041f6eca374f1ff009b9747cf/lib/authentication.js#L45-L83 | train |
dcodeIO/IntN.js | dist/IntN.js | IntN | function IntN(bytes, unsigned) {
/**
* Represented byte values, least significant first.
* @type {!Array.<number>}
* @expose
*/
this.bytes = new Array(nBytes);
for (var i=0, k=Math.min(nBytes, bytes.len... | javascript | function IntN(bytes, unsigned) {
/**
* Represented byte values, least significant first.
* @type {!Array.<number>}
* @expose
*/
this.bytes = new Array(nBytes);
for (var i=0, k=Math.min(nBytes, bytes.len... | [
"function",
"IntN",
"(",
"bytes",
",",
"unsigned",
")",
"{",
"/**\n * Represented byte values, least significant first.\n * @type {!Array.<number>}\n * @expose\n */",
"this",
".",
"bytes",
"=",
"new",
"Array",
"(",
"nByt... | Constructs a new IntN, where N is the number of bits represented by this class.
@class A class for representing arbitrary size integers, both signed and unsigned.
@exports IntN
@param {!Array.<number>|number} bytes Byte values, least significant first
@param {boolean=} unsigned Whether unsigned or signed, defaults to `... | [
"Constructs",
"a",
"new",
"IntN",
"where",
"N",
"is",
"the",
"number",
"of",
"bits",
"represented",
"by",
"this",
"class",
"."
] | d50a1323077a61c29460c5a267c2853e0b8ed0cf | https://github.com/dcodeIO/IntN.js/blob/d50a1323077a61c29460c5a267c2853e0b8ed0cf/dist/IntN.js#L81-L101 | train |
sagiegurari/js-project-commons | lib/grunt/config/init-config.js | createBuildConfig | function createBuildConfig(grunt, options, projectConfig) {
var configType = 'grunt-web';
if (options.buildConfig.dualProject) {
configType = 'grunt-dual';
} else if (options.buildConfig.nodeProject) {
configType = 'grunt-node';
}
var loader = require('./' + configType);
return... | javascript | function createBuildConfig(grunt, options, projectConfig) {
var configType = 'grunt-web';
if (options.buildConfig.dualProject) {
configType = 'grunt-dual';
} else if (options.buildConfig.nodeProject) {
configType = 'grunt-node';
}
var loader = require('./' + configType);
return... | [
"function",
"createBuildConfig",
"(",
"grunt",
",",
"options",
",",
"projectConfig",
")",
"{",
"var",
"configType",
"=",
"'grunt-web'",
";",
"if",
"(",
"options",
".",
"buildConfig",
".",
"dualProject",
")",
"{",
"configType",
"=",
"'grunt-dual'",
";",
"}",
... | Returns the build config object.
@function
@memberof! GruntInitConfig
@private
@param {Object} grunt - The grunt instance
@param {Object} options - Any additional grunt config data
@param {Object} [projectConfig] - Optional project specific config
@returns {Object} Grunt config object | [
"Returns",
"the",
"build",
"config",
"object",
"."
] | 42dd07a8a3b2c49db71f489e08b94ac7279007a3 | https://github.com/sagiegurari/js-project-commons/blob/42dd07a8a3b2c49db71f489e08b94ac7279007a3/lib/grunt/config/init-config.js#L18-L29 | train |
ThatDevCompany/that-build-library | src/utils/echo.js | echo | function echo(message) {
return __awaiter(this, void 0, void 0, function* () {
console.log('----------------');
console.log(message);
console.log('----------------');
return Promise.resolve();
});
} | javascript | function echo(message) {
return __awaiter(this, void 0, void 0, function* () {
console.log('----------------');
console.log(message);
console.log('----------------');
return Promise.resolve();
});
} | [
"function",
"echo",
"(",
"message",
")",
"{",
"return",
"__awaiter",
"(",
"this",
",",
"void",
"0",
",",
"void",
"0",
",",
"function",
"*",
"(",
")",
"{",
"console",
".",
"log",
"(",
"'----------------'",
")",
";",
"console",
".",
"log",
"(",
"messag... | Echo a message to the console | [
"Echo",
"a",
"message",
"to",
"the",
"console"
] | 865aaac49531fa9793a055a4df8e9b1b41e71753 | https://github.com/ThatDevCompany/that-build-library/blob/865aaac49531fa9793a055a4df8e9b1b41e71753/src/utils/echo.js#L14-L21 | train |
fatalxiao/js-markdown | src/lib/syntax/block/List.js | generateListItem | function generateListItem(result, hasBlankLine) {
const content = [result[3]];
if (hasBlankLine) {
content.unshift('\n');
}
return {
type: 'ListItem',
checked: result[2] === '[x]' ? true : (result[2] === '[ ]' ? false : undefined), // true / false / undefined
content,
... | javascript | function generateListItem(result, hasBlankLine) {
const content = [result[3]];
if (hasBlankLine) {
content.unshift('\n');
}
return {
type: 'ListItem',
checked: result[2] === '[x]' ? true : (result[2] === '[ ]' ? false : undefined), // true / false / undefined
content,
... | [
"function",
"generateListItem",
"(",
"result",
",",
"hasBlankLine",
")",
"{",
"const",
"content",
"=",
"[",
"result",
"[",
"3",
"]",
"]",
";",
"if",
"(",
"hasBlankLine",
")",
"{",
"content",
".",
"unshift",
"(",
"'\\n'",
")",
";",
"}",
"return",
"{",
... | generate a list item node according to match result
@param result
@returns {{type: string, checked: boolean, content: [*], children: Array}} | [
"generate",
"a",
"list",
"item",
"node",
"according",
"to",
"match",
"result"
] | dffa23be561f50282e5ccc2f1595a51d18a81246 | https://github.com/fatalxiao/js-markdown/blob/dffa23be561f50282e5ccc2f1595a51d18a81246/src/lib/syntax/block/List.js#L72-L87 | train |
3axap4eHko/yyf | src/undo-redo.js | getHistory | function getHistory(context) {
if (!historyMap.has(context)) {
clear(context);
}
return historyMap.get(context);
} | javascript | function getHistory(context) {
if (!historyMap.has(context)) {
clear(context);
}
return historyMap.get(context);
} | [
"function",
"getHistory",
"(",
"context",
")",
"{",
"if",
"(",
"!",
"historyMap",
".",
"has",
"(",
"context",
")",
")",
"{",
"clear",
"(",
"context",
")",
";",
"}",
"return",
"historyMap",
".",
"get",
"(",
"context",
")",
";",
"}"
] | Returns context history
@param {Object} context
@returns {Object} | [
"Returns",
"context",
"history"
] | 0eddc236a3a5052b682ecc31dbb459772e653c14 | https://github.com/3axap4eHko/yyf/blob/0eddc236a3a5052b682ecc31dbb459772e653c14/src/undo-redo.js#L30-L35 | train |
observing/fossa | lib/collection.js | constructor | function constructor(models, options) {
if (!Array.isArray(models)) {
options = models;
models = [];
}
options = options || {};
//
// Set the database name if it was provided in the options.
//
if (options.url) this.url = options.url;
if (options.databas... | javascript | function constructor(models, options) {
if (!Array.isArray(models)) {
options = models;
models = [];
}
options = options || {};
//
// Set the database name if it was provided in the options.
//
if (options.url) this.url = options.url;
if (options.databas... | [
"function",
"constructor",
"(",
"models",
",",
"options",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"models",
")",
")",
"{",
"options",
"=",
"models",
";",
"models",
"=",
"[",
"]",
";",
"}",
"options",
"=",
"options",
"||",
"{",
"}",
... | Override default Collection Constructor.
@param {Array} models
@param {Object} options
@api private | [
"Override",
"default",
"Collection",
"Constructor",
"."
] | 29b3717ee10a13fb607f5bbddcb8b003faf008c6 | https://github.com/observing/fossa/blob/29b3717ee10a13fb607f5bbddcb8b003faf008c6/lib/collection.js#L31-L54 | train |
observing/fossa | lib/collection.js | clone | function clone() {
return new this.constructor(this.models, {
url: 'function' === typeof this.url ? this.url() : this.url,
model: this.model,
database: this.database,
comparator: this.comparator
});
} | javascript | function clone() {
return new this.constructor(this.models, {
url: 'function' === typeof this.url ? this.url() : this.url,
model: this.model,
database: this.database,
comparator: this.comparator
});
} | [
"function",
"clone",
"(",
")",
"{",
"return",
"new",
"this",
".",
"constructor",
"(",
"this",
".",
"models",
",",
"{",
"url",
":",
"'function'",
"===",
"typeof",
"this",
".",
"url",
"?",
"this",
".",
"url",
"(",
")",
":",
"this",
".",
"url",
",",
... | Clone this Collection.
@returns {Collection}
@api public | [
"Clone",
"this",
"Collection",
"."
] | 29b3717ee10a13fb607f5bbddcb8b003faf008c6 | https://github.com/observing/fossa/blob/29b3717ee10a13fb607f5bbddcb8b003faf008c6/lib/collection.js#L73-L80 | train |
davidtucker/node-shutdown-manager | lib/shutdownManager.js | ShutdownManager | function ShutdownManager (params) {
// Set State
var that = this;
this.isShuttingDown = false;
this.actionChain = [];
this.finalActionChain = [];
// Set Parameters
this.logger = (params && params.hasOwnProperty("logger")) ? params.logger : null;
this.loggingPrefix = (params && params.hasOwnProperty("log... | javascript | function ShutdownManager (params) {
// Set State
var that = this;
this.isShuttingDown = false;
this.actionChain = [];
this.finalActionChain = [];
// Set Parameters
this.logger = (params && params.hasOwnProperty("logger")) ? params.logger : null;
this.loggingPrefix = (params && params.hasOwnProperty("log... | [
"function",
"ShutdownManager",
"(",
"params",
")",
"{",
"// Set State",
"var",
"that",
"=",
"this",
";",
"this",
".",
"isShuttingDown",
"=",
"false",
";",
"this",
".",
"actionChain",
"=",
"[",
"]",
";",
"this",
".",
"finalActionChain",
"=",
"[",
"]",
";"... | The manager class which handles detecting the shutdown process as well as managing
a chain of actions to be performed when the shutdown process has been detected.
@param params [Object]
* +logger+ - (<tt>Object</tt>) You can pass in a custom logger. If a custom logger
is not passed in, the console will be used.
* +lo... | [
"The",
"manager",
"class",
"which",
"handles",
"detecting",
"the",
"shutdown",
"process",
"as",
"well",
"as",
"managing",
"a",
"chain",
"of",
"actions",
"to",
"be",
"performed",
"when",
"the",
"shutdown",
"process",
"has",
"been",
"detected",
"."
] | 5106ba004f7351c4281d9f736de176126077e75a | https://github.com/davidtucker/node-shutdown-manager/blob/5106ba004f7351c4281d9f736de176126077e75a/lib/shutdownManager.js#L40-L85 | train |
maciejzasada/grunt-gae | tasks/gae.js | readAuth | function readAuth (path) {
var auth;
if (grunt.file.exists(path)) {
auth = grunt.file.read(path).trim().split(/\s/);
if (auth.length === 2 && auth[0].indexOf('@') !== -1) {
return {email: auth[0], password: auth[1]};
}
}
return null;
... | javascript | function readAuth (path) {
var auth;
if (grunt.file.exists(path)) {
auth = grunt.file.read(path).trim().split(/\s/);
if (auth.length === 2 && auth[0].indexOf('@') !== -1) {
return {email: auth[0], password: auth[1]};
}
}
return null;
... | [
"function",
"readAuth",
"(",
"path",
")",
"{",
"var",
"auth",
";",
"if",
"(",
"grunt",
".",
"file",
".",
"exists",
"(",
"path",
")",
")",
"{",
"auth",
"=",
"grunt",
".",
"file",
".",
"read",
"(",
"path",
")",
".",
"trim",
"(",
")",
".",
"split"... | Reads authentication file.
@param path
@returns {null} | [
"Reads",
"authentication",
"file",
"."
] | 69371677a5c136981fb6f8618c2f9bb1cf6628f5 | https://github.com/maciejzasada/grunt-gae/blob/69371677a5c136981fb6f8618c2f9bb1cf6628f5/tasks/gae.js#L37-L46 | train |
maciejzasada/grunt-gae | tasks/gae.js | run | function run(command, auth, options, async, done, msgSuccess, msgSuccessAsync, msgFailure) {
var args,
flags,
field,
i,
childProcess;
// Pass auth.
command = command.replace('{auth}', auth ? format('--email=%s --passin ', auth.email) : '');
... | javascript | function run(command, auth, options, async, done, msgSuccess, msgSuccessAsync, msgFailure) {
var args,
flags,
field,
i,
childProcess;
// Pass auth.
command = command.replace('{auth}', auth ? format('--email=%s --passin ', auth.email) : '');
... | [
"function",
"run",
"(",
"command",
",",
"auth",
",",
"options",
",",
"async",
",",
"done",
",",
"msgSuccess",
",",
"msgSuccessAsync",
",",
"msgFailure",
")",
"{",
"var",
"args",
",",
"flags",
",",
"field",
",",
"i",
",",
"childProcess",
";",
"// Pass aut... | Runs GAE command.
@param command
@param auth
@param options
@param async
@param done
@param msgSuccess
@param msgSuccessAsync
@param msgFailure | [
"Runs",
"GAE",
"command",
"."
] | 69371677a5c136981fb6f8618c2f9bb1cf6628f5 | https://github.com/maciejzasada/grunt-gae/blob/69371677a5c136981fb6f8618c2f9bb1cf6628f5/tasks/gae.js#L59-L136 | train |
viRingbells/easy-babel | lib/depends.js | depends | function depends (targets) {
debug('Depends: start parse dependencies');
targets = prepare.targets(targets).filter(directories);
debug('Depends: target : ' + targets);
targets.forEach(parse_node_module);
} | javascript | function depends (targets) {
debug('Depends: start parse dependencies');
targets = prepare.targets(targets).filter(directories);
debug('Depends: target : ' + targets);
targets.forEach(parse_node_module);
} | [
"function",
"depends",
"(",
"targets",
")",
"{",
"debug",
"(",
"'Depends: start parse dependencies'",
")",
";",
"targets",
"=",
"prepare",
".",
"targets",
"(",
"targets",
")",
".",
"filter",
"(",
"directories",
")",
";",
"debug",
"(",
"'Depends: target : '",
"... | Parse all dependencies | [
"Parse",
"all",
"dependencies"
] | 2cb332affc404304cfb01924aaefeac864c002bc | https://github.com/viRingbells/easy-babel/blob/2cb332affc404304cfb01924aaefeac864c002bc/lib/depends.js#L19-L24 | train |
alexindigo/executioner | lib/terminate.js | terminate | function terminate(control)
{
if (control && control._process && typeof control._process.kill == 'function')
{
control._process._executioner_killRequested = true;
control._process.kill();
return true;
}
return false;
} | javascript | function terminate(control)
{
if (control && control._process && typeof control._process.kill == 'function')
{
control._process._executioner_killRequested = true;
control._process.kill();
return true;
}
return false;
} | [
"function",
"terminate",
"(",
"control",
")",
"{",
"if",
"(",
"control",
"&&",
"control",
".",
"_process",
"&&",
"typeof",
"control",
".",
"_process",
".",
"kill",
"==",
"'function'",
")",
"{",
"control",
".",
"_process",
".",
"_executioner_killRequested",
"... | Terminates currently executed job,
if available
@param {object} control - job control with reference to the executed process
@returns {boolean} - true if there was a process to terminate, false otherwise | [
"Terminates",
"currently",
"executed",
"job",
"if",
"available"
] | 582f92897f47c13f4531e0b692aebb4a9f134eec | https://github.com/alexindigo/executioner/blob/582f92897f47c13f4531e0b692aebb4a9f134eec/lib/terminate.js#L11-L21 | train |
TMiguelT/node-mtg-json | index.js | getMtgJson | function getMtgJson(type, directory, opts) {
//Setup input and output URIs
const outFileName = getJsonFilename(type, opts);
const url = `${BASE_URL}/${outFileName}`;
const output = path.resolve(`${directory}/${outFileName}`);
const outputStream = fs.createWriteStream(output);
//Return a file pa... | javascript | function getMtgJson(type, directory, opts) {
//Setup input and output URIs
const outFileName = getJsonFilename(type, opts);
const url = `${BASE_URL}/${outFileName}`;
const output = path.resolve(`${directory}/${outFileName}`);
const outputStream = fs.createWriteStream(output);
//Return a file pa... | [
"function",
"getMtgJson",
"(",
"type",
",",
"directory",
",",
"opts",
")",
"{",
"//Setup input and output URIs",
"const",
"outFileName",
"=",
"getJsonFilename",
"(",
"type",
",",
"opts",
")",
";",
"const",
"url",
"=",
"`",
"${",
"BASE_URL",
"}",
"${",
"outFi... | Returns a promise of an MtG Json file
@param type Either 'sets' or 'cards' - the type of file to download.
@param directory The location to put the new json file (the filename is decided by the request)
@param opts An object with the keys {extras : bool, zip : bool, returnFile: bool} | [
"Returns",
"a",
"promise",
"of",
"an",
"MtG",
"Json",
"file"
] | f1e292c42b4d685a8acd05b2d80a6da59321b484 | https://github.com/TMiguelT/node-mtg-json/blob/f1e292c42b4d685a8acd05b2d80a6da59321b484/index.js#L23-L59 | train |
AirDwing/airx-proto | dist/message.js | Data | function Data(properties) {
this.custom = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function Data(properties) {
this.custom = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"Data",
"(",
"properties",
")",
"{",
"this",
".",
"custom",
"=",
"[",
"]",
";",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
... | Properties of a Data.
@exports IData
@interface IData
@property {IGateway} [gateway] Data gateway
@property {IAttitude} [attitude] Data attitude
@property {IBattery} [battery] Data battery
@property {IBattery} [battery_controller] Data battery_controller
@property {IDronestatus} [dronestatus] Data dronestatus
@property... | [
"Properties",
"of",
"a",
"Data",
"."
] | 028223a4c34e7ff078032da28532371052d0fa3b | https://github.com/AirDwing/airx-proto/blob/028223a4c34e7ff078032da28532371052d0fa3b/dist/message.js#L279-L285 | train |
AirDwing/airx-proto | dist/message.js | Custom | function Custom(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function Custom(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"Custom",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"if",
... | Properties of a Custom.
@exports ICustom
@interface ICustom
@property {string} [key] Custom key
@property {google.protobuf.IAny} [val] Custom val
Constructs a new Custom.
@exports Custom
@classdesc Represents a Custom.
@constructor
@param {ICustom=} [properties] Properties to set | [
"Properties",
"of",
"a",
"Custom",
"."
] | 028223a4c34e7ff078032da28532371052d0fa3b | https://github.com/AirDwing/airx-proto/blob/028223a4c34e7ff078032da28532371052d0fa3b/dist/message.js#L749-L754 | train |
AirDwing/airx-proto | dist/message.js | Gateway | function Gateway(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function Gateway(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"Gateway",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"if",
... | Properties of a Gateway.
@exports IGateway
@interface IGateway
@property {string} [name] Gateway name
Constructs a new Gateway.
@exports Gateway
@classdesc Represents a Gateway.
@constructor
@param {IGateway=} [properties] Properties to set | [
"Properties",
"of",
"a",
"Gateway",
"."
] | 028223a4c34e7ff078032da28532371052d0fa3b | https://github.com/AirDwing/airx-proto/blob/028223a4c34e7ff078032da28532371052d0fa3b/dist/message.js#L1421-L1426 | train |
AirDwing/airx-proto | dist/message.js | Attitude | function Attitude(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function Attitude(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"Attitude",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"if",... | Properties of an Attitude.
@exports IAttitude
@interface IAttitude
@property {number} [pitch] 俯仰
desc: 俯仰角,绕x轴,对应欧拉角γ。抬头为正
unit: °
range: [-180, 180]
@property {number} [roll] 横滚
desc: 翻滚角,绕z轴,对应欧拉角β。右滚为正
unit: °
range: [-180, 180]
@property {number} [yaw] 偏航
desc: 方向/航向角,绕y轴,对应欧拉角α。0为指向真北,顺时针旋转增加数值
unit: °
range: [-18... | [
"Properties",
"of",
"an",
"Attitude",
"."
] | 028223a4c34e7ff078032da28532371052d0fa3b | https://github.com/AirDwing/airx-proto/blob/028223a4c34e7ff078032da28532371052d0fa3b/dist/message.js#L1618-L1623 | train |
AirDwing/airx-proto | dist/message.js | Battery | function Battery(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function Battery(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"Battery",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"if",
... | Properties of a Battery.
@exports IBattery
@interface IBattery
@property {number} [percent] 电量
desc: 电量百分比
unit: %
range: [0, 100]
@property {boolean} [charging] 正在充电
desc: 是否正在充电
@property {number} [voltage] 电压
desc: 电池组总电压
unit: mV
range: [0, +∞)
@property {number} [current] 电流
desc: 正为放电,负为充电
unit: mA
@property {num... | [
"Properties",
"of",
"a",
"Battery",
"."
] | 028223a4c34e7ff078032da28532371052d0fa3b | https://github.com/AirDwing/airx-proto/blob/028223a4c34e7ff078032da28532371052d0fa3b/dist/message.js#L1871-L1876 | train |
AirDwing/airx-proto | dist/message.js | Dronestatus | function Dronestatus(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function Dronestatus(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"Dronestatus",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"i... | Properties of a Dronestatus.
@exports IDronestatus
@interface IDronestatus
@property {boolean} [motors] 电机状态
desc: 电机是否启动
@property {boolean} [flying] 飞行状态
desc: 是否正在飞行
Constructs a new Dronestatus.
@exports Dronestatus
@classdesc Represents a Dronestatus.
@constructor
@param {IDronestatus=} [properties] Properties t... | [
"Properties",
"of",
"a",
"Dronestatus",
"."
] | 028223a4c34e7ff078032da28532371052d0fa3b | https://github.com/AirDwing/airx-proto/blob/028223a4c34e7ff078032da28532371052d0fa3b/dist/message.js#L2156-L2161 | train |
AirDwing/airx-proto | dist/message.js | GNSS | function GNSS(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function GNSS(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"GNSS",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"if",
"... | Properties of a GNSS.
@exports IGNSS
@interface IGNSS
@property {number} [satellite] 卫星数
desc: 3颗:2D定位,4颗:3D定位
range: [0, 65535]
@property {number} [latitude] 纬度
desc: 纬度,十进制,北纬为正,南纬为负
unit: °
range: [-90, 90]
@property {number} [longitude] 经度
desc: 经度,十进制,东经为正,西经为负
unit: °
range: [-90, 90]
@property {number} [amsl] 海拔... | [
"Properties",
"of",
"a",
"GNSS",
"."
] | 028223a4c34e7ff078032da28532371052d0fa3b | https://github.com/AirDwing/airx-proto/blob/028223a4c34e7ff078032da28532371052d0fa3b/dist/message.js#L2386-L2391 | train |
AirDwing/airx-proto | dist/message.js | Signal | function Signal(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function Signal(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"Signal",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"if",
... | Properties of a Signal.
@exports ISignal
@interface ISignal
@property {number} [percent] 信号强度
desc: 信号强度百分比
unit: %
range: [0, 100]
@property {Signal.Type} [type] 类型
desc: 连接方式类型
range: [ UNDEFINED, OTHER, TELE2G, TELE3G, TELE4G, TELE5G, BAND24GHZ, BAND58GHZ]
@property {string} [protocal] 协议
desc: 链路协议,大多数情况下仅当选择具体频率或O... | [
"Properties",
"of",
"a",
"Signal",
"."
] | 028223a4c34e7ff078032da28532371052d0fa3b | https://github.com/AirDwing/airx-proto/blob/028223a4c34e7ff078032da28532371052d0fa3b/dist/message.js#L2731-L2736 | train |
AirDwing/airx-proto | dist/message.js | Velocity | function Velocity(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function Velocity(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"Velocity",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"if",... | Properties of a Velocity.
@exports IVelocity
@interface IVelocity
@property {number} [x] x速度
desc: 载具在x方向上的速度,使用N-E-D (North-East-Down),以米为单位
unit: m
@property {number} [y] y速度
desc: 载具在y方向上的速度,使用N-E-D (North-East-Down),以米为单位
unit: m
@property {number} [z] z速度
desc: 载具在z方向上的速度,使用N-E-D (North-East-Down),以米为单位
unit: m
@p... | [
"Properties",
"of",
"a",
"Velocity",
"."
] | 028223a4c34e7ff078032da28532371052d0fa3b | https://github.com/AirDwing/airx-proto/blob/028223a4c34e7ff078032da28532371052d0fa3b/dist/message.js#L3078-L3083 | train |
AirDwing/airx-proto | dist/message.js | Atmosphere | function Atmosphere(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function Atmosphere(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"Atmosphere",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"if... | Properties of an Atmosphere.
@exports IAtmosphere
@interface IAtmosphere
@property {number} [pm25] PM2.5
desc: PM2.5浓度
range: [0, +∞)
@property {number} [co] 一氧化碳
desc: 一氧化碳浓度
range: [0, +∞)
@property {number} [so2] 二氧化硫
desc: 二氧化硫浓度
range: [0, +∞)
@property {number} [no2] 二氧化氮
desc: 二氧化氮浓度
range: [0, +∞)
@property {nu... | [
"Properties",
"of",
"an",
"Atmosphere",
"."
] | 028223a4c34e7ff078032da28532371052d0fa3b | https://github.com/AirDwing/airx-proto/blob/028223a4c34e7ff078032da28532371052d0fa3b/dist/message.js#L3359-L3364 | train |
kuno/neco | deps/npm/lib/utils/relativize.js | relativize | function relativize (dest, src) {
// both of these are absolute paths.
// find the shortest relative distance.
src = src.split("/")
var abs = dest
dest = dest.split("/")
var i = 0
while (src[i] === dest[i]) i++
if (i === 1) return abs // nothing in common, leave absolute
src.splice(0, i + 1)
var dot... | javascript | function relativize (dest, src) {
// both of these are absolute paths.
// find the shortest relative distance.
src = src.split("/")
var abs = dest
dest = dest.split("/")
var i = 0
while (src[i] === dest[i]) i++
if (i === 1) return abs // nothing in common, leave absolute
src.splice(0, i + 1)
var dot... | [
"function",
"relativize",
"(",
"dest",
",",
"src",
")",
"{",
"// both of these are absolute paths.",
"// find the shortest relative distance.",
"src",
"=",
"src",
".",
"split",
"(",
"\"/\"",
")",
"var",
"abs",
"=",
"dest",
"dest",
"=",
"dest",
".",
"split",
"(",... | return the shortest path between two folders. | [
"return",
"the",
"shortest",
"path",
"between",
"two",
"folders",
"."
] | cf6361c1fcb9466c6b2ab3b127b5d0160ca50735 | https://github.com/kuno/neco/blob/cf6361c1fcb9466c6b2ab3b127b5d0160ca50735/deps/npm/lib/utils/relativize.js#L5-L20 | train |
observing/fossa | index.js | configure | function configure(obj, fossa) {
function get(key, backup) {
return key in obj ? obj[key] : backup;
}
//
// Allow new options to be be merged in against the original object.
//
get.merge = function merge(properties) {
return fossa.merge(obj, properties);
};
return get;
} | javascript | function configure(obj, fossa) {
function get(key, backup) {
return key in obj ? obj[key] : backup;
}
//
// Allow new options to be be merged in against the original object.
//
get.merge = function merge(properties) {
return fossa.merge(obj, properties);
};
return get;
} | [
"function",
"configure",
"(",
"obj",
",",
"fossa",
")",
"{",
"function",
"get",
"(",
"key",
",",
"backup",
")",
"{",
"return",
"key",
"in",
"obj",
"?",
"obj",
"[",
"key",
"]",
":",
"backup",
";",
"}",
"//",
"// Allow new options to be be merged in against ... | Queryable options with merge and fallback functionality.
@param {Object} obj
@param {Fossa} fossa instance
@returns {Function}
@api private | [
"Queryable",
"options",
"with",
"merge",
"and",
"fallback",
"functionality",
"."
] | 29b3717ee10a13fb607f5bbddcb8b003faf008c6 | https://github.com/observing/fossa/blob/29b3717ee10a13fb607f5bbddcb8b003faf008c6/index.js#L25-L38 | train |
observing/fossa | index.js | Fossa | function Fossa(options) {
this.fuse();
//
// Store the options.
//
this.writable('queue', []);
this.writable('plugins', {});
this.writable('connecting', false);
this.readable('options', configure(options || {}, this));
//
// Prepare a default model and collection sprinkled with MongoDB proxy metho... | javascript | function Fossa(options) {
this.fuse();
//
// Store the options.
//
this.writable('queue', []);
this.writable('plugins', {});
this.writable('connecting', false);
this.readable('options', configure(options || {}, this));
//
// Prepare a default model and collection sprinkled with MongoDB proxy metho... | [
"function",
"Fossa",
"(",
"options",
")",
"{",
"this",
".",
"fuse",
"(",
")",
";",
"//",
"// Store the options.",
"//",
"this",
".",
"writable",
"(",
"'queue'",
",",
"[",
"]",
")",
";",
"this",
".",
"writable",
"(",
"'plugins'",
",",
"{",
"}",
")",
... | Constructor of Fossa.
@Constructor
@param {Object} options
@api public | [
"Constructor",
"of",
"Fossa",
"."
] | 29b3717ee10a13fb607f5bbddcb8b003faf008c6 | https://github.com/observing/fossa/blob/29b3717ee10a13fb607f5bbddcb8b003faf008c6/index.js#L47-L77 | train |
alikhil/zaes-js | src/aes.js | expandKey | function expandKey(key) {
let tempWord = new Array(WORD_LENGTH);
let rounds = getRoundsCount(key);
let wordsCount = key.length / WORD_LENGTH;
let keySchedule = new Array(COLUMNS * (rounds + 1));
for (let i = 0; i < wordsCount; i++) {
keySchedule[i] = key.slice(WORD_LENGTH * i, WORD_LENGTH * i + WORD_LENGTH);
... | javascript | function expandKey(key) {
let tempWord = new Array(WORD_LENGTH);
let rounds = getRoundsCount(key);
let wordsCount = key.length / WORD_LENGTH;
let keySchedule = new Array(COLUMNS * (rounds + 1));
for (let i = 0; i < wordsCount; i++) {
keySchedule[i] = key.slice(WORD_LENGTH * i, WORD_LENGTH * i + WORD_LENGTH);
... | [
"function",
"expandKey",
"(",
"key",
")",
"{",
"let",
"tempWord",
"=",
"new",
"Array",
"(",
"WORD_LENGTH",
")",
";",
"let",
"rounds",
"=",
"getRoundsCount",
"(",
"key",
")",
";",
"let",
"wordsCount",
"=",
"key",
".",
"length",
"/",
"WORD_LENGTH",
";",
... | Generates keys for each round | [
"Generates",
"keys",
"for",
"each",
"round"
] | 5887597a14d81b0ced3439f4ad1fd9457dc8a1c9 | https://github.com/alikhil/zaes-js/blob/5887597a14d81b0ced3439f4ad1fd9457dc8a1c9/src/aes.js#L70-L89 | train |
alikhil/zaes-js | src/aes.js | encryptBlock | function encryptBlock(block, keySchedule) {
let state = splitToMatrix(block);
state = a_u.addRoundKey(state, keySchedule.slice(0, 4));
let rounds = keySchedule.length / COLUMNS;
for (let round = 1; round < rounds; round++){
state = a_u.subBytes(state);
state = a_u.shiftRows(state);
state = a_u.mixColumns(sta... | javascript | function encryptBlock(block, keySchedule) {
let state = splitToMatrix(block);
state = a_u.addRoundKey(state, keySchedule.slice(0, 4));
let rounds = keySchedule.length / COLUMNS;
for (let round = 1; round < rounds; round++){
state = a_u.subBytes(state);
state = a_u.shiftRows(state);
state = a_u.mixColumns(sta... | [
"function",
"encryptBlock",
"(",
"block",
",",
"keySchedule",
")",
"{",
"let",
"state",
"=",
"splitToMatrix",
"(",
"block",
")",
";",
"state",
"=",
"a_u",
".",
"addRoundKey",
"(",
"state",
",",
"keySchedule",
".",
"slice",
"(",
"0",
",",
"4",
")",
")",... | Encrypts given block | [
"Encrypts",
"given",
"block"
] | 5887597a14d81b0ced3439f4ad1fd9457dc8a1c9 | https://github.com/alikhil/zaes-js/blob/5887597a14d81b0ced3439f4ad1fd9457dc8a1c9/src/aes.js#L108-L124 | train |
terryweiss/grunt-bundles | tasks/bundles.js | function ( taskName ) {
var task = grunt.config.get( "bundles" )[taskName];
var retVal = [];
if ( task ) {
var sources = task.modules;
if ( !sys.isEmpty( sources ) && !sys.isEmpty( sources.src ) ) {
grunt.log.writeln( "Adding sources for " + taskName );
retVal = sys.map( grunt.file.expand( so... | javascript | function ( taskName ) {
var task = grunt.config.get( "bundles" )[taskName];
var retVal = [];
if ( task ) {
var sources = task.modules;
if ( !sys.isEmpty( sources ) && !sys.isEmpty( sources.src ) ) {
grunt.log.writeln( "Adding sources for " + taskName );
retVal = sys.map( grunt.file.expand( so... | [
"function",
"(",
"taskName",
")",
"{",
"var",
"task",
"=",
"grunt",
".",
"config",
".",
"get",
"(",
"\"bundles\"",
")",
"[",
"taskName",
"]",
";",
"var",
"retVal",
"=",
"[",
"]",
";",
"if",
"(",
"task",
")",
"{",
"var",
"sources",
"=",
"task",
".... | find another task's entries | [
"find",
"another",
"task",
"s",
"entries"
] | 33133118e99ff9f42ad17023561f5c268a7307cd | https://github.com/terryweiss/grunt-bundles/blob/33133118e99ff9f42ad17023561f5c268a7307cd/tasks/bundles.js#L46-L59 | train | |
terryweiss/grunt-bundles | tasks/bundles.js | function ( file ) {
var resolved;
var expanded = grunt.file.expand( file )[0];
if ( !expanded ) {
resolved = require.resolve( file );
} else {
resolved = "./" + expanded;
}
return resolved;
} | javascript | function ( file ) {
var resolved;
var expanded = grunt.file.expand( file )[0];
if ( !expanded ) {
resolved = require.resolve( file );
} else {
resolved = "./" + expanded;
}
return resolved;
} | [
"function",
"(",
"file",
")",
"{",
"var",
"resolved",
";",
"var",
"expanded",
"=",
"grunt",
".",
"file",
".",
"expand",
"(",
"file",
")",
"[",
"0",
"]",
";",
"if",
"(",
"!",
"expanded",
")",
"{",
"resolved",
"=",
"require",
".",
"resolve",
"(",
"... | Resolve modules paths | [
"Resolve",
"modules",
"paths"
] | 33133118e99ff9f42ad17023561f5c268a7307cd | https://github.com/terryweiss/grunt-bundles/blob/33133118e99ff9f42ad17023561f5c268a7307cd/tasks/bundles.js#L62-L74 | train | |
terryweiss/grunt-bundles | tasks/bundles.js | function ( pkg ) {
grunt.verbose.writeln( "Populating compiler" );
var copts = {
noParse : pkg.noParse,
entries : pkg.modules,
externalRequireName : options.externalRequireName,
pack : options.pack,
bundleExternal : options.bundleExternal,
// buil... | javascript | function ( pkg ) {
grunt.verbose.writeln( "Populating compiler" );
var copts = {
noParse : pkg.noParse,
entries : pkg.modules,
externalRequireName : options.externalRequireName,
pack : options.pack,
bundleExternal : options.bundleExternal,
// buil... | [
"function",
"(",
"pkg",
")",
"{",
"grunt",
".",
"verbose",
".",
"writeln",
"(",
"\"Populating compiler\"",
")",
";",
"var",
"copts",
"=",
"{",
"noParse",
":",
"pkg",
".",
"noParse",
",",
"entries",
":",
"pkg",
".",
"modules",
",",
"externalRequireName",
... | Create the browserify instance and prep it | [
"Create",
"the",
"browserify",
"instance",
"and",
"prep",
"it"
] | 33133118e99ff9f42ad17023561f5c268a7307cd | https://github.com/terryweiss/grunt-bundles/blob/33133118e99ff9f42ad17023561f5c268a7307cd/tasks/bundles.js#L217-L259 | train | |
terryweiss/grunt-bundles | tasks/bundles.js | function ( pkg, compiler ) {
if ( !sys.isEmpty( task.data.depends ) && options.resolveAliases && !sys.isEmpty( pkg.dependAliases ) ) {
compiler.transform( function ( file ) {
grunt.verbose.writeln( "Transforming " + file );
function write( buf ) {
data += buf;
}
var data = '';
r... | javascript | function ( pkg, compiler ) {
if ( !sys.isEmpty( task.data.depends ) && options.resolveAliases && !sys.isEmpty( pkg.dependAliases ) ) {
compiler.transform( function ( file ) {
grunt.verbose.writeln( "Transforming " + file );
function write( buf ) {
data += buf;
}
var data = '';
r... | [
"function",
"(",
"pkg",
",",
"compiler",
")",
"{",
"if",
"(",
"!",
"sys",
".",
"isEmpty",
"(",
"task",
".",
"data",
".",
"depends",
")",
"&&",
"options",
".",
"resolveAliases",
"&&",
"!",
"sys",
".",
"isEmpty",
"(",
"pkg",
".",
"dependAliases",
")",
... | transform dependencies while browserify runs | [
"transform",
"dependencies",
"while",
"browserify",
"runs"
] | 33133118e99ff9f42ad17023561f5c268a7307cd | https://github.com/terryweiss/grunt-bundles/blob/33133118e99ff9f42ad17023561f5c268a7307cd/tasks/bundles.js#L262-L295 | train | |
bholloway/browserify-debug-tools | lib/dump-to-file.js | dumpToFile | function dumpToFile(extension, regex) {
return inspect(onComplete);
function onComplete(filename, contents, done) {
if (!regex || regex.test(filename)) {
var newName = [filename, extension || 'gen'].join('.');
fs.writeFile(newName, contents, done);
} else {
done();
}
}
} | javascript | function dumpToFile(extension, regex) {
return inspect(onComplete);
function onComplete(filename, contents, done) {
if (!regex || regex.test(filename)) {
var newName = [filename, extension || 'gen'].join('.');
fs.writeFile(newName, contents, done);
} else {
done();
}
}
} | [
"function",
"dumpToFile",
"(",
"extension",
",",
"regex",
")",
"{",
"return",
"inspect",
"(",
"onComplete",
")",
";",
"function",
"onComplete",
"(",
"filename",
",",
"contents",
",",
"done",
")",
"{",
"if",
"(",
"!",
"regex",
"||",
"regex",
".",
"test",
... | Transform that writes out the current state of the transformed file next to the original source file.
Particularly helpful for source map visualisation.
@see http://sokra.github.io/source-map-visualization
@param {string} [extension] An optionalextention to append to the file (defaults to 'gen' meaning generated)
@para... | [
"Transform",
"that",
"writes",
"out",
"the",
"current",
"state",
"of",
"the",
"transformed",
"file",
"next",
"to",
"the",
"original",
"source",
"file",
".",
"Particularly",
"helpful",
"for",
"source",
"map",
"visualisation",
"."
] | 47aa05164d73ec7512bdd4a18db0e12fa6b96209 | https://github.com/bholloway/browserify-debug-tools/blob/47aa05164d73ec7512bdd4a18db0e12fa6b96209/lib/dump-to-file.js#L14-L25 | train |
tianjianchn/midd | packages/midd-session-mysql-store/src/index.js | dbName | function dbName(str) {
if (!str) return str;
str = str.replace(/[A-Z]/g, $0 => `_${$0.toLowerCase()}`);
if (str[0] === '_') return str.slice(1);
return str;
} | javascript | function dbName(str) {
if (!str) return str;
str = str.replace(/[A-Z]/g, $0 => `_${$0.toLowerCase()}`);
if (str[0] === '_') return str.slice(1);
return str;
} | [
"function",
"dbName",
"(",
"str",
")",
"{",
"if",
"(",
"!",
"str",
")",
"return",
"str",
";",
"str",
"=",
"str",
".",
"replace",
"(",
"/",
"[A-Z]",
"/",
"g",
",",
"$0",
"=>",
"`",
"${",
"$0",
".",
"toLowerCase",
"(",
")",
"}",
"`",
")",
";",
... | convert the string to a underline-delimited string which will used in database | [
"convert",
"the",
"string",
"to",
"a",
"underline",
"-",
"delimited",
"string",
"which",
"will",
"used",
"in",
"database"
] | 849f07f68c30335a68be5e1e2b709eb930a560d7 | https://github.com/tianjianchn/midd/blob/849f07f68c30335a68be5e1e2b709eb930a560d7/packages/midd-session-mysql-store/src/index.js#L115-L120 | train |
glayzzle/php-core | src/strings.js | function () {
bytes = str.substr(u, 45).split('')
for (i in bytes) {
bytes[i] = bytes[i].charCodeAt(0)
}
return bytes.length || 0
} | javascript | function () {
bytes = str.substr(u, 45).split('')
for (i in bytes) {
bytes[i] = bytes[i].charCodeAt(0)
}
return bytes.length || 0
} | [
"function",
"(",
")",
"{",
"bytes",
"=",
"str",
".",
"substr",
"(",
"u",
",",
"45",
")",
".",
"split",
"(",
"''",
")",
"for",
"(",
"i",
"in",
"bytes",
")",
"{",
"bytes",
"[",
"i",
"]",
"=",
"bytes",
"[",
"i",
"]",
".",
"charCodeAt",
"(",
"0... | divide string into chunks of 45 characters | [
"divide",
"string",
"into",
"chunks",
"of",
"45",
"characters"
] | 39b8e8f077d67517dbe8ae6dd52ad95e456f84cd | https://github.com/glayzzle/php-core/blob/39b8e8f077d67517dbe8ae6dd52ad95e456f84cd/src/strings.js#L2494-L2500 | train | |
scttnlsn/nettle | lib/store.js | function(result, callback) {
self.cache.put(result, function(err, doc) {
if (err) return callback(err);
callback(null, result, doc._id);
});
} | javascript | function(result, callback) {
self.cache.put(result, function(err, doc) {
if (err) return callback(err);
callback(null, result, doc._id);
});
} | [
"function",
"(",
"result",
",",
"callback",
")",
"{",
"self",
".",
"cache",
".",
"put",
"(",
"result",
",",
"function",
"(",
"err",
",",
"doc",
")",
"{",
"if",
"(",
"err",
")",
"return",
"callback",
"(",
"err",
")",
";",
"callback",
"(",
"null",
... | Cache the result | [
"Cache",
"the",
"result"
] | bfdb06b20f3b808e0b330f4d8235e40db24e48dd | https://github.com/scttnlsn/nettle/blob/bfdb06b20f3b808e0b330f4d8235e40db24e48dd/lib/store.js#L75-L80 | train | |
scttnlsn/nettle | lib/store.js | function(result, cached, callback) {
self.metacache.store(id, processor, cached, function(err) {
if (err) return callback(err);
callback(null, result);
});
} | javascript | function(result, cached, callback) {
self.metacache.store(id, processor, cached, function(err) {
if (err) return callback(err);
callback(null, result);
});
} | [
"function",
"(",
"result",
",",
"cached",
",",
"callback",
")",
"{",
"self",
".",
"metacache",
".",
"store",
"(",
"id",
",",
"processor",
",",
"cached",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"return",
"callback",
"(",
"err",
... | Update the metacache | [
"Update",
"the",
"metacache"
] | bfdb06b20f3b808e0b330f4d8235e40db24e48dd | https://github.com/scttnlsn/nettle/blob/bfdb06b20f3b808e0b330f4d8235e40db24e48dd/lib/store.js#L83-L88 | train | |
scttnlsn/nettle | lib/store.js | function(metacache, callback) {
var funcs = [];
for (var processor in metacache) {
if (processor !== '_id') {
var cached = metacache[processor];
funcs.push(function(callback) {
self.cache.del... | javascript | function(metacache, callback) {
var funcs = [];
for (var processor in metacache) {
if (processor !== '_id') {
var cached = metacache[processor];
funcs.push(function(callback) {
self.cache.del... | [
"function",
"(",
"metacache",
",",
"callback",
")",
"{",
"var",
"funcs",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"processor",
"in",
"metacache",
")",
"{",
"if",
"(",
"processor",
"!==",
"'_id'",
")",
"{",
"var",
"cached",
"=",
"metacache",
"[",
"proce... | Delete all cached entities | [
"Delete",
"all",
"cached",
"entities"
] | bfdb06b20f3b808e0b330f4d8235e40db24e48dd | https://github.com/scttnlsn/nettle/blob/bfdb06b20f3b808e0b330f4d8235e40db24e48dd/lib/store.js#L105-L118 | train | |
MartinKolarik/ractive-render | lib/rvc.js | load | function load(file, options) {
if (options.cache && rr.cache['rvc!' + file]) {
return Promise.resolve(rr.cache['rvc!' + file]);
}
return requireJSAsync(file).then(function (Component) {
// flush requireJS's cache
_.forEach(requireJS.s.contexts._.defined, function (value, key, array) {
if (key.substr(0, 4) ... | javascript | function load(file, options) {
if (options.cache && rr.cache['rvc!' + file]) {
return Promise.resolve(rr.cache['rvc!' + file]);
}
return requireJSAsync(file).then(function (Component) {
// flush requireJS's cache
_.forEach(requireJS.s.contexts._.defined, function (value, key, array) {
if (key.substr(0, 4) ... | [
"function",
"load",
"(",
"file",
",",
"options",
")",
"{",
"if",
"(",
"options",
".",
"cache",
"&&",
"rr",
".",
"cache",
"[",
"'rvc!'",
"+",
"file",
"]",
")",
"{",
"return",
"Promise",
".",
"resolve",
"(",
"rr",
".",
"cache",
"[",
"'rvc!'",
"+",
... | Create a component from the given file using RVC
@param {String} file
@param {Object} options
@returns {Promise}
@public | [
"Create",
"a",
"component",
"from",
"the",
"given",
"file",
"using",
"RVC"
] | 417a97c42de4b1ea6c1ab13803f5470b3cc6f75a | https://github.com/MartinKolarik/ractive-render/blob/417a97c42de4b1ea6c1ab13803f5470b3cc6f75a/lib/rvc.js#L31-L62 | train |
MartinKolarik/ractive-render | lib/rvc.js | requireJSAsync | function requireJSAsync (file) {
return new Promise(function (resolve, reject) {
requireJS([ 'rvc!' + requireJSPath(file, '.html') ], resolve, reject);
});
} | javascript | function requireJSAsync (file) {
return new Promise(function (resolve, reject) {
requireJS([ 'rvc!' + requireJSPath(file, '.html') ], resolve, reject);
});
} | [
"function",
"requireJSAsync",
"(",
"file",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"requireJS",
"(",
"[",
"'rvc!'",
"+",
"requireJSPath",
"(",
"file",
",",
"'.html'",
")",
"]",
",",
"resolve",
",",
... | Wrapper for requireJS
@param {String} file
@returns {Promise}
@private | [
"Wrapper",
"for",
"requireJS"
] | 417a97c42de4b1ea6c1ab13803f5470b3cc6f75a | https://github.com/MartinKolarik/ractive-render/blob/417a97c42de4b1ea6c1ab13803f5470b3cc6f75a/lib/rvc.js#L71-L75 | train |
MartinKolarik/ractive-render | lib/rvc.js | requireJSPath | function requireJSPath(file, extension) {
return path.join(path.dirname(file), path.basename(file, extension)).replace(/\\/g, '/');
} | javascript | function requireJSPath(file, extension) {
return path.join(path.dirname(file), path.basename(file, extension)).replace(/\\/g, '/');
} | [
"function",
"requireJSPath",
"(",
"file",
",",
"extension",
")",
"{",
"return",
"path",
".",
"join",
"(",
"path",
".",
"dirname",
"(",
"file",
")",
",",
"path",
".",
"basename",
"(",
"file",
",",
"extension",
")",
")",
".",
"replace",
"(",
"/",
"\\\\... | Get RequireJS path to the given file
@param {String} file
@param {String} [extension]
@returns {string}
@private | [
"Get",
"RequireJS",
"path",
"to",
"the",
"given",
"file"
] | 417a97c42de4b1ea6c1ab13803f5470b3cc6f75a | https://github.com/MartinKolarik/ractive-render/blob/417a97c42de4b1ea6c1ab13803f5470b3cc6f75a/lib/rvc.js#L85-L87 | train |
ceddl/ceddl-aditional-inputs | src/heatmap.js | DetectMouseUser | function DetectMouseUser(event) {
if(isMouseUser) {
// collection throttle interval.
setInterval(function() {
trackData = true;
}, 50);
return true;
}
let current = movement;
if(x && y){
movement = movement + Mat... | javascript | function DetectMouseUser(event) {
if(isMouseUser) {
// collection throttle interval.
setInterval(function() {
trackData = true;
}, 50);
return true;
}
let current = movement;
if(x && y){
movement = movement + Mat... | [
"function",
"DetectMouseUser",
"(",
"event",
")",
"{",
"if",
"(",
"isMouseUser",
")",
"{",
"// collection throttle interval.",
"setInterval",
"(",
"function",
"(",
")",
"{",
"trackData",
"=",
"true",
";",
"}",
",",
"50",
")",
";",
"return",
"true",
";",
"}... | Only use the mousemove data if the user
is actualy using a mouse. This can be hard
to detect. If you have a inproved sollution
please do not hesitate to contact
ceddl-polyfill team or create a pull
request. | [
"Only",
"use",
"the",
"mousemove",
"data",
"if",
"the",
"user",
"is",
"actualy",
"using",
"a",
"mouse",
".",
"This",
"can",
"be",
"hard",
"to",
"detect",
".",
"If",
"you",
"have",
"a",
"inproved",
"sollution",
"please",
"do",
"not",
"hesitate",
"to",
"... | 0e018d463107a0b631c317d7bf372aa9e194b7da | https://github.com/ceddl/ceddl-aditional-inputs/blob/0e018d463107a0b631c317d7bf372aa9e194b7da/src/heatmap.js#L27-L48 | train |
ceddl/ceddl-aditional-inputs | src/heatmap.js | startIdle | function startIdle() {
var idleCount = 0;
function idle() {
coordinates.push({
t: 1,
x: lastX,
y: lastY
});
idleCount++;
if (idleCount > 10) {
clearInterval(idleInterval);
}
... | javascript | function startIdle() {
var idleCount = 0;
function idle() {
coordinates.push({
t: 1,
x: lastX,
y: lastY
});
idleCount++;
if (idleCount > 10) {
clearInterval(idleInterval);
}
... | [
"function",
"startIdle",
"(",
")",
"{",
"var",
"idleCount",
"=",
"0",
";",
"function",
"idle",
"(",
")",
"{",
"coordinates",
".",
"push",
"(",
"{",
"t",
":",
"1",
",",
"x",
":",
"lastX",
",",
"y",
":",
"lastY",
"}",
")",
";",
"idleCount",
"++",
... | As the mouse stops moving the stream of events stop.
The user is deciding or reading text?! For 10 intervals
continue to add the position to the coordinates. | [
"As",
"the",
"mouse",
"stops",
"moving",
"the",
"stream",
"of",
"events",
"stop",
".",
"The",
"user",
"is",
"deciding",
"or",
"reading",
"text?!",
"For",
"10",
"intervals",
"continue",
"to",
"add",
"the",
"position",
"to",
"the",
"coordinates",
"."
] | 0e018d463107a0b631c317d7bf372aa9e194b7da | https://github.com/ceddl/ceddl-aditional-inputs/blob/0e018d463107a0b631c317d7bf372aa9e194b7da/src/heatmap.js#L55-L72 | train |
ceddl/ceddl-aditional-inputs | src/heatmap.js | emitHeatmapCoordinates | function emitHeatmapCoordinates() {
if(coordinates.length > 0) {
ceddl.emitEvent('heatmap:update', {
width: windowWidth,
coordinates: coordinates.splice(0, coordinates.length)
});
}
windowWidth = Math.round(parseInt(window.innerWidth, 10));... | javascript | function emitHeatmapCoordinates() {
if(coordinates.length > 0) {
ceddl.emitEvent('heatmap:update', {
width: windowWidth,
coordinates: coordinates.splice(0, coordinates.length)
});
}
windowWidth = Math.round(parseInt(window.innerWidth, 10));... | [
"function",
"emitHeatmapCoordinates",
"(",
")",
"{",
"if",
"(",
"coordinates",
".",
"length",
">",
"0",
")",
"{",
"ceddl",
".",
"emitEvent",
"(",
"'heatmap:update'",
",",
"{",
"width",
":",
"windowWidth",
",",
"coordinates",
":",
"coordinates",
".",
"splice"... | Send data to ceddl and clear the current coordinates. | [
"Send",
"data",
"to",
"ceddl",
"and",
"clear",
"the",
"current",
"coordinates",
"."
] | 0e018d463107a0b631c317d7bf372aa9e194b7da | https://github.com/ceddl/ceddl-aditional-inputs/blob/0e018d463107a0b631c317d7bf372aa9e194b7da/src/heatmap.js#L77-L85 | train |
ceddl/ceddl-aditional-inputs | src/heatmap.js | isClickTarget | function isClickTarget(element) {
return element.hasAttribute('ceddl-click') ||
(element.nodeType === 1 && element.tagName.toUpperCase() === 'BUTTON') ||
(element.nodeType === 1 && element.tagName.toUpperCase() === 'A');
} | javascript | function isClickTarget(element) {
return element.hasAttribute('ceddl-click') ||
(element.nodeType === 1 && element.tagName.toUpperCase() === 'BUTTON') ||
(element.nodeType === 1 && element.tagName.toUpperCase() === 'A');
} | [
"function",
"isClickTarget",
"(",
"element",
")",
"{",
"return",
"element",
".",
"hasAttribute",
"(",
"'ceddl-click'",
")",
"||",
"(",
"element",
".",
"nodeType",
"===",
"1",
"&&",
"element",
".",
"tagName",
".",
"toUpperCase",
"(",
")",
"===",
"'BUTTON'",
... | Determines if the element is a valid element to stop the delegation loop and
emit the coordinates dataset. | [
"Determines",
"if",
"the",
"element",
"is",
"a",
"valid",
"element",
"to",
"stop",
"the",
"delegation",
"loop",
"and",
"emit",
"the",
"coordinates",
"dataset",
"."
] | 0e018d463107a0b631c317d7bf372aa9e194b7da | https://github.com/ceddl/ceddl-aditional-inputs/blob/0e018d463107a0b631c317d7bf372aa9e194b7da/src/heatmap.js#L91-L95 | train |
ceddl/ceddl-aditional-inputs | src/heatmap.js | delegate | function delegate(callback, el) {
var currentElement = el;
do {
if (!isClickTarget(currentElement)) continue;
callback(currentElement);
return;
} while(currentElement.nodeName.toUpperCase() !== 'BODY' && (currentElement = currentElement.parentNode));
} | javascript | function delegate(callback, el) {
var currentElement = el;
do {
if (!isClickTarget(currentElement)) continue;
callback(currentElement);
return;
} while(currentElement.nodeName.toUpperCase() !== 'BODY' && (currentElement = currentElement.parentNode));
} | [
"function",
"delegate",
"(",
"callback",
",",
"el",
")",
"{",
"var",
"currentElement",
"=",
"el",
";",
"do",
"{",
"if",
"(",
"!",
"isClickTarget",
"(",
"currentElement",
")",
")",
"continue",
";",
"callback",
"(",
"currentElement",
")",
";",
"return",
";... | A deligation loop to find the clicked element and execute click callback
with that element. | [
"A",
"deligation",
"loop",
"to",
"find",
"the",
"clicked",
"element",
"and",
"execute",
"click",
"callback",
"with",
"that",
"element",
"."
] | 0e018d463107a0b631c317d7bf372aa9e194b7da | https://github.com/ceddl/ceddl-aditional-inputs/blob/0e018d463107a0b631c317d7bf372aa9e194b7da/src/heatmap.js#L101-L109 | train |
rmdort/react-kitt | src/components/ButtonGroup/index.js | ButtonGroup | function ButtonGroup({ children, className, ...rest }) {
const classes = cx(buttonGroupClassName, className)
return (
<div className={classes} {...rest}>
{children}
</div>
)
} | javascript | function ButtonGroup({ children, className, ...rest }) {
const classes = cx(buttonGroupClassName, className)
return (
<div className={classes} {...rest}>
{children}
</div>
)
} | [
"function",
"ButtonGroup",
"(",
"{",
"children",
",",
"className",
",",
"...",
"rest",
"}",
")",
"{",
"const",
"classes",
"=",
"cx",
"(",
"buttonGroupClassName",
",",
"className",
")",
"return",
"(",
"<",
"div",
"className",
"=",
"{",
"classes",
"}",
"{"... | Button groups arrange multiple buttons in a horizontal or vertical group. | [
"Button",
"groups",
"arrange",
"multiple",
"buttons",
"in",
"a",
"horizontal",
"or",
"vertical",
"group",
"."
] | a3dc0ef1451a84b8f7bed1f86dd0f3db26e8ff31 | https://github.com/rmdort/react-kitt/blob/a3dc0ef1451a84b8f7bed1f86dd0f3db26e8ff31/src/components/ButtonGroup/index.js#L10-L17 | train |
stefangordon/ethproof | dist/index.common.js | hashDocument | function hashDocument(document) {
var words;
if (Buffer.isBuffer(document)) {
words = Base64.parse(document.toString('base64'));
} else if (typeof document === 'string') {
words = Base64.parse(document);
} else {
throw new TypeError('Expected document to be Buffer or String');
}
var hash = sha... | javascript | function hashDocument(document) {
var words;
if (Buffer.isBuffer(document)) {
words = Base64.parse(document.toString('base64'));
} else if (typeof document === 'string') {
words = Base64.parse(document);
} else {
throw new TypeError('Expected document to be Buffer or String');
}
var hash = sha... | [
"function",
"hashDocument",
"(",
"document",
")",
"{",
"var",
"words",
";",
"if",
"(",
"Buffer",
".",
"isBuffer",
"(",
"document",
")",
")",
"{",
"words",
"=",
"Base64",
".",
"parse",
"(",
"document",
".",
"toString",
"(",
"'base64'",
")",
")",
";",
... | Generate hash of a document
@param {string|buffer} document - The document as a string or buffer
@return {string} Hex string representing hash | [
"Generate",
"hash",
"of",
"a",
"document"
] | 5c0711b242dfe587d30fd57389222af635cd1dce | https://github.com/stefangordon/ethproof/blob/5c0711b242dfe587d30fd57389222af635cd1dce/dist/index.common.js#L21-L35 | train |
stefangordon/ethproof | dist/index.common.js | publishProof | function publishProof(privateKeyHex, toAddress, hash, rpcUri) {
if (!EthereumUtil.isValidAddress(EthereumUtil.addHexPrefix(toAddress))) {
throw new Error('Invalid destination address.');
}
if (!rpcUri) {
rpcUri = localDefault;
}
var web3 = new Web3(
new Web3.providers.HttpProvider(rpcUri)
);
... | javascript | function publishProof(privateKeyHex, toAddress, hash, rpcUri) {
if (!EthereumUtil.isValidAddress(EthereumUtil.addHexPrefix(toAddress))) {
throw new Error('Invalid destination address.');
}
if (!rpcUri) {
rpcUri = localDefault;
}
var web3 = new Web3(
new Web3.providers.HttpProvider(rpcUri)
);
... | [
"function",
"publishProof",
"(",
"privateKeyHex",
",",
"toAddress",
",",
"hash",
",",
"rpcUri",
")",
"{",
"if",
"(",
"!",
"EthereumUtil",
".",
"isValidAddress",
"(",
"EthereumUtil",
".",
"addHexPrefix",
"(",
"toAddress",
")",
")",
")",
"{",
"throw",
"new",
... | Publishes a proof of existence to the Ethereum chain
@param {string} privateKeyHex - Private key as a hex string
@param {string} toAddress - Destination address
@param {string} hash - Hash as hex string
@param {string} rpcUri - Optional RPC Uri. Defaults to http://localhost:8545
@return {string} Hex string representin... | [
"Publishes",
"a",
"proof",
"of",
"existence",
"to",
"the",
"Ethereum",
"chain"
] | 5c0711b242dfe587d30fd57389222af635cd1dce | https://github.com/stefangordon/ethproof/blob/5c0711b242dfe587d30fd57389222af635cd1dce/dist/index.common.js#L45-L64 | train |
stefangordon/ethproof | dist/index.common.js | buildTransaction | function buildTransaction(privateKeyHex, toAddress, hash, web3) {
var privateKeyBuffer = Buffer.from(privateKeyHex, 'hex');
if (!EthereumUtil.isValidPrivate(privateKeyBuffer)) {
throw new Error('Invalid private key.');
}
var txParams = {
nonce: '0x00',
gasPrice: '0x09184e72a000', // How should we ... | javascript | function buildTransaction(privateKeyHex, toAddress, hash, web3) {
var privateKeyBuffer = Buffer.from(privateKeyHex, 'hex');
if (!EthereumUtil.isValidPrivate(privateKeyBuffer)) {
throw new Error('Invalid private key.');
}
var txParams = {
nonce: '0x00',
gasPrice: '0x09184e72a000', // How should we ... | [
"function",
"buildTransaction",
"(",
"privateKeyHex",
",",
"toAddress",
",",
"hash",
",",
"web3",
")",
"{",
"var",
"privateKeyBuffer",
"=",
"Buffer",
".",
"from",
"(",
"privateKeyHex",
",",
"'hex'",
")",
";",
"if",
"(",
"!",
"EthereumUtil",
".",
"isValidPriv... | Builds a signed transaction for transmitting,
primarily used internally. | [
"Builds",
"a",
"signed",
"transaction",
"for",
"transmitting",
"primarily",
"used",
"internally",
"."
] | 5c0711b242dfe587d30fd57389222af635cd1dce | https://github.com/stefangordon/ethproof/blob/5c0711b242dfe587d30fd57389222af635cd1dce/dist/index.common.js#L70-L101 | train |
rgeraldporter/ebird-histogramr | src/lib/csv.js | toCsvValue | function toCsvValue(theValue, sDelimiter) {
const t = typeof (theValue);
let output,
stringDelimiter
;
if (typeof (sDelimiter) === "undefined" || sDelimiter === null)
stringDelimiter = '"';
else
stringDelimiter = sDelimiter;
if (t === "undefined" || t === null)
... | javascript | function toCsvValue(theValue, sDelimiter) {
const t = typeof (theValue);
let output,
stringDelimiter
;
if (typeof (sDelimiter) === "undefined" || sDelimiter === null)
stringDelimiter = '"';
else
stringDelimiter = sDelimiter;
if (t === "undefined" || t === null)
... | [
"function",
"toCsvValue",
"(",
"theValue",
",",
"sDelimiter",
")",
"{",
"const",
"t",
"=",
"typeof",
"(",
"theValue",
")",
";",
"let",
"output",
",",
"stringDelimiter",
";",
"if",
"(",
"typeof",
"(",
"sDelimiter",
")",
"===",
"\"undefined\"",
"||",
"sDelim... | Converts a value to a string appropriate for entry into a CSV table. E.g., a string value will be surrounded by quotes.
@param {string|number|object} theValue
@param {string} sDelimiter The string delimiter. Defaults to a double quote (") if omitted. | [
"Converts",
"a",
"value",
"to",
"a",
"string",
"appropriate",
"for",
"entry",
"into",
"a",
"CSV",
"table",
".",
"E",
".",
"g",
".",
"a",
"string",
"value",
"will",
"be",
"surrounded",
"by",
"quotes",
"."
] | a8c47f3bf28fb21e8ced613c19168879deb55aef | https://github.com/rgeraldporter/ebird-histogramr/blob/a8c47f3bf28fb21e8ced613c19168879deb55aef/src/lib/csv.js#L6-L25 | train |
heroqu/node-content-store | index.js | taskMinus | function taskMinus() {
taskCounter--
if (taskCounter === 0) {
// Time to respond
if (files.length === 0) {
res.send(200, {
result: 'no files to upload',
files
})
} else {
res.send(201, {
result: 'upload OK',
... | javascript | function taskMinus() {
taskCounter--
if (taskCounter === 0) {
// Time to respond
if (files.length === 0) {
res.send(200, {
result: 'no files to upload',
files
})
} else {
res.send(201, {
result: 'upload OK',
... | [
"function",
"taskMinus",
"(",
")",
"{",
"taskCounter",
"--",
"if",
"(",
"taskCounter",
"===",
"0",
")",
"{",
"// Time to respond",
"if",
"(",
"files",
".",
"length",
"===",
"0",
")",
"{",
"res",
".",
"send",
"(",
"200",
",",
"{",
"result",
":",
"'no ... | call this one after any subtask is finished | [
"call",
"this",
"one",
"after",
"any",
"subtask",
"is",
"finished"
] | 0100814bfd988d60ad94cdf5a441eff328208a6a | https://github.com/heroqu/node-content-store/blob/0100814bfd988d60ad94cdf5a441eff328208a6a/index.js#L97-L114 | train |
thinkkoa/think_trace | index.js | function (tmr, timeout) {
return new Promise((resolve, reject) => {
/*eslint-disable no-return-assign */
return tmr = setTimeout(reject, timeout, httpError(408));
});
} | javascript | function (tmr, timeout) {
return new Promise((resolve, reject) => {
/*eslint-disable no-return-assign */
return tmr = setTimeout(reject, timeout, httpError(408));
});
} | [
"function",
"(",
"tmr",
",",
"timeout",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"/*eslint-disable no-return-assign */",
"return",
"tmr",
"=",
"setTimeout",
"(",
"reject",
",",
"timeout",
",",
"httpError",
"("... | http timeout timer
@param {any} tmr
@param {any} timeout
@returns | [
"http",
"timeout",
"timer"
] | b9b6838a7287281b3585995faf60e5531eab435e | https://github.com/thinkkoa/think_trace/blob/b9b6838a7287281b3585995faf60e5531eab435e/index.js#L60-L65 | train | |
owstack/ows-common | lib/util/js.js | defineImmutable | function defineImmutable(target, values) {
Object.keys(values).forEach(function(key){
Object.defineProperty(target, key, {
configurable: false,
enumerable: true,
value: values[key]
});
});
return target;
} | javascript | function defineImmutable(target, values) {
Object.keys(values).forEach(function(key){
Object.defineProperty(target, key, {
configurable: false,
enumerable: true,
value: values[key]
});
});
return target;
} | [
"function",
"defineImmutable",
"(",
"target",
",",
"values",
")",
"{",
"Object",
".",
"keys",
"(",
"values",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"Object",
".",
"defineProperty",
"(",
"target",
",",
"key",
",",
"{",
"configurable",... | Define immutable properties on a target object
@param {Object} target - An object to be extended
@param {Object} values - An object of properties
@return {Object} The target object | [
"Define",
"immutable",
"properties",
"on",
"a",
"target",
"object"
] | aa2a7970547cf451c06e528472ee965d3b4cac36 | https://github.com/owstack/ows-common/blob/aa2a7970547cf451c06e528472ee965d3b4cac36/lib/util/js.js#L62-L71 | train |
motionbank/piecemaker-api-client | src-js/api.js | function ( data ) {
if ( !data ) return data;
if ( typeof data !== 'object' ) return data;
if ( 'entrySet' in data && typeof data.entrySet === 'function' ) {
//var allowed_long_keys = ['utc_timestamp', 'duration', 'type', 'token'];
var set = data.entrySet();
if ( !set ) return dat... | javascript | function ( data ) {
if ( !data ) return data;
if ( typeof data !== 'object' ) return data;
if ( 'entrySet' in data && typeof data.entrySet === 'function' ) {
//var allowed_long_keys = ['utc_timestamp', 'duration', 'type', 'token'];
var set = data.entrySet();
if ( !set ) return dat... | [
"function",
"(",
"data",
")",
"{",
"if",
"(",
"!",
"data",
")",
"return",
"data",
";",
"if",
"(",
"typeof",
"data",
"!==",
"'object'",
")",
"return",
"data",
";",
"if",
"(",
"'entrySet'",
"in",
"data",
"&&",
"typeof",
"data",
".",
"entrySet",
"===",
... | Convert Processing.js HashMaps to JavaScript objects | [
"Convert",
"Processing",
".",
"js",
"HashMaps",
"to",
"JavaScript",
"objects"
] | 6d0a3ab7d603fa7e21303433d099aaa36b09f7c4 | https://github.com/motionbank/piecemaker-api-client/blob/6d0a3ab7d603fa7e21303433d099aaa36b09f7c4/src-js/api.js#L1238-L1265 | train | |
amida-tech/blue-button-pim | lib/evaluator.js | evaluate | function evaluate(score, at, mt) {
var automaticThreshold = at || 17.73;
var manualThreshold = mt || 15.957;
var result = "no match";
if (score >= automaticThreshold) {
result = "automatic";
} else if (score >= manualThreshold) {
result = "manual";
}
return result;
} | javascript | function evaluate(score, at, mt) {
var automaticThreshold = at || 17.73;
var manualThreshold = mt || 15.957;
var result = "no match";
if (score >= automaticThreshold) {
result = "automatic";
} else if (score >= manualThreshold) {
result = "manual";
}
return result;
} | [
"function",
"evaluate",
"(",
"score",
",",
"at",
",",
"mt",
")",
"{",
"var",
"automaticThreshold",
"=",
"at",
"||",
"17.73",
";",
"var",
"manualThreshold",
"=",
"mt",
"||",
"15.957",
";",
"var",
"result",
"=",
"\"no match\"",
";",
"if",
"(",
"score",
"... | evaluates matching score | [
"evaluates",
"matching",
"score"
] | 329dcc5fa5f3d877c2b675e8e0d689a8ef25a895 | https://github.com/amida-tech/blue-button-pim/blob/329dcc5fa5f3d877c2b675e8e0d689a8ef25a895/lib/evaluator.js#L4-L17 | train |
wzrdtales/seneca-mesh-ng | mesh.js | function(seneca, options, bases, next) {
var add = [];
var host = options.host;
if (0 === bases.length) {
if (null != host && host !== DEFAULT_HOST) {
add.push(host + ":" + DEFAULT_PORT);
}
add.push(DEFAULT_HOST + ":" + DEFAULT_PORT);
}
... | javascript | function(seneca, options, bases, next) {
var add = [];
var host = options.host;
if (0 === bases.length) {
if (null != host && host !== DEFAULT_HOST) {
add.push(host + ":" + DEFAULT_PORT);
}
add.push(DEFAULT_HOST + ":" + DEFAULT_PORT);
}
... | [
"function",
"(",
"seneca",
",",
"options",
",",
"bases",
",",
"next",
")",
"{",
"var",
"add",
"=",
"[",
"]",
";",
"var",
"host",
"=",
"options",
".",
"host",
";",
"if",
"(",
"0",
"===",
"bases",
".",
"length",
")",
"{",
"if",
"(",
"null",
"!=",... | order significant! depends on defined as uses bases.length | [
"order",
"significant!",
"depends",
"on",
"defined",
"as",
"uses",
"bases",
".",
"length"
] | 25ffc2a53b83bf9575086ce7b8c35d88c188e760 | https://github.com/wzrdtales/seneca-mesh-ng/blob/25ffc2a53b83bf9575086ce7b8c35d88c188e760/mesh.js#L522-L534 | train | |
kuno/neco | deps/npm/lib/utils/semver.js | maxSatisfying | function maxSatisfying (versions, range) {
return versions
.filter(function (v) { return satisfies(v, range) })
.sort(compare)
.pop()
} | javascript | function maxSatisfying (versions, range) {
return versions
.filter(function (v) { return satisfies(v, range) })
.sort(compare)
.pop()
} | [
"function",
"maxSatisfying",
"(",
"versions",
",",
"range",
")",
"{",
"return",
"versions",
".",
"filter",
"(",
"function",
"(",
"v",
")",
"{",
"return",
"satisfies",
"(",
"v",
",",
"range",
")",
"}",
")",
".",
"sort",
"(",
"compare",
")",
".",
"pop"... | returns the highest satisfying version in the list, or undefined | [
"returns",
"the",
"highest",
"satisfying",
"version",
"in",
"the",
"list",
"or",
"undefined"
] | cf6361c1fcb9466c6b2ab3b127b5d0160ca50735 | https://github.com/kuno/neco/blob/cf6361c1fcb9466c6b2ab3b127b5d0160ca50735/deps/npm/lib/utils/semver.js#L145-L150 | train |
mrmlnc/grunt-puglint | lib/formatter.js | function(item) {
// Drop newline symbol in error string
item.msg = (Array.isArray(item.msg) ? item.msg.join(' ') : item.msg).replace('\n', '');
// Using zero instead of undefined
item.column = (item.column === undefined) ? 0 : item.column;
// Drop `PUG:LINT_` prefix in error code
item.code = chalk.grey(item... | javascript | function(item) {
// Drop newline symbol in error string
item.msg = (Array.isArray(item.msg) ? item.msg.join(' ') : item.msg).replace('\n', '');
// Using zero instead of undefined
item.column = (item.column === undefined) ? 0 : item.column;
// Drop `PUG:LINT_` prefix in error code
item.code = chalk.grey(item... | [
"function",
"(",
"item",
")",
"{",
"// Drop newline symbol in error string",
"item",
".",
"msg",
"=",
"(",
"Array",
".",
"isArray",
"(",
"item",
".",
"msg",
")",
"?",
"item",
".",
"msg",
".",
"join",
"(",
"' '",
")",
":",
"item",
".",
"msg",
")",
"."... | Formatting string for the table
@param {Object} item | [
"Formatting",
"string",
"for",
"the",
"table"
] | cc890d96ea328f78302d9006f65c7a9c9083ebfd | https://github.com/mrmlnc/grunt-puglint/blob/cc890d96ea328f78302d9006f65c7a9c9083ebfd/lib/formatter.js#L13-L23 | train | |
jeanamarante/catena | tasks/dev/watch.js | readFile | function readFile (file) {
if (!isFileRegistered(file)) { return undefined; }
fileRegistry[file].content = gruntIsFile(file) ? gruntRead(file) + '\x0A' : '';
} | javascript | function readFile (file) {
if (!isFileRegistered(file)) { return undefined; }
fileRegistry[file].content = gruntIsFile(file) ? gruntRead(file) + '\x0A' : '';
} | [
"function",
"readFile",
"(",
"file",
")",
"{",
"if",
"(",
"!",
"isFileRegistered",
"(",
"file",
")",
")",
"{",
"return",
"undefined",
";",
"}",
"fileRegistry",
"[",
"file",
"]",
".",
"content",
"=",
"gruntIsFile",
"(",
"file",
")",
"?",
"gruntRead",
"(... | Read registered file's contents and store them into writeArray.
@function readFile
@param {String} file
@return {String}
@api private | [
"Read",
"registered",
"file",
"s",
"contents",
"and",
"store",
"them",
"into",
"writeArray",
"."
] | c7762332f71c0fd7cfafba8d1e3cd66053529954 | https://github.com/jeanamarante/catena/blob/c7762332f71c0fd7cfafba8d1e3cd66053529954/tasks/dev/watch.js#L57-L61 | 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.