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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
alexindigo/configly | modifiers.js | date | function date(value) {
var parsedDate = Date.parse(value);
// couldn't parse it
if (typeOf(parsedDate) != 'number') {
return throwModifierError('date', value, {message: 'Invalid Date'});
}
return new Date(parsedDate);
} | javascript | function date(value) {
var parsedDate = Date.parse(value);
// couldn't parse it
if (typeOf(parsedDate) != 'number') {
return throwModifierError('date', value, {message: 'Invalid Date'});
}
return new Date(parsedDate);
} | [
"function",
"date",
"(",
"value",
")",
"{",
"var",
"parsedDate",
"=",
"Date",
".",
"parse",
"(",
"value",
")",
";",
"// couldn't parse it",
"if",
"(",
"typeOf",
"(",
"parsedDate",
")",
"!=",
"'number'",
")",
"{",
"return",
"throwModifierError",
"(",
"'date... | Parses provided string as a Date string
@param {string} value - Date string to parse
@returns {Date} - Date object representaion of the provided string | [
"Parses",
"provided",
"string",
"as",
"a",
"Date",
"string"
] | 026423ba0e036cf8ca33cd2fd160df519715272d | https://github.com/alexindigo/configly/blob/026423ba0e036cf8ca33cd2fd160df519715272d/modifiers.js#L62-L71 | train |
alexindigo/configly | modifiers.js | float | function float(value) {
var parsedFloat = Number.parseFloat(value);
// couldn't parse it
if (typeOf(parsedFloat) != 'number') {
return throwModifierError('float', value, {message: 'Invalid Float'});
}
return parsedFloat;
} | javascript | function float(value) {
var parsedFloat = Number.parseFloat(value);
// couldn't parse it
if (typeOf(parsedFloat) != 'number') {
return throwModifierError('float', value, {message: 'Invalid Float'});
}
return parsedFloat;
} | [
"function",
"float",
"(",
"value",
")",
"{",
"var",
"parsedFloat",
"=",
"Number",
".",
"parseFloat",
"(",
"value",
")",
";",
"// couldn't parse it",
"if",
"(",
"typeOf",
"(",
"parsedFloat",
")",
"!=",
"'number'",
")",
"{",
"return",
"throwModifierError",
"("... | Parses provided string as Float
@param {string} value - string to parse
@returns {float} - Parsed float number | [
"Parses",
"provided",
"string",
"as",
"Float"
] | 026423ba0e036cf8ca33cd2fd160df519715272d | https://github.com/alexindigo/configly/blob/026423ba0e036cf8ca33cd2fd160df519715272d/modifiers.js#L96-L105 | train |
joshwcomeau/redux-favicon | src/favicon-middleware.js | favicoIntegration | function favicoIntegration(options = defaultFavicoOptions) {
// Create a new Favico integration.
// Initially this was going to be a singleton object, but I realized there
// may be cases where you want several different types of notifications.
// The middleware does not yet support multiple instances, but it s... | javascript | function favicoIntegration(options = defaultFavicoOptions) {
// Create a new Favico integration.
// Initially this was going to be a singleton object, but I realized there
// may be cases where you want several different types of notifications.
// The middleware does not yet support multiple instances, but it s... | [
"function",
"favicoIntegration",
"(",
"options",
"=",
"defaultFavicoOptions",
")",
"{",
"// Create a new Favico integration.",
"// Initially this was going to be a singleton object, but I realized there",
"// may be cases where you want several different types of notifications.",
"// The middl... | This integration communicates directly with Favico.js to set the badge. | [
"This",
"integration",
"communicates",
"directly",
"with",
"Favico",
".",
"js",
"to",
"set",
"the",
"badge",
"."
] | 655f9810f9745bc9e44c1b827e4653e24660a7b6 | https://github.com/joshwcomeau/redux-favicon/blob/655f9810f9745bc9e44c1b827e4653e24660a7b6/src/favicon-middleware.js#L38-L108 | train |
alexindigo/configly | lib/parse_tokens.js | parseTokens | function parseTokens(entry, env)
{
var found = 0;
if (entry.indexOf('${') > -1)
{
entry = entry.replace(/\$\{([^}]+)\}/g, function(match, token)
{
var value = getVar.call(this, token, env);
// need to have `found` counter
// to see if any of the variables
// in the string were re... | javascript | function parseTokens(entry, env)
{
var found = 0;
if (entry.indexOf('${') > -1)
{
entry = entry.replace(/\$\{([^}]+)\}/g, function(match, token)
{
var value = getVar.call(this, token, env);
// need to have `found` counter
// to see if any of the variables
// in the string were re... | [
"function",
"parseTokens",
"(",
"entry",
",",
"env",
")",
"{",
"var",
"found",
"=",
"0",
";",
"if",
"(",
"entry",
".",
"indexOf",
"(",
"'${'",
")",
">",
"-",
"1",
")",
"{",
"entry",
"=",
"entry",
".",
"replace",
"(",
"/",
"\\$\\{([^}]+)\\}",
"/",
... | Parses provided config entry
to find variable placeholders
and replace them with values
@param {string} entry - string to parse
@param {object} env - object to search within
@returns {string|boolean} - replaced string or empty string
if no matching variables found | [
"Parses",
"provided",
"config",
"entry",
"to",
"find",
"variable",
"placeholders",
"and",
"replace",
"them",
"with",
"values"
] | 026423ba0e036cf8ca33cd2fd160df519715272d | https://github.com/alexindigo/configly/blob/026423ba0e036cf8ca33cd2fd160df519715272d/lib/parse_tokens.js#L18-L44 | train |
Deathspike/npm-build-tools | src/utilities/cmd.js | globs | function globs(sourcePath, ignore, commands, done) {
var expression = /\$g\[(.+?)\]/g;
var result = [];
each(commands, function(command, next) {
var map = {};
var match;
var matches = [];
while ((match = expression.exec(command))) matches.push(match);
each(matches, function(patternMatch, next)... | javascript | function globs(sourcePath, ignore, commands, done) {
var expression = /\$g\[(.+?)\]/g;
var result = [];
each(commands, function(command, next) {
var map = {};
var match;
var matches = [];
while ((match = expression.exec(command))) matches.push(match);
each(matches, function(patternMatch, next)... | [
"function",
"globs",
"(",
"sourcePath",
",",
"ignore",
",",
"commands",
",",
"done",
")",
"{",
"var",
"expression",
"=",
"/",
"\\$g\\[(.+?)\\]",
"/",
"g",
";",
"var",
"result",
"=",
"[",
"]",
";",
"each",
"(",
"commands",
",",
"function",
"(",
"command... | Iterates through each command and expands each glob pattern.
@param {string} sourcePath
@param {Array.<string>} commands
@param {function(Error, Array.<string>=)} done | [
"Iterates",
"through",
"each",
"command",
"and",
"expands",
"each",
"glob",
"pattern",
"."
] | caf2a0933b5900e34dc093f34b070a5b947cce39 | https://github.com/Deathspike/npm-build-tools/blob/caf2a0933b5900e34dc093f34b070a5b947cce39/src/utilities/cmd.js#L35-L60 | train |
Deathspike/npm-build-tools | src/utilities/cmd.js | loadConfig | function loadConfig(done) {
fs.stat('package.json', function(err) {
if (err) return done(undefined, {});
fs.readFile('package.json', function(err, contents) {
if (err) return done(err);
try {
done(undefined, JSON.parse(contents).config || {});
} catch(err) {
done(err);
... | javascript | function loadConfig(done) {
fs.stat('package.json', function(err) {
if (err) return done(undefined, {});
fs.readFile('package.json', function(err, contents) {
if (err) return done(err);
try {
done(undefined, JSON.parse(contents).config || {});
} catch(err) {
done(err);
... | [
"function",
"loadConfig",
"(",
"done",
")",
"{",
"fs",
".",
"stat",
"(",
"'package.json'",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"return",
"done",
"(",
"undefined",
",",
"{",
"}",
")",
";",
"fs",
".",
"readFile",
"(",
"'pack... | Loads the configuration.
@param {function(Error, Object=)} | [
"Loads",
"the",
"configuration",
"."
] | caf2a0933b5900e34dc093f34b070a5b947cce39 | https://github.com/Deathspike/npm-build-tools/blob/caf2a0933b5900e34dc093f34b070a5b947cce39/src/utilities/cmd.js#L66-L78 | train |
Deathspike/npm-build-tools | src/utilities/cmd.js | loadOptions | function loadOptions(entries) {
var options = new Command().version(require('../../package').version);
entries.forEach(function(entry) {
options.option(entry.option, entry.text, entry.parse);
});
return options.parse(process.argv);
} | javascript | function loadOptions(entries) {
var options = new Command().version(require('../../package').version);
entries.forEach(function(entry) {
options.option(entry.option, entry.text, entry.parse);
});
return options.parse(process.argv);
} | [
"function",
"loadOptions",
"(",
"entries",
")",
"{",
"var",
"options",
"=",
"new",
"Command",
"(",
")",
".",
"version",
"(",
"require",
"(",
"'../../package'",
")",
".",
"version",
")",
";",
"entries",
".",
"forEach",
"(",
"function",
"(",
"entry",
")",
... | Loads the options.
@param {Array.<{option: string, text: string}>} entries
@returns {Object.<string, *>} | [
"Loads",
"the",
"options",
"."
] | caf2a0933b5900e34dc093f34b070a5b947cce39 | https://github.com/Deathspike/npm-build-tools/blob/caf2a0933b5900e34dc093f34b070a5b947cce39/src/utilities/cmd.js#L85-L91 | train |
Deathspike/npm-build-tools | src/utilities/cmd.js | variables | function variables(root, config, done) {
var expression = /\$v\[(.+?)\]/g;
each(Object.keys(root), function(key, next) {
var value = root[key];
if (typeof value === 'object') return variables(value, config, next);
if (typeof value !== 'string') return next();
root[key] = value.replace(expression, fu... | javascript | function variables(root, config, done) {
var expression = /\$v\[(.+?)\]/g;
each(Object.keys(root), function(key, next) {
var value = root[key];
if (typeof value === 'object') return variables(value, config, next);
if (typeof value !== 'string') return next();
root[key] = value.replace(expression, fu... | [
"function",
"variables",
"(",
"root",
",",
"config",
",",
"done",
")",
"{",
"var",
"expression",
"=",
"/",
"\\$v\\[(.+?)\\]",
"/",
"g",
";",
"each",
"(",
"Object",
".",
"keys",
"(",
"root",
")",
",",
"function",
"(",
"key",
",",
"next",
")",
"{",
"... | Expands each variable.
@param {Object} root
@param {Object.<string, string>} config
@param {function()} done | [
"Expands",
"each",
"variable",
"."
] | caf2a0933b5900e34dc093f34b070a5b947cce39 | https://github.com/Deathspike/npm-build-tools/blob/caf2a0933b5900e34dc093f34b070a5b947cce39/src/utilities/cmd.js#L99-L110 | train |
aheckmann/observed | lib/observed.js | Observable | function Observable (subject, parent, prefix) {
if ('object' != typeof subject)
throw new TypeError('object expected. got: ' + typeof subject);
if (!(this instanceof Observable))
return new Observable(subject, parent, prefix);
debug('new', subject, !!parent, prefix);
Emitter.call(this);
this._bind(... | javascript | function Observable (subject, parent, prefix) {
if ('object' != typeof subject)
throw new TypeError('object expected. got: ' + typeof subject);
if (!(this instanceof Observable))
return new Observable(subject, parent, prefix);
debug('new', subject, !!parent, prefix);
Emitter.call(this);
this._bind(... | [
"function",
"Observable",
"(",
"subject",
",",
"parent",
",",
"prefix",
")",
"{",
"if",
"(",
"'object'",
"!=",
"typeof",
"subject",
")",
"throw",
"new",
"TypeError",
"(",
"'object expected. got: '",
"+",
"typeof",
"subject",
")",
";",
"if",
"(",
"!",
"(",
... | Observable constructor.
The passed `subject` will be observed for changes to
all properties, included nested objects and arrays.
An `EventEmitter` will be returned. This emitter will
emit the following events:
- add
- update
- delete
- reconfigure
// - setPrototype?
@param {Object} subject
@param {Observable} [par... | [
"Observable",
"constructor",
"."
] | 834ddd5be149aeb2b1ee9ce231cf3e836b9ea4bf | https://github.com/aheckmann/observed/blob/834ddd5be149aeb2b1ee9ce231cf3e836b9ea4bf/lib/observed.js#L31-L42 | train |
http-auth/apache-md5 | src/index.js | to64 | function to64(index, count) {
let result = '';
while (--count >= 0) { // Result char count.
result += itoa64[index & 63]; // Get corresponding char.
index = index >> 6; // Move to next one.
}
return result;
} | javascript | function to64(index, count) {
let result = '';
while (--count >= 0) { // Result char count.
result += itoa64[index & 63]; // Get corresponding char.
index = index >> 6; // Move to next one.
}
return result;
} | [
"function",
"to64",
"(",
"index",
",",
"count",
")",
"{",
"let",
"result",
"=",
"''",
";",
"while",
"(",
"--",
"count",
">=",
"0",
")",
"{",
"// Result char count.",
"result",
"+=",
"itoa64",
"[",
"index",
"&",
"63",
"]",
";",
"// Get corresponding char.... | To 64 bit version. | [
"To",
"64",
"bit",
"version",
"."
] | 27aa6364d50eeb93dfaf0b2a090c0cf035b32b49 | https://github.com/http-auth/apache-md5/blob/27aa6364d50eeb93dfaf0b2a090c0cf035b32b49/src/index.js#L10-L19 | train |
http-auth/apache-md5 | src/index.js | getSalt | function getSalt(inputSalt) {
let salt = '';
if (inputSalt) {
// Remove $apr1$ token and extract salt.
salt = inputSalt.split('$')[2];
} else {
while(salt.length < 8) { // Random 8 chars.
let rchIndex = Math.floor((Math.random() * 64));
salt += itoa64[rchInde... | javascript | function getSalt(inputSalt) {
let salt = '';
if (inputSalt) {
// Remove $apr1$ token and extract salt.
salt = inputSalt.split('$')[2];
} else {
while(salt.length < 8) { // Random 8 chars.
let rchIndex = Math.floor((Math.random() * 64));
salt += itoa64[rchInde... | [
"function",
"getSalt",
"(",
"inputSalt",
")",
"{",
"let",
"salt",
"=",
"''",
";",
"if",
"(",
"inputSalt",
")",
"{",
"// Remove $apr1$ token and extract salt.",
"salt",
"=",
"inputSalt",
".",
"split",
"(",
"'$'",
")",
"[",
"2",
"]",
";",
"}",
"else",
"{",... | Returns salt. | [
"Returns",
"salt",
"."
] | 27aa6364d50eeb93dfaf0b2a090c0cf035b32b49 | https://github.com/http-auth/apache-md5/blob/27aa6364d50eeb93dfaf0b2a090c0cf035b32b49/src/index.js#L22-L36 | train |
http-auth/apache-md5 | src/index.js | getPassword | function getPassword(final) {
// Encrypted pass.
let epass = '';
epass += to64((final.charCodeAt(0) << 16) | (final.charCodeAt(6) << 8) | final.charCodeAt(12), 4);
epass += to64((final.charCodeAt(1) << 16) | (final.charCodeAt(7) << 8) | final.charCodeAt(13), 4);
epass += to64((final.charCodeAt(2) <... | javascript | function getPassword(final) {
// Encrypted pass.
let epass = '';
epass += to64((final.charCodeAt(0) << 16) | (final.charCodeAt(6) << 8) | final.charCodeAt(12), 4);
epass += to64((final.charCodeAt(1) << 16) | (final.charCodeAt(7) << 8) | final.charCodeAt(13), 4);
epass += to64((final.charCodeAt(2) <... | [
"function",
"getPassword",
"(",
"final",
")",
"{",
"// Encrypted pass.",
"let",
"epass",
"=",
"''",
";",
"epass",
"+=",
"to64",
"(",
"(",
"final",
".",
"charCodeAt",
"(",
"0",
")",
"<<",
"16",
")",
"|",
"(",
"final",
".",
"charCodeAt",
"(",
"6",
")",... | Returns password. | [
"Returns",
"password",
"."
] | 27aa6364d50eeb93dfaf0b2a090c0cf035b32b49 | https://github.com/http-auth/apache-md5/blob/27aa6364d50eeb93dfaf0b2a090c0cf035b32b49/src/index.js#L39-L51 | train |
serban-petrescu/ui5-jsx-rm | src/transformer.js | getElementTag | function getElementTag(node) {
if (node.openingElement && t.isJSXIdentifier(node.openingElement.name)) {
return node.openingElement.name.name;
} else {
error(node.openingElement, "Unable to parse opening tag.");
}
} | javascript | function getElementTag(node) {
if (node.openingElement && t.isJSXIdentifier(node.openingElement.name)) {
return node.openingElement.name.name;
} else {
error(node.openingElement, "Unable to parse opening tag.");
}
} | [
"function",
"getElementTag",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"openingElement",
"&&",
"t",
".",
"isJSXIdentifier",
"(",
"node",
".",
"openingElement",
".",
"name",
")",
")",
"{",
"return",
"node",
".",
"openingElement",
".",
"name",
".",
"n... | Retrieve the tag string for an element node. | [
"Retrieve",
"the",
"tag",
"string",
"for",
"an",
"element",
"node",
"."
] | 57beb245a6c70d7fad75a69242deb0a1ee7f3ee0 | https://github.com/serban-petrescu/ui5-jsx-rm/blob/57beb245a6c70d7fad75a69242deb0a1ee7f3ee0/src/transformer.js#L8-L14 | train |
serban-petrescu/ui5-jsx-rm | src/transformer.js | transformSpecialAttribute | function transformSpecialAttribute(name, attribute) {
if (t.isJSXExpressionContainer(attribute.value)) {
let value = attribute.value.expression;
switch (name) {
case "ui5ControlData":
renderer.renderControlData(value);
break;
... | javascript | function transformSpecialAttribute(name, attribute) {
if (t.isJSXExpressionContainer(attribute.value)) {
let value = attribute.value.expression;
switch (name) {
case "ui5ControlData":
renderer.renderControlData(value);
break;
... | [
"function",
"transformSpecialAttribute",
"(",
"name",
",",
"attribute",
")",
"{",
"if",
"(",
"t",
".",
"isJSXExpressionContainer",
"(",
"attribute",
".",
"value",
")",
")",
"{",
"let",
"value",
"=",
"attribute",
".",
"value",
".",
"expression",
";",
"switch"... | Transforms the special attribute with the given name. | [
"Transforms",
"the",
"special",
"attribute",
"with",
"the",
"given",
"name",
"."
] | 57beb245a6c70d7fad75a69242deb0a1ee7f3ee0 | https://github.com/serban-petrescu/ui5-jsx-rm/blob/57beb245a6c70d7fad75a69242deb0a1ee7f3ee0/src/transformer.js#L19-L38 | train |
serban-petrescu/ui5-jsx-rm | src/transformer.js | transformStyles | function transformStyles(value) {
if (t.isStringLiteral(value)) {
renderer.renderAttributeExpression("style", value);
} else if (t.isJSXExpressionContainer(value)){
renderer.handleStyles(value.expression);
} else {
error(value, "Unknown style specification typ... | javascript | function transformStyles(value) {
if (t.isStringLiteral(value)) {
renderer.renderAttributeExpression("style", value);
} else if (t.isJSXExpressionContainer(value)){
renderer.handleStyles(value.expression);
} else {
error(value, "Unknown style specification typ... | [
"function",
"transformStyles",
"(",
"value",
")",
"{",
"if",
"(",
"t",
".",
"isStringLiteral",
"(",
"value",
")",
")",
"{",
"renderer",
".",
"renderAttributeExpression",
"(",
"\"style\"",
",",
"value",
")",
";",
"}",
"else",
"if",
"(",
"t",
".",
"isJSXEx... | Transforms the style specification in either a plain attribute rendering
or a handler function call. | [
"Transforms",
"the",
"style",
"specification",
"in",
"either",
"a",
"plain",
"attribute",
"rendering",
"or",
"a",
"handler",
"function",
"call",
"."
] | 57beb245a6c70d7fad75a69242deb0a1ee7f3ee0 | https://github.com/serban-petrescu/ui5-jsx-rm/blob/57beb245a6c70d7fad75a69242deb0a1ee7f3ee0/src/transformer.js#L44-L52 | train |
serban-petrescu/ui5-jsx-rm | src/transformer.js | transformClasses | function transformClasses(value) {
if (t.isStringLiteral(value)) {
value.value.split(" ").forEach(function(cls) {
renderer.addClass(cls);
});
} else if (t.isJSXExpressionContainer(value)){
renderer.handleClasses(value.expression);
} else {
... | javascript | function transformClasses(value) {
if (t.isStringLiteral(value)) {
value.value.split(" ").forEach(function(cls) {
renderer.addClass(cls);
});
} else if (t.isJSXExpressionContainer(value)){
renderer.handleClasses(value.expression);
} else {
... | [
"function",
"transformClasses",
"(",
"value",
")",
"{",
"if",
"(",
"t",
".",
"isStringLiteral",
"(",
"value",
")",
")",
"{",
"value",
".",
"value",
".",
"split",
"(",
"\" \"",
")",
".",
"forEach",
"(",
"function",
"(",
"cls",
")",
"{",
"renderer",
".... | Transforms the class specification into either a sequence of add-class
renderer calls or a handler function call. | [
"Transforms",
"the",
"class",
"specification",
"into",
"either",
"a",
"sequence",
"of",
"add",
"-",
"class",
"renderer",
"calls",
"or",
"a",
"handler",
"function",
"call",
"."
] | 57beb245a6c70d7fad75a69242deb0a1ee7f3ee0 | https://github.com/serban-petrescu/ui5-jsx-rm/blob/57beb245a6c70d7fad75a69242deb0a1ee7f3ee0/src/transformer.js#L58-L68 | train |
davidfig/pixel | convert.js | draw | function draw(c, frame)
{
const pixels = frame.data
for (let y = 0; y < frame.height; y++)
{
for (let x = 0; x < frame.width; x++)
{
const color = pixels[x + y * frame.width]
if (typeof color !== 'undefined')
{
let hex = color.toString(16)
... | javascript | function draw(c, frame)
{
const pixels = frame.data
for (let y = 0; y < frame.height; y++)
{
for (let x = 0; x < frame.width; x++)
{
const color = pixels[x + y * frame.width]
if (typeof color !== 'undefined')
{
let hex = color.toString(16)
... | [
"function",
"draw",
"(",
"c",
",",
"frame",
")",
"{",
"const",
"pixels",
"=",
"frame",
".",
"data",
"for",
"(",
"let",
"y",
"=",
"0",
";",
"y",
"<",
"frame",
".",
"height",
";",
"y",
"++",
")",
"{",
"for",
"(",
"let",
"x",
"=",
"0",
";",
"x... | used by RenderSheet to render the frame
@private
@param {CanvasRenderingContext2D} c
@param {object} frame | [
"used",
"by",
"RenderSheet",
"to",
"render",
"the",
"frame"
] | 2713a7922f9e7f4c008c0fc4ec398e9b1b64aace | https://github.com/davidfig/pixel/blob/2713a7922f9e7f4c008c0fc4ec398e9b1b64aace/convert.js#L34-L55 | train |
SungardAS/condensation | lib/condensation/util.js | taskNameFunc | function taskNameFunc() {
var validParts = _.dropWhile(_.flatten([this.prefix,arguments]),function(item) {
return !item;
});
return validParts.join(this.separator);
} | javascript | function taskNameFunc() {
var validParts = _.dropWhile(_.flatten([this.prefix,arguments]),function(item) {
return !item;
});
return validParts.join(this.separator);
} | [
"function",
"taskNameFunc",
"(",
")",
"{",
"var",
"validParts",
"=",
"_",
".",
"dropWhile",
"(",
"_",
".",
"flatten",
"(",
"[",
"this",
".",
"prefix",
",",
"arguments",
"]",
")",
",",
"function",
"(",
"item",
")",
"{",
"return",
"!",
"item",
";",
"... | Make a task name
@param {...string} str - Parts of the task name that will be joined together
@returns {string} - The full task name | [
"Make",
"a",
"task",
"name"
] | 4595b3d7ac7f7adbc7a8c049aa5fac18e59bf016 | https://github.com/SungardAS/condensation/blob/4595b3d7ac7f7adbc7a8c049aa5fac18e59bf016/lib/condensation/util.js#L25-L30 | train |
MoOx/postcss-message-helpers | index.js | sourceString | function sourceString(source) {
var message = "<css input>"
if (source) {
if (source.input && source.input.file) {
message = source.input.file
}
if (source.start) {
message += ":" + source.start.line + ":" + source.start.column
}
}
return message
} | javascript | function sourceString(source) {
var message = "<css input>"
if (source) {
if (source.input && source.input.file) {
message = source.input.file
}
if (source.start) {
message += ":" + source.start.line + ":" + source.start.column
}
}
return message
} | [
"function",
"sourceString",
"(",
"source",
")",
"{",
"var",
"message",
"=",
"\"<css input>\"",
"if",
"(",
"source",
")",
"{",
"if",
"(",
"source",
".",
"input",
"&&",
"source",
".",
"input",
".",
"file",
")",
"{",
"message",
"=",
"source",
".",
"input"... | Returns GNU style source
@param {Object} source | [
"Returns",
"GNU",
"style",
"source"
] | 5f9d44c18e0aba563ac13550617378b69a4f9744 | https://github.com/MoOx/postcss-message-helpers/blob/5f9d44c18e0aba563ac13550617378b69a4f9744/index.js#L20-L32 | train |
Z-Team-Pro/ZTeam-Chat | public/js/main.js | scrollToBottom | function scrollToBottom(){
var it= jQuery('#testit');
var message= jQuery('#messages');
var newMessage= message.children('li:last-child')
var clientH= it.prop('clientHeight');
var scrollTop=it.prop('scrollTop');
var scrollH=it.prop('scrollHeight');
var newMessageH= newMessage.innerHeight();
var prevmessageH=newMessa... | javascript | function scrollToBottom(){
var it= jQuery('#testit');
var message= jQuery('#messages');
var newMessage= message.children('li:last-child')
var clientH= it.prop('clientHeight');
var scrollTop=it.prop('scrollTop');
var scrollH=it.prop('scrollHeight');
var newMessageH= newMessage.innerHeight();
var prevmessageH=newMessa... | [
"function",
"scrollToBottom",
"(",
")",
"{",
"var",
"it",
"=",
"jQuery",
"(",
"'#testit'",
")",
";",
"var",
"message",
"=",
"jQuery",
"(",
"'#messages'",
")",
";",
"var",
"newMessage",
"=",
"message",
".",
"children",
"(",
"'li:last-child'",
")",
"var",
... | scroll to bottom | [
"scroll",
"to",
"bottom"
] | e6557a36cb20ecf040688c1e30bb6aac5fab438a | https://github.com/Z-Team-Pro/ZTeam-Chat/blob/e6557a36cb20ecf040688c1e30bb6aac5fab438a/public/js/main.js#L46-L62 | train |
kengz/neo4jKB | lib/constrain.js | function(res) {
var author = _.get(res, 'envelope.user.id') || 'bot'
return _.zipObject(cons.mandatoryFields, ['hash', 'test', author, cons.now()])
} | javascript | function(res) {
var author = _.get(res, 'envelope.user.id') || 'bot'
return _.zipObject(cons.mandatoryFields, ['hash', 'test', author, cons.now()])
} | [
"function",
"(",
"res",
")",
"{",
"var",
"author",
"=",
"_",
".",
"get",
"(",
"res",
",",
"'envelope.user.id'",
")",
"||",
"'bot'",
"return",
"_",
".",
"zipObject",
"(",
"cons",
".",
"mandatoryFields",
",",
"[",
"'hash'",
",",
"'test'",
",",
"author",
... | Generate an object of mandatoryFields with default values for extension.
@private
@param {JSON} [res] For the robot to extract user id.
@return {JSON} mandatoryFieldsObject with default values. | [
"Generate",
"an",
"object",
"of",
"mandatoryFields",
"with",
"default",
"values",
"for",
"extension",
"."
] | 8762390ac81974afc6bb44a2dd3c44b44aaaa09a | https://github.com/kengz/neo4jKB/blob/8762390ac81974afc6bb44a2dd3c44b44aaaa09a/lib/constrain.js#L101-L104 | train | |
kengz/neo4jKB | lib/constrain.js | function(str) {
var startsWith = !_.isNull(str.match(wOpsHeadRe))
return startsWith & cons.isLegalSentence(str)
} | javascript | function(str) {
var startsWith = !_.isNull(str.match(wOpsHeadRe))
return startsWith & cons.isLegalSentence(str)
} | [
"function",
"(",
"str",
")",
"{",
"var",
"startsWith",
"=",
"!",
"_",
".",
"isNull",
"(",
"str",
".",
"match",
"(",
"wOpsHeadRe",
")",
")",
"return",
"startsWith",
"&",
"cons",
".",
"isLegalSentence",
"(",
"str",
")",
"}"
] | Check if the string is a WHERE operation string and is legal.
@private
@param {string} str WHERE sentence.
@return {Boolean} | [
"Check",
"if",
"the",
"string",
"is",
"a",
"WHERE",
"operation",
"string",
"and",
"is",
"legal",
"."
] | 8762390ac81974afc6bb44a2dd3c44b44aaaa09a | https://github.com/kengz/neo4jKB/blob/8762390ac81974afc6bb44a2dd3c44b44aaaa09a/lib/constrain.js#L349-L352 | train | |
kengz/neo4jKB | lib/constrain.js | function(str) {
var startsWith = !_.isNull(str.match(sOpsHeadRe))
return startsWith & cons.isLegalSentence(str)
} | javascript | function(str) {
var startsWith = !_.isNull(str.match(sOpsHeadRe))
return startsWith & cons.isLegalSentence(str)
} | [
"function",
"(",
"str",
")",
"{",
"var",
"startsWith",
"=",
"!",
"_",
".",
"isNull",
"(",
"str",
".",
"match",
"(",
"sOpsHeadRe",
")",
")",
"return",
"startsWith",
"&",
"cons",
".",
"isLegalSentence",
"(",
"str",
")",
"}"
] | Check if the string is a SET|REMOVE operation string and is legal.
@private
@param {string} str WHERE sentence.
@return {Boolean} | [
"Check",
"if",
"the",
"string",
"is",
"a",
"SET|REMOVE",
"operation",
"string",
"and",
"is",
"legal",
"."
] | 8762390ac81974afc6bb44a2dd3c44b44aaaa09a | https://github.com/kengz/neo4jKB/blob/8762390ac81974afc6bb44a2dd3c44b44aaaa09a/lib/constrain.js#L360-L363 | train | |
kengz/neo4jKB | lib/constrain.js | function(str) {
var startsWith = !_.isNull(str.match(rOpsHeadRe))
return startsWith & cons.isLegalSentence(str)
} | javascript | function(str) {
var startsWith = !_.isNull(str.match(rOpsHeadRe))
return startsWith & cons.isLegalSentence(str)
} | [
"function",
"(",
"str",
")",
"{",
"var",
"startsWith",
"=",
"!",
"_",
".",
"isNull",
"(",
"str",
".",
"match",
"(",
"rOpsHeadRe",
")",
")",
"return",
"startsWith",
"&",
"cons",
".",
"isLegalSentence",
"(",
"str",
")",
"}"
] | Check if the string is a RETURN|DELETE|DETACH DELETE operation string and is legal.
@private
@param {string} str RETURN sentence.
@return {Boolean} | [
"Check",
"if",
"the",
"string",
"is",
"a",
"RETURN|DELETE|DETACH",
"DELETE",
"operation",
"string",
"and",
"is",
"legal",
"."
] | 8762390ac81974afc6bb44a2dd3c44b44aaaa09a | https://github.com/kengz/neo4jKB/blob/8762390ac81974afc6bb44a2dd3c44b44aaaa09a/lib/constrain.js#L371-L374 | train | |
kengz/neo4jKB | lib/constrain.js | function(str) {
var startsWith = !_.isNull(str.match(pOpsHeadRe))
return startsWith & cons.isLegalSentence(str)
} | javascript | function(str) {
var startsWith = !_.isNull(str.match(pOpsHeadRe))
return startsWith & cons.isLegalSentence(str)
} | [
"function",
"(",
"str",
")",
"{",
"var",
"startsWith",
"=",
"!",
"_",
".",
"isNull",
"(",
"str",
".",
"match",
"(",
"pOpsHeadRe",
")",
")",
"return",
"startsWith",
"&",
"cons",
".",
"isLegalSentence",
"(",
"str",
")",
"}"
] | Check if the string is a SHORTESTPATH|ALLSHORTESTPATHS operation string and is legal.
@private
@param {string} str PATH sentence.
@return {Boolean} | [
"Check",
"if",
"the",
"string",
"is",
"a",
"SHORTESTPATH|ALLSHORTESTPATHS",
"operation",
"string",
"and",
"is",
"legal",
"."
] | 8762390ac81974afc6bb44a2dd3c44b44aaaa09a | https://github.com/kengz/neo4jKB/blob/8762390ac81974afc6bb44a2dd3c44b44aaaa09a/lib/constrain.js#L382-L385 | train | |
Deathspike/npm-build-tools | src/run.js | run | function run(commands, done) {
var children = [];
var pending = commands.length || 1;
var err;
each(commands, function(command, next) {
children.push(childProcess.spawn(shell[0], [shell[1], command], {
stdio: ['pipe', process.stdout, process.stderr]
}).on('exit', function(code) {
if (!err &&... | javascript | function run(commands, done) {
var children = [];
var pending = commands.length || 1;
var err;
each(commands, function(command, next) {
children.push(childProcess.spawn(shell[0], [shell[1], command], {
stdio: ['pipe', process.stdout, process.stderr]
}).on('exit', function(code) {
if (!err &&... | [
"function",
"run",
"(",
"commands",
",",
"done",
")",
"{",
"var",
"children",
"=",
"[",
"]",
";",
"var",
"pending",
"=",
"commands",
".",
"length",
"||",
"1",
";",
"var",
"err",
";",
"each",
"(",
"commands",
",",
"function",
"(",
"command",
",",
"n... | Runs each command in parallel.
@param {Array.<string>} commands
@param {function(Error=)} done | [
"Runs",
"each",
"command",
"in",
"parallel",
"."
] | caf2a0933b5900e34dc093f34b070a5b947cce39 | https://github.com/Deathspike/npm-build-tools/blob/caf2a0933b5900e34dc093f34b070a5b947cce39/src/run.js#L31-L50 | train |
Deathspike/npm-build-tools | src/run.js | watch | function watch(sourcePath, patterns, commands) {
var isBusy = false;
var isPending = false;
var runnable = function() {
if (isBusy) return (isPending = true);
isBusy = true;
run(commands, function(err) {
if (err) console.error(err.stack || err);
isBusy = false;
if (isPending) runnabl... | javascript | function watch(sourcePath, patterns, commands) {
var isBusy = false;
var isPending = false;
var runnable = function() {
if (isBusy) return (isPending = true);
isBusy = true;
run(commands, function(err) {
if (err) console.error(err.stack || err);
isBusy = false;
if (isPending) runnabl... | [
"function",
"watch",
"(",
"sourcePath",
",",
"patterns",
",",
"commands",
")",
"{",
"var",
"isBusy",
"=",
"false",
";",
"var",
"isPending",
"=",
"false",
";",
"var",
"runnable",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"isBusy",
")",
"return",
"(",
... | Watches the patterns in the source path and runs commands on changes.
@param {string} sourcePath
@param {(Array.<string>|string)} patterns
@param {Array.<string>} commands | [
"Watches",
"the",
"patterns",
"in",
"the",
"source",
"path",
"and",
"runs",
"commands",
"on",
"changes",
"."
] | caf2a0933b5900e34dc093f34b070a5b947cce39 | https://github.com/Deathspike/npm-build-tools/blob/caf2a0933b5900e34dc093f34b070a5b947cce39/src/run.js#L74-L90 | train |
draggett/arena-webhub | webhub.js | fail | function fail(status, description, response) {
let body = status + ' ' + description;
console.log(body);
response.writeHead(status, {
'Content-Type': 'text/plain',
'Access-Control-Allow-Origin': '*',
'Content-Length': body.length
});
response.write(body);
response.end();
} | javascript | function fail(status, description, response) {
let body = status + ' ' + description;
console.log(body);
response.writeHead(status, {
'Content-Type': 'text/plain',
'Access-Control-Allow-Origin': '*',
'Content-Length': body.length
});
response.write(body);
response.end();
} | [
"function",
"fail",
"(",
"status",
",",
"description",
",",
"response",
")",
"{",
"let",
"body",
"=",
"status",
"+",
"' '",
"+",
"description",
";",
"console",
".",
"log",
"(",
"body",
")",
";",
"response",
".",
"writeHead",
"(",
"status",
",",
"{",
... | helper for http server | [
"helper",
"for",
"http",
"server"
] | 85335f197147e608d3899e3c1665188dddd178ec | https://github.com/draggett/arena-webhub/blob/85335f197147e608d3899e3c1665188dddd178ec/webhub.js#L701-L712 | train |
draggett/arena-webhub | webhub.js | authorised | function authorised(request) {
// JWT is usually passed via an HTTP header
let token = request.headers.authorization;
// For EventSource and WebSocket, JWT is passed as a URL parameter
if (token === undefined) {
let url = URL.parse(request.url, true);
if (url.query)
token = url.q... | javascript | function authorised(request) {
// JWT is usually passed via an HTTP header
let token = request.headers.authorization;
// For EventSource and WebSocket, JWT is passed as a URL parameter
if (token === undefined) {
let url = URL.parse(request.url, true);
if (url.query)
token = url.q... | [
"function",
"authorised",
"(",
"request",
")",
"{",
"// JWT is usually passed via an HTTP header",
"let",
"token",
"=",
"request",
".",
"headers",
".",
"authorization",
";",
"// For EventSource and WebSocket, JWT is passed as a URL parameter",
"if",
"(",
"token",
"===",
"un... | helper for HTTP request authorisation | [
"helper",
"for",
"HTTP",
"request",
"authorisation"
] | 85335f197147e608d3899e3c1665188dddd178ec | https://github.com/draggett/arena-webhub/blob/85335f197147e608d3899e3c1665188dddd178ec/webhub.js#L730-L744 | train |
draggett/arena-webhub | webhub.js | ws_send | function ws_send(socket, data) {
//console.log("send: " + data);
let header;
let payload = new Buffer.from(data);
const len = payload.length;
if (len <= 125) {
header = new Buffer.alloc(2);
header[1] = len;
} else if (len <= 0xffff) {
header = new Buffer.alloc(4);
header[1] = 126;
header[2] = (len >> ... | javascript | function ws_send(socket, data) {
//console.log("send: " + data);
let header;
let payload = new Buffer.from(data);
const len = payload.length;
if (len <= 125) {
header = new Buffer.alloc(2);
header[1] = len;
} else if (len <= 0xffff) {
header = new Buffer.alloc(4);
header[1] = 126;
header[2] = (len >> ... | [
"function",
"ws_send",
"(",
"socket",
",",
"data",
")",
"{",
"//console.log(\"send: \" + data);",
"let",
"header",
";",
"let",
"payload",
"=",
"new",
"Buffer",
".",
"from",
"(",
"data",
")",
";",
"const",
"len",
"=",
"payload",
".",
"length",
";",
"if",
... | send string data to web socket | [
"send",
"string",
"data",
"to",
"web",
"socket"
] | 85335f197147e608d3899e3c1665188dddd178ec | https://github.com/draggett/arena-webhub/blob/85335f197147e608d3899e3c1665188dddd178ec/webhub.js#L1186-L1217 | train |
draggett/arena-webhub | webhub.js | ws_receive | function ws_receive(raw)
{
let data = unpack(raw); // string to byte array
let fin = (data[0] & 128) == 128;
let opcode = data[0] & 15;
let isMasked = (data[1] & 128) == 128;
let dataLength = data[1] & 127;
let start = 2;
let length = data.length;
let output = "";
if (dataLength == 126)
star... | javascript | function ws_receive(raw)
{
let data = unpack(raw); // string to byte array
let fin = (data[0] & 128) == 128;
let opcode = data[0] & 15;
let isMasked = (data[1] & 128) == 128;
let dataLength = data[1] & 127;
let start = 2;
let length = data.length;
let output = "";
if (dataLength == 126)
star... | [
"function",
"ws_receive",
"(",
"raw",
")",
"{",
"let",
"data",
"=",
"unpack",
"(",
"raw",
")",
";",
"// string to byte array",
"let",
"fin",
"=",
"(",
"data",
"[",
"0",
"]",
"&",
"128",
")",
"==",
"128",
";",
"let",
"opcode",
"=",
"data",
"[",
"0",... | return message as string | [
"return",
"message",
"as",
"string"
] | 85335f197147e608d3899e3c1665188dddd178ec | https://github.com/draggett/arena-webhub/blob/85335f197147e608d3899e3c1665188dddd178ec/webhub.js#L1220-L1253 | train |
Deathspike/npm-build-tools | src/concat.js | concat | function concat(divider, sourcePath, relativePaths, done) {
var writeDivider = false;
each(relativePaths, function(relativePath, next) {
var absoluteSourcePath = path.resolve(sourcePath, relativePath);
var readStream = fs.createReadStream(absoluteSourcePath);
if (writeDivider) process.stdout.write(divid... | javascript | function concat(divider, sourcePath, relativePaths, done) {
var writeDivider = false;
each(relativePaths, function(relativePath, next) {
var absoluteSourcePath = path.resolve(sourcePath, relativePath);
var readStream = fs.createReadStream(absoluteSourcePath);
if (writeDivider) process.stdout.write(divid... | [
"function",
"concat",
"(",
"divider",
",",
"sourcePath",
",",
"relativePaths",
",",
"done",
")",
"{",
"var",
"writeDivider",
"=",
"false",
";",
"each",
"(",
"relativePaths",
",",
"function",
"(",
"relativePath",
",",
"next",
")",
"{",
"var",
"absoluteSourceP... | Concatenate files from the source path into the standard output.
@param {string} divider
@param {string} sourcePath
@param {Array.<string>} relativePaths
@param {function(Error)=} done | [
"Concatenate",
"files",
"from",
"the",
"source",
"path",
"into",
"the",
"standard",
"output",
"."
] | caf2a0933b5900e34dc093f34b070a5b947cce39 | https://github.com/Deathspike/npm-build-tools/blob/caf2a0933b5900e34dc093f34b070a5b947cce39/src/concat.js#L37-L46 | train |
rbackhouse/mpdjs | cordova/mpdjs/jsbuild/r.js | function (path) {
//There has to be an easier way to do this.
var i, part, ary,
firstChar = path.charAt(0);
if (firstChar !== '/' &&
firstChar !== '\\' &&
path.indexOf(':') === -1) {
... | javascript | function (path) {
//There has to be an easier way to do this.
var i, part, ary,
firstChar = path.charAt(0);
if (firstChar !== '/' &&
firstChar !== '\\' &&
path.indexOf(':') === -1) {
... | [
"function",
"(",
"path",
")",
"{",
"//There has to be an easier way to do this.",
"var",
"i",
",",
"part",
",",
"ary",
",",
"firstChar",
"=",
"path",
".",
"charAt",
"(",
"0",
")",
";",
"if",
"(",
"firstChar",
"!==",
"'/'",
"&&",
"firstChar",
"!==",
"'\\\\'... | Remove . and .. from paths, normalize on front slashes | [
"Remove",
".",
"and",
"..",
"from",
"paths",
"normalize",
"on",
"front",
"slashes"
] | 23fde33a7a24ba8d516c623643e359a25a46259c | https://github.com/rbackhouse/mpdjs/blob/23fde33a7a24ba8d516c623643e359a25a46259c/cordova/mpdjs/jsbuild/r.js#L155-L180 | train | |
rbackhouse/mpdjs | cordova/mpdjs/jsbuild/r.js | function(dest, source) {
lang.eachProp(source, function (value, prop) {
if (typeof value === 'object' && value &&
!lang.isArray(value) && !lang.isFunction(value) &&
!(value instanceof RegExp)) {
if (!dest[prop]) {
... | javascript | function(dest, source) {
lang.eachProp(source, function (value, prop) {
if (typeof value === 'object' && value &&
!lang.isArray(value) && !lang.isFunction(value) &&
!(value instanceof RegExp)) {
if (!dest[prop]) {
... | [
"function",
"(",
"dest",
",",
"source",
")",
"{",
"lang",
".",
"eachProp",
"(",
"source",
",",
"function",
"(",
"value",
",",
"prop",
")",
"{",
"if",
"(",
"typeof",
"value",
"===",
"'object'",
"&&",
"value",
"&&",
"!",
"lang",
".",
"isArray",
"(",
... | Does a deep mix of source into dest, where source values override
dest values if a winner is needed.
@param {Object} dest destination object that receives the mixed
values.
@param {Object} source source object contributing properties to mix
in.
@return {[Object]} returns dest object with the modification. | [
"Does",
"a",
"deep",
"mix",
"of",
"source",
"into",
"dest",
"where",
"source",
"values",
"override",
"dest",
"values",
"if",
"a",
"winner",
"is",
"needed",
"."
] | 23fde33a7a24ba8d516c623643e359a25a46259c | https://github.com/rbackhouse/mpdjs/blob/23fde33a7a24ba8d516c623643e359a25a46259c/cordova/mpdjs/jsbuild/r.js#L2796-L2811 | train | |
rbackhouse/mpdjs | cordova/mpdjs/jsbuild/r.js | SourceMap | function SourceMap(options) {
options = defaults(options, {
file : null,
root : null,
orig : null,
orig_line_diff : 0,
dest_line_diff : 0,
});
var generator = new MOZ_SourceMap.SourceMapGenerator({
file : options.file,
sourceRoot : options.root
... | javascript | function SourceMap(options) {
options = defaults(options, {
file : null,
root : null,
orig : null,
orig_line_diff : 0,
dest_line_diff : 0,
});
var generator = new MOZ_SourceMap.SourceMapGenerator({
file : options.file,
sourceRoot : options.root
... | [
"function",
"SourceMap",
"(",
"options",
")",
"{",
"options",
"=",
"defaults",
"(",
"options",
",",
"{",
"file",
":",
"null",
",",
"root",
":",
"null",
",",
"orig",
":",
"null",
",",
"orig_line_diff",
":",
"0",
",",
"dest_line_diff",
":",
"0",
",",
"... | a small wrapper around fitzgen's source-map library | [
"a",
"small",
"wrapper",
"around",
"fitzgen",
"s",
"source",
"-",
"map",
"library"
] | 23fde33a7a24ba8d516c623643e359a25a46259c | https://github.com/rbackhouse/mpdjs/blob/23fde33a7a24ba8d516c623643e359a25a46259c/cordova/mpdjs/jsbuild/r.js#L23709-L23759 | train |
rbackhouse/mpdjs | cordova/mpdjs/jsbuild/r.js | can_mangle | function can_mangle(name) {
if (unmangleable.indexOf(name) >= 0) return false;
if (reserved.indexOf(name) >= 0) return false;
if (options.only_cache) {
return cache.props.has(name);
}
if (/^-?[0-9]+(\.[0-9]+)?(e[+-][0-9]+)?$/.test(name)) return false;
return t... | javascript | function can_mangle(name) {
if (unmangleable.indexOf(name) >= 0) return false;
if (reserved.indexOf(name) >= 0) return false;
if (options.only_cache) {
return cache.props.has(name);
}
if (/^-?[0-9]+(\.[0-9]+)?(e[+-][0-9]+)?$/.test(name)) return false;
return t... | [
"function",
"can_mangle",
"(",
"name",
")",
"{",
"if",
"(",
"unmangleable",
".",
"indexOf",
"(",
"name",
")",
">=",
"0",
")",
"return",
"false",
";",
"if",
"(",
"reserved",
".",
"indexOf",
"(",
"name",
")",
">=",
"0",
")",
"return",
"false",
";",
"... | only function declarations after this line | [
"only",
"function",
"declarations",
"after",
"this",
"line"
] | 23fde33a7a24ba8d516c623643e359a25a46259c | https://github.com/rbackhouse/mpdjs/blob/23fde33a7a24ba8d516c623643e359a25a46259c/cordova/mpdjs/jsbuild/r.js#L24531-L24539 | train |
rbackhouse/mpdjs | cordova/mpdjs/jsbuild/r.js | traverse | function traverse(object, visitor) {
var child;
if (!object) {
return;
}
if (visitor.call(null, object) === false) {
return false;
}
for (var i = 0, keys = Object.keys(object); i < keys.length; i++) {
child = object[keys[i]];
... | javascript | function traverse(object, visitor) {
var child;
if (!object) {
return;
}
if (visitor.call(null, object) === false) {
return false;
}
for (var i = 0, keys = Object.keys(object); i < keys.length; i++) {
child = object[keys[i]];
... | [
"function",
"traverse",
"(",
"object",
",",
"visitor",
")",
"{",
"var",
"child",
";",
"if",
"(",
"!",
"object",
")",
"{",
"return",
";",
"}",
"if",
"(",
"visitor",
".",
"call",
"(",
"null",
",",
"object",
")",
"===",
"false",
")",
"{",
"return",
... | From an esprima example for traversing its ast. | [
"From",
"an",
"esprima",
"example",
"for",
"traversing",
"its",
"ast",
"."
] | 23fde33a7a24ba8d516c623643e359a25a46259c | https://github.com/rbackhouse/mpdjs/blob/23fde33a7a24ba8d516c623643e359a25a46259c/cordova/mpdjs/jsbuild/r.js#L24982-L25000 | train |
rbackhouse/mpdjs | cordova/mpdjs/jsbuild/r.js | getValidDeps | function getValidDeps(node) {
if (!node || node.type !== 'ArrayExpression' || !node.elements) {
return;
}
var deps = [];
node.elements.some(function (elem) {
if (elem.type === 'Literal') {
deps.push(elem.value);
}
});
... | javascript | function getValidDeps(node) {
if (!node || node.type !== 'ArrayExpression' || !node.elements) {
return;
}
var deps = [];
node.elements.some(function (elem) {
if (elem.type === 'Literal') {
deps.push(elem.value);
}
});
... | [
"function",
"getValidDeps",
"(",
"node",
")",
"{",
"if",
"(",
"!",
"node",
"||",
"node",
".",
"type",
"!==",
"'ArrayExpression'",
"||",
"!",
"node",
".",
"elements",
")",
"{",
"return",
";",
"}",
"var",
"deps",
"=",
"[",
"]",
";",
"node",
".",
"ele... | Pulls out dependencies from an array literal with just string members.
If string literals, will just return those string values in an array,
skipping other items in the array.
@param {Node} node an AST node.
@returns {Array} an array of strings.
If null is returned, then it means the input node was not a valid
depend... | [
"Pulls",
"out",
"dependencies",
"from",
"an",
"array",
"literal",
"with",
"just",
"string",
"members",
".",
"If",
"string",
"literals",
"will",
"just",
"return",
"those",
"string",
"values",
"in",
"an",
"array",
"skipping",
"other",
"items",
"in",
"the",
"ar... | 23fde33a7a24ba8d516c623643e359a25a46259c | https://github.com/rbackhouse/mpdjs/blob/23fde33a7a24ba8d516c623643e359a25a46259c/cordova/mpdjs/jsbuild/r.js#L25034-L25048 | train |
rbackhouse/mpdjs | cordova/mpdjs/jsbuild/r.js | function (obj, options, totalIndent) {
var startBrace, endBrace, nextIndent,
first = true,
value = '',
lineReturn = options.lineReturn,
indent = options.indent,
outDentRegExp = options.outDentRegExp,
quote = opti... | javascript | function (obj, options, totalIndent) {
var startBrace, endBrace, nextIndent,
first = true,
value = '',
lineReturn = options.lineReturn,
indent = options.indent,
outDentRegExp = options.outDentRegExp,
quote = opti... | [
"function",
"(",
"obj",
",",
"options",
",",
"totalIndent",
")",
"{",
"var",
"startBrace",
",",
"endBrace",
",",
"nextIndent",
",",
"first",
"=",
"true",
",",
"value",
"=",
"''",
",",
"lineReturn",
"=",
"options",
".",
"lineReturn",
",",
"indent",
"=",
... | Tries converting a JS object to a string. This will likely suck, and
is tailored to the type of config expected in a loader config call.
So, hasOwnProperty fields, strings, numbers, arrays and functions,
no weird recursively referenced stuff.
@param {Object} obj the object to convert
@param {Object} options ... | [
"Tries",
"converting",
"a",
"JS",
"object",
"to",
"a",
"string",
".",
"This",
"will",
"likely",
"suck",
"and",
"is",
"tailored",
"to",
"the",
"type",
"of",
"config",
"expected",
"in",
"a",
"loader",
"config",
"call",
".",
"So",
"hasOwnProperty",
"fields",
... | 23fde33a7a24ba8d516c623643e359a25a46259c | https://github.com/rbackhouse/mpdjs/blob/23fde33a7a24ba8d516c623643e359a25a46259c/cordova/mpdjs/jsbuild/r.js#L26399-L26462 | train | |
rbackhouse/mpdjs | cordova/mpdjs/jsbuild/r.js | addSemiColon | function addSemiColon(text, config) {
if (config.skipSemiColonInsertion || endsWithSemiColonRegExp.test(text)) {
return text;
} else {
return text + ";";
}
} | javascript | function addSemiColon(text, config) {
if (config.skipSemiColonInsertion || endsWithSemiColonRegExp.test(text)) {
return text;
} else {
return text + ";";
}
} | [
"function",
"addSemiColon",
"(",
"text",
",",
"config",
")",
"{",
"if",
"(",
"config",
".",
"skipSemiColonInsertion",
"||",
"endsWithSemiColonRegExp",
".",
"test",
"(",
"text",
")",
")",
"{",
"return",
"text",
";",
"}",
"else",
"{",
"return",
"text",
"+",
... | Some JS may not be valid if concatenated with other JS, in particular
the style of omitting semicolons and rely on ASI. Add a semicolon in
those cases. | [
"Some",
"JS",
"may",
"not",
"be",
"valid",
"if",
"concatenated",
"with",
"other",
"JS",
"in",
"particular",
"the",
"style",
"of",
"omitting",
"semicolons",
"and",
"rely",
"on",
"ASI",
".",
"Add",
"a",
"semicolon",
"in",
"those",
"cases",
"."
] | 23fde33a7a24ba8d516c623643e359a25a46259c | https://github.com/rbackhouse/mpdjs/blob/23fde33a7a24ba8d516c623643e359a25a46259c/cordova/mpdjs/jsbuild/r.js#L28129-L28135 | train |
rbackhouse/mpdjs | cordova/mpdjs/jsbuild/r.js | appendToFileContents | function appendToFileContents(fileContents, singleContents, path, config, module, sourceMapGenerator) {
var refPath, sourceMapPath, resourcePath, pluginId, sourceMapLineNumber, lineCount, parts, i;
if (sourceMapGenerator) {
if (config.out) {
refPath = config.baseUrl;
... | javascript | function appendToFileContents(fileContents, singleContents, path, config, module, sourceMapGenerator) {
var refPath, sourceMapPath, resourcePath, pluginId, sourceMapLineNumber, lineCount, parts, i;
if (sourceMapGenerator) {
if (config.out) {
refPath = config.baseUrl;
... | [
"function",
"appendToFileContents",
"(",
"fileContents",
",",
"singleContents",
",",
"path",
",",
"config",
",",
"module",
",",
"sourceMapGenerator",
")",
"{",
"var",
"refPath",
",",
"sourceMapPath",
",",
"resourcePath",
",",
"pluginId",
",",
"sourceMapLineNumber",
... | Appends singleContents to fileContents and returns the result. If a sourceMapGenerator
is provided, adds singleContents to the source map.
@param {string} fileContents - The file contents to which to append singleContents
@param {string} singleContents - The additional contents to append to fileContents
@param {strin... | [
"Appends",
"singleContents",
"to",
"fileContents",
"and",
"returns",
"the",
"result",
".",
"If",
"a",
"sourceMapGenerator",
"is",
"provided",
"adds",
"singleContents",
"to",
"the",
"source",
"map",
"."
] | 23fde33a7a24ba8d516c623643e359a25a46259c | https://github.com/rbackhouse/mpdjs/blob/23fde33a7a24ba8d516c623643e359a25a46259c/cordova/mpdjs/jsbuild/r.js#L28181-L28234 | train |
swordf1zh/mattermoster | app.js | onError | function onError(error) {
if (error.syscall !== 'listen') throw error;
const bind = (typeof port === 'string')
? 'Pipe ' + port
: 'Port ' + port;
// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bin... | javascript | function onError(error) {
if (error.syscall !== 'listen') throw error;
const bind = (typeof port === 'string')
? 'Pipe ' + port
: 'Port ' + port;
// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bin... | [
"function",
"onError",
"(",
"error",
")",
"{",
"if",
"(",
"error",
".",
"syscall",
"!==",
"'listen'",
")",
"throw",
"error",
";",
"const",
"bind",
"=",
"(",
"typeof",
"port",
"===",
"'string'",
")",
"?",
"'Pipe '",
"+",
"port",
":",
"'Port '",
"+",
"... | Event listener for HTTP server "error" event. | [
"Event",
"listener",
"for",
"HTTP",
"server",
"error",
"event",
"."
] | 10e6c37c80eb023ab8ab044c46445a78a18053e7 | https://github.com/swordf1zh/mattermoster/blob/10e6c37c80eb023ab8ab044c46445a78a18053e7/app.js#L119-L141 | train |
KanoComputing/js-api-resource | lib/util.js | addMultipartData | function addMultipartData (formData, data) {
var key, arr, i;
for (key in data) {
if (data.hasOwnProperty(key) && key !== 'files') {
if (data[key] instanceof Array) {
arr = data[key];
for (i = 0; i < arr.length; i += 1) {
formData.append(... | javascript | function addMultipartData (formData, data) {
var key, arr, i;
for (key in data) {
if (data.hasOwnProperty(key) && key !== 'files') {
if (data[key] instanceof Array) {
arr = data[key];
for (i = 0; i < arr.length; i += 1) {
formData.append(... | [
"function",
"addMultipartData",
"(",
"formData",
",",
"data",
")",
"{",
"var",
"key",
",",
"arr",
",",
"i",
";",
"for",
"(",
"key",
"in",
"data",
")",
"{",
"if",
"(",
"data",
".",
"hasOwnProperty",
"(",
"key",
")",
"&&",
"key",
"!==",
"'files'",
")... | Helper used by `formRequestPayload` to append data to FormData instance | [
"Helper",
"used",
"by",
"formRequestPayload",
"to",
"append",
"data",
"to",
"FormData",
"instance"
] | 9f8e5a5a07402411ab2a8bbb91d7d8c094b8d9c5 | https://github.com/KanoComputing/js-api-resource/blob/9f8e5a5a07402411ab2a8bbb91d7d8c094b8d9c5/lib/util.js#L46-L62 | train |
KanoComputing/js-api-resource | lib/util.js | addFiles | function addFiles (formData, files) {
var file, arr, key, i = 0, filename;
for (key in files) {
if (files.hasOwnProperty(key) && files[key]) {
if (files[key] instanceof Array) {
arr = files[key];
filename = getFilename(arr[i]) || null;
for (... | javascript | function addFiles (formData, files) {
var file, arr, key, i = 0, filename;
for (key in files) {
if (files.hasOwnProperty(key) && files[key]) {
if (files[key] instanceof Array) {
arr = files[key];
filename = getFilename(arr[i]) || null;
for (... | [
"function",
"addFiles",
"(",
"formData",
",",
"files",
")",
"{",
"var",
"file",
",",
"arr",
",",
"key",
",",
"i",
"=",
"0",
",",
"filename",
";",
"for",
"(",
"key",
"in",
"files",
")",
"{",
"if",
"(",
"files",
".",
"hasOwnProperty",
"(",
"key",
"... | Helper used by `formRequestPayload` to append files to a FormData instance | [
"Helper",
"used",
"by",
"formRequestPayload",
"to",
"append",
"files",
"to",
"a",
"FormData",
"instance"
] | 9f8e5a5a07402411ab2a8bbb91d7d8c094b8d9c5 | https://github.com/KanoComputing/js-api-resource/blob/9f8e5a5a07402411ab2a8bbb91d7d8c094b8d9c5/lib/util.js#L66-L86 | train |
bigeasy/swimlane | src/swimlane.js | wrap | function wrap (factory, node, tag) {
// If there is a previous node that is not text, insert a new line to
// for
if (node.previousSibling != null && node.previousSibling.nodeType != 3) {
var newline = factory.createTextNode("\n");
body.insertBefore(newline, node);
}
var wrapper = f... | javascript | function wrap (factory, node, tag) {
// If there is a previous node that is not text, insert a new line to
// for
if (node.previousSibling != null && node.previousSibling.nodeType != 3) {
var newline = factory.createTextNode("\n");
body.insertBefore(newline, node);
}
var wrapper = f... | [
"function",
"wrap",
"(",
"factory",
",",
"node",
",",
"tag",
")",
"{",
"// If there is a previous node that is not text, insert a new line to",
"// for ",
"if",
"(",
"node",
".",
"previousSibling",
"!=",
"null",
"&&",
"node",
".",
"previousSibling",
".",
"nodeType",
... | Wraps the given node in a new element with the given tag created using the given factory. | [
"Wraps",
"the",
"given",
"node",
"in",
"a",
"new",
"element",
"with",
"the",
"given",
"tag",
"created",
"using",
"the",
"given",
"factory",
"."
] | 9e4baffa21761248b7c1a902d6a4a65fca02b3e1 | https://github.com/bigeasy/swimlane/blob/9e4baffa21761248b7c1a902d6a4a65fca02b3e1/src/swimlane.js#L615-L626 | train |
bigeasy/swimlane | src/swimlane.js | text | function text (factory, node, cursor) {
// Process a text node.
var parentNode = node.parentNode;
// If the node is CDATA convert it to text.
if (node.nodeType == 4) {
var text = factory.createTextNode(node.data);
parentNode.insertBefore(text, node);
parentNode.removeChild(node);
... | javascript | function text (factory, node, cursor) {
// Process a text node.
var parentNode = node.parentNode;
// If the node is CDATA convert it to text.
if (node.nodeType == 4) {
var text = factory.createTextNode(node.data);
parentNode.insertBefore(text, node);
parentNode.removeChild(node);
... | [
"function",
"text",
"(",
"factory",
",",
"node",
",",
"cursor",
")",
"{",
"// Process a text node. ",
"var",
"parentNode",
"=",
"node",
".",
"parentNode",
";",
"// If the node is CDATA convert it to text.",
"if",
"(",
"node",
".",
"nodeType",
"==",
"4",
")",
"{"... | Called for each node, this method will normalize the node if it is a text element, but if it is not a text element nothing is done. | [
"Called",
"for",
"each",
"node",
"this",
"method",
"will",
"normalize",
"the",
"node",
"if",
"it",
"is",
"a",
"text",
"element",
"but",
"if",
"it",
"is",
"not",
"a",
"text",
"element",
"nothing",
"is",
"done",
"."
] | 9e4baffa21761248b7c1a902d6a4a65fca02b3e1 | https://github.com/bigeasy/swimlane/blob/9e4baffa21761248b7c1a902d6a4a65fca02b3e1/src/swimlane.js#L689-L727 | train |
hhff/spree-ember | docs/theme/assets/vendor/foundation/js/foundation.min.js | function (selector, context) {
if (typeof selector === 'string') {
if (context) {
var cont;
if (context.jquery) {
cont = context[0];
if (!cont) {
return context;
}
} else {
cont = context;
}
return $(cont.querySelector... | javascript | function (selector, context) {
if (typeof selector === 'string') {
if (context) {
var cont;
if (context.jquery) {
cont = context[0];
if (!cont) {
return context;
}
} else {
cont = context;
}
return $(cont.querySelector... | [
"function",
"(",
"selector",
",",
"context",
")",
"{",
"if",
"(",
"typeof",
"selector",
"===",
"'string'",
")",
"{",
"if",
"(",
"context",
")",
"{",
"var",
"cont",
";",
"if",
"(",
"context",
".",
"jquery",
")",
"{",
"cont",
"=",
"context",
"[",
"0"... | private Fast Selector wrapper, returns jQuery object. Only use where getElementById is not available. | [
"private",
"Fast",
"Selector",
"wrapper",
"returns",
"jQuery",
"object",
".",
"Only",
"use",
"where",
"getElementById",
"is",
"not",
"available",
"."
] | 31aeaa7a3b909c6524d193beddea1267b211130f | https://github.com/hhff/spree-ember/blob/31aeaa7a3b909c6524d193beddea1267b211130f/docs/theme/assets/vendor/foundation/js/foundation.min.js#L49-L68 | train | |
hhff/spree-ember | docs/theme/assets/vendor/foundation/js/foundation.min.js | function (init) {
var arr = [];
if (!init) {
arr.push('data');
}
if (this.namespace.length > 0) {
arr.push(this.namespace);
}
arr.push(this.name);
return arr.join('-');
} | javascript | function (init) {
var arr = [];
if (!init) {
arr.push('data');
}
if (this.namespace.length > 0) {
arr.push(this.namespace);
}
arr.push(this.name);
return arr.join('-');
} | [
"function",
"(",
"init",
")",
"{",
"var",
"arr",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"init",
")",
"{",
"arr",
".",
"push",
"(",
"'data'",
")",
";",
"}",
"if",
"(",
"this",
".",
"namespace",
".",
"length",
">",
"0",
")",
"{",
"arr",
".",
"pu... | Namespace functions. | [
"Namespace",
"functions",
"."
] | 31aeaa7a3b909c6524d193beddea1267b211130f | https://github.com/hhff/spree-ember/blob/31aeaa7a3b909c6524d193beddea1267b211130f/docs/theme/assets/vendor/foundation/js/foundation.min.js#L72-L83 | train | |
hhff/spree-ember | docs/theme/assets/vendor/foundation/js/foundation.min.js | function (dropdown, target, settings, position) {
var sheet = Foundation.stylesheet,
pip_offset_base = 8;
if (dropdown.hasClass(settings.mega_class)) {
pip_offset_base = position.left + (target.outerWidth() / 2) - 8;
} else if (this.small()) {
pip_offset_base += position.lef... | javascript | function (dropdown, target, settings, position) {
var sheet = Foundation.stylesheet,
pip_offset_base = 8;
if (dropdown.hasClass(settings.mega_class)) {
pip_offset_base = position.left + (target.outerWidth() / 2) - 8;
} else if (this.small()) {
pip_offset_base += position.lef... | [
"function",
"(",
"dropdown",
",",
"target",
",",
"settings",
",",
"position",
")",
"{",
"var",
"sheet",
"=",
"Foundation",
".",
"stylesheet",
",",
"pip_offset_base",
"=",
"8",
";",
"if",
"(",
"dropdown",
".",
"hasClass",
"(",
"settings",
".",
"mega_class",... | Insert rule to style psuedo elements | [
"Insert",
"rule",
"to",
"style",
"psuedo",
"elements"
] | 31aeaa7a3b909c6524d193beddea1267b211130f | https://github.com/hhff/spree-ember/blob/31aeaa7a3b909c6524d193beddea1267b211130f/docs/theme/assets/vendor/foundation/js/foundation.min.js#L2355-L2396 | train | |
davidfig/pixel | pixelart.js | function (x1, y1, w, h, color, c)
{
_c = c || _c
if (color)
{
_c.fillStyle = color
}
box(x1 * _scale, y1 * _scale, w * _scale, h * _scale)
} | javascript | function (x1, y1, w, h, color, c)
{
_c = c || _c
if (color)
{
_c.fillStyle = color
}
box(x1 * _scale, y1 * _scale, w * _scale, h * _scale)
} | [
"function",
"(",
"x1",
",",
"y1",
",",
"w",
",",
"h",
",",
"color",
",",
"c",
")",
"{",
"_c",
"=",
"c",
"||",
"_c",
"if",
"(",
"color",
")",
"{",
"_c",
".",
"fillStyle",
"=",
"color",
"}",
"box",
"(",
"x1",
"*",
"_scale",
",",
"y1",
"*",
... | draw and fill rectangle
@param {number} x1 - x
@param {number} y2 - y
@param {number} radius - radius
@param {string} color
@param {CanvasRenderingContext2D} [c] | [
"draw",
"and",
"fill",
"rectangle"
] | 2713a7922f9e7f4c008c0fc4ec398e9b1b64aace | https://github.com/davidfig/pixel/blob/2713a7922f9e7f4c008c0fc4ec398e9b1b64aace/pixelart.js#L68-L76 | train | |
davidfig/pixel | pixelart.js | function (x0, y0, radius, color, c)
{
_c = c || _c
if (color)
{
_c.fillStyle = color
}
x0 *= _scale
y0 *= _scale
radius *= _scale
let x = radius
let y = 0
let decisionOver2 = 1 - x // Decision criterion divided by 2 evalua... | javascript | function (x0, y0, radius, color, c)
{
_c = c || _c
if (color)
{
_c.fillStyle = color
}
x0 *= _scale
y0 *= _scale
radius *= _scale
let x = radius
let y = 0
let decisionOver2 = 1 - x // Decision criterion divided by 2 evalua... | [
"function",
"(",
"x0",
",",
"y0",
",",
"radius",
",",
"color",
",",
"c",
")",
"{",
"_c",
"=",
"c",
"||",
"_c",
"if",
"(",
"color",
")",
"{",
"_c",
".",
"fillStyle",
"=",
"color",
"}",
"x0",
"*=",
"_scale",
"y0",
"*=",
"_scale",
"radius",
"*=",
... | draw and fill circle
@param {number} x0 - x-center
@param {number} y0 - y-center
@param {number} radius - radius
@param {string} color
@param {CanvasRenderingContext2D} [c] | [
"draw",
"and",
"fill",
"circle"
] | 2713a7922f9e7f4c008c0fc4ec398e9b1b64aace | https://github.com/davidfig/pixel/blob/2713a7922f9e7f4c008c0fc4ec398e9b1b64aace/pixelart.js#L158-L188 | train | |
davidfig/pixel | pixelart.js | function (x0, y0, width, height, c)
{
_c = c || _c
const data = _c.getImageData(x0, y0, width, height)
const bits = data.data
const pixels = []
for (let y = 0; y < height; y += _scale)
{
for (let x = 0; x < width; x += _scale)
{
... | javascript | function (x0, y0, width, height, c)
{
_c = c || _c
const data = _c.getImageData(x0, y0, width, height)
const bits = data.data
const pixels = []
for (let y = 0; y < height; y += _scale)
{
for (let x = 0; x < width; x += _scale)
{
... | [
"function",
"(",
"x0",
",",
"y0",
",",
"width",
",",
"height",
",",
"c",
")",
"{",
"_c",
"=",
"c",
"||",
"_c",
"const",
"data",
"=",
"_c",
".",
"getImageData",
"(",
"x0",
",",
"y0",
",",
"width",
",",
"height",
")",
"const",
"bits",
"=",
"data"... | gets data for use with yy-pixel.Pixel file format
@param {number} x0 - starting point in canvas
@param {number} y0
@param {number} width
@param {number} height
@param {HTMLContext} c | [
"gets",
"data",
"for",
"use",
"with",
"yy",
"-",
"pixel",
".",
"Pixel",
"file",
"format"
] | 2713a7922f9e7f4c008c0fc4ec398e9b1b64aace | https://github.com/davidfig/pixel/blob/2713a7922f9e7f4c008c0fc4ec398e9b1b64aace/pixelart.js#L423-L447 | train | |
kengz/neo4jKB | lib/parse.js | log | function log(arg) {
var str = JSON.stringify(arg)
console.log(str)
return str;
} | javascript | function log(arg) {
var str = JSON.stringify(arg)
console.log(str)
return str;
} | [
"function",
"log",
"(",
"arg",
")",
"{",
"var",
"str",
"=",
"JSON",
".",
"stringify",
"(",
"arg",
")",
"console",
".",
"log",
"(",
"str",
")",
"return",
"str",
";",
"}"
] | A conveience method. JSON-stringify the argument, logs it, and return the string.
@param {JSON} arg The JSON to be stringified.
@return {string} the stringified JSON.
/* istanbul ignore next | [
"A",
"conveience",
"method",
".",
"JSON",
"-",
"stringify",
"the",
"argument",
"logs",
"it",
"and",
"return",
"the",
"string",
"."
] | 8762390ac81974afc6bb44a2dd3c44b44aaaa09a | https://github.com/kengz/neo4jKB/blob/8762390ac81974afc6bb44a2dd3c44b44aaaa09a/lib/parse.js#L12-L16 | train |
kengz/neo4jKB | lib/parse.js | picker | function picker(iteratees) {
iteratees = iteratees || ['name']
return _.partial(_.pick, _, iteratees)
} | javascript | function picker(iteratees) {
iteratees = iteratees || ['name']
return _.partial(_.pick, _, iteratees)
} | [
"function",
"picker",
"(",
"iteratees",
")",
"{",
"iteratees",
"=",
"iteratees",
"||",
"[",
"'name'",
"]",
"return",
"_",
".",
"partial",
"(",
"_",
".",
"pick",
",",
"_",
",",
"iteratees",
")",
"}"
] | For use with transform. Generate a picker function using _.pick with a supplied iteratees.
@param {string|Array} iteratees Of _.pick
@return {Function} That picks iteratees of its argument. | [
"For",
"use",
"with",
"transform",
".",
"Generate",
"a",
"picker",
"function",
"using",
"_",
".",
"pick",
"with",
"a",
"supplied",
"iteratees",
"."
] | 8762390ac81974afc6bb44a2dd3c44b44aaaa09a | https://github.com/kengz/neo4jKB/blob/8762390ac81974afc6bb44a2dd3c44b44aaaa09a/lib/parse.js#L530-L533 | train |
goto-bus-stop/get-artist-title | lib/core.js | combineSplitters | function combineSplitters (splitters) {
var l = splitters.length
return function (str) {
for (var i = 0; i < l; i++) {
var result = splitters[i](str)
if (result) return result
}
}
} | javascript | function combineSplitters (splitters) {
var l = splitters.length
return function (str) {
for (var i = 0; i < l; i++) {
var result = splitters[i](str)
if (result) return result
}
}
} | [
"function",
"combineSplitters",
"(",
"splitters",
")",
"{",
"var",
"l",
"=",
"splitters",
".",
"length",
"return",
"function",
"(",
"str",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"var",
"result",
... | Return the result of the first splitter function that matches. | [
"Return",
"the",
"result",
"of",
"the",
"first",
"splitter",
"function",
"that",
"matches",
"."
] | dd233b21dba6f26bc137a68c71c35132a26f68f2 | https://github.com/goto-bus-stop/get-artist-title/blob/dd233b21dba6f26bc137a68c71c35132a26f68f2/lib/core.js#L21-L29 | train |
goto-bus-stop/get-artist-title | lib/core.js | reducePlugins | function reducePlugins (plugins) {
var before = []
var split = []
var after = []
plugins.forEach(function (plugin) {
if (plugin.before) before.push(plugin.before)
if (plugin.split) split.push(plugin.split)
if (plugin.after) after.push(plugin.after)
})
return {
before: flow(before),
split... | javascript | function reducePlugins (plugins) {
var before = []
var split = []
var after = []
plugins.forEach(function (plugin) {
if (plugin.before) before.push(plugin.before)
if (plugin.split) split.push(plugin.split)
if (plugin.after) after.push(plugin.after)
})
return {
before: flow(before),
split... | [
"function",
"reducePlugins",
"(",
"plugins",
")",
"{",
"var",
"before",
"=",
"[",
"]",
"var",
"split",
"=",
"[",
"]",
"var",
"after",
"=",
"[",
"]",
"plugins",
".",
"forEach",
"(",
"function",
"(",
"plugin",
")",
"{",
"if",
"(",
"plugin",
".",
"bef... | Combine multiple plugins into a single plugin. | [
"Combine",
"multiple",
"plugins",
"into",
"a",
"single",
"plugin",
"."
] | dd233b21dba6f26bc137a68c71c35132a26f68f2 | https://github.com/goto-bus-stop/get-artist-title/blob/dd233b21dba6f26bc137a68c71c35132a26f68f2/lib/core.js#L32-L46 | train |
goto-bus-stop/get-artist-title | lib/core.js | getSongArtistTitle | function getSongArtistTitle (str, options, plugins) {
if (options) {
if (options.defaultArtist) {
plugins.push(fallBackToArtist(options.defaultArtist))
}
if (options.defaultTitle) {
plugins.push(fallBackToTitle(options.defaultTitle))
}
}
var plugin = reducePlugins(plugins)
checkPlu... | javascript | function getSongArtistTitle (str, options, plugins) {
if (options) {
if (options.defaultArtist) {
plugins.push(fallBackToArtist(options.defaultArtist))
}
if (options.defaultTitle) {
plugins.push(fallBackToTitle(options.defaultTitle))
}
}
var plugin = reducePlugins(plugins)
checkPlu... | [
"function",
"getSongArtistTitle",
"(",
"str",
",",
"options",
",",
"plugins",
")",
"{",
"if",
"(",
"options",
")",
"{",
"if",
"(",
"options",
".",
"defaultArtist",
")",
"{",
"plugins",
".",
"push",
"(",
"fallBackToArtist",
"(",
"options",
".",
"defaultArti... | Get an artist name and song title from a string. | [
"Get",
"an",
"artist",
"name",
"and",
"song",
"title",
"from",
"a",
"string",
"."
] | dd233b21dba6f26bc137a68c71c35132a26f68f2 | https://github.com/goto-bus-stop/get-artist-title/blob/dd233b21dba6f26bc137a68c71c35132a26f68f2/lib/core.js#L74-L92 | train |
samthor/mocha-headless-server | index.js | flatten | function flatten(test) {
return {
title: test.title,
duration: test.duration,
err: test.err ? Object.assign({}, test.err) : null,
};
} | javascript | function flatten(test) {
return {
title: test.title,
duration: test.duration,
err: test.err ? Object.assign({}, test.err) : null,
};
} | [
"function",
"flatten",
"(",
"test",
")",
"{",
"return",
"{",
"title",
":",
"test",
".",
"title",
",",
"duration",
":",
"test",
".",
"duration",
",",
"err",
":",
"test",
".",
"err",
"?",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"test",
".",
"e... | Flatten Mocha's `Test` object into plain JSON. | [
"Flatten",
"Mocha",
"s",
"Test",
"object",
"into",
"plain",
"JSON",
"."
] | d07e983726b87368160a4f9ebc37f9bbebe4b4e2 | https://github.com/samthor/mocha-headless-server/blob/d07e983726b87368160a4f9ebc37f9bbebe4b4e2/index.js#L73-L79 | train |
rsamec/business-rules | dist/hobbies/node-business-rules.js | BusinessRules | function BusinessRules(Data) {
this.Data = Data;
this.MainValidator = this.createMainValidator().CreateRule("Data");
this.ValidationResult = this.MainValidator.ValidationResult;
this.HobbiesNumberValidator = this.MainValidator.Validators["Hobbies"];
} | javascript | function BusinessRules(Data) {
this.Data = Data;
this.MainValidator = this.createMainValidator().CreateRule("Data");
this.ValidationResult = this.MainValidator.ValidationResult;
this.HobbiesNumberValidator = this.MainValidator.Validators["Hobbies"];
} | [
"function",
"BusinessRules",
"(",
"Data",
")",
"{",
"this",
".",
"Data",
"=",
"Data",
";",
"this",
".",
"MainValidator",
"=",
"this",
".",
"createMainValidator",
"(",
")",
".",
"CreateRule",
"(",
"\"Data\"",
")",
";",
"this",
".",
"ValidationResult",
"=",
... | Default constructor.
@param data | [
"Default",
"constructor",
"."
] | 09be8a3764874fa2b020f0e6eae1241d0a9e94cc | https://github.com/rsamec/business-rules/blob/09be8a3764874fa2b020f0e6eae1241d0a9e94cc/dist/hobbies/node-business-rules.js#L40-L46 | train |
Deathspike/npm-build-tools | src/clean.js | clean | function clean(directoryPath, isRoot, done) {
fs.stat(directoryPath, function(err, stat) {
if (err) return done(isRoot ? undefined : err);
if (stat.isFile()) return fs.unlink(directoryPath, done);
fs.readdir(directoryPath, function(err, relativePaths) {
if (err) return done(err);
each(relative... | javascript | function clean(directoryPath, isRoot, done) {
fs.stat(directoryPath, function(err, stat) {
if (err) return done(isRoot ? undefined : err);
if (stat.isFile()) return fs.unlink(directoryPath, done);
fs.readdir(directoryPath, function(err, relativePaths) {
if (err) return done(err);
each(relative... | [
"function",
"clean",
"(",
"directoryPath",
",",
"isRoot",
",",
"done",
")",
"{",
"fs",
".",
"stat",
"(",
"directoryPath",
",",
"function",
"(",
"err",
",",
"stat",
")",
"{",
"if",
"(",
"err",
")",
"return",
"done",
"(",
"isRoot",
"?",
"undefined",
":... | Cleans the files and directories in the directory path.
@param {string} directoryPath
@param {function(Error=)} done | [
"Cleans",
"the",
"files",
"and",
"directories",
"in",
"the",
"directory",
"path",
"."
] | caf2a0933b5900e34dc093f34b070a5b947cce39 | https://github.com/Deathspike/npm-build-tools/blob/caf2a0933b5900e34dc093f34b070a5b947cce39/src/clean.js#L30-L49 | train |
erdtman/content-security-policy | lib/index.js | getDirective | function getDirective (options, name) {
if (!options[name]) {
return null;
}
if (typeof options[name] === 'string') {
return name + ' ' + options[name];
}
if (Array.isArray(options[name])) {
let result = name + ' ';
options[name].forEach(value => {
result += value + ' ';
});
re... | javascript | function getDirective (options, name) {
if (!options[name]) {
return null;
}
if (typeof options[name] === 'string') {
return name + ' ' + options[name];
}
if (Array.isArray(options[name])) {
let result = name + ' ';
options[name].forEach(value => {
result += value + ' ';
});
re... | [
"function",
"getDirective",
"(",
"options",
",",
"name",
")",
"{",
"if",
"(",
"!",
"options",
"[",
"name",
"]",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"typeof",
"options",
"[",
"name",
"]",
"===",
"'string'",
")",
"{",
"return",
"name",
"... | Helper function to compile one directive. handles strings and arrays.
@param options
all options
@param name
name of the one to compile
@returns compilation of named option | [
"Helper",
"function",
"to",
"compile",
"one",
"directive",
".",
"handles",
"strings",
"and",
"arrays",
"."
] | 7803af4bec2b4b0ff7fe85b61403160373b96349 | https://github.com/erdtman/content-security-policy/blob/7803af4bec2b4b0ff7fe85b61403160373b96349/lib/index.js#L107-L125 | train |
rbackhouse/mpdjs | cordova/mpdjs/plugins/cordova-plugin-file/www/requestFileSystem.js | function (file_system) {
if (file_system) {
if (successCallback) {
fileSystems.getFs(file_system.name, function (fs) {
// This should happen only on platforms that haven't implemented requestAllFileSystems (windows)
... | javascript | function (file_system) {
if (file_system) {
if (successCallback) {
fileSystems.getFs(file_system.name, function (fs) {
// This should happen only on platforms that haven't implemented requestAllFileSystems (windows)
... | [
"function",
"(",
"file_system",
")",
"{",
"if",
"(",
"file_system",
")",
"{",
"if",
"(",
"successCallback",
")",
"{",
"fileSystems",
".",
"getFs",
"(",
"file_system",
".",
"name",
",",
"function",
"(",
"fs",
")",
"{",
"// This should happen only on platforms t... | if successful, return a FileSystem object | [
"if",
"successful",
"return",
"a",
"FileSystem",
"object"
] | 23fde33a7a24ba8d516c623643e359a25a46259c | https://github.com/rbackhouse/mpdjs/blob/23fde33a7a24ba8d516c623643e359a25a46259c/cordova/mpdjs/plugins/cordova-plugin-file/www/requestFileSystem.js#L60-L75 | train | |
seriousManual/node-piglow | lib/PiGlowBackend.js | PiGlow | function PiGlow() {
var that = this;
this._wire = null;
this._currentState = null;
Emitter.call(this);
this._initialize(function (error) {
if (error) {
that.emit('error', error);
} else {
that.emit('initialize');
}
});
} | javascript | function PiGlow() {
var that = this;
this._wire = null;
this._currentState = null;
Emitter.call(this);
this._initialize(function (error) {
if (error) {
that.emit('error', error);
} else {
that.emit('initialize');
}
});
} | [
"function",
"PiGlow",
"(",
")",
"{",
"var",
"that",
"=",
"this",
";",
"this",
".",
"_wire",
"=",
"null",
";",
"this",
".",
"_currentState",
"=",
"null",
";",
"Emitter",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"_initialize",
"(",
"function",
... | command that causes the hardware board to update its LED values
PiGlow Backend
@constructor | [
"command",
"that",
"causes",
"the",
"hardware",
"board",
"to",
"update",
"its",
"LED",
"values",
"PiGlow",
"Backend"
] | 2175fda7d56a779adb4aaec29e86cbc7745809ef | https://github.com/seriousManual/node-piglow/blob/2175fda7d56a779adb4aaec29e86cbc7745809ef/lib/PiGlowBackend.js#L19-L34 | train |
serban-petrescu/ui5-jsx-rm | src/visitor.js | buildErrorHandler | function buildErrorHandler(path) {
return function(node, text) {
throw path.hub.file.buildCodeFrameError(node, text);
}
} | javascript | function buildErrorHandler(path) {
return function(node, text) {
throw path.hub.file.buildCodeFrameError(node, text);
}
} | [
"function",
"buildErrorHandler",
"(",
"path",
")",
"{",
"return",
"function",
"(",
"node",
",",
"text",
")",
"{",
"throw",
"path",
".",
"hub",
".",
"file",
".",
"buildCodeFrameError",
"(",
"node",
",",
"text",
")",
";",
"}",
"}"
] | Builds an error handling function for the given path. | [
"Builds",
"an",
"error",
"handling",
"function",
"for",
"the",
"given",
"path",
"."
] | 57beb245a6c70d7fad75a69242deb0a1ee7f3ee0 | https://github.com/serban-petrescu/ui5-jsx-rm/blob/57beb245a6c70d7fad75a69242deb0a1ee7f3ee0/src/visitor.js#L16-L20 | train |
dpw/node-buffer-more-ints | buffer-more-ints.js | check_value | function check_value(val, min, max) {
val = +val;
if (typeof(val) != 'number' || val < min || val > max || Math.floor(val) !== val) {
throw new TypeError("\"value\" argument is out of bounds");
}
return val;
} | javascript | function check_value(val, min, max) {
val = +val;
if (typeof(val) != 'number' || val < min || val > max || Math.floor(val) !== val) {
throw new TypeError("\"value\" argument is out of bounds");
}
return val;
} | [
"function",
"check_value",
"(",
"val",
",",
"min",
",",
"max",
")",
"{",
"val",
"=",
"+",
"val",
";",
"if",
"(",
"typeof",
"(",
"val",
")",
"!=",
"'number'",
"||",
"val",
"<",
"min",
"||",
"val",
">",
"max",
"||",
"Math",
".",
"floor",
"(",
"va... | Check that a value is an integer within the given range | [
"Check",
"that",
"a",
"value",
"is",
"an",
"integer",
"within",
"the",
"given",
"range"
] | e0909f16d6d2c8801ae0119c36486019cfd8cf31 | https://github.com/dpw/node-buffer-more-ints/blob/e0909f16d6d2c8801ae0119c36486019cfd8cf31/buffer-more-ints.js#L49-L55 | train |
dpw/node-buffer-more-ints | buffer-more-ints.js | check_bounds | function check_bounds(buf, offset, len) {
if (offset < 0 || offset + len > buf.length) {
throw new RangeError("Index out of range");
}
} | javascript | function check_bounds(buf, offset, len) {
if (offset < 0 || offset + len > buf.length) {
throw new RangeError("Index out of range");
}
} | [
"function",
"check_bounds",
"(",
"buf",
",",
"offset",
",",
"len",
")",
"{",
"if",
"(",
"offset",
"<",
"0",
"||",
"offset",
"+",
"len",
">",
"buf",
".",
"length",
")",
"{",
"throw",
"new",
"RangeError",
"(",
"\"Index out of range\"",
")",
";",
"}",
"... | Check that something is within the Buffer bounds | [
"Check",
"that",
"something",
"is",
"within",
"the",
"Buffer",
"bounds"
] | e0909f16d6d2c8801ae0119c36486019cfd8cf31 | https://github.com/dpw/node-buffer-more-ints/blob/e0909f16d6d2c8801ae0119c36486019cfd8cf31/buffer-more-ints.js#L58-L62 | train |
jugglinmike/compare-ast | lib/compare.js | compareAst | function compareAst(actualSrc, expectedSrc, options) {
var actualAst, expectedAst;
options = options || {};
if (!options.comparators) {
options.comparators = [];
}
/*
* A collection of comparator functions that recognize equivalent nodes
* that would otherwise be reported as unequal by simple object compar... | javascript | function compareAst(actualSrc, expectedSrc, options) {
var actualAst, expectedAst;
options = options || {};
if (!options.comparators) {
options.comparators = [];
}
/*
* A collection of comparator functions that recognize equivalent nodes
* that would otherwise be reported as unequal by simple object compar... | [
"function",
"compareAst",
"(",
"actualSrc",
",",
"expectedSrc",
",",
"options",
")",
"{",
"var",
"actualAst",
",",
"expectedAst",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"options",
".",
"comparators",
")",
"{",
"options",
"."... | Given a "template" expected AST that defines abstract identifier names described by `options.varPattern`, "bind" those identifiers to their concrete names in the "actual" AST. | [
"Given",
"a",
"template",
"expected",
"AST",
"that",
"defines",
"abstract",
"identifier",
"names",
"described",
"by",
"options",
".",
"varPattern",
"bind",
"those",
"identifiers",
"to",
"their",
"concrete",
"names",
"in",
"the",
"actual",
"AST",
"."
] | 4329c661186c976ffe556826f518167256ca7ab3 | https://github.com/jugglinmike/compare-ast/blob/4329c661186c976ffe556826f518167256ca7ab3/lib/compare.js#L8-L89 | train |
radiovisual/metalsmith-rootpath | index.js | plugin | function plugin() {
return function (files, metalsmith, done) {
Object.keys(files).forEach(function (file) {
setImmediate(done);
var pathslash = process.platform === 'win32' ? '\\' : '/';
var rootPath = '';
var levels = needles(file, pathslash);
for (var i = 0; i < levels; i++) {
rootPath += '..... | javascript | function plugin() {
return function (files, metalsmith, done) {
Object.keys(files).forEach(function (file) {
setImmediate(done);
var pathslash = process.platform === 'win32' ? '\\' : '/';
var rootPath = '';
var levels = needles(file, pathslash);
for (var i = 0; i < levels; i++) {
rootPath += '..... | [
"function",
"plugin",
"(",
")",
"{",
"return",
"function",
"(",
"files",
",",
"metalsmith",
",",
"done",
")",
"{",
"Object",
".",
"keys",
"(",
"files",
")",
".",
"forEach",
"(",
"function",
"(",
"file",
")",
"{",
"setImmediate",
"(",
"done",
")",
";"... | Metalsmith plugin that sets a `rootPath` variable on each file's metadata.
This allows you to find relative paths in your templates easily.
@return {Function} | [
"Metalsmith",
"plugin",
"that",
"sets",
"a",
"rootPath",
"variable",
"on",
"each",
"file",
"s",
"metadata",
".",
"This",
"allows",
"you",
"to",
"find",
"relative",
"paths",
"in",
"your",
"templates",
"easily",
"."
] | a649c672e25107ac190969a6db5c6a79ead0c698 | https://github.com/radiovisual/metalsmith-rootpath/blob/a649c672e25107ac190969a6db5c6a79ead0c698/index.js#L17-L32 | train |
bowheart/zedux | src/utils/general.js | getDetailedObjectType | function getDetailedObjectType(thing) {
let prototype = Object.getPrototypeOf(thing)
if (!prototype) return NO_PROTOTYPE
return Object.getPrototypeOf(prototype)
? COMPLEX_OBJECT
: PLAIN_OBJECT
} | javascript | function getDetailedObjectType(thing) {
let prototype = Object.getPrototypeOf(thing)
if (!prototype) return NO_PROTOTYPE
return Object.getPrototypeOf(prototype)
? COMPLEX_OBJECT
: PLAIN_OBJECT
} | [
"function",
"getDetailedObjectType",
"(",
"thing",
")",
"{",
"let",
"prototype",
"=",
"Object",
".",
"getPrototypeOf",
"(",
"thing",
")",
"if",
"(",
"!",
"prototype",
")",
"return",
"NO_PROTOTYPE",
"return",
"Object",
".",
"getPrototypeOf",
"(",
"prototype",
"... | Determines which kind of object an "object" is.
Objects can be prototype-less, complex, or plain. | [
"Determines",
"which",
"kind",
"of",
"object",
"an",
"object",
"is",
"."
] | f817a5e9520e0496628e94e8782134ac53ece858 | https://github.com/bowheart/zedux/blob/f817a5e9520e0496628e94e8782134ac53ece858/src/utils/general.js#L95-L103 | train |
rsamec/business-rules | dist/invoice/node-business-rules.js | BusinessRules | function BusinessRules(Data) {
this.Data = Data;
this.InvoiceValidator = this.createInvoiceValidator().CreateRule("Data");
this.ValidationResult = this.InvoiceValidator.ValidationResult;
} | javascript | function BusinessRules(Data) {
this.Data = Data;
this.InvoiceValidator = this.createInvoiceValidator().CreateRule("Data");
this.ValidationResult = this.InvoiceValidator.ValidationResult;
} | [
"function",
"BusinessRules",
"(",
"Data",
")",
"{",
"this",
".",
"Data",
"=",
"Data",
";",
"this",
".",
"InvoiceValidator",
"=",
"this",
".",
"createInvoiceValidator",
"(",
")",
".",
"CreateRule",
"(",
"\"Data\"",
")",
";",
"this",
".",
"ValidationResult",
... | Default ctor.
@param Data Invoice data | [
"Default",
"ctor",
"."
] | 09be8a3764874fa2b020f0e6eae1241d0a9e94cc | https://github.com/rsamec/business-rules/blob/09be8a3764874fa2b020f0e6eae1241d0a9e94cc/dist/invoice/node-business-rules.js#L25-L30 | train |
rsamec/business-rules | dist/invoice/node-business-rules.js | function (args) {
args.HasError = false;
args.ErrorMessage = "";
if (this.Items !== undefined && this.Items.length === 0) {
args.HasError = true;
args.ErrorMessage = "At least one item must be on invoice.";
args... | javascript | function (args) {
args.HasError = false;
args.ErrorMessage = "";
if (this.Items !== undefined && this.Items.length === 0) {
args.HasError = true;
args.ErrorMessage = "At least one item must be on invoice.";
args... | [
"function",
"(",
"args",
")",
"{",
"args",
".",
"HasError",
"=",
"false",
";",
"args",
".",
"ErrorMessage",
"=",
"\"\"",
";",
"if",
"(",
"this",
".",
"Items",
"!==",
"undefined",
"&&",
"this",
".",
"Items",
".",
"length",
"===",
"0",
")",
"{",
"arg... | at least one item must be filled | [
"at",
"least",
"one",
"item",
"must",
"be",
"filled"
] | 09be8a3764874fa2b020f0e6eae1241d0a9e94cc | https://github.com/rsamec/business-rules/blob/09be8a3764874fa2b020f0e6eae1241d0a9e94cc/dist/invoice/node-business-rules.js#L63-L73 | train | |
seriousManual/node-piglow | index.js | createPiGlow | function createPiGlow(callback) {
var myPiGlow = new PiGlowBackend();
var myInterface = piGlowInterface(myPiGlow);
myPiGlow
.on('initialize', function() {
callback(null, myInterface);
})
.on('error', function(error) {
callback(error, null);
});
} | javascript | function createPiGlow(callback) {
var myPiGlow = new PiGlowBackend();
var myInterface = piGlowInterface(myPiGlow);
myPiGlow
.on('initialize', function() {
callback(null, myInterface);
})
.on('error', function(error) {
callback(error, null);
});
} | [
"function",
"createPiGlow",
"(",
"callback",
")",
"{",
"var",
"myPiGlow",
"=",
"new",
"PiGlowBackend",
"(",
")",
";",
"var",
"myInterface",
"=",
"piGlowInterface",
"(",
"myPiGlow",
")",
";",
"myPiGlow",
".",
"on",
"(",
"'initialize'",
",",
"function",
"(",
... | convenience constructor function | [
"convenience",
"constructor",
"function"
] | 2175fda7d56a779adb4aaec29e86cbc7745809ef | https://github.com/seriousManual/node-piglow/blob/2175fda7d56a779adb4aaec29e86cbc7745809ef/index.js#L10-L21 | train |
dominictarr/line-graph | ruler.js | calcSteps | function calcSteps (min, max, room, width) {
var range = max - min
var i = 0, e
while(true) {
var e = Math.pow(10, i++)
if(e > 10000000000)
throw new Error('oops')
var re = range/e
var space = width*1.25
if(room / (re) > space) return e
if(room*2 / (re) > space) return e*2
... | javascript | function calcSteps (min, max, room, width) {
var range = max - min
var i = 0, e
while(true) {
var e = Math.pow(10, i++)
if(e > 10000000000)
throw new Error('oops')
var re = range/e
var space = width*1.25
if(room / (re) > space) return e
if(room*2 / (re) > space) return e*2
... | [
"function",
"calcSteps",
"(",
"min",
",",
"max",
",",
"room",
",",
"width",
")",
"{",
"var",
"range",
"=",
"max",
"-",
"min",
"var",
"i",
"=",
"0",
",",
"e",
"while",
"(",
"true",
")",
"{",
"var",
"e",
"=",
"Math",
".",
"pow",
"(",
"10",
",",... | must have range, room, and width | [
"must",
"have",
"range",
"room",
"and",
"width"
] | 81b3d0eed7b6b2809a4aff0fc990e00df325ab30 | https://github.com/dominictarr/line-graph/blob/81b3d0eed7b6b2809a4aff0fc990e00df325ab30/ruler.js#L6-L23 | train |
kengz/neo4jKB | lib/query.js | postQuery | function postQuery(statArr) {
var options = {
method: 'POST',
baseUrl: this.NEO4J_BASEURL,
url: this.NEO4J_ENDPT,
headers: {
'Accept': 'application/json; charset=UTF-8',
'Content-type': 'application/json'
},
json: {
statements: statArr
// [{stateme... | javascript | function postQuery(statArr) {
var options = {
method: 'POST',
baseUrl: this.NEO4J_BASEURL,
url: this.NEO4J_ENDPT,
headers: {
'Accept': 'application/json; charset=UTF-8',
'Content-type': 'application/json'
},
json: {
statements: statArr
// [{stateme... | [
"function",
"postQuery",
"(",
"statArr",
")",
"{",
"var",
"options",
"=",
"{",
"method",
":",
"'POST'",
",",
"baseUrl",
":",
"this",
".",
"NEO4J_BASEURL",
",",
"url",
":",
"this",
".",
"NEO4J_ENDPT",
",",
"headers",
":",
"{",
"'Accept'",
":",
"'applicati... | POST a comitting query to the db.
@private
@param {Array} statArr Array of statement objects.
@param {Function} callback Function with (err, res, body) args for the query result.
@return {Promise} A promise object resolved with the query results from the request module. | [
"POST",
"a",
"comitting",
"query",
"to",
"the",
"db",
"."
] | 8762390ac81974afc6bb44a2dd3c44b44aaaa09a | https://github.com/kengz/neo4jKB/blob/8762390ac81974afc6bb44a2dd3c44b44aaaa09a/lib/query.js#L89-L108 | train |
kengz/neo4jKB | lib/query.js | resolver | function resolver(obj) {
return new Promise(function(resolve, reject) {
_.isEmpty(obj.results) ? reject(new Error(JSON.stringify(obj.errors))) : resolve(obj.results);
})
} | javascript | function resolver(obj) {
return new Promise(function(resolve, reject) {
_.isEmpty(obj.results) ? reject(new Error(JSON.stringify(obj.errors))) : resolve(obj.results);
})
} | [
"function",
"resolver",
"(",
"obj",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"_",
".",
"isEmpty",
"(",
"obj",
".",
"results",
")",
"?",
"reject",
"(",
"new",
"Error",
"(",
"JSON",
".",
"stringify... | Resolver function to chain Promise to resolve results or reject errors. Used in postQuery.
@private
@param {JSON} obj Returned from the neo4j server.
@return {Promise} That resolves results or rejects errors. | [
"Resolver",
"function",
"to",
"chain",
"Promise",
"to",
"resolve",
"results",
"or",
"reject",
"errors",
".",
"Used",
"in",
"postQuery",
"."
] | 8762390ac81974afc6bb44a2dd3c44b44aaaa09a | https://github.com/kengz/neo4jKB/blob/8762390ac81974afc6bb44a2dd3c44b44aaaa09a/lib/query.js#L116-L120 | train |
seriousManual/node-piglow | lib/util/valueProcessor.js | processValue | function processValue(value) {
if (isNaN(value)) return 0;
value = Math.max(MIN_VALUE, Math.min(value, MAX_VALUE));
//value is between 0 and 1, thus is interpreted as percentage
if (value < 1) value = value * MAX_VALUE;
value = parseInt(value, 10);
return value;
} | javascript | function processValue(value) {
if (isNaN(value)) return 0;
value = Math.max(MIN_VALUE, Math.min(value, MAX_VALUE));
//value is between 0 and 1, thus is interpreted as percentage
if (value < 1) value = value * MAX_VALUE;
value = parseInt(value, 10);
return value;
} | [
"function",
"processValue",
"(",
"value",
")",
"{",
"if",
"(",
"isNaN",
"(",
"value",
")",
")",
"return",
"0",
";",
"value",
"=",
"Math",
".",
"max",
"(",
"MIN_VALUE",
",",
"Math",
".",
"min",
"(",
"value",
",",
"MAX_VALUE",
")",
")",
";",
"//value... | sanitizes brightness values and does a gamma correction mapping
@param value
@return {*} | [
"sanitizes",
"brightness",
"values",
"and",
"does",
"a",
"gamma",
"correction",
"mapping"
] | 2175fda7d56a779adb4aaec29e86cbc7745809ef | https://github.com/seriousManual/node-piglow/blob/2175fda7d56a779adb4aaec29e86cbc7745809ef/lib/util/valueProcessor.js#L9-L20 | train |
rsamec/business-rules | dist/vacationApproval/node-business-rules.js | function () {
if (this.Data.ExcludedDays == undefined || this.Data.ExcludedDays.length == 0)
return this.ExcludedWeekdays;
return _.union(this.ExcludedWeekdays, this.ExcludedDaysDatePart);
} | javascript | function () {
if (this.Data.ExcludedDays == undefined || this.Data.ExcludedDays.length == 0)
return this.ExcludedWeekdays;
return _.union(this.ExcludedWeekdays, this.ExcludedDaysDatePart);
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"Data",
".",
"ExcludedDays",
"==",
"undefined",
"||",
"this",
".",
"Data",
".",
"ExcludedDays",
".",
"length",
"==",
"0",
")",
"return",
"this",
".",
"ExcludedWeekdays",
";",
"return",
"_",
".",
"union... | Return days excluded out of vacation. | [
"Return",
"days",
"excluded",
"out",
"of",
"vacation",
"."
] | 09be8a3764874fa2b020f0e6eae1241d0a9e94cc | https://github.com/rsamec/business-rules/blob/09be8a3764874fa2b020f0e6eae1241d0a9e94cc/dist/vacationApproval/node-business-rules.js#L289-L293 | train | |
rsamec/business-rules | dist/vacationApproval/node-business-rules.js | function (config, args) {
var msg = config["Msg"];
var format = config["Format"];
if (format != undefined) {
_.extend(args, {
FormatedFrom: moment(args.From).format(format),
FormatedTo: moment(args.To).f... | javascript | function (config, args) {
var msg = config["Msg"];
var format = config["Format"];
if (format != undefined) {
_.extend(args, {
FormatedFrom: moment(args.From).format(format),
FormatedTo: moment(args.To).f... | [
"function",
"(",
"config",
",",
"args",
")",
"{",
"var",
"msg",
"=",
"config",
"[",
"\"Msg\"",
"]",
";",
"var",
"format",
"=",
"config",
"[",
"\"Format\"",
"]",
";",
"if",
"(",
"format",
"!=",
"undefined",
")",
"{",
"_",
".",
"extend",
"(",
"args",... | create custom message for validation | [
"create",
"custom",
"message",
"for",
"validation"
] | 09be8a3764874fa2b020f0e6eae1241d0a9e94cc | https://github.com/rsamec/business-rules/blob/09be8a3764874fa2b020f0e6eae1241d0a9e94cc/dist/vacationApproval/node-business-rules.js#L347-L363 | train | |
rsamec/business-rules | dist/vacationApproval/node-business-rules.js | function (args) {
args.HasError = false;
args.ErrorMessage = "";
//no dates - > nothing to validate
if (!_.isDate(this.From) || !_.isDate(this.To))
return;
if (self.FromDatePart.isAfter(self.ToDatePart)) {
... | javascript | function (args) {
args.HasError = false;
args.ErrorMessage = "";
//no dates - > nothing to validate
if (!_.isDate(this.From) || !_.isDate(this.To))
return;
if (self.FromDatePart.isAfter(self.ToDatePart)) {
... | [
"function",
"(",
"args",
")",
"{",
"args",
".",
"HasError",
"=",
"false",
";",
"args",
".",
"ErrorMessage",
"=",
"\"\"",
";",
"//no dates - > nothing to validate",
"if",
"(",
"!",
"_",
".",
"isDate",
"(",
"this",
".",
"From",
")",
"||",
"!",
"_",
".",
... | create validator function | [
"create",
"validator",
"function"
] | 09be8a3764874fa2b020f0e6eae1241d0a9e94cc | https://github.com/rsamec/business-rules/blob/09be8a3764874fa2b020f0e6eae1241d0a9e94cc/dist/vacationApproval/node-business-rules.js#L368-L405 | train | |
rsamec/business-rules | dist/vacationApproval/node-business-rules.js | function (args) {
args.HasError = false;
args.ErrorMessage = "";
var greaterThanToday = new VacationApproval.FromToDateValidator();
greaterThanToday.FromOperator = 4 /* GreaterThanEqual */;
greaterThanToday.From = new Date();
... | javascript | function (args) {
args.HasError = false;
args.ErrorMessage = "";
var greaterThanToday = new VacationApproval.FromToDateValidator();
greaterThanToday.FromOperator = 4 /* GreaterThanEqual */;
greaterThanToday.From = new Date();
... | [
"function",
"(",
"args",
")",
"{",
"args",
".",
"HasError",
"=",
"false",
";",
"args",
".",
"ErrorMessage",
"=",
"\"\"",
";",
"var",
"greaterThanToday",
"=",
"new",
"VacationApproval",
".",
"FromToDateValidator",
"(",
")",
";",
"greaterThanToday",
".",
"From... | add custom validation | [
"add",
"custom",
"validation"
] | 09be8a3764874fa2b020f0e6eae1241d0a9e94cc | https://github.com/rsamec/business-rules/blob/09be8a3764874fa2b020f0e6eae1241d0a9e94cc/dist/vacationApproval/node-business-rules.js#L517-L537 | train | |
rbackhouse/mpdjs | cordova/mpdjs/plugins/cordova-plugin-file/src/browser/FileProxy.js | onError | function onError (e) {
switch (e.target.errorCode) {
case 12:
console.log('Error - Attempt to open db with a lower version than the ' +
'current one.');
break;
default:
console.log('errorCode: ' + e.target.errorC... | javascript | function onError (e) {
switch (e.target.errorCode) {
case 12:
console.log('Error - Attempt to open db with a lower version than the ' +
'current one.');
break;
default:
console.log('errorCode: ' + e.target.errorC... | [
"function",
"onError",
"(",
"e",
")",
"{",
"switch",
"(",
"e",
".",
"target",
".",
"errorCode",
")",
"{",
"case",
"12",
":",
"console",
".",
"log",
"(",
"'Error - Attempt to open db with a lower version than the '",
"+",
"'current one.'",
")",
";",
"break",
";... | Global error handler. Errors bubble from request, to transaction, to db. | [
"Global",
"error",
"handler",
".",
"Errors",
"bubble",
"from",
"request",
"to",
"transaction",
"to",
"db",
"."
] | 23fde33a7a24ba8d516c623643e359a25a46259c | https://github.com/rbackhouse/mpdjs/blob/23fde33a7a24ba8d516c623643e359a25a46259c/cordova/mpdjs/plugins/cordova-plugin-file/src/browser/FileProxy.js#L968-L979 | train |
Deathspike/npm-build-tools | src/embed.js | embed | function embed(sourcePath, relativePaths, name, done) {
var items = '';
each(relativePaths, function(relativePath, next) {
var fullPath = path.join(sourcePath, relativePath);
fs.readFile(fullPath, 'utf8', function(err, text) {
if (err) return next(err);
items += ' $templateCache.put(\'' +
... | javascript | function embed(sourcePath, relativePaths, name, done) {
var items = '';
each(relativePaths, function(relativePath, next) {
var fullPath = path.join(sourcePath, relativePath);
fs.readFile(fullPath, 'utf8', function(err, text) {
if (err) return next(err);
items += ' $templateCache.put(\'' +
... | [
"function",
"embed",
"(",
"sourcePath",
",",
"relativePaths",
",",
"name",
",",
"done",
")",
"{",
"var",
"items",
"=",
"''",
";",
"each",
"(",
"relativePaths",
",",
"function",
"(",
"relativePath",
",",
"next",
")",
"{",
"var",
"fullPath",
"=",
"path",
... | Embed the relative paths in an angular-specific template wrapper.
@param {string} sourcePath
@param {Array.<string>} relativePaths
@param {string} name
@param {function(Error=)} done | [
"Embed",
"the",
"relative",
"paths",
"in",
"an",
"angular",
"-",
"specific",
"template",
"wrapper",
"."
] | caf2a0933b5900e34dc093f34b070a5b947cce39 | https://github.com/Deathspike/npm-build-tools/blob/caf2a0933b5900e34dc093f34b070a5b947cce39/src/embed.js#L36-L55 | train |
Deathspike/npm-build-tools | src/embed.js | inline | function inline(text) {
var result = '';
for (var i = 0; i < text.length; i += 1) {
var value = text.charAt(i);
if (value === '\'') result += '\\\'';
else if (value === '\\') result += '\\\\';
else if (value === '\b') result += '\\b';
else if (value === '\f') result += '\\f';
else if (value ... | javascript | function inline(text) {
var result = '';
for (var i = 0; i < text.length; i += 1) {
var value = text.charAt(i);
if (value === '\'') result += '\\\'';
else if (value === '\\') result += '\\\\';
else if (value === '\b') result += '\\b';
else if (value === '\f') result += '\\f';
else if (value ... | [
"function",
"inline",
"(",
"text",
")",
"{",
"var",
"result",
"=",
"''",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"text",
".",
"length",
";",
"i",
"+=",
"1",
")",
"{",
"var",
"value",
"=",
"text",
".",
"charAt",
"(",
"i",
")",
... | Escapes for inline embedding.
@param {string} text
@returns {string} | [
"Escapes",
"for",
"inline",
"embedding",
"."
] | caf2a0933b5900e34dc093f34b070a5b947cce39 | https://github.com/Deathspike/npm-build-tools/blob/caf2a0933b5900e34dc093f34b070a5b947cce39/src/embed.js#L62-L76 | train |
raineorshine/generator-yoga | app/index.js | parseArray | function parseArray(str) {
return R.filter(R.identity, str.split(',').map(R.invoker(0, 'trim')))
} | javascript | function parseArray(str) {
return R.filter(R.identity, str.split(',').map(R.invoker(0, 'trim')))
} | [
"function",
"parseArray",
"(",
"str",
")",
"{",
"return",
"R",
".",
"filter",
"(",
"R",
".",
"identity",
",",
"str",
".",
"split",
"(",
"','",
")",
".",
"map",
"(",
"R",
".",
"invoker",
"(",
"0",
",",
"'trim'",
")",
")",
")",
"}"
] | parse an array from a string | [
"parse",
"an",
"array",
"from",
"a",
"string"
] | 26b133ee29a8a690e208efcabbeac28fde4e93a4 | https://github.com/raineorshine/generator-yoga/blob/26b133ee29a8a690e208efcabbeac28fde4e93a4/app/index.js#L16-L18 | train |
raineorshine/generator-yoga | app/index.js | stringifyIndented | function stringifyIndented(value, chr, n) {
return indent(JSON.stringify(value, null, n), chr, n).slice(chr.length * n)
} | javascript | function stringifyIndented(value, chr, n) {
return indent(JSON.stringify(value, null, n), chr, n).slice(chr.length * n)
} | [
"function",
"stringifyIndented",
"(",
"value",
",",
"chr",
",",
"n",
")",
"{",
"return",
"indent",
"(",
"JSON",
".",
"stringify",
"(",
"value",
",",
"null",
",",
"n",
")",
",",
"chr",
",",
"n",
")",
".",
"slice",
"(",
"chr",
".",
"length",
"*",
"... | stringify an object and indent everything after the opening line | [
"stringify",
"an",
"object",
"and",
"indent",
"everything",
"after",
"the",
"opening",
"line"
] | 26b133ee29a8a690e208efcabbeac28fde4e93a4 | https://github.com/raineorshine/generator-yoga/blob/26b133ee29a8a690e208efcabbeac28fde4e93a4/app/index.js#L21-L23 | train |
raineorshine/generator-yoga | app/index.js | function () {
var done = this.async();
if(this.createMode) {
// copy yoga-generator itself
this.fs.copy(path.join(__dirname, '../'), this.destinationPath(), {
globOptions: {
dot: true,
ignore: [
'**/.DS_Store',
'**/.git',
'**/.git/**... | javascript | function () {
var done = this.async();
if(this.createMode) {
// copy yoga-generator itself
this.fs.copy(path.join(__dirname, '../'), this.destinationPath(), {
globOptions: {
dot: true,
ignore: [
'**/.DS_Store',
'**/.git',
'**/.git/**... | [
"function",
"(",
")",
"{",
"var",
"done",
"=",
"this",
".",
"async",
"(",
")",
";",
"if",
"(",
"this",
".",
"createMode",
")",
"{",
"// copy yoga-generator itself",
"this",
".",
"fs",
".",
"copy",
"(",
"path",
".",
"join",
"(",
"__dirname",
",",
"'..... | Copies all files from the template directory to the destination path parsing filenames using prefixnote and running them through striate | [
"Copies",
"all",
"files",
"from",
"the",
"template",
"directory",
"to",
"the",
"destination",
"path",
"parsing",
"filenames",
"using",
"prefixnote",
"and",
"running",
"them",
"through",
"striate"
] | 26b133ee29a8a690e208efcabbeac28fde4e93a4 | https://github.com/raineorshine/generator-yoga/blob/26b133ee29a8a690e208efcabbeac28fde4e93a4/app/index.js#L106-L157 | train | |
alexindigo/manifesto | manifesto.js | parseManifest | function parseManifest(manifest, docroot, callback)
{
var inCache = false
, lines = [];
// get manifest file data
fs.readFile(manifest, 'ascii', function(err, data)
{
var counter = 0;
if (err)
{
// to prevent sudden continuation
return callback(err);
}
... | javascript | function parseManifest(manifest, docroot, callback)
{
var inCache = false
, lines = [];
// get manifest file data
fs.readFile(manifest, 'ascii', function(err, data)
{
var counter = 0;
if (err)
{
// to prevent sudden continuation
return callback(err);
}
... | [
"function",
"parseManifest",
"(",
"manifest",
",",
"docroot",
",",
"callback",
")",
"{",
"var",
"inCache",
"=",
"false",
",",
"lines",
"=",
"[",
"]",
";",
"// get manifest file data",
"fs",
".",
"readFile",
"(",
"manifest",
",",
"'ascii'",
",",
"function",
... | strip cacheable items from the manifest file | [
"strip",
"cacheable",
"items",
"from",
"the",
"manifest",
"file"
] | 5ec285d3ef6db35c7c5c017694665e4b0f4119c3 | https://github.com/alexindigo/manifesto/blob/5ec285d3ef6db35c7c5c017694665e4b0f4119c3/manifesto.js#L48-L134 | train |
alexindigo/manifesto | manifesto.js | addWatcher | function addWatcher(file, handler, callback)
{
fs.stat(file, function(err, stat)
{
if (err) return callback(false);
fs.watch(file, handler(file));
callback(true, stat.mtime.getTime());
});
} | javascript | function addWatcher(file, handler, callback)
{
fs.stat(file, function(err, stat)
{
if (err) return callback(false);
fs.watch(file, handler(file));
callback(true, stat.mtime.getTime());
});
} | [
"function",
"addWatcher",
"(",
"file",
",",
"handler",
",",
"callback",
")",
"{",
"fs",
".",
"stat",
"(",
"file",
",",
"function",
"(",
"err",
",",
"stat",
")",
"{",
"if",
"(",
"err",
")",
"return",
"callback",
"(",
"false",
")",
";",
"fs",
".",
... | gets file's mtime and sets the watcher | [
"gets",
"file",
"s",
"mtime",
"and",
"sets",
"the",
"watcher"
] | 5ec285d3ef6db35c7c5c017694665e4b0f4119c3 | https://github.com/alexindigo/manifesto/blob/5ec285d3ef6db35c7c5c017694665e4b0f4119c3/manifesto.js#L137-L147 | train |
alexindigo/manifesto | manifesto.js | watcher | function watcher(manifest)
{
return function(file)
{
return function(event)
{
if (event == 'change')
{
fs.stat(file, function(err, stat)
{
if (err) return; // do nothing at this point
var mtime = stat.mtime.getTime();
if (cache[manifest].version < ... | javascript | function watcher(manifest)
{
return function(file)
{
return function(event)
{
if (event == 'change')
{
fs.stat(file, function(err, stat)
{
if (err) return; // do nothing at this point
var mtime = stat.mtime.getTime();
if (cache[manifest].version < ... | [
"function",
"watcher",
"(",
"manifest",
")",
"{",
"return",
"function",
"(",
"file",
")",
"{",
"return",
"function",
"(",
"event",
")",
"{",
"if",
"(",
"event",
"==",
"'change'",
")",
"{",
"fs",
".",
"stat",
"(",
"file",
",",
"function",
"(",
"err",
... | generates version watcher callback going total inception | [
"generates",
"version",
"watcher",
"callback",
"going",
"total",
"inception"
] | 5ec285d3ef6db35c7c5c017694665e4b0f4119c3 | https://github.com/alexindigo/manifesto/blob/5ec285d3ef6db35c7c5c017694665e4b0f4119c3/manifesto.js#L151-L172 | train |
sematext/spm-agent | lib/agent.js | Agent | function Agent (plugin) {
var events = require('events')
var util = require('util')
var eventEmitter = new events.EventEmitter()
var cluster = require('cluster')
var workerId = 0 + '-' + process.pid // 0 == Master, default
if (!cluster.isMaster) {
workerId = cluster.worker.id + '-' + process.pid
}
v... | javascript | function Agent (plugin) {
var events = require('events')
var util = require('util')
var eventEmitter = new events.EventEmitter()
var cluster = require('cluster')
var workerId = 0 + '-' + process.pid // 0 == Master, default
if (!cluster.isMaster) {
workerId = cluster.worker.id + '-' + process.pid
}
v... | [
"function",
"Agent",
"(",
"plugin",
")",
"{",
"var",
"events",
"=",
"require",
"(",
"'events'",
")",
"var",
"util",
"=",
"require",
"(",
"'util'",
")",
"var",
"eventEmitter",
"=",
"new",
"events",
".",
"EventEmitter",
"(",
")",
"var",
"cluster",
"=",
"... | Agent super class that provides an EventEmitter for 'metric' event.
In addition it fires for each added metric an event named by the property metric.name
@param {function} plugin - Function providing a plugin having start(agent) and stop method. The plugin can use agent.addMetric function.
@returns {function} an Agen... | [
"Agent",
"super",
"class",
"that",
"provides",
"an",
"EventEmitter",
"for",
"metric",
"event",
".",
"In",
"addition",
"it",
"fires",
"for",
"each",
"added",
"metric",
"an",
"event",
"named",
"by",
"the",
"property",
"metric",
".",
"name"
] | 7b98be0cfc41fb7bf7f7c605e6602148570269a3 | https://github.com/sematext/spm-agent/blob/7b98be0cfc41fb7bf7f7c605e6602148570269a3/lib/agent.js#L29-L147 | train |
sematext/spm-agent | lib/agent.js | function (metric) {
metric.workerId = workerId
metric.pid = process.pid
if (!metric.sct) {
if (metric.name && /collectd/.test(metric.name)) {
metric.sct = 'OS'
} else {
metric.sct = 'APP'
}
}
if (!metric.ts) {
metric.ts = new Date().getTi... | javascript | function (metric) {
metric.workerId = workerId
metric.pid = process.pid
if (!metric.sct) {
if (metric.name && /collectd/.test(metric.name)) {
metric.sct = 'OS'
} else {
metric.sct = 'APP'
}
}
if (!metric.ts) {
metric.ts = new Date().getTi... | [
"function",
"(",
"metric",
")",
"{",
"metric",
".",
"workerId",
"=",
"workerId",
"metric",
".",
"pid",
"=",
"process",
".",
"pid",
"if",
"(",
"!",
"metric",
".",
"sct",
")",
"{",
"if",
"(",
"metric",
".",
"name",
"&&",
"/",
"collectd",
"/",
".",
... | Adds a metric value and emits event to listeners on 'metric' or metric.name
@param metric | [
"Adds",
"a",
"metric",
"value",
"and",
"emits",
"event",
"to",
"listeners",
"on",
"metric",
"or",
"metric",
".",
"name"
] | 7b98be0cfc41fb7bf7f7c605e6602148570269a3 | https://github.com/sematext/spm-agent/blob/7b98be0cfc41fb7bf7f7c605e6602148570269a3/lib/agent.js#L49-L73 | train | |
reelyactive/barterer | lib/routes/whereis.js | redirect | function redirect(id, prefix, suffix, res) {
var validatedID = reelib.identifier.toIdentifierString(id);
if(validatedID && (validatedID !== id)) {
res.redirect(prefix + validatedID + suffix);
return true;
}
return false;
} | javascript | function redirect(id, prefix, suffix, res) {
var validatedID = reelib.identifier.toIdentifierString(id);
if(validatedID && (validatedID !== id)) {
res.redirect(prefix + validatedID + suffix);
return true;
}
return false;
} | [
"function",
"redirect",
"(",
"id",
",",
"prefix",
",",
"suffix",
",",
"res",
")",
"{",
"var",
"validatedID",
"=",
"reelib",
".",
"identifier",
".",
"toIdentifierString",
"(",
"id",
")",
";",
"if",
"(",
"validatedID",
"&&",
"(",
"validatedID",
"!==",
"id"... | Redirect if required and return the status.
@param {String} id The given ID.
@param {String} prefix The prefix to the ID in the path.
@param {String} suffix The suffix to the ID in the path.
@param {Object} res The HTTP result.
@return {boolean} Redirection performed? | [
"Redirect",
"if",
"required",
"and",
"return",
"the",
"status",
"."
] | ab4caa541b13c78cca3f4df9dcfc8f17c1c14c2c | https://github.com/reelyactive/barterer/blob/ab4caa541b13c78cca3f4df9dcfc8f17c1c14c2c/lib/routes/whereis.js#L58-L67 | train |
yamadapc/airbnb-scrapper | lib/index.js | main | function main(program) {
program || (program = { args: [] });
if(program.args.length === 0) {
program.outputHelp();
return process.exit(1);
}
return Promise
.map(program.args, _.partial(exports.downloadPosting, program))
.map(function(html) {
return cheerio.load(html);
})
.map(exp... | javascript | function main(program) {
program || (program = { args: [] });
if(program.args.length === 0) {
program.outputHelp();
return process.exit(1);
}
return Promise
.map(program.args, _.partial(exports.downloadPosting, program))
.map(function(html) {
return cheerio.load(html);
})
.map(exp... | [
"function",
"main",
"(",
"program",
")",
"{",
"program",
"||",
"(",
"program",
"=",
"{",
"args",
":",
"[",
"]",
"}",
")",
";",
"if",
"(",
"program",
".",
"args",
".",
"length",
"===",
"0",
")",
"{",
"program",
".",
"outputHelp",
"(",
")",
";",
... | Takes a `program` instance from the `commander` module and executes the `cli`
functionality.
@param {Object} program A `program` object from `commander`
@return {Promise} A promise to the execution's result | [
"Takes",
"a",
"program",
"instance",
"from",
"the",
"commander",
"module",
"and",
"executes",
"the",
"cli",
"functionality",
"."
] | 7cf98ecb496e348f91568ceb5aca4cb57205ace5 | https://github.com/yamadapc/airbnb-scrapper/blob/7cf98ecb496e348f91568ceb5aca4cb57205ace5/lib/index.js#L26-L40 | train |
alexindigo/mixly | append.js | mixAppend | function mixAppend(to)
{
var args = Array.prototype.slice.call(arguments)
, i = 0
;
// it will start with `1` – second argument
// leaving `to` out of the loop
while (++i < args.length)
{
copy(to, args[i]);
}
return to;
} | javascript | function mixAppend(to)
{
var args = Array.prototype.slice.call(arguments)
, i = 0
;
// it will start with `1` – second argument
// leaving `to` out of the loop
while (++i < args.length)
{
copy(to, args[i]);
}
return to;
} | [
"function",
"mixAppend",
"(",
"to",
")",
"{",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
",",
"i",
"=",
"0",
";",
"// it will start with `1` – second argument",
"// leaving `to` out of the loop",
"while",
"("... | Merges objects into the first one
@param {object} to - object to merge into
@param {...object} from - object(s) to merge with
@returns {object} - mixed result object | [
"Merges",
"objects",
"into",
"the",
"first",
"one"
] | 602081b28806dc46286da783fef4f3ba1ecbb199 | https://github.com/alexindigo/mixly/blob/602081b28806dc46286da783fef4f3ba1ecbb199/append.js#L13-L27 | train |
weswigham/not.js | not.js | function(rec, key) {
return (function() {
if (typeof key === "symbol") {
return undefined;
}
if (key === scopeName) {
return scope;
}
if (key === indicator) {
return proxy;
}
if (key.sli... | javascript | function(rec, key) {
return (function() {
if (typeof key === "symbol") {
return undefined;
}
if (key === scopeName) {
return scope;
}
if (key === indicator) {
return proxy;
}
if (key.sli... | [
"function",
"(",
"rec",
",",
"key",
")",
"{",
"return",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"typeof",
"key",
"===",
"\"symbol\"",
")",
"{",
"return",
"undefined",
";",
"}",
"if",
"(",
"key",
"===",
"scopeName",
")",
"{",
"return",
"scope",
"... | New version of the has-all-the-things trap | [
"New",
"version",
"of",
"the",
"has",
"-",
"all",
"-",
"the",
"-",
"things",
"trap"
] | 58688349c9945e1d56ab2864e942c8f3e2e7cb55 | https://github.com/weswigham/not.js/blob/58688349c9945e1d56ab2864e942c8f3e2e7cb55/not.js#L264-L333 | train | |
weswigham/not.js | not.js | prepareFunc | function prepareFunc(func, builder, basepath) { //Prepare an implied function for repeated use
funcStringCache[func] = funcStringCache[func] || ('(function() { with (proxy(scope)) { return ('+func.toString()+')('+defaultScopeName+'); } })()');
return function(scope) {
var scope = scope || {};
var builder =... | javascript | function prepareFunc(func, builder, basepath) { //Prepare an implied function for repeated use
funcStringCache[func] = funcStringCache[func] || ('(function() { with (proxy(scope)) { return ('+func.toString()+')('+defaultScopeName+'); } })()');
return function(scope) {
var scope = scope || {};
var builder =... | [
"function",
"prepareFunc",
"(",
"func",
",",
"builder",
",",
"basepath",
")",
"{",
"//Prepare an implied function for repeated use",
"funcStringCache",
"[",
"func",
"]",
"=",
"funcStringCache",
"[",
"func",
"]",
"||",
"(",
"'(function() { with (proxy(scope)) { return ('",... | Cache stringified functions for implied usage | [
"Cache",
"stringified",
"functions",
"for",
"implied",
"usage"
] | 58688349c9945e1d56ab2864e942c8f3e2e7cb55 | https://github.com/weswigham/not.js/blob/58688349c9945e1d56ab2864e942c8f3e2e7cb55/not.js#L358-L372 | train |
alexindigo/mixly | chain.js | mixChain | function mixChain()
{
var args = Array.prototype.slice.call(arguments)
, i = args.length
;
while (--i > 0)
{
args[i-1].__proto__ = args[i];
}
return args[i];
} | javascript | function mixChain()
{
var args = Array.prototype.slice.call(arguments)
, i = args.length
;
while (--i > 0)
{
args[i-1].__proto__ = args[i];
}
return args[i];
} | [
"function",
"mixChain",
"(",
")",
"{",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
",",
"i",
"=",
"args",
".",
"length",
";",
"while",
"(",
"--",
"i",
">",
"0",
")",
"{",
"args",
"[",
"i",
"-... | Modifies prototype chain for the provided objects,
based on the order of the arguments
@param {...object} object - objects to be part of the prototype chain
@returns {object} - augmented object | [
"Modifies",
"prototype",
"chain",
"for",
"the",
"provided",
"objects",
"based",
"on",
"the",
"order",
"of",
"the",
"arguments"
] | 602081b28806dc46286da783fef4f3ba1ecbb199 | https://github.com/alexindigo/mixly/blob/602081b28806dc46286da783fef4f3ba1ecbb199/chain.js#L11-L23 | train |
Smile-SA/grunt-build-html | tasks/buildHtml.js | function (remoteUrl) {
if (remoteUrl.indexOf('http') !== 0) {
grunt.log.error('Something seems wrong with this remote url: ' + remoteUrl);
}
return remoteUrl.toLowerCase().replace('://', '@@').replace(/\?/g, '@');
} | javascript | function (remoteUrl) {
if (remoteUrl.indexOf('http') !== 0) {
grunt.log.error('Something seems wrong with this remote url: ' + remoteUrl);
}
return remoteUrl.toLowerCase().replace('://', '@@').replace(/\?/g, '@');
} | [
"function",
"(",
"remoteUrl",
")",
"{",
"if",
"(",
"remoteUrl",
".",
"indexOf",
"(",
"'http'",
")",
"!==",
"0",
")",
"{",
"grunt",
".",
"log",
".",
"error",
"(",
"'Something seems wrong with this remote url: '",
"+",
"remoteUrl",
")",
";",
"}",
"return",
"... | Transform URL to cache key in order to dump its content
@param remoteUrl Remote content URL
@returns {string|*} URL as cache key | [
"Transform",
"URL",
"to",
"cache",
"key",
"in",
"order",
"to",
"dump",
"its",
"content"
] | 6fe1644ff6d08e0eada9482ae9dcdb0d4169ea2e | https://github.com/Smile-SA/grunt-build-html/blob/6fe1644ff6d08e0eada9482ae9dcdb0d4169ea2e/tasks/buildHtml.js#L67-L72 | train | |
Smile-SA/grunt-build-html | tasks/buildHtml.js | function (tplUrl, data) {
if (urlPrefix) {
tplUrl = urlPrefix + tplUrl;
}
if (urlSuffix) {
tplUrl += urlSuffix;
}
var html = '';
debug(' retrieve remote content from ' + tplUrl);
var remoteFragmentKey = getTemplateCacheKeyFromRemoteUrl(tplUrl);
... | javascript | function (tplUrl, data) {
if (urlPrefix) {
tplUrl = urlPrefix + tplUrl;
}
if (urlSuffix) {
tplUrl += urlSuffix;
}
var html = '';
debug(' retrieve remote content from ' + tplUrl);
var remoteFragmentKey = getTemplateCacheKeyFromRemoteUrl(tplUrl);
... | [
"function",
"(",
"tplUrl",
",",
"data",
")",
"{",
"if",
"(",
"urlPrefix",
")",
"{",
"tplUrl",
"=",
"urlPrefix",
"+",
"tplUrl",
";",
"}",
"if",
"(",
"urlSuffix",
")",
"{",
"tplUrl",
"+=",
"urlSuffix",
";",
"}",
"var",
"html",
"=",
"''",
";",
"debug"... | Retrieve remote content method to be used in HTML files.
@param tplUrl
Remote content URL
@param data
Options
@returns {*} Remote content data | [
"Retrieve",
"remote",
"content",
"method",
"to",
"be",
"used",
"in",
"HTML",
"files",
"."
] | 6fe1644ff6d08e0eada9482ae9dcdb0d4169ea2e | https://github.com/Smile-SA/grunt-build-html/blob/6fe1644ff6d08e0eada9482ae9dcdb0d4169ea2e/tasks/buildHtml.js#L90-L112 | train | |
Smile-SA/grunt-build-html | tasks/buildHtml.js | function (tplName, data, ignoreEvaluation) {
var files, templateData, html = '';
if (typeof data !== 'object') {
ignoreEvaluation = data;
data = {};
}
data = _.extend({}, options.data, data);
if (_.has(templates, tplName)) {
debug(' include ' + templates[tp... | javascript | function (tplName, data, ignoreEvaluation) {
var files, templateData, html = '';
if (typeof data !== 'object') {
ignoreEvaluation = data;
data = {};
}
data = _.extend({}, options.data, data);
if (_.has(templates, tplName)) {
debug(' include ' + templates[tp... | [
"function",
"(",
"tplName",
",",
"data",
",",
"ignoreEvaluation",
")",
"{",
"var",
"files",
",",
"templateData",
",",
"html",
"=",
"''",
";",
"if",
"(",
"typeof",
"data",
"!==",
"'object'",
")",
"{",
"ignoreEvaluation",
"=",
"data",
";",
"data",
"=",
"... | Include method to be used in HTML files.
@param tplName Relative template path
@param data The data object used to populate the text.
@returns {string} Compiled template content | [
"Include",
"method",
"to",
"be",
"used",
"in",
"HTML",
"files",
"."
] | 6fe1644ff6d08e0eada9482ae9dcdb0d4169ea2e | https://github.com/Smile-SA/grunt-build-html/blob/6fe1644ff6d08e0eada9482ae9dcdb0d4169ea2e/tasks/buildHtml.js#L120-L150 | 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.