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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
byCedric/semantic-release-git-branches | lib/git.js | getModifiedFiles | async function getModifiedFiles() {
return (await execa.stdout('git', ['ls-files', '-m', '-o', '--exclude-standard']))
.split('\n')
.map(tag => tag.trim())
.filter(tag => Boolean(tag));
} | javascript | async function getModifiedFiles() {
return (await execa.stdout('git', ['ls-files', '-m', '-o', '--exclude-standard']))
.split('\n')
.map(tag => tag.trim())
.filter(tag => Boolean(tag));
} | [
"async",
"function",
"getModifiedFiles",
"(",
")",
"{",
"return",
"(",
"await",
"execa",
".",
"stdout",
"(",
"'git'",
",",
"[",
"'ls-files'",
",",
"'-m'",
",",
"'-o'",
",",
"'--exclude-standard'",
"]",
")",
")",
".",
"split",
"(",
"'\\n'",
")",
".",
"m... | Retrieve the list of files modified on the local repository.
@return {Array<String>} Array of modified files path. | [
"Retrieve",
"the",
"list",
"of",
"files",
"modified",
"on",
"the",
"local",
"repository",
"."
] | 199337210d7dd21d9cd8442604ef9e063ef69dc2 | https://github.com/byCedric/semantic-release-git-branches/blob/199337210d7dd21d9cd8442604ef9e063ef69dc2/lib/git.js#L9-L14 | train |
fibo/dflow | src/engine/level.js | level | function level (pipe, cachedLevelOf, taskKey) {
var taskLevel = 0
var parentsOf = parents.bind(null, pipe)
if (typeof cachedLevelOf[taskKey] === 'number') {
return cachedLevelOf[taskKey]
}
function computeLevel (parentTaskKey) {
// ↓ Recursion here: the level of a task is the max level of its parent... | javascript | function level (pipe, cachedLevelOf, taskKey) {
var taskLevel = 0
var parentsOf = parents.bind(null, pipe)
if (typeof cachedLevelOf[taskKey] === 'number') {
return cachedLevelOf[taskKey]
}
function computeLevel (parentTaskKey) {
// ↓ Recursion here: the level of a task is the max level of its parent... | [
"function",
"level",
"(",
"pipe",
",",
"cachedLevelOf",
",",
"taskKey",
")",
"{",
"var",
"taskLevel",
"=",
"0",
"var",
"parentsOf",
"=",
"parents",
".",
"bind",
"(",
"null",
",",
"pipe",
")",
"if",
"(",
"typeof",
"cachedLevelOf",
"[",
"taskKey",
"]",
"... | Compute level of task.
@param {Object} pipe
@param {Object} cachedLevelOf
@param {String} taskKey
@returns {Number} taskLevel | [
"Compute",
"level",
"of",
"task",
"."
] | 6530e4659952b9013e47b5fb28fbbd3a7a4af17d | https://github.com/fibo/dflow/blob/6530e4659952b9013e47b5fb28fbbd3a7a4af17d/src/engine/level.js#L13-L31 | train |
fedecia/gmail-api-sync | index.js | function (callback) {
fs.readFile(clientSecretPath, function processClientSecrets(err, content) {
if (err) {
debug('Error loading client secret file: ' + err);
return callback(err);
} else {
credentials = JSON.parse(content);
return callback();
... | javascript | function (callback) {
fs.readFile(clientSecretPath, function processClientSecrets(err, content) {
if (err) {
debug('Error loading client secret file: ' + err);
return callback(err);
} else {
credentials = JSON.parse(content);
return callback();
... | [
"function",
"(",
"callback",
")",
"{",
"fs",
".",
"readFile",
"(",
"clientSecretPath",
",",
"function",
"processClientSecrets",
"(",
"err",
",",
"content",
")",
"{",
"if",
"(",
"err",
")",
"{",
"debug",
"(",
"'Error loading client secret file: '",
"+",
"err",
... | Load client secrets from a local file. | [
"Load",
"client",
"secrets",
"from",
"a",
"local",
"file",
"."
] | c29bfda8735eaa6590d05f59e45d6301385a321c | https://github.com/fedecia/gmail-api-sync/blob/c29bfda8735eaa6590d05f59e45d6301385a321c/index.js#L23-L33 | train | |
fibo/dflow | src/engine/isDflowFun.js | isDflowFun | function isDflowFun (f) {
var isFunction = typeof f === 'function'
var hasFuncsObject = typeof f.funcs === 'object'
var hasGraphObject = typeof f.graph === 'object'
var hasValidGraph = true
if (!isFunction || !hasFuncsObject || !hasGraphObject) return false
if (isFunction && hasGraphObject && hasFuncsObje... | javascript | function isDflowFun (f) {
var isFunction = typeof f === 'function'
var hasFuncsObject = typeof f.funcs === 'object'
var hasGraphObject = typeof f.graph === 'object'
var hasValidGraph = true
if (!isFunction || !hasFuncsObject || !hasGraphObject) return false
if (isFunction && hasGraphObject && hasFuncsObje... | [
"function",
"isDflowFun",
"(",
"f",
")",
"{",
"var",
"isFunction",
"=",
"typeof",
"f",
"===",
"'function'",
"var",
"hasFuncsObject",
"=",
"typeof",
"f",
".",
"funcs",
"===",
"'object'",
"var",
"hasGraphObject",
"=",
"typeof",
"f",
".",
"graph",
"===",
"'ob... | Duct tape for dflow functions.
@param {Function} f
@returns {Boolean} ok, it looks like a dflowFun | [
"Duct",
"tape",
"for",
"dflow",
"functions",
"."
] | 6530e4659952b9013e47b5fb28fbbd3a7a4af17d | https://github.com/fibo/dflow/blob/6530e4659952b9013e47b5fb28fbbd3a7a4af17d/src/engine/isDflowFun.js#L11-L28 | train |
OADA/oada-formats | formats.js | Formats | function Formats(options) {
options = options || {};
this.debugConstructor = options.debug || debug;
this.debug = this.debugConstructor('oada:formats');
this.errorConstructor = options.error || debug;
this.error = this.errorConstructor('oada:formats:error');
this.Model = Model;
this.model... | javascript | function Formats(options) {
options = options || {};
this.debugConstructor = options.debug || debug;
this.debug = this.debugConstructor('oada:formats');
this.errorConstructor = options.error || debug;
this.error = this.errorConstructor('oada:formats:error');
this.Model = Model;
this.model... | [
"function",
"Formats",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"debugConstructor",
"=",
"options",
".",
"debug",
"||",
"debug",
";",
"this",
".",
"debug",
"=",
"this",
".",
"debugConstructor",
"(",
"'oada:fo... | Maintains and builds OADA format models
@constructor
@param {object} options - Various optional options
@param {function} options.debug - A custom debug logger, debug.js interface
@param {function} options.error - A custom error logger, debug.js interface | [
"Maintains",
"and",
"builds",
"OADA",
"format",
"models"
] | ac4b4ab496736c0803e00e1eaf98377d6b15058d | https://github.com/OADA/oada-formats/blob/ac4b4ab496736c0803e00e1eaf98377d6b15058d/formats.js#L43-L61 | train |
fibo/dflow | src/engine/inputArgs.js | inputArgs | function inputArgs (outs, pipe, taskKey) {
var args = []
var inputPipesOf = inputPipes.bind(null, pipe)
function populateArg (inputPipe) {
var index = inputPipe[2] || 0
var value = outs[inputPipe[0]]
args[index] = value
}
inputPipesOf(taskKey).forEach(populateArg)
return args
} | javascript | function inputArgs (outs, pipe, taskKey) {
var args = []
var inputPipesOf = inputPipes.bind(null, pipe)
function populateArg (inputPipe) {
var index = inputPipe[2] || 0
var value = outs[inputPipe[0]]
args[index] = value
}
inputPipesOf(taskKey).forEach(populateArg)
return args
} | [
"function",
"inputArgs",
"(",
"outs",
",",
"pipe",
",",
"taskKey",
")",
"{",
"var",
"args",
"=",
"[",
"]",
"var",
"inputPipesOf",
"=",
"inputPipes",
".",
"bind",
"(",
"null",
",",
"pipe",
")",
"function",
"populateArg",
"(",
"inputPipe",
")",
"{",
"var... | Retrieve input arguments of a task.
@param {Object} outs
@param {Object} pipe
@param {String} taskKey
@returns {Array} args | [
"Retrieve",
"input",
"arguments",
"of",
"a",
"task",
"."
] | 6530e4659952b9013e47b5fb28fbbd3a7a4af17d | https://github.com/fibo/dflow/blob/6530e4659952b9013e47b5fb28fbbd3a7a4af17d/src/engine/inputArgs.js#L13-L27 | train |
mojitoholic/pauldron | pauldron-policy/SimplePolicyDecisionCombinerEngine.js | evaluate | function evaluate(request, policies, engines) {
const decisions = policies.map((policy) => (
engines[policy.type].evaluate(request, policy)
));
return combineDecisionsDenyOverrides(decisions);
} | javascript | function evaluate(request, policies, engines) {
const decisions = policies.map((policy) => (
engines[policy.type].evaluate(request, policy)
));
return combineDecisionsDenyOverrides(decisions);
} | [
"function",
"evaluate",
"(",
"request",
",",
"policies",
",",
"engines",
")",
"{",
"const",
"decisions",
"=",
"policies",
".",
"map",
"(",
"(",
"policy",
")",
"=>",
"(",
"engines",
"[",
"policy",
".",
"type",
"]",
".",
"evaluate",
"(",
"request",
",",
... | deny-override | [
"deny",
"-",
"override"
] | ec5acc53be9ae75436ef46cef6dddd8f088732a3 | https://github.com/mojitoholic/pauldron/blob/ec5acc53be9ae75436ef46cef6dddd8f088732a3/pauldron-policy/SimplePolicyDecisionCombinerEngine.js#L31-L36 | train |
retextjs/retext-emoji | index.js | toGemoji | function toGemoji(node) {
var value = toString(node)
var info = (unicodes[value] || emoticons[value] || {}).shortcode
if (info) {
node.value = info
}
} | javascript | function toGemoji(node) {
var value = toString(node)
var info = (unicodes[value] || emoticons[value] || {}).shortcode
if (info) {
node.value = info
}
} | [
"function",
"toGemoji",
"(",
"node",
")",
"{",
"var",
"value",
"=",
"toString",
"(",
"node",
")",
"var",
"info",
"=",
"(",
"unicodes",
"[",
"value",
"]",
"||",
"emoticons",
"[",
"value",
"]",
"||",
"{",
"}",
")",
".",
"shortcode",
"if",
"(",
"info"... | Replace a unicode emoji with a short-code. | [
"Replace",
"a",
"unicode",
"emoji",
"with",
"a",
"short",
"-",
"code",
"."
] | 2edeea12f59bed2b0cb29acbf93bfb29fd8b1b1e | https://github.com/retextjs/retext-emoji/blob/2edeea12f59bed2b0cb29acbf93bfb29fd8b1b1e/index.js#L80-L87 | train |
retextjs/retext-emoji | index.js | toEmoji | function toEmoji(node) {
var value = toString(node)
var info = (shortcodes[value] || emoticons[value] || {}).emoji
if (info) {
node.value = info
}
} | javascript | function toEmoji(node) {
var value = toString(node)
var info = (shortcodes[value] || emoticons[value] || {}).emoji
if (info) {
node.value = info
}
} | [
"function",
"toEmoji",
"(",
"node",
")",
"{",
"var",
"value",
"=",
"toString",
"(",
"node",
")",
"var",
"info",
"=",
"(",
"shortcodes",
"[",
"value",
"]",
"||",
"emoticons",
"[",
"value",
"]",
"||",
"{",
"}",
")",
".",
"emoji",
"if",
"(",
"info",
... | Replace a short-code with a unicode emoji. | [
"Replace",
"a",
"short",
"-",
"code",
"with",
"a",
"unicode",
"emoji",
"."
] | 2edeea12f59bed2b0cb29acbf93bfb29fd8b1b1e | https://github.com/retextjs/retext-emoji/blob/2edeea12f59bed2b0cb29acbf93bfb29fd8b1b1e/index.js#L90-L97 | train |
fabric8-ui/ngx-widgets | gulpfile.js | minifyTemplate | function minifyTemplate(file) {
try {
let minifiedFile = htmlMinifier.minify(file, {
collapseWhitespace: true,
caseSensitive: true,
removeComments: true
});
return minifiedFile;
} catch (err) {
console.log(err);
}
} | javascript | function minifyTemplate(file) {
try {
let minifiedFile = htmlMinifier.minify(file, {
collapseWhitespace: true,
caseSensitive: true,
removeComments: true
});
return minifiedFile;
} catch (err) {
console.log(err);
}
} | [
"function",
"minifyTemplate",
"(",
"file",
")",
"{",
"try",
"{",
"let",
"minifiedFile",
"=",
"htmlMinifier",
".",
"minify",
"(",
"file",
",",
"{",
"collapseWhitespace",
":",
"true",
",",
"caseSensitive",
":",
"true",
",",
"removeComments",
":",
"true",
"}",
... | Minify HTML templates | [
"Minify",
"HTML",
"templates"
] | b569e15fac75c5739d87b1c9a46216bb792c8d80 | https://github.com/fabric8-ui/ngx-widgets/blob/b569e15fac75c5739d87b1c9a46216bb792c8d80/gulpfile.js#L73-L84 | train |
fabric8-ui/ngx-widgets | gulpfile.js | transpile | function transpile() {
return exec('node_modules/.bin/ngc -p tsconfig.json', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
if (err !== null) {
process.exit(1);
}
});
} | javascript | function transpile() {
return exec('node_modules/.bin/ngc -p tsconfig.json', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
if (err !== null) {
process.exit(1);
}
});
} | [
"function",
"transpile",
"(",
")",
"{",
"return",
"exec",
"(",
"'node_modules/.bin/ngc -p tsconfig.json'",
",",
"function",
"(",
"err",
",",
"stdout",
",",
"stderr",
")",
"{",
"console",
".",
"log",
"(",
"stdout",
")",
";",
"console",
".",
"log",
"(",
"std... | Build the components
Since the gulpngc is no longer being supported we need to us ngc
@returns {ChildProcess} | [
"Build",
"the",
"components",
"Since",
"the",
"gulpngc",
"is",
"no",
"longer",
"being",
"supported",
"we",
"need",
"to",
"us",
"ngc"
] | b569e15fac75c5739d87b1c9a46216bb792c8d80 | https://github.com/fabric8-ui/ngx-widgets/blob/b569e15fac75c5739d87b1c9a46216bb792c8d80/gulpfile.js#L158-L166 | train |
ShoppinPal/Materializecss-Autocomplete | dist/js/materializecss-autocomplete.js | clearValue | function clearValue() {
clearSelectedItem();
setInputClearButton();
if (self.parentForm && self.parentForm !== null) {
self.parentForm.$setDirty();
}
} | javascript | function clearValue() {
clearSelectedItem();
setInputClearButton();
if (self.parentForm && self.parentForm !== null) {
self.parentForm.$setDirty();
}
} | [
"function",
"clearValue",
"(",
")",
"{",
"clearSelectedItem",
"(",
")",
";",
"setInputClearButton",
"(",
")",
";",
"if",
"(",
"self",
".",
"parentForm",
"&&",
"self",
".",
"parentForm",
"!==",
"null",
")",
"{",
"self",
".",
"parentForm",
".",
"$setDirty",
... | clear the input text field using clear button Check clear button visble and hidden | [
"clear",
"the",
"input",
"text",
"field",
"using",
"clear",
"button",
"Check",
"clear",
"button",
"visble",
"and",
"hidden"
] | 07bef97b9b373949058716054ec84c5ec5a397b9 | https://github.com/ShoppinPal/Materializecss-Autocomplete/blob/07bef97b9b373949058716054ec84c5ec5a397b9/dist/js/materializecss-autocomplete.js#L263-L269 | train |
ShoppinPal/Materializecss-Autocomplete | dist/js/materializecss-autocomplete.js | handleSearchText | function handleSearchText(searchText, previousSearchText) {
self.index = -1;
// do nothing on init
if (searchText === previousSearchText) return;
else if (self.selectedItem && self.displayProperty1) {
setLoading(false);
if (self.selectedItem[self.displayProperty1] !== searchText)... | javascript | function handleSearchText(searchText, previousSearchText) {
self.index = -1;
// do nothing on init
if (searchText === previousSearchText) return;
else if (self.selectedItem && self.displayProperty1) {
setLoading(false);
if (self.selectedItem[self.displayProperty1] !== searchText)... | [
"function",
"handleSearchText",
"(",
"searchText",
",",
"previousSearchText",
")",
"{",
"self",
".",
"index",
"=",
"-",
"1",
";",
"// do nothing on init",
"if",
"(",
"searchText",
"===",
"previousSearchText",
")",
"return",
";",
"else",
"if",
"(",
"self",
".",... | Handles changes to the searchText property.
@param searchText
@param previousSearchText | [
"Handles",
"changes",
"to",
"the",
"searchText",
"property",
"."
] | 07bef97b9b373949058716054ec84c5ec5a397b9 | https://github.com/ShoppinPal/Materializecss-Autocomplete/blob/07bef97b9b373949058716054ec84c5ec5a397b9/dist/js/materializecss-autocomplete.js#L458-L478 | train |
ShoppinPal/Materializecss-Autocomplete | dist/js/materializecss-autocomplete.js | selectedItemChange | function selectedItemChange(selectedItem, previousSelectedItem) {
if (selectedItem) {
if (self.displayProperty1) {
self.searchText = selectedItem[self.displayProperty1];
}
if (self.parentForm && self.parentForm !== null) {
self.parentForm.$setDirty();
}
}
... | javascript | function selectedItemChange(selectedItem, previousSelectedItem) {
if (selectedItem) {
if (self.displayProperty1) {
self.searchText = selectedItem[self.displayProperty1];
}
if (self.parentForm && self.parentForm !== null) {
self.parentForm.$setDirty();
}
}
... | [
"function",
"selectedItemChange",
"(",
"selectedItem",
",",
"previousSelectedItem",
")",
"{",
"if",
"(",
"selectedItem",
")",
"{",
"if",
"(",
"self",
".",
"displayProperty1",
")",
"{",
"self",
".",
"searchText",
"=",
"selectedItem",
"[",
"self",
".",
"displayP... | Handles changes to the selected item.
@param selectedItem
@param previousSelectedItem | [
"Handles",
"changes",
"to",
"the",
"selected",
"item",
"."
] | 07bef97b9b373949058716054ec84c5ec5a397b9 | https://github.com/ShoppinPal/Materializecss-Autocomplete/blob/07bef97b9b373949058716054ec84c5ec5a397b9/dist/js/materializecss-autocomplete.js#L485-L501 | train |
ShoppinPal/Materializecss-Autocomplete | dist/js/materializecss-autocomplete.js | updateScroll | function updateScroll() {
if (!self.element.li[0]) return;
var height = self.element.li[0].offsetHeight,
top = height * self.index,
bot = top + height,
hgt = self.element.scroller.clientHeight,
scrollTop = self.element.scroller.scrollTop;
if (top<scrollTop) {
sc... | javascript | function updateScroll() {
if (!self.element.li[0]) return;
var height = self.element.li[0].offsetHeight,
top = height * self.index,
bot = top + height,
hgt = self.element.scroller.clientHeight,
scrollTop = self.element.scroller.scrollTop;
if (top<scrollTop) {
sc... | [
"function",
"updateScroll",
"(",
")",
"{",
"if",
"(",
"!",
"self",
".",
"element",
".",
"li",
"[",
"0",
"]",
")",
"return",
";",
"var",
"height",
"=",
"self",
".",
"element",
".",
"li",
"[",
"0",
"]",
".",
"offsetHeight",
",",
"top",
"=",
"height... | Makes sure that the focused element is within view. | [
"Makes",
"sure",
"that",
"the",
"focused",
"element",
"is",
"within",
"view",
"."
] | 07bef97b9b373949058716054ec84c5ec5a397b9 | https://github.com/ShoppinPal/Materializecss-Autocomplete/blob/07bef97b9b373949058716054ec84c5ec5a397b9/dist/js/materializecss-autocomplete.js#L527-L539 | train |
ShoppinPal/Materializecss-Autocomplete | dist/js/materializecss-autocomplete.js | handleUniqueResult | function handleUniqueResult(results) {
var res = [], flag = {};
for (var i = 0; i<results.length; i++) {
if (flag[results[i][self.displayProperty1]]) continue;
flag[results[i][self.displayProperty1]] = true;
res.push(results[i]);
}
return res;
} | javascript | function handleUniqueResult(results) {
var res = [], flag = {};
for (var i = 0; i<results.length; i++) {
if (flag[results[i][self.displayProperty1]]) continue;
flag[results[i][self.displayProperty1]] = true;
res.push(results[i]);
}
return res;
} | [
"function",
"handleUniqueResult",
"(",
"results",
")",
"{",
"var",
"res",
"=",
"[",
"]",
",",
"flag",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"results",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"flag",
... | This function check for result uniqueness on displayProperty1 params and return unique array
@param results
@returns {Array} | [
"This",
"function",
"check",
"for",
"result",
"uniqueness",
"on",
"displayProperty1",
"params",
"and",
"return",
"unique",
"array"
] | 07bef97b9b373949058716054ec84c5ec5a397b9 | https://github.com/ShoppinPal/Materializecss-Autocomplete/blob/07bef97b9b373949058716054ec84c5ec5a397b9/dist/js/materializecss-autocomplete.js#L604-L612 | train |
ShoppinPal/Materializecss-Autocomplete | dist/js/materializecss-autocomplete.js | convertArrayToObject | function convertArrayToObject(array) {
var temp = [];
array.forEach(function (text) {
temp.push({
index: text
});
});
return temp;
} | javascript | function convertArrayToObject(array) {
var temp = [];
array.forEach(function (text) {
temp.push({
index: text
});
});
return temp;
} | [
"function",
"convertArrayToObject",
"(",
"array",
")",
"{",
"var",
"temp",
"=",
"[",
"]",
";",
"array",
".",
"forEach",
"(",
"function",
"(",
"text",
")",
"{",
"temp",
".",
"push",
"(",
"{",
"index",
":",
"text",
"}",
")",
";",
"}",
")",
";",
"re... | This function converts an array of strings to object of strings with key "index"
@param array
@returns {Array} | [
"This",
"function",
"converts",
"an",
"array",
"of",
"strings",
"to",
"object",
"of",
"strings",
"with",
"key",
"index"
] | 07bef97b9b373949058716054ec84c5ec5a397b9 | https://github.com/ShoppinPal/Materializecss-Autocomplete/blob/07bef97b9b373949058716054ec84c5ec5a397b9/dist/js/materializecss-autocomplete.js#L636-L644 | train |
cgmartin/express-api-server | src/lib/graceful-shutdown.js | function(retCode) {
retCode = (typeof retCode !== 'undefined') ? retCode : 0;
if (server) {
if (shutdownInProgress) { return; }
shutdownInProgress = true;
console.info('Shutting down gracefully...');
server.close(function() {
console.info... | javascript | function(retCode) {
retCode = (typeof retCode !== 'undefined') ? retCode : 0;
if (server) {
if (shutdownInProgress) { return; }
shutdownInProgress = true;
console.info('Shutting down gracefully...');
server.close(function() {
console.info... | [
"function",
"(",
"retCode",
")",
"{",
"retCode",
"=",
"(",
"typeof",
"retCode",
"!==",
"'undefined'",
")",
"?",
"retCode",
":",
"0",
";",
"if",
"(",
"server",
")",
"{",
"if",
"(",
"shutdownInProgress",
")",
"{",
"return",
";",
"}",
"shutdownInProgress",
... | Shut down gracefully | [
"Shut",
"down",
"gracefully"
] | 9d6de16e7c84d21b83639a904f2eaed4a30a4088 | https://github.com/cgmartin/express-api-server/blob/9d6de16e7c84d21b83639a904f2eaed4a30a4088/src/lib/graceful-shutdown.js#L12-L34 | train | |
fibo/dflow | src/engine/inject/arguments.js | injectArguments | function injectArguments (funcs, task, args) {
function getArgument (index) {
return args[index]
}
/**
* Inject arguments.
*/
function inject (taskKey) {
var funcName = task[taskKey]
if (funcName === 'arguments') {
funcs[funcName] = function getArguments () { return args }
} else ... | javascript | function injectArguments (funcs, task, args) {
function getArgument (index) {
return args[index]
}
/**
* Inject arguments.
*/
function inject (taskKey) {
var funcName = task[taskKey]
if (funcName === 'arguments') {
funcs[funcName] = function getArguments () { return args }
} else ... | [
"function",
"injectArguments",
"(",
"funcs",
",",
"task",
",",
"args",
")",
"{",
"function",
"getArgument",
"(",
"index",
")",
"{",
"return",
"args",
"[",
"index",
"]",
"}",
"/**\n * Inject arguments.\n */",
"function",
"inject",
"(",
"taskKey",
")",
"{",
... | Inject functions to retrieve arguments.
@param {Object} funcs reference
@param {Object} task
@param {Object} args | [
"Inject",
"functions",
"to",
"retrieve",
"arguments",
"."
] | 6530e4659952b9013e47b5fb28fbbd3a7a4af17d | https://github.com/fibo/dflow/blob/6530e4659952b9013e47b5fb28fbbd3a7a4af17d/src/engine/inject/arguments.js#L11-L36 | train |
fibo/dflow | src/engine/inject/arguments.js | inject | function inject (taskKey) {
var funcName = task[taskKey]
if (funcName === 'arguments') {
funcs[funcName] = function getArguments () { return args }
} else {
var arg = regexArgument.exec(funcName)
if (arg) {
funcs[funcName] = getArgument.bind(null, arg[1])
}
}
} | javascript | function inject (taskKey) {
var funcName = task[taskKey]
if (funcName === 'arguments') {
funcs[funcName] = function getArguments () { return args }
} else {
var arg = regexArgument.exec(funcName)
if (arg) {
funcs[funcName] = getArgument.bind(null, arg[1])
}
}
} | [
"function",
"inject",
"(",
"taskKey",
")",
"{",
"var",
"funcName",
"=",
"task",
"[",
"taskKey",
"]",
"if",
"(",
"funcName",
"===",
"'arguments'",
")",
"{",
"funcs",
"[",
"funcName",
"]",
"=",
"function",
"getArguments",
"(",
")",
"{",
"return",
"args",
... | Inject arguments. | [
"Inject",
"arguments",
"."
] | 6530e4659952b9013e47b5fb28fbbd3a7a4af17d | https://github.com/fibo/dflow/blob/6530e4659952b9013e47b5fb28fbbd3a7a4af17d/src/engine/inject/arguments.js#L20-L32 | train |
fibo/dflow | src/engine/inject/globals.js | injectGlobals | function injectGlobals (funcs, task) {
/**
* Inject task
*/
function inject (taskKey) {
var taskName = task[taskKey]
// Do not overwrite a function if already defined.
// For example, console.log cannot be used as is, it must binded to console.
if (typeof funcs[taskName] === 'function') retu... | javascript | function injectGlobals (funcs, task) {
/**
* Inject task
*/
function inject (taskKey) {
var taskName = task[taskKey]
// Do not overwrite a function if already defined.
// For example, console.log cannot be used as is, it must binded to console.
if (typeof funcs[taskName] === 'function') retu... | [
"function",
"injectGlobals",
"(",
"funcs",
",",
"task",
")",
"{",
"/**\n * Inject task\n */",
"function",
"inject",
"(",
"taskKey",
")",
"{",
"var",
"taskName",
"=",
"task",
"[",
"taskKey",
"]",
"// Do not overwrite a function if already defined.",
"// For example, ... | Inject globals.
@param {Object} funcs reference
@param {Object} task | [
"Inject",
"globals",
"."
] | 6530e4659952b9013e47b5fb28fbbd3a7a4af17d | https://github.com/fibo/dflow/blob/6530e4659952b9013e47b5fb28fbbd3a7a4af17d/src/engine/inject/globals.js#L12-L42 | train |
fibo/dflow | src/examples/renderer/client-side.js | renderExample | function renderExample (divId, example) {
var graph = graphs[example]
var canvas = new Canvas(divId, {
node: {
DefaultNode: Node,
InvalidNode,
ToggleNode
},
util: { typeOfNode }
})
canvas.render(graph.view)
dflow.fun(graph)()
} | javascript | function renderExample (divId, example) {
var graph = graphs[example]
var canvas = new Canvas(divId, {
node: {
DefaultNode: Node,
InvalidNode,
ToggleNode
},
util: { typeOfNode }
})
canvas.render(graph.view)
dflow.fun(graph)()
} | [
"function",
"renderExample",
"(",
"divId",
",",
"example",
")",
"{",
"var",
"graph",
"=",
"graphs",
"[",
"example",
"]",
"var",
"canvas",
"=",
"new",
"Canvas",
"(",
"divId",
",",
"{",
"node",
":",
"{",
"DefaultNode",
":",
"Node",
",",
"InvalidNode",
",... | Render example into given div and execute dflow graph.
@param {String} divId
@param {String} example
@returns {undefined} | [
"Render",
"example",
"into",
"given",
"div",
"and",
"execute",
"dflow",
"graph",
"."
] | 6530e4659952b9013e47b5fb28fbbd3a7a4af17d | https://github.com/fibo/dflow/blob/6530e4659952b9013e47b5fb28fbbd3a7a4af17d/src/examples/renderer/client-side.js#L18-L33 | train |
fibo/dflow | src/engine/inject/references.js | injectReferences | function injectReferences (funcs, task) {
/**
* Inject task.
*
* @param {String} taskKey
*/
function inject (taskKey) {
var referenceName = null
var referencedFunction = null
var taskName = task[taskKey]
/**
* Inject reference.
*/
function reference () {
return ref... | javascript | function injectReferences (funcs, task) {
/**
* Inject task.
*
* @param {String} taskKey
*/
function inject (taskKey) {
var referenceName = null
var referencedFunction = null
var taskName = task[taskKey]
/**
* Inject reference.
*/
function reference () {
return ref... | [
"function",
"injectReferences",
"(",
"funcs",
",",
"task",
")",
"{",
"/**\n * Inject task.\n *\n * @param {String} taskKey\n */",
"function",
"inject",
"(",
"taskKey",
")",
"{",
"var",
"referenceName",
"=",
"null",
"var",
"referencedFunction",
"=",
"null",
"var"... | Inject references to functions.
@param {Object} funcs reference
@param {Object} task | [
"Inject",
"references",
"to",
"functions",
"."
] | 6530e4659952b9013e47b5fb28fbbd3a7a4af17d | https://github.com/fibo/dflow/blob/6530e4659952b9013e47b5fb28fbbd3a7a4af17d/src/engine/inject/references.js#L11-L47 | train |
fibo/dflow | src/engine/inject/references.js | inject | function inject (taskKey) {
var referenceName = null
var referencedFunction = null
var taskName = task[taskKey]
/**
* Inject reference.
*/
function reference () {
return referencedFunction
}
if (regexReference.test(taskName)) {
referenceName = taskName.substring(1)
... | javascript | function inject (taskKey) {
var referenceName = null
var referencedFunction = null
var taskName = task[taskKey]
/**
* Inject reference.
*/
function reference () {
return referencedFunction
}
if (regexReference.test(taskName)) {
referenceName = taskName.substring(1)
... | [
"function",
"inject",
"(",
"taskKey",
")",
"{",
"var",
"referenceName",
"=",
"null",
"var",
"referencedFunction",
"=",
"null",
"var",
"taskName",
"=",
"task",
"[",
"taskKey",
"]",
"/**\n * Inject reference.\n */",
"function",
"reference",
"(",
")",
"{",
... | Inject task.
@param {String} taskKey | [
"Inject",
"task",
"."
] | 6530e4659952b9013e47b5fb28fbbd3a7a4af17d | https://github.com/fibo/dflow/blob/6530e4659952b9013e47b5fb28fbbd3a7a4af17d/src/engine/inject/references.js#L18-L44 | train |
fibo/dflow | src/engine/inject/strings.js | injectStrings | function injectStrings (funcs, task) {
/**
* Inject a function that returns a string.
*/
function inject (taskKey) {
var taskName = task[taskKey]
if (regexQuoted.test(taskName)) {
funcs[taskName] = function () {
return taskName.substr(1, taskName.length - 2)
}
}
}
Object... | javascript | function injectStrings (funcs, task) {
/**
* Inject a function that returns a string.
*/
function inject (taskKey) {
var taskName = task[taskKey]
if (regexQuoted.test(taskName)) {
funcs[taskName] = function () {
return taskName.substr(1, taskName.length - 2)
}
}
}
Object... | [
"function",
"injectStrings",
"(",
"funcs",
",",
"task",
")",
"{",
"/**\n * Inject a function that returns a string.\n */",
"function",
"inject",
"(",
"taskKey",
")",
"{",
"var",
"taskName",
"=",
"task",
"[",
"taskKey",
"]",
"if",
"(",
"regexQuoted",
".",
"test... | Inject functions that return strings.
@param {Object} funcs reference
@param {Object} task collection | [
"Inject",
"functions",
"that",
"return",
"strings",
"."
] | 6530e4659952b9013e47b5fb28fbbd3a7a4af17d | https://github.com/fibo/dflow/blob/6530e4659952b9013e47b5fb28fbbd3a7a4af17d/src/engine/inject/strings.js#L10-L27 | train |
fibo/dflow | src/engine/inject/strings.js | inject | function inject (taskKey) {
var taskName = task[taskKey]
if (regexQuoted.test(taskName)) {
funcs[taskName] = function () {
return taskName.substr(1, taskName.length - 2)
}
}
} | javascript | function inject (taskKey) {
var taskName = task[taskKey]
if (regexQuoted.test(taskName)) {
funcs[taskName] = function () {
return taskName.substr(1, taskName.length - 2)
}
}
} | [
"function",
"inject",
"(",
"taskKey",
")",
"{",
"var",
"taskName",
"=",
"task",
"[",
"taskKey",
"]",
"if",
"(",
"regexQuoted",
".",
"test",
"(",
"taskName",
")",
")",
"{",
"funcs",
"[",
"taskName",
"]",
"=",
"function",
"(",
")",
"{",
"return",
"task... | Inject a function that returns a string. | [
"Inject",
"a",
"function",
"that",
"returns",
"a",
"string",
"."
] | 6530e4659952b9013e47b5fb28fbbd3a7a4af17d | https://github.com/fibo/dflow/blob/6530e4659952b9013e47b5fb28fbbd3a7a4af17d/src/engine/inject/strings.js#L15-L23 | train |
macbre/wayback-machine | lib/wayback.js | request | function request(url, options, callback) {
var debug = require('debug')('wayback:http');
debug('req', url);
callback = typeof callback === 'undefined' ? options : callback;
// @see https://www.npmjs.com/package/fetch
var stream = new fetch(url, typeof options === 'object' ? options : undefined);
stream.on('err... | javascript | function request(url, options, callback) {
var debug = require('debug')('wayback:http');
debug('req', url);
callback = typeof callback === 'undefined' ? options : callback;
// @see https://www.npmjs.com/package/fetch
var stream = new fetch(url, typeof options === 'object' ? options : undefined);
stream.on('err... | [
"function",
"request",
"(",
"url",
",",
"options",
",",
"callback",
")",
"{",
"var",
"debug",
"=",
"require",
"(",
"'debug'",
")",
"(",
"'wayback:http'",
")",
";",
"debug",
"(",
"'req'",
",",
"url",
")",
";",
"callback",
"=",
"typeof",
"callback",
"===... | a simple HTTP client wrapper returning a response stream | [
"a",
"simple",
"HTTP",
"client",
"wrapper",
"returning",
"a",
"response",
"stream"
] | b48fbf4735efad4fd6571cc292d28dc17cf6786c | https://github.com/macbre/wayback-machine/blob/b48fbf4735efad4fd6571cc292d28dc17cf6786c/lib/wayback.js#L9-L28 | train |
Bandwidth/opkit | lib/Persisters/filepersister.js | filePersister | function filePersister(filepath) {
var self = this;
this.initialized = false;
this.filepath = filepath;
/**
* Check to see if the specified file path is available.
* @returns A promise appropriately resolving or rejecting.
*/
this.start = function() {
if (!this.initialized) {
return fsp.emptyDir(this.... | javascript | function filePersister(filepath) {
var self = this;
this.initialized = false;
this.filepath = filepath;
/**
* Check to see if the specified file path is available.
* @returns A promise appropriately resolving or rejecting.
*/
this.start = function() {
if (!this.initialized) {
return fsp.emptyDir(this.... | [
"function",
"filePersister",
"(",
"filepath",
")",
"{",
"var",
"self",
"=",
"this",
";",
"this",
".",
"initialized",
"=",
"false",
";",
"this",
".",
"filepath",
"=",
"filepath",
";",
"/**\n\t * Check to see if the specified file path is available.\n\t * @returns A promi... | File persister factory method. Returns a persister object.
@param {Schema} filepath - Directory to store the data
@param {Object} persisterPluginObject - For users who have written their own persister object. | [
"File",
"persister",
"factory",
"method",
".",
"Returns",
"a",
"persister",
"object",
"."
] | f83321ee93dd8362370fc4ce0790658bead64337 | https://github.com/Bandwidth/opkit/blob/f83321ee93dd8362370fc4ce0790658bead64337/lib/Persisters/filepersister.js#L10-L75 | train |
alliance-pcsg/primo-explore-custom-actions | dist/module.js | addAction | function addAction(action, ctrl) {
this.addActionIcon(action, ctrl);
if (!this.actionExists(action, ctrl)) {
ctrl.actionListService.requiredActionsList.splice(action.index, 0, action.name);
ctrl.actionListService.actionsToIndex[action.name] = action.index;
ctrl.actionListService.onTo... | javascript | function addAction(action, ctrl) {
this.addActionIcon(action, ctrl);
if (!this.actionExists(action, ctrl)) {
ctrl.actionListService.requiredActionsList.splice(action.index, 0, action.name);
ctrl.actionListService.actionsToIndex[action.name] = action.index;
ctrl.actionListService.onTo... | [
"function",
"addAction",
"(",
"action",
",",
"ctrl",
")",
"{",
"this",
".",
"addActionIcon",
"(",
"action",
",",
"ctrl",
")",
";",
"if",
"(",
"!",
"this",
".",
"actionExists",
"(",
"action",
",",
"ctrl",
")",
")",
"{",
"ctrl",
".",
"actionListService",... | Adds an action to the actions menu, including its icon.
@param {object} action action object
@param {object} ctrl instance of prmActionCtrl
TODO coerce action.index to be <= requiredActionsList.length | [
"Adds",
"an",
"action",
"to",
"the",
"actions",
"menu",
"including",
"its",
"icon",
"."
] | f5457699d27c0b76e61aab584eb4065a7a985b9d | https://github.com/alliance-pcsg/primo-explore-custom-actions/blob/f5457699d27c0b76e61aab584eb4065a7a985b9d/dist/module.js#L50-L58 | train |
alliance-pcsg/primo-explore-custom-actions | dist/module.js | removeAction | function removeAction(action, ctrl) {
if (this.actionExists(action, ctrl)) {
this.removeActionIcon(action, ctrl);
delete ctrl.actionListService.actionsToIndex[action.name];
delete ctrl.actionListService.onToggle[action.name];
var i = ctrl.actionListService.actionsToDisplay.indexOf(... | javascript | function removeAction(action, ctrl) {
if (this.actionExists(action, ctrl)) {
this.removeActionIcon(action, ctrl);
delete ctrl.actionListService.actionsToIndex[action.name];
delete ctrl.actionListService.onToggle[action.name];
var i = ctrl.actionListService.actionsToDisplay.indexOf(... | [
"function",
"removeAction",
"(",
"action",
",",
"ctrl",
")",
"{",
"if",
"(",
"this",
".",
"actionExists",
"(",
"action",
",",
"ctrl",
")",
")",
"{",
"this",
".",
"removeActionIcon",
"(",
"action",
",",
"ctrl",
")",
";",
"delete",
"ctrl",
".",
"actionLi... | Removes an action from the actions menu, including its icon.
@param {object} action action object
@param {object} ctrl instance of prmActionCtrl | [
"Removes",
"an",
"action",
"from",
"the",
"actions",
"menu",
"including",
"its",
"icon",
"."
] | f5457699d27c0b76e61aab584eb4065a7a985b9d | https://github.com/alliance-pcsg/primo-explore-custom-actions/blob/f5457699d27c0b76e61aab584eb4065a7a985b9d/dist/module.js#L64-L74 | train |
Bandwidth/opkit | lib/ec2.js | dataFormatter | function dataFormatter(data) {
var instanceInfoArray = [];
var instanceInfoObject = {};
var reservations = data.Reservations;
for (var reservation in reservations) {
var instances = reservations[reservation].Instances;
for (var instance in instances) {
var tags = instances[instance].Tags;
for (var tag in... | javascript | function dataFormatter(data) {
var instanceInfoArray = [];
var instanceInfoObject = {};
var reservations = data.Reservations;
for (var reservation in reservations) {
var instances = reservations[reservation].Instances;
for (var instance in instances) {
var tags = instances[instance].Tags;
for (var tag in... | [
"function",
"dataFormatter",
"(",
"data",
")",
"{",
"var",
"instanceInfoArray",
"=",
"[",
"]",
";",
"var",
"instanceInfoObject",
"=",
"{",
"}",
";",
"var",
"reservations",
"=",
"data",
".",
"Reservations",
";",
"for",
"(",
"var",
"reservation",
"in",
"rese... | Helper function to format data returned by AWS EC2 queries. | [
"Helper",
"function",
"to",
"format",
"data",
"returned",
"by",
"AWS",
"EC2",
"queries",
"."
] | f83321ee93dd8362370fc4ce0790658bead64337 | https://github.com/Bandwidth/opkit/blob/f83321ee93dd8362370fc4ce0790658bead64337/lib/ec2.js#L264-L287 | train |
jcreigno/nodejs-file-extractor | lib/main.js | Extractor | function Extractor(ac , options) {
EventEmitter.call(this);
var self = this;
self.matchers = [];
self.vars = ac || {};
self.options = options || {};
self.watchers = [];
self._listen = function (car, file) {
car.once('end', function () {
self.emit('end', self.vars);
... | javascript | function Extractor(ac , options) {
EventEmitter.call(this);
var self = this;
self.matchers = [];
self.vars = ac || {};
self.options = options || {};
self.watchers = [];
self._listen = function (car, file) {
car.once('end', function () {
self.emit('end', self.vars);
... | [
"function",
"Extractor",
"(",
"ac",
",",
"options",
")",
"{",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"var",
"self",
"=",
"this",
";",
"self",
".",
"matchers",
"=",
"[",
"]",
";",
"self",
".",
"vars",
"=",
"ac",
"||",
"{",
"}",
";",
... | Extractor Object. | [
"Extractor",
"Object",
"."
] | ce071d1a50eed08e0e593d0609de8b61da320280 | https://github.com/jcreigno/nodejs-file-extractor/blob/ce071d1a50eed08e0e593d0609de8b61da320280/lib/main.js#L13-L42 | train |
jcreigno/nodejs-file-extractor | lib/main.js | wildcards | function wildcards(f, cb, ctxt) {
var starmatch = f.match(/([^*]*)\*.*/);
if (!starmatch) { //keep async
process.nextTick(function () {
cb.apply(ctxt, [f]);
});
return;
}
var basedirPath = starmatch[1].split(/\//);
basedirPath.pop();
var wkdir = basedirPath.j... | javascript | function wildcards(f, cb, ctxt) {
var starmatch = f.match(/([^*]*)\*.*/);
if (!starmatch) { //keep async
process.nextTick(function () {
cb.apply(ctxt, [f]);
});
return;
}
var basedirPath = starmatch[1].split(/\//);
basedirPath.pop();
var wkdir = basedirPath.j... | [
"function",
"wildcards",
"(",
"f",
",",
"cb",
",",
"ctxt",
")",
"{",
"var",
"starmatch",
"=",
"f",
".",
"match",
"(",
"/",
"([^*]*)\\*.*",
"/",
")",
";",
"if",
"(",
"!",
"starmatch",
")",
"{",
"//keep async",
"process",
".",
"nextTick",
"(",
"functio... | handle wildcards in filenames
@param f: filename.
@param cb : callback when a matching file is found.
@param ctxt : callback invocation context. | [
"handle",
"wildcards",
"in",
"filenames"
] | ce071d1a50eed08e0e593d0609de8b61da320280 | https://github.com/jcreigno/nodejs-file-extractor/blob/ce071d1a50eed08e0e593d0609de8b61da320280/lib/main.js#L81-L108 | train |
SpoonX/Censoring | index.js | Censoring | function Censoring() {
/**
* The string to replaces found matches with. Defaults to ***
*
* @type {String}
*/
this.replacementString = '***';
/**
* The color used for highlighting
*
* @type {string}
*/
this.highlightColor = 'F2B8B8';
/**
* Holds the cu... | javascript | function Censoring() {
/**
* The string to replaces found matches with. Defaults to ***
*
* @type {String}
*/
this.replacementString = '***';
/**
* The color used for highlighting
*
* @type {string}
*/
this.highlightColor = 'F2B8B8';
/**
* Holds the cu... | [
"function",
"Censoring",
"(",
")",
"{",
"/**\n * The string to replaces found matches with. Defaults to ***\n *\n * @type {String}\n */",
"this",
".",
"replacementString",
"=",
"'***'",
";",
"/**\n * The color used for highlighting\n *\n * @type {string}\n */"... | The Censoring object constructor.
@constructor | [
"The",
"Censoring",
"object",
"constructor",
"."
] | 9ffc8c42d67a5773f6a09821a3f84b7482b41f3c | https://github.com/SpoonX/Censoring/blob/9ffc8c42d67a5773f6a09821a3f84b7482b41f3c/index.js#L9-L87 | train |
SpoonX/Censoring | index.js | function (filters) {
if (!this.isArray(filters)) {
throw 'Invalid filters type supplied. Expected Array.';
}
for (var i = 0; i < filters.length; i++) {
this.enableFilter(filters[i]);
}
return this;
} | javascript | function (filters) {
if (!this.isArray(filters)) {
throw 'Invalid filters type supplied. Expected Array.';
}
for (var i = 0; i < filters.length; i++) {
this.enableFilter(filters[i]);
}
return this;
} | [
"function",
"(",
"filters",
")",
"{",
"if",
"(",
"!",
"this",
".",
"isArray",
"(",
"filters",
")",
")",
"{",
"throw",
"'Invalid filters type supplied. Expected Array.'",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"filters",
".",
"length",... | Enable multiple filters at once.
@param {Array} filters
@returns {Censoring}
@see Censoring.enableFilter | [
"Enable",
"multiple",
"filters",
"at",
"once",
"."
] | 9ffc8c42d67a5773f6a09821a3f84b7482b41f3c | https://github.com/SpoonX/Censoring/blob/9ffc8c42d67a5773f6a09821a3f84b7482b41f3c/index.js#L142-L152 | train | |
SpoonX/Censoring | index.js | function (words) {
if (!this.isArray(words)) {
throw 'Invalid type supplied for addFilterWords. Expected array.';
}
for (var i = 0; i < words.length; i++) {
this.addFilterWord(words[i]);
}
return this;
} | javascript | function (words) {
if (!this.isArray(words)) {
throw 'Invalid type supplied for addFilterWords. Expected array.';
}
for (var i = 0; i < words.length; i++) {
this.addFilterWord(words[i]);
}
return this;
} | [
"function",
"(",
"words",
")",
"{",
"if",
"(",
"!",
"this",
".",
"isArray",
"(",
"words",
")",
")",
"{",
"throw",
"'Invalid type supplied for addFilterWords. Expected array.'",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"words",
".",
"len... | Add multiple filterWords.
@param {[]} words
@returns {Censoring} | [
"Add",
"multiple",
"filterWords",
"."
] | 9ffc8c42d67a5773f6a09821a3f84b7482b41f3c | https://github.com/SpoonX/Censoring/blob/9ffc8c42d67a5773f6a09821a3f84b7482b41f3c/index.js#L176-L186 | train | |
SpoonX/Censoring | index.js | function (word) {
var pattern = '',
any = '[^a-z0-9]?',
last = false,
character;
for (var i = 0; i < word.length; i++) {
last = i === (word.length - 1);
character = word.charAt(i);
if (typeof this.map1337[character] === 'undefined') {
pattern += (c... | javascript | function (word) {
var pattern = '',
any = '[^a-z0-9]?',
last = false,
character;
for (var i = 0; i < word.length; i++) {
last = i === (word.length - 1);
character = word.charAt(i);
if (typeof this.map1337[character] === 'undefined') {
pattern += (c... | [
"function",
"(",
"word",
")",
"{",
"var",
"pattern",
"=",
"''",
",",
"any",
"=",
"'[^a-z0-9]?'",
",",
"last",
"=",
"false",
",",
"character",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"word",
".",
"length",
";",
"i",
"++",
")",
"{",... | Add a word to filter out.
@param {String} word
@returns {Censoring} | [
"Add",
"a",
"word",
"to",
"filter",
"out",
"."
] | 9ffc8c42d67a5773f6a09821a3f84b7482b41f3c | https://github.com/SpoonX/Censoring/blob/9ffc8c42d67a5773f6a09821a3f84b7482b41f3c/index.js#L194-L228 | train | |
SpoonX/Censoring | index.js | function (str, highlight) {
this.currentMatch.replace = this.filterString(str, highlight);
this.currentMatch.hasMatches = str !== this.currentMatch.replace;
return this;
} | javascript | function (str, highlight) {
this.currentMatch.replace = this.filterString(str, highlight);
this.currentMatch.hasMatches = str !== this.currentMatch.replace;
return this;
} | [
"function",
"(",
"str",
",",
"highlight",
")",
"{",
"this",
".",
"currentMatch",
".",
"replace",
"=",
"this",
".",
"filterString",
"(",
"str",
",",
"highlight",
")",
";",
"this",
".",
"currentMatch",
".",
"hasMatches",
"=",
"str",
"!==",
"this",
".",
"... | Prepare some text to be matched against.
@param {String} str
@param {Boolean} highlight
@returns {Censoring} | [
"Prepare",
"some",
"text",
"to",
"be",
"matched",
"against",
"."
] | 9ffc8c42d67a5773f6a09821a3f84b7482b41f3c | https://github.com/SpoonX/Censoring/blob/9ffc8c42d67a5773f6a09821a3f84b7482b41f3c/index.js#L269-L274 | train | |
SpoonX/Censoring | index.js | function (str, highlight) {
highlight = highlight || false;
var self = this;
var highlightColor = this.highlightColor;
var replace = function (str, pattern) {
if (!highlight) {
return str.replace(pattern, function (match) {
self.currentMatch.matches.push(match);
... | javascript | function (str, highlight) {
highlight = highlight || false;
var self = this;
var highlightColor = this.highlightColor;
var replace = function (str, pattern) {
if (!highlight) {
return str.replace(pattern, function (match) {
self.currentMatch.matches.push(match);
... | [
"function",
"(",
"str",
",",
"highlight",
")",
"{",
"highlight",
"=",
"highlight",
"||",
"false",
";",
"var",
"self",
"=",
"this",
";",
"var",
"highlightColor",
"=",
"this",
".",
"highlightColor",
";",
"var",
"replace",
"=",
"function",
"(",
"str",
",",
... | Filter the string.
@param {String} str
@param {Boolean} highlight
@returns {String}} | [
"Filter",
"the",
"string",
"."
] | 9ffc8c42d67a5773f6a09821a3f84b7482b41f3c | https://github.com/SpoonX/Censoring/blob/9ffc8c42d67a5773f6a09821a3f84b7482b41f3c/index.js#L292-L340 | train | |
ipetez/react-create | src/scripts/component.js | addCssExtension | function addCssExtension(args, styleExts, extensions) {
for (let x = 0, len = args.length; x < len; x++) {
if (styleExts.includes(args[x])) {
extensions.push('.' + args[x].slice(2));
}
}
} | javascript | function addCssExtension(args, styleExts, extensions) {
for (let x = 0, len = args.length; x < len; x++) {
if (styleExts.includes(args[x])) {
extensions.push('.' + args[x].slice(2));
}
}
} | [
"function",
"addCssExtension",
"(",
"args",
",",
"styleExts",
",",
"extensions",
")",
"{",
"for",
"(",
"let",
"x",
"=",
"0",
",",
"len",
"=",
"args",
".",
"length",
";",
"x",
"<",
"len",
";",
"x",
"++",
")",
"{",
"if",
"(",
"styleExts",
".",
"inc... | Grabbing style extension from arguments and adding to
full list of extensions | [
"Grabbing",
"style",
"extension",
"from",
"arguments",
"and",
"adding",
"to",
"full",
"list",
"of",
"extensions"
] | 1b77954244aab1aac2133fe4bc4fa943d3c2c6d7 | https://github.com/ipetez/react-create/blob/1b77954244aab1aac2133fe4bc4fa943d3c2c6d7/src/scripts/component.js#L23-L29 | train |
strapi/strapi-generate-email | files/api/email/models/Email.js | function (values, next) {
const api = path.basename(__filename, '.js').toLowerCase();
if (strapi.api.hasOwnProperty(api) && _.size(strapi.api[api].templates)) {
const template = _.includes(strapi.api[api].templates, values.template) ? values.template : strapi.models[api].defaultTemplate;
// Set te... | javascript | function (values, next) {
const api = path.basename(__filename, '.js').toLowerCase();
if (strapi.api.hasOwnProperty(api) && _.size(strapi.api[api].templates)) {
const template = _.includes(strapi.api[api].templates, values.template) ? values.template : strapi.models[api].defaultTemplate;
// Set te... | [
"function",
"(",
"values",
",",
"next",
")",
"{",
"const",
"api",
"=",
"path",
".",
"basename",
"(",
"__filename",
",",
"'.js'",
")",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"strapi",
".",
"api",
".",
"hasOwnProperty",
"(",
"api",
")",
"&&",
... | Lifecycle callbacks
Before validate | [
"Lifecycle",
"callbacks",
"Before",
"validate"
] | e29983b725d4089364ebe6e5f6449c709bbac51d | https://github.com/strapi/strapi-generate-email/blob/e29983b725d4089364ebe6e5f6449c709bbac51d/files/api/email/models/Email.js#L55-L94 | train | |
jokesterfr/node-pcsc | lib/node-pcsc.js | getItem | function getItem(ATR) {
var item;
while( item === undefined ) {
item = slist[ATR];
if(!ATR) break;
ATR = ATR.substring(0, ATR.length-1);
}
return item;
} | javascript | function getItem(ATR) {
var item;
while( item === undefined ) {
item = slist[ATR];
if(!ATR) break;
ATR = ATR.substring(0, ATR.length-1);
}
return item;
} | [
"function",
"getItem",
"(",
"ATR",
")",
"{",
"var",
"item",
";",
"while",
"(",
"item",
"===",
"undefined",
")",
"{",
"item",
"=",
"slist",
"[",
"ATR",
"]",
";",
"if",
"(",
"!",
"ATR",
")",
"break",
";",
"ATR",
"=",
"ATR",
".",
"substring",
"(",
... | Retrieve some more infos about the inserted card
@param ATR {String} atr of the inserted card
@return {Object} if defined, the card name and info details | [
"Retrieve",
"some",
"more",
"infos",
"about",
"the",
"inserted",
"card"
] | 8593d1bf784afe1fc605b936de9af266dac02eb1 | https://github.com/jokesterfr/node-pcsc/blob/8593d1bf784afe1fc605b936de9af266dac02eb1/lib/node-pcsc.js#L72-L80 | train |
creamidea/keyboard-js | samples/heatmap.js | Log | function Log(keyboardInfo) {
var log = keyboardInfo.querySelector('ul')
var st = keyboardInfo.querySelector('.statistic')
var totalAvgTime = 0
var totalCount = 0
return function (key, statistic) {
var count = statistic.count
var average = statistic.average
totalCount = totalCount +... | javascript | function Log(keyboardInfo) {
var log = keyboardInfo.querySelector('ul')
var st = keyboardInfo.querySelector('.statistic')
var totalAvgTime = 0
var totalCount = 0
return function (key, statistic) {
var count = statistic.count
var average = statistic.average
totalCount = totalCount +... | [
"function",
"Log",
"(",
"keyboardInfo",
")",
"{",
"var",
"log",
"=",
"keyboardInfo",
".",
"querySelector",
"(",
"'ul'",
")",
"var",
"st",
"=",
"keyboardInfo",
".",
"querySelector",
"(",
"'.statistic'",
")",
"var",
"totalAvgTime",
"=",
"0",
"var",
"totalCount... | canvas.style.zIndex = 10 | [
"canvas",
".",
"style",
".",
"zIndex",
"=",
"10"
] | 71b6f21899eca0154a3fd5494fe5dd5d4db2b887 | https://github.com/creamidea/keyboard-js/blob/71b6f21899eca0154a3fd5494fe5dd5d4db2b887/samples/heatmap.js#L40-L61 | train |
jonschlinkert/read-data | index.js | extname | function extname(ext) {
var str = ext.charAt(0) === '.' ? ext.slice(1) : ext;
if (str === 'yml') str = 'yaml';
return str;
} | javascript | function extname(ext) {
var str = ext.charAt(0) === '.' ? ext.slice(1) : ext;
if (str === 'yml') str = 'yaml';
return str;
} | [
"function",
"extname",
"(",
"ext",
")",
"{",
"var",
"str",
"=",
"ext",
".",
"charAt",
"(",
"0",
")",
"===",
"'.'",
"?",
"ext",
".",
"slice",
"(",
"1",
")",
":",
"ext",
";",
"if",
"(",
"str",
"===",
"'yml'",
")",
"str",
"=",
"'yaml'",
";",
"re... | Get the extname without leading `.` | [
"Get",
"the",
"extname",
"without",
"leading",
"."
] | 0d9636f9d1d064d57fd0d0e2948bcbd77ba8acfd | https://github.com/jonschlinkert/read-data/blob/0d9636f9d1d064d57fd0d0e2948bcbd77ba8acfd/index.js#L179-L183 | train |
SimpleRegex/SRL-JavaScript | lib/Language/Helpers/buildQuery.js | buildQuery | function buildQuery(query, builder = new Builder()) {
for (let i = 0; i < query.length; i++) {
const method = query[i]
if (Array.isArray(method)) {
builder.and(buildQuery(method, new NonCapture()))
continue
}
if (!method instanceof Method) {
// A... | javascript | function buildQuery(query, builder = new Builder()) {
for (let i = 0; i < query.length; i++) {
const method = query[i]
if (Array.isArray(method)) {
builder.and(buildQuery(method, new NonCapture()))
continue
}
if (!method instanceof Method) {
// A... | [
"function",
"buildQuery",
"(",
"query",
",",
"builder",
"=",
"new",
"Builder",
"(",
")",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"query",
".",
"length",
";",
"i",
"++",
")",
"{",
"const",
"method",
"=",
"query",
"[",
"i",
"]"... | After the query was resolved, it can be built and thus executed.
@param array $query
@param Builder|null $builder If no Builder is given, the default Builder will be taken.
@return Builder
@throws SyntaxException | [
"After",
"the",
"query",
"was",
"resolved",
"it",
"can",
"be",
"built",
"and",
"thus",
"executed",
"."
] | eb2f0576ec49076e95fc2adec57e10d83c24d438 | https://github.com/SimpleRegex/SRL-JavaScript/blob/eb2f0576ec49076e95fc2adec57e10d83c24d438/lib/Language/Helpers/buildQuery.js#L16-L59 | train |
nhn/tui.dom | src/js/domutil.js | setClassName | function setClassName(element, cssClass) {
cssClass = snippet.isArray(cssClass) ? cssClass.join(' ') : cssClass;
cssClass = trim(cssClass);
if (snippet.isUndefined(element.className.baseVal)) {
element.className = cssClass;
return;
}
element.className.baseVal = cssClass;
} | javascript | function setClassName(element, cssClass) {
cssClass = snippet.isArray(cssClass) ? cssClass.join(' ') : cssClass;
cssClass = trim(cssClass);
if (snippet.isUndefined(element.className.baseVal)) {
element.className = cssClass;
return;
}
element.className.baseVal = cssClass;
} | [
"function",
"setClassName",
"(",
"element",
",",
"cssClass",
")",
"{",
"cssClass",
"=",
"snippet",
".",
"isArray",
"(",
"cssClass",
")",
"?",
"cssClass",
".",
"join",
"(",
"' '",
")",
":",
"cssClass",
";",
"cssClass",
"=",
"trim",
"(",
"cssClass",
")",
... | Set className value
@param {(HTMLElement|SVGElement)} element - target element
@param {(string|string[])} cssClass - class names
@ignore | [
"Set",
"className",
"value"
] | beafe74afb8f647d770e202894ecc9c2dc0ca2b5 | https://github.com/nhn/tui.dom/blob/beafe74afb8f647d770e202894ecc9c2dc0ca2b5/src/js/domutil.js#L82-L94 | train |
kozhevnikov/jsdoc-memberof-namespace | index.js | getNamespace | function getNamespace(file, path) {
const files = namespaces.filter(ns => ns.meta.filename === file && ns.meta.path === path);
if (files.length > 0) {
return files[files.length - 1];
}
const paths = namespaces.filter(ns => isIndex(ns.meta.filename) && isParent(ns.meta.path, path));
if (paths.length > 0) ... | javascript | function getNamespace(file, path) {
const files = namespaces.filter(ns => ns.meta.filename === file && ns.meta.path === path);
if (files.length > 0) {
return files[files.length - 1];
}
const paths = namespaces.filter(ns => isIndex(ns.meta.filename) && isParent(ns.meta.path, path));
if (paths.length > 0) ... | [
"function",
"getNamespace",
"(",
"file",
",",
"path",
")",
"{",
"const",
"files",
"=",
"namespaces",
".",
"filter",
"(",
"ns",
"=>",
"ns",
".",
"meta",
".",
"filename",
"===",
"file",
"&&",
"ns",
".",
"meta",
".",
"path",
"===",
"path",
")",
";",
"... | Get closest namespace doclet previously parsed either from the same file as the doclet
or from one of the index.js files present in the same directory or any of its parents
@param {string} file - File name of the doclet
@param {string} path - Directory path of the doclet
@return {?Doclet} - Namespace doclet or null | [
"Get",
"closest",
"namespace",
"doclet",
"previously",
"parsed",
"either",
"from",
"the",
"same",
"file",
"as",
"the",
"doclet",
"or",
"from",
"one",
"of",
"the",
"index",
".",
"js",
"files",
"present",
"in",
"the",
"same",
"directory",
"or",
"any",
"of",
... | 6035128bd605c427105c5fabed31114f806c9e7b | https://github.com/kozhevnikov/jsdoc-memberof-namespace/blob/6035128bd605c427105c5fabed31114f806c9e7b/index.js#L95-L108 | train |
hubiinetwork/nahmii-sdk | lib/utils.js | expandPropertyNameGlobs | function expandPropertyNameGlobs(object, globPatterns) {
const result = [];
if (!globPatterns.length)
return result;
const arrayGroupPattern = globPatterns[0];
const indexOfArrayGroup = arrayGroupPattern.indexOf('[]');
if (indexOfArrayGroup !== -1) {
const {arrayProp, arrayPropNam... | javascript | function expandPropertyNameGlobs(object, globPatterns) {
const result = [];
if (!globPatterns.length)
return result;
const arrayGroupPattern = globPatterns[0];
const indexOfArrayGroup = arrayGroupPattern.indexOf('[]');
if (indexOfArrayGroup !== -1) {
const {arrayProp, arrayPropNam... | [
"function",
"expandPropertyNameGlobs",
"(",
"object",
",",
"globPatterns",
")",
"{",
"const",
"result",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"globPatterns",
".",
"length",
")",
"return",
"result",
";",
"const",
"arrayGroupPattern",
"=",
"globPatterns",
"[",
"... | Takes an array of property patterns and expands any glob pattern it finds
based on the provided object.
@private
@param object
@param globPatterns
@returns {Array} | [
"Takes",
"an",
"array",
"of",
"property",
"patterns",
"and",
"expands",
"any",
"glob",
"pattern",
"it",
"finds",
"based",
"on",
"the",
"provided",
"object",
"."
] | 7a372deebf7d7326e3639ddb01c9ce6224fc83d6 | https://github.com/hubiinetwork/nahmii-sdk/blob/7a372deebf7d7326e3639ddb01c9ce6224fc83d6/lib/utils.js#L80-L125 | train |
hubiinetwork/nahmii-sdk | lib/utils.js | fromRpcSig | function fromRpcSig(flatSig) {
const expandedSig = ethutil.fromRpcSig(flatSig);
return {
s: ethutil.bufferToHex(expandedSig.s),
r: ethutil.bufferToHex(expandedSig.r),
v: expandedSig.v
};
} | javascript | function fromRpcSig(flatSig) {
const expandedSig = ethutil.fromRpcSig(flatSig);
return {
s: ethutil.bufferToHex(expandedSig.s),
r: ethutil.bufferToHex(expandedSig.r),
v: expandedSig.v
};
} | [
"function",
"fromRpcSig",
"(",
"flatSig",
")",
"{",
"const",
"expandedSig",
"=",
"ethutil",
".",
"fromRpcSig",
"(",
"flatSig",
")",
";",
"return",
"{",
"s",
":",
"ethutil",
".",
"bufferToHex",
"(",
"expandedSig",
".",
"s",
")",
",",
"r",
":",
"ethutil",
... | Takes a flat format RPC signature and returns it in expanded form, with
s, r in hex string form, and v a number
@param {String} flatSig Flat form signature
@returns {Object} Expanded form signature | [
"Takes",
"a",
"flat",
"format",
"RPC",
"signature",
"and",
"returns",
"it",
"in",
"expanded",
"form",
"with",
"s",
"r",
"in",
"hex",
"string",
"form",
"and",
"v",
"a",
"number"
] | 7a372deebf7d7326e3639ddb01c9ce6224fc83d6 | https://github.com/hubiinetwork/nahmii-sdk/blob/7a372deebf7d7326e3639ddb01c9ce6224fc83d6/lib/utils.js#L177-L185 | train |
hubiinetwork/nahmii-sdk | lib/utils.js | isSignedBy | function isSignedBy(message, signature, address) {
try {
const ethMessage = ethHash(message);
return caseInsensitiveCompare(recoverAddress(ethMessage, signature), prefix0x(address));
}
catch (e) {
return false;
}
} | javascript | function isSignedBy(message, signature, address) {
try {
const ethMessage = ethHash(message);
return caseInsensitiveCompare(recoverAddress(ethMessage, signature), prefix0x(address));
}
catch (e) {
return false;
}
} | [
"function",
"isSignedBy",
"(",
"message",
",",
"signature",
",",
"address",
")",
"{",
"try",
"{",
"const",
"ethMessage",
"=",
"ethHash",
"(",
"message",
")",
";",
"return",
"caseInsensitiveCompare",
"(",
"recoverAddress",
"(",
"ethMessage",
",",
"signature",
"... | Checks whether or not the address is the address of the private key used to
sign the specified message and signature.
@param {String} message - A message hash as a hexadecimal string
@param {Object} signature - The signature of the message given as V, R and S properties
@param {String} address - A hexadecimal represent... | [
"Checks",
"whether",
"or",
"not",
"the",
"address",
"is",
"the",
"address",
"of",
"the",
"private",
"key",
"used",
"to",
"sign",
"the",
"specified",
"message",
"and",
"signature",
"."
] | 7a372deebf7d7326e3639ddb01c9ce6224fc83d6 | https://github.com/hubiinetwork/nahmii-sdk/blob/7a372deebf7d7326e3639ddb01c9ce6224fc83d6/lib/utils.js#L243-L251 | train |
SimpleRegex/SRL-JavaScript | lib/Language/Helpers/methodMatch.js | methodMatch | function methodMatch(part) {
let maxMatch = null
let maxMatchCount = 0
// Go through each mapper and check if the name matches. Then, take the highest match to avoid matching
// 'any', if 'any character' was given, and so on.
Object.keys(mapper).forEach((key) => {
const regex = new RegExp(`... | javascript | function methodMatch(part) {
let maxMatch = null
let maxMatchCount = 0
// Go through each mapper and check if the name matches. Then, take the highest match to avoid matching
// 'any', if 'any character' was given, and so on.
Object.keys(mapper).forEach((key) => {
const regex = new RegExp(`... | [
"function",
"methodMatch",
"(",
"part",
")",
"{",
"let",
"maxMatch",
"=",
"null",
"let",
"maxMatchCount",
"=",
"0",
"// Go through each mapper and check if the name matches. Then, take the highest match to avoid matching",
"// 'any', if 'any character' was given, and so on.",
"Object... | Match a string part to a method. Please note that the string must start with a method.
@param {string} part
@throws {SyntaxException} If no method was found, a SyntaxException will be thrown.
@return {method} | [
"Match",
"a",
"string",
"part",
"to",
"a",
"method",
".",
"Please",
"note",
"that",
"the",
"string",
"must",
"start",
"with",
"a",
"method",
"."
] | eb2f0576ec49076e95fc2adec57e10d83c24d438 | https://github.com/SimpleRegex/SRL-JavaScript/blob/eb2f0576ec49076e95fc2adec57e10d83c24d438/lib/Language/Helpers/methodMatch.js#L75-L100 | train |
jahting/pnltri.js | build/pnltri.js | function () { // <<<<<< public
var newMono, newMonoTo, toFirstOutSeg, fromRevSeg;
for ( var i = 0, j = this.segments.length; i < j; i++) {
newMono = this.segments[i];
if ( this.PolyLeftArr[newMono.chainId] ) {
// preserve winding order
newMonoTo = newMono.vTo; // target of segment
newMono.m... | javascript | function () { // <<<<<< public
var newMono, newMonoTo, toFirstOutSeg, fromRevSeg;
for ( var i = 0, j = this.segments.length; i < j; i++) {
newMono = this.segments[i];
if ( this.PolyLeftArr[newMono.chainId] ) {
// preserve winding order
newMonoTo = newMono.vTo; // target of segment
newMono.m... | [
"function",
"(",
")",
"{",
"// <<<<<< public",
"var",
"newMono",
",",
"newMonoTo",
",",
"toFirstOutSeg",
",",
"fromRevSeg",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"j",
"=",
"this",
".",
"segments",
".",
"length",
";",
"i",
"<",
"j",
";",
"i",
... | Generate the uni-y-monotone sub-polygons from the trapezoidation of the polygon. | [
"Generate",
"the",
"uni",
"-",
"y",
"-",
"monotone",
"sub",
"-",
"polygons",
"from",
"the",
"trapezoidation",
"of",
"the",
"polygon",
"."
] | 72f162d39da3a84c78ff16181940da79f3f50ba9 | https://github.com/jahting/pnltri.js/blob/72f162d39da3a84c78ff16181940da79f3f50ba9/build/pnltri.js#L350-L377 | train | |
jahting/pnltri.js | build/pnltri.js | function () { // <<<<<<<<<< public
var normedMonoChains = this.polyData.getMonoSubPolys();
this.polyData.clearTriangles();
for ( var i=0; i<normedMonoChains.length; i++ ) {
// loop through uni-y-monotone chains
// => monoPosmin is next to monoPosmax (left or right)
var monoPosmax = normedMonoChains[i... | javascript | function () { // <<<<<<<<<< public
var normedMonoChains = this.polyData.getMonoSubPolys();
this.polyData.clearTriangles();
for ( var i=0; i<normedMonoChains.length; i++ ) {
// loop through uni-y-monotone chains
// => monoPosmin is next to monoPosmax (left or right)
var monoPosmax = normedMonoChains[i... | [
"function",
"(",
")",
"{",
"// <<<<<<<<<< public",
"var",
"normedMonoChains",
"=",
"this",
".",
"polyData",
".",
"getMonoSubPolys",
"(",
")",
";",
"this",
".",
"polyData",
".",
"clearTriangles",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
... | Pass each uni-y-monotone polygon with start at Y-max for greedy triangulation. | [
"Pass",
"each",
"uni",
"-",
"y",
"-",
"monotone",
"polygon",
"with",
"start",
"at",
"Y",
"-",
"max",
"for",
"greedy",
"triangulation",
"."
] | 72f162d39da3a84c78ff16181940da79f3f50ba9 | https://github.com/jahting/pnltri.js/blob/72f162d39da3a84c78ff16181940da79f3f50ba9/build/pnltri.js#L1897-L1913 | train | |
3rd-Eden/FlashPolicyFileServer | index.js | Server | function Server (options, origins) {
var me = this;
this.origins = origins || ['*:*'];
this.port = 843;
this.log = console.log;
// merge `this` with the options
Object.keys(options).forEach(function (key) {
me[key] && (me[key] = options[key])
});
// create the net server
this.socket = net.creat... | javascript | function Server (options, origins) {
var me = this;
this.origins = origins || ['*:*'];
this.port = 843;
this.log = console.log;
// merge `this` with the options
Object.keys(options).forEach(function (key) {
me[key] && (me[key] = options[key])
});
// create the net server
this.socket = net.creat... | [
"function",
"Server",
"(",
"options",
",",
"origins",
")",
"{",
"var",
"me",
"=",
"this",
";",
"this",
".",
"origins",
"=",
"origins",
"||",
"[",
"'*:*'",
"]",
";",
"this",
".",
"port",
"=",
"843",
";",
"this",
".",
"log",
"=",
"console",
".",
"l... | The server that does the Policy File severing
Options:
- `log` false or a function that can output log information, defaults to console.log?
@param {Object} options Options to customize the servers functionality.
@param {Array} origins The origins that are allowed on this server, defaults to `*:*`.
@api public | [
"The",
"server",
"that",
"does",
"the",
"Policy",
"File",
"severing"
] | a3ad25396a63db58afff8d1c1358e1f30458ec37 | https://github.com/3rd-Eden/FlashPolicyFileServer/blob/a3ad25396a63db58afff8d1c1358e1f30458ec37/index.js#L20-L80 | train |
hubiinetwork/nahmii-sdk | lib/settlement/utils.js | determineNonceFromReceipt | function determineNonceFromReceipt(receipt, address) {
const {sender, recipient} = receipt;
return caseInsensitiveCompare(sender.wallet, address) ? sender.nonce : recipient.nonce;
} | javascript | function determineNonceFromReceipt(receipt, address) {
const {sender, recipient} = receipt;
return caseInsensitiveCompare(sender.wallet, address) ? sender.nonce : recipient.nonce;
} | [
"function",
"determineNonceFromReceipt",
"(",
"receipt",
",",
"address",
")",
"{",
"const",
"{",
"sender",
",",
"recipient",
"}",
"=",
"receipt",
";",
"return",
"caseInsensitiveCompare",
"(",
"sender",
".",
"wallet",
",",
"address",
")",
"?",
"sender",
".",
... | Determine the settlement nonce for a wallet.
@param {Receipt} receipt - The receipt object
@param {Address} address - The wallet address
@returns {number} The nonce | [
"Determine",
"the",
"settlement",
"nonce",
"for",
"a",
"wallet",
"."
] | 7a372deebf7d7326e3639ddb01c9ce6224fc83d6 | https://github.com/hubiinetwork/nahmii-sdk/blob/7a372deebf7d7326e3639ddb01c9ce6224fc83d6/lib/settlement/utils.js#L20-L23 | train |
InsideInc/node-pinterest-api | index.js | function(seriesCallback) {
async.eachLimit(groupedPinIds, 50, function(groupOfPinIds, eachCallback) {
var pinIdsString = groupOfPinIds.join(',');
getCache(pinIdsString, true, function (cacheData) {
if (cacheData === null) {
... | javascript | function(seriesCallback) {
async.eachLimit(groupedPinIds, 50, function(groupOfPinIds, eachCallback) {
var pinIdsString = groupOfPinIds.join(',');
getCache(pinIdsString, true, function (cacheData) {
if (cacheData === null) {
... | [
"function",
"(",
"seriesCallback",
")",
"{",
"async",
".",
"eachLimit",
"(",
"groupedPinIds",
",",
"50",
",",
"function",
"(",
"groupOfPinIds",
",",
"eachCallback",
")",
"{",
"var",
"pinIdsString",
"=",
"groupOfPinIds",
".",
"join",
"(",
"','",
")",
";",
"... | get pin data from API | [
"get",
"pin",
"data",
"from",
"API"
] | 74b94fc5ecfc8a52752bcd99b5d25d1223b49692 | https://github.com/InsideInc/node-pinterest-api/blob/74b94fc5ecfc8a52752bcd99b5d25d1223b49692/index.js#L646-L670 | train | |
InsideInc/node-pinterest-api | index.js | function(seriesCallback) {
var userBoardAlreadyAdded = {};
for(var i = 0; i < allPinsData.length; i++) {
var pin = allPinsData[i];
if(pin.board) {
var boardUrlParts = pin.board.url.split('/');
var us... | javascript | function(seriesCallback) {
var userBoardAlreadyAdded = {};
for(var i = 0; i < allPinsData.length; i++) {
var pin = allPinsData[i];
if(pin.board) {
var boardUrlParts = pin.board.url.split('/');
var us... | [
"function",
"(",
"seriesCallback",
")",
"{",
"var",
"userBoardAlreadyAdded",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"allPinsData",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"pin",
"=",
"allPinsData",
"[",
"i",
"]... | create list of boards that the pins belong to | [
"create",
"list",
"of",
"boards",
"that",
"the",
"pins",
"belong",
"to"
] | 74b94fc5ecfc8a52752bcd99b5d25d1223b49692 | https://github.com/InsideInc/node-pinterest-api/blob/74b94fc5ecfc8a52752bcd99b5d25d1223b49692/index.js#L672-L691 | train | |
InsideInc/node-pinterest-api | index.js | function(seriesCallback) {
if(!obtainDates) {
seriesCallback();
return;
}
var pinDateMaps = [];
async.eachLimit(boards, 5, function(board, eachCallback) {
getDatesForBoardPinsFromRss(board.user, ... | javascript | function(seriesCallback) {
if(!obtainDates) {
seriesCallback();
return;
}
var pinDateMaps = [];
async.eachLimit(boards, 5, function(board, eachCallback) {
getDatesForBoardPinsFromRss(board.user, ... | [
"function",
"(",
"seriesCallback",
")",
"{",
"if",
"(",
"!",
"obtainDates",
")",
"{",
"seriesCallback",
"(",
")",
";",
"return",
";",
"}",
"var",
"pinDateMaps",
"=",
"[",
"]",
";",
"async",
".",
"eachLimit",
"(",
"boards",
",",
"5",
",",
"function",
... | get what dates we can for pins from the board RSS feeds | [
"get",
"what",
"dates",
"we",
"can",
"for",
"pins",
"from",
"the",
"board",
"RSS",
"feeds"
] | 74b94fc5ecfc8a52752bcd99b5d25d1223b49692 | https://github.com/InsideInc/node-pinterest-api/blob/74b94fc5ecfc8a52752bcd99b5d25d1223b49692/index.js#L693-L726 | train | |
InsideInc/node-pinterest-api | index.js | function(seriesCallback) {
if(!obtainDates) {
seriesCallback();
return;
}
getDatesForPinsFromScraping(pinsThatNeedScrapedDates, null, function (pinDateMap) {
for (var i = 0; i < allPinsData.length; i++) {
... | javascript | function(seriesCallback) {
if(!obtainDates) {
seriesCallback();
return;
}
getDatesForPinsFromScraping(pinsThatNeedScrapedDates, null, function (pinDateMap) {
for (var i = 0; i < allPinsData.length; i++) {
... | [
"function",
"(",
"seriesCallback",
")",
"{",
"if",
"(",
"!",
"obtainDates",
")",
"{",
"seriesCallback",
"(",
")",
";",
"return",
";",
"}",
"getDatesForPinsFromScraping",
"(",
"pinsThatNeedScrapedDates",
",",
"null",
",",
"function",
"(",
"pinDateMap",
")",
"{"... | get remaining dates by scraping | [
"get",
"remaining",
"dates",
"by",
"scraping"
] | 74b94fc5ecfc8a52752bcd99b5d25d1223b49692 | https://github.com/InsideInc/node-pinterest-api/blob/74b94fc5ecfc8a52752bcd99b5d25d1223b49692/index.js#L728-L744 | train | |
jpederson/Squirrel.js | jquery.squirrel.js | stash | function stash(storage, storageKey, key, value) {
// get the squirrel storage object.
var store = window.JSON.parse(storage.getItem(storageKey));
// if it doesn't exist, create an empty object.
if (store === null) {
store = {};
}
// if a value isn't speci... | javascript | function stash(storage, storageKey, key, value) {
// get the squirrel storage object.
var store = window.JSON.parse(storage.getItem(storageKey));
// if it doesn't exist, create an empty object.
if (store === null) {
store = {};
}
// if a value isn't speci... | [
"function",
"stash",
"(",
"storage",
",",
"storageKey",
",",
"key",
",",
"value",
")",
"{",
"// get the squirrel storage object.",
"var",
"store",
"=",
"window",
".",
"JSON",
".",
"parse",
"(",
"storage",
".",
"getItem",
"(",
"storageKey",
")",
")",
";",
"... | METHODS stash or grab a value from our session store object. | [
"METHODS",
"stash",
"or",
"grab",
"a",
"value",
"from",
"our",
"session",
"store",
"object",
"."
] | 9b8897f2ec03afcf7d4262706a6169c6c196c7ee | https://github.com/jpederson/Squirrel.js/blob/9b8897f2ec03afcf7d4262706a6169c6c196c7ee/jquery.squirrel.js#L295-L333 | train |
SimpleRegex/SRL-JavaScript | lib/Language/Helpers/parseParentheses.js | createLiterallyObjects | function createLiterallyObjects(query, openPos, stringPositions) {
const firstRaw = query.substr(0, openPos)
const result = [firstRaw.trim()]
let pointer = 0
stringPositions.forEach((stringPosition) => {
if (!stringPosition.end) {
throw new SyntaxException('Invalid string ending fou... | javascript | function createLiterallyObjects(query, openPos, stringPositions) {
const firstRaw = query.substr(0, openPos)
const result = [firstRaw.trim()]
let pointer = 0
stringPositions.forEach((stringPosition) => {
if (!stringPosition.end) {
throw new SyntaxException('Invalid string ending fou... | [
"function",
"createLiterallyObjects",
"(",
"query",
",",
"openPos",
",",
"stringPositions",
")",
"{",
"const",
"firstRaw",
"=",
"query",
".",
"substr",
"(",
"0",
",",
"openPos",
")",
"const",
"result",
"=",
"[",
"firstRaw",
".",
"trim",
"(",
")",
"]",
"l... | Replace all "literal strings" with a Literally object to simplify parsing later on.
@param {string} string
@param {number} openPos
@param {array} stringPositions
@return {array}
@throws {SyntaxException} | [
"Replace",
"all",
"literal",
"strings",
"with",
"a",
"Literally",
"object",
"to",
"simplify",
"parsing",
"later",
"on",
"."
] | eb2f0576ec49076e95fc2adec57e10d83c24d438 | https://github.com/SimpleRegex/SRL-JavaScript/blob/eb2f0576ec49076e95fc2adec57e10d83c24d438/lib/Language/Helpers/parseParentheses.js#L118-L150 | train |
nhn/tui.dom | src/js/domevent.js | memorizeHandler | function memorizeHandler(element, type, keyFn, valueFn) {
const map = safeEvent(element, type);
let items = map.get(keyFn);
if (items) {
items.push(valueFn);
} else {
items = [valueFn];
map.set(keyFn, items);
}
} | javascript | function memorizeHandler(element, type, keyFn, valueFn) {
const map = safeEvent(element, type);
let items = map.get(keyFn);
if (items) {
items.push(valueFn);
} else {
items = [valueFn];
map.set(keyFn, items);
}
} | [
"function",
"memorizeHandler",
"(",
"element",
",",
"type",
",",
"keyFn",
",",
"valueFn",
")",
"{",
"const",
"map",
"=",
"safeEvent",
"(",
"element",
",",
"type",
")",
";",
"let",
"items",
"=",
"map",
".",
"get",
"(",
"keyFn",
")",
";",
"if",
"(",
... | Memorize DOM event handler for unbinding
@param {HTMLElement} element - element to bind events
@param {string} type - events name
@param {function} keyFn - handler function that user passed at on() use
@param {function} valueFn - handler function that wrapped by domevent for
implementing some features | [
"Memorize",
"DOM",
"event",
"handler",
"for",
"unbinding"
] | beafe74afb8f647d770e202894ecc9c2dc0ca2b5 | https://github.com/nhn/tui.dom/blob/beafe74afb8f647d770e202894ecc9c2dc0ca2b5/src/js/domevent.js#L50-L60 | train |
nhn/tui.dom | src/js/domevent.js | bindEvent | function bindEvent(element, type, handler, context) {
/**
* Event handler
* @param {Event} e - event object
*/
function eventHandler(e) {
handler.call(context || element, e || window.event);
}
/**
* Event handler for normalize mouseenter event
* @param {MouseEvent} e - ... | javascript | function bindEvent(element, type, handler, context) {
/**
* Event handler
* @param {Event} e - event object
*/
function eventHandler(e) {
handler.call(context || element, e || window.event);
}
/**
* Event handler for normalize mouseenter event
* @param {MouseEvent} e - ... | [
"function",
"bindEvent",
"(",
"element",
",",
"type",
",",
"handler",
",",
"context",
")",
"{",
"/**\n * Event handler\n * @param {Event} e - event object\n */",
"function",
"eventHandler",
"(",
"e",
")",
"{",
"handler",
".",
"call",
"(",
"context",
"||",
... | Bind DOM events
@param {HTMLElement} element - element to bind events
@param {string} type - events name
@param {function} handler - handler function or context for handler
method
@param {object} [context] context - context for handler method. | [
"Bind",
"DOM",
"events"
] | beafe74afb8f647d770e202894ecc9c2dc0ca2b5 | https://github.com/nhn/tui.dom/blob/beafe74afb8f647d770e202894ecc9c2dc0ca2b5/src/js/domevent.js#L80-L114 | train |
nhn/tui.dom | src/js/domevent.js | mouseEnterHandler | function mouseEnterHandler(e) {
e = e || window.event;
if (checkMouse(element, e)) {
eventHandler(e);
}
} | javascript | function mouseEnterHandler(e) {
e = e || window.event;
if (checkMouse(element, e)) {
eventHandler(e);
}
} | [
"function",
"mouseEnterHandler",
"(",
"e",
")",
"{",
"e",
"=",
"e",
"||",
"window",
".",
"event",
";",
"if",
"(",
"checkMouse",
"(",
"element",
",",
"e",
")",
")",
"{",
"eventHandler",
"(",
"e",
")",
";",
"}",
"}"
] | Event handler for normalize mouseenter event
@param {MouseEvent} e - event object | [
"Event",
"handler",
"for",
"normalize",
"mouseenter",
"event"
] | beafe74afb8f647d770e202894ecc9c2dc0ca2b5 | https://github.com/nhn/tui.dom/blob/beafe74afb8f647d770e202894ecc9c2dc0ca2b5/src/js/domevent.js#L93-L99 | train |
nhn/tui.dom | src/js/domevent.js | unbindEvent | function unbindEvent(element, type, handler) {
const events = safeEvent(element, type);
const items = events.get(handler);
if (!items) {
return;
}
forgetHandler(element, type, handler);
util.forEach(items, func => {
if ('removeEventListener' in element) {
element.r... | javascript | function unbindEvent(element, type, handler) {
const events = safeEvent(element, type);
const items = events.get(handler);
if (!items) {
return;
}
forgetHandler(element, type, handler);
util.forEach(items, func => {
if ('removeEventListener' in element) {
element.r... | [
"function",
"unbindEvent",
"(",
"element",
",",
"type",
",",
"handler",
")",
"{",
"const",
"events",
"=",
"safeEvent",
"(",
"element",
",",
"type",
")",
";",
"const",
"items",
"=",
"events",
".",
"get",
"(",
"handler",
")",
";",
"if",
"(",
"!",
"item... | Unbind DOM events
@param {HTMLElement} element - element to unbind events
@param {string} type - events name
@param {function} handler - handler function or context for handler
method | [
"Unbind",
"DOM",
"events"
] | beafe74afb8f647d770e202894ecc9c2dc0ca2b5 | https://github.com/nhn/tui.dom/blob/beafe74afb8f647d770e202894ecc9c2dc0ca2b5/src/js/domevent.js#L123-L140 | train |
lukaaash/sftp-ws | examples/console-client/index.js | execute | function execute(context, action) {
if (!remote) return fail(context, "Not connected to a server");
// prepare source path
if (context.args.length < 1) return fail(context, "Remote path missing");
var path = remote.join(remotePath, context.args[0]);
action(path);
} | javascript | function execute(context, action) {
if (!remote) return fail(context, "Not connected to a server");
// prepare source path
if (context.args.length < 1) return fail(context, "Remote path missing");
var path = remote.join(remotePath, context.args[0]);
action(path);
} | [
"function",
"execute",
"(",
"context",
",",
"action",
")",
"{",
"if",
"(",
"!",
"remote",
")",
"return",
"fail",
"(",
"context",
",",
"\"Not connected to a server\"",
")",
";",
"// prepare source path\r",
"if",
"(",
"context",
".",
"args",
".",
"length",
"<"... | execute a simple action on a remote path | [
"execute",
"a",
"simple",
"action",
"on",
"a",
"remote",
"path"
] | ec48b5974f13233285483201c1808d7c3b3045c3 | https://github.com/lukaaash/sftp-ws/blob/ec48b5974f13233285483201c1808d7c3b3045c3/examples/console-client/index.js#L267-L274 | train |
lukaaash/sftp-ws | examples/console-client/index.js | list | function list(context, err, items, paths) {
if (err) return fail(context, err);
var long = context.options["l"];
if (typeof long === "undefined") long = (context.command.slice(-3) === "dir");
items.forEach(function (item) {
if (item.filename == "." || item.filename == ".."... | javascript | function list(context, err, items, paths) {
if (err) return fail(context, err);
var long = context.options["l"];
if (typeof long === "undefined") long = (context.command.slice(-3) === "dir");
items.forEach(function (item) {
if (item.filename == "." || item.filename == ".."... | [
"function",
"list",
"(",
"context",
",",
"err",
",",
"items",
",",
"paths",
")",
"{",
"if",
"(",
"err",
")",
"return",
"fail",
"(",
"context",
",",
"err",
")",
";",
"var",
"long",
"=",
"context",
".",
"options",
"[",
"\"l\"",
"]",
";",
"if",
"(",... | display a list of items | [
"display",
"a",
"list",
"of",
"items"
] | ec48b5974f13233285483201c1808d7c3b3045c3 | https://github.com/lukaaash/sftp-ws/blob/ec48b5974f13233285483201c1808d7c3b3045c3/examples/console-client/index.js#L277-L297 | train |
lukaaash/sftp-ws | examples/console-client/index.js | done | function done(context, err, message) {
if (err) return fail(context, err);
if (typeof message !== "undefined") shell.write(message);
context.end();
} | javascript | function done(context, err, message) {
if (err) return fail(context, err);
if (typeof message !== "undefined") shell.write(message);
context.end();
} | [
"function",
"done",
"(",
"context",
",",
"err",
",",
"message",
")",
"{",
"if",
"(",
"err",
")",
"return",
"fail",
"(",
"context",
",",
"err",
")",
";",
"if",
"(",
"typeof",
"message",
"!==",
"\"undefined\"",
")",
"shell",
".",
"write",
"(",
"message... | finish command successfully or with an error | [
"finish",
"command",
"successfully",
"or",
"with",
"an",
"error"
] | ec48b5974f13233285483201c1808d7c3b3045c3 | https://github.com/lukaaash/sftp-ws/blob/ec48b5974f13233285483201c1808d7c3b3045c3/examples/console-client/index.js#L327-L331 | train |
lukaaash/sftp-ws | examples/console-client/index.js | fail | function fail(context, err) {
var message;
switch (err.code) {
case "ENOENT":
message = err.path + ": No such file or directory";
break;
case "ENOSYS":
message = "Command not supported";
break;
default:
message = err["... | javascript | function fail(context, err) {
var message;
switch (err.code) {
case "ENOENT":
message = err.path + ": No such file or directory";
break;
case "ENOSYS":
message = "Command not supported";
break;
default:
message = err["... | [
"function",
"fail",
"(",
"context",
",",
"err",
")",
"{",
"var",
"message",
";",
"switch",
"(",
"err",
".",
"code",
")",
"{",
"case",
"\"ENOENT\"",
":",
"message",
"=",
"err",
".",
"path",
"+",
"\": No such file or directory\"",
";",
"break",
";",
"case"... | fail command with an error message | [
"fail",
"command",
"with",
"an",
"error",
"message"
] | ec48b5974f13233285483201c1808d7c3b3045c3 | https://github.com/lukaaash/sftp-ws/blob/ec48b5974f13233285483201c1808d7c3b3045c3/examples/console-client/index.js#L334-L349 | train |
leodido/luhn.js | gulpfile.babel.js | umd | function umd() {
let bundler = browserify(src, { debug: true, standalone: 'luhn' })
.transform(babelify) // .configure({ optional: ['runtime'] })
.bundle();
return bundler
.pipe(source(pack.main)) // gives streaming vinyl file object
.pipe(buffer()) // convert from streaming to buffered vinyl file ... | javascript | function umd() {
let bundler = browserify(src, { debug: true, standalone: 'luhn' })
.transform(babelify) // .configure({ optional: ['runtime'] })
.bundle();
return bundler
.pipe(source(pack.main)) // gives streaming vinyl file object
.pipe(buffer()) // convert from streaming to buffered vinyl file ... | [
"function",
"umd",
"(",
")",
"{",
"let",
"bundler",
"=",
"browserify",
"(",
"src",
",",
"{",
"debug",
":",
"true",
",",
"standalone",
":",
"'luhn'",
"}",
")",
".",
"transform",
"(",
"babelify",
")",
"// .configure({ optional: ['runtime'] })",
".",
"bundle",
... | umd standalone library with sourcemaps | [
"umd",
"standalone",
"library",
"with",
"sourcemaps"
] | ef24d03e0e7f56ba6bafde0f966813ecb8cf7419 | https://github.com/leodido/luhn.js/blob/ef24d03e0e7f56ba6bafde0f966813ecb8cf7419/gulpfile.babel.js#L33-L44 | train |
leodido/luhn.js | gulpfile.babel.js | min | function min() {
return gulp.src(pack.main)
.pipe(uglify())
.on('error', gutil.log)
.pipe(rename({ extname: minext + '.js' }))
.pipe(gulp.dest('./'));
} | javascript | function min() {
return gulp.src(pack.main)
.pipe(uglify())
.on('error', gutil.log)
.pipe(rename({ extname: minext + '.js' }))
.pipe(gulp.dest('./'));
} | [
"function",
"min",
"(",
")",
"{",
"return",
"gulp",
".",
"src",
"(",
"pack",
".",
"main",
")",
".",
"pipe",
"(",
"uglify",
"(",
")",
")",
".",
"on",
"(",
"'error'",
",",
"gutil",
".",
"log",
")",
".",
"pipe",
"(",
"rename",
"(",
"{",
"extname",... | minified umd standalone library | [
"minified",
"umd",
"standalone",
"library"
] | ef24d03e0e7f56ba6bafde0f966813ecb8cf7419 | https://github.com/leodido/luhn.js/blob/ef24d03e0e7f56ba6bafde0f966813ecb8cf7419/gulpfile.babel.js#L47-L53 | train |
hubiinetwork/nahmii-sdk | lib/event-provider/index.js | subscribeToEvents | function subscribeToEvents() {
const socket = _socket.get(this);
function onEventApiError(error) {
dbg('Event API connection error: ' + JSON.stringify(error));
}
socket.on('pong', (latency) => {
dbg(`Event API latency: ${latency} ms`);
});
socket.on('connect_error', onEventApiE... | javascript | function subscribeToEvents() {
const socket = _socket.get(this);
function onEventApiError(error) {
dbg('Event API connection error: ' + JSON.stringify(error));
}
socket.on('pong', (latency) => {
dbg(`Event API latency: ${latency} ms`);
});
socket.on('connect_error', onEventApiE... | [
"function",
"subscribeToEvents",
"(",
")",
"{",
"const",
"socket",
"=",
"_socket",
".",
"get",
"(",
"this",
")",
";",
"function",
"onEventApiError",
"(",
"error",
")",
"{",
"dbg",
"(",
"'Event API connection error: '",
"+",
"JSON",
".",
"stringify",
"(",
"er... | Subscribes to critical socket.io events and relays nahmii events to any
registered listeners.
Private method, invoke with 'this' bound to provider instance.
@private | [
"Subscribes",
"to",
"critical",
"socket",
".",
"io",
"events",
"and",
"relays",
"nahmii",
"events",
"to",
"any",
"registered",
"listeners",
".",
"Private",
"method",
"invoke",
"with",
"this",
"bound",
"to",
"provider",
"instance",
"."
] | 7a372deebf7d7326e3639ddb01c9ce6224fc83d6 | https://github.com/hubiinetwork/nahmii-sdk/blob/7a372deebf7d7326e3639ddb01c9ce6224fc83d6/lib/event-provider/index.js#L136-L158 | train |
AdamBrodzinski/RedScript | lib/transform.js | function(line) {
// example: def bar(a, b) do
//
// (^\s*) begining of line
// (def|defp) $1 public or private def
// (.*?) $2 in betweend def ... do
// \s* optional space
// do opening keyword (bracket in JS)
// \s*$ ... | javascript | function(line) {
// example: def bar(a, b) do
//
// (^\s*) begining of line
// (def|defp) $1 public or private def
// (.*?) $2 in betweend def ... do
// \s* optional space
// do opening keyword (bracket in JS)
// \s*$ ... | [
"function",
"(",
"line",
")",
"{",
"// example: def bar(a, b) do",
"//",
"// (^\\s*) begining of line",
"// (def|defp) $1 public or private def",
"// (.*?) $2 in betweend def ... do",
"// \\s* optional space",
"// do opening keyword (bracket in JS)",
"// \... | defines public and private module functions returns String a -> String b | [
"defines",
"public",
"and",
"private",
"module",
"functions",
"returns",
"String",
"a",
"-",
">",
"String",
"b"
] | ec5b657770c268441bb9cf37cac2080a5707da95 | https://github.com/AdamBrodzinski/RedScript/blob/ec5b657770c268441bb9cf37cac2080a5707da95/lib/transform.js#L38-L67 | train | |
AdamBrodzinski/RedScript | lib/transform.js | function(line) {
var newLine;
// ex: [foo <- 1,2,3]
// [ opening array
// (.*) $1 array to concat into
// (<-) $2
// (.*) $3 content to be merged
// ] closing array
var regexArr = /\[(.*)(\<\-)(.*)\]/;
// ex: {foo <- foo... | javascript | function(line) {
var newLine;
// ex: [foo <- 1,2,3]
// [ opening array
// (.*) $1 array to concat into
// (<-) $2
// (.*) $3 content to be merged
// ] closing array
var regexArr = /\[(.*)(\<\-)(.*)\]/;
// ex: {foo <- foo... | [
"function",
"(",
"line",
")",
"{",
"var",
"newLine",
";",
"// ex: [foo <- 1,2,3]",
"// [ opening array",
"// (.*) $1 array to concat into",
"// (<-) $2",
"// (.*) $3 content to be merged",
"// ] closing array",
"var",
"regexArr",
"=",
"/",
"\\[(.*)(\\<\\... | merges immutable objects or arrays together returns String a -> String b | [
"merges",
"immutable",
"objects",
"or",
"arrays",
"together",
"returns",
"String",
"a",
"-",
">",
"String",
"b"
] | ec5b657770c268441bb9cf37cac2080a5707da95 | https://github.com/AdamBrodzinski/RedScript/blob/ec5b657770c268441bb9cf37cac2080a5707da95/lib/transform.js#L72-L98 | train | |
AdamBrodzinski/RedScript | lib/transform.js | function(line, index, lines) {
var newLine;
if (insideString('|>', line)) return line;
// line does not have a one liner pipeline
if (!line.match(/(\=|return)(.*?)(\|\>)/)) return line;
// if next line has a pipe operator
if (lines[index] && lines[index + 1].match(/^\s*\|... | javascript | function(line, index, lines) {
var newLine;
if (insideString('|>', line)) return line;
// line does not have a one liner pipeline
if (!line.match(/(\=|return)(.*?)(\|\>)/)) return line;
// if next line has a pipe operator
if (lines[index] && lines[index + 1].match(/^\s*\|... | [
"function",
"(",
"line",
",",
"index",
",",
"lines",
")",
"{",
"var",
"newLine",
";",
"if",
"(",
"insideString",
"(",
"'|>'",
",",
"line",
")",
")",
"return",
"line",
";",
"// line does not have a one liner pipeline",
"if",
"(",
"!",
"line",
".",
"match",
... | One liner piping returns String a -> String b | [
"One",
"liner",
"piping",
"returns",
"String",
"a",
"-",
">",
"String",
"b"
] | ec5b657770c268441bb9cf37cac2080a5707da95 | https://github.com/AdamBrodzinski/RedScript/blob/ec5b657770c268441bb9cf37cac2080a5707da95/lib/transform.js#L120-L154 | train | |
AdamBrodzinski/RedScript | lib/transform.js | function(line) {
//^
// (\s*) $1 opts leading spaces
// ([\w$]+\s*) $2 variable name & trailing spaces
// (\=) $3 division equals OR
// \s* opt spaces
// (.*?) rest of expression to assign
// $
var parts = line.match(/^(\s*)... | javascript | function(line) {
//^
// (\s*) $1 opts leading spaces
// ([\w$]+\s*) $2 variable name & trailing spaces
// (\=) $3 division equals OR
// \s* opt spaces
// (.*?) rest of expression to assign
// $
var parts = line.match(/^(\s*)... | [
"function",
"(",
"line",
")",
"{",
"//^",
"// (\\s*) $1 opts leading spaces",
"// ([\\w$]+\\s*) $2 variable name & trailing spaces",
"// (\\=) $3 division equals OR",
"// \\s* opt spaces",
"// (.*?) rest of expression to assign",
"// $",
"var",
"parts",
"=... | adds `const` to any declaration, works with shorthand operators String a -> String b | [
"adds",
"const",
"to",
"any",
"declaration",
"works",
"with",
"shorthand",
"operators",
"String",
"a",
"-",
">",
"String",
"b"
] | ec5b657770c268441bb9cf37cac2080a5707da95 | https://github.com/AdamBrodzinski/RedScript/blob/ec5b657770c268441bb9cf37cac2080a5707da95/lib/transform.js#L229-L246 | train | |
GrosSacASac/DOM99 | documentation/presentation/reveal.js-2.6.2/plugin/zoom-js/zoom.js | magnify | function magnify( pageOffsetX, pageOffsetY, elementOffsetX, elementOffsetY, scale ) {
if( supportsTransforms ) {
var origin = pageOffsetX +'px '+ pageOffsetY +'px',
transform = 'translate('+ -elementOffsetX +'px,'+ -elementOffsetY +'px) scale('+ scale +')';
document.body.style.transformOrigin = origin;
... | javascript | function magnify( pageOffsetX, pageOffsetY, elementOffsetX, elementOffsetY, scale ) {
if( supportsTransforms ) {
var origin = pageOffsetX +'px '+ pageOffsetY +'px',
transform = 'translate('+ -elementOffsetX +'px,'+ -elementOffsetY +'px) scale('+ scale +')';
document.body.style.transformOrigin = origin;
... | [
"function",
"magnify",
"(",
"pageOffsetX",
",",
"pageOffsetY",
",",
"elementOffsetX",
",",
"elementOffsetY",
",",
"scale",
")",
"{",
"if",
"(",
"supportsTransforms",
")",
"{",
"var",
"origin",
"=",
"pageOffsetX",
"+",
"'px '",
"+",
"pageOffsetY",
"+",
"'px'",
... | Applies the CSS required to zoom in, prioritizes use of CSS3
transforms but falls back on zoom for IE.
@param {Number} pageOffsetX
@param {Number} pageOffsetY
@param {Number} elementOffsetX
@param {Number} elementOffsetY
@param {Number} scale | [
"Applies",
"the",
"CSS",
"required",
"to",
"zoom",
"in",
"prioritizes",
"use",
"of",
"CSS3",
"transforms",
"but",
"falls",
"back",
"on",
"zoom",
"for",
"IE",
"."
] | 0563cb3d4865d968e829d39c68dc62af3fc95cc8 | https://github.com/GrosSacASac/DOM99/blob/0563cb3d4865d968e829d39c68dc62af3fc95cc8/documentation/presentation/reveal.js-2.6.2/plugin/zoom-js/zoom.js#L81-L128 | train |
GrosSacASac/DOM99 | documentation/presentation/reveal.js-2.6.2/plugin/zoom-js/zoom.js | pan | function pan() {
var range = 0.12,
rangeX = window.innerWidth * range,
rangeY = window.innerHeight * range,
scrollOffset = getScrollOffset();
// Up
if( mouseY < rangeY ) {
window.scroll( scrollOffset.x, scrollOffset.y - ( 1 - ( mouseY / rangeY ) ) * ( 14 / level ) );
}
// Down
else if( mouseY >... | javascript | function pan() {
var range = 0.12,
rangeX = window.innerWidth * range,
rangeY = window.innerHeight * range,
scrollOffset = getScrollOffset();
// Up
if( mouseY < rangeY ) {
window.scroll( scrollOffset.x, scrollOffset.y - ( 1 - ( mouseY / rangeY ) ) * ( 14 / level ) );
}
// Down
else if( mouseY >... | [
"function",
"pan",
"(",
")",
"{",
"var",
"range",
"=",
"0.12",
",",
"rangeX",
"=",
"window",
".",
"innerWidth",
"*",
"range",
",",
"rangeY",
"=",
"window",
".",
"innerHeight",
"*",
"range",
",",
"scrollOffset",
"=",
"getScrollOffset",
"(",
")",
";",
"/... | Pan the document when the mosue cursor approaches the edges
of the window. | [
"Pan",
"the",
"document",
"when",
"the",
"mosue",
"cursor",
"approaches",
"the",
"edges",
"of",
"the",
"window",
"."
] | 0563cb3d4865d968e829d39c68dc62af3fc95cc8 | https://github.com/GrosSacASac/DOM99/blob/0563cb3d4865d968e829d39c68dc62af3fc95cc8/documentation/presentation/reveal.js-2.6.2/plugin/zoom-js/zoom.js#L134-L157 | train |
GrosSacASac/DOM99 | documentation/presentation/reveal.js-2.6.2/plugin/zoom-js/zoom.js | function() {
clearTimeout( panEngageTimeout );
clearInterval( panUpdateInterval );
var scrollOffset = getScrollOffset();
if( currentOptions && currentOptions.element ) {
scrollOffset.x -= ( window.innerWidth - ( currentOptions.width * currentOptions.scale ) ) / 2;
}
magnify( scrollOffset.x, scr... | javascript | function() {
clearTimeout( panEngageTimeout );
clearInterval( panUpdateInterval );
var scrollOffset = getScrollOffset();
if( currentOptions && currentOptions.element ) {
scrollOffset.x -= ( window.innerWidth - ( currentOptions.width * currentOptions.scale ) ) / 2;
}
magnify( scrollOffset.x, scr... | [
"function",
"(",
")",
"{",
"clearTimeout",
"(",
"panEngageTimeout",
")",
";",
"clearInterval",
"(",
"panUpdateInterval",
")",
";",
"var",
"scrollOffset",
"=",
"getScrollOffset",
"(",
")",
";",
"if",
"(",
"currentOptions",
"&&",
"currentOptions",
".",
"element",
... | Resets the document zoom state to its default. | [
"Resets",
"the",
"document",
"zoom",
"state",
"to",
"its",
"default",
"."
] | 0563cb3d4865d968e829d39c68dc62af3fc95cc8 | https://github.com/GrosSacASac/DOM99/blob/0563cb3d4865d968e829d39c68dc62af3fc95cc8/documentation/presentation/reveal.js-2.6.2/plugin/zoom-js/zoom.js#L233-L246 | train | |
Botanalyticsco/botanalytics | examples/amazon-lex-with-lambda.js | buildResponseCard | function buildResponseCard(title, subTitle, options) {
let buttons = null;
if (options != null) {
buttons = [];
for (let i = 0; i < Math.min(5, options.length); i++) {
buttons.push(options[i]);
}
}
return {
contentType: 'application/vnd.amazonaws.card.generic'... | javascript | function buildResponseCard(title, subTitle, options) {
let buttons = null;
if (options != null) {
buttons = [];
for (let i = 0; i < Math.min(5, options.length); i++) {
buttons.push(options[i]);
}
}
return {
contentType: 'application/vnd.amazonaws.card.generic'... | [
"function",
"buildResponseCard",
"(",
"title",
",",
"subTitle",
",",
"options",
")",
"{",
"let",
"buttons",
"=",
"null",
";",
"if",
"(",
"options",
"!=",
"null",
")",
"{",
"buttons",
"=",
"[",
"]",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
... | Build a responseCard with a title, subtitle, and an optional set of options which should be displayed as buttons. | [
"Build",
"a",
"responseCard",
"with",
"a",
"title",
"subtitle",
"and",
"an",
"optional",
"set",
"of",
"options",
"which",
"should",
"be",
"displayed",
"as",
"buttons",
"."
] | a6ca41f226752ab765b939dbc11bb6402465603a | https://github.com/Botanalyticsco/botanalytics/blob/a6ca41f226752ab765b939dbc11bb6402465603a/examples/amazon-lex-with-lambda.js#L74-L91 | train |
Botanalyticsco/botanalytics | examples/amazon-lex-with-lambda.js | getAvailabilities | function getAvailabilities(date) {
const dayOfWeek = parseLocalDate(date).getDay();
const availabilities = [];
const availableProbability = 0.3;
if (dayOfWeek === 1) {
let startHour = 10;
while (startHour <= 16) {
if (Math.random() < availableProbability) {
//... | javascript | function getAvailabilities(date) {
const dayOfWeek = parseLocalDate(date).getDay();
const availabilities = [];
const availableProbability = 0.3;
if (dayOfWeek === 1) {
let startHour = 10;
while (startHour <= 16) {
if (Math.random() < availableProbability) {
//... | [
"function",
"getAvailabilities",
"(",
"date",
")",
"{",
"const",
"dayOfWeek",
"=",
"parseLocalDate",
"(",
"date",
")",
".",
"getDay",
"(",
")",
";",
"const",
"availabilities",
"=",
"[",
"]",
";",
"const",
"availableProbability",
"=",
"0.3",
";",
"if",
"(",... | Helper function which in a full implementation would feed into a backend API to provide query schedule availability.
The output of this function is an array of 30 minute periods of availability, expressed in ISO-8601 time format.
In order to enable quick demonstration of all possible conversation paths supported in t... | [
"Helper",
"function",
"which",
"in",
"a",
"full",
"implementation",
"would",
"feed",
"into",
"a",
"backend",
"API",
"to",
"provide",
"query",
"schedule",
"availability",
".",
"The",
"output",
"of",
"this",
"function",
"is",
"an",
"array",
"of",
"30",
"minute... | a6ca41f226752ab765b939dbc11bb6402465603a | https://github.com/Botanalyticsco/botanalytics/blob/a6ca41f226752ab765b939dbc11bb6402465603a/examples/amazon-lex-with-lambda.js#L138-L166 | train |
Botanalyticsco/botanalytics | examples/amazon-lex-with-lambda.js | getAvailabilitiesForDuration | function getAvailabilitiesForDuration(duration, availabilities) {
const durationAvailabilities = [];
let startTime = '10:00';
while (startTime !== '17:00') {
if (availabilities.indexOf(startTime) !== -1) {
if (duration === 30) {
durationAvailabilities.push(startTime);
... | javascript | function getAvailabilitiesForDuration(duration, availabilities) {
const durationAvailabilities = [];
let startTime = '10:00';
while (startTime !== '17:00') {
if (availabilities.indexOf(startTime) !== -1) {
if (duration === 30) {
durationAvailabilities.push(startTime);
... | [
"function",
"getAvailabilitiesForDuration",
"(",
"duration",
",",
"availabilities",
")",
"{",
"const",
"durationAvailabilities",
"=",
"[",
"]",
";",
"let",
"startTime",
"=",
"'10:00'",
";",
"while",
"(",
"startTime",
"!==",
"'17:00'",
")",
"{",
"if",
"(",
"ava... | Helper function to return the windows of availability of the given duration, when provided a set of 30 minute windows. | [
"Helper",
"function",
"to",
"return",
"the",
"windows",
"of",
"availability",
"of",
"the",
"given",
"duration",
"when",
"provided",
"a",
"set",
"of",
"30",
"minute",
"windows",
"."
] | a6ca41f226752ab765b939dbc11bb6402465603a | https://github.com/Botanalyticsco/botanalytics/blob/a6ca41f226752ab765b939dbc11bb6402465603a/examples/amazon-lex-with-lambda.js#L187-L201 | train |
Botanalyticsco/botanalytics | examples/amazon-lex-with-lambda.js | buildAvailableTimeString | function buildAvailableTimeString(availabilities) {
let prefix = 'We have availabilities at ';
if (availabilities.length > 3) {
prefix = 'We have plenty of availability, including ';
}
prefix += buildTimeOutputString(availabilities[0]);
if (availabilities.length === 2) {
return `${pr... | javascript | function buildAvailableTimeString(availabilities) {
let prefix = 'We have availabilities at ';
if (availabilities.length > 3) {
prefix = 'We have plenty of availability, including ';
}
prefix += buildTimeOutputString(availabilities[0]);
if (availabilities.length === 2) {
return `${pr... | [
"function",
"buildAvailableTimeString",
"(",
"availabilities",
")",
"{",
"let",
"prefix",
"=",
"'We have availabilities at '",
";",
"if",
"(",
"availabilities",
".",
"length",
">",
"3",
")",
"{",
"prefix",
"=",
"'We have plenty of availability, including '",
";",
"}",... | Build a string eliciting for a possible time slot among at least two availabilities. | [
"Build",
"a",
"string",
"eliciting",
"for",
"a",
"possible",
"time",
"slot",
"among",
"at",
"least",
"two",
"availabilities",
"."
] | a6ca41f226752ab765b939dbc11bb6402465603a | https://github.com/Botanalyticsco/botanalytics/blob/a6ca41f226752ab765b939dbc11bb6402465603a/examples/amazon-lex-with-lambda.js#L260-L270 | train |
Botanalyticsco/botanalytics | examples/amazon-lex-with-lambda.js | buildOptions | function buildOptions(slot, appointmentType, date, bookingMap) {
const dayStrings = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
if (slot === 'AppointmentType') {
return [
{ text: 'cleaning (30 min)', value: 'cleaning' },
{ text: 'root canal (60 min)', value: 'root canal' }... | javascript | function buildOptions(slot, appointmentType, date, bookingMap) {
const dayStrings = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
if (slot === 'AppointmentType') {
return [
{ text: 'cleaning (30 min)', value: 'cleaning' },
{ text: 'root canal (60 min)', value: 'root canal' }... | [
"function",
"buildOptions",
"(",
"slot",
",",
"appointmentType",
",",
"date",
",",
"bookingMap",
")",
"{",
"const",
"dayStrings",
"=",
"[",
"'Sun'",
",",
"'Mon'",
",",
"'Tue'",
",",
"'Wed'",
",",
"'Thu'",
",",
"'Fri'",
",",
"'Sat'",
"]",
";",
"if",
"("... | Build a list of potential options for a given slot, to be used in responseCard generation. | [
"Build",
"a",
"list",
"of",
"potential",
"options",
"for",
"a",
"given",
"slot",
"to",
"be",
"used",
"in",
"responseCard",
"generation",
"."
] | a6ca41f226752ab765b939dbc11bb6402465603a | https://github.com/Botanalyticsco/botanalytics/blob/a6ca41f226752ab765b939dbc11bb6402465603a/examples/amazon-lex-with-lambda.js#L273-L312 | train |
alltherooms/cached-request | lib/cached-request.js | makeRequest | function makeRequest () {
request = self.request.apply(null, args);
requestMiddleware.use(request);
request.on("response", function (response) {
var contentEncoding, gzipper;
//Only cache successful responses
if (response.statusCode >= 200 && response.statusCode < 300) {
response.... | javascript | function makeRequest () {
request = self.request.apply(null, args);
requestMiddleware.use(request);
request.on("response", function (response) {
var contentEncoding, gzipper;
//Only cache successful responses
if (response.statusCode >= 200 && response.statusCode < 300) {
response.... | [
"function",
"makeRequest",
"(",
")",
"{",
"request",
"=",
"self",
".",
"request",
".",
"apply",
"(",
"null",
",",
"args",
")",
";",
"requestMiddleware",
".",
"use",
"(",
"request",
")",
";",
"request",
".",
"on",
"(",
"\"response\"",
",",
"function",
"... | Makes the actual request and caches the response | [
"Makes",
"the",
"actual",
"request",
"and",
"caches",
"the",
"response"
] | 41a841cb05e338dda40a055c682a9ee493757023 | https://github.com/alltherooms/cached-request/blob/41a841cb05e338dda40a055c682a9ee493757023/lib/cached-request.js#L259-L306 | train |
echo008/xmi | packages/xmi-router/src/dynamic.js | dynamicLoad | function dynamicLoad(dynamicOptions, options, defaultOptions) {
let loadableFn = Loadable
let loadableOptions = defaultOptions
if (typeof dynamicOptions.then === 'function') {
// Support for direct import(),
// eg: dynamic(import('../hello-world'))
loadableOptions.loader = () => dyn... | javascript | function dynamicLoad(dynamicOptions, options, defaultOptions) {
let loadableFn = Loadable
let loadableOptions = defaultOptions
if (typeof dynamicOptions.then === 'function') {
// Support for direct import(),
// eg: dynamic(import('../hello-world'))
loadableOptions.loader = () => dyn... | [
"function",
"dynamicLoad",
"(",
"dynamicOptions",
",",
"options",
",",
"defaultOptions",
")",
"{",
"let",
"loadableFn",
"=",
"Loadable",
"let",
"loadableOptions",
"=",
"defaultOptions",
"if",
"(",
"typeof",
"dynamicOptions",
".",
"then",
"===",
"'function'",
")",
... | Thanks to umi | [
"Thanks",
"to",
"umi"
] | c751515b537fa713a6df45b30d0767bbb1e8c66c | https://github.com/echo008/xmi/blob/c751515b537fa713a6df45b30d0767bbb1e8c66c/packages/xmi-router/src/dynamic.js#L19-L62 | train |
sebarmeli/bamboo-api | lib/bamboo.js | function(host, username, password) {
var defaultUrl = "http://localhost:8085";
host = host || defaultUrl;
if (username && password) {
var protocol = host.match(/(^|\s)(https?:\/\/)/i);
if (_.isArray(protocol)) {
protocol = _.first(protocol);
... | javascript | function(host, username, password) {
var defaultUrl = "http://localhost:8085";
host = host || defaultUrl;
if (username && password) {
var protocol = host.match(/(^|\s)(https?:\/\/)/i);
if (_.isArray(protocol)) {
protocol = _.first(protocol);
... | [
"function",
"(",
"host",
",",
"username",
",",
"password",
")",
"{",
"var",
"defaultUrl",
"=",
"\"http://localhost:8085\"",
";",
"host",
"=",
"host",
"||",
"defaultUrl",
";",
"if",
"(",
"username",
"&&",
"password",
")",
"{",
"var",
"protocol",
"=",
"host"... | Function defining a Bamboo instance
@param {String} host - hostname. By default "http://localhost:8085"
@param {String=} username - optional param for base HTTP authentication. Username
@param {String=} password - optional param for base HTTP authentication. Password
@constructor | [
"Function",
"defining",
"a",
"Bamboo",
"instance"
] | 2ef5a9040dfb1c05dc55d14629db3f544a446f4d | https://github.com/sebarmeli/bamboo-api/blob/2ef5a9040dfb1c05dc55d14629db3f544a446f4d/lib/bamboo.js#L25-L43 | train | |
sebarmeli/bamboo-api | lib/bamboo.js | checkErrorsWithResult | function checkErrorsWithResult(error, response) {
var errors = checkErrors(error, response);
if (errors !== false) {
return errors;
}
try {
var body = JSON.parse(response.body);
} catch (parseError) {
return parseError;
}
var... | javascript | function checkErrorsWithResult(error, response) {
var errors = checkErrors(error, response);
if (errors !== false) {
return errors;
}
try {
var body = JSON.parse(response.body);
} catch (parseError) {
return parseError;
}
var... | [
"function",
"checkErrorsWithResult",
"(",
"error",
",",
"response",
")",
"{",
"var",
"errors",
"=",
"checkErrors",
"(",
"error",
",",
"response",
")",
";",
"if",
"(",
"errors",
"!==",
"false",
")",
"{",
"return",
"errors",
";",
"}",
"try",
"{",
"var",
... | Method checks for errors in error and server response
Additionally parsing response body and checking if it contain any results
@param {Error|null} error
@param {Object} response
@returns {Error|Boolean} if error, will return Error otherwise false
@protected | [
"Method",
"checks",
"for",
"errors",
"in",
"error",
"and",
"server",
"response",
"Additionally",
"parsing",
"response",
"body",
"and",
"checking",
"if",
"it",
"contain",
"any",
"results"
] | 2ef5a9040dfb1c05dc55d14629db3f544a446f4d | https://github.com/sebarmeli/bamboo-api/blob/2ef5a9040dfb1c05dc55d14629db3f544a446f4d/lib/bamboo.js#L711-L731 | train |
sebarmeli/bamboo-api | lib/bamboo.js | checkErrors | function checkErrors(error, response) {
if (error) {
return error instanceof Error ? error : new Error(error);
}
// Bamboo API enable plan returns 204 with empty response in case of success
if ((response.statusCode !== 200) && (response.statusCode !== 204)) {
ret... | javascript | function checkErrors(error, response) {
if (error) {
return error instanceof Error ? error : new Error(error);
}
// Bamboo API enable plan returns 204 with empty response in case of success
if ((response.statusCode !== 200) && (response.statusCode !== 204)) {
ret... | [
"function",
"checkErrors",
"(",
"error",
",",
"response",
")",
"{",
"if",
"(",
"error",
")",
"{",
"return",
"error",
"instanceof",
"Error",
"?",
"error",
":",
"new",
"Error",
"(",
"error",
")",
";",
"}",
"// Bamboo API enable plan returns 204 with empty response... | Method checks for errors in error and server response
@param {Error|null} error
@param {Object} response
@returns {Error|Boolean} if error, will return Error otherwise false
@protected | [
"Method",
"checks",
"for",
"errors",
"in",
"error",
"and",
"server",
"response"
] | 2ef5a9040dfb1c05dc55d14629db3f544a446f4d | https://github.com/sebarmeli/bamboo-api/blob/2ef5a9040dfb1c05dc55d14629db3f544a446f4d/lib/bamboo.js#L741-L752 | train |
sebarmeli/bamboo-api | lib/bamboo.js | mergeUrlWithParams | function mergeUrlWithParams(url, params) {
params = params || {};
return _.isEmpty(params) ? url : url + "?" + qs.stringify(params);
} | javascript | function mergeUrlWithParams(url, params) {
params = params || {};
return _.isEmpty(params) ? url : url + "?" + qs.stringify(params);
} | [
"function",
"mergeUrlWithParams",
"(",
"url",
",",
"params",
")",
"{",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"return",
"_",
".",
"isEmpty",
"(",
"params",
")",
"?",
"url",
":",
"url",
"+",
"\"?\"",
"+",
"qs",
".",
"stringify",
"(",
"params",
... | Method will add params to the specified url
@param {String} url
@param {Object=} params - optional, object with parameters that should be merged with specified url
@returns {String}
@protected | [
"Method",
"will",
"add",
"params",
"to",
"the",
"specified",
"url"
] | 2ef5a9040dfb1c05dc55d14629db3f544a446f4d | https://github.com/sebarmeli/bamboo-api/blob/2ef5a9040dfb1c05dc55d14629db3f544a446f4d/lib/bamboo.js#L762-L765 | train |
pa11y/pa11y-webservice-client-node | lib/client.js | client | function client (root) {
return {
tasks: {
// Create a new task
create: function (task, done) {
post(root + 'tasks', task, done);
},
// Get all tasks
get: function (query, done) {
get(root + 'tasks', query, done);
},
// Get results for all tasks
results: function (query, done) {
... | javascript | function client (root) {
return {
tasks: {
// Create a new task
create: function (task, done) {
post(root + 'tasks', task, done);
},
// Get all tasks
get: function (query, done) {
get(root + 'tasks', query, done);
},
// Get results for all tasks
results: function (query, done) {
... | [
"function",
"client",
"(",
"root",
")",
"{",
"return",
"{",
"tasks",
":",
"{",
"// Create a new task",
"create",
":",
"function",
"(",
"task",
",",
"done",
")",
"{",
"post",
"(",
"root",
"+",
"'tasks'",
",",
"task",
",",
"done",
")",
";",
"}",
",",
... | Create a web-service client | [
"Create",
"a",
"web",
"-",
"service",
"client"
] | 841f1bf26dce4de578add0761fa88e00c7a2d3bf | https://github.com/pa11y/pa11y-webservice-client-node/blob/841f1bf26dce4de578add0761fa88e00c7a2d3bf/lib/client.js#L23-L88 | train |
matrix-org/matrix-react-skin | src/app/index.js | routeUrl | function routeUrl(location) {
if (location.hash.indexOf('#/register') == 0) {
var hashparts = location.hash.split('?');
var params = {};
if (hashparts.length == 2) {
var pairs = hashparts[1].split('&');
for (var i = 0; i < pairs.length; ++i) {
var part... | javascript | function routeUrl(location) {
if (location.hash.indexOf('#/register') == 0) {
var hashparts = location.hash.split('?');
var params = {};
if (hashparts.length == 2) {
var pairs = hashparts[1].split('&');
for (var i = 0; i < pairs.length; ++i) {
var part... | [
"function",
"routeUrl",
"(",
"location",
")",
"{",
"if",
"(",
"location",
".",
"hash",
".",
"indexOf",
"(",
"'#/register'",
")",
"==",
"0",
")",
"{",
"var",
"hashparts",
"=",
"location",
".",
"hash",
".",
"split",
"(",
"'?'",
")",
";",
"var",
"params... | Here, we do some crude URL analysis to allow deep-linking. We only support registration deep-links in this example. | [
"Here",
"we",
"do",
"some",
"crude",
"URL",
"analysis",
"to",
"allow",
"deep",
"-",
"linking",
".",
"We",
"only",
"support",
"registration",
"deep",
"-",
"links",
"in",
"this",
"example",
"."
] | a5b7a790f332d74d74f52b2cbaa1fd68559aae4d | https://github.com/matrix-org/matrix-react-skin/blob/a5b7a790f332d74d74f52b2cbaa1fd68559aae4d/src/app/index.js#L27-L41 | train |
GrosSacASac/DOM99 | documentation/presentation/reveal.js-2.6.2/plugin/markdown/markdown.js | processSlides | function processSlides() {
var sections = document.querySelectorAll( '[data-markdown]'),
section;
for( var i = 0, len = sections.length; i < len; i++ ) {
section = sections[i];
if( section.getAttribute( 'data-markdown' ).length ) {
var xhr = new XMLHttpRequest(),
url = section.getAttribute( '... | javascript | function processSlides() {
var sections = document.querySelectorAll( '[data-markdown]'),
section;
for( var i = 0, len = sections.length; i < len; i++ ) {
section = sections[i];
if( section.getAttribute( 'data-markdown' ).length ) {
var xhr = new XMLHttpRequest(),
url = section.getAttribute( '... | [
"function",
"processSlides",
"(",
")",
"{",
"var",
"sections",
"=",
"document",
".",
"querySelectorAll",
"(",
"'[data-markdown]'",
")",
",",
"section",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"sections",
".",
"length",
";",
"i",
"<",
"l... | Parses any current data-markdown slides, splits
multi-slide markdown into separate sections and
handles loading of external markdown. | [
"Parses",
"any",
"current",
"data",
"-",
"markdown",
"slides",
"splits",
"multi",
"-",
"slide",
"markdown",
"into",
"separate",
"sections",
"and",
"handles",
"loading",
"of",
"external",
"markdown",
"."
] | 0563cb3d4865d968e829d39c68dc62af3fc95cc8 | https://github.com/GrosSacASac/DOM99/blob/0563cb3d4865d968e829d39c68dc62af3fc95cc8/documentation/presentation/reveal.js-2.6.2/plugin/markdown/markdown.js#L199-L269 | train |
rlmv/gitbook-plugin-anchors | index.js | insertAnchors | function insertAnchors(content) {
var $ = cheerio.load(content);
$(':header').each(function(i, elem) {
var header = $(elem);
var id = header.attr("id");
if (!id) {
id = slug(header.text());
header.attr("id", id);
}
header.prepend('<a name="' + id +... | javascript | function insertAnchors(content) {
var $ = cheerio.load(content);
$(':header').each(function(i, elem) {
var header = $(elem);
var id = header.attr("id");
if (!id) {
id = slug(header.text());
header.attr("id", id);
}
header.prepend('<a name="' + id +... | [
"function",
"insertAnchors",
"(",
"content",
")",
"{",
"var",
"$",
"=",
"cheerio",
".",
"load",
"(",
"content",
")",
";",
"$",
"(",
"':header'",
")",
".",
"each",
"(",
"function",
"(",
"i",
",",
"elem",
")",
"{",
"var",
"header",
"=",
"$",
"(",
"... | insert anchor link into section | [
"insert",
"anchor",
"link",
"into",
"section"
] | ba139e94705b71d7c752015e6e7407aaaf07528f | https://github.com/rlmv/gitbook-plugin-anchors/blob/ba139e94705b71d7c752015e6e7407aaaf07528f/index.js#L5-L20 | train |
lil5/simple-cryptor-pouch | src/index.js | simplecryptor | function simplecryptor (password, options = {}) {
const db = this
// set default ignore
options.ignore = ['_id', '_rev', '_deleted'].concat(options.ignore)
const simpleCryptoJS = new SimpleCryptoJS(password)
// https://github.com/pouchdb-community/transform-pouch#example-encryption
db.transform({
inc... | javascript | function simplecryptor (password, options = {}) {
const db = this
// set default ignore
options.ignore = ['_id', '_rev', '_deleted'].concat(options.ignore)
const simpleCryptoJS = new SimpleCryptoJS(password)
// https://github.com/pouchdb-community/transform-pouch#example-encryption
db.transform({
inc... | [
"function",
"simplecryptor",
"(",
"password",
",",
"options",
"=",
"{",
"}",
")",
"{",
"const",
"db",
"=",
"this",
"// set default ignore",
"options",
".",
"ignore",
"=",
"[",
"'_id'",
",",
"'_rev'",
",",
"'_deleted'",
"]",
".",
"concat",
"(",
"options",
... | pouch function to encrypt and decrypt
@param {string} password
@param {Object} [options={}]
@return {Object | Promise} | [
"pouch",
"function",
"to",
"encrypt",
"and",
"decrypt"
] | 15179a510cc707c3402472716ef029d3255b12ee | https://github.com/lil5/simple-cryptor-pouch/blob/15179a510cc707c3402472716ef029d3255b12ee/src/index.js#L12-L29 | train |
nickyout/fast-stable-stringify | cli/files-to-comparison-results.js | mergeToMap | function mergeToMap(arrFileObj) {
return arrFileObj.reduce(function(result, fileObj) {
var name;
var libData;
for (name in fileObj) {
libData = fileObj[name];
obj.setObject(result, [libData.suite, libData.browser, libData.name], libData);
}
return result;
}, {});
} | javascript | function mergeToMap(arrFileObj) {
return arrFileObj.reduce(function(result, fileObj) {
var name;
var libData;
for (name in fileObj) {
libData = fileObj[name];
obj.setObject(result, [libData.suite, libData.browser, libData.name], libData);
}
return result;
}, {});
} | [
"function",
"mergeToMap",
"(",
"arrFileObj",
")",
"{",
"return",
"arrFileObj",
".",
"reduce",
"(",
"function",
"(",
"result",
",",
"fileObj",
")",
"{",
"var",
"name",
";",
"var",
"libData",
";",
"for",
"(",
"name",
"in",
"fileObj",
")",
"{",
"libData",
... | Converts the file contents generated by BenchmarkStatsProcessor to a DataSetComparisonResult array.
@param {Array} arrFileObj
@returns {Object} | [
"Converts",
"the",
"file",
"contents",
"generated",
"by",
"BenchmarkStatsProcessor",
"to",
"a",
"DataSetComparisonResult",
"array",
"."
] | 53460c31e7b4b0cccb7c7ddacc89bf42ccd5eb0c | https://github.com/nickyout/fast-stable-stringify/blob/53460c31e7b4b0cccb7c7ddacc89bf42ccd5eb0c/cli/files-to-comparison-results.js#L9-L19 | train |
svagi/redux-routines | lib/index.js | createActionType | function createActionType(prefix, stage, separator) {
if (typeof prefix !== 'string' || typeof stage !== 'string') {
throw new Error('Invalid routine prefix or stage. It should be string.');
}
return '' + prefix + separator + stage;
} | javascript | function createActionType(prefix, stage, separator) {
if (typeof prefix !== 'string' || typeof stage !== 'string') {
throw new Error('Invalid routine prefix or stage. It should be string.');
}
return '' + prefix + separator + stage;
} | [
"function",
"createActionType",
"(",
"prefix",
",",
"stage",
",",
"separator",
")",
"{",
"if",
"(",
"typeof",
"prefix",
"!==",
"'string'",
"||",
"typeof",
"stage",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Invalid routine prefix or stage. It s... | Routine action type factory | [
"Routine",
"action",
"type",
"factory"
] | d9585eab26c15c032a5ca9a759eea35782cc3436 | https://github.com/svagi/redux-routines/blob/d9585eab26c15c032a5ca9a759eea35782cc3436/lib/index.js#L21-L26 | train |
nickyout/fast-stable-stringify | cli/format-table.js | toFixedWidth | function toFixedWidth(value, maxChars) {
var result = value.toFixed(2).substr(0, maxChars);
if (result[result.length - 1] == '.') {
result = result.substr(0, result.length - 2) + ' ';
}
return result;
} | javascript | function toFixedWidth(value, maxChars) {
var result = value.toFixed(2).substr(0, maxChars);
if (result[result.length - 1] == '.') {
result = result.substr(0, result.length - 2) + ' ';
}
return result;
} | [
"function",
"toFixedWidth",
"(",
"value",
",",
"maxChars",
")",
"{",
"var",
"result",
"=",
"value",
".",
"toFixed",
"(",
"2",
")",
".",
"substr",
"(",
"0",
",",
"maxChars",
")",
";",
"if",
"(",
"result",
"[",
"result",
".",
"length",
"-",
"1",
"]",... | Crude, but should be enough internally | [
"Crude",
"but",
"should",
"be",
"enough",
"internally"
] | 53460c31e7b4b0cccb7c7ddacc89bf42ccd5eb0c | https://github.com/nickyout/fast-stable-stringify/blob/53460c31e7b4b0cccb7c7ddacc89bf42ccd5eb0c/cli/format-table.js#L4-L10 | train |
JamesMGreene/qunit-assert-html | src/qunit-assert-html.js | _getPushContext | function _getPushContext(context) {
var pushContext;
if (context && typeof context.push === "function") {
// `context` is an `Assert` context
pushContext = context;
}
else if (context && context.assert && typeof context.assert.push === "function") {
// `context` is a `Te... | javascript | function _getPushContext(context) {
var pushContext;
if (context && typeof context.push === "function") {
// `context` is an `Assert` context
pushContext = context;
}
else if (context && context.assert && typeof context.assert.push === "function") {
// `context` is a `Te... | [
"function",
"_getPushContext",
"(",
"context",
")",
"{",
"var",
"pushContext",
";",
"if",
"(",
"context",
"&&",
"typeof",
"context",
".",
"push",
"===",
"\"function\"",
")",
"{",
"// `context` is an `Assert` context",
"pushContext",
"=",
"context",
";",
"}",
"el... | Find an appropriate `Assert` context to `push` results to.
@param * context - An unknown context, possibly `Assert`, `Test`, or neither
@private | [
"Find",
"an",
"appropriate",
"Assert",
"context",
"to",
"push",
"results",
"to",
"."
] | 670b20e64b68465934d0bfedf5fbf952b45c3b5e | https://github.com/JamesMGreene/qunit-assert-html/blob/670b20e64b68465934d0bfedf5fbf952b45c3b5e/src/qunit-assert-html.js#L36-L62 | train |
yvele/poosh | packages/poosh-core/src/pipeline/appendContentBuffer.js | shouldSkip | function shouldSkip(file, rough) {
// Basically, if rough, any small change should still process the content
return rough
? file.cache.status === LocalStatus.Unchanged
: file.content.status === LocalStatus.Unchanged;
} | javascript | function shouldSkip(file, rough) {
// Basically, if rough, any small change should still process the content
return rough
? file.cache.status === LocalStatus.Unchanged
: file.content.status === LocalStatus.Unchanged;
} | [
"function",
"shouldSkip",
"(",
"file",
",",
"rough",
")",
"{",
"// Basically, if rough, any small change should still process the content",
"return",
"rough",
"?",
"file",
".",
"cache",
".",
"status",
"===",
"LocalStatus",
".",
"Unchanged",
":",
"file",
".",
"content"... | When content status is labeled as unchanged, buffer doesn't need to be processed. | [
"When",
"content",
"status",
"is",
"labeled",
"as",
"unchanged",
"buffer",
"doesn",
"t",
"need",
"to",
"be",
"processed",
"."
] | 1b8a84d2bc38d92711405004270c0dcc84e4dbf0 | https://github.com/yvele/poosh/blob/1b8a84d2bc38d92711405004270c0dcc84e4dbf0/packages/poosh-core/src/pipeline/appendContentBuffer.js#L8-L13 | 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.