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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
alphagov/openregister-picker-engine | src/index.js | presentResults | function presentResults (graph, reverseMap, rawResults, query) {
var nodesWithLocales = rawResults.map(r => reverseMap[r])
var canonicalNodesWithPaths = nodesWithLocales.reduce((canonicalNodes, nwl) => {
return canonicalNodes.concat(findCanonicalNodeWithPath(graph, nwl.node, nwl.locale, []))
}, [])
const ... | javascript | function presentResults (graph, reverseMap, rawResults, query) {
var nodesWithLocales = rawResults.map(r => reverseMap[r])
var canonicalNodesWithPaths = nodesWithLocales.reduce((canonicalNodes, nwl) => {
return canonicalNodes.concat(findCanonicalNodeWithPath(graph, nwl.node, nwl.locale, []))
}, [])
const ... | [
"function",
"presentResults",
"(",
"graph",
",",
"reverseMap",
",",
"rawResults",
",",
"query",
")",
"{",
"var",
"nodesWithLocales",
"=",
"rawResults",
".",
"map",
"(",
"r",
"=>",
"reverseMap",
"[",
"r",
"]",
")",
"var",
"canonicalNodesWithPaths",
"=",
"node... | Engine gives us back a list of results that includes synonyms, typos, endonyms and other things we don't want the user to see. This function transforms those into a list of stable canonical country names. | [
"Engine",
"gives",
"us",
"back",
"a",
"list",
"of",
"results",
"that",
"includes",
"synonyms",
"typos",
"endonyms",
"and",
"other",
"things",
"we",
"don",
"t",
"want",
"the",
"user",
"to",
"see",
".",
"This",
"function",
"transforms",
"those",
"into",
"a",... | fed0cc61aab3e8c174fe65ea84ca12674e5cd520 | https://github.com/alphagov/openregister-picker-engine/blob/fed0cc61aab3e8c174fe65ea84ca12674e5cd520/src/index.js#L177-L213 | train |
mhart/dynamo-table | index.js | checkTable | function checkTable(count) {
// Make sure we don't go into an infinite loop
if (++count > 1000) return cb(new Error('Wait limit exceeded'))
self.describeTable(function(err, data) {
if (err) return cb(err)
if (data.TableStatus !== 'ACTIVE' || (data.GlobalSecondaryIndexes &&
... | javascript | function checkTable(count) {
// Make sure we don't go into an infinite loop
if (++count > 1000) return cb(new Error('Wait limit exceeded'))
self.describeTable(function(err, data) {
if (err) return cb(err)
if (data.TableStatus !== 'ACTIVE' || (data.GlobalSecondaryIndexes &&
... | [
"function",
"checkTable",
"(",
"count",
")",
"{",
"// Make sure we don't go into an infinite loop",
"if",
"(",
"++",
"count",
">",
"1000",
")",
"return",
"cb",
"(",
"new",
"Error",
"(",
"'Wait limit exceeded'",
")",
")",
"self",
".",
"describeTable",
"(",
"funct... | check whether the update has in fact been applied | [
"check",
"whether",
"the",
"update",
"has",
"in",
"fact",
"been",
"applied"
] | b5c3ef80db8d90fa92c233ae9811e6751469cfc6 | https://github.com/mhart/dynamo-table/blob/b5c3ef80db8d90fa92c233ae9811e6751469cfc6/index.js#L673-L687 | train |
nfroidure/streamfilter | src/index.js | createReadStreamBackpressureManager | function createReadStreamBackpressureManager(readableStream) {
const manager = {
waitPush: true,
programmedPushs: [],
programPush: function programPush(chunk, encoding, done) {
// Store the current write
manager.programmedPushs.push([chunk, encoding, done]);
// Need to be async to avoid ... | javascript | function createReadStreamBackpressureManager(readableStream) {
const manager = {
waitPush: true,
programmedPushs: [],
programPush: function programPush(chunk, encoding, done) {
// Store the current write
manager.programmedPushs.push([chunk, encoding, done]);
// Need to be async to avoid ... | [
"function",
"createReadStreamBackpressureManager",
"(",
"readableStream",
")",
"{",
"const",
"manager",
"=",
"{",
"waitPush",
":",
"true",
",",
"programmedPushs",
":",
"[",
"]",
",",
"programPush",
":",
"function",
"programPush",
"(",
"chunk",
",",
"encoding",
"... | Utils to manage readable stream backpressure | [
"Utils",
"to",
"manage",
"readable",
"stream",
"backpressure"
] | 373da8fa746a054f501ab34bb9feba74da226a84 | https://github.com/nfroidure/streamfilter/blob/373da8fa746a054f501ab34bb9feba74da226a84/src/index.js#L112-L152 | train |
damirkusar/generator-leptir-angular-material | generators/app/templates/public/modules/core/js/services/menus.service.js | function (menuId, menuItemId, menuItemTitle, menuItemUiState, menuItemType, position) {
this.validateMenuExistance(menuId);
// Push new menu item
menus[menuId].items.push({
id: menuItemId,
title: menuItemTitle,
uiState: menuItemUiState... | javascript | function (menuId, menuItemId, menuItemTitle, menuItemUiState, menuItemType, position) {
this.validateMenuExistance(menuId);
// Push new menu item
menus[menuId].items.push({
id: menuItemId,
title: menuItemTitle,
uiState: menuItemUiState... | [
"function",
"(",
"menuId",
",",
"menuItemId",
",",
"menuItemTitle",
",",
"menuItemUiState",
",",
"menuItemType",
",",
"position",
")",
"{",
"this",
".",
"validateMenuExistance",
"(",
"menuId",
")",
";",
"// Push new menu item",
"menus",
"[",
"menuId",
"]",
".",
... | Add menu item object | [
"Add",
"menu",
"item",
"object"
] | ef5e0a2c8bbad386687e7a609d17587e075fc43b | https://github.com/damirkusar/generator-leptir-angular-material/blob/ef5e0a2c8bbad386687e7a609d17587e075fc43b/generators/app/templates/public/modules/core/js/services/menus.service.js#L43-L58 | train | |
NiklasGollenstede/web-ext-utils | utils/notify.js | notify | async function notify({ title, message, icon = 'default', timeout, }) { try {
if (!Notifications) { console.info('notify', arguments[0]); return false; }
const create = !open; open = true; const options = {
type: 'basic', title, message,
iconUrl: (/^\w+$/).test(icon) ? (await getIcon(icon)) : icon,
}; !isGecko &... | javascript | async function notify({ title, message, icon = 'default', timeout, }) { try {
if (!Notifications) { console.info('notify', arguments[0]); return false; }
const create = !open; open = true; const options = {
type: 'basic', title, message,
iconUrl: (/^\w+$/).test(icon) ? (await getIcon(icon)) : icon,
}; !isGecko &... | [
"async",
"function",
"notify",
"(",
"{",
"title",
",",
"message",
",",
"icon",
"=",
"'default'",
",",
"timeout",
",",
"}",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"Notifications",
")",
"{",
"console",
".",
"info",
"(",
"'notify'",
",",
"arguments",
"["... | Displays a basic notification to the user.
@param {string} .title Notification title.
@param {string} .message Notification body text.
@param {string} .icon Notification icon URL or one of [ 'default', 'info', 'warn', 'error', 'success', ]
to choose and/or generate an icon automatically.
@param {natur... | [
"Displays",
"a",
"basic",
"notification",
"to",
"the",
"user",
"."
] | 395698c633da88db86377d583b9b4eac6d9cc299 | https://github.com/NiklasGollenstede/web-ext-utils/blob/395698c633da88db86377d583b9b4eac6d9cc299/utils/notify.js#L15-L29 | train |
peerigon/batch-replace | lib/replace.js | runModules | function runModules(str, modules) {
var replacements = [],
module;
if (Array.isArray(modules) === false) {
modules = [modules];
}
modules.forEach(function forEachModule(module) {
if (!module) {
throw new Error("Unknown module '" + module + "'");
}
r... | javascript | function runModules(str, modules) {
var replacements = [],
module;
if (Array.isArray(modules) === false) {
modules = [modules];
}
modules.forEach(function forEachModule(module) {
if (!module) {
throw new Error("Unknown module '" + module + "'");
}
r... | [
"function",
"runModules",
"(",
"str",
",",
"modules",
")",
"{",
"var",
"replacements",
"=",
"[",
"]",
",",
"module",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",
"modules",
")",
"===",
"false",
")",
"{",
"modules",
"=",
"[",
"modules",
"]",
";",
"... | Runs the given modules on the text and returns the insertions.
@private
@param {String} str
@param {Array<String|ReplacementModule>} modules
@returns {Array<Array>} | [
"Runs",
"the",
"given",
"modules",
"on",
"the",
"text",
"and",
"returns",
"the",
"insertions",
"."
] | 218feaba2c618386e101b1c659240fcd9f42329a | https://github.com/peerigon/batch-replace/blob/218feaba2c618386e101b1c659240fcd9f42329a/lib/replace.js#L167-L184 | train |
peerigon/batch-replace | lib/replace.js | runModule | function runModule(module, str, replacements) {
var pattern = module.pattern,
replace = module.replace,
match;
// Reset the pattern so we can re-use it
pattern.lastIndex = 0;
while ((match = pattern.exec(str)) !== null) {
replacements[match.index] = {
oldStr: match[... | javascript | function runModule(module, str, replacements) {
var pattern = module.pattern,
replace = module.replace,
match;
// Reset the pattern so we can re-use it
pattern.lastIndex = 0;
while ((match = pattern.exec(str)) !== null) {
replacements[match.index] = {
oldStr: match[... | [
"function",
"runModule",
"(",
"module",
",",
"str",
",",
"replacements",
")",
"{",
"var",
"pattern",
"=",
"module",
".",
"pattern",
",",
"replace",
"=",
"module",
".",
"replace",
",",
"match",
";",
"// Reset the pattern so we can re-use it",
"pattern",
".",
"l... | Matches the module's pattern against the string and stores the scheduled replacement
under the corresponding array index.
@private
@param {ReplacementModule} module
@param {String} str
@param {Array<Replacement>} replacements | [
"Matches",
"the",
"module",
"s",
"pattern",
"against",
"the",
"string",
"and",
"stores",
"the",
"scheduled",
"replacement",
"under",
"the",
"corresponding",
"array",
"index",
"."
] | 218feaba2c618386e101b1c659240fcd9f42329a | https://github.com/peerigon/batch-replace/blob/218feaba2c618386e101b1c659240fcd9f42329a/lib/replace.js#L195-L214 | train |
peerigon/batch-replace | lib/replace.js | applyReplacements | function applyReplacements(str, replacements) {
var result = "",
replacement,
i;
for (i = 0; i < replacements.length; i++) {
replacement = replacements[i];
if (replacement) {
result += replacement.newStr;
i += replacement.oldStr.length - 1;
} else... | javascript | function applyReplacements(str, replacements) {
var result = "",
replacement,
i;
for (i = 0; i < replacements.length; i++) {
replacement = replacements[i];
if (replacement) {
result += replacement.newStr;
i += replacement.oldStr.length - 1;
} else... | [
"function",
"applyReplacements",
"(",
"str",
",",
"replacements",
")",
"{",
"var",
"result",
"=",
"\"\"",
",",
"replacement",
",",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"replacements",
".",
"length",
";",
"i",
"++",
")",
"{",
"replaceme... | Applies all replacements on the given string.
@private
@param {String} str
@param {Array<Replacement>} replacements
@returns {string} | [
"Applies",
"all",
"replacements",
"on",
"the",
"given",
"string",
"."
] | 218feaba2c618386e101b1c659240fcd9f42329a | https://github.com/peerigon/batch-replace/blob/218feaba2c618386e101b1c659240fcd9f42329a/lib/replace.js#L224-L242 | train |
doowb/paginationator | lib/pages.js | decorate | function decorate(pages, page) {
Object.defineProperties(page, {
first: {
enumerable: true,
set: function() {},
get: function() {
return pages.first && pages.first.current;
}
},
current: {
enumerable: true,
set: function() {},
get: function() {
re... | javascript | function decorate(pages, page) {
Object.defineProperties(page, {
first: {
enumerable: true,
set: function() {},
get: function() {
return pages.first && pages.first.current;
}
},
current: {
enumerable: true,
set: function() {},
get: function() {
re... | [
"function",
"decorate",
"(",
"pages",
",",
"page",
")",
"{",
"Object",
".",
"defineProperties",
"(",
"page",
",",
"{",
"first",
":",
"{",
"enumerable",
":",
"true",
",",
"set",
":",
"function",
"(",
")",
"{",
"}",
",",
"get",
":",
"function",
"(",
... | Decorates a page with additional properties.
@param {Object} `page` Instance of page to decorate
@return {Object} Returns the decorated page to be added to the list | [
"Decorates",
"a",
"page",
"with",
"additional",
"properties",
"."
] | e8c1f1d7ea0a39a2f23e6838a9a73a05c30c7b16 | https://github.com/doowb/paginationator/blob/e8c1f1d7ea0a39a2f23e6838a9a73a05c30c7b16/lib/pages.js#L69-L112 | train |
creationix/bodec | bodec-browser.js | toHex | function toHex(binary, start, end) {
var hex = "";
if (end === undefined) {
end = binary.length;
if (start === undefined) start = 0;
}
for (var i = start; i < end; i++) {
var byte = binary[i];
hex += String.fromCharCode(nibbleToCode(byte >> 4)) +
String.fromCharCode(nibbleToCode(byte ... | javascript | function toHex(binary, start, end) {
var hex = "";
if (end === undefined) {
end = binary.length;
if (start === undefined) start = 0;
}
for (var i = start; i < end; i++) {
var byte = binary[i];
hex += String.fromCharCode(nibbleToCode(byte >> 4)) +
String.fromCharCode(nibbleToCode(byte ... | [
"function",
"toHex",
"(",
"binary",
",",
"start",
",",
"end",
")",
"{",
"var",
"hex",
"=",
"\"\"",
";",
"if",
"(",
"end",
"===",
"undefined",
")",
"{",
"end",
"=",
"binary",
".",
"length",
";",
"if",
"(",
"start",
"===",
"undefined",
")",
"start",
... | Like slice, but encode as a hex string | [
"Like",
"slice",
"but",
"encode",
"as",
"a",
"hex",
"string"
] | 19f94a638f1ab3454b759ff4baf61ee09e8b3ae5 | https://github.com/creationix/bodec/blob/19f94a638f1ab3454b759ff4baf61ee09e8b3ae5/bodec-browser.js#L94-L106 | train |
chrahunt/tagpro-navmesh | src/pathfinder.js | nodeValue | function nodeValue(node1, node2) {
return (node1.dist + heuristic(node1.point)) - (node2.dist + heuristic(node2.point));
} | javascript | function nodeValue(node1, node2) {
return (node1.dist + heuristic(node1.point)) - (node2.dist + heuristic(node2.point));
} | [
"function",
"nodeValue",
"(",
"node1",
",",
"node2",
")",
"{",
"return",
"(",
"node1",
".",
"dist",
"+",
"heuristic",
"(",
"node1",
".",
"point",
")",
")",
"-",
"(",
"node2",
".",
"dist",
"+",
"heuristic",
"(",
"node2",
".",
"point",
")",
")",
";",... | Compares the value of two nodes. | [
"Compares",
"the",
"value",
"of",
"two",
"nodes",
"."
] | b50fbdad1061fb4760ac22ee756f34ab3e177539 | https://github.com/chrahunt/tagpro-navmesh/blob/b50fbdad1061fb4760ac22ee756f34ab3e177539/src/pathfinder.js#L35-L37 | train |
Levino/coindesk-api-node | index.js | function (currency, callback) {
// Call an asynchronous function, often a save() to DB
self.getPricesForSingleCurrency(from, to, currency, function (err, result) {
if (err) {
callback(err)
} else {
ratesWithTimes[currency] = result
callback()
}
})
... | javascript | function (currency, callback) {
// Call an asynchronous function, often a save() to DB
self.getPricesForSingleCurrency(from, to, currency, function (err, result) {
if (err) {
callback(err)
} else {
ratesWithTimes[currency] = result
callback()
}
})
... | [
"function",
"(",
"currency",
",",
"callback",
")",
"{",
"// Call an asynchronous function, often a save() to DB",
"self",
".",
"getPricesForSingleCurrency",
"(",
"from",
",",
"to",
",",
"currency",
",",
"function",
"(",
"err",
",",
"result",
")",
"{",
"if",
"(",
... | 2nd param is the function that each item is passed to | [
"2nd",
"param",
"is",
"the",
"function",
"that",
"each",
"item",
"is",
"passed",
"to"
] | a477ac65e76fbcf31644055758cdb60d45fea04a | https://github.com/Levino/coindesk-api-node/blob/a477ac65e76fbcf31644055758cdb60d45fea04a/index.js#L69-L79 | train | |
Levino/coindesk-api-node | index.js | function (err) {
if (err) {
callback(err, null)
}
_.each(ratesWithTimes, function (rates, currency) {
rates.forEach(function (timeratepair) {
var newEntry = {}
newEntry[currency] = timeratepair.rate
if (allRates[timeratepair.time]) {
allRates[t... | javascript | function (err) {
if (err) {
callback(err, null)
}
_.each(ratesWithTimes, function (rates, currency) {
rates.forEach(function (timeratepair) {
var newEntry = {}
newEntry[currency] = timeratepair.rate
if (allRates[timeratepair.time]) {
allRates[t... | [
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
",",
"null",
")",
"}",
"_",
".",
"each",
"(",
"ratesWithTimes",
",",
"function",
"(",
"rates",
",",
"currency",
")",
"{",
"rates",
".",
"forEach",
"(",
"function"... | 3rd param is the function to call when everything's done | [
"3rd",
"param",
"is",
"the",
"function",
"to",
"call",
"when",
"everything",
"s",
"done"
] | a477ac65e76fbcf31644055758cdb60d45fea04a | https://github.com/Levino/coindesk-api-node/blob/a477ac65e76fbcf31644055758cdb60d45fea04a/index.js#L81-L107 | train | |
axetroy/redux-zero-logger | index.js | logger | function logger(config = {}) {
// return an middleware
return store => next => action => {
const prevState = store.getState();
const r = next(action);
function prinf(prev, action, next) {
console.group(action, "@" + new Date().toISOString());
console.log("%cprev state", "color:#9E9E9E", pre... | javascript | function logger(config = {}) {
// return an middleware
return store => next => action => {
const prevState = store.getState();
const r = next(action);
function prinf(prev, action, next) {
console.group(action, "@" + new Date().toISOString());
console.log("%cprev state", "color:#9E9E9E", pre... | [
"function",
"logger",
"(",
"config",
"=",
"{",
"}",
")",
"{",
"// return an middleware",
"return",
"store",
"=>",
"next",
"=>",
"action",
"=>",
"{",
"const",
"prevState",
"=",
"store",
".",
"getState",
"(",
")",
";",
"const",
"r",
"=",
"next",
"(",
"ac... | The logger middleware for redux-zero
@param config
@returns {function(*): function(*): function(*=)} | [
"The",
"logger",
"middleware",
"for",
"redux",
"-",
"zero"
] | 6f97f15b9e6af9663c137a9002e0bde3dead7453 | https://github.com/axetroy/redux-zero-logger/blob/6f97f15b9e6af9663c137a9002e0bde3dead7453/index.js#L6-L30 | train |
winkerVSbecks/draper | src/build.js | toRems | function toRems(rem, type) {
return R.compose(
R.objOf(type),
R.map(R.multiply(rem)),
R.prop(type)
);
} | javascript | function toRems(rem, type) {
return R.compose(
R.objOf(type),
R.map(R.multiply(rem)),
R.prop(type)
);
} | [
"function",
"toRems",
"(",
"rem",
",",
"type",
")",
"{",
"return",
"R",
".",
"compose",
"(",
"R",
".",
"objOf",
"(",
"type",
")",
",",
"R",
".",
"map",
"(",
"R",
".",
"multiply",
"(",
"rem",
")",
")",
",",
"R",
".",
"prop",
"(",
"type",
")",
... | Converts a scale to rems | [
"Converts",
"a",
"scale",
"to",
"rems"
] | 1648dce7c2252a8beea9e8a7faecc7b4129f2244 | https://github.com/winkerVSbecks/draper/blob/1648dce7c2252a8beea9e8a7faecc7b4129f2244/src/build.js#L51-L57 | train |
NiklasGollenstede/web-ext-utils | options/editor/index.js | sanitize | function sanitize(html) {
const parts = (html ? html +'' : '').split(rTag);
return parts.map((s, i) => i % 2 ? s : s.replace(rEsc, c => oEsc[c])).join('');
} | javascript | function sanitize(html) {
const parts = (html ? html +'' : '').split(rTag);
return parts.map((s, i) => i % 2 ? s : s.replace(rEsc, c => oEsc[c])).join('');
} | [
"function",
"sanitize",
"(",
"html",
")",
"{",
"const",
"parts",
"=",
"(",
"html",
"?",
"html",
"+",
"''",
":",
"''",
")",
".",
"split",
"(",
"rTag",
")",
";",
"return",
"parts",
".",
"map",
"(",
"(",
"s",
",",
"i",
")",
"=>",
"i",
"%",
"2",
... | Sanitizes untrusted HTML by escaping everything that is not recognized as a whitelisted tag or entity.
@param {string} html Untrusted HTML input.
@return {string} Sanitized HTML that won't contain any tags but those whitelisted by `rTag` below.
@author Niklas Gollenstede
@license MIT | [
"Sanitizes",
"untrusted",
"HTML",
"by",
"escaping",
"everything",
"that",
"is",
"not",
"recognized",
"as",
"a",
"whitelisted",
"tag",
"or",
"entity",
"."
] | 395698c633da88db86377d583b9b4eac6d9cc299 | https://github.com/NiklasGollenstede/web-ext-utils/blob/395698c633da88db86377d583b9b4eac6d9cc299/options/editor/index.js#L329-L332 | train |
chrahunt/tagpro-navmesh | src/parse-map.js | generateContourGrid | function generateContourGrid(arr) {
// Generate grid for holding values.
var contour_grid = new Array(arr.length - 1);
for (var n = 0; n < contour_grid.length; n++) {
contour_grid[n] = new Array(arr[0].length - 1);
}
var corners = [1.1, 1.2, 1.3, 1.4];
// Specifies the resulting values for the above cor... | javascript | function generateContourGrid(arr) {
// Generate grid for holding values.
var contour_grid = new Array(arr.length - 1);
for (var n = 0; n < contour_grid.length; n++) {
contour_grid[n] = new Array(arr[0].length - 1);
}
var corners = [1.1, 1.2, 1.3, 1.4];
// Specifies the resulting values for the above cor... | [
"function",
"generateContourGrid",
"(",
"arr",
")",
"{",
"// Generate grid for holding values.",
"var",
"contour_grid",
"=",
"new",
"Array",
"(",
"arr",
".",
"length",
"-",
"1",
")",
";",
"for",
"(",
"var",
"n",
"=",
"0",
";",
"n",
"<",
"contour_grid",
"."... | Converts the provided array into its equivalent representation
using cells.
@private
@param {MapTiles} arr -
@param {Array.<Array.<Cell>>} - The converted array. | [
"Converts",
"the",
"provided",
"array",
"into",
"its",
"equivalent",
"representation",
"using",
"cells",
"."
] | b50fbdad1061fb4760ac22ee756f34ab3e177539 | https://github.com/chrahunt/tagpro-navmesh/blob/b50fbdad1061fb4760ac22ee756f34ab3e177539/src/parse-map.js#L127-L157 | train |
chrahunt/tagpro-navmesh | src/parse-map.js | find | function find(arr, obj, cmp) {
if (typeof cmp !== 'undefined') {
for (var i = 0; i < arr.length; i++) {
if (cmp(arr[i], obj)) {
return i;
}
}
return -1;
}
} | javascript | function find(arr, obj, cmp) {
if (typeof cmp !== 'undefined') {
for (var i = 0; i < arr.length; i++) {
if (cmp(arr[i], obj)) {
return i;
}
}
return -1;
}
} | [
"function",
"find",
"(",
"arr",
",",
"obj",
",",
"cmp",
")",
"{",
"if",
"(",
"typeof",
"cmp",
"!==",
"'undefined'",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"arr",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"cmp",
... | Callback function for testing equality of items.
@private
@callback comparisonCallback
@param {*} - The first item.
@param {*} - The second item.
@return {boolean} - Whether or not the items are equal.
Returns the location of obj in arr with equality determined by cmp.
@private
@param {Array.<*>} arr - The array to b... | [
"Callback",
"function",
"for",
"testing",
"equality",
"of",
"items",
"."
] | b50fbdad1061fb4760ac22ee756f34ab3e177539 | https://github.com/chrahunt/tagpro-navmesh/blob/b50fbdad1061fb4760ac22ee756f34ab3e177539/src/parse-map.js#L178-L187 | train |
chrahunt/tagpro-navmesh | src/parse-map.js | nextNeighbor | function nextNeighbor(elt, dir) {
var drow = 0, dcol = 0;
if (dir == "none") {
return null;
} else {
var offset = directions[dir];
return {r: elt.r + offset[0], c: elt.c + offset[1]};
}
} | javascript | function nextNeighbor(elt, dir) {
var drow = 0, dcol = 0;
if (dir == "none") {
return null;
} else {
var offset = directions[dir];
return {r: elt.r + offset[0], c: elt.c + offset[1]};
}
} | [
"function",
"nextNeighbor",
"(",
"elt",
",",
"dir",
")",
"{",
"var",
"drow",
"=",
"0",
",",
"dcol",
"=",
"0",
";",
"if",
"(",
"dir",
"==",
"\"none\"",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"var",
"offset",
"=",
"directions",
"[",
"di... | Takes the current location and direction at this point and returns the next location to check. Returns null if this cell is not part of a shape. | [
"Takes",
"the",
"current",
"location",
"and",
"direction",
"at",
"this",
"point",
"and",
"returns",
"the",
"next",
"location",
"to",
"check",
".",
"Returns",
"null",
"if",
"this",
"cell",
"is",
"not",
"part",
"of",
"a",
"shape",
"."
] | b50fbdad1061fb4760ac22ee756f34ab3e177539 | https://github.com/chrahunt/tagpro-navmesh/blob/b50fbdad1061fb4760ac22ee756f34ab3e177539/src/parse-map.js#L226-L234 | train |
chrahunt/tagpro-navmesh | src/parse-map.js | nextCell | function nextCell(elt) {
if (elt.c + 1 < actionInfo[elt.r].length) {
return {r: elt.r, c: elt.c + 1};
} else if (elt.r + 1 < actionInfo.length) {
return {r: elt.r + 1, c: 0};
}
return null;
} | javascript | function nextCell(elt) {
if (elt.c + 1 < actionInfo[elt.r].length) {
return {r: elt.r, c: elt.c + 1};
} else if (elt.r + 1 < actionInfo.length) {
return {r: elt.r + 1, c: 0};
}
return null;
} | [
"function",
"nextCell",
"(",
"elt",
")",
"{",
"if",
"(",
"elt",
".",
"c",
"+",
"1",
"<",
"actionInfo",
"[",
"elt",
".",
"r",
"]",
".",
"length",
")",
"{",
"return",
"{",
"r",
":",
"elt",
".",
"r",
",",
"c",
":",
"elt",
".",
"c",
"+",
"1",
... | Get the next cell, from left to right, top to bottom. Returns null if last element in array reached. | [
"Get",
"the",
"next",
"cell",
"from",
"left",
"to",
"right",
"top",
"to",
"bottom",
".",
"Returns",
"null",
"if",
"last",
"element",
"in",
"array",
"reached",
"."
] | b50fbdad1061fb4760ac22ee756f34ab3e177539 | https://github.com/chrahunt/tagpro-navmesh/blob/b50fbdad1061fb4760ac22ee756f34ab3e177539/src/parse-map.js#L238-L245 | train |
chrahunt/tagpro-navmesh | src/parse-map.js | getCoordinates | function getCoordinates(location) {
var tile_width = 40;
var x = location.r * tile_width;
var y = location.c * tile_width;
return {x: x, y: y};
} | javascript | function getCoordinates(location) {
var tile_width = 40;
var x = location.r * tile_width;
var y = location.c * tile_width;
return {x: x, y: y};
} | [
"function",
"getCoordinates",
"(",
"location",
")",
"{",
"var",
"tile_width",
"=",
"40",
";",
"var",
"x",
"=",
"location",
".",
"r",
"*",
"tile_width",
";",
"var",
"y",
"=",
"location",
".",
"c",
"*",
"tile_width",
";",
"return",
"{",
"x",
":",
"x",
... | Convert an array location to a point representing the top-left
corner of the tile in global coordinates.
@private
@param {ArrayLoc} location - The array location to get the
coordinates for.
@return {MPPoint} - The coordinates of the tile. | [
"Convert",
"an",
"array",
"location",
"to",
"a",
"point",
"representing",
"the",
"top",
"-",
"left",
"corner",
"of",
"the",
"tile",
"in",
"global",
"coordinates",
"."
] | b50fbdad1061fb4760ac22ee756f34ab3e177539 | https://github.com/chrahunt/tagpro-navmesh/blob/b50fbdad1061fb4760ac22ee756f34ab3e177539/src/parse-map.js#L392-L397 | train |
chrahunt/tagpro-navmesh | src/parse-map.js | convertShapesToCoords | function convertShapesToCoords(shapes) {
var tile_width = 40;
var new_shapes = map2d(shapes, function(loc) {
// It would be loc.r + 1 and loc.c + 1 but that has been removed
// to account for the one-tile width of padding added in doParse.
var row = loc.r * tile_width;
var col = loc.c * tile_width;... | javascript | function convertShapesToCoords(shapes) {
var tile_width = 40;
var new_shapes = map2d(shapes, function(loc) {
// It would be loc.r + 1 and loc.c + 1 but that has been removed
// to account for the one-tile width of padding added in doParse.
var row = loc.r * tile_width;
var col = loc.c * tile_width;... | [
"function",
"convertShapesToCoords",
"(",
"shapes",
")",
"{",
"var",
"tile_width",
"=",
"40",
";",
"var",
"new_shapes",
"=",
"map2d",
"(",
"shapes",
",",
"function",
"(",
"loc",
")",
"{",
"// It would be loc.r + 1 and loc.c + 1 but that has been removed",
"// to accou... | Takes in an array of shapes and converts from contour grid layout
to actual coordinates.
@private
@param {Array.<Array.<ArrayLoc>>} shapes - output from generateShapes
@return {Array.<Array.<{{x: number, y: number}}>>} | [
"Takes",
"in",
"an",
"array",
"of",
"shapes",
"and",
"converts",
"from",
"contour",
"grid",
"layout",
"to",
"actual",
"coordinates",
"."
] | b50fbdad1061fb4760ac22ee756f34ab3e177539 | https://github.com/chrahunt/tagpro-navmesh/blob/b50fbdad1061fb4760ac22ee756f34ab3e177539/src/parse-map.js#L406-L417 | train |
shd101wyy/lisp2js | lisp2js.js | validateName | function validateName(var_name) {
var o = "";
for (var i = 0; i < var_name.length; i++) {
var code = var_name.charCodeAt(i);
if ((code > 47 && code < 58) || // numeric (0-9)
(code > 64 && code < 91) || // upper alpha (A-Z)
(code > 96 && code < 123)... | javascript | function validateName(var_name) {
var o = "";
for (var i = 0; i < var_name.length; i++) {
var code = var_name.charCodeAt(i);
if ((code > 47 && code < 58) || // numeric (0-9)
(code > 64 && code < 91) || // upper alpha (A-Z)
(code > 96 && code < 123)... | [
"function",
"validateName",
"(",
"var_name",
")",
"{",
"var",
"o",
"=",
"\"\"",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"var_name",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"code",
"=",
"var_name",
".",
"charCodeAt",
"(",
"i"... | validate variable name. | [
"validate",
"variable",
"name",
"."
] | 6cf8bb199e565152e3d6461f94040c464ba441b4 | https://github.com/shd101wyy/lisp2js/blob/6cf8bb199e565152e3d6461f94040c464ba441b4/lisp2js.js#L603-L623 | train |
winkerVSbecks/draper | dist/absolute.js | absolute | function absolute(rem){return{abs:{position:'absolute'},
top0:{top:0},
right0:{right:0},
bottom0:{bottom:0},
left0:{left:0},
top1:{top:1*rem},
right1:{right:1*rem},
bottom1:{bottom:1*rem},
left1:{left:1*rem},
top2:{top:2*rem},
right2:{right:2*rem},
bottom2:{bottom:2*rem},
left2:{left:2*rem},
top3:{top:3*rem},
right3... | javascript | function absolute(rem){return{abs:{position:'absolute'},
top0:{top:0},
right0:{right:0},
bottom0:{bottom:0},
left0:{left:0},
top1:{top:1*rem},
right1:{right:1*rem},
bottom1:{bottom:1*rem},
left1:{left:1*rem},
top2:{top:2*rem},
right2:{right:2*rem},
bottom2:{bottom:2*rem},
left2:{left:2*rem},
top3:{top:3*rem},
right3... | [
"function",
"absolute",
"(",
"rem",
")",
"{",
"return",
"{",
"abs",
":",
"{",
"position",
":",
"'absolute'",
"}",
",",
"top0",
":",
"{",
"top",
":",
"0",
"}",
",",
"right0",
":",
"{",
"right",
":",
"0",
"}",
",",
"bottom0",
":",
"{",
"bottom",
... | Generate absolute position classes | [
"Generate",
"absolute",
"position",
"classes"
] | 1648dce7c2252a8beea9e8a7faecc7b4129f2244 | https://github.com/winkerVSbecks/draper/blob/1648dce7c2252a8beea9e8a7faecc7b4129f2244/dist/absolute.js#L6-L37 | train |
hlapp/wirelesstags-js | plugins/polling-updater.js | PollingTagUpdater | function PollingTagUpdater(platform, options) {
EventEmitter.call(this);
this.tagsByUUID = {};
this.options = Object.assign({}, options);
if (! this.options.wsdl_url) {
let apiBaseURI;
if (platform) apiBaseURI = platform.apiBaseURI;
if (options && options.apiBaseURI) apiBaseURI =... | javascript | function PollingTagUpdater(platform, options) {
EventEmitter.call(this);
this.tagsByUUID = {};
this.options = Object.assign({}, options);
if (! this.options.wsdl_url) {
let apiBaseURI;
if (platform) apiBaseURI = platform.apiBaseURI;
if (options && options.apiBaseURI) apiBaseURI =... | [
"function",
"PollingTagUpdater",
"(",
"platform",
",",
"options",
")",
"{",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"tagsByUUID",
"=",
"{",
"}",
";",
"this",
".",
"options",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"... | Creates the updater instance.
@param {WirelessTagPlatform} [platform] - Platform object through
which tags to be updated were (or are going to be)
found (or created in discovery mode). In normal mode,
this is only used to possibly override configuration
options, specifically the base URI for the cloud API
endpoints. F... | [
"Creates",
"the",
"updater",
"instance",
"."
] | ce63485ce37b33f552ceb2939740a40957a416f3 | https://github.com/hlapp/wirelesstags-js/blob/ce63485ce37b33f552ceb2939740a40957a416f3/plugins/polling-updater.js#L99-L149 | train |
hlapp/wirelesstags-js | plugins/polling-updater.js | updateTag | function updateTag(tag, tagData) {
// if not a valid object for receiving updates, we are done
if (! tag) return;
// check that this is the current tag manager
if (tagData.mac && (tag.wirelessTagManager.mac !== tagData.mac)) {
throw new Error("expected tag " + tag.uuid
+ ... | javascript | function updateTag(tag, tagData) {
// if not a valid object for receiving updates, we are done
if (! tag) return;
// check that this is the current tag manager
if (tagData.mac && (tag.wirelessTagManager.mac !== tagData.mac)) {
throw new Error("expected tag " + tag.uuid
+ ... | [
"function",
"updateTag",
"(",
"tag",
",",
"tagData",
")",
"{",
"// if not a valid object for receiving updates, we are done",
"if",
"(",
"!",
"tag",
")",
"return",
";",
"// check that this is the current tag manager",
"if",
"(",
"tagData",
".",
"mac",
"&&",
"(",
"tag"... | Updates the tag corresponding to the given tag data. Does nothing
if the respective tag is undefined or null.
@param {WirelessTag} tag - the tag object to be updated
@param {object} tagData - the data to update the tag object with;
this is normally returned from the API endpoint
@private | [
"Updates",
"the",
"tag",
"corresponding",
"to",
"the",
"given",
"tag",
"data",
".",
"Does",
"nothing",
"if",
"the",
"respective",
"tag",
"is",
"undefined",
"or",
"null",
"."
] | ce63485ce37b33f552ceb2939740a40957a416f3 | https://github.com/hlapp/wirelesstags-js/blob/ce63485ce37b33f552ceb2939740a40957a416f3/plugins/polling-updater.js#L338-L352 | train |
hlapp/wirelesstags-js | plugins/polling-updater.js | createTag | function createTag(tagData, platform, factory) {
let mgrData = {};
managerProps.forEach((k) => {
let mk = k.replace(/^manager([A-Z])/, '$1');
if (mk !== k) mk = mk.toLowerCase();
mgrData[mk] = tagData[k];
delete tagData[k];
});
if (! platform) platform = {};
if (! fac... | javascript | function createTag(tagData, platform, factory) {
let mgrData = {};
managerProps.forEach((k) => {
let mk = k.replace(/^manager([A-Z])/, '$1');
if (mk !== k) mk = mk.toLowerCase();
mgrData[mk] = tagData[k];
delete tagData[k];
});
if (! platform) platform = {};
if (! fac... | [
"function",
"createTag",
"(",
"tagData",
",",
"platform",
",",
"factory",
")",
"{",
"let",
"mgrData",
"=",
"{",
"}",
";",
"managerProps",
".",
"forEach",
"(",
"(",
"k",
")",
"=>",
"{",
"let",
"mk",
"=",
"k",
".",
"replace",
"(",
"/",
"^manager([A-Z])... | Creates a tag object from the given attribute data object, and returns it.
@param {object} tagData - the attribute data object as returned by
the polling API endpoint
@param {WirelessTagPlatform} platform - the platform instance for
creating tag and tag manager objects. If the value does
not provide a factory, `factor... | [
"Creates",
"a",
"tag",
"object",
"from",
"the",
"given",
"attribute",
"data",
"object",
"and",
"returns",
"it",
"."
] | ce63485ce37b33f552ceb2939740a40957a416f3 | https://github.com/hlapp/wirelesstags-js/blob/ce63485ce37b33f552ceb2939740a40957a416f3/plugins/polling-updater.js#L367-L386 | train |
hlapp/wirelesstags-js | plugins/polling-updater.js | createSoapClient | function createSoapClient(opts) {
let wsdl = opts && opts.wsdl_url ?
opts.wsdl_url : API_BASE_URI + WSDL_URL_PATH;
let clientOpts = { request: request.defaults({ jar: true, gzip: true }) };
return new Promise((resolve, reject) => {
soap.createClient(wsdl, clientOpts, (err, client) => {
... | javascript | function createSoapClient(opts) {
let wsdl = opts && opts.wsdl_url ?
opts.wsdl_url : API_BASE_URI + WSDL_URL_PATH;
let clientOpts = { request: request.defaults({ jar: true, gzip: true }) };
return new Promise((resolve, reject) => {
soap.createClient(wsdl, clientOpts, (err, client) => {
... | [
"function",
"createSoapClient",
"(",
"opts",
")",
"{",
"let",
"wsdl",
"=",
"opts",
"&&",
"opts",
".",
"wsdl_url",
"?",
"opts",
".",
"wsdl_url",
":",
"API_BASE_URI",
"+",
"WSDL_URL_PATH",
";",
"let",
"clientOpts",
"=",
"{",
"request",
":",
"request",
".",
... | Creates the SOAP client, using the supplied options for locating
the WSDL document for the endpoint.
@param {object} [opts] - WSDL and SOAP endpoint options
@param {string} [opts.wsdl_url] - the URL from which to fetch the
WSDL document; defaults to the concatenation of
[API_BASE_URI]{@link
module:plugins/polling-upda... | [
"Creates",
"the",
"SOAP",
"client",
"using",
"the",
"supplied",
"options",
"for",
"locating",
"the",
"WSDL",
"document",
"for",
"the",
"endpoint",
"."
] | ce63485ce37b33f552ceb2939740a40957a416f3 | https://github.com/hlapp/wirelesstags-js/blob/ce63485ce37b33f552ceb2939740a40957a416f3/plugins/polling-updater.js#L403-L413 | train |
hlapp/wirelesstags-js | plugins/polling-updater.js | pollForNextUpdate | function pollForNextUpdate(client, tagManager, callback) {
let req = new Promise((resolve, reject) => {
let methodName = tagManager ?
"GetNextUpdateForAllManagersOnDB" :
"GetNextUpdateForAllManagers";
let soapMethod = client[methodName];
let args = {};
if (tag... | javascript | function pollForNextUpdate(client, tagManager, callback) {
let req = new Promise((resolve, reject) => {
let methodName = tagManager ?
"GetNextUpdateForAllManagersOnDB" :
"GetNextUpdateForAllManagers";
let soapMethod = client[methodName];
let args = {};
if (tag... | [
"function",
"pollForNextUpdate",
"(",
"client",
",",
"tagManager",
",",
"callback",
")",
"{",
"let",
"req",
"=",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"let",
"methodName",
"=",
"tagManager",
"?",
"\"GetNextUpdateForAllManagersOn... | Polls the API endpoint for available updates and returns them.
@param {object} client - the SOAP client object
@param {WirelessTagManager} [tagManager] - the tag manager to which
to restrict updates
@param {module:wirelesstags~apiCallback} [callback] - if provided,
the `tagManager` parameter must be
provided too (even... | [
"Polls",
"the",
"API",
"endpoint",
"for",
"available",
"updates",
"and",
"returns",
"them",
"."
] | ce63485ce37b33f552ceb2939740a40957a416f3 | https://github.com/hlapp/wirelesstags-js/blob/ce63485ce37b33f552ceb2939740a40957a416f3/plugins/polling-updater.js#L429-L457 | train |
hlapp/wirelesstags-js | plugins/polling-updater.js | logError | function logError(log, err) {
let debug = log.debug || log.trace || log.log;
if (err.Fault) {
log.error(err.Fault);
if (err.response && err.response.request) {
log.error("URL: " + err.response.request.href);
}
if (err.body) debug(err.body);
} else {
log.er... | javascript | function logError(log, err) {
let debug = log.debug || log.trace || log.log;
if (err.Fault) {
log.error(err.Fault);
if (err.response && err.response.request) {
log.error("URL: " + err.response.request.href);
}
if (err.body) debug(err.body);
} else {
log.er... | [
"function",
"logError",
"(",
"log",
",",
"err",
")",
"{",
"let",
"debug",
"=",
"log",
".",
"debug",
"||",
"log",
".",
"trace",
"||",
"log",
".",
"log",
";",
"if",
"(",
"err",
".",
"Fault",
")",
"{",
"log",
".",
"error",
"(",
"err",
".",
"Fault"... | Logs the given error to the given log facility.
@private | [
"Logs",
"the",
"given",
"error",
"to",
"the",
"given",
"log",
"facility",
"."
] | ce63485ce37b33f552ceb2939740a40957a416f3 | https://github.com/hlapp/wirelesstags-js/blob/ce63485ce37b33f552ceb2939740a40957a416f3/plugins/polling-updater.js#L464-L475 | train |
cristidraghici/sync-sql | lib/worker.js | function (connectionInfo, query, params) {
var connection,
client = new pg.Client(connectionInfo);
client.connect(function (err) {
if (err) {
return respond({
success: false,
data: {
err: err,
query: query,
... | javascript | function (connectionInfo, query, params) {
var connection,
client = new pg.Client(connectionInfo);
client.connect(function (err) {
if (err) {
return respond({
success: false,
data: {
err: err,
query: query,
... | [
"function",
"(",
"connectionInfo",
",",
"query",
",",
"params",
")",
"{",
"var",
"connection",
",",
"client",
"=",
"new",
"pg",
".",
"Client",
"(",
"connectionInfo",
")",
";",
"client",
".",
"connect",
"(",
"function",
"(",
"err",
")",
"{",
"if",
"(",
... | Execute postresql query
@param {object} connectionInfo Object containing information about the connection
@param {string} query The query to execute
@param {Array} params Params to use in the query
@returns {mixed} Void | [
"Execute",
"postresql",
"query"
] | 1fa5d16aa9d47f81802f8796c8255452ece73804 | https://github.com/cristidraghici/sync-sql/blob/1fa5d16aa9d47f81802f8796c8255452ece73804/lib/worker.js#L27-L67 | train | |
cristidraghici/sync-sql | lib/worker.js | function (connectionInfo, query, params) {
var connection;
// Connection validation
if (typeof connectionInfo.host !== 'string' || connectionInfo.host.length === 0) {
return respond({
success: false,
data: {
err: 'Bad hostname provided.',
quer... | javascript | function (connectionInfo, query, params) {
var connection;
// Connection validation
if (typeof connectionInfo.host !== 'string' || connectionInfo.host.length === 0) {
return respond({
success: false,
data: {
err: 'Bad hostname provided.',
quer... | [
"function",
"(",
"connectionInfo",
",",
"query",
",",
"params",
")",
"{",
"var",
"connection",
";",
"// Connection validation",
"if",
"(",
"typeof",
"connectionInfo",
".",
"host",
"!==",
"'string'",
"||",
"connectionInfo",
".",
"host",
".",
"length",
"===",
"0... | Execute mysql query
@param {object} connectionInfo Object containing information about the connection
@param {string} query The query to execute
@param {Array} params Params to use in the query
@returns {mixed} Void | [
"Execute",
"mysql",
"query"
] | 1fa5d16aa9d47f81802f8796c8255452ece73804 | https://github.com/cristidraghici/sync-sql/blob/1fa5d16aa9d47f81802f8796c8255452ece73804/lib/worker.js#L76-L166 | train | |
NiklasGollenstede/web-ext-utils | utils/inject.js | injectAsync | function injectAsync(_function, ...args) { return new Promise((resolve, reject) => {
if (typeof _function !== 'function') { throw new TypeError('Injecting a string is a form of eval()'); }
const { document, } = (this || global); // call with an iframe.contentWindow as this to inject into its context
const script = ... | javascript | function injectAsync(_function, ...args) { return new Promise((resolve, reject) => {
if (typeof _function !== 'function') { throw new TypeError('Injecting a string is a form of eval()'); }
const { document, } = (this || global); // call with an iframe.contentWindow as this to inject into its context
const script = ... | [
"function",
"injectAsync",
"(",
"_function",
",",
"...",
"args",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"if",
"(",
"typeof",
"_function",
"!==",
"'function'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
... | Same as `inject`, only that it executes `_function` asynchronously,
allows `_function` to return a Promise, and that it returns a Promise to that value.
The calling overhead is even greater than that of the synchronous `inject`.
@this {Window} | [
"Same",
"as",
"inject",
"only",
"that",
"it",
"executes",
"_function",
"asynchronously",
"allows",
"_function",
"to",
"return",
"a",
"Promise",
"and",
"that",
"it",
"returns",
"a",
"Promise",
"to",
"that",
"value",
".",
"The",
"calling",
"overhead",
"is",
"e... | 395698c633da88db86377d583b9b4eac6d9cc299 | https://github.com/NiklasGollenstede/web-ext-utils/blob/395698c633da88db86377d583b9b4eac6d9cc299/utils/inject.js#L56-L101 | train |
winkerVSbecks/draper | dist/build.js | remScale | function remScale(config){
return R.compose(
R.merge(config),
R.converge(R.merge,[
toRems(config.rem,'scale'),
toRems(config.rem,'typeScale')]))(
config);
} | javascript | function remScale(config){
return R.compose(
R.merge(config),
R.converge(R.merge,[
toRems(config.rem,'scale'),
toRems(config.rem,'typeScale')]))(
config);
} | [
"function",
"remScale",
"(",
"config",
")",
"{",
"return",
"R",
".",
"compose",
"(",
"R",
".",
"merge",
"(",
"config",
")",
",",
"R",
".",
"converge",
"(",
"R",
".",
"merge",
",",
"[",
"toRems",
"(",
"config",
".",
"rem",
",",
"'scale'",
")",
","... | Convert the scale and typescale to rems | [
"Convert",
"the",
"scale",
"and",
"typescale",
"to",
"rems"
] | 1648dce7c2252a8beea9e8a7faecc7b4129f2244 | https://github.com/winkerVSbecks/draper/blob/1648dce7c2252a8beea9e8a7faecc7b4129f2244/dist/build.js#L62-L70 | train |
winkerVSbecks/draper | dist/build.js | extendConfig | function extendConfig(options){
return R.mapObjIndexed(function(prop,type){return(
prop(options[type]));},extendOps);
} | javascript | function extendConfig(options){
return R.mapObjIndexed(function(prop,type){return(
prop(options[type]));},extendOps);
} | [
"function",
"extendConfig",
"(",
"options",
")",
"{",
"return",
"R",
".",
"mapObjIndexed",
"(",
"function",
"(",
"prop",
",",
"type",
")",
"{",
"return",
"(",
"prop",
"(",
"options",
"[",
"type",
"]",
")",
")",
";",
"}",
",",
"extendOps",
")",
";",
... | Customize base config | [
"Customize",
"base",
"config"
] | 1648dce7c2252a8beea9e8a7faecc7b4129f2244 | https://github.com/winkerVSbecks/draper/blob/1648dce7c2252a8beea9e8a7faecc7b4129f2244/dist/build.js#L75-L78 | train |
ericnishio/finnish-holidays-js | lib/date-utils.js | function(year, month, day) {
var date = new Date(Date.UTC(year, month - 1, day));
return date;
} | javascript | function(year, month, day) {
var date = new Date(Date.UTC(year, month - 1, day));
return date;
} | [
"function",
"(",
"year",
",",
"month",
",",
"day",
")",
"{",
"var",
"date",
"=",
"new",
"Date",
"(",
"Date",
".",
"UTC",
"(",
"year",
",",
"month",
"-",
"1",
",",
"day",
")",
")",
";",
"return",
"date",
";",
"}"
] | Creates a date.
@param {number} year
@param {number} month
@param {number} day
@return {Date} | [
"Creates",
"a",
"date",
"."
] | 33416bd96b18bf7b18c331c831212aefb2a6f9c2 | https://github.com/ericnishio/finnish-holidays-js/blob/33416bd96b18bf7b18c331c831212aefb2a6f9c2/lib/date-utils.js#L13-L16 | train | |
ericnishio/finnish-holidays-js | lib/date-utils.js | function(year, month, day) {
var dayOfWeek = this.createDate(year, month, day).getDay();
return dayOfWeek === this.SATURDAY || dayOfWeek === this.SUNDAY;
} | javascript | function(year, month, day) {
var dayOfWeek = this.createDate(year, month, day).getDay();
return dayOfWeek === this.SATURDAY || dayOfWeek === this.SUNDAY;
} | [
"function",
"(",
"year",
",",
"month",
",",
"day",
")",
"{",
"var",
"dayOfWeek",
"=",
"this",
".",
"createDate",
"(",
"year",
",",
"month",
",",
"day",
")",
".",
"getDay",
"(",
")",
";",
"return",
"dayOfWeek",
"===",
"this",
".",
"SATURDAY",
"||",
... | Checks if a date falls on a weekend.
@param {number} year
@param {number} month
@param {number} day
@return {boolean} | [
"Checks",
"if",
"a",
"date",
"falls",
"on",
"a",
"weekend",
"."
] | 33416bd96b18bf7b18c331c831212aefb2a6f9c2 | https://github.com/ericnishio/finnish-holidays-js/blob/33416bd96b18bf7b18c331c831212aefb2a6f9c2/lib/date-utils.js#L89-L92 | train | |
ericnishio/finnish-holidays-js | lib/date-utils.js | function(year) {
var a = year % 19;
var b = Math.floor(year / 100);
var c = year % 100;
var d = Math.floor(b / 4);
var e = b % 4;
var f = Math.floor((b + 8) / 25);
var g = Math.floor((b - f + 1) / 3);
var h = (19 * a + b - d - g + 15) % 30;
var i = Math.floor(c / 4);
var k = c % ... | javascript | function(year) {
var a = year % 19;
var b = Math.floor(year / 100);
var c = year % 100;
var d = Math.floor(b / 4);
var e = b % 4;
var f = Math.floor((b + 8) / 25);
var g = Math.floor((b - f + 1) / 3);
var h = (19 * a + b - d - g + 15) % 30;
var i = Math.floor(c / 4);
var k = c % ... | [
"function",
"(",
"year",
")",
"{",
"var",
"a",
"=",
"year",
"%",
"19",
";",
"var",
"b",
"=",
"Math",
".",
"floor",
"(",
"year",
"/",
"100",
")",
";",
"var",
"c",
"=",
"year",
"%",
"100",
";",
"var",
"d",
"=",
"Math",
".",
"floor",
"(",
"b",... | Determines the date of Easter Sunday.
@param {number} year
@return {Date} | [
"Determines",
"the",
"date",
"of",
"Easter",
"Sunday",
"."
] | 33416bd96b18bf7b18c331c831212aefb2a6f9c2 | https://github.com/ericnishio/finnish-holidays-js/blob/33416bd96b18bf7b18c331c831212aefb2a6f9c2/lib/date-utils.js#L99-L117 | train | |
ericnishio/finnish-holidays-js | lib/date-utils.js | function(year) {
var date = this.easterSunday(year);
var y = date.getFullYear();
var m = date.getMonth() + 1;
var d = date.getDate() + 1;
return this.createDate(y, m, d);
} | javascript | function(year) {
var date = this.easterSunday(year);
var y = date.getFullYear();
var m = date.getMonth() + 1;
var d = date.getDate() + 1;
return this.createDate(y, m, d);
} | [
"function",
"(",
"year",
")",
"{",
"var",
"date",
"=",
"this",
".",
"easterSunday",
"(",
"year",
")",
";",
"var",
"y",
"=",
"date",
".",
"getFullYear",
"(",
")",
";",
"var",
"m",
"=",
"date",
".",
"getMonth",
"(",
")",
"+",
"1",
";",
"var",
"d"... | Determines the date of Easter Monday.
Day after Easter Sunday
@param {number} year
@return {Date} | [
"Determines",
"the",
"date",
"of",
"Easter",
"Monday",
".",
"Day",
"after",
"Easter",
"Sunday"
] | 33416bd96b18bf7b18c331c831212aefb2a6f9c2 | https://github.com/ericnishio/finnish-holidays-js/blob/33416bd96b18bf7b18c331c831212aefb2a6f9c2/lib/date-utils.js#L125-L131 | train | |
ericnishio/finnish-holidays-js | lib/date-utils.js | function(year) {
var self = this;
var date = this.easterSunday(year);
var dayOfWeek = null;
function resolveFriday() {
if (dayOfWeek === self.FRIDAY) {
return date;
} else {
date = self.subtractDays(date, 1);
dayOfWeek = self.getDayOfWeek(date);
return resolv... | javascript | function(year) {
var self = this;
var date = this.easterSunday(year);
var dayOfWeek = null;
function resolveFriday() {
if (dayOfWeek === self.FRIDAY) {
return date;
} else {
date = self.subtractDays(date, 1);
dayOfWeek = self.getDayOfWeek(date);
return resolv... | [
"function",
"(",
"year",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"date",
"=",
"this",
".",
"easterSunday",
"(",
"year",
")",
";",
"var",
"dayOfWeek",
"=",
"null",
";",
"function",
"resolveFriday",
"(",
")",
"{",
"if",
"(",
"dayOfWeek",
"===... | Determines the date of Good Friday.
Friday before Easter Sunday
@param {number} year
@return {Date} | [
"Determines",
"the",
"date",
"of",
"Good",
"Friday",
".",
"Friday",
"before",
"Easter",
"Sunday"
] | 33416bd96b18bf7b18c331c831212aefb2a6f9c2 | https://github.com/ericnishio/finnish-holidays-js/blob/33416bd96b18bf7b18c331c831212aefb2a6f9c2/lib/date-utils.js#L139-L155 | train | |
ericnishio/finnish-holidays-js | lib/date-utils.js | function(year) {
var self = this;
var month = 6;
var midsummerEve;
self.range(19, 26).forEach(function(day) {
if (!midsummerEve) {
var date = self.createDate(year, month, day);
var dayOfWeek = self.getDayOfWeek(date);
if (dayOfWeek === self.FRIDAY) {
midsummerEv... | javascript | function(year) {
var self = this;
var month = 6;
var midsummerEve;
self.range(19, 26).forEach(function(day) {
if (!midsummerEve) {
var date = self.createDate(year, month, day);
var dayOfWeek = self.getDayOfWeek(date);
if (dayOfWeek === self.FRIDAY) {
midsummerEv... | [
"function",
"(",
"year",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"month",
"=",
"6",
";",
"var",
"midsummerEve",
";",
"self",
".",
"range",
"(",
"19",
",",
"26",
")",
".",
"forEach",
"(",
"function",
"(",
"day",
")",
"{",
"if",
"(",
"!... | Determines the date of Midsummer Eve.
Friday between June 19-25
@param {number} year
@return {Date} | [
"Determines",
"the",
"date",
"of",
"Midsummer",
"Eve",
".",
"Friday",
"between",
"June",
"19",
"-",
"25"
] | 33416bd96b18bf7b18c331c831212aefb2a6f9c2 | https://github.com/ericnishio/finnish-holidays-js/blob/33416bd96b18bf7b18c331c831212aefb2a6f9c2/lib/date-utils.js#L185-L202 | train | |
ericnishio/finnish-holidays-js | lib/date-utils.js | function(year) {
var self = this;
var month = 6;
var midsummerDay;
self.range(20, 26).forEach(function(day) {
if (!midsummerDay) {
var date = self.createDate(year, month, day);
var dayOfWeek = self.getDayOfWeek(date);
if (dayOfWeek === self.SATURDAY) {
midsummer... | javascript | function(year) {
var self = this;
var month = 6;
var midsummerDay;
self.range(20, 26).forEach(function(day) {
if (!midsummerDay) {
var date = self.createDate(year, month, day);
var dayOfWeek = self.getDayOfWeek(date);
if (dayOfWeek === self.SATURDAY) {
midsummer... | [
"function",
"(",
"year",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"month",
"=",
"6",
";",
"var",
"midsummerDay",
";",
"self",
".",
"range",
"(",
"20",
",",
"26",
")",
".",
"forEach",
"(",
"function",
"(",
"day",
")",
"{",
"if",
"(",
"!... | Determines the date of Midsummer Day.
Saturday between June 20-26
@param {number} year
@return {Date} | [
"Determines",
"the",
"date",
"of",
"Midsummer",
"Day",
".",
"Saturday",
"between",
"June",
"20",
"-",
"26"
] | 33416bd96b18bf7b18c331c831212aefb2a6f9c2 | https://github.com/ericnishio/finnish-holidays-js/blob/33416bd96b18bf7b18c331c831212aefb2a6f9c2/lib/date-utils.js#L210-L227 | train | |
ericnishio/finnish-holidays-js | lib/date-utils.js | function(year) {
var self = this;
var october31 = self.createDate(year, 10, 31);
var secondMonth = 11;
var allSaintsDay;
if (self.getDayOfWeek(october31) === self.SATURDAY) {
allSaintsDay = october31;
} else {
self.range(1, 6).forEach(function(day) {
if (!allSaintsDay) {
... | javascript | function(year) {
var self = this;
var october31 = self.createDate(year, 10, 31);
var secondMonth = 11;
var allSaintsDay;
if (self.getDayOfWeek(october31) === self.SATURDAY) {
allSaintsDay = october31;
} else {
self.range(1, 6).forEach(function(day) {
if (!allSaintsDay) {
... | [
"function",
"(",
"year",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"october31",
"=",
"self",
".",
"createDate",
"(",
"year",
",",
"10",
",",
"31",
")",
";",
"var",
"secondMonth",
"=",
"11",
";",
"var",
"allSaintsDay",
";",
"if",
"(",
"self"... | Determines the date of All Saints' Day.
Saturday between October 31 and November 6
@param {number} year
@return {Date} | [
"Determines",
"the",
"date",
"of",
"All",
"Saints",
"Day",
".",
"Saturday",
"between",
"October",
"31",
"and",
"November",
"6"
] | 33416bd96b18bf7b18c331c831212aefb2a6f9c2 | https://github.com/ericnishio/finnish-holidays-js/blob/33416bd96b18bf7b18c331c831212aefb2a6f9c2/lib/date-utils.js#L235-L257 | train | |
ericnishio/finnish-holidays-js | lib/date-utils.js | function(num) {
num = parseInt(num);
if (num < 10) {
num = '0' + num;
} else {
num = num.toString();
}
return num;
} | javascript | function(num) {
num = parseInt(num);
if (num < 10) {
num = '0' + num;
} else {
num = num.toString();
}
return num;
} | [
"function",
"(",
"num",
")",
"{",
"num",
"=",
"parseInt",
"(",
"num",
")",
";",
"if",
"(",
"num",
"<",
"10",
")",
"{",
"num",
"=",
"'0'",
"+",
"num",
";",
"}",
"else",
"{",
"num",
"=",
"num",
".",
"toString",
"(",
")",
";",
"}",
"return",
"... | Adds a leading zero to a single-digit number.
@param {number} num
@return {string} | [
"Adds",
"a",
"leading",
"zero",
"to",
"a",
"single",
"-",
"digit",
"number",
"."
] | 33416bd96b18bf7b18c331c831212aefb2a6f9c2 | https://github.com/ericnishio/finnish-holidays-js/blob/33416bd96b18bf7b18c331c831212aefb2a6f9c2/lib/date-utils.js#L264-L274 | train | |
ericnishio/finnish-holidays-js | lib/date-utils.js | function(fromNumber, toNumber) {
if (typeof fromNumber === 'undefined' || typeof toNumber === 'undefined') {
throw Error('Invalid range.');
}
var arr = [];
for (var i = fromNumber; i <= toNumber; i++) {
arr.push(i);
}
return arr;
} | javascript | function(fromNumber, toNumber) {
if (typeof fromNumber === 'undefined' || typeof toNumber === 'undefined') {
throw Error('Invalid range.');
}
var arr = [];
for (var i = fromNumber; i <= toNumber; i++) {
arr.push(i);
}
return arr;
} | [
"function",
"(",
"fromNumber",
",",
"toNumber",
")",
"{",
"if",
"(",
"typeof",
"fromNumber",
"===",
"'undefined'",
"||",
"typeof",
"toNumber",
"===",
"'undefined'",
")",
"{",
"throw",
"Error",
"(",
"'Invalid range.'",
")",
";",
"}",
"var",
"arr",
"=",
"[",... | Creates an array of a range of numbers.
@param {number} fromNumber
@param {number} toNumber
@return {Array} | [
"Creates",
"an",
"array",
"of",
"a",
"range",
"of",
"numbers",
"."
] | 33416bd96b18bf7b18c331c831212aefb2a6f9c2 | https://github.com/ericnishio/finnish-holidays-js/blob/33416bd96b18bf7b18c331c831212aefb2a6f9c2/lib/date-utils.js#L282-L294 | train | |
thehydroimpulse/rollout | index.js | Rollout | function Rollout(client) {
this.client = client || redis.createClient();
this._id = 'id';
this._namespace = null;
this._groups = {};
this.group('all', function(user) { return true; });
} | javascript | function Rollout(client) {
this.client = client || redis.createClient();
this._id = 'id';
this._namespace = null;
this._groups = {};
this.group('all', function(user) { return true; });
} | [
"function",
"Rollout",
"(",
"client",
")",
"{",
"this",
".",
"client",
"=",
"client",
"||",
"redis",
".",
"createClient",
"(",
")",
";",
"this",
".",
"_id",
"=",
"'id'",
";",
"this",
".",
"_namespace",
"=",
"null",
";",
"this",
".",
"_groups",
"=",
... | Rollout constructor.
@param {Redis} client A redis instance. | [
"Rollout",
"constructor",
"."
] | 78f7ed4292defb056641de9c8c9370cd75daee73 | https://github.com/thehydroimpulse/rollout/blob/78f7ed4292defb056641de9c8c9370cd75daee73/index.js#L27-L34 | train |
evaletolab/karibou-wallet | lib/wallet.driver.mongoose.js | objectToSignature | function objectToSignature(source) {
function sortObject(input) {
if(typeof input !== 'object' ||input===null)
return input
var output = {};
Object.keys(input).sort().forEach(function (key) {
output[key] = sortObject(input[key]);
});
return output;
}
var signature=... | javascript | function objectToSignature(source) {
function sortObject(input) {
if(typeof input !== 'object' ||input===null)
return input
var output = {};
Object.keys(input).sort().forEach(function (key) {
output[key] = sortObject(input[key]);
});
return output;
}
var signature=... | [
"function",
"objectToSignature",
"(",
"source",
")",
"{",
"function",
"sortObject",
"(",
"input",
")",
"{",
"if",
"(",
"typeof",
"input",
"!==",
"'object'",
"||",
"input",
"===",
"null",
")",
"return",
"input",
"var",
"output",
"=",
"{",
"}",
";",
"Objec... | this is used to prepare the object signature | [
"this",
"is",
"used",
"to",
"prepare",
"the",
"object",
"signature"
] | 2d072b7d1412e8d486be8a8beb77273f1a17c2ef | https://github.com/evaletolab/karibou-wallet/blob/2d072b7d1412e8d486be8a8beb77273f1a17c2ef/lib/wallet.driver.mongoose.js#L62-L81 | train |
mattmcmanus/node-helmsman | helmsman.js | defaultFillCommandData | function defaultFillCommandData(defaults, file, extension) {
var data;
try {
data = require(file).command || {};
} catch (e) {
// If it's JavaScript then return the error
if (extension === '.js') {
data = {failedRequire: e};
}
}
return _.merge(defaults, data);
} | javascript | function defaultFillCommandData(defaults, file, extension) {
var data;
try {
data = require(file).command || {};
} catch (e) {
// If it's JavaScript then return the error
if (extension === '.js') {
data = {failedRequire: e};
}
}
return _.merge(defaults, data);
} | [
"function",
"defaultFillCommandData",
"(",
"defaults",
",",
"file",
",",
"extension",
")",
"{",
"var",
"data",
";",
"try",
"{",
"data",
"=",
"require",
"(",
"file",
")",
".",
"command",
"||",
"{",
"}",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"// If it... | The default function used to get metadata from a command | [
"The",
"default",
"function",
"used",
"to",
"get",
"metadata",
"from",
"a",
"command"
] | 50b285676f077a72c7408e28b2c5b3a395db1f6a | https://github.com/mattmcmanus/node-helmsman/blob/50b285676f077a72c7408e28b2c5b3a395db1f6a/helmsman.js#L22-L35 | train |
mattmcmanus/node-helmsman | helmsman.js | isOneOrMore | function isOneOrMore(commands, iterator) {
var list = commands.filter(iterator);
if (list.length === 1) {
return list[0];
} else if (list.length > 1) {
return new Error(util.format('There are %d options for "%s": %s',
list.length, cmd, list.join(', ')));
}
return false;
} | javascript | function isOneOrMore(commands, iterator) {
var list = commands.filter(iterator);
if (list.length === 1) {
return list[0];
} else if (list.length > 1) {
return new Error(util.format('There are %d options for "%s": %s',
list.length, cmd, list.join(', ')));
}
return false;
} | [
"function",
"isOneOrMore",
"(",
"commands",
",",
"iterator",
")",
"{",
"var",
"list",
"=",
"commands",
".",
"filter",
"(",
"iterator",
")",
";",
"if",
"(",
"list",
".",
"length",
"===",
"1",
")",
"{",
"return",
"list",
"[",
"0",
"]",
";",
"}",
"els... | Determine how many commands match the iterator. Return one if command, | [
"Determine",
"how",
"many",
"commands",
"match",
"the",
"iterator",
".",
"Return",
"one",
"if",
"command"
] | 50b285676f077a72c7408e28b2c5b3a395db1f6a | https://github.com/mattmcmanus/node-helmsman/blob/50b285676f077a72c7408e28b2c5b3a395db1f6a/helmsman.js#L205-L216 | train |
AXErunners/axecore-p2p | lib/messages/commands/filteradd.js | FilteraddMessage | function FilteraddMessage(arg, options) {
Message.call(this, options);
this.command = 'filteradd';
$.checkArgument(
_.isUndefined(arg) || BufferUtil.isBuffer(arg),
'First argument is expected to be a Buffer or undefined'
);
this.data = arg || BufferUtil.EMPTY_BUFFER;
} | javascript | function FilteraddMessage(arg, options) {
Message.call(this, options);
this.command = 'filteradd';
$.checkArgument(
_.isUndefined(arg) || BufferUtil.isBuffer(arg),
'First argument is expected to be a Buffer or undefined'
);
this.data = arg || BufferUtil.EMPTY_BUFFER;
} | [
"function",
"FilteraddMessage",
"(",
"arg",
",",
"options",
")",
"{",
"Message",
".",
"call",
"(",
"this",
",",
"options",
")",
";",
"this",
".",
"command",
"=",
"'filteradd'",
";",
"$",
".",
"checkArgument",
"(",
"_",
".",
"isUndefined",
"(",
"arg",
"... | Request peer to add data to a bloom filter already set by 'filterload'
@param {Buffer=} data - Array of bytes representing bloom filter data
@param {Object=} options
@extends Message
@constructor | [
"Request",
"peer",
"to",
"add",
"data",
"to",
"a",
"bloom",
"filter",
"already",
"set",
"by",
"filterload"
] | c06d0e1d7b9ed44b7ee3061feb394d3896240da9 | https://github.com/AXErunners/axecore-p2p/blob/c06d0e1d7b9ed44b7ee3061feb394d3896240da9/lib/messages/commands/filteradd.js#L20-L28 | train |
flipside/gulp-graphql | index.js | function (dirname, options) {
var src = options.graphqlPath || (dirname + '/node_modules/graphql');
// console.log(src);
try {
graphql = require(src).graphql;
var graphqlUtil = require(src + '/utilities');
introspectionQuery = graphqlUtil.introspectionQuery;
printSchema = graphqlUtil.printSchema;... | javascript | function (dirname, options) {
var src = options.graphqlPath || (dirname + '/node_modules/graphql');
// console.log(src);
try {
graphql = require(src).graphql;
var graphqlUtil = require(src + '/utilities');
introspectionQuery = graphqlUtil.introspectionQuery;
printSchema = graphqlUtil.printSchema;... | [
"function",
"(",
"dirname",
",",
"options",
")",
"{",
"var",
"src",
"=",
"options",
".",
"graphqlPath",
"||",
"(",
"dirname",
"+",
"'/node_modules/graphql'",
")",
";",
"// console.log(src);",
"try",
"{",
"graphql",
"=",
"require",
"(",
"src",
")",
".",
"gr... | loads graphql via absolute path to base directory | [
"loads",
"graphql",
"via",
"absolute",
"path",
"to",
"base",
"directory"
] | 5b8c5044180b92ce3948330040ae474fa73acce0 | https://github.com/flipside/gulp-graphql/blob/5b8c5044180b92ce3948330040ae474fa73acce0/index.js#L9-L28 | train | |
TimeMagazine/elastic-svg | index.js | resize | function resize() {
console.log("resizing base");
base.width = parent.clientWidth;
svg.setAttributeNS(null, "width", base.width);
// only resize the height if aspect was specified instead of height
if (opts.aspect) {
base.height = base.width * opts.aspect;
svg.setAttributeNS(null, "height", ... | javascript | function resize() {
console.log("resizing base");
base.width = parent.clientWidth;
svg.setAttributeNS(null, "width", base.width);
// only resize the height if aspect was specified instead of height
if (opts.aspect) {
base.height = base.width * opts.aspect;
svg.setAttributeNS(null, "height", ... | [
"function",
"resize",
"(",
")",
"{",
"console",
".",
"log",
"(",
"\"resizing base\"",
")",
";",
"base",
".",
"width",
"=",
"parent",
".",
"clientWidth",
";",
"svg",
".",
"setAttributeNS",
"(",
"null",
",",
"\"width\"",
",",
"base",
".",
"width",
")",
"... | function called when the window resizes | [
"function",
"called",
"when",
"the",
"window",
"resizes"
] | 39ab1051953c3c4947803c3badf7776ffbc25cbc | https://github.com/TimeMagazine/elastic-svg/blob/39ab1051953c3c4947803c3badf7776ffbc25cbc/index.js#L52-L69 | train |
dschenkelman/z-schema-errors | lib/index.js | distinct | function distinct(array){
return Object.keys(array.reduce(function(current, value){
current[value] = true;
return current;
}, {}));
} | javascript | function distinct(array){
return Object.keys(array.reduce(function(current, value){
current[value] = true;
return current;
}, {}));
} | [
"function",
"distinct",
"(",
"array",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"array",
".",
"reduce",
"(",
"function",
"(",
"current",
",",
"value",
")",
"{",
"current",
"[",
"value",
"]",
"=",
"true",
";",
"return",
"current",
";",
"}",
",",... | only for array of strings | [
"only",
"for",
"array",
"of",
"strings"
] | ddf02965869d34e7cbf11db0e16c4bf14f1d4e53 | https://github.com/dschenkelman/z-schema-errors/blob/ddf02965869d34e7cbf11db0e16c4bf14f1d4e53/lib/index.js#L8-L13 | train |
NiklasGollenstede/web-ext-utils | utils/files.js | readFile | async function readFile(path, encoding) {
const url = browser.extension.getURL(realpath(path));
return new Promise((resolve, reject) => {
const xhr = new global.XMLHttpRequest;
xhr.responseType = encoding == null ? 'arraybuffer' : 'text';
xhr.addEventListener('load', () => resolve(xhr.response));
xhr.addEven... | javascript | async function readFile(path, encoding) {
const url = browser.extension.getURL(realpath(path));
return new Promise((resolve, reject) => {
const xhr = new global.XMLHttpRequest;
xhr.responseType = encoding == null ? 'arraybuffer' : 'text';
xhr.addEventListener('load', () => resolve(xhr.response));
xhr.addEven... | [
"async",
"function",
"readFile",
"(",
"path",
",",
"encoding",
")",
"{",
"const",
"url",
"=",
"browser",
".",
"extension",
".",
"getURL",
"(",
"realpath",
"(",
"path",
")",
")",
";",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
... | Loads a file included in the extension.
@param {string} path Absolute path of the file to read.
@param {string} encoding Optional. Allowed values: 'utf-8'
@return {any} [description] | [
"Loads",
"a",
"file",
"included",
"in",
"the",
"extension",
"."
] | 395698c633da88db86377d583b9b4eac6d9cc299 | https://github.com/NiklasGollenstede/web-ext-utils/blob/395698c633da88db86377d583b9b4eac6d9cc299/utils/files.js#L60-L71 | train |
AXErunners/axecore-p2p | lib/messages/commands/version.js | VersionMessage | function VersionMessage(arg, options) {
/* jshint maxcomplexity: 10 */
if (!arg) {
arg = {};
}
Message.call(this, options);
this.command = 'version';
this.version = arg.version || options.protocolVersion;
this.nonce = arg.nonce || utils.getNonce();
this.services = arg.services || new BN(1, 10);
th... | javascript | function VersionMessage(arg, options) {
/* jshint maxcomplexity: 10 */
if (!arg) {
arg = {};
}
Message.call(this, options);
this.command = 'version';
this.version = arg.version || options.protocolVersion;
this.nonce = arg.nonce || utils.getNonce();
this.services = arg.services || new BN(1, 10);
th... | [
"function",
"VersionMessage",
"(",
"arg",
",",
"options",
")",
"{",
"/* jshint maxcomplexity: 10 */",
"if",
"(",
"!",
"arg",
")",
"{",
"arg",
"=",
"{",
"}",
";",
"}",
"Message",
".",
"call",
"(",
"this",
",",
"options",
")",
";",
"this",
".",
"command"... | The version message is used on connection creation to advertise
the type of node. The remote node will respond with its version, and no
communication is possible until both peers have exchanged their versions.
@see https://en.bitcoin.it/wiki/Protocol_documentation#version
@param {Object=} arg - properties for the vers... | [
"The",
"version",
"message",
"is",
"used",
"on",
"connection",
"creation",
"to",
"advertise",
"the",
"type",
"of",
"node",
".",
"The",
"remote",
"node",
"will",
"respond",
"with",
"its",
"version",
"and",
"no",
"communication",
"is",
"possible",
"until",
"bo... | c06d0e1d7b9ed44b7ee3061feb394d3896240da9 | https://github.com/AXErunners/axecore-p2p/blob/c06d0e1d7b9ed44b7ee3061feb394d3896240da9/lib/messages/commands/version.js#L29-L43 | train |
chriswongtv/node-all-paths | libs/populateMap.js | validateNode | function validateNode (cost) {
cost = Number(cost)
if (isNaN(cost)) {
throw new TypeError(`Cost must be a number, istead got ${cost}`)
}
if (cost <= 0) {
throw new TypeError(`The cost must be a number above 0, instead got ${cost}`)
}
return cost
} | javascript | function validateNode (cost) {
cost = Number(cost)
if (isNaN(cost)) {
throw new TypeError(`Cost must be a number, istead got ${cost}`)
}
if (cost <= 0) {
throw new TypeError(`The cost must be a number above 0, instead got ${cost}`)
}
return cost
} | [
"function",
"validateNode",
"(",
"cost",
")",
"{",
"cost",
"=",
"Number",
"(",
"cost",
")",
"if",
"(",
"isNaN",
"(",
"cost",
")",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"`",
"${",
"cost",
"}",
"`",
")",
"}",
"if",
"(",
"cost",
"<=",
"0",
"... | Assert that the provided cost in a positive number
@private
@param {number} cost Cost to validate
@return {number} cost | [
"Assert",
"that",
"the",
"provided",
"cost",
"in",
"a",
"positive",
"number"
] | 69cc7d0a834e1d7179c2ba7990624ca7468ded1d | https://github.com/chriswongtv/node-all-paths/blob/69cc7d0a834e1d7179c2ba7990624ca7468ded1d/libs/populateMap.js#L10-L22 | train |
chriswongtv/node-all-paths | libs/populateMap.js | populateMap | function populateMap (map, object, keys) {
// Return the map once all the keys have been populated
if (!keys.length) return map
let key = keys.shift()
let value = object[key]
if (value !== null && typeof value === 'object') {
// When the key is an object, we recursevely populate its proprieties into
... | javascript | function populateMap (map, object, keys) {
// Return the map once all the keys have been populated
if (!keys.length) return map
let key = keys.shift()
let value = object[key]
if (value !== null && typeof value === 'object') {
// When the key is an object, we recursevely populate its proprieties into
... | [
"function",
"populateMap",
"(",
"map",
",",
"object",
",",
"keys",
")",
"{",
"// Return the map once all the keys have been populated",
"if",
"(",
"!",
"keys",
".",
"length",
")",
"return",
"map",
"let",
"key",
"=",
"keys",
".",
"shift",
"(",
")",
"let",
"va... | Populates the `Map` passed as first agument with the values in the provided
object. Supports nested objects, recursively adding them to a `Map`
@param {Map} map `Map` to populate with the values from the object
@param {object} object Object to translate into the `Map`
@param {array} keys Keys of the obj... | [
"Populates",
"the",
"Map",
"passed",
"as",
"first",
"agument",
"with",
"the",
"values",
"in",
"the",
"provided",
"object",
".",
"Supports",
"nested",
"objects",
"recursively",
"adding",
"them",
"to",
"a",
"Map"
] | 69cc7d0a834e1d7179c2ba7990624ca7468ded1d | https://github.com/chriswongtv/node-all-paths/blob/69cc7d0a834e1d7179c2ba7990624ca7468ded1d/libs/populateMap.js#L34-L55 | train |
traedamatic/bunyan-mongodb-stream | lib/logStream.js | LogStream | function LogStream(options) {
this.model = options.model || false;
if (!this.model) {
throw new Error('[LogStream] - Fatal Error - No mongoose model provided!');
}
Writable.call(this, options);
} | javascript | function LogStream(options) {
this.model = options.model || false;
if (!this.model) {
throw new Error('[LogStream] - Fatal Error - No mongoose model provided!');
}
Writable.call(this, options);
} | [
"function",
"LogStream",
"(",
"options",
")",
"{",
"this",
".",
"model",
"=",
"options",
".",
"model",
"||",
"false",
";",
"if",
"(",
"!",
"this",
".",
"model",
")",
"{",
"throw",
"new",
"Error",
"(",
"'[LogStream] - Fatal Error - No mongoose model provided!'"... | the LogStream constructor.
it inherits all methods of a writable stream
the constructor takes a options object. A important field is the model, the model will
be used for saving the log entry to the mongo db instance.
@param options
@constructor | [
"the",
"LogStream",
"constructor",
".",
"it",
"inherits",
"all",
"methods",
"of",
"a",
"writable",
"stream",
"the",
"constructor",
"takes",
"a",
"options",
"object",
".",
"A",
"important",
"field",
"is",
"the",
"model",
"the",
"model",
"will",
"be",
"used",
... | d28cd8d7f4266287ebc502986e94c683e45b5587 | https://github.com/traedamatic/bunyan-mongodb-stream/blob/d28cd8d7f4266287ebc502986e94c683e45b5587/lib/logStream.js#L14-L23 | train |
AXErunners/axecore-p2p | lib/messages/commands/headers.js | HeadersMessage | function HeadersMessage(arg, options) {
Message.call(this, options);
this.BlockHeader = options.BlockHeader;
this.command = 'headers';
$.checkArgument(
_.isUndefined(arg) || (Array.isArray(arg) && arg[0] instanceof this.BlockHeader),
'First argument is expected to be an array of BlockHeader instances'
... | javascript | function HeadersMessage(arg, options) {
Message.call(this, options);
this.BlockHeader = options.BlockHeader;
this.command = 'headers';
$.checkArgument(
_.isUndefined(arg) || (Array.isArray(arg) && arg[0] instanceof this.BlockHeader),
'First argument is expected to be an array of BlockHeader instances'
... | [
"function",
"HeadersMessage",
"(",
"arg",
",",
"options",
")",
"{",
"Message",
".",
"call",
"(",
"this",
",",
"options",
")",
";",
"this",
".",
"BlockHeader",
"=",
"options",
".",
"BlockHeader",
";",
"this",
".",
"command",
"=",
"'headers'",
";",
"$",
... | Sent in response to a `getheaders` message. It contains information about
block headers.
@param {Array} arg - An array of BlockHeader instances
@param {Object=} options
@param {Array=} options.headers - array of block headers
@param {Function} options.BlockHeader - a BlockHeader constructor
@extends Message
@constructo... | [
"Sent",
"in",
"response",
"to",
"a",
"getheaders",
"message",
".",
"It",
"contains",
"information",
"about",
"block",
"headers",
"."
] | c06d0e1d7b9ed44b7ee3061feb394d3896240da9 | https://github.com/AXErunners/axecore-p2p/blob/c06d0e1d7b9ed44b7ee3061feb394d3896240da9/lib/messages/commands/headers.js#L22-L31 | train |
NiklasGollenstede/web-ext-utils | loader/index.js | runInFrame | async function runInFrame(tabId, frameId, script, ...args) {
if (typeof tabId !== 'number') { tabId = (await getActiveTabId()); }
return (await Frame.get(tabId, frameId || 0)).call(getScource(script), args);
} | javascript | async function runInFrame(tabId, frameId, script, ...args) {
if (typeof tabId !== 'number') { tabId = (await getActiveTabId()); }
return (await Frame.get(tabId, frameId || 0)).call(getScource(script), args);
} | [
"async",
"function",
"runInFrame",
"(",
"tabId",
",",
"frameId",
",",
"script",
",",
"...",
"args",
")",
"{",
"if",
"(",
"typeof",
"tabId",
"!==",
"'number'",
")",
"{",
"tabId",
"=",
"(",
"await",
"getActiveTabId",
"(",
")",
")",
";",
"}",
"return",
... | Dynamically executes functions as content scripts.
@param {natural|null} tabId The id of the tab to run in. Default to an active tab, preferably in the current window.
@param {natural|null} frameId The id of the frame within the tab to run in. Defaults to the top level frame.
@param {function|string} sc... | [
"Dynamically",
"executes",
"functions",
"as",
"content",
"scripts",
"."
] | 395698c633da88db86377d583b9b4eac6d9cc299 | https://github.com/NiklasGollenstede/web-ext-utils/blob/395698c633da88db86377d583b9b4eac6d9cc299/loader/index.js#L22-L25 | train |
hakobera/mai | lib/mai.js | function(conf) {
if (!conf) {
throw new Error("'conf' is required");
}
var text, headers, message, smtpClient,
callback = conf.callback || function(){};
text = this._buildTemplate(conf.templateName, conf.params);
headers = this._buildHeaders(conf, text);... | javascript | function(conf) {
if (!conf) {
throw new Error("'conf' is required");
}
var text, headers, message, smtpClient,
callback = conf.callback || function(){};
text = this._buildTemplate(conf.templateName, conf.params);
headers = this._buildHeaders(conf, text);... | [
"function",
"(",
"conf",
")",
"{",
"if",
"(",
"!",
"conf",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"'conf' is required\"",
")",
";",
"}",
"var",
"text",
",",
"headers",
",",
"message",
",",
"smtpClient",
",",
"callback",
"=",
"conf",
".",
"callback",... | Send e-mail.
@param {Object} conf Configuration.
- from {String} Sender of the format (address or name <address> or "name" <address>)
- to {String} Recipients (same format as above), multiple recipients are separated by a comma
- cc {String} [optional] Carbon copied recipients (same format as above)
- bcc {String} [op... | [
"Send",
"e",
"-",
"mail",
"."
] | 0e8e56fc66c31a59588ff6fbea04152674c5910e | https://github.com/hakobera/mai/blob/0e8e56fc66c31a59588ff6fbea04152674c5910e/lib/mai.js#L86-L107 | train | |
pgherveou/gulp-file-cache | index.js | FileCache | function FileCache(name) {
this._filename = name || '.gulp-cache';
// load cache
try {
this._cache = JSON.parse(fs.readFileSync(this._filename, 'utf8'));
} catch (err) {
this._cache = {};
}
} | javascript | function FileCache(name) {
this._filename = name || '.gulp-cache';
// load cache
try {
this._cache = JSON.parse(fs.readFileSync(this._filename, 'utf8'));
} catch (err) {
this._cache = {};
}
} | [
"function",
"FileCache",
"(",
"name",
")",
"{",
"this",
".",
"_filename",
"=",
"name",
"||",
"'.gulp-cache'",
";",
"// load cache",
"try",
"{",
"this",
".",
"_cache",
"=",
"JSON",
".",
"parse",
"(",
"fs",
".",
"readFileSync",
"(",
"this",
".",
"_filename... | create a new FileCache instance | [
"create",
"a",
"new",
"FileCache",
"instance"
] | 43bc6f48525c04f79a127d5775bf1d5489c65990 | https://github.com/pgherveou/gulp-file-cache/blob/43bc6f48525c04f79a127d5775bf1d5489c65990/index.js#L8-L17 | train |
pgherveou/gulp-file-cache | index.js | flush | function flush(callback) {
fs.writeFile(_this._filename, JSON.stringify(_this._cache), callback);
} | javascript | function flush(callback) {
fs.writeFile(_this._filename, JSON.stringify(_this._cache), callback);
} | [
"function",
"flush",
"(",
"callback",
")",
"{",
"fs",
".",
"writeFile",
"(",
"_this",
".",
"_filename",
",",
"JSON",
".",
"stringify",
"(",
"_this",
".",
"_cache",
")",
",",
"callback",
")",
";",
"}"
] | flush cache to disk | [
"flush",
"cache",
"to",
"disk"
] | 43bc6f48525c04f79a127d5775bf1d5489c65990 | https://github.com/pgherveou/gulp-file-cache/blob/43bc6f48525c04f79a127d5775bf1d5489c65990/index.js#L40-L42 | train |
mpayetta/statsd-newrelic-backend | lib/dispatcher/metric-name.js | function (metricType, statsdKey) {
statsdKey = statsdKey.replace(/([^a-zA-Z0-9:_])/g, '_');
return [prefixes[metricType], '_', statsdKey].join('');
} | javascript | function (metricType, statsdKey) {
statsdKey = statsdKey.replace(/([^a-zA-Z0-9:_])/g, '_');
return [prefixes[metricType], '_', statsdKey].join('');
} | [
"function",
"(",
"metricType",
",",
"statsdKey",
")",
"{",
"statsdKey",
"=",
"statsdKey",
".",
"replace",
"(",
"/",
"([^a-zA-Z0-9:_])",
"/",
"g",
",",
"'_'",
")",
";",
"return",
"[",
"prefixes",
"[",
"metricType",
"]",
",",
"'_'",
",",
"statsdKey",
"]",
... | Custom events don't allow to have dots in the name so we need to replace them with '_' | [
"Custom",
"events",
"don",
"t",
"allow",
"to",
"have",
"dots",
"in",
"the",
"name",
"so",
"we",
"need",
"to",
"replace",
"them",
"with",
"_"
] | 64caaa368d9732c6bab916c91f46492eeb2392ba | https://github.com/mpayetta/statsd-newrelic-backend/blob/64caaa368d9732c6bab916c91f46492eeb2392ba/lib/dispatcher/metric-name.js#L22-L25 | train | |
wooorm/bcp-47-match | index.js | factory | function factory(check, filter) {
return match
function match(tags, ranges) {
var values = normalize(tags, ranges)
var result = []
var next
var tagIndex
var tagLength
var tag
var rangeIndex
var rangeLength
var range
var matches
tags = values.tags
ranges = values.ran... | javascript | function factory(check, filter) {
return match
function match(tags, ranges) {
var values = normalize(tags, ranges)
var result = []
var next
var tagIndex
var tagLength
var tag
var rangeIndex
var rangeLength
var range
var matches
tags = values.tags
ranges = values.ran... | [
"function",
"factory",
"(",
"check",
",",
"filter",
")",
"{",
"return",
"match",
"function",
"match",
"(",
"tags",
",",
"ranges",
")",
"{",
"var",
"values",
"=",
"normalize",
"(",
"tags",
",",
"ranges",
")",
"var",
"result",
"=",
"[",
"]",
"var",
"ne... | Factory to perform a filter or a lookup. This factory creates a function that accepts a list of tags and a list of ranges, and contains logic to exit early for lookups. `check` just has to deal with one tag and one range. This match function iterates over ranges, and for each range, iterates over tags. That way, earli... | [
"Factory",
"to",
"perform",
"a",
"filter",
"or",
"a",
"lookup",
".",
"This",
"factory",
"creates",
"a",
"function",
"that",
"accepts",
"a",
"list",
"of",
"tags",
"and",
"a",
"list",
"of",
"ranges",
"and",
"contains",
"logic",
"to",
"exit",
"early",
"for"... | 7f726bc9ed245b63c87b597952135d4d00981e3b | https://github.com/wooorm/bcp-47-match/blob/7f726bc9ed245b63c87b597952135d4d00981e3b/index.js#L113-L163 | train |
wooorm/bcp-47-match | index.js | cast | function cast(values, name) {
var value = values && typeof values === 'string' ? [values] : values
if (!value || typeof value !== 'object' || !('length' in value)) {
throw new Error(
'Invalid ' + name + ' `' + value + '`, expected non-empty string'
)
}
return value
} | javascript | function cast(values, name) {
var value = values && typeof values === 'string' ? [values] : values
if (!value || typeof value !== 'object' || !('length' in value)) {
throw new Error(
'Invalid ' + name + ' `' + value + '`, expected non-empty string'
)
}
return value
} | [
"function",
"cast",
"(",
"values",
",",
"name",
")",
"{",
"var",
"value",
"=",
"values",
"&&",
"typeof",
"values",
"===",
"'string'",
"?",
"[",
"values",
"]",
":",
"values",
"if",
"(",
"!",
"value",
"||",
"typeof",
"value",
"!==",
"'object'",
"||",
"... | Validate tags or ranges, and cast them to arrays. | [
"Validate",
"tags",
"or",
"ranges",
"and",
"cast",
"them",
"to",
"arrays",
"."
] | 7f726bc9ed245b63c87b597952135d4d00981e3b | https://github.com/wooorm/bcp-47-match/blob/7f726bc9ed245b63c87b597952135d4d00981e3b/index.js#L173-L183 | train |
chrahunt/tagpro-navmesh | gulpfile.js | watchifyFile | function watchifyFile(src, out) {
var opts = assign({}, watchify.args, {
entries: src,
standalone: "NavMesh",
debug: true
});
var b = watchify(browserify(opts));
function bundle() {
return b.bundle()
.on('error', gutil.log.bind(gutil, "Browserify Error"))
... | javascript | function watchifyFile(src, out) {
var opts = assign({}, watchify.args, {
entries: src,
standalone: "NavMesh",
debug: true
});
var b = watchify(browserify(opts));
function bundle() {
return b.bundle()
.on('error', gutil.log.bind(gutil, "Browserify Error"))
... | [
"function",
"watchifyFile",
"(",
"src",
",",
"out",
")",
"{",
"var",
"opts",
"=",
"assign",
"(",
"{",
"}",
",",
"watchify",
".",
"args",
",",
"{",
"entries",
":",
"src",
",",
"standalone",
":",
"\"NavMesh\"",
",",
"debug",
":",
"true",
"}",
")",
";... | Compile and watchify sourced file. | [
"Compile",
"and",
"watchify",
"sourced",
"file",
"."
] | b50fbdad1061fb4760ac22ee756f34ab3e177539 | https://github.com/chrahunt/tagpro-navmesh/blob/b50fbdad1061fb4760ac22ee756f34ab3e177539/gulpfile.js#L53-L70 | train |
chrahunt/tagpro-navmesh | src/navmesh.js | function(tile) {
var x = tile.x;
var y = tile.y;
var xUp = x + 1 < xUpperBound;
var xDown = x >= 0;
var yUp = y + 1 < yUpperBound;
var yDown = y >= 0;
var adjacents = [];
if (xUp) {
adjacents.push({x: x + 1, y: y});
if (yUp) {
adjacents.push({x: x + 1, y: y + 1});
... | javascript | function(tile) {
var x = tile.x;
var y = tile.y;
var xUp = x + 1 < xUpperBound;
var xDown = x >= 0;
var yUp = y + 1 < yUpperBound;
var yDown = y >= 0;
var adjacents = [];
if (xUp) {
adjacents.push({x: x + 1, y: y});
if (yUp) {
adjacents.push({x: x + 1, y: y + 1});
... | [
"function",
"(",
"tile",
")",
"{",
"var",
"x",
"=",
"tile",
".",
"x",
";",
"var",
"y",
"=",
"tile",
".",
"y",
";",
"var",
"xUp",
"=",
"x",
"+",
"1",
"<",
"xUpperBound",
";",
"var",
"xDown",
"=",
"x",
">=",
"0",
";",
"var",
"yUp",
"=",
"y",
... | Get the locations adjacent to a given tile in the map. | [
"Get",
"the",
"locations",
"adjacent",
"to",
"a",
"given",
"tile",
"in",
"the",
"map",
"."
] | b50fbdad1061fb4760ac22ee756f34ab3e177539 | https://github.com/chrahunt/tagpro-navmesh/blob/b50fbdad1061fb4760ac22ee756f34ab3e177539/src/navmesh.js#L762-L796 | train | |
AXErunners/axecore-p2p | lib/messages/commands/merkleblock.js | MerkleblockMessage | function MerkleblockMessage(arg, options) {
Message.call(this, options);
this.MerkleBlock = options.MerkleBlock; // constructor
this.command = 'merkleblock';
$.checkArgument(
_.isUndefined(arg) || arg instanceof this.MerkleBlock,
'An instance of MerkleBlock or undefined is expected'
);
this.merkleBl... | javascript | function MerkleblockMessage(arg, options) {
Message.call(this, options);
this.MerkleBlock = options.MerkleBlock; // constructor
this.command = 'merkleblock';
$.checkArgument(
_.isUndefined(arg) || arg instanceof this.MerkleBlock,
'An instance of MerkleBlock or undefined is expected'
);
this.merkleBl... | [
"function",
"MerkleblockMessage",
"(",
"arg",
",",
"options",
")",
"{",
"Message",
".",
"call",
"(",
"this",
",",
"options",
")",
";",
"this",
".",
"MerkleBlock",
"=",
"options",
".",
"MerkleBlock",
";",
"// constructor",
"this",
".",
"command",
"=",
"'mer... | Contains information about a MerkleBlock
@see https://en.bitcoin.it/wiki/Protocol_documentation
@param {MerkleBlock} arg - An instance of MerkleBlock
@param {Object=} options
@param {Function} options.MerkleBlock - a MerkleBlock constructor
@extends Message
@constructor | [
"Contains",
"information",
"about",
"a",
"MerkleBlock"
] | c06d0e1d7b9ed44b7ee3061feb394d3896240da9 | https://github.com/AXErunners/axecore-p2p/blob/c06d0e1d7b9ed44b7ee3061feb394d3896240da9/lib/messages/commands/merkleblock.js#L19-L28 | train |
mike182uk/cellref | index.js | cellref | function cellref (ref) {
if (R1C1.test(ref)) {
return convertR1C1toA1(ref)
}
if (A1.test(ref)) {
return convertA1toR1C1(ref)
}
throw new Error(`could not detect cell reference notation for ${ref}`)
} | javascript | function cellref (ref) {
if (R1C1.test(ref)) {
return convertR1C1toA1(ref)
}
if (A1.test(ref)) {
return convertA1toR1C1(ref)
}
throw new Error(`could not detect cell reference notation for ${ref}`)
} | [
"function",
"cellref",
"(",
"ref",
")",
"{",
"if",
"(",
"R1C1",
".",
"test",
"(",
"ref",
")",
")",
"{",
"return",
"convertR1C1toA1",
"(",
"ref",
")",
"}",
"if",
"(",
"A1",
".",
"test",
"(",
"ref",
")",
")",
"{",
"return",
"convertA1toR1C1",
"(",
... | Auto detect notation used and convert to the opposite notation
@param {String} ref
@returns {String}
@throws {Error} | [
"Auto",
"detect",
"notation",
"used",
"and",
"convert",
"to",
"the",
"opposite",
"notation"
] | 0f1c9d94bc71632c8f19b52d72632fd5718e4a26 | https://github.com/mike182uk/cellref/blob/0f1c9d94bc71632c8f19b52d72632fd5718e4a26/index.js#L33-L43 | train |
mike182uk/cellref | index.js | convertA1toR1C1 | function convertA1toR1C1 (ref) {
if (!A1.test(ref)) {
throw new Error(`${ref} is not a valid A1 cell reference`)
}
var refParts = ref
.replace(A1, '$1,$2')
.split(',')
var columnStr = refParts[0]
var row = refParts[1]
var column = 0
for (var i = 0; i < columnStr.length; i++) {
column = ... | javascript | function convertA1toR1C1 (ref) {
if (!A1.test(ref)) {
throw new Error(`${ref} is not a valid A1 cell reference`)
}
var refParts = ref
.replace(A1, '$1,$2')
.split(',')
var columnStr = refParts[0]
var row = refParts[1]
var column = 0
for (var i = 0; i < columnStr.length; i++) {
column = ... | [
"function",
"convertA1toR1C1",
"(",
"ref",
")",
"{",
"if",
"(",
"!",
"A1",
".",
"test",
"(",
"ref",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"ref",
"}",
"`",
")",
"}",
"var",
"refParts",
"=",
"ref",
".",
"replace",
"(",
"A1",
","... | Convert A1 notation to R1C1 notation
@param {String} ref
@returns {String}
@throws {Error} | [
"Convert",
"A1",
"notation",
"to",
"R1C1",
"notation"
] | 0f1c9d94bc71632c8f19b52d72632fd5718e4a26 | https://github.com/mike182uk/cellref/blob/0f1c9d94bc71632c8f19b52d72632fd5718e4a26/index.js#L53-L71 | train |
mike182uk/cellref | index.js | convertR1C1toA1 | function convertR1C1toA1 (ref) {
if (!R1C1.test(ref)) {
throw new Error(`${ref} is not a valid R1C1 cell reference`)
}
var refParts = ref
.replace(R1C1, '$1,$2')
.split(',')
var row = refParts[0]
var column = refParts[1]
var columnStr = ''
for (; column; column = Math.floor((column - 1) / 2... | javascript | function convertR1C1toA1 (ref) {
if (!R1C1.test(ref)) {
throw new Error(`${ref} is not a valid R1C1 cell reference`)
}
var refParts = ref
.replace(R1C1, '$1,$2')
.split(',')
var row = refParts[0]
var column = refParts[1]
var columnStr = ''
for (; column; column = Math.floor((column - 1) / 2... | [
"function",
"convertR1C1toA1",
"(",
"ref",
")",
"{",
"if",
"(",
"!",
"R1C1",
".",
"test",
"(",
"ref",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"ref",
"}",
"`",
")",
"}",
"var",
"refParts",
"=",
"ref",
".",
"replace",
"(",
"R1C1",
... | Convert R1C1 notation to A1 notation
@param {String} ref
@returns {String}
@throws {Error} | [
"Convert",
"R1C1",
"notation",
"to",
"A1",
"notation"
] | 0f1c9d94bc71632c8f19b52d72632fd5718e4a26 | https://github.com/mike182uk/cellref/blob/0f1c9d94bc71632c8f19b52d72632fd5718e4a26/index.js#L81-L99 | train |
bda-research/gearman-node | lib/gearmanode/worker.js | function (data) {
data = data || '';
var jobServer = this.clientOrWorker._getJobServerByUid(this.jobServerUid);
Worker.logger.log('debug', 'work data, handle=%s, data=%s', this.handle, data.toString());
jobServer.send(protocol.encodePacket(protocol.PACKET_TYPES.WORK_DATA, [this.handle, d... | javascript | function (data) {
data = data || '';
var jobServer = this.clientOrWorker._getJobServerByUid(this.jobServerUid);
Worker.logger.log('debug', 'work data, handle=%s, data=%s', this.handle, data.toString());
jobServer.send(protocol.encodePacket(protocol.PACKET_TYPES.WORK_DATA, [this.handle, d... | [
"function",
"(",
"data",
")",
"{",
"data",
"=",
"data",
"||",
"''",
";",
"var",
"jobServer",
"=",
"this",
".",
"clientOrWorker",
".",
"_getJobServerByUid",
"(",
"this",
".",
"jobServerUid",
")",
";",
"Worker",
".",
"logger",
".",
"log",
"(",
"'debug'",
... | This is sent to update the client with data from a running job.
A worker should use this when it needs to send updates,
send partial results, or flush data during long running jobs.
@method
@memberof Job
@param {string|Buffer} data to be sent to client
@returns {void} nothing | [
"This",
"is",
"sent",
"to",
"update",
"the",
"client",
"with",
"data",
"from",
"a",
"running",
"job",
".",
"A",
"worker",
"should",
"use",
"this",
"when",
"it",
"needs",
"to",
"send",
"updates",
"send",
"partial",
"results",
"or",
"flush",
"data",
"durin... | f4df581cea7e184b03a20e27db75beff67e54acc | https://github.com/bda-research/gearman-node/blob/f4df581cea7e184b03a20e27db75beff67e54acc/lib/gearmanode/worker.js#L353-L358 | train | |
bda-research/gearman-node | lib/gearmanode/worker.js | function (packetType, packetData) {
var jobServer = this.clientOrWorker._getJobServerByUid(this.jobServerUid);
jobServer.send(protocol.encodePacket(packetType, packetData));
if(!this.clientOrWorker.readyReset)// ensure the worker won't exit
jobServer.send(protocol.encodePacket(protocol.PACKET_TY... | javascript | function (packetType, packetData) {
var jobServer = this.clientOrWorker._getJobServerByUid(this.jobServerUid);
jobServer.send(protocol.encodePacket(packetType, packetData));
if(!this.clientOrWorker.readyReset)// ensure the worker won't exit
jobServer.send(protocol.encodePacket(protocol.PACKET_TY... | [
"function",
"(",
"packetType",
",",
"packetData",
")",
"{",
"var",
"jobServer",
"=",
"this",
".",
"clientOrWorker",
".",
"_getJobServerByUid",
"(",
"this",
".",
"jobServerUid",
")",
";",
"jobServer",
".",
"send",
"(",
"protocol",
".",
"encodePacket",
"(",
"p... | Re-usable helper method to send data to client and close this job.
@method
@access private | [
"Re",
"-",
"usable",
"helper",
"method",
"to",
"send",
"data",
"to",
"client",
"and",
"close",
"this",
"job",
"."
] | f4df581cea7e184b03a20e27db75beff67e54acc | https://github.com/bda-research/gearman-node/blob/f4df581cea7e184b03a20e27db75beff67e54acc/lib/gearmanode/worker.js#L423-L431 | train | |
ericnishio/finnish-holidays-js | lib/translator.js | function(english, language) {
if (typeof translations[english] !== 'undefined' && typeof translations[english][language] !== 'undefined') {
return translations[english][language];
} else {
return english;
}
} | javascript | function(english, language) {
if (typeof translations[english] !== 'undefined' && typeof translations[english][language] !== 'undefined') {
return translations[english][language];
} else {
return english;
}
} | [
"function",
"(",
"english",
",",
"language",
")",
"{",
"if",
"(",
"typeof",
"translations",
"[",
"english",
"]",
"!==",
"'undefined'",
"&&",
"typeof",
"translations",
"[",
"english",
"]",
"[",
"language",
"]",
"!==",
"'undefined'",
")",
"{",
"return",
"tra... | Translates the name of a holiday.
@param {string} english
@param {string} language
@return {string} | [
"Translates",
"the",
"name",
"of",
"a",
"holiday",
"."
] | 33416bd96b18bf7b18c331c831212aefb2a6f9c2 | https://github.com/ericnishio/finnish-holidays-js/blob/33416bd96b18bf7b18c331c831212aefb2a6f9c2/lib/translator.js#L71-L77 | train | |
souporserious/animation-bus | example/index.js | scrollHandler | function scrollHandler() {
for (let i = 0; i < scrollElements.length; i++) {
animationBus.applyStyles(scrollElements[i])
}
isTicking = false
} | javascript | function scrollHandler() {
for (let i = 0; i < scrollElements.length; i++) {
animationBus.applyStyles(scrollElements[i])
}
isTicking = false
} | [
"function",
"scrollHandler",
"(",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"scrollElements",
".",
"length",
";",
"i",
"++",
")",
"{",
"animationBus",
".",
"applyStyles",
"(",
"scrollElements",
"[",
"i",
"]",
")",
"}",
"isTicking",
"... | Listen for window scroll and apply transforms to elements | [
"Listen",
"for",
"window",
"scroll",
"and",
"apply",
"transforms",
"to",
"elements"
] | 6b711e937533d427cc1e3505836fb0d88fe14974 | https://github.com/souporserious/animation-bus/blob/6b711e937533d427cc1e3505836fb0d88fe14974/example/index.js#L46-L51 | train |
mpayetta/statsd-newrelic-backend | lib/index.js | function (time, metrics) {
/**
* Iterate over every kind of metric we want to send to new relic
*/
options.dispatchMetrics.forEach(function (metricType) {
var statsdKeysForType = metrics[metricType],
statsdKey,
statsdValue,
dispatchMetric = function (dispatc... | javascript | function (time, metrics) {
/**
* Iterate over every kind of metric we want to send to new relic
*/
options.dispatchMetrics.forEach(function (metricType) {
var statsdKeysForType = metrics[metricType],
statsdKey,
statsdValue,
dispatchMetric = function (dispatc... | [
"function",
"(",
"time",
",",
"metrics",
")",
"{",
"/**\n * Iterate over every kind of metric we want to send to new relic\n */",
"options",
".",
"dispatchMetrics",
".",
"forEach",
"(",
"function",
"(",
"metricType",
")",
"{",
"var",
"statsdKeysForType",
"=",
"met... | Handle the flush event triggered by StatsD.
This handler will read the gauges and counters data and send them to New Relic as Custom Metrics
through the agent API recordMetric.
Unless other names are provided as part of the configuration, the Custom Metrics naming
follows the New Relic suggested convention:
- Custom/[... | [
"Handle",
"the",
"flush",
"event",
"triggered",
"by",
"StatsD",
".",
"This",
"handler",
"will",
"read",
"the",
"gauges",
"and",
"counters",
"data",
"and",
"send",
"them",
"to",
"New",
"Relic",
"as",
"Custom",
"Metrics",
"through",
"the",
"agent",
"API",
"r... | 64caaa368d9732c6bab916c91f46492eeb2392ba | https://github.com/mpayetta/statsd-newrelic-backend/blob/64caaa368d9732c6bab916c91f46492eeb2392ba/lib/index.js#L53-L73 | train | |
atmin/freak | freak.js | mixin | function mixin(target, properties) {
Object.keys(properties).forEach(function(prop) {
target[prop] = properties[prop];
});
} | javascript | function mixin(target, properties) {
Object.keys(properties).forEach(function(prop) {
target[prop] = properties[prop];
});
} | [
"function",
"mixin",
"(",
"target",
",",
"properties",
")",
"{",
"Object",
".",
"keys",
"(",
"properties",
")",
".",
"forEach",
"(",
"function",
"(",
"prop",
")",
"{",
"target",
"[",
"prop",
"]",
"=",
"properties",
"[",
"prop",
"]",
";",
"}",
")",
... | Mix properties into target | [
"Mix",
"properties",
"into",
"target"
] | c32494ff1ab60aac2952a998d695023a533b8066 | https://github.com/atmin/freak/blob/c32494ff1ab60aac2952a998d695023a533b8066/freak.js#L11-L15 | train |
atmin/freak | freak.js | off | function off(event, callback) {
if (callback) {
listeners[event].splice(listeners[event].indexOf(callback), 1);
}
else {
listeners[event] = [];
}
} | javascript | function off(event, callback) {
if (callback) {
listeners[event].splice(listeners[event].indexOf(callback), 1);
}
else {
listeners[event] = [];
}
} | [
"function",
"off",
"(",
"event",
",",
"callback",
")",
"{",
"if",
"(",
"callback",
")",
"{",
"listeners",
"[",
"event",
"]",
".",
"splice",
"(",
"listeners",
"[",
"event",
"]",
".",
"indexOf",
"(",
"callback",
")",
",",
"1",
")",
";",
"}",
"else",
... | Remove all or specified listeners given event and property | [
"Remove",
"all",
"or",
"specified",
"listeners",
"given",
"event",
"and",
"property"
] | c32494ff1ab60aac2952a998d695023a533b8066 | https://github.com/atmin/freak/blob/c32494ff1ab60aac2952a998d695023a533b8066/freak.js#L36-L43 | train |
atmin/freak | freak.js | tracker | function tracker(prop) {
function _tracker(context) {
return function(_prop, _arg) {
context.deps[_prop] = context.deps[_prop] || [];
if (!context.deps[_prop].reduce(function found(prev, curr) {
return prev || (curr[0] === prop);
}, false)) {
context.deps[_p... | javascript | function tracker(prop) {
function _tracker(context) {
return function(_prop, _arg) {
context.deps[_prop] = context.deps[_prop] || [];
if (!context.deps[_prop].reduce(function found(prev, curr) {
return prev || (curr[0] === prop);
}, false)) {
context.deps[_p... | [
"function",
"tracker",
"(",
"prop",
")",
"{",
"function",
"_tracker",
"(",
"context",
")",
"{",
"return",
"function",
"(",
"_prop",
",",
"_arg",
")",
"{",
"context",
".",
"deps",
"[",
"_prop",
"]",
"=",
"context",
".",
"deps",
"[",
"_prop",
"]",
"||"... | Proxy the accessor function to record all accessed properties | [
"Proxy",
"the",
"accessor",
"function",
"to",
"record",
"all",
"accessed",
"properties"
] | c32494ff1ab60aac2952a998d695023a533b8066 | https://github.com/atmin/freak/blob/c32494ff1ab60aac2952a998d695023a533b8066/freak.js#L89-L106 | train |
atmin/freak | freak.js | _get | function _get(prop) {
var val = obj[prop];
return cache[prop] = (typeof val === 'function') ?
val.call(tracker(prop)) : val;
} | javascript | function _get(prop) {
var val = obj[prop];
return cache[prop] = (typeof val === 'function') ?
val.call(tracker(prop)) : val;
} | [
"function",
"_get",
"(",
"prop",
")",
"{",
"var",
"val",
"=",
"obj",
"[",
"prop",
"]",
";",
"return",
"cache",
"[",
"prop",
"]",
"=",
"(",
"typeof",
"val",
"===",
"'function'",
")",
"?",
"val",
".",
"call",
"(",
"tracker",
"(",
"prop",
")",
")",
... | Getter for prop | [
"Getter",
"for",
"prop"
] | c32494ff1ab60aac2952a998d695023a533b8066 | https://github.com/atmin/freak/blob/c32494ff1ab60aac2952a998d695023a533b8066/freak.js#L109-L113 | train |
atmin/freak | freak.js | setter | function setter(prop, val) {
var oldVal = _get(prop);
if (typeof obj[prop] === 'function') {
// Computed property setter
obj[prop].call(tracker(prop), val);
}
else {
// Simple property
obj[prop] = val;
}
delete cache[prop];
delete children[prop];
return (oldVal... | javascript | function setter(prop, val) {
var oldVal = _get(prop);
if (typeof obj[prop] === 'function') {
// Computed property setter
obj[prop].call(tracker(prop), val);
}
else {
// Simple property
obj[prop] = val;
}
delete cache[prop];
delete children[prop];
return (oldVal... | [
"function",
"setter",
"(",
"prop",
",",
"val",
")",
"{",
"var",
"oldVal",
"=",
"_get",
"(",
"prop",
")",
";",
"if",
"(",
"typeof",
"obj",
"[",
"prop",
"]",
"===",
"'function'",
")",
"{",
"// Computed property setter",
"obj",
"[",
"prop",
"]",
".",
"c... | Set prop to val | [
"Set",
"prop",
"to",
"val"
] | c32494ff1ab60aac2952a998d695023a533b8066 | https://github.com/atmin/freak/blob/c32494ff1ab60aac2952a998d695023a533b8066/freak.js#L127-L143 | train |
atmin/freak | freak.js | accessor | function accessor(prop, arg) {
return (arg === undefined) ? getter(prop) : setter(prop, arg);
} | javascript | function accessor(prop, arg) {
return (arg === undefined) ? getter(prop) : setter(prop, arg);
} | [
"function",
"accessor",
"(",
"prop",
",",
"arg",
")",
"{",
"return",
"(",
"arg",
"===",
"undefined",
")",
"?",
"getter",
"(",
"prop",
")",
":",
"setter",
"(",
"prop",
",",
"arg",
")",
";",
"}"
] | Functional accessor, unify getter and setter | [
"Functional",
"accessor",
"unify",
"getter",
"and",
"setter"
] | c32494ff1ab60aac2952a998d695023a533b8066 | https://github.com/atmin/freak/blob/c32494ff1ab60aac2952a998d695023a533b8066/freak.js#L146-L148 | train |
atmin/freak | freak.js | construct | function construct(target) {
mixin(target, {
values: obj,
parent: parent || null,
root: root || target,
prop: prop === undefined ? null : prop,
// .on(event[, prop], callback)
on: on,
// .off(event[, prop][, callback])
off: off,
// .trigger(event[, prop])
... | javascript | function construct(target) {
mixin(target, {
values: obj,
parent: parent || null,
root: root || target,
prop: prop === undefined ? null : prop,
// .on(event[, prop], callback)
on: on,
// .off(event[, prop][, callback])
off: off,
// .trigger(event[, prop])
... | [
"function",
"construct",
"(",
"target",
")",
"{",
"mixin",
"(",
"target",
",",
"{",
"values",
":",
"obj",
",",
"parent",
":",
"parent",
"||",
"null",
",",
"root",
":",
"root",
"||",
"target",
",",
"prop",
":",
"prop",
"===",
"undefined",
"?",
"null",... | Attach instance members | [
"Attach",
"instance",
"members"
] | c32494ff1ab60aac2952a998d695023a533b8066 | https://github.com/atmin/freak/blob/c32494ff1ab60aac2952a998d695023a533b8066/freak.js#L151-L243 | train |
atmin/freak | freak.js | wrapMutatingArrayMethod | function wrapMutatingArrayMethod(method, func) {
return function() {
var result = [][method].apply(obj, arguments);
this.len = this.values.length;
cache = {};
children = {};
func.apply(this, arguments);
target.parent.trigger('update', target.prop);
return re... | javascript | function wrapMutatingArrayMethod(method, func) {
return function() {
var result = [][method].apply(obj, arguments);
this.len = this.values.length;
cache = {};
children = {};
func.apply(this, arguments);
target.parent.trigger('update', target.prop);
return re... | [
"function",
"wrapMutatingArrayMethod",
"(",
"method",
",",
"func",
")",
"{",
"return",
"function",
"(",
")",
"{",
"var",
"result",
"=",
"[",
"]",
"[",
"method",
"]",
".",
"apply",
"(",
"obj",
",",
"arguments",
")",
";",
"this",
".",
"len",
"=",
"this... | Wrap mutating array method to update state and notify listeners | [
"Wrap",
"mutating",
"array",
"method",
"to",
"update",
"state",
"and",
"notify",
"listeners"
] | c32494ff1ab60aac2952a998d695023a533b8066 | https://github.com/atmin/freak/blob/c32494ff1ab60aac2952a998d695023a533b8066/freak.js#L170-L180 | train |
rkirsling/formula-parser | formulaParser.js | matchOperator | function matchOperator(str, operatorList) {
return operatorList.reduce((match, operator) => {
return match ||
(str.startsWith(operator.symbol) ? operator : null);
}, null);
} | javascript | function matchOperator(str, operatorList) {
return operatorList.reduce((match, operator) => {
return match ||
(str.startsWith(operator.symbol) ? operator : null);
}, null);
} | [
"function",
"matchOperator",
"(",
"str",
",",
"operatorList",
")",
"{",
"return",
"operatorList",
".",
"reduce",
"(",
"(",
"match",
",",
"operator",
")",
"=>",
"{",
"return",
"match",
"||",
"(",
"str",
".",
"startsWith",
"(",
"operator",
".",
"symbol",
"... | Attempts to match a given list of operators against the head of a given string.
Returns the first match if successful, otherwise null.
@private
@static
@param {string} str - a string to match against
@param {Object[]} operatorList - an array of operator definitions, sorted by longest symbol
@returns {?Objec... | [
"Attempts",
"to",
"match",
"a",
"given",
"list",
"of",
"operators",
"against",
"the",
"head",
"of",
"a",
"given",
"string",
".",
"Returns",
"the",
"first",
"match",
"if",
"successful",
"otherwise",
"null",
"."
] | 8f792a333339231f8bfc38a315b777bdd7207ef2 | https://github.com/rkirsling/formula-parser/blob/8f792a333339231f8bfc38a315b777bdd7207ef2/formulaParser.js#L28-L33 | train |
rkirsling/formula-parser | formulaParser.js | _parseParenthesizedSubformula | function _parseParenthesizedSubformula(self, currentString) {
if (currentString.charAt(0) !== '(') {
return null;
}
const parsedSubformula = _parseFormula(self, sliceSymbol(currentString, '('), MIN_PRECEDENCE);
if (parsedSubformula.remainder.charAt(0) !== ')') {
throw new SyntaxError('Invalid formula! ... | javascript | function _parseParenthesizedSubformula(self, currentString) {
if (currentString.charAt(0) !== '(') {
return null;
}
const parsedSubformula = _parseFormula(self, sliceSymbol(currentString, '('), MIN_PRECEDENCE);
if (parsedSubformula.remainder.charAt(0) !== ')') {
throw new SyntaxError('Invalid formula! ... | [
"function",
"_parseParenthesizedSubformula",
"(",
"self",
",",
"currentString",
")",
"{",
"if",
"(",
"currentString",
".",
"charAt",
"(",
"0",
")",
"!==",
"'('",
")",
"{",
"return",
"null",
";",
"}",
"const",
"parsedSubformula",
"=",
"_parseFormula",
"(",
"s... | Attempts to parse a parenthesized subformula at the head of a given string.
Returns an AST node and string remainder if successful, otherwise null.
@private
@param {FormulaParser} self
@param {string} currentString - remainder of input string left to parse
@returns {?Object} | [
"Attempts",
"to",
"parse",
"a",
"parenthesized",
"subformula",
"at",
"the",
"head",
"of",
"a",
"given",
"string",
".",
"Returns",
"an",
"AST",
"node",
"and",
"string",
"remainder",
"if",
"successful",
"otherwise",
"null",
"."
] | 8f792a333339231f8bfc38a315b777bdd7207ef2 | https://github.com/rkirsling/formula-parser/blob/8f792a333339231f8bfc38a315b777bdd7207ef2/formulaParser.js#L65-L79 | train |
rkirsling/formula-parser | formulaParser.js | _parseUnarySubformula | function _parseUnarySubformula(self, currentString) {
const unary = matchOperator(currentString, self.unaries);
if (!unary) {
return null;
}
const parsedSubformula = _parseFormula(self, sliceSymbol(currentString, unary.symbol), unary.precedence);
return {
json: { [unary.key]: parsedSubformula.json }... | javascript | function _parseUnarySubformula(self, currentString) {
const unary = matchOperator(currentString, self.unaries);
if (!unary) {
return null;
}
const parsedSubformula = _parseFormula(self, sliceSymbol(currentString, unary.symbol), unary.precedence);
return {
json: { [unary.key]: parsedSubformula.json }... | [
"function",
"_parseUnarySubformula",
"(",
"self",
",",
"currentString",
")",
"{",
"const",
"unary",
"=",
"matchOperator",
"(",
"currentString",
",",
"self",
".",
"unaries",
")",
";",
"if",
"(",
"!",
"unary",
")",
"{",
"return",
"null",
";",
"}",
"const",
... | Attempts to parse a unary subformula at the head of a given string.
Returns an AST node and string remainder if successful, otherwise null.
@private
@param {FormulaParser} self
@param {string} currentString - remainder of input string left to parse
@returns {?Object} | [
"Attempts",
"to",
"parse",
"a",
"unary",
"subformula",
"at",
"the",
"head",
"of",
"a",
"given",
"string",
".",
"Returns",
"an",
"AST",
"node",
"and",
"string",
"remainder",
"if",
"successful",
"otherwise",
"null",
"."
] | 8f792a333339231f8bfc38a315b777bdd7207ef2 | https://github.com/rkirsling/formula-parser/blob/8f792a333339231f8bfc38a315b777bdd7207ef2/formulaParser.js#L90-L102 | train |
rkirsling/formula-parser | formulaParser.js | _parseBinarySubformula | function _parseBinarySubformula(self, currentString, currentPrecedence, leftOperandJSON) {
const binary = matchOperator(currentString, self.binaries);
if (!binary || binary.precedence < currentPrecedence) {
return null;
}
const nextPrecedence = binary.precedence + (binary.associativity === 'left');
const... | javascript | function _parseBinarySubformula(self, currentString, currentPrecedence, leftOperandJSON) {
const binary = matchOperator(currentString, self.binaries);
if (!binary || binary.precedence < currentPrecedence) {
return null;
}
const nextPrecedence = binary.precedence + (binary.associativity === 'left');
const... | [
"function",
"_parseBinarySubformula",
"(",
"self",
",",
"currentString",
",",
"currentPrecedence",
",",
"leftOperandJSON",
")",
"{",
"const",
"binary",
"=",
"matchOperator",
"(",
"currentString",
",",
"self",
".",
"binaries",
")",
";",
"if",
"(",
"!",
"binary",
... | Attempts to parse a binary subformula at the head of a given string,
given a lower precedence bound and an AST node to be used as a left operand.
Returns an AST node and string remainder if successful, otherwise null.
@private
@param {FormulaParser} self
@param {string} currentString - remainder of input st... | [
"Attempts",
"to",
"parse",
"a",
"binary",
"subformula",
"at",
"the",
"head",
"of",
"a",
"given",
"string",
"given",
"a",
"lower",
"precedence",
"bound",
"and",
"an",
"AST",
"node",
"to",
"be",
"used",
"as",
"a",
"left",
"operand",
".",
"Returns",
"an",
... | 8f792a333339231f8bfc38a315b777bdd7207ef2 | https://github.com/rkirsling/formula-parser/blob/8f792a333339231f8bfc38a315b777bdd7207ef2/formulaParser.js#L116-L129 | train |
chrahunt/tagpro-navmesh | src/partition.js | convertPolyToP2TPoly | function convertPolyToP2TPoly(poly) {
return poly.points.map(function(p) {
return new poly2tri.Point(p.x, p.y);
});
} | javascript | function convertPolyToP2TPoly(poly) {
return poly.points.map(function(p) {
return new poly2tri.Point(p.x, p.y);
});
} | [
"function",
"convertPolyToP2TPoly",
"(",
"poly",
")",
"{",
"return",
"poly",
".",
"points",
".",
"map",
"(",
"function",
"(",
"p",
")",
"{",
"return",
"new",
"poly2tri",
".",
"Point",
"(",
"p",
".",
"x",
",",
"p",
".",
"y",
")",
";",
"}",
")",
";... | A polygon for use with poly2tri.
@private
@typedef P2TPoly
@type {Array.<P2TPoint>}
Convert a polygon into format required by poly2tri.
@private
@param {Poly} poly - The polygon to convert.
@return {P2TPoly} - The converted polygon. | [
"A",
"polygon",
"for",
"use",
"with",
"poly2tri",
"."
] | b50fbdad1061fb4760ac22ee756f34ab3e177539 | https://github.com/chrahunt/tagpro-navmesh/blob/b50fbdad1061fb4760ac22ee756f34ab3e177539/src/partition.js#L33-L37 | train |
chrahunt/tagpro-navmesh | src/partition.js | separatePolys | function separatePolys(polys, offset) {
offset = offset || 1;
var discovered = {};
var dupes = {};
// Offset to use in calculation.
// Find duplicates.
for (var s1 = 0; s1 < polys.length; s1++) {
var poly = polys[s1];
for (var i = 0; i < poly.numpoints; i++) {
var point = poly.points[i].toStri... | javascript | function separatePolys(polys, offset) {
offset = offset || 1;
var discovered = {};
var dupes = {};
// Offset to use in calculation.
// Find duplicates.
for (var s1 = 0; s1 < polys.length; s1++) {
var poly = polys[s1];
for (var i = 0; i < poly.numpoints; i++) {
var point = poly.points[i].toStri... | [
"function",
"separatePolys",
"(",
"polys",
",",
"offset",
")",
"{",
"offset",
"=",
"offset",
"||",
"1",
";",
"var",
"discovered",
"=",
"{",
"}",
";",
"var",
"dupes",
"=",
"{",
"}",
";",
"// Offset to use in calculation.",
"// Find duplicates.",
"for",
"(",
... | Takes an array of polygons that overlap themselves and others
at discrete corner points and separate those overlapping corners
slightly so the polygons are suitable for triangulation by
poly2tri.js. This changes the Poly objects in the array.
@private
@param {Array.<Poly>} polys - The polygons to separate.
@param {numb... | [
"Takes",
"an",
"array",
"of",
"polygons",
"that",
"overlap",
"themselves",
"and",
"others",
"at",
"discrete",
"corner",
"points",
"and",
"separate",
"those",
"overlapping",
"corners",
"slightly",
"so",
"the",
"polygons",
"are",
"suitable",
"for",
"triangulation",
... | b50fbdad1061fb4760ac22ee756f34ab3e177539 | https://github.com/chrahunt/tagpro-navmesh/blob/b50fbdad1061fb4760ac22ee756f34ab3e177539/src/partition.js#L69-L118 | train |
ericnishio/finnish-holidays-js | lib/calendar.js | function(count, includeWeekends) {
initialize();
count = count || 3;
includeWeekends = includeWeekends || false;
var self = this;
var holidays = [];
if (count > self.MAX_HOLIDAYS) {
throw Error('Cannot request more than {MAX_HOLIDAYS} holidays at once.'.replace('{MAX HOLIDAYS}', self.MA... | javascript | function(count, includeWeekends) {
initialize();
count = count || 3;
includeWeekends = includeWeekends || false;
var self = this;
var holidays = [];
if (count > self.MAX_HOLIDAYS) {
throw Error('Cannot request more than {MAX_HOLIDAYS} holidays at once.'.replace('{MAX HOLIDAYS}', self.MA... | [
"function",
"(",
"count",
",",
"includeWeekends",
")",
"{",
"initialize",
"(",
")",
";",
"count",
"=",
"count",
"||",
"3",
";",
"includeWeekends",
"=",
"includeWeekends",
"||",
"false",
";",
"var",
"self",
"=",
"this",
";",
"var",
"holidays",
"=",
"[",
... | Returns the next holidays.
@param {number} [count] number of holidays to list (default: 3)
@param {boolean} [includeWeekends] include holidays falling on a weekend (default: false)
@return {Array} | [
"Returns",
"the",
"next",
"holidays",
"."
] | 33416bd96b18bf7b18c331c831212aefb2a6f9c2 | https://github.com/ericnishio/finnish-holidays-js/blob/33416bd96b18bf7b18c331c831212aefb2a6f9c2/lib/calendar.js#L13-L52 | train | |
ericnishio/finnish-holidays-js | lib/calendar.js | collectHolidays | function collectHolidays() {
if (typeof self.year.holidays[self.m] !== 'undefined' && typeof self.year.holidays[self.m] !== 'undefined') {
self.year.holidays[self.m].forEach(function(holiday) {
if (holidays.length < count && holiday.day >= self.d) {
holidays.push(holiday);
... | javascript | function collectHolidays() {
if (typeof self.year.holidays[self.m] !== 'undefined' && typeof self.year.holidays[self.m] !== 'undefined') {
self.year.holidays[self.m].forEach(function(holiday) {
if (holidays.length < count && holiday.day >= self.d) {
holidays.push(holiday);
... | [
"function",
"collectHolidays",
"(",
")",
"{",
"if",
"(",
"typeof",
"self",
".",
"year",
".",
"holidays",
"[",
"self",
".",
"m",
"]",
"!==",
"'undefined'",
"&&",
"typeof",
"self",
".",
"year",
".",
"holidays",
"[",
"self",
".",
"m",
"]",
"!==",
"'unde... | Collects holidays. | [
"Collects",
"holidays",
"."
] | 33416bd96b18bf7b18c331c831212aefb2a6f9c2 | https://github.com/ericnishio/finnish-holidays-js/blob/33416bd96b18bf7b18c331c831212aefb2a6f9c2/lib/calendar.js#L29-L37 | train |
ericnishio/finnish-holidays-js | lib/calendar.js | function(year, includeWeekends) {
initialize(year);
includeWeekends = includeWeekends || false;
var self = this;
var holidays = [];
if (!includeWeekends) {
self.year.discardWeekends();
}
Object.keys(self.year.holidays).forEach(function(month) {
self.year.holidays[month].forEa... | javascript | function(year, includeWeekends) {
initialize(year);
includeWeekends = includeWeekends || false;
var self = this;
var holidays = [];
if (!includeWeekends) {
self.year.discardWeekends();
}
Object.keys(self.year.holidays).forEach(function(month) {
self.year.holidays[month].forEa... | [
"function",
"(",
"year",
",",
"includeWeekends",
")",
"{",
"initialize",
"(",
"year",
")",
";",
"includeWeekends",
"=",
"includeWeekends",
"||",
"false",
";",
"var",
"self",
"=",
"this",
";",
"var",
"holidays",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"incl... | Returns holidays by year.
@param {number} year
@param {boolean} [includeWeekends] include holidays falling on a weekend (default: false)
@return {Array} | [
"Returns",
"holidays",
"by",
"year",
"."
] | 33416bd96b18bf7b18c331c831212aefb2a6f9c2 | https://github.com/ericnishio/finnish-holidays-js/blob/33416bd96b18bf7b18c331c831212aefb2a6f9c2/lib/calendar.js#L60-L79 | train | |
ericnishio/finnish-holidays-js | lib/calendar.js | function(month, year, includeWeekends) {
initialize(year, month);
includeWeekends = includeWeekends || false;
if (!month || !year) {
throw Error('Month or year missing.');
}
var self = this;
var holidays = [];
if (!includeWeekends) {
self.year.discardWeekends();
}
if... | javascript | function(month, year, includeWeekends) {
initialize(year, month);
includeWeekends = includeWeekends || false;
if (!month || !year) {
throw Error('Month or year missing.');
}
var self = this;
var holidays = [];
if (!includeWeekends) {
self.year.discardWeekends();
}
if... | [
"function",
"(",
"month",
",",
"year",
",",
"includeWeekends",
")",
"{",
"initialize",
"(",
"year",
",",
"month",
")",
";",
"includeWeekends",
"=",
"includeWeekends",
"||",
"false",
";",
"if",
"(",
"!",
"month",
"||",
"!",
"year",
")",
"{",
"throw",
"E... | Returns holidays by month and year.
@param {number} month
@param {number} year
@param {boolean} [includeWeekends] include holidays falling on a weekend (default: false) | [
"Returns",
"holidays",
"by",
"month",
"and",
"year",
"."
] | 33416bd96b18bf7b18c331c831212aefb2a6f9c2 | https://github.com/ericnishio/finnish-holidays-js/blob/33416bd96b18bf7b18c331c831212aefb2a6f9c2/lib/calendar.js#L87-L110 | train | |
ericnishio/finnish-holidays-js | lib/calendar.js | initialize | function initialize(y, m, d) {
var today = dateUtils.today();
var thisDay = dateUtils.getDay(today);
var thisMonth = dateUtils.getMonth(today);
var thisYear = dateUtils.getYear(today);
calendar.y = y || thisYear;
calendar.m = m || thisMonth;
calendar.d = d || thisDay;
calendar.year = yearFactory.get(c... | javascript | function initialize(y, m, d) {
var today = dateUtils.today();
var thisDay = dateUtils.getDay(today);
var thisMonth = dateUtils.getMonth(today);
var thisYear = dateUtils.getYear(today);
calendar.y = y || thisYear;
calendar.m = m || thisMonth;
calendar.d = d || thisDay;
calendar.year = yearFactory.get(c... | [
"function",
"initialize",
"(",
"y",
",",
"m",
",",
"d",
")",
"{",
"var",
"today",
"=",
"dateUtils",
".",
"today",
"(",
")",
";",
"var",
"thisDay",
"=",
"dateUtils",
".",
"getDay",
"(",
"today",
")",
";",
"var",
"thisMonth",
"=",
"dateUtils",
".",
"... | Initializes the calendar.
@param {number} [y] year (default: this year)
@param {number} [m] month (default: this month)
@param {number} [d] day (default: this day)
@private | [
"Initializes",
"the",
"calendar",
"."
] | 33416bd96b18bf7b18c331c831212aefb2a6f9c2 | https://github.com/ericnishio/finnish-holidays-js/blob/33416bd96b18bf7b18c331c831212aefb2a6f9c2/lib/calendar.js#L120-L131 | train |
ericnishio/finnish-holidays-js | lib/calendar.js | nextMonth | function nextMonth() {
if (calendar.m === 12) {
calendar.m = 1;
calendar.y += 1;
calendar.d = 1;
} else {
calendar.m += 1;
calendar.d = 1;
}
calendar.year = yearFactory.get(calendar.y);
} | javascript | function nextMonth() {
if (calendar.m === 12) {
calendar.m = 1;
calendar.y += 1;
calendar.d = 1;
} else {
calendar.m += 1;
calendar.d = 1;
}
calendar.year = yearFactory.get(calendar.y);
} | [
"function",
"nextMonth",
"(",
")",
"{",
"if",
"(",
"calendar",
".",
"m",
"===",
"12",
")",
"{",
"calendar",
".",
"m",
"=",
"1",
";",
"calendar",
".",
"y",
"+=",
"1",
";",
"calendar",
".",
"d",
"=",
"1",
";",
"}",
"else",
"{",
"calendar",
".",
... | Goes to the next month.
@private | [
"Goes",
"to",
"the",
"next",
"month",
"."
] | 33416bd96b18bf7b18c331c831212aefb2a6f9c2 | https://github.com/ericnishio/finnish-holidays-js/blob/33416bd96b18bf7b18c331c831212aefb2a6f9c2/lib/calendar.js#L137-L148 | train |
julescarbon/grunt-dentist | tasks/dentist.js | parse_html | function parse_html() {
var reading_js = false, reading_css = false;
var parser = new htmlparser.Parser({
onopentag: function(name, attribs){
if (name === "script" && ! attribs.src && (attribs.type === "text/javascript" || ! attribs.type)){
reading_js = true;
}
... | javascript | function parse_html() {
var reading_js = false, reading_css = false;
var parser = new htmlparser.Parser({
onopentag: function(name, attribs){
if (name === "script" && ! attribs.src && (attribs.type === "text/javascript" || ! attribs.type)){
reading_js = true;
}
... | [
"function",
"parse_html",
"(",
")",
"{",
"var",
"reading_js",
"=",
"false",
",",
"reading_css",
"=",
"false",
";",
"var",
"parser",
"=",
"new",
"htmlparser",
".",
"Parser",
"(",
"{",
"onopentag",
":",
"function",
"(",
"name",
",",
"attribs",
")",
"{",
... | Use the HTML parser to grab anything inside script and style tags. | [
"Use",
"the",
"HTML",
"parser",
"to",
"grab",
"anything",
"inside",
"script",
"and",
"style",
"tags",
"."
] | d6dc4921f67bf521fb044fdb89bffe9cbdeacbbb | https://github.com/julescarbon/grunt-dentist/blob/d6dc4921f67bf521fb044fdb89bffe9cbdeacbbb/tasks/dentist.js#L83-L115 | train |
julescarbon/grunt-dentist | tasks/dentist.js | remove_inline_scripts | function remove_inline_scripts(){
for (var i = 0; i < scripts.length; i++) {
if (scripts[i].length && scripts[i] !== "\n") {
html = html.replace(scripts[i], "");
}
}
} | javascript | function remove_inline_scripts(){
for (var i = 0; i < scripts.length; i++) {
if (scripts[i].length && scripts[i] !== "\n") {
html = html.replace(scripts[i], "");
}
}
} | [
"function",
"remove_inline_scripts",
"(",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"scripts",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"scripts",
"[",
"i",
"]",
".",
"length",
"&&",
"scripts",
"[",
"i",
"]",
"!==",
... | Remove inlined scripts from HTML | [
"Remove",
"inlined",
"scripts",
"from",
"HTML"
] | d6dc4921f67bf521fb044fdb89bffe9cbdeacbbb | https://github.com/julescarbon/grunt-dentist/blob/d6dc4921f67bf521fb044fdb89bffe9cbdeacbbb/tasks/dentist.js#L118-L124 | train |
julescarbon/grunt-dentist | tasks/dentist.js | remove_inline_stylesheets | function remove_inline_stylesheets(){
for (var i = 0; i < styles.length; i++) {
if (styles[i].length && styles[i] !== "\n") {
html = html.replace(styles[i], "");
}
}
} | javascript | function remove_inline_stylesheets(){
for (var i = 0; i < styles.length; i++) {
if (styles[i].length && styles[i] !== "\n") {
html = html.replace(styles[i], "");
}
}
} | [
"function",
"remove_inline_stylesheets",
"(",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"styles",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"styles",
"[",
"i",
"]",
".",
"length",
"&&",
"styles",
"[",
"i",
"]",
"!==",
... | Remove inlined stylesheets from HTML | [
"Remove",
"inlined",
"stylesheets",
"from",
"HTML"
] | d6dc4921f67bf521fb044fdb89bffe9cbdeacbbb | https://github.com/julescarbon/grunt-dentist/blob/d6dc4921f67bf521fb044fdb89bffe9cbdeacbbb/tasks/dentist.js#L127-L133 | 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.