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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
zlash/kwyjibo | js/controller.js | DocAction | function DocAction(docStr) {
return function (target, propertyKey, descriptor) {
let m = exports.globalKCState.getOrInsertController(target.constructor).getOrInsertMethod(propertyKey);
m.docString = docStr;
};
} | javascript | function DocAction(docStr) {
return function (target, propertyKey, descriptor) {
let m = exports.globalKCState.getOrInsertController(target.constructor).getOrInsertMethod(propertyKey);
m.docString = docStr;
};
} | [
"function",
"DocAction",
"(",
"docStr",
")",
"{",
"return",
"function",
"(",
"target",
",",
"propertyKey",
",",
"descriptor",
")",
"{",
"let",
"m",
"=",
"exports",
".",
"globalKCState",
".",
"getOrInsertController",
"(",
"target",
".",
"constructor",
")",
".... | Attach a documentation string to the method
@param {string} docStr - The documentation string. | [
"Attach",
"a",
"documentation",
"string",
"to",
"the",
"method"
] | 466da0e0445f04b48e0e0ff83ecaaa0554114c64 | https://github.com/zlash/kwyjibo/blob/466da0e0445f04b48e0e0ff83ecaaa0554114c64/js/controller.js#L262-L267 | train |
zlash/kwyjibo | js/controller.js | OpenApiResponse | function OpenApiResponse(httpCode, description, type) {
return function (target, propertyKey, descriptor) {
let m = exports.globalKCState.getOrInsertController(target.constructor).getOrInsertMethod(propertyKey);
httpCode = httpCode.toString();
m.openApiResponses[httpCode] = { description: de... | javascript | function OpenApiResponse(httpCode, description, type) {
return function (target, propertyKey, descriptor) {
let m = exports.globalKCState.getOrInsertController(target.constructor).getOrInsertMethod(propertyKey);
httpCode = httpCode.toString();
m.openApiResponses[httpCode] = { description: de... | [
"function",
"OpenApiResponse",
"(",
"httpCode",
",",
"description",
",",
"type",
")",
"{",
"return",
"function",
"(",
"target",
",",
"propertyKey",
",",
"descriptor",
")",
"{",
"let",
"m",
"=",
"exports",
".",
"globalKCState",
".",
"getOrInsertController",
"("... | Attach a OpenApi Response to the method
@param {number|string} httpCode - The http code used for the response
@param {string} description - Response description
@param {string} type - The Open Api defined type. | [
"Attach",
"a",
"OpenApi",
"Response",
"to",
"the",
"method"
] | 466da0e0445f04b48e0e0ff83ecaaa0554114c64 | https://github.com/zlash/kwyjibo/blob/466da0e0445f04b48e0e0ff83ecaaa0554114c64/js/controller.js#L275-L281 | train |
amobiz/json-normalizer | lib/normalize.js | async | function async(schema, values, optionalOptions, callbackFn) {
var options, callback;
options = optionalOptions || {};
callback = callbackFn || optionalOptions;
process.nextTick(_async);
function _async() {
deref(schema, options, function (err, derefSchema) {
var result;
if (err) {
callback(err);
... | javascript | function async(schema, values, optionalOptions, callbackFn) {
var options, callback;
options = optionalOptions || {};
callback = callbackFn || optionalOptions;
process.nextTick(_async);
function _async() {
deref(schema, options, function (err, derefSchema) {
var result;
if (err) {
callback(err);
... | [
"function",
"async",
"(",
"schema",
",",
"values",
",",
"optionalOptions",
",",
"callbackFn",
")",
"{",
"var",
"options",
",",
"callback",
";",
"options",
"=",
"optionalOptions",
"||",
"{",
"}",
";",
"callback",
"=",
"callbackFn",
"||",
"optionalOptions",
";... | Normalizes a loose json data object to a strict json-schema data object.
@context Don't care.
@param schema The schema used to normalize the given JSON data object.
@param data The JSON data object.
@param options Optional. Currently only accepts loader or array of loaders.
@param options.loader | options.loaders A lo... | [
"Normalizes",
"a",
"loose",
"json",
"data",
"object",
"to",
"a",
"strict",
"json",
"-",
"schema",
"data",
"object",
"."
] | 76a8ab1db2da4600dbd28c5c6c7fd11e43c0dd55 | https://github.com/amobiz/json-normalizer/blob/76a8ab1db2da4600dbd28c5c6c7fd11e43c0dd55/lib/normalize.js#L19-L38 | train |
kevva/squeak | index.js | Squeak | function Squeak(opts) {
if (!(this instanceof Squeak)) {
return new Squeak(opts);
}
EventEmitter.call(this);
this.opts = opts || {};
this.align = this.opts.align !== false;
this.indent = this.opts.indent || 2;
this.separator = this.opts.separator || ' : ';
this.stream = this.opts.stream || process.stderr ||... | javascript | function Squeak(opts) {
if (!(this instanceof Squeak)) {
return new Squeak(opts);
}
EventEmitter.call(this);
this.opts = opts || {};
this.align = this.opts.align !== false;
this.indent = this.opts.indent || 2;
this.separator = this.opts.separator || ' : ';
this.stream = this.opts.stream || process.stderr ||... | [
"function",
"Squeak",
"(",
"opts",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Squeak",
")",
")",
"{",
"return",
"new",
"Squeak",
"(",
"opts",
")",
";",
"}",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"opts",
"=",
... | Initialize a new `Squeak`
@param {Object} opts
@api public | [
"Initialize",
"a",
"new",
"Squeak"
] | 5fd68a6e256015bc2bed80a89047629fb6ebfd41 | https://github.com/kevva/squeak/blob/5fd68a6e256015bc2bed80a89047629fb6ebfd41/index.js#L16-L29 | train |
amida-tech/cms-fhir | lib/cmsTxtToIntObj.js | hook | function hook(cps, section) {
var i, len;
if (section["section header"] === "empty") {
if (section["data"]) {
// Guess it's a claim
len = section["data"].length;
for (i = 0; i < len; i++) {
if (section["data"][i]["claim number"]) {
... | javascript | function hook(cps, section) {
var i, len;
if (section["section header"] === "empty") {
if (section["data"]) {
// Guess it's a claim
len = section["data"].length;
for (i = 0; i < len; i++) {
if (section["data"][i]["claim number"]) {
... | [
"function",
"hook",
"(",
"cps",
",",
"section",
")",
"{",
"var",
"i",
",",
"len",
";",
"if",
"(",
"section",
"[",
"\"section header\"",
"]",
"===",
"\"empty\"",
")",
"{",
"if",
"(",
"section",
"[",
"\"data\"",
"]",
")",
"{",
"// Guess it's a claim",
"l... | Massage each section trying to restore a broken structure if any | [
"Massage",
"each",
"section",
"trying",
"to",
"restore",
"a",
"broken",
"structure",
"if",
"any"
] | 34404ea5d9c3c3582ae72b877d9febd703b57d56 | https://github.com/amida-tech/cms-fhir/blob/34404ea5d9c3c3582ae72b877d9febd703b57d56/lib/cmsTxtToIntObj.js#L19-L51 | train |
quorrajs/Positron | lib/view/helpers.js | elixir | function elixir(file, buildDirectory) {
if (!buildDirectory) {
buildDirectory = 'build';
}
var manifestPath = path.join(publicPath(buildDirectory), 'rev-manifest.json');
var manifest = require(manifestPath);
if (isset(manifest[file])) {
return '/'+ str.... | javascript | function elixir(file, buildDirectory) {
if (!buildDirectory) {
buildDirectory = 'build';
}
var manifestPath = path.join(publicPath(buildDirectory), 'rev-manifest.json');
var manifest = require(manifestPath);
if (isset(manifest[file])) {
return '/'+ str.... | [
"function",
"elixir",
"(",
"file",
",",
"buildDirectory",
")",
"{",
"if",
"(",
"!",
"buildDirectory",
")",
"{",
"buildDirectory",
"=",
"'build'",
";",
"}",
"var",
"manifestPath",
"=",
"path",
".",
"join",
"(",
"publicPath",
"(",
"buildDirectory",
")",
",",... | Get the path to a versioned Elixir file.
@param {String} file
@param {String} buildDirectory
@return {String}
@throws Error | [
"Get",
"the",
"path",
"to",
"a",
"versioned",
"Elixir",
"file",
"."
] | a4bad5a5f581743d1885405c11ae26600fb957af | https://github.com/quorrajs/Positron/blob/a4bad5a5f581743d1885405c11ae26600fb957af/lib/view/helpers.js#L22-L37 | train |
Jam3/f1 | lib/parsers/getParser.js | function(states, targets, transitions) {
initMethods.forEach( function(method) {
method(states, targets, transitions);
});
} | javascript | function(states, targets, transitions) {
initMethods.forEach( function(method) {
method(states, targets, transitions);
});
} | [
"function",
"(",
"states",
",",
"targets",
",",
"transitions",
")",
"{",
"initMethods",
".",
"forEach",
"(",
"function",
"(",
"method",
")",
"{",
"method",
"(",
"states",
",",
"targets",
",",
"transitions",
")",
";",
"}",
")",
";",
"}"
] | This will be called when the `f1` instance is initialized.
@param {Object} states states the `f1` instance currently is using
@param {Object} targets targets the `f1` instance currently is using
@param {Array} transitions transitions the `f1` instance currently is using | [
"This",
"will",
"be",
"called",
"when",
"the",
"f1",
"instance",
"is",
"initialized",
"."
] | 31bf0f9f4491f08d8b453aff744ba22ceab94607 | https://github.com/Jam3/f1/blob/31bf0f9f4491f08d8b453aff744ba22ceab94607/lib/parsers/getParser.js#L38-L44 | train | |
jaymell/nodeCf | src/config.js | parseExtraVars | function parseExtraVars(extraVars) {
if (!(_.isString(extraVars))) {
return undefined;
}
const myVars = _.split(extraVars, ' ').map(it => {
const v = _.split(it, '=');
if ( v.length != 2 )
throw new Error("Can't parse variable");
return v;
});
return _.fromPairs(myVars);
} | javascript | function parseExtraVars(extraVars) {
if (!(_.isString(extraVars))) {
return undefined;
}
const myVars = _.split(extraVars, ' ').map(it => {
const v = _.split(it, '=');
if ( v.length != 2 )
throw new Error("Can't parse variable");
return v;
});
return _.fromPairs(myVars);
} | [
"function",
"parseExtraVars",
"(",
"extraVars",
")",
"{",
"if",
"(",
"!",
"(",
"_",
".",
"isString",
"(",
"extraVars",
")",
")",
")",
"{",
"return",
"undefined",
";",
"}",
"const",
"myVars",
"=",
"_",
".",
"split",
"(",
"extraVars",
",",
"' '",
")",
... | given a string of one or more key-value pairs separated by '=', convert and return object | [
"given",
"a",
"string",
"of",
"one",
"or",
"more",
"key",
"-",
"value",
"pairs",
"separated",
"by",
"=",
"convert",
"and",
"return",
"object"
] | d0f499a1b0adf5c810c33698a66ef16db6bc590d | https://github.com/jaymell/nodeCf/blob/d0f499a1b0adf5c810c33698a66ef16db6bc590d/src/config.js#L102-L113 | train |
jaymell/nodeCf | src/config.js | parseArgs | function parseArgs(argv) {
debug('parseArgs argv: ', argv);
// default action
var action = 'deploy';
if ( argv['_'].length >= 1 ) {
action = argv['_'][0];
}
failIfEmpty('e', 'environment', argv);
failIfAbsent('e', 'environment', argv);
if ('s' in argv || 'stacks' in argv) failIfEmpty('s', 'stacks'... | javascript | function parseArgs(argv) {
debug('parseArgs argv: ', argv);
// default action
var action = 'deploy';
if ( argv['_'].length >= 1 ) {
action = argv['_'][0];
}
failIfEmpty('e', 'environment', argv);
failIfAbsent('e', 'environment', argv);
if ('s' in argv || 'stacks' in argv) failIfEmpty('s', 'stacks'... | [
"function",
"parseArgs",
"(",
"argv",
")",
"{",
"debug",
"(",
"'parseArgs argv: '",
",",
"argv",
")",
";",
"// default action",
"var",
"action",
"=",
"'deploy'",
";",
"if",
"(",
"argv",
"[",
"'_'",
"]",
".",
"length",
">=",
"1",
")",
"{",
"action",
"="... | validate command line arguments | [
"validate",
"command",
"line",
"arguments"
] | d0f499a1b0adf5c810c33698a66ef16db6bc590d | https://github.com/jaymell/nodeCf/blob/d0f499a1b0adf5c810c33698a66ef16db6bc590d/src/config.js#L138-L159 | train |
jaymell/nodeCf | src/config.js | loadConfigFile | async function loadConfigFile(filePath) {
const f = await Promise.any(
_.map(['.yml', '.yaml', '.json', ''], async(ext) =>
await utils.fileExists(`${filePath}${ext}`)));
if (f) {
return loadYaml(await fs.readFileAsync(f));
}
return undefined;
} | javascript | async function loadConfigFile(filePath) {
const f = await Promise.any(
_.map(['.yml', '.yaml', '.json', ''], async(ext) =>
await utils.fileExists(`${filePath}${ext}`)));
if (f) {
return loadYaml(await fs.readFileAsync(f));
}
return undefined;
} | [
"async",
"function",
"loadConfigFile",
"(",
"filePath",
")",
"{",
"const",
"f",
"=",
"await",
"Promise",
".",
"any",
"(",
"_",
".",
"map",
"(",
"[",
"'.yml'",
",",
"'.yaml'",
",",
"'.json'",
",",
"''",
"]",
",",
"async",
"(",
"ext",
")",
"=>",
"awa... | if file exists, load it, else return undefined. Iterate through various possible file extensions in attempt to find file. | [
"if",
"file",
"exists",
"load",
"it",
"else",
"return",
"undefined",
".",
"Iterate",
"through",
"various",
"possible",
"file",
"extensions",
"in",
"attempt",
"to",
"find",
"file",
"."
] | d0f499a1b0adf5c810c33698a66ef16db6bc590d | https://github.com/jaymell/nodeCf/blob/d0f499a1b0adf5c810c33698a66ef16db6bc590d/src/config.js#L192-L200 | train |
feedhenry-raincatcher/raincatcher-angularjs | packages/angularjs-auth-keycloak/lib/profileData.js | extractAttributeFields | function extractAttributeFields(attributeFields) {
var attributes = {};
if (attributeFields) {
for (var field in attributeFields) {
if (attributeFields[field].length > 0) {
attributes[field] = attributeFields[field][0];
}
}
}
return attributes;
} | javascript | function extractAttributeFields(attributeFields) {
var attributes = {};
if (attributeFields) {
for (var field in attributeFields) {
if (attributeFields[field].length > 0) {
attributes[field] = attributeFields[field][0];
}
}
}
return attributes;
} | [
"function",
"extractAttributeFields",
"(",
"attributeFields",
")",
"{",
"var",
"attributes",
"=",
"{",
"}",
";",
"if",
"(",
"attributeFields",
")",
"{",
"for",
"(",
"var",
"field",
"in",
"attributeFields",
")",
"{",
"if",
"(",
"attributeFields",
"[",
"field"... | Extract attribute fields from the profile data returned by Keycloak
@param attributeFields - Object which contains all the attributes of a user | [
"Extract",
"attribute",
"fields",
"from",
"the",
"profile",
"data",
"returned",
"by",
"Keycloak"
] | b394689227901e18871ad9edd0ec226c5e6839e1 | https://github.com/feedhenry-raincatcher/raincatcher-angularjs/blob/b394689227901e18871ad9edd0ec226c5e6839e1/packages/angularjs-auth-keycloak/lib/profileData.js#L5-L15 | train |
feedhenry-raincatcher/raincatcher-angularjs | packages/angularjs-auth-keycloak/lib/profileData.js | formatProfileData | function formatProfileData(profileData) {
var profile;
if (profileData) {
profile = extractAttributeFields(profileData.attributes);
profile.username = profileData.username;
profile.email = profileData.email;
}
return profile;
} | javascript | function formatProfileData(profileData) {
var profile;
if (profileData) {
profile = extractAttributeFields(profileData.attributes);
profile.username = profileData.username;
profile.email = profileData.email;
}
return profile;
} | [
"function",
"formatProfileData",
"(",
"profileData",
")",
"{",
"var",
"profile",
";",
"if",
"(",
"profileData",
")",
"{",
"profile",
"=",
"extractAttributeFields",
"(",
"profileData",
".",
"attributes",
")",
";",
"profile",
".",
"username",
"=",
"profileData",
... | Formats profile data as expected by the application
@param profileData - Object which contains the profile data of a user | [
"Formats",
"profile",
"data",
"as",
"expected",
"by",
"the",
"application"
] | b394689227901e18871ad9edd0ec226c5e6839e1 | https://github.com/feedhenry-raincatcher/raincatcher-angularjs/blob/b394689227901e18871ad9edd0ec226c5e6839e1/packages/angularjs-auth-keycloak/lib/profileData.js#L21-L29 | train |
Jam3/f1 | index.js | f1 | function f1(settings) {
if(!(this instanceof f1)) {
return new f1(settings);
}
settings = settings || {};
var emitter = this;
var onUpdate = settings.onUpdate || noop;
var onState = settings.onState || noop;
// this is used to generate a "name" for an f1 instance if one isn't given
numInstances... | javascript | function f1(settings) {
if(!(this instanceof f1)) {
return new f1(settings);
}
settings = settings || {};
var emitter = this;
var onUpdate = settings.onUpdate || noop;
var onState = settings.onState || noop;
// this is used to generate a "name" for an f1 instance if one isn't given
numInstances... | [
"function",
"f1",
"(",
"settings",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"f1",
")",
")",
"{",
"return",
"new",
"f1",
"(",
"settings",
")",
";",
"}",
"settings",
"=",
"settings",
"||",
"{",
"}",
";",
"var",
"emitter",
"=",
"this",
"... | To construct a new `f1` instance you can do it in two ways.
```javascript
ui = f1([ settigns ]);
```
or
```javascript
ui = new f1([ settings ]);
```
To construct an `f1` instance you can pass in an optional settings object. The following are properties you can pass in settings:
```javascript
{
onState: listenerState,... | [
"To",
"construct",
"a",
"new",
"f1",
"instance",
"you",
"can",
"do",
"it",
"in",
"two",
"ways",
"."
] | 31bf0f9f4491f08d8b453aff744ba22ceab94607 | https://github.com/Jam3/f1/blob/31bf0f9f4491f08d8b453aff744ba22ceab94607/index.js#L75-L138 | train |
Jam3/f1 | index.js | function(transitions) {
this.defTransitions = Array.isArray(transitions) ? transitions : Array.prototype.slice.apply(arguments);
return this;
} | javascript | function(transitions) {
this.defTransitions = Array.isArray(transitions) ? transitions : Array.prototype.slice.apply(arguments);
return this;
} | [
"function",
"(",
"transitions",
")",
"{",
"this",
".",
"defTransitions",
"=",
"Array",
".",
"isArray",
"(",
"transitions",
")",
"?",
"transitions",
":",
"Array",
".",
"prototype",
".",
"slice",
".",
"apply",
"(",
"arguments",
")",
";",
"return",
"this",
... | defines how this `f1` instance can move between states.
For instance if we had two states out and idle you could define your transitions
like this:
```javascript
var ui = require('f1')();
ui.transitions( [
'out', 'idle', // defines that you can go from the out state to the idle state
'idle', 'out' // defines that yo... | [
"defines",
"how",
"this",
"f1",
"instance",
"can",
"move",
"between",
"states",
"."
] | 31bf0f9f4491f08d8b453aff744ba22ceab94607 | https://github.com/Jam3/f1/blob/31bf0f9f4491f08d8b453aff744ba22ceab94607/index.js#L344-L349 | train | |
Jam3/f1 | index.js | function(parsersDefinitions) {
// check that the parsersDefinitions is an object
if(typeof parsersDefinitions !== 'object' || Array.isArray(parsersDefinitions)) {
throw new Error('parsers should be an Object that contains arrays of functions under init and update');
}
this.parser = this.parser |... | javascript | function(parsersDefinitions) {
// check that the parsersDefinitions is an object
if(typeof parsersDefinitions !== 'object' || Array.isArray(parsersDefinitions)) {
throw new Error('parsers should be an Object that contains arrays of functions under init and update');
}
this.parser = this.parser |... | [
"function",
"(",
"parsersDefinitions",
")",
"{",
"// check that the parsersDefinitions is an object",
"if",
"(",
"typeof",
"parsersDefinitions",
"!==",
"'object'",
"||",
"Array",
".",
"isArray",
"(",
"parsersDefinitions",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
... | `f1` can target many different platforms. How it does this is by using parsers which
can target different platforms. Parsers apply calculated state objects to targets.
If working with the dom for instance your state could define values which will be applied
by the parser to the dom elements style object.
When calling... | [
"f1",
"can",
"target",
"many",
"different",
"platforms",
".",
"How",
"it",
"does",
"this",
"is",
"by",
"using",
"parsers",
"which",
"can",
"target",
"different",
"platforms",
".",
"Parsers",
"apply",
"calculated",
"state",
"objects",
"to",
"targets",
"."
] | 31bf0f9f4491f08d8b453aff744ba22ceab94607 | https://github.com/Jam3/f1/blob/31bf0f9f4491f08d8b453aff744ba22ceab94607/index.js#L368-L380 | train | |
Jam3/f1 | index.js | function(initState) {
if(!this.isInitialized) {
this.isInitialized = true;
var driver = this.driver;
if(!this.defStates) {
throw new Error('You must define states before attempting to call init');
} else if(!this.defTransitions) {
throw new Error('You must define transit... | javascript | function(initState) {
if(!this.isInitialized) {
this.isInitialized = true;
var driver = this.driver;
if(!this.defStates) {
throw new Error('You must define states before attempting to call init');
} else if(!this.defTransitions) {
throw new Error('You must define transit... | [
"function",
"(",
"initState",
")",
"{",
"if",
"(",
"!",
"this",
".",
"isInitialized",
")",
"{",
"this",
".",
"isInitialized",
"=",
"true",
";",
"var",
"driver",
"=",
"this",
".",
"driver",
";",
"if",
"(",
"!",
"this",
".",
"defStates",
")",
"{",
"t... | Initializes `f1`. `init` will throw errors if required parameters such as
states and transitions are missing. The initial state for the `f1` instance
should be passed in.
@param {String} Initial state for the `f1` instance
@chainable | [
"Initializes",
"f1",
".",
"init",
"will",
"throw",
"errors",
"if",
"required",
"parameters",
"such",
"as",
"states",
"and",
"transitions",
"are",
"missing",
".",
"The",
"initial",
"state",
"for",
"the",
"f1",
"instance",
"should",
"be",
"passed",
"in",
"."
] | 31bf0f9f4491f08d8b453aff744ba22ceab94607 | https://github.com/Jam3/f1/blob/31bf0f9f4491f08d8b453aff744ba22ceab94607/index.js#L390-L425 | train | |
Jam3/f1 | index.js | function(pathToTarget, target, parserDefinition) {
var data = this.data;
var parser = this.parser;
var animationData;
// if parse functions were passed in then create a new parser
if(parserDefinition) {
parser = new getParser(parserDefinition);
}
// if we have a parser then apply t... | javascript | function(pathToTarget, target, parserDefinition) {
var data = this.data;
var parser = this.parser;
var animationData;
// if parse functions were passed in then create a new parser
if(parserDefinition) {
parser = new getParser(parserDefinition);
}
// if we have a parser then apply t... | [
"function",
"(",
"pathToTarget",
",",
"target",
",",
"parserDefinition",
")",
"{",
"var",
"data",
"=",
"this",
".",
"data",
";",
"var",
"parser",
"=",
"this",
".",
"parser",
";",
"var",
"animationData",
";",
"// if parse functions were passed in then create a new ... | An advanced method where you can apply the current state f1
has calculated to any object.
Basically allows you to have one f1 object control multiple objects
or manually apply animations to objects.
@param {String} pathToTarget A path in the current state to the object you'd like to apply. The path should
be defined... | [
"An",
"advanced",
"method",
"where",
"you",
"can",
"apply",
"the",
"current",
"state",
"f1",
"has",
"calculated",
"to",
"any",
"object",
"."
] | 31bf0f9f4491f08d8b453aff744ba22ceab94607 | https://github.com/Jam3/f1/blob/31bf0f9f4491f08d8b453aff744ba22ceab94607/index.js#L510-L539 | train | |
freshout-dev/thulium | etc/EJS/EJS.js | function(options){
this.type = options.type || EJS.type;
this.cache = options.cache != null ? options.cache : EJS.cache;
this.text = options.text || null;
this.name = options.name || null;
this.ext = options.ext || EJS.ext;
this.extMatch = new RegExp(this.ext.replace(/\./, '\.'));
} | javascript | function(options){
this.type = options.type || EJS.type;
this.cache = options.cache != null ? options.cache : EJS.cache;
this.text = options.text || null;
this.name = options.name || null;
this.ext = options.ext || EJS.ext;
this.extMatch = new RegExp(this.ext.replace(/\./, '\.'));
} | [
"function",
"(",
"options",
")",
"{",
"this",
".",
"type",
"=",
"options",
".",
"type",
"||",
"EJS",
".",
"type",
";",
"this",
".",
"cache",
"=",
"options",
".",
"cache",
"!=",
"null",
"?",
"options",
".",
"cache",
":",
"EJS",
".",
"cache",
";",
... | Sets options on this view to be rendered with.
@param {Object} options | [
"Sets",
"options",
"on",
"this",
"view",
"to",
"be",
"rendered",
"with",
"."
] | ba3173e700fbe810ce13063e7ad46e9b05bb49e7 | https://github.com/freshout-dev/thulium/blob/ba3173e700fbe810ce13063e7ad46e9b05bb49e7/etc/EJS/EJS.js#L128-L135 | train | |
chjj/rondo | lib/ev.js | function(el, type, event) {
if (!el) {
// emit for ALL elements
el = document.getElementsByTagName('*');
var i = el.length;
while (i--) if (el[i].nodeType === 1) {
emit(el[i], type, event);
}
return;
}
event = event || {};
event.target = event.target || el;
event.type = event.ty... | javascript | function(el, type, event) {
if (!el) {
// emit for ALL elements
el = document.getElementsByTagName('*');
var i = el.length;
while (i--) if (el[i].nodeType === 1) {
emit(el[i], type, event);
}
return;
}
event = event || {};
event.target = event.target || el;
event.type = event.ty... | [
"function",
"(",
"el",
",",
"type",
",",
"event",
")",
"{",
"if",
"(",
"!",
"el",
")",
"{",
"// emit for ALL elements",
"el",
"=",
"document",
".",
"getElementsByTagName",
"(",
"'*'",
")",
";",
"var",
"i",
"=",
"el",
".",
"length",
";",
"while",
"(",... | emit a custom or native event, simulate bubbling | [
"emit",
"a",
"custom",
"or",
"native",
"event",
"simulate",
"bubbling"
] | 5a0643a2e4ce74e25240517e1cf423df5a188008 | https://github.com/chjj/rondo/blob/5a0643a2e4ce74e25240517e1cf423df5a188008/lib/ev.js#L366-L397 | train | |
parsnick/laravel-elixir-bowerbundle | src/Package.js | Package | function Package(name)
{
var dotBowerJson = Package._readBowerJson(name) || {};
var overrides = globalOverrides[name] || {};
this.name = name;
this.installed = !! dotBowerJson.name;
this.main = overrides.main || dotBowerJson.main || [];
this.depend... | javascript | function Package(name)
{
var dotBowerJson = Package._readBowerJson(name) || {};
var overrides = globalOverrides[name] || {};
this.name = name;
this.installed = !! dotBowerJson.name;
this.main = overrides.main || dotBowerJson.main || [];
this.depend... | [
"function",
"Package",
"(",
"name",
")",
"{",
"var",
"dotBowerJson",
"=",
"Package",
".",
"_readBowerJson",
"(",
"name",
")",
"||",
"{",
"}",
";",
"var",
"overrides",
"=",
"globalOverrides",
"[",
"name",
"]",
"||",
"{",
"}",
";",
"this",
".",
"name",
... | Constructor for Package
@param {string} name | [
"Constructor",
"for",
"Package"
] | f6e7df503b4abec1c721a8b56b508162f714dd71 | https://github.com/parsnick/laravel-elixir-bowerbundle/blob/f6e7df503b4abec1c721a8b56b508162f714dd71/src/Package.js#L13-L22 | train |
quorrajs/Positron | lib/http/SessionMiddleware.js | StartSession | function StartSession(app, next) {
this.__app = app;
this.__next = next;
/**
* Session config
*/
this.__config = this.__app.config.get('session');
this.sessionHandler = app.sessionHandler;
} | javascript | function StartSession(app, next) {
this.__app = app;
this.__next = next;
/**
* Session config
*/
this.__config = this.__app.config.get('session');
this.sessionHandler = app.sessionHandler;
} | [
"function",
"StartSession",
"(",
"app",
",",
"next",
")",
"{",
"this",
".",
"__app",
"=",
"app",
";",
"this",
".",
"__next",
"=",
"next",
";",
"/**\n * Session config\n */",
"this",
".",
"__config",
"=",
"this",
".",
"__app",
".",
"config",
".",
... | SessionMiddleware.js
@author: Harish Anchu <harishanchu@gmail.com>
@copyright Copyright (c) 2015-2016, QuorraJS.
@license See LICENSE.txt | [
"SessionMiddleware",
".",
"js"
] | a4bad5a5f581743d1885405c11ae26600fb957af | https://github.com/quorrajs/Positron/blob/a4bad5a5f581743d1885405c11ae26600fb957af/lib/http/SessionMiddleware.js#L9-L19 | train |
feedhenry-raincatcher/raincatcher-angularjs | packages/angularjs-workflow/lib/workflow-process/workflow-process-steps/workflow-process-steps-controller.js | WorkflowProcessStepsController | function WorkflowProcessStepsController($scope, $state, wfmService, $timeout, $stateParams) {
var self = this;
var workorderId = $stateParams.workorderId;
function updateWorkflowState(workorder) {
//If the workflow is complete, then we can switch to the summary view.
if (wfmService.isCompleted(workorder)... | javascript | function WorkflowProcessStepsController($scope, $state, wfmService, $timeout, $stateParams) {
var self = this;
var workorderId = $stateParams.workorderId;
function updateWorkflowState(workorder) {
//If the workflow is complete, then we can switch to the summary view.
if (wfmService.isCompleted(workorder)... | [
"function",
"WorkflowProcessStepsController",
"(",
"$scope",
",",
"$state",
",",
"wfmService",
",",
"$timeout",
",",
"$stateParams",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"workorderId",
"=",
"$stateParams",
".",
"workorderId",
";",
"function",
"updat... | Lots of this will move to core.
Here, we render the current step of the workflow to the user.
@param $scope
@param $state
@param wfmService
@param $timeout
@param $stateParams
@constructor | [
"Lots",
"of",
"this",
"will",
"move",
"to",
"core",
"."
] | b394689227901e18871ad9edd0ec226c5e6839e1 | https://github.com/feedhenry-raincatcher/raincatcher-angularjs/blob/b394689227901e18871ad9edd0ec226c5e6839e1/packages/angularjs-workflow/lib/workflow-process/workflow-process-steps/workflow-process-steps-controller.js#L16-L60 | train |
chjj/rondo | lib/zest.js | function(sel) {
var cap, param;
if (typeof sel !== 'string') {
if (sel.length > 1) {
var func = []
, i = 0
, l = sel.length;
for (; i < l; i++) {
func.push(parse(sel[i]));
}
l = func.length;
return function(el) {
for (i = 0; i < l; i++) {
... | javascript | function(sel) {
var cap, param;
if (typeof sel !== 'string') {
if (sel.length > 1) {
var func = []
, i = 0
, l = sel.length;
for (; i < l; i++) {
func.push(parse(sel[i]));
}
l = func.length;
return function(el) {
for (i = 0; i < l; i++) {
... | [
"function",
"(",
"sel",
")",
"{",
"var",
"cap",
",",
"param",
";",
"if",
"(",
"typeof",
"sel",
"!==",
"'string'",
")",
"{",
"if",
"(",
"sel",
".",
"length",
">",
"1",
")",
"{",
"var",
"func",
"=",
"[",
"]",
",",
"i",
"=",
"0",
",",
"l",
"="... | Parsing
parse simple selectors, return a `test` | [
"Parsing",
"parse",
"simple",
"selectors",
"return",
"a",
"test"
] | 5a0643a2e4ce74e25240517e1cf423df5a188008 | https://github.com/chjj/rondo/blob/5a0643a2e4ce74e25240517e1cf423df5a188008/lib/zest.js#L279-L317 | train | |
chjj/rondo | lib/zest.js | function(sel) {
var filter = []
, comb = combinators.noop
, qname
, cap
, op
, len;
// add implicit universal selectors
sel = sel.replace(/(^|\s)(:|\[|\.|#)/g, '$1*$2');
while (cap = /\s*((?:\w+|\*)(?:[.#:][^\s]+|\[[^\]]+\])*)\s*$/.exec(sel)) {
len = sel.length - cap[0].length;
cap... | javascript | function(sel) {
var filter = []
, comb = combinators.noop
, qname
, cap
, op
, len;
// add implicit universal selectors
sel = sel.replace(/(^|\s)(:|\[|\.|#)/g, '$1*$2');
while (cap = /\s*((?:\w+|\*)(?:[.#:][^\s]+|\[[^\]]+\])*)\s*$/.exec(sel)) {
len = sel.length - cap[0].length;
cap... | [
"function",
"(",
"sel",
")",
"{",
"var",
"filter",
"=",
"[",
"]",
",",
"comb",
"=",
"combinators",
".",
"noop",
",",
"qname",
",",
"cap",
",",
"op",
",",
"len",
";",
"// add implicit universal selectors",
"sel",
"=",
"sel",
".",
"replace",
"(",
"/",
... | parse and compile the selector into a single filter function | [
"parse",
"and",
"compile",
"the",
"selector",
"into",
"a",
"single",
"filter",
"function"
] | 5a0643a2e4ce74e25240517e1cf423df5a188008 | https://github.com/chjj/rondo/blob/5a0643a2e4ce74e25240517e1cf423df5a188008/lib/zest.js#L321-L355 | train | |
IonicaBizau/node-levenshtein-array | lib/index.js | LevArray | function LevArray (data, str) {
var result = [];
for (var i = 0; i < data.length; ++i) {
var cWord = data[i];
result.push({
l: LevDist(cWord, str)
, w: cWord
});
}
result.sort(function (a, b) {
return a.l > b.l ? 1 : -1;
});
return result;
} | javascript | function LevArray (data, str) {
var result = [];
for (var i = 0; i < data.length; ++i) {
var cWord = data[i];
result.push({
l: LevDist(cWord, str)
, w: cWord
});
}
result.sort(function (a, b) {
return a.l > b.l ? 1 : -1;
});
return result;
} | [
"function",
"LevArray",
"(",
"data",
",",
"str",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"data",
".",
"length",
";",
"++",
"i",
")",
"{",
"var",
"cWord",
"=",
"data",
"[",
"i",
"]",
";... | LevArray
Finds the Levenshtein distance of an array, sorting it then.
@name LevArray
@function
@param {Array} data An array of strings.
@param {String} str The searched string.
@return {Array} An array of objects like this (it's sorted by levdist):
- `l` (Number): The Levenshtein distance value.
- `w` (String): The w... | [
"LevArray",
"Finds",
"the",
"Levenshtein",
"distance",
"of",
"an",
"array",
"sorting",
"it",
"then",
"."
] | d833b32773934ecc52477bcf7ae4ad2b228d8097 | https://github.com/IonicaBizau/node-levenshtein-array/blob/d833b32773934ecc52477bcf7ae4ad2b228d8097/lib/index.js#L17-L30 | train |
StefanoVollono/angular-select | github-page/main.min.js | function () {
return $http({
method: 'GET',
url: 'https://api.punkapi.com/v2/beers'
}).then(function (response) {
var beerArray = response.data;
var newBeerArray = [];
beerArray.forEach( function (arrayItem) {
... | javascript | function () {
return $http({
method: 'GET',
url: 'https://api.punkapi.com/v2/beers'
}).then(function (response) {
var beerArray = response.data;
var newBeerArray = [];
beerArray.forEach( function (arrayItem) {
... | [
"function",
"(",
")",
"{",
"return",
"$http",
"(",
"{",
"method",
":",
"'GET'",
",",
"url",
":",
"'https://api.punkapi.com/v2/beers'",
"}",
")",
".",
"then",
"(",
"function",
"(",
"response",
")",
"{",
"var",
"beerArray",
"=",
"response",
".",
"data",
";... | Get beer list from service | [
"Get",
"beer",
"list",
"from",
"service"
] | b62dc06976b22a39bedadc1b67aa2039b73d8540 | https://github.com/StefanoVollono/angular-select/blob/b62dc06976b22a39bedadc1b67aa2039b73d8540/github-page/main.min.js#L43791-L43810 | train | |
quorrajs/Positron | lib/routing/routeCompiler.js | findNextSeparator | function findNextSeparator(pattern) {
if ('' == pattern) {
// return empty string if pattern is empty or false (false which can be returned by substr)
return '';
}
// first remove all placeholders from the pattern so we can find the next real static character
pattern = pattern.replace(/\... | javascript | function findNextSeparator(pattern) {
if ('' == pattern) {
// return empty string if pattern is empty or false (false which can be returned by substr)
return '';
}
// first remove all placeholders from the pattern so we can find the next real static character
pattern = pattern.replace(/\... | [
"function",
"findNextSeparator",
"(",
"pattern",
")",
"{",
"if",
"(",
"''",
"==",
"pattern",
")",
"{",
"// return empty string if pattern is empty or false (false which can be returned by substr)",
"return",
"''",
";",
"}",
"// first remove all placeholders from the pattern so we... | Returns the next static character in the Route pattern that will serve as a separator.
@param {String} pattern The route pattern
@return string The next static character that functions as separator (or empty string when none available) | [
"Returns",
"the",
"next",
"static",
"character",
"in",
"the",
"Route",
"pattern",
"that",
"will",
"serve",
"as",
"a",
"separator",
"."
] | a4bad5a5f581743d1885405c11ae26600fb957af | https://github.com/quorrajs/Positron/blob/a4bad5a5f581743d1885405c11ae26600fb957af/lib/routing/routeCompiler.js#L126-L135 | train |
quorrajs/Positron | lib/routing/routeCompiler.js | computeRegexp | function computeRegexp(tokens, index, firstOptional) {
var token = tokens[index];
if ('text' === token[0]) {
// Text tokens
return str.regexQuote(token[1]);
} else {
// Variable tokens
if (0 === index && 0 === firstOptional) {
// When the only token is an optional... | javascript | function computeRegexp(tokens, index, firstOptional) {
var token = tokens[index];
if ('text' === token[0]) {
// Text tokens
return str.regexQuote(token[1]);
} else {
// Variable tokens
if (0 === index && 0 === firstOptional) {
// When the only token is an optional... | [
"function",
"computeRegexp",
"(",
"tokens",
",",
"index",
",",
"firstOptional",
")",
"{",
"var",
"token",
"=",
"tokens",
"[",
"index",
"]",
";",
"if",
"(",
"'text'",
"===",
"token",
"[",
"0",
"]",
")",
"{",
"// Text tokens",
"return",
"str",
".",
"rege... | Computes the regexp used to match a specific token. It can be static text or a subpattern.
@param {Array} tokens The route tokens
@param {Number} index The index of the current token
@param {Number} firstOptional The index of the first optional token
@return string The regexp pattern for a single toke... | [
"Computes",
"the",
"regexp",
"used",
"to",
"match",
"a",
"specific",
"token",
".",
"It",
"can",
"be",
"static",
"text",
"or",
"a",
"subpattern",
"."
] | a4bad5a5f581743d1885405c11ae26600fb957af | https://github.com/quorrajs/Positron/blob/a4bad5a5f581743d1885405c11ae26600fb957af/lib/routing/routeCompiler.js#L145-L172 | train |
quorrajs/Positron | lib/routing/routeCompiler.js | function (route) {
var staticPrefix = null;
var hostVariables = [];
var pathVariables = [];
var variables = [];
var tokens = [];
var regex = null;
var hostRegex = null;
var hostTokens = [];
var host;
if ('' !== (host = route.domain())) {
... | javascript | function (route) {
var staticPrefix = null;
var hostVariables = [];
var pathVariables = [];
var variables = [];
var tokens = [];
var regex = null;
var hostRegex = null;
var hostTokens = [];
var host;
if ('' !== (host = route.domain())) {
... | [
"function",
"(",
"route",
")",
"{",
"var",
"staticPrefix",
"=",
"null",
";",
"var",
"hostVariables",
"=",
"[",
"]",
";",
"var",
"pathVariables",
"=",
"[",
"]",
";",
"var",
"variables",
"=",
"[",
"]",
";",
"var",
"tokens",
"=",
"[",
"]",
";",
"var",... | Compiles the current route instance.
@param route A Route instance
@return CompiledRoute A CompiledRoute instance | [
"Compiles",
"the",
"current",
"route",
"instance",
"."
] | a4bad5a5f581743d1885405c11ae26600fb957af | https://github.com/quorrajs/Positron/blob/a4bad5a5f581743d1885405c11ae26600fb957af/lib/routing/routeCompiler.js#L182-L225 | train | |
quorrajs/Positron | lib/support/utils.js | acceptParams | function acceptParams(str, index) {
var parts = str.split(/ *; */);
var ret = {value: parts[0], quality: 1, params: {}, originalIndex: index};
for (var i = 1; i < parts.length; ++i) {
var pms = parts[i].split(/ *= */);
if ('q' == pms[0]) {
ret.quality = parseFloat(pms[1]);
... | javascript | function acceptParams(str, index) {
var parts = str.split(/ *; */);
var ret = {value: parts[0], quality: 1, params: {}, originalIndex: index};
for (var i = 1; i < parts.length; ++i) {
var pms = parts[i].split(/ *= */);
if ('q' == pms[0]) {
ret.quality = parseFloat(pms[1]);
... | [
"function",
"acceptParams",
"(",
"str",
",",
"index",
")",
"{",
"var",
"parts",
"=",
"str",
".",
"split",
"(",
"/",
" *; *",
"/",
")",
";",
"var",
"ret",
"=",
"{",
"value",
":",
"parts",
"[",
"0",
"]",
",",
"quality",
":",
"1",
",",
"params",
"... | Parse accept params `str` returning an
object with `.value`, `.quality` and `.params`.
also includes `.originalIndex` for stable sorting
@param {String} str
@return {Object} | [
"Parse",
"accept",
"params",
"str",
"returning",
"an",
"object",
"with",
".",
"value",
".",
"quality",
"and",
".",
"params",
".",
"also",
"includes",
".",
"originalIndex",
"for",
"stable",
"sorting"
] | a4bad5a5f581743d1885405c11ae26600fb957af | https://github.com/quorrajs/Positron/blob/a4bad5a5f581743d1885405c11ae26600fb957af/lib/support/utils.js#L282-L296 | train |
smikes/pure-fts | lib/thaw.js | parseJSON | function parseJSON(buf, cb) {
try {
cb(null, JSON.parse(buf));
} catch (err) {
return cb(err);
}
} | javascript | function parseJSON(buf, cb) {
try {
cb(null, JSON.parse(buf));
} catch (err) {
return cb(err);
}
} | [
"function",
"parseJSON",
"(",
"buf",
",",
"cb",
")",
"{",
"try",
"{",
"cb",
"(",
"null",
",",
"JSON",
".",
"parse",
"(",
"buf",
")",
")",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"return",
"cb",
"(",
"err",
")",
";",
"}",
"}"
] | convert thrown exceptions into callback err | [
"convert",
"thrown",
"exceptions",
"into",
"callback",
"err"
] | 157db4136d3e99f00e1791a070f7fd64c7eadfb6 | https://github.com/smikes/pure-fts/blob/157db4136d3e99f00e1791a070f7fd64c7eadfb6/lib/thaw.js#L46-L52 | train |
mikesamuel/pug-plugin-trusted-types | packages/plugin/index.js | multiMapSet | function multiMapSet(multimap, key, value) {
if (!multimap.has(key)) {
multimap.set(key, new Set());
}
const values = multimap.get(key);
if (!values.has(value)) {
values.add(value);
return true;
}
return false;
} | javascript | function multiMapSet(multimap, key, value) {
if (!multimap.has(key)) {
multimap.set(key, new Set());
}
const values = multimap.get(key);
if (!values.has(value)) {
values.add(value);
return true;
}
return false;
} | [
"function",
"multiMapSet",
"(",
"multimap",
",",
"key",
",",
"value",
")",
"{",
"if",
"(",
"!",
"multimap",
".",
"has",
"(",
"key",
")",
")",
"{",
"multimap",
".",
"set",
"(",
"key",
",",
"new",
"Set",
"(",
")",
")",
";",
"}",
"const",
"values",
... | Given a multimap that uses sets to collect values,
adds the value to the set for the given key. | [
"Given",
"a",
"multimap",
"that",
"uses",
"sets",
"to",
"collect",
"values",
"adds",
"the",
"value",
"to",
"the",
"set",
"for",
"the",
"given",
"key",
"."
] | 772c5aa30ca27d46dfddd654d7a60f16fa4519d6 | https://github.com/mikesamuel/pug-plugin-trusted-types/blob/772c5aa30ca27d46dfddd654d7a60f16fa4519d6/packages/plugin/index.js#L41-L51 | train |
mikesamuel/pug-plugin-trusted-types | packages/plugin/index.js | transitiveClosure | function transitiveClosure(nodeLabels, graph) {
let madeProgress = false;
do {
madeProgress = false;
for (const [ src, values ] of Array.from(nodeLabels.entries())) {
const targets = graph[src];
if (targets) {
for (const target of targets) {
for (const value of values) {
... | javascript | function transitiveClosure(nodeLabels, graph) {
let madeProgress = false;
do {
madeProgress = false;
for (const [ src, values ] of Array.from(nodeLabels.entries())) {
const targets = graph[src];
if (targets) {
for (const target of targets) {
for (const value of values) {
... | [
"function",
"transitiveClosure",
"(",
"nodeLabels",
",",
"graph",
")",
"{",
"let",
"madeProgress",
"=",
"false",
";",
"do",
"{",
"madeProgress",
"=",
"false",
";",
"for",
"(",
"const",
"[",
"src",
",",
"values",
"]",
"of",
"Array",
".",
"from",
"(",
"n... | Given a set of graph nodes to labels, propagates labels to
across edges.
@param nodeLabels a Map of nodes to labels. Modified in place.
@param graph an adjacency table such that graph[src] is a series of targets,
nodes adjacent to src. | [
"Given",
"a",
"set",
"of",
"graph",
"nodes",
"to",
"labels",
"propagates",
"labels",
"to",
"across",
"edges",
"."
] | 772c5aa30ca27d46dfddd654d7a60f16fa4519d6 | https://github.com/mikesamuel/pug-plugin-trusted-types/blob/772c5aa30ca27d46dfddd654d7a60f16fa4519d6/packages/plugin/index.js#L61-L76 | train |
mikesamuel/pug-plugin-trusted-types | packages/plugin/index.js | distrust | function distrust(msg, optAstNode) {
const { filename, line } = optAstNode || policyPath[policyPath.length - 2] || {};
const relfilename = options.basedir ? path.relative(options.basedir, filename) : filename;
report(`${ relfilename }:${ line }: ${ msg }`);
mayTrustOutput = false;
} | javascript | function distrust(msg, optAstNode) {
const { filename, line } = optAstNode || policyPath[policyPath.length - 2] || {};
const relfilename = options.basedir ? path.relative(options.basedir, filename) : filename;
report(`${ relfilename }:${ line }: ${ msg }`);
mayTrustOutput = false;
} | [
"function",
"distrust",
"(",
"msg",
",",
"optAstNode",
")",
"{",
"const",
"{",
"filename",
",",
"line",
"}",
"=",
"optAstNode",
"||",
"policyPath",
"[",
"policyPath",
".",
"length",
"-",
"2",
"]",
"||",
"{",
"}",
";",
"const",
"relfilename",
"=",
"opti... | Logs a message and flips a bit so that we do not bless the output of this template. | [
"Logs",
"a",
"message",
"and",
"flips",
"a",
"bit",
"so",
"that",
"we",
"do",
"not",
"bless",
"the",
"output",
"of",
"this",
"template",
"."
] | 772c5aa30ca27d46dfddd654d7a60f16fa4519d6 | https://github.com/mikesamuel/pug-plugin-trusted-types/blob/772c5aa30ca27d46dfddd654d7a60f16fa4519d6/packages/plugin/index.js#L150-L155 | train |
mikesamuel/pug-plugin-trusted-types | packages/plugin/index.js | getContainerName | function getContainerName(skip = 0) {
let element = null;
let mixin = null;
for (let i = policyPath.length - (skip * 2); (i -= 2) >= 0;) {
const policyPathElement = policyPath[i];
if (typeof policyPathElement === 'object') {
if (policyPathElement.type === 'Tag') {
... | javascript | function getContainerName(skip = 0) {
let element = null;
let mixin = null;
for (let i = policyPath.length - (skip * 2); (i -= 2) >= 0;) {
const policyPathElement = policyPath[i];
if (typeof policyPathElement === 'object') {
if (policyPathElement.type === 'Tag') {
... | [
"function",
"getContainerName",
"(",
"skip",
"=",
"0",
")",
"{",
"let",
"element",
"=",
"null",
";",
"let",
"mixin",
"=",
"null",
";",
"for",
"(",
"let",
"i",
"=",
"policyPath",
".",
"length",
"-",
"(",
"skip",
"*",
"2",
")",
";",
"(",
"i",
"-=",... | Walk upwards to find the enclosing tag and mixin if any. | [
"Walk",
"upwards",
"to",
"find",
"the",
"enclosing",
"tag",
"and",
"mixin",
"if",
"any",
"."
] | 772c5aa30ca27d46dfddd654d7a60f16fa4519d6 | https://github.com/mikesamuel/pug-plugin-trusted-types/blob/772c5aa30ca27d46dfddd654d7a60f16fa4519d6/packages/plugin/index.js#L158-L174 | train |
mikesamuel/pug-plugin-trusted-types | packages/plugin/index.js | addGuard | function addGuard(guard, expr) {
let safeExpr = null;
if (!isWellFormed(expr)) {
expr = '{/*Malformed Expression*/}';
}
needsRuntime = true;
safeExpr = ` rt_${ unpredictableSuffix }.${ guard }(${ expr }) `;
return safeExpr;
} | javascript | function addGuard(guard, expr) {
let safeExpr = null;
if (!isWellFormed(expr)) {
expr = '{/*Malformed Expression*/}';
}
needsRuntime = true;
safeExpr = ` rt_${ unpredictableSuffix }.${ guard }(${ expr }) `;
return safeExpr;
} | [
"function",
"addGuard",
"(",
"guard",
",",
"expr",
")",
"{",
"let",
"safeExpr",
"=",
"null",
";",
"if",
"(",
"!",
"isWellFormed",
"(",
"expr",
")",
")",
"{",
"expr",
"=",
"'{/*Malformed Expression*/}'",
";",
"}",
"needsRuntime",
"=",
"true",
";",
"safeEx... | Decorate expression text with a call to a guard function. | [
"Decorate",
"expression",
"text",
"with",
"a",
"call",
"to",
"a",
"guard",
"function",
"."
] | 772c5aa30ca27d46dfddd654d7a60f16fa4519d6 | https://github.com/mikesamuel/pug-plugin-trusted-types/blob/772c5aa30ca27d46dfddd654d7a60f16fa4519d6/packages/plugin/index.js#L235-L243 | train |
mikesamuel/pug-plugin-trusted-types | packages/plugin/index.js | addScrubber | function addScrubber(scrubber, element, expr) {
let safeExpr = null;
if (!isWellFormed(expr)) {
expr = '{/*Malformed Expression*/}';
}
needsScrubber = true;
safeExpr = ` sc_${ unpredictableSuffix }.${ scrubber }(${ stringify(element || '*') }, ${ expr }) `;
return safeExpr;
... | javascript | function addScrubber(scrubber, element, expr) {
let safeExpr = null;
if (!isWellFormed(expr)) {
expr = '{/*Malformed Expression*/}';
}
needsScrubber = true;
safeExpr = ` sc_${ unpredictableSuffix }.${ scrubber }(${ stringify(element || '*') }, ${ expr }) `;
return safeExpr;
... | [
"function",
"addScrubber",
"(",
"scrubber",
",",
"element",
",",
"expr",
")",
"{",
"let",
"safeExpr",
"=",
"null",
";",
"if",
"(",
"!",
"isWellFormed",
"(",
"expr",
")",
")",
"{",
"expr",
"=",
"'{/*Malformed Expression*/}'",
";",
"}",
"needsScrubber",
"=",... | Decorate expression text with a call to a scrubber function that checks an entire attribute bundle at runtime. | [
"Decorate",
"expression",
"text",
"with",
"a",
"call",
"to",
"a",
"scrubber",
"function",
"that",
"checks",
"an",
"entire",
"attribute",
"bundle",
"at",
"runtime",
"."
] | 772c5aa30ca27d46dfddd654d7a60f16fa4519d6 | https://github.com/mikesamuel/pug-plugin-trusted-types/blob/772c5aa30ca27d46dfddd654d7a60f16fa4519d6/packages/plugin/index.js#L247-L255 | train |
mikesamuel/pug-plugin-trusted-types | packages/plugin/index.js | checkCodeDoesNotInterfere | function checkCodeDoesNotInterfere(astNode, exprKey, isExpression) {
let expr = astNode[exprKey];
const seen = new Set();
const type = typeof expr;
if (type !== 'string') {
// expr may be true, not "true".
// This occurs for inferred expressions like valueless attributes.
... | javascript | function checkCodeDoesNotInterfere(astNode, exprKey, isExpression) {
let expr = astNode[exprKey];
const seen = new Set();
const type = typeof expr;
if (type !== 'string') {
// expr may be true, not "true".
// This occurs for inferred expressions like valueless attributes.
... | [
"function",
"checkCodeDoesNotInterfere",
"(",
"astNode",
",",
"exprKey",
",",
"isExpression",
")",
"{",
"let",
"expr",
"=",
"astNode",
"[",
"exprKey",
"]",
";",
"const",
"seen",
"=",
"new",
"Set",
"(",
")",
";",
"const",
"type",
"=",
"typeof",
"expr",
";... | If user expressions have free variables like pug_html then don't bless the output because we'd have to statically analyze the generated JS to preserve output integrity. | [
"If",
"user",
"expressions",
"have",
"free",
"variables",
"like",
"pug_html",
"then",
"don",
"t",
"bless",
"the",
"output",
"because",
"we",
"d",
"have",
"to",
"statically",
"analyze",
"the",
"generated",
"JS",
"to",
"preserve",
"output",
"integrity",
"."
] | 772c5aa30ca27d46dfddd654d7a60f16fa4519d6 | https://github.com/mikesamuel/pug-plugin-trusted-types/blob/772c5aa30ca27d46dfddd654d7a60f16fa4519d6/packages/plugin/index.js#L281-L349 | train |
mikesamuel/pug-plugin-trusted-types | packages/plugin/index.js | noncifyAttrs | function noncifyAttrs(element, getValue, attrs) {
if (nonceValueExpression) {
if (element === 'script' || element === 'style' ||
(element === 'link' && (getValue('rel') || '').toLowerCase() === 'stylesheet')) {
if (attrs.findIndex(({ name }) => name === 'nonce') < 0) {
at... | javascript | function noncifyAttrs(element, getValue, attrs) {
if (nonceValueExpression) {
if (element === 'script' || element === 'style' ||
(element === 'link' && (getValue('rel') || '').toLowerCase() === 'stylesheet')) {
if (attrs.findIndex(({ name }) => name === 'nonce') < 0) {
at... | [
"function",
"noncifyAttrs",
"(",
"element",
",",
"getValue",
",",
"attrs",
")",
"{",
"if",
"(",
"nonceValueExpression",
")",
"{",
"if",
"(",
"element",
"===",
"'script'",
"||",
"element",
"===",
"'style'",
"||",
"(",
"element",
"===",
"'link'",
"&&",
"(",
... | Add nonce attributes to attribute sets as needed. | [
"Add",
"nonce",
"attributes",
"to",
"attribute",
"sets",
"as",
"needed",
"."
] | 772c5aa30ca27d46dfddd654d7a60f16fa4519d6 | https://github.com/mikesamuel/pug-plugin-trusted-types/blob/772c5aa30ca27d46dfddd654d7a60f16fa4519d6/packages/plugin/index.js#L352-L365 | train |
mikesamuel/pug-plugin-trusted-types | packages/plugin/index.js | noncifyTag | function noncifyTag({ name, block: { nodes } }) {
if (name === 'form' && csrfInputValueExpression) {
nodes.unshift({
type: 'Conditional',
test: csrfInputValueExpression,
consequent: {
type: 'Block',
nodes: [
{
type: 'Tag',... | javascript | function noncifyTag({ name, block: { nodes } }) {
if (name === 'form' && csrfInputValueExpression) {
nodes.unshift({
type: 'Conditional',
test: csrfInputValueExpression,
consequent: {
type: 'Block',
nodes: [
{
type: 'Tag',... | [
"function",
"noncifyTag",
"(",
"{",
"name",
",",
"block",
":",
"{",
"nodes",
"}",
"}",
")",
"{",
"if",
"(",
"name",
"===",
"'form'",
"&&",
"csrfInputValueExpression",
")",
"{",
"nodes",
".",
"unshift",
"(",
"{",
"type",
":",
"'Conditional'",
",",
"test... | Add nonce attributes to tags as needed. | [
"Add",
"nonce",
"attributes",
"to",
"tags",
"as",
"needed",
"."
] | 772c5aa30ca27d46dfddd654d7a60f16fa4519d6 | https://github.com/mikesamuel/pug-plugin-trusted-types/blob/772c5aa30ca27d46dfddd654d7a60f16fa4519d6/packages/plugin/index.js#L368-L409 | train |
mikesamuel/pug-plugin-trusted-types | packages/plugin/index.js | apply | function apply(x) {
const policyPathLength = policyPath.length;
policyPath[policyPathLength] = x;
if (Array.isArray(x)) {
for (let i = 0, len = x.length; i < len; ++i) {
policyPath[policyPathLength + 1] = i;
apply(x[i]);
}
} else if (x && typeof x === 'object'... | javascript | function apply(x) {
const policyPathLength = policyPath.length;
policyPath[policyPathLength] = x;
if (Array.isArray(x)) {
for (let i = 0, len = x.length; i < len; ++i) {
policyPath[policyPathLength + 1] = i;
apply(x[i]);
}
} else if (x && typeof x === 'object'... | [
"function",
"apply",
"(",
"x",
")",
"{",
"const",
"policyPathLength",
"=",
"policyPath",
".",
"length",
";",
"policyPath",
"[",
"policyPathLength",
"]",
"=",
"x",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",
"x",
")",
")",
"{",
"for",
"(",
"let",
"i... | Walk the AST applying the policy | [
"Walk",
"the",
"AST",
"applying",
"the",
"policy"
] | 772c5aa30ca27d46dfddd654d7a60f16fa4519d6 | https://github.com/mikesamuel/pug-plugin-trusted-types/blob/772c5aa30ca27d46dfddd654d7a60f16fa4519d6/packages/plugin/index.js#L570-L597 | train |
theThings/jailed-node | lib/Plugin.js | Plugin | function Plugin(script, _interface, options) {
this._script = script
this._options = options || {}
this._initialInterface = _interface || {}
this._connect()
} | javascript | function Plugin(script, _interface, options) {
this._script = script
this._options = options || {}
this._initialInterface = _interface || {}
this._connect()
} | [
"function",
"Plugin",
"(",
"script",
",",
"_interface",
",",
"options",
")",
"{",
"this",
".",
"_script",
"=",
"script",
"this",
".",
"_options",
"=",
"options",
"||",
"{",
"}",
"this",
".",
"_initialInterface",
"=",
"_interface",
"||",
"{",
"}",
"this",... | Plugin constructor, represents a plugin initialized by a script
with the given path
@param {String} url of a plugin source
@param {Object} _interface to provide for the plugin | [
"Plugin",
"constructor",
"represents",
"a",
"plugin",
"initialized",
"by",
"a",
"script",
"with",
"the",
"given",
"path"
] | 6e453d97e74fbd1c0b27b982084f6fd7c1aa0173 | https://github.com/theThings/jailed-node/blob/6e453d97e74fbd1c0b27b982084f6fd7c1aa0173/lib/Plugin.js#L18-L23 | train |
aeroith/epub-metadata-parser | lib/epub-metadata-parser.js | function (arr) {
var jsonData = {};
_.forEach(arr, function (elem) {
var keys = Object.keys(elem);
_.forEach(keys, function (key) {
var value = elem[key];
jsonData[key] = value;
});
})
return jsonData;
} | javascript | function (arr) {
var jsonData = {};
_.forEach(arr, function (elem) {
var keys = Object.keys(elem);
_.forEach(keys, function (key) {
var value = elem[key];
jsonData[key] = value;
});
})
return jsonData;
} | [
"function",
"(",
"arr",
")",
"{",
"var",
"jsonData",
"=",
"{",
"}",
";",
"_",
".",
"forEach",
"(",
"arr",
",",
"function",
"(",
"elem",
")",
"{",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"elem",
")",
";",
"_",
".",
"forEach",
"(",
"keys"... | a helper function to convert an array to json object | [
"a",
"helper",
"function",
"to",
"convert",
"an",
"array",
"to",
"json",
"object"
] | e52e5066967ba8c8a0f86d2768416ab407d05e47 | https://github.com/aeroith/epub-metadata-parser/blob/e52e5066967ba8c8a0f86d2768416ab407d05e47/lib/epub-metadata-parser.js#L165-L175 | train | |
gribnoysup/nfield-api | index.js | bindAPI | function bindAPI (self, api, fnName) {
return api[fnName].bind(self, self.__REQUEST_OPTIONS, self.__CREDENTIALS, self.__TOKEN);
} | javascript | function bindAPI (self, api, fnName) {
return api[fnName].bind(self, self.__REQUEST_OPTIONS, self.__CREDENTIALS, self.__TOKEN);
} | [
"function",
"bindAPI",
"(",
"self",
",",
"api",
",",
"fnName",
")",
"{",
"return",
"api",
"[",
"fnName",
"]",
".",
"bind",
"(",
"self",
",",
"self",
".",
"__REQUEST_OPTIONS",
",",
"self",
".",
"__CREDENTIALS",
",",
"self",
".",
"__TOKEN",
")",
";",
"... | A little wrapper for easy binding API functions to ConnectedInstance | [
"A",
"little",
"wrapper",
"for",
"easy",
"binding",
"API",
"functions",
"to",
"ConnectedInstance"
] | fcd635255fad2fc483d0e9045ecf7faba04378d9 | https://github.com/gribnoysup/nfield-api/blob/fcd635255fad2fc483d0e9045ecf7faba04378d9/index.js#L10-L12 | train |
gribnoysup/nfield-api | index.js | ConnectedInstance | function ConnectedInstance (requestOptions, authToken, credentials) {
this.__REQUEST_OPTIONS = requestOptions;
this.__TOKEN = authToken;
this.__CREDENTIALS = credentials;
this.SurveyFieldwork = {
status : bindAPI(this, API, 'statusSurveyFieldwork'),
start : bindAPI(this, API, 'startSurveyFieldwork'),... | javascript | function ConnectedInstance (requestOptions, authToken, credentials) {
this.__REQUEST_OPTIONS = requestOptions;
this.__TOKEN = authToken;
this.__CREDENTIALS = credentials;
this.SurveyFieldwork = {
status : bindAPI(this, API, 'statusSurveyFieldwork'),
start : bindAPI(this, API, 'startSurveyFieldwork'),... | [
"function",
"ConnectedInstance",
"(",
"requestOptions",
",",
"authToken",
",",
"credentials",
")",
"{",
"this",
".",
"__REQUEST_OPTIONS",
"=",
"requestOptions",
";",
"this",
".",
"__TOKEN",
"=",
"authToken",
";",
"this",
".",
"__CREDENTIALS",
"=",
"credentials",
... | Creates an instance of object, connected to Nfield API
@constructor | [
"Creates",
"an",
"instance",
"of",
"object",
"connected",
"to",
"Nfield",
"API"
] | fcd635255fad2fc483d0e9045ecf7faba04378d9 | https://github.com/gribnoysup/nfield-api/blob/fcd635255fad2fc483d0e9045ecf7faba04378d9/index.js#L18-L82 | train |
gribnoysup/nfield-api | index.js | NfieldClient | function NfieldClient (defOptions) {
var defaultRequestCliOptions = {
baseUrl : 'https://api.nfieldmr.com/'
};
extend(true, defaultRequestCliOptions, defOptions);
/**
* Sign In api method provided strait with NfieldCliend instance because it doesn't need authentication
*/
this.SignIn = API.... | javascript | function NfieldClient (defOptions) {
var defaultRequestCliOptions = {
baseUrl : 'https://api.nfieldmr.com/'
};
extend(true, defaultRequestCliOptions, defOptions);
/**
* Sign In api method provided strait with NfieldCliend instance because it doesn't need authentication
*/
this.SignIn = API.... | [
"function",
"NfieldClient",
"(",
"defOptions",
")",
"{",
"var",
"defaultRequestCliOptions",
"=",
"{",
"baseUrl",
":",
"'https://api.nfieldmr.com/'",
"}",
";",
"extend",
"(",
"true",
",",
"defaultRequestCliOptions",
",",
"defOptions",
")",
";",
"/**\n * Sign In api m... | Creates NfieldClient object
@constructor | [
"Creates",
"NfieldClient",
"object"
] | fcd635255fad2fc483d0e9045ecf7faba04378d9 | https://github.com/gribnoysup/nfield-api/blob/fcd635255fad2fc483d0e9045ecf7faba04378d9/index.js#L88-L135 | train |
alexyoung/pop | lib/server.js | server | function server() {
// TODO: Show require express error
var express = require('express')
, app = express();
app.configure(function() {
app.use(express.static(siteBuilder.outputRoot));
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
// Map missing trailing slashes fo... | javascript | function server() {
// TODO: Show require express error
var express = require('express')
, app = express();
app.configure(function() {
app.use(express.static(siteBuilder.outputRoot));
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
// Map missing trailing slashes fo... | [
"function",
"server",
"(",
")",
"{",
"// TODO: Show require express error",
"var",
"express",
"=",
"require",
"(",
"'express'",
")",
",",
"app",
"=",
"express",
"(",
")",
";",
"app",
".",
"configure",
"(",
"function",
"(",
")",
"{",
"app",
".",
"use",
"(... | Instantiates and runs the Express server. | [
"Instantiates",
"and",
"runs",
"the",
"Express",
"server",
"."
] | 8a0b3f2605cb58e8ae6b34f1373dde00610e9858 | https://github.com/alexyoung/pop/blob/8a0b3f2605cb58e8ae6b34f1373dde00610e9858/lib/server.js#L18-L41 | train |
edus44/express-deliver | lib/response/error.js | normalizeError | function normalizeError(err,pools){
if (!(err instanceof Error)){
err = new Error(err)
}
if (!err._isException){
//Iterate over exceptionPools finding error match
for(let i=0;i<pools.length;i++){
let exception = pools[i]._convert(err)
if (exception) return ex... | javascript | function normalizeError(err,pools){
if (!(err instanceof Error)){
err = new Error(err)
}
if (!err._isException){
//Iterate over exceptionPools finding error match
for(let i=0;i<pools.length;i++){
let exception = pools[i]._convert(err)
if (exception) return ex... | [
"function",
"normalizeError",
"(",
"err",
",",
"pools",
")",
"{",
"if",
"(",
"!",
"(",
"err",
"instanceof",
"Error",
")",
")",
"{",
"err",
"=",
"new",
"Error",
"(",
"err",
")",
"}",
"if",
"(",
"!",
"err",
".",
"_isException",
")",
"{",
"//Iterate o... | Tries to always return an expressDeliver exception
@param {any} err
@param {Array<ExceptionPool>} pools
@return {Exception} | [
"Tries",
"to",
"always",
"return",
"an",
"expressDeliver",
"exception"
] | 895abfaf2e5e48a00b4fef943dccaffcbf244780 | https://github.com/edus44/express-deliver/blob/895abfaf2e5e48a00b4fef943dccaffcbf244780/lib/response/error.js#L31-L44 | train |
edus44/express-deliver | lib/response/error.js | defaultTransformError | function defaultTransformError(err,req){
let body = {
code: err.code,
message: err.message,
data: err.data,
}
if (req._expressDeliverOptions.printErrorStack===true){
body.stack = err.stack
}
if (err.name == 'InternalError' && req._expressDeliverOptions.printInternal... | javascript | function defaultTransformError(err,req){
let body = {
code: err.code,
message: err.message,
data: err.data,
}
if (req._expressDeliverOptions.printErrorStack===true){
body.stack = err.stack
}
if (err.name == 'InternalError' && req._expressDeliverOptions.printInternal... | [
"function",
"defaultTransformError",
"(",
"err",
",",
"req",
")",
"{",
"let",
"body",
"=",
"{",
"code",
":",
"err",
".",
"code",
",",
"message",
":",
"err",
".",
"message",
",",
"data",
":",
"err",
".",
"data",
",",
"}",
"if",
"(",
"req",
".",
"_... | Default error response transformation
@param {Exception} err
@param {Request} req
@return {Object} | [
"Default",
"error",
"response",
"transformation"
] | 895abfaf2e5e48a00b4fef943dccaffcbf244780 | https://github.com/edus44/express-deliver/blob/895abfaf2e5e48a00b4fef943dccaffcbf244780/lib/response/error.js#L68-L87 | train |
pumpumba/Influsion-back-end | machinepack-youtubenodemachines/youtubeAPICalls.js | getChannel | function getChannel(auth, youtube, channelID, callback) {
youtube.channels.list( // Call the Youtube API
{
auth: auth,
part: "snippet, statistics",
order: "date",
id: channelID,
maxResults: 1 // Integer 0-50, default 5
},
function(err, res) {
if (err) {
console.... | javascript | function getChannel(auth, youtube, channelID, callback) {
youtube.channels.list( // Call the Youtube API
{
auth: auth,
part: "snippet, statistics",
order: "date",
id: channelID,
maxResults: 1 // Integer 0-50, default 5
},
function(err, res) {
if (err) {
console.... | [
"function",
"getChannel",
"(",
"auth",
",",
"youtube",
",",
"channelID",
",",
"callback",
")",
"{",
"youtube",
".",
"channels",
".",
"list",
"(",
"// Call the Youtube API",
"{",
"auth",
":",
"auth",
",",
"part",
":",
"\"snippet, statistics\"",
",",
"order",
... | Get a Youtube channel via channel ID | [
"Get",
"a",
"Youtube",
"channel",
"via",
"channel",
"ID"
] | 68ba7a42e415f08eb16551b564ee384011e1918e | https://github.com/pumpumba/Influsion-back-end/blob/68ba7a42e415f08eb16551b564ee384011e1918e/machinepack-youtubenodemachines/youtubeAPICalls.js#L31-L53 | train |
pumpumba/Influsion-back-end | machinepack-youtubenodemachines/youtubeAPICalls.js | getChannelUsername | function getChannelUsername(auth, youtube, username, callback) {
youtube.channels.list( // Call the Youtube API
{
auth: auth,
part: "snippet, statistics",
order: "date",
forUsername: username,
maxResults: 1 // Integer 0-50, default 5
},
function(err, res) {
if (err) {
... | javascript | function getChannelUsername(auth, youtube, username, callback) {
youtube.channels.list( // Call the Youtube API
{
auth: auth,
part: "snippet, statistics",
order: "date",
forUsername: username,
maxResults: 1 // Integer 0-50, default 5
},
function(err, res) {
if (err) {
... | [
"function",
"getChannelUsername",
"(",
"auth",
",",
"youtube",
",",
"username",
",",
"callback",
")",
"{",
"youtube",
".",
"channels",
".",
"list",
"(",
"// Call the Youtube API",
"{",
"auth",
":",
"auth",
",",
"part",
":",
"\"snippet, statistics\"",
",",
"ord... | Get a Youtube channel via channel name | [
"Get",
"a",
"Youtube",
"channel",
"via",
"channel",
"name"
] | 68ba7a42e415f08eb16551b564ee384011e1918e | https://github.com/pumpumba/Influsion-back-end/blob/68ba7a42e415f08eb16551b564ee384011e1918e/machinepack-youtubenodemachines/youtubeAPICalls.js#L56-L78 | train |
pumpumba/Influsion-back-end | machinepack-youtubenodemachines/youtubeAPICalls.js | getVideos | function getVideos(auth, youtube, channel_id, count, callback) {
youtube.search.list( // Call the Youtube API
{
auth: auth,
part: "snippet",
order: "date",
maxResults : count, //integer 0-50, default 5
channelId: channel_id
},
function(err, res) {
if (err) {
console.log("The API re... | javascript | function getVideos(auth, youtube, channel_id, count, callback) {
youtube.search.list( // Call the Youtube API
{
auth: auth,
part: "snippet",
order: "date",
maxResults : count, //integer 0-50, default 5
channelId: channel_id
},
function(err, res) {
if (err) {
console.log("The API re... | [
"function",
"getVideos",
"(",
"auth",
",",
"youtube",
",",
"channel_id",
",",
"count",
",",
"callback",
")",
"{",
"youtube",
".",
"search",
".",
"list",
"(",
"// Call the Youtube API",
"{",
"auth",
":",
"auth",
",",
"part",
":",
"\"snippet\"",
",",
"order"... | Get Youtube videos via channel ID | [
"Get",
"Youtube",
"videos",
"via",
"channel",
"ID"
] | 68ba7a42e415f08eb16551b564ee384011e1918e | https://github.com/pumpumba/Influsion-back-end/blob/68ba7a42e415f08eb16551b564ee384011e1918e/machinepack-youtubenodemachines/youtubeAPICalls.js#L106-L126 | train |
pumpumba/Influsion-back-end | machinepack-youtubenodemachines/youtubeAPICalls.js | getVideoStatistics | function getVideoStatistics(auth, youtube, items, count, callback) {
// Convert the video ID:s of the provided videos to the appropriate format
var IDs = "";
if (Array.isArray(items)) {
for (var i = 0; i < items.length; i++) {
if (i != 0) {
IDs += ", "
}
IDs += items[i].id.videoId;
... | javascript | function getVideoStatistics(auth, youtube, items, count, callback) {
// Convert the video ID:s of the provided videos to the appropriate format
var IDs = "";
if (Array.isArray(items)) {
for (var i = 0; i < items.length; i++) {
if (i != 0) {
IDs += ", "
}
IDs += items[i].id.videoId;
... | [
"function",
"getVideoStatistics",
"(",
"auth",
",",
"youtube",
",",
"items",
",",
"count",
",",
"callback",
")",
"{",
"// Convert the video ID:s of the provided videos to the appropriate format",
"var",
"IDs",
"=",
"\"\"",
";",
"if",
"(",
"Array",
".",
"isArray",
"(... | Get video statistics | [
"Get",
"video",
"statistics"
] | 68ba7a42e415f08eb16551b564ee384011e1918e | https://github.com/pumpumba/Influsion-back-end/blob/68ba7a42e415f08eb16551b564ee384011e1918e/machinepack-youtubenodemachines/youtubeAPICalls.js#L129-L157 | train |
pumpumba/Influsion-back-end | machinepack-youtubenodemachines/youtubeAPICalls.js | formatVideosJson | function formatVideosJson(videos, statistics) {
var formatedVideos = []
if (Array.isArray(videos)) {
for (var i = 0; i < videos.length; i++) {
var video = {
"platform": "Youtube",
"channel_id": videos[i].snippet.channelId,
"channel_url": "",
"channel_title": videos[i].snip... | javascript | function formatVideosJson(videos, statistics) {
var formatedVideos = []
if (Array.isArray(videos)) {
for (var i = 0; i < videos.length; i++) {
var video = {
"platform": "Youtube",
"channel_id": videos[i].snippet.channelId,
"channel_url": "",
"channel_title": videos[i].snip... | [
"function",
"formatVideosJson",
"(",
"videos",
",",
"statistics",
")",
"{",
"var",
"formatedVideos",
"=",
"[",
"]",
"if",
"(",
"Array",
".",
"isArray",
"(",
"videos",
")",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"videos",
".",
"l... | Format the JSON object containing the video data | [
"Format",
"the",
"JSON",
"object",
"containing",
"the",
"video",
"data"
] | 68ba7a42e415f08eb16551b564ee384011e1918e | https://github.com/pumpumba/Influsion-back-end/blob/68ba7a42e415f08eb16551b564ee384011e1918e/machinepack-youtubenodemachines/youtubeAPICalls.js#L190-L231 | train |
nicjansma/breakup.js | lib/breakup.js | function() {
// run iterator for this item
iterator(arr[current], function(err) {
// check for any errors with this element
if (err) {
callback(err, yielded);
} else {
// move onto the next element
... | javascript | function() {
// run iterator for this item
iterator(arr[current], function(err) {
// check for any errors with this element
if (err) {
callback(err, yielded);
} else {
// move onto the next element
... | [
"function",
"(",
")",
"{",
"// run iterator for this item",
"iterator",
"(",
"arr",
"[",
"current",
"]",
",",
"function",
"(",
"err",
")",
"{",
"// check for any errors with this element",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
",",
"yielded",
")"... | Iteration loop function. Called once for each element | [
"Iteration",
"loop",
"function",
".",
"Called",
"once",
"for",
"each",
"element"
] | d87a35514301ca150109979b814b9a5fc205079c | https://github.com/nicjansma/breakup.js/blob/d87a35514301ca150109979b814b9a5fc205079c/lib/breakup.js#L117-L161 | train | |
reworkcss/rework-plugin-at2x | index.js | combineMediaQuery | function combineMediaQuery(base, additional) {
var finalQuery = [];
base.forEach(function(b) {
additional.forEach(function(a) {
finalQuery.push(b + ' and ' + a);
});
});
return finalQuery.join(', ');
} | javascript | function combineMediaQuery(base, additional) {
var finalQuery = [];
base.forEach(function(b) {
additional.forEach(function(a) {
finalQuery.push(b + ' and ' + a);
});
});
return finalQuery.join(', ');
} | [
"function",
"combineMediaQuery",
"(",
"base",
",",
"additional",
")",
"{",
"var",
"finalQuery",
"=",
"[",
"]",
";",
"base",
".",
"forEach",
"(",
"function",
"(",
"b",
")",
"{",
"additional",
".",
"forEach",
"(",
"function",
"(",
"a",
")",
"{",
"finalQu... | Combines existing media query with 2x media query. | [
"Combines",
"existing",
"media",
"query",
"with",
"2x",
"media",
"query",
"."
] | 404b240e69f7ee3814f100e877732d7281c178d7 | https://github.com/reworkcss/rework-plugin-at2x/blob/404b240e69f7ee3814f100e877732d7281c178d7/index.js#L109-L117 | train |
BlackWaspTech/wasp-graphql | src/query.js | query | function query(url, init) {
// Reject if user provided no arguments
if (!url || typeof url !== 'string') {
return Promise.reject(
"Expected a non-empty string for 'url' but received: " + typeof url
);
}
// Reject if user provided an invalid second argument
if (!init) {
return Prom... | javascript | function query(url, init) {
// Reject if user provided no arguments
if (!url || typeof url !== 'string') {
return Promise.reject(
"Expected a non-empty string for 'url' but received: " + typeof url
);
}
// Reject if user provided an invalid second argument
if (!init) {
return Prom... | [
"function",
"query",
"(",
"url",
",",
"init",
")",
"{",
"// Reject if user provided no arguments\r",
"if",
"(",
"!",
"url",
"||",
"typeof",
"url",
"!==",
"'string'",
")",
"{",
"return",
"Promise",
".",
"reject",
"(",
"\"Expected a non-empty string for 'url' but rece... | Provides a thin, GQL-compliant wrapper over the Fetch API.
Syntax: query(url, init)
@param {string} url - The url for the intended resource
@param {(string|Object)} init - Can be a string of fields or a configuration object
@param {string} [init.fields] - GQL fields: Will be added to the body of the request
@param {O... | [
"Provides",
"a",
"thin",
"GQL",
"-",
"compliant",
"wrapper",
"over",
"the",
"Fetch",
"API",
"."
] | 5857b82b6eda9bb5dea5f0a881cd910b1bb3944a | https://github.com/BlackWaspTech/wasp-graphql/blob/5857b82b6eda9bb5dea5f0a881cd910b1bb3944a/src/query.js#L24-L74 | train |
quorrajs/Positron | lib/http/request.js | function (key, defaultValue) {
var body = self.body || {};
var query = self.query || {};
if (null != body[key]) return body[key];
if (null != query[key]) return query[key];
return defaultValue;
} | javascript | function (key, defaultValue) {
var body = self.body || {};
var query = self.query || {};
if (null != body[key]) return body[key];
if (null != query[key]) return query[key];
return defaultValue;
} | [
"function",
"(",
"key",
",",
"defaultValue",
")",
"{",
"var",
"body",
"=",
"self",
".",
"body",
"||",
"{",
"}",
";",
"var",
"query",
"=",
"self",
".",
"query",
"||",
"{",
"}",
";",
"if",
"(",
"null",
"!=",
"body",
"[",
"key",
"]",
")",
"return"... | Return the value of a request input param `name` when present or `defaultValue`.
- Checks body params, ex: id=12, {"id":12}
- Checks query string params, ex: ?id=12
To utilize request bodies, `req.body`
should be an object. This can be done by enabling
the `bodyParser` middleware.
@param {String} key
@param {*} defa... | [
"Return",
"the",
"value",
"of",
"a",
"request",
"input",
"param",
"name",
"when",
"present",
"or",
"defaultValue",
"."
] | a4bad5a5f581743d1885405c11ae26600fb957af | https://github.com/quorrajs/Positron/blob/a4bad5a5f581743d1885405c11ae26600fb957af/lib/http/request.js#L227-L233 | train | |
quorrajs/Positron | lib/http/request.js | function (key) {
var keys = Array.isArray(key) ? key : arguments;
for (var i = 0; i < keys.length; i++) {
if (isEmptyString(keys[i])) return false;
}
return true;
} | javascript | function (key) {
var keys = Array.isArray(key) ? key : arguments;
for (var i = 0; i < keys.length; i++) {
if (isEmptyString(keys[i])) return false;
}
return true;
} | [
"function",
"(",
"key",
")",
"{",
"var",
"keys",
"=",
"Array",
".",
"isArray",
"(",
"key",
")",
"?",
"key",
":",
"arguments",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
... | Determine if the request contains a non-empty value for an input item.
@param {String|Array} key
@return bool | [
"Determine",
"if",
"the",
"request",
"contains",
"a",
"non",
"-",
"empty",
"value",
"for",
"an",
"input",
"item",
"."
] | a4bad5a5f581743d1885405c11ae26600fb957af | https://github.com/quorrajs/Positron/blob/a4bad5a5f581743d1885405c11ae26600fb957af/lib/http/request.js#L241-L249 | train | |
quorrajs/Positron | lib/http/request.js | function (key) {
var keys = Array.isArray(key) ? key : arguments;
var input = self.input.all();
var results = {};
for (var i = 0; i < keys.length; i++) {
results[keys[i]] = input[keys[i]];
}
return results;
} | javascript | function (key) {
var keys = Array.isArray(key) ? key : arguments;
var input = self.input.all();
var results = {};
for (var i = 0; i < keys.length; i++) {
results[keys[i]] = input[keys[i]];
}
return results;
} | [
"function",
"(",
"key",
")",
"{",
"var",
"keys",
"=",
"Array",
".",
"isArray",
"(",
"key",
")",
"?",
"key",
":",
"arguments",
";",
"var",
"input",
"=",
"self",
".",
"input",
".",
"all",
"(",
")",
";",
"var",
"results",
"=",
"{",
"}",
";",
"for"... | Get a subset of the items from the input data.
@param {Array|String} key
@return {Array} | [
"Get",
"a",
"subset",
"of",
"the",
"items",
"from",
"the",
"input",
"data",
"."
] | a4bad5a5f581743d1885405c11ae26600fb957af | https://github.com/quorrajs/Positron/blob/a4bad5a5f581743d1885405c11ae26600fb957af/lib/http/request.js#L265-L276 | train | |
quorrajs/Positron | lib/http/request.js | function (filter, keys) {
if (self.session) {
var flash = isset(filter) ? self.input[filter](keys) : self.input.all();
self.session.flash('_old_input', flash);
}
} | javascript | function (filter, keys) {
if (self.session) {
var flash = isset(filter) ? self.input[filter](keys) : self.input.all();
self.session.flash('_old_input', flash);
}
} | [
"function",
"(",
"filter",
",",
"keys",
")",
"{",
"if",
"(",
"self",
".",
"session",
")",
"{",
"var",
"flash",
"=",
"isset",
"(",
"filter",
")",
"?",
"self",
".",
"input",
"[",
"filter",
"]",
"(",
"keys",
")",
":",
"self",
".",
"input",
".",
"a... | Flash the input for the current request to the session.
@param {String} filter
@param {Object} keys | [
"Flash",
"the",
"input",
"for",
"the",
"current",
"request",
"to",
"the",
"session",
"."
] | a4bad5a5f581743d1885405c11ae26600fb957af | https://github.com/quorrajs/Positron/blob/a4bad5a5f581743d1885405c11ae26600fb957af/lib/http/request.js#L283-L289 | train | |
quorrajs/Positron | lib/http/request.js | function (key, defaultValue) {
var input = self.session.get('_old_input', []);
// Input that is flashed to the session can be easily retrieved by the
// developer, making repopulating old forms and the like much more
// convenient, since the request's previous input is a... | javascript | function (key, defaultValue) {
var input = self.session.get('_old_input', []);
// Input that is flashed to the session can be easily retrieved by the
// developer, making repopulating old forms and the like much more
// convenient, since the request's previous input is a... | [
"function",
"(",
"key",
",",
"defaultValue",
")",
"{",
"var",
"input",
"=",
"self",
".",
"session",
".",
"get",
"(",
"'_old_input'",
",",
"[",
"]",
")",
";",
"// Input that is flashed to the session can be easily retrieved by the",
"// developer, making repopulating old... | Retrieve an old input item.
@param {String} key
@param {*} defaultValue
@return {*} | [
"Retrieve",
"an",
"old",
"input",
"item",
"."
] | a4bad5a5f581743d1885405c11ae26600fb957af | https://github.com/quorrajs/Positron/blob/a4bad5a5f581743d1885405c11ae26600fb957af/lib/http/request.js#L338-L349 | train | |
quorrajs/Positron | lib/http/request.js | function (key) {
if (self.files) {
return self.files[key] ? self.files[key] : null;
}
} | javascript | function (key) {
if (self.files) {
return self.files[key] ? self.files[key] : null;
}
} | [
"function",
"(",
"key",
")",
"{",
"if",
"(",
"self",
".",
"files",
")",
"{",
"return",
"self",
".",
"files",
"[",
"key",
"]",
"?",
"self",
".",
"files",
"[",
"key",
"]",
":",
"null",
";",
"}",
"}"
] | Retrieve a file from the request.
@param {String} key
@return {*} | [
"Retrieve",
"a",
"file",
"from",
"the",
"request",
"."
] | a4bad5a5f581743d1885405c11ae26600fb957af | https://github.com/quorrajs/Positron/blob/a4bad5a5f581743d1885405c11ae26600fb957af/lib/http/request.js#L356-L360 | train | |
edloidas/roll-parser | src/object/Result.js | Result | function Result( notation, value, rolls ) {
this.notation = notation;
this.value = value;
this.rolls = rolls;
} | javascript | function Result( notation, value, rolls ) {
this.notation = notation;
this.value = value;
this.rolls = rolls;
} | [
"function",
"Result",
"(",
"notation",
",",
"value",
",",
"rolls",
")",
"{",
"this",
".",
"notation",
"=",
"notation",
";",
"this",
".",
"value",
"=",
"value",
";",
"this",
".",
"rolls",
"=",
"rolls",
";",
"}"
] | A class that represents a dice roll result
@class
@classdesc A class that represents a dice roll result
@since v2.0.0
@param {String} notation - A roll notation
@param {Number} value - A numeric representation of roll result, like total summ or success count
@param {Array} rolls - An array of rolls dome
@see Roll
@see ... | [
"A",
"class",
"that",
"represents",
"a",
"dice",
"roll",
"result"
] | 38912b298edb0a4d67ba1c796d7ac159ebaf7901 | https://github.com/edloidas/roll-parser/blob/38912b298edb0a4d67ba1c796d7ac159ebaf7901/src/object/Result.js#L13-L17 | train |
Holixus/nano-md5 | md5.js | bytesToWords | function bytesToWords(bytes) {
var bytes_count = bytes.length,
bits_count = bytes_count << 3,
words = new Uint32Array((bytes_count + 64) >>> 6 << 4);
for (var i = 0, n = bytes.length; i < n; ++i)
words[i >>> 2] |= bytes.charCodeAt(i) << ((i & 3) << 3);
words[bytes_count >> 2] |= 0x80 << (bits_count & 31)... | javascript | function bytesToWords(bytes) {
var bytes_count = bytes.length,
bits_count = bytes_count << 3,
words = new Uint32Array((bytes_count + 64) >>> 6 << 4);
for (var i = 0, n = bytes.length; i < n; ++i)
words[i >>> 2] |= bytes.charCodeAt(i) << ((i & 3) << 3);
words[bytes_count >> 2] |= 0x80 << (bits_count & 31)... | [
"function",
"bytesToWords",
"(",
"bytes",
")",
"{",
"var",
"bytes_count",
"=",
"bytes",
".",
"length",
",",
"bits_count",
"=",
"bytes_count",
"<<",
"3",
",",
"words",
"=",
"new",
"Uint32Array",
"(",
"(",
"bytes_count",
"+",
"64",
")",
">>>",
"6",
"<<",
... | converts bytes string to 32-bits words array padded with "1" and zeros and bits_length for MD5 message buffer | [
"converts",
"bytes",
"string",
"to",
"32",
"-",
"bits",
"words",
"array",
"padded",
"with",
"1",
"and",
"zeros",
"and",
"bits_length",
"for",
"MD5",
"message",
"buffer"
] | 058964cfeb6d9c14b0a20c1122f83e1d6b8870f1 | https://github.com/Holixus/nano-md5/blob/058964cfeb6d9c14b0a20c1122f83e1d6b8870f1/md5.js#L43-L52 | train |
clux/tiebreaker | tiebreaker.js | Id | function Id(s, r, m, isSimple) {
this.s = s;
this.r = r;
this.m = m;
Object.defineProperty(this, '_simple', {
value: isSimple
});
} | javascript | function Id(s, r, m, isSimple) {
this.s = s;
this.r = r;
this.m = m;
Object.defineProperty(this, '_simple', {
value: isSimple
});
} | [
"function",
"Id",
"(",
"s",
",",
"r",
",",
"m",
",",
"isSimple",
")",
"{",
"this",
".",
"s",
"=",
"s",
";",
"this",
".",
"r",
"=",
"r",
";",
"this",
".",
"m",
"=",
"m",
";",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"'_simple'",
",",... | for grouped breakers | [
"for",
"grouped",
"breakers"
] | ef5809b6016b544b4d2cbbdaebf73d6aff36a63c | https://github.com/clux/tiebreaker/blob/ef5809b6016b544b4d2cbbdaebf73d6aff36a63c/tiebreaker.js#L6-L13 | train |
clux/tiebreaker | tiebreaker.js | function (seedAry, match) {
var res = $.replicate(seedAry.length, []);
seedAry.forEach(function (xps, x) {
// NB: while we are not writing 1-1 from seedAry to res, we are always
// making sure not to overwrite what we had in previous iterations
if (xps.indexOf(match.p[0]) < 0) {
res[x] = res[x].co... | javascript | function (seedAry, match) {
var res = $.replicate(seedAry.length, []);
seedAry.forEach(function (xps, x) {
// NB: while we are not writing 1-1 from seedAry to res, we are always
// making sure not to overwrite what we had in previous iterations
if (xps.indexOf(match.p[0]) < 0) {
res[x] = res[x].co... | [
"function",
"(",
"seedAry",
",",
"match",
")",
"{",
"var",
"res",
"=",
"$",
".",
"replicate",
"(",
"seedAry",
".",
"length",
",",
"[",
"]",
")",
";",
"seedAry",
".",
"forEach",
"(",
"function",
"(",
"xps",
",",
"x",
")",
"{",
"// NB: while we are not... | split up the posAry entried cluster found in corresponding within section breakers | [
"split",
"up",
"the",
"posAry",
"entried",
"cluster",
"found",
"in",
"corresponding",
"within",
"section",
"breakers"
] | ef5809b6016b544b4d2cbbdaebf73d6aff36a63c | https://github.com/clux/tiebreaker/blob/ef5809b6016b544b4d2cbbdaebf73d6aff36a63c/tiebreaker.js#L107-L123 | train | |
feedhenry-raincatcher/raincatcher-angularjs | packages/angularjs-workorder/lib/workorder-list/workorder-list-controller.js | WorkorderListController | function WorkorderListController($scope, workorderService, workorderFlowService, $q, workorderStatusService) {
var self = this;
var _workorders = [];
self.workorders = [];
function refreshWorkorders() {
// Needs $q.when to trigger angular's change detection
workorderService.list().then(function(workor... | javascript | function WorkorderListController($scope, workorderService, workorderFlowService, $q, workorderStatusService) {
var self = this;
var _workorders = [];
self.workorders = [];
function refreshWorkorders() {
// Needs $q.when to trigger angular's change detection
workorderService.list().then(function(workor... | [
"function",
"WorkorderListController",
"(",
"$scope",
",",
"workorderService",
",",
"workorderFlowService",
",",
"$q",
",",
"workorderStatusService",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"_workorders",
"=",
"[",
"]",
";",
"self",
".",
"workorders",
... | Controller for listing Workorders
@constructor | [
"Controller",
"for",
"listing",
"Workorders"
] | b394689227901e18871ad9edd0ec226c5e6839e1 | https://github.com/feedhenry-raincatcher/raincatcher-angularjs/blob/b394689227901e18871ad9edd0ec226c5e6839e1/packages/angularjs-workorder/lib/workorder-list/workorder-list-controller.js#L10-L93 | train |
jaymell/nodeCf | src/utils.js | fileExists | async function fileExists(f) {
debug(`fileExists called with: ${JSON.stringify(arguments)}`);
try {
await fs.statAsync(f);
return f;
} catch (e) {
throw e;
}
} | javascript | async function fileExists(f) {
debug(`fileExists called with: ${JSON.stringify(arguments)}`);
try {
await fs.statAsync(f);
return f;
} catch (e) {
throw e;
}
} | [
"async",
"function",
"fileExists",
"(",
"f",
")",
"{",
"debug",
"(",
"`",
"${",
"JSON",
".",
"stringify",
"(",
"arguments",
")",
"}",
"`",
")",
";",
"try",
"{",
"await",
"fs",
".",
"statAsync",
"(",
"f",
")",
";",
"return",
"f",
";",
"}",
"catch"... | return filename if exists, else throw | [
"return",
"filename",
"if",
"exists",
"else",
"throw"
] | d0f499a1b0adf5c810c33698a66ef16db6bc590d | https://github.com/jaymell/nodeCf/blob/d0f499a1b0adf5c810c33698a66ef16db6bc590d/src/utils.js#L8-L16 | train |
jaymell/nodeCf | src/utils.js | execTasks | async function execTasks(tasks, taskType) {
debug(`execTasks: called for ${taskType}`);
if (!(_.isEmpty(tasks))) {
if (taskType) console.log(`running ${taskType}...`);
const output = await Promise.mapSeries(tasks, async(task) => {
const result = await execTask(task);
if (_.isString(result.stdout... | javascript | async function execTasks(tasks, taskType) {
debug(`execTasks: called for ${taskType}`);
if (!(_.isEmpty(tasks))) {
if (taskType) console.log(`running ${taskType}...`);
const output = await Promise.mapSeries(tasks, async(task) => {
const result = await execTask(task);
if (_.isString(result.stdout... | [
"async",
"function",
"execTasks",
"(",
"tasks",
",",
"taskType",
")",
"{",
"debug",
"(",
"`",
"${",
"taskType",
"}",
"`",
")",
";",
"if",
"(",
"!",
"(",
"_",
".",
"isEmpty",
"(",
"tasks",
")",
")",
")",
"{",
"if",
"(",
"taskType",
")",
"console",... | exec list of tasks, print stdout and stderr for each | [
"exec",
"list",
"of",
"tasks",
"print",
"stdout",
"and",
"stderr",
"for",
"each"
] | d0f499a1b0adf5c810c33698a66ef16db6bc590d | https://github.com/jaymell/nodeCf/blob/d0f499a1b0adf5c810c33698a66ef16db6bc590d/src/utils.js#L30-L46 | train |
edloidas/roll-parser | src/object/Roll.js | Roll | function Roll( dice = 20, count = 1, modifier = 0 ) {
this.dice = positiveInteger( dice );
this.count = positiveInteger( count );
this.modifier = normalizeInteger( modifier );
} | javascript | function Roll( dice = 20, count = 1, modifier = 0 ) {
this.dice = positiveInteger( dice );
this.count = positiveInteger( count );
this.modifier = normalizeInteger( modifier );
} | [
"function",
"Roll",
"(",
"dice",
"=",
"20",
",",
"count",
"=",
"1",
",",
"modifier",
"=",
"0",
")",
"{",
"this",
".",
"dice",
"=",
"positiveInteger",
"(",
"dice",
")",
";",
"this",
".",
"count",
"=",
"positiveInteger",
"(",
"count",
")",
";",
"this... | A class that represents a dice roll from D&D setting
@class
@classdesc A class that represents a dice roll from D&D setting
@since v2.0.0
@param {Number} dice - A number of dice faces
@param {Number} count - A number of dices
@param {Number} modifier - A modifier, that should be added/sustracted from result
@see WodRol... | [
"A",
"class",
"that",
"represents",
"a",
"dice",
"roll",
"from",
"D&D",
"setting"
] | 38912b298edb0a4d67ba1c796d7ac159ebaf7901 | https://github.com/edloidas/roll-parser/blob/38912b298edb0a4d67ba1c796d7ac159ebaf7901/src/object/Roll.js#L16-L20 | train |
YannickBochatay/JSYG | dist/JSYG.js | function(mtx) {
if (mtx && typeof mtx == "object" && mtx.mtx) mtx = mtx.mtx;
if (!mtx) return new Point(this.x,this.y);
var point = svg.createSVGPoint();
point.x = this.x;
point.y = this.y;
point = point.matrixTransform(mtx);
... | javascript | function(mtx) {
if (mtx && typeof mtx == "object" && mtx.mtx) mtx = mtx.mtx;
if (!mtx) return new Point(this.x,this.y);
var point = svg.createSVGPoint();
point.x = this.x;
point.y = this.y;
point = point.matrixTransform(mtx);
... | [
"function",
"(",
"mtx",
")",
"{",
"if",
"(",
"mtx",
"&&",
"typeof",
"mtx",
"==",
"\"object\"",
"&&",
"mtx",
".",
"mtx",
")",
"mtx",
"=",
"mtx",
".",
"mtx",
";",
"if",
"(",
"!",
"mtx",
")",
"return",
"new",
"Point",
"(",
"this",
".",
"x",
",",
... | Applique une matrice de transformation
@param mtx instance de JSYG.Matrix (ou SVGMatrix)
@returns nouvelle instance | [
"Applique",
"une",
"matrice",
"de",
"transformation"
] | b32a5368b57498b51c0c8261cf9a682e5ed6ff11 | https://github.com/YannickBochatay/JSYG/blob/b32a5368b57498b51c0c8261cf9a682e5ed6ff11/dist/JSYG.js#L623-L634 | train | |
YannickBochatay/JSYG | dist/JSYG.js | Matrix | function Matrix(arg) {
if (arg && arguments.length === 1) {
if (arg instanceof window.SVGMatrix) this.mtx = arg.scale(1);
else if (arg instanceof Matrix) this.mtx = arg.mtx.scale(1);
else if (typeof arg == "string") return Matrix.parse(arg);
else throw new... | javascript | function Matrix(arg) {
if (arg && arguments.length === 1) {
if (arg instanceof window.SVGMatrix) this.mtx = arg.scale(1);
else if (arg instanceof Matrix) this.mtx = arg.mtx.scale(1);
else if (typeof arg == "string") return Matrix.parse(arg);
else throw new... | [
"function",
"Matrix",
"(",
"arg",
")",
"{",
"if",
"(",
"arg",
"&&",
"arguments",
".",
"length",
"===",
"1",
")",
"{",
"if",
"(",
"arg",
"instanceof",
"window",
".",
"SVGMatrix",
")",
"this",
".",
"mtx",
"=",
"arg",
".",
"scale",
"(",
"1",
")",
";... | Constructeur de matrices
@param arg optionnel, si défini reprend les coefficients de l'argument. arg peut être
une instance de SVGMatrix (DOM SVG) ou de Matrix.
On peut également passer 6 arguments numériques pour définir chacun des coefficients.
@returns {Matrix} | [
"Constructeur",
"de",
"matrices"
] | b32a5368b57498b51c0c8261cf9a682e5ed6ff11 | https://github.com/YannickBochatay/JSYG/blob/b32a5368b57498b51c0c8261cf9a682e5ed6ff11/dist/JSYG.js#L766-L781 | train |
YannickBochatay/JSYG | dist/JSYG.js | function(str,tag,content) {
return str.replace(regexpTag(tag),function(str,p1,p2) { content && content.push(p2); return ''; });
} | javascript | function(str,tag,content) {
return str.replace(regexpTag(tag),function(str,p1,p2) { content && content.push(p2); return ''; });
} | [
"function",
"(",
"str",
",",
"tag",
",",
"content",
")",
"{",
"return",
"str",
".",
"replace",
"(",
"regexpTag",
"(",
"tag",
")",
",",
"function",
"(",
"str",
",",
"p1",
",",
"p2",
")",
"{",
"content",
"&&",
"content",
".",
"push",
"(",
"p2",
")"... | Retire les balises et leur contenu
@param {String} str chaîne à analyser
@param {String} tag nom de la balise à supprimer
@param {Array} content tableau qui sera rempli par le contenu des balises trouvées (les tableaux passent par référence)
@@returns {String} | [
"Retire",
"les",
"balises",
"et",
"leur",
"contenu"
] | b32a5368b57498b51c0c8261cf9a682e5ed6ff11 | https://github.com/YannickBochatay/JSYG/blob/b32a5368b57498b51c0c8261cf9a682e5ed6ff11/dist/JSYG.js#L1405-L1407 | train | |
alexyoung/pop | lib/filters.js | function(data) {
data = data.replace(/{% highlight ([^ ]*) %}/g, '<pre class="prettyprint lang-$1">');
data = data.replace(/{% endhighlight %}/g, '</pre>');
return data;
} | javascript | function(data) {
data = data.replace(/{% highlight ([^ ]*) %}/g, '<pre class="prettyprint lang-$1">');
data = data.replace(/{% endhighlight %}/g, '</pre>');
return data;
} | [
"function",
"(",
"data",
")",
"{",
"data",
"=",
"data",
".",
"replace",
"(",
"/",
"{% highlight ([^ ]*) %}",
"/",
"g",
",",
"'<pre class=\"prettyprint lang-$1\">'",
")",
";",
"data",
"=",
"data",
".",
"replace",
"(",
"/",
"{% endhighlight %}",
"/",
"g",
",",... | Replaces liquid tag highlight directives with prettyprint HTML tags.
@param {String} The text for a post
@return {String} | [
"Replaces",
"liquid",
"tag",
"highlight",
"directives",
"with",
"prettyprint",
"HTML",
"tags",
"."
] | 8a0b3f2605cb58e8ae6b34f1373dde00610e9858 | https://github.com/alexyoung/pop/blob/8a0b3f2605cb58e8ae6b34f1373dde00610e9858/lib/filters.js#L14-L18 | train | |
gagle/node-argp | lib/argp.js | function (){
if (!instance._once) return;
//Uncache the files
["index.js", "command.js", "argp.js", "body.js", "error.js", "wrap.js"]
.forEach (function (filename){
delete require.cache[__dirname + path.sep + filename];
});
//The user may have a reference to the instance so it sh... | javascript | function (){
if (!instance._once) return;
//Uncache the files
["index.js", "command.js", "argp.js", "body.js", "error.js", "wrap.js"]
.forEach (function (filename){
delete require.cache[__dirname + path.sep + filename];
});
//The user may have a reference to the instance so it sh... | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"instance",
".",
"_once",
")",
"return",
";",
"//Uncache the files",
"[",
"\"index.js\"",
",",
"\"command.js\"",
",",
"\"argp.js\"",
",",
"\"body.js\"",
",",
"\"error.js\"",
",",
"\"wrap.js\"",
"]",
".",
"forEach",
... | The Argp and Command instances execute this code | [
"The",
"Argp",
"and",
"Command",
"instances",
"execute",
"this",
"code"
] | e4a5a018c0b9fa8b370498c085e20fe8ff9fad5b | https://github.com/gagle/node-argp/blob/e4a5a018c0b9fa8b370498c085e20fe8ff9fad5b/lib/argp.js#L992-L1009 | train | |
feedhenry-raincatcher/raincatcher-angularjs | packages/angularjs-workflow/lib/workflow-process/workflow-process-begin/workflow-process-begin-controller.js | WorkflowProcessBeginController | function WorkflowProcessBeginController($state, workorderService, wfmService, $stateParams) {
var self = this;
var workorderId = $stateParams.workorderId;
workorderService.read(workorderId).then(function(workorder) {
self.workorder = workorder;
self.workflow = workorder.workflow;
self.results = worko... | javascript | function WorkflowProcessBeginController($state, workorderService, wfmService, $stateParams) {
var self = this;
var workorderId = $stateParams.workorderId;
workorderService.read(workorderId).then(function(workorder) {
self.workorder = workorder;
self.workflow = workorder.workflow;
self.results = worko... | [
"function",
"WorkflowProcessBeginController",
"(",
"$state",
",",
"workorderService",
",",
"wfmService",
",",
"$stateParams",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"workorderId",
"=",
"$stateParams",
".",
"workorderId",
";",
"workorderService",
".",
"r... | Controller for starting a workflow process.
@param $state
@param workflowService
@param $stateParams
@param $timeout
@constructor | [
"Controller",
"for",
"starting",
"a",
"workflow",
"process",
"."
] | b394689227901e18871ad9edd0ec226c5e6839e1 | https://github.com/feedhenry-raincatcher/raincatcher-angularjs/blob/b394689227901e18871ad9edd0ec226c5e6839e1/packages/angularjs-workflow/lib/workflow-process/workflow-process-begin/workflow-process-begin-controller.js#L12-L37 | train |
yaxia/json-edm-parser | parser.js | function (token, value) {
var self = this;
var emitString = false;
function additionalEmit(additionalKey, additionalValue) {
var oldKey = self.internalParser.key;
self.internalParser.key = additionalKey;
self.internalParser.onValue(additionalValue);
self.internalParser.key = oldKey;
}
if (tok... | javascript | function (token, value) {
var self = this;
var emitString = false;
function additionalEmit(additionalKey, additionalValue) {
var oldKey = self.internalParser.key;
self.internalParser.key = additionalKey;
self.internalParser.onValue(additionalValue);
self.internalParser.key = oldKey;
}
if (tok... | [
"function",
"(",
"token",
",",
"value",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"emitString",
"=",
"false",
";",
"function",
"additionalEmit",
"(",
"additionalKey",
",",
"additionalValue",
")",
"{",
"var",
"oldKey",
"=",
"self",
".",
"internalPar... | Handles the EDM types in the JSON object
1. Number will be treated as Edm.Int32 by default
2. Literal value 1.0 will be treated as Edm.Double
3. Others will be handled according to the literal value | [
"Handles",
"the",
"EDM",
"types",
"in",
"the",
"JSON",
"object",
"1",
".",
"Number",
"will",
"be",
"treated",
"as",
"Edm",
".",
"Int32",
"by",
"default",
"2",
".",
"Literal",
"value",
"1",
".",
"0",
"will",
"be",
"treated",
"as",
"Edm",
".",
"Double"... | b50508e0e2bf85f97a1ac281ed1f1425ad769816 | https://github.com/yaxia/json-edm-parser/blob/b50508e0e2bf85f97a1ac281ed1f1425ad769816/parser.js#L47-L82 | train | |
theThings/jailed-node | lib/JailedSite.js | JailedSite | function JailedSite(connection) {
this._interface = {}
this._remote = null
this._remoteUpdateHandler = function() {
}
this._getInterfaceHandler = function() {
}
this._interfaceSetAsRemoteHandler = function() {
}
this._disconnectHandler = function() {
}
this._store = new ReferenceStore
var _this... | javascript | function JailedSite(connection) {
this._interface = {}
this._remote = null
this._remoteUpdateHandler = function() {
}
this._getInterfaceHandler = function() {
}
this._interfaceSetAsRemoteHandler = function() {
}
this._disconnectHandler = function() {
}
this._store = new ReferenceStore
var _this... | [
"function",
"JailedSite",
"(",
"connection",
")",
"{",
"this",
".",
"_interface",
"=",
"{",
"}",
"this",
".",
"_remote",
"=",
"null",
"this",
".",
"_remoteUpdateHandler",
"=",
"function",
"(",
")",
"{",
"}",
"this",
".",
"_getInterfaceHandler",
"=",
"funct... | JailedSite object represents a single site in the
communication protocol between the application and the plugin
@param {Object} connection a special object allowing to send
and receive messages from the opposite site (basically it
should only provide send() and onMessage() methods) | [
"JailedSite",
"object",
"represents",
"a",
"single",
"site",
"in",
"the",
"communication",
"protocol",
"between",
"the",
"application",
"and",
"the",
"plugin"
] | 6e453d97e74fbd1c0b27b982084f6fd7c1aa0173 | https://github.com/theThings/jailed-node/blob/6e453d97e74fbd1c0b27b982084f6fd7c1aa0173/lib/JailedSite.js#L15-L41 | train |
edloidas/roll-parser | src/converter.js | convertToAnyRoll | function convertToAnyRoll( object = {}) {
const { again, success, fail } = object || {};
if ( isAbsent( again ) && isAbsent( success ) && isAbsent( fail )) {
return convertToRoll( object );
} // else
return convertToWodRoll( object );
} | javascript | function convertToAnyRoll( object = {}) {
const { again, success, fail } = object || {};
if ( isAbsent( again ) && isAbsent( success ) && isAbsent( fail )) {
return convertToRoll( object );
} // else
return convertToWodRoll( object );
} | [
"function",
"convertToAnyRoll",
"(",
"object",
"=",
"{",
"}",
")",
"{",
"const",
"{",
"again",
",",
"success",
",",
"fail",
"}",
"=",
"object",
"||",
"{",
"}",
";",
"if",
"(",
"isAbsent",
"(",
"again",
")",
"&&",
"isAbsent",
"(",
"success",
")",
"&... | Converts any arguments to `Roll` or `WodRoll` object.
If passed argument has `again`, `success` or `fail` property, the function will return `WodRoll`.
Otherwise, `Roll` will be returned.
@func
@alias convert
@since v2.1.0
@param {Object} object - `Roll`, `WodRoll` or similar object.
@return {Roll|WodRoll} Result of c... | [
"Converts",
"any",
"arguments",
"to",
"Roll",
"or",
"WodRoll",
"object",
".",
"If",
"passed",
"argument",
"has",
"again",
"success",
"or",
"fail",
"property",
"the",
"function",
"will",
"return",
"WodRoll",
".",
"Otherwise",
"Roll",
"will",
"be",
"returned",
... | 38912b298edb0a4d67ba1c796d7ac159ebaf7901 | https://github.com/edloidas/roll-parser/blob/38912b298edb0a4d67ba1c796d7ac159ebaf7901/src/converter.js#L32-L39 | train |
nightswapping/ng-image-upload | dist/ng-image-upload-template-in.js | imageFilter | function imageFilter (item /*{File|FileLikeObject}*/, options) {
var type = '|' + item.type.slice(item.type.lastIndexOf('/') + 1) + '|';
if ('|jpg|png|jpeg|bmp|gif|'.indexOf(type) === -1) {
var err = new Error('File extension not supported (' + type + ')');
vm.onUploadFinished(err);
... | javascript | function imageFilter (item /*{File|FileLikeObject}*/, options) {
var type = '|' + item.type.slice(item.type.lastIndexOf('/') + 1) + '|';
if ('|jpg|png|jpeg|bmp|gif|'.indexOf(type) === -1) {
var err = new Error('File extension not supported (' + type + ')');
vm.onUploadFinished(err);
... | [
"function",
"imageFilter",
"(",
"item",
"/*{File|FileLikeObject}*/",
",",
"options",
")",
"{",
"var",
"type",
"=",
"'|'",
"+",
"item",
".",
"type",
".",
"slice",
"(",
"item",
".",
"type",
".",
"lastIndexOf",
"(",
"'/'",
")",
"+",
"1",
")",
"+",
"'|'",
... | Set up filters to check that images should be uploaded before uploading them Filters out the items that are not pictures | [
"Set",
"up",
"filters",
"to",
"check",
"that",
"images",
"should",
"be",
"uploaded",
"before",
"uploading",
"them",
"Filters",
"out",
"the",
"items",
"that",
"are",
"not",
"pictures"
] | fd23bdc436651c3caff1917524c461bd7d2482ea | https://github.com/nightswapping/ng-image-upload/blob/fd23bdc436651c3caff1917524c461bd7d2482ea/dist/ng-image-upload-template-in.js#L37-L46 | train |
nightswapping/ng-image-upload | dist/ng-image-upload-template-in.js | sizeFilter | function sizeFilter (item /*{File|FileLikeObject}*/, options) {
var size = item.size,
// Use passed size limit or default to 10MB
sizeLimit = vm.sizeLimit || 10 * 1000 * 1000;
if (size > sizeLimit) {
var err = new Error('File too big (' + size + ')');
vm.onUploadFinished(... | javascript | function sizeFilter (item /*{File|FileLikeObject}*/, options) {
var size = item.size,
// Use passed size limit or default to 10MB
sizeLimit = vm.sizeLimit || 10 * 1000 * 1000;
if (size > sizeLimit) {
var err = new Error('File too big (' + size + ')');
vm.onUploadFinished(... | [
"function",
"sizeFilter",
"(",
"item",
"/*{File|FileLikeObject}*/",
",",
"options",
")",
"{",
"var",
"size",
"=",
"item",
".",
"size",
",",
"// Use passed size limit or default to 10MB",
"sizeLimit",
"=",
"vm",
".",
"sizeLimit",
"||",
"10",
"*",
"1000",
"*",
"10... | Filters out images that are larger than the specified or default limit | [
"Filters",
"out",
"images",
"that",
"are",
"larger",
"than",
"the",
"specified",
"or",
"default",
"limit"
] | fd23bdc436651c3caff1917524c461bd7d2482ea | https://github.com/nightswapping/ng-image-upload/blob/fd23bdc436651c3caff1917524c461bd7d2482ea/dist/ng-image-upload-template-in.js#L49-L59 | train |
nightswapping/ng-image-upload | dist/ng-image-upload-template-in.js | onLoad | function onLoad(event) {
var img = new Image();
img.onload = utils.getDimensions(canvas, vm.$storage);
img.src = event.target.result;
} | javascript | function onLoad(event) {
var img = new Image();
img.onload = utils.getDimensions(canvas, vm.$storage);
img.src = event.target.result;
} | [
"function",
"onLoad",
"(",
"event",
")",
"{",
"var",
"img",
"=",
"new",
"Image",
"(",
")",
";",
"img",
".",
"onload",
"=",
"utils",
".",
"getDimensions",
"(",
"canvas",
",",
"vm",
".",
"$storage",
")",
";",
"img",
".",
"src",
"=",
"event",
".",
"... | Wait for the reader to be loaded to get the right img.src | [
"Wait",
"for",
"the",
"reader",
"to",
"be",
"loaded",
"to",
"get",
"the",
"right",
"img",
".",
"src"
] | fd23bdc436651c3caff1917524c461bd7d2482ea | https://github.com/nightswapping/ng-image-upload/blob/fd23bdc436651c3caff1917524c461bd7d2482ea/dist/ng-image-upload-template-in.js#L131-L135 | train |
nightswapping/ng-image-upload | dist/ng-image-upload-template-in.js | function(file) {
var type = '|' + file.type.slice(file.type.lastIndexOf('/') + 1) + '|';
return '|jpg|png|jpeg|bmp|gif|'.indexOf(type) !== -1;
} | javascript | function(file) {
var type = '|' + file.type.slice(file.type.lastIndexOf('/') + 1) + '|';
return '|jpg|png|jpeg|bmp|gif|'.indexOf(type) !== -1;
} | [
"function",
"(",
"file",
")",
"{",
"var",
"type",
"=",
"'|'",
"+",
"file",
".",
"type",
".",
"slice",
"(",
"file",
".",
"type",
".",
"lastIndexOf",
"(",
"'/'",
")",
"+",
"1",
")",
"+",
"'|'",
";",
"return",
"'|jpg|png|jpeg|bmp|gif|'",
".",
"indexOf",... | Checks if the item is jpg, png, jpeg, bmp or a gif | [
"Checks",
"if",
"the",
"item",
"is",
"jpg",
"png",
"jpeg",
"bmp",
"or",
"a",
"gif"
] | fd23bdc436651c3caff1917524c461bd7d2482ea | https://github.com/nightswapping/ng-image-upload/blob/fd23bdc436651c3caff1917524c461bd7d2482ea/dist/ng-image-upload-template-in.js#L301-L304 | train | |
nightswapping/ng-image-upload | dist/ng-image-upload-template-in.js | function(dataURI) {
var binary = atob(dataURI.split(',')[1]);
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
var array = [];
for(var i = 0; i < binary.length; i++) {
array.push(binary.charCodeAt(i));
}
return new Blob([ new Uint8Array(arra... | javascript | function(dataURI) {
var binary = atob(dataURI.split(',')[1]);
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
var array = [];
for(var i = 0; i < binary.length; i++) {
array.push(binary.charCodeAt(i));
}
return new Blob([ new Uint8Array(arra... | [
"function",
"(",
"dataURI",
")",
"{",
"var",
"binary",
"=",
"atob",
"(",
"dataURI",
".",
"split",
"(",
"','",
")",
"[",
"1",
"]",
")",
";",
"var",
"mimeString",
"=",
"dataURI",
".",
"split",
"(",
"','",
")",
"[",
"0",
"]",
".",
"split",
"(",
"'... | Turns the Data URI into a blob so it can be sent over to the server | [
"Turns",
"the",
"Data",
"URI",
"into",
"a",
"blob",
"so",
"it",
"can",
"be",
"sent",
"over",
"to",
"the",
"server"
] | fd23bdc436651c3caff1917524c461bd7d2482ea | https://github.com/nightswapping/ng-image-upload/blob/fd23bdc436651c3caff1917524c461bd7d2482ea/dist/ng-image-upload-template-in.js#L308-L318 | train | |
rlivsey/fireplace | addon/model/promise-model.js | observePromise | function observePromise(proxy, promise) {
promise.then(value => {
set(proxy, 'isFulfilled', true);
value._settingFromFirebase = true;
set(proxy, 'content', value);
value._settingFromFirebase = false;
}, reason => {
set(proxy, 'isRejected', true);
set(proxy, 'reason', reason);
// don't re... | javascript | function observePromise(proxy, promise) {
promise.then(value => {
set(proxy, 'isFulfilled', true);
value._settingFromFirebase = true;
set(proxy, 'content', value);
value._settingFromFirebase = false;
}, reason => {
set(proxy, 'isRejected', true);
set(proxy, 'reason', reason);
// don't re... | [
"function",
"observePromise",
"(",
"proxy",
",",
"promise",
")",
"{",
"promise",
".",
"then",
"(",
"value",
"=>",
"{",
"set",
"(",
"proxy",
",",
"'isFulfilled'",
",",
"true",
")",
";",
"value",
".",
"_settingFromFirebase",
"=",
"true",
";",
"set",
"(",
... | reimplemented private method from Ember, but with setting _settingFromFirebase so we can avoid extra saves down the line | [
"reimplemented",
"private",
"method",
"from",
"Ember",
"but",
"with",
"setting",
"_settingFromFirebase",
"so",
"we",
"can",
"avoid",
"extra",
"saves",
"down",
"the",
"line"
] | 76cb3288dd99fd420b03547322b64b169caf595c | https://github.com/rlivsey/fireplace/blob/76cb3288dd99fd420b03547322b64b169caf595c/addon/model/promise-model.js#L10-L21 | train |
open-nata/apkparser | src/index.js | parse | async function parse(apkPath, target = `${os.tmpdir()}/apktoolDecodes`) {
const cmd = `java -jar ${apktoolPath} d ${apkPath} -f -o ${target}`
await shell(cmd)
const MainfestFilePath = `${target}/AndroidManifest.xml`
const doc = await parseManifest(MainfestFilePath)
return parseDoc(doc)
} | javascript | async function parse(apkPath, target = `${os.tmpdir()}/apktoolDecodes`) {
const cmd = `java -jar ${apktoolPath} d ${apkPath} -f -o ${target}`
await shell(cmd)
const MainfestFilePath = `${target}/AndroidManifest.xml`
const doc = await parseManifest(MainfestFilePath)
return parseDoc(doc)
} | [
"async",
"function",
"parse",
"(",
"apkPath",
",",
"target",
"=",
"`",
"${",
"os",
".",
"tmpdir",
"(",
")",
"}",
"`",
")",
"{",
"const",
"cmd",
"=",
"`",
"${",
"apktoolPath",
"}",
"${",
"apkPath",
"}",
"${",
"target",
"}",
"`",
"await",
"shell",
... | parse apk and return manifest
@param {String} apkPath apk path
@param {String} target target extract dir, default to ${os.tmpdir()}/apktoolDecodes
@return {Promise} resolve manifest | [
"parse",
"apk",
"and",
"return",
"manifest"
] | ca1e7bfc67ecaf094316d1cf949d88b84fd9928d | https://github.com/open-nata/apkparser/blob/ca1e7bfc67ecaf094316d1cf949d88b84fd9928d/src/index.js#L98-L104 | train |
VisionistInc/jibe | lib/models/Room.js | uniquenessValidator | function uniquenessValidator(values) {
if (values.presentAuthors) {
values = values.presentAuthors;
}
values.sort();
for (var i = 0; i < values.length - 1; i++) {
if (values[i] === values[i+1]) {
// can throw error or return false
// error allows supplying more detail
throw new Error(... | javascript | function uniquenessValidator(values) {
if (values.presentAuthors) {
values = values.presentAuthors;
}
values.sort();
for (var i = 0; i < values.length - 1; i++) {
if (values[i] === values[i+1]) {
// can throw error or return false
// error allows supplying more detail
throw new Error(... | [
"function",
"uniquenessValidator",
"(",
"values",
")",
"{",
"if",
"(",
"values",
".",
"presentAuthors",
")",
"{",
"values",
"=",
"values",
".",
"presentAuthors",
";",
"}",
"values",
".",
"sort",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"... | are all values unique? | [
"are",
"all",
"values",
"unique?"
] | 3a154c0d86a3bcf8980c5104daec099ec738a4e0 | https://github.com/VisionistInc/jibe/blob/3a154c0d86a3bcf8980c5104daec099ec738a4e0/lib/models/Room.js#L59-L74 | train |
alexyoung/pop | lib/pop.js | loadConfig | function loadConfig() {
var root = process.cwd()
, config = readConfig(path.join(root, '_config.json'));
config.root = root;
return config;
} | javascript | function loadConfig() {
var root = process.cwd()
, config = readConfig(path.join(root, '_config.json'));
config.root = root;
return config;
} | [
"function",
"loadConfig",
"(",
")",
"{",
"var",
"root",
"=",
"process",
".",
"cwd",
"(",
")",
",",
"config",
"=",
"readConfig",
"(",
"path",
".",
"join",
"(",
"root",
",",
"'_config.json'",
")",
")",
";",
"config",
".",
"root",
"=",
"root",
";",
"r... | Loads the config script and sets the local variable.
@return {Object} Config object | [
"Loads",
"the",
"config",
"script",
"and",
"sets",
"the",
"local",
"variable",
"."
] | 8a0b3f2605cb58e8ae6b34f1373dde00610e9858 | https://github.com/alexyoung/pop/blob/8a0b3f2605cb58e8ae6b34f1373dde00610e9858/lib/pop.js#L23-L28 | train |
alexyoung/pop | lib/pop.js | loadConfigAndGenerateSite | function loadConfigAndGenerateSite(useServer, port) {
var config = loadConfig();
if (port) config.port = port;
generateSite(config, useServer);
} | javascript | function loadConfigAndGenerateSite(useServer, port) {
var config = loadConfig();
if (port) config.port = port;
generateSite(config, useServer);
} | [
"function",
"loadConfigAndGenerateSite",
"(",
"useServer",
",",
"port",
")",
"{",
"var",
"config",
"=",
"loadConfig",
"(",
")",
";",
"if",
"(",
"port",
")",
"config",
".",
"port",
"=",
"port",
";",
"generateSite",
"(",
"config",
",",
"useServer",
")",
";... | Loads configuration then runs `generateSite`.
@params {Boolean} Use a HTTP sever? | [
"Loads",
"configuration",
"then",
"runs",
"generateSite",
"."
] | 8a0b3f2605cb58e8ae6b34f1373dde00610e9858 | https://github.com/alexyoung/pop/blob/8a0b3f2605cb58e8ae6b34f1373dde00610e9858/lib/pop.js#L35-L39 | train |
alexyoung/pop | lib/pop.js | generateSite | function generateSite(config, useServer) {
var fileMap = new FileMap(config)
, siteBuilder = new SiteBuilder(config)
, server = require(__dirname + '/server')(siteBuilder);
fileMap.walk();
fileMap.on('ready', function() {
siteBuilder.fileMap = fileMap;
siteBuilder.build();
});
siteBuilder.on... | javascript | function generateSite(config, useServer) {
var fileMap = new FileMap(config)
, siteBuilder = new SiteBuilder(config)
, server = require(__dirname + '/server')(siteBuilder);
fileMap.walk();
fileMap.on('ready', function() {
siteBuilder.fileMap = fileMap;
siteBuilder.build();
});
siteBuilder.on... | [
"function",
"generateSite",
"(",
"config",
",",
"useServer",
")",
"{",
"var",
"fileMap",
"=",
"new",
"FileMap",
"(",
"config",
")",
",",
"siteBuilder",
"=",
"new",
"SiteBuilder",
"(",
"config",
")",
",",
"server",
"=",
"require",
"(",
"__dirname",
"+",
"... | Runs `FileMap` and `SiteBuilder` based on the config.
@params {Object} Configuration options
@params {Boolean} Use a HTTP sever?
@return {SiteBuilder} A `SiteBuilder` instance | [
"Runs",
"FileMap",
"and",
"SiteBuilder",
"based",
"on",
"the",
"config",
"."
] | 8a0b3f2605cb58e8ae6b34f1373dde00610e9858 | https://github.com/alexyoung/pop/blob/8a0b3f2605cb58e8ae6b34f1373dde00610e9858/lib/pop.js#L48-L67 | train |
krundru/webdriver-runner | lib/util.js | saveScreenshot | function saveScreenshot(driver, dir, testTitle) {
const data = driver.takeScreenshot()
const fileName = testTitle.replace(/[^a-zA-Z0-9]/g, '_')
.concat('_')
.concat(new Date().getTime())
.concat('.png')
const fullPath = path.resolve(dir, fileName)
fs.writeFileSync(fullPath, data, 'base64')
report... | javascript | function saveScreenshot(driver, dir, testTitle) {
const data = driver.takeScreenshot()
const fileName = testTitle.replace(/[^a-zA-Z0-9]/g, '_')
.concat('_')
.concat(new Date().getTime())
.concat('.png')
const fullPath = path.resolve(dir, fileName)
fs.writeFileSync(fullPath, data, 'base64')
report... | [
"function",
"saveScreenshot",
"(",
"driver",
",",
"dir",
",",
"testTitle",
")",
"{",
"const",
"data",
"=",
"driver",
".",
"takeScreenshot",
"(",
")",
"const",
"fileName",
"=",
"testTitle",
".",
"replace",
"(",
"/",
"[^a-zA-Z0-9]",
"/",
"g",
",",
"'_'",
"... | Saves current screenshot from driver.
fileName is resolved from testTitle and saved under given directory.
And the same is reported to test-result report with `image` type.
Ex:
if (this.currentTest.state !== 'failed') {
wdUtil.saveScreenshot(driver, './', this.currentTest.title)
}
@param {Driver} driver sync'ed webd... | [
"Saves",
"current",
"screenshot",
"from",
"driver",
".",
"fileName",
"is",
"resolved",
"from",
"testTitle",
"and",
"saved",
"under",
"given",
"directory",
"."
] | fb9db651966f546d0f6864b317475f805db86a12 | https://github.com/krundru/webdriver-runner/blob/fb9db651966f546d0f6864b317475f805db86a12/lib/util.js#L19-L33 | train |
cjoudrey/wobot | lib/bot.js | function() {
var self = this;
self.jabber.on('data', function(buffer) {
console.log(' IN > ' + buffer.toString());
});
var origSend = this.jabber.send;
self.jabber.send = function(stanza) {
console.log(' OUT > ' + stanza);
return origSend.call(self.jabber, stanza);
};
} | javascript | function() {
var self = this;
self.jabber.on('data', function(buffer) {
console.log(' IN > ' + buffer.toString());
});
var origSend = this.jabber.send;
self.jabber.send = function(stanza) {
console.log(' OUT > ' + stanza);
return origSend.call(self.jabber, stanza);
};
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"jabber",
".",
"on",
"(",
"'data'",
",",
"function",
"(",
"buffer",
")",
"{",
"console",
".",
"log",
"(",
"' IN > '",
"+",
"buffer",
".",
"toString",
"(",
")",
")",
";",
"}... | Helper function that overrides the XMPP `send` method to allow incoming and outgoing debugging. | [
"Helper",
"function",
"that",
"overrides",
"the",
"XMPP",
"send",
"method",
"to",
"allow",
"incoming",
"and",
"outgoing",
"debugging",
"."
] | 7f044ec5e02a0707c637ce9bf5d77028796cda39 | https://github.com/cjoudrey/wobot/blob/7f044ec5e02a0707c637ce9bf5d77028796cda39/lib/bot.js#L38-L50 | train | |
cjoudrey/wobot | lib/bot.js | function() {
var self = this;
this.setAvailability('chat');
this.keepalive = setInterval(function() {
self.jabber.send(new xmpp.Message({}));
self.emit('ping');
}, 30000);
// load our profile to get name
this.getProfile(function(err, data) {
if (err) {
// This isn't t... | javascript | function() {
var self = this;
this.setAvailability('chat');
this.keepalive = setInterval(function() {
self.jabber.send(new xmpp.Message({}));
self.emit('ping');
}, 30000);
// load our profile to get name
this.getProfile(function(err, data) {
if (err) {
// This isn't t... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"this",
".",
"setAvailability",
"(",
"'chat'",
")",
";",
"this",
".",
"keepalive",
"=",
"setInterval",
"(",
"function",
"(",
")",
"{",
"self",
".",
"jabber",
".",
"send",
"(",
"new",
"xmpp",... | Whenever an XMPP connection is made, this function is responsible for triggering the `connect` event and starting the 30s anti-idle. It will also set the availability of the bot to `chat`. | [
"Whenever",
"an",
"XMPP",
"connection",
"is",
"made",
"this",
"function",
"is",
"responsible",
"for",
"triggering",
"the",
"connect",
"event",
"and",
"starting",
"the",
"30s",
"anti",
"-",
"idle",
".",
"It",
"will",
"also",
"set",
"the",
"availability",
"of"... | 7f044ec5e02a0707c637ce9bf5d77028796cda39 | https://github.com/cjoudrey/wobot/blob/7f044ec5e02a0707c637ce9bf5d77028796cda39/lib/bot.js#L61-L88 | train | |
cjoudrey/wobot | lib/bot.js | function(stanza) {
this.emit('data', stanza);
if (stanza.is('message') && stanza.attrs.type === 'groupchat') {
var body = stanza.getChildText('body');
if (!body) return;
// Ignore chat history
if (stanza.getChild('delay')) return;
var fromJid = new xmpp.JID(stanza.attrs.from);
... | javascript | function(stanza) {
this.emit('data', stanza);
if (stanza.is('message') && stanza.attrs.type === 'groupchat') {
var body = stanza.getChildText('body');
if (!body) return;
// Ignore chat history
if (stanza.getChild('delay')) return;
var fromJid = new xmpp.JID(stanza.attrs.from);
... | [
"function",
"(",
"stanza",
")",
"{",
"this",
".",
"emit",
"(",
"'data'",
",",
"stanza",
")",
";",
"if",
"(",
"stanza",
".",
"is",
"(",
"'message'",
")",
"&&",
"stanza",
".",
"attrs",
".",
"type",
"===",
"'groupchat'",
")",
"{",
"var",
"body",
"=",
... | This function is responsible for handling incoming XMPP messages. The `data` event will be triggered with the message for custom XMPP handling. The bot will parse the message and trigger the `message` event when it is a group chat message or the `privateMessage` event when it is a private message. | [
"This",
"function",
"is",
"responsible",
"for",
"handling",
"incoming",
"XMPP",
"messages",
".",
"The",
"data",
"event",
"will",
"be",
"triggered",
"with",
"the",
"message",
"for",
"custom",
"XMPP",
"handling",
".",
"The",
"bot",
"will",
"parse",
"the",
"mes... | 7f044ec5e02a0707c637ce9bf5d77028796cda39 | https://github.com/cjoudrey/wobot/blob/7f044ec5e02a0707c637ce9bf5d77028796cda39/lib/bot.js#L97-L153 | train | |
SLaks/csrf-crypto | csrf-crypto.js | getCookieToken | function getCookieToken(res) {
var value = res.req.cookies[cookieName(res.req)];
if (!value)
return false;
var parts = value.split('|');
// If the existing cookie is invalid, reject it.
if (parts.length !== 3)
return false;
// If the user data doesn't match this request's user, reject the cookie
... | javascript | function getCookieToken(res) {
var value = res.req.cookies[cookieName(res.req)];
if (!value)
return false;
var parts = value.split('|');
// If the existing cookie is invalid, reject it.
if (parts.length !== 3)
return false;
// If the user data doesn't match this request's user, reject the cookie
... | [
"function",
"getCookieToken",
"(",
"res",
")",
"{",
"var",
"value",
"=",
"res",
".",
"req",
".",
"cookies",
"[",
"cookieName",
"(",
"res",
".",
"req",
")",
"]",
";",
"if",
"(",
"!",
"value",
")",
"return",
"false",
";",
"var",
"parts",
"=",
"value"... | Private function that finds an existing cookie token and returns its salt value | [
"Private",
"function",
"that",
"finds",
"an",
"existing",
"cookie",
"token",
"and",
"returns",
"its",
"salt",
"value"
] | d6b7cfa76652be74d3692b2080ad668b08556892 | https://github.com/SLaks/csrf-crypto/blob/d6b7cfa76652be74d3692b2080ad668b08556892/csrf-crypto.js#L96-L121 | train |
SLaks/csrf-crypto | csrf-crypto.js | getFormToken | function getFormToken() {
/*jshint validthis:true */
if (this._csrfFormToken)
return this._csrfFormToken;
checkSecure(this.req);
var cookieToken = getCookieToken(this) || createCookie(this);
var salt = base64Random(saltSize);
var hasher = crypto.createHmac(options.algorithm, formKey);
hasher.update(c... | javascript | function getFormToken() {
/*jshint validthis:true */
if (this._csrfFormToken)
return this._csrfFormToken;
checkSecure(this.req);
var cookieToken = getCookieToken(this) || createCookie(this);
var salt = base64Random(saltSize);
var hasher = crypto.createHmac(options.algorithm, formKey);
hasher.update(c... | [
"function",
"getFormToken",
"(",
")",
"{",
"/*jshint validthis:true */",
"if",
"(",
"this",
".",
"_csrfFormToken",
")",
"return",
"this",
".",
"_csrfFormToken",
";",
"checkSecure",
"(",
"this",
".",
"req",
")",
";",
"var",
"cookieToken",
"=",
"getCookieToken",
... | Gets a new form token for the current response.
This function must be called on the response object.
@returns {String} An opaque token to include with new requests. | [
"Gets",
"a",
"new",
"form",
"token",
"for",
"the",
"current",
"response",
".",
"This",
"function",
"must",
"be",
"called",
"on",
"the",
"response",
"object",
"."
] | d6b7cfa76652be74d3692b2080ad668b08556892 | https://github.com/SLaks/csrf-crypto/blob/d6b7cfa76652be74d3692b2080ad668b08556892/csrf-crypto.js#L140-L156 | train |
SLaks/csrf-crypto | csrf-crypto.js | verifyFormToken | function verifyFormToken(formToken) {
/*jshint validthis:true */
checkSecure(this);
// If we already cached this token, we know that it's valid.
// If we validate two different tokens for the same request,
// this won't incorrectly skip the second one.
if (this.res._csrfFormToken && this.res._csrfFormToken... | javascript | function verifyFormToken(formToken) {
/*jshint validthis:true */
checkSecure(this);
// If we already cached this token, we know that it's valid.
// If we validate two different tokens for the same request,
// this won't incorrectly skip the second one.
if (this.res._csrfFormToken && this.res._csrfFormToken... | [
"function",
"verifyFormToken",
"(",
"formToken",
")",
"{",
"/*jshint validthis:true */",
"checkSecure",
"(",
"this",
")",
";",
"// If we already cached this token, we know that it's valid.",
"// If we validate two different tokens for the same request,",
"// this won't incorrectly skip t... | Verifies a form token submitted with the current request.
This function must be called on the request object.
@returns {Boolean} True if the form token matches the cookie in the request. | [
"Verifies",
"a",
"form",
"token",
"submitted",
"with",
"the",
"current",
"request",
".",
"This",
"function",
"must",
"be",
"called",
"on",
"the",
"request",
"object",
"."
] | d6b7cfa76652be74d3692b2080ad668b08556892 | https://github.com/SLaks/csrf-crypto/blob/d6b7cfa76652be74d3692b2080ad668b08556892/csrf-crypto.js#L164-L201 | train |
jaymell/nodeCf | src/nodeCf.js | getTemplateFile | async function getTemplateFile(templateDir, stackName) {
const f = await Promise.any(
_.map(['.yml', '.yaml', '.json', ''], async(ext) =>
await utils.fileExists(`${path.join(templateDir, stackName)}${ext}`)));
if (f) {
return f;
}
throw new Error(`Stack template "${stackName}" not found!`);
} | javascript | async function getTemplateFile(templateDir, stackName) {
const f = await Promise.any(
_.map(['.yml', '.yaml', '.json', ''], async(ext) =>
await utils.fileExists(`${path.join(templateDir, stackName)}${ext}`)));
if (f) {
return f;
}
throw new Error(`Stack template "${stackName}" not found!`);
} | [
"async",
"function",
"getTemplateFile",
"(",
"templateDir",
",",
"stackName",
")",
"{",
"const",
"f",
"=",
"await",
"Promise",
".",
"any",
"(",
"_",
".",
"map",
"(",
"[",
"'.yml'",
",",
"'.yaml'",
",",
"'.json'",
",",
"''",
"]",
",",
"async",
"(",
"e... | look for template having multiple possible file extensions | [
"look",
"for",
"template",
"having",
"multiple",
"possible",
"file",
"extensions"
] | d0f499a1b0adf5c810c33698a66ef16db6bc590d | https://github.com/jaymell/nodeCf/blob/d0f499a1b0adf5c810c33698a66ef16db6bc590d/src/nodeCf.js#L239-L247 | train |
fti-technology/node-skytap | lib/skytap.js | Skytap | function Skytap () {
this.audit = new Audit(this);
this.environments = new Environments(this);
this.ips = new Ips(this);
this.networks = new Networks(this);
this.projects = new Projects(this);
this.templates = new Templates(this);
this.usage = new Usage(this);
this.... | javascript | function Skytap () {
this.audit = new Audit(this);
this.environments = new Environments(this);
this.ips = new Ips(this);
this.networks = new Networks(this);
this.projects = new Projects(this);
this.templates = new Templates(this);
this.usage = new Usage(this);
this.... | [
"function",
"Skytap",
"(",
")",
"{",
"this",
".",
"audit",
"=",
"new",
"Audit",
"(",
"this",
")",
";",
"this",
".",
"environments",
"=",
"new",
"Environments",
"(",
"this",
")",
";",
"this",
".",
"ips",
"=",
"new",
"Ips",
"(",
"this",
")",
";",
"... | Skytap API Library
@param {Object} config | [
"Skytap",
"API",
"Library"
] | 1d5af43ee26aabfebe52627ea09f291c99923a49 | https://github.com/fti-technology/node-skytap/blob/1d5af43ee26aabfebe52627ea09f291c99923a49/lib/skytap.js#L23-L38 | 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.