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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ibm-bluemix-mobile-services/bms-monitoring-sdk-node | bluemix.js | refreshProxyAccessToken | function refreshProxyAccessToken() {
settings.AZTokenProvider().then(function(token) {
proxyAccessToken = token;
logger.log('Refreshed proxy access token: ' + proxyAccessToken);
}, function(err) {
logger.log(err);
emitter.emit('error', 'Unable to refresh a... | javascript | function refreshProxyAccessToken() {
settings.AZTokenProvider().then(function(token) {
proxyAccessToken = token;
logger.log('Refreshed proxy access token: ' + proxyAccessToken);
}, function(err) {
logger.log(err);
emitter.emit('error', 'Unable to refresh a... | [
"function",
"refreshProxyAccessToken",
"(",
")",
"{",
"settings",
".",
"AZTokenProvider",
"(",
")",
".",
"then",
"(",
"function",
"(",
"token",
")",
"{",
"proxyAccessToken",
"=",
"token",
";",
"logger",
".",
"log",
"(",
"'Refreshed proxy access token: '",
"+",
... | After invoking this function, one must invoke elasticsearchOptions again in order for new access token to be used. | [
"After",
"invoking",
"this",
"function",
"one",
"must",
"invoke",
"elasticsearchOptions",
"again",
"in",
"order",
"for",
"new",
"access",
"token",
"to",
"be",
"used",
"."
] | 5b26fbd3b8adacb3fa9f4a0cbd60c8eae1a44df9 | https://github.com/ibm-bluemix-mobile-services/bms-monitoring-sdk-node/blob/5b26fbd3b8adacb3fa9f4a0cbd60c8eae1a44df9/bluemix.js#L239-L248 | train |
dalekjs/dalek-driver-sauce | lib/commands/screenshot.js | function (path, pathname, hash, uuid) {
this.actionQueue.push(this.webdriverClient.screenshot.bind(this.webdriverClient));
this.actionQueue.push(this._screenshotCb.bind(this, path, pathname, hash, uuid));
return this;
} | javascript | function (path, pathname, hash, uuid) {
this.actionQueue.push(this.webdriverClient.screenshot.bind(this.webdriverClient));
this.actionQueue.push(this._screenshotCb.bind(this, path, pathname, hash, uuid));
return this;
} | [
"function",
"(",
"path",
",",
"pathname",
",",
"hash",
",",
"uuid",
")",
"{",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"screenshot",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
")",
")",
";",
"this",
".",... | Makes an screenshot of the current page
@method screenshot
@param {string} path Root directory path
@param {string} pathname Pathname of the screenshot path
@param {string} hash Unique hash of that fn call
@param {string} uuid Unique hash of that fn call
@chainable | [
"Makes",
"an",
"screenshot",
"of",
"the",
"current",
"page"
] | 4b3ef87a0c35a91db8456d074b0d47a3e0df58f7 | https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/screenshot.js#L52-L56 | train | |
dalekjs/dalek-driver-sauce | lib/commands/screenshot.js | function (path, pathname, hash, uuid, result) {
var deferred = Q.defer();
// replace base64 metadata
var base64Data = JSON.parse(result).value.replace(/^data:image\/png;base64,/,'');
// replace placeholders
var realpath = this._replacePathPlaceholder(path + pathname);
// check if we need to add ... | javascript | function (path, pathname, hash, uuid, result) {
var deferred = Q.defer();
// replace base64 metadata
var base64Data = JSON.parse(result).value.replace(/^data:image\/png;base64,/,'');
// replace placeholders
var realpath = this._replacePathPlaceholder(path + pathname);
// check if we need to add ... | [
"function",
"(",
"path",
",",
"pathname",
",",
"hash",
",",
"uuid",
",",
"result",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"// replace base64 metadata",
"var",
"base64Data",
"=",
"JSON",
".",
"parse",
"(",
"result",
")",
"."... | Sends out an event with the results of the `screenshot` call
and stores the screenshot in the filesystem
@method _screenshotCb
@param {string} path Root directory path
@param {string} pathname Pathname of the screenshot path
@param {string} hash Unique hash of that fn call
@param {string} uuid Unique hash of that fn c... | [
"Sends",
"out",
"an",
"event",
"with",
"the",
"results",
"of",
"the",
"screenshot",
"call",
"and",
"stores",
"the",
"screenshot",
"in",
"the",
"filesystem"
] | 4b3ef87a0c35a91db8456d074b0d47a3e0df58f7 | https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/screenshot.js#L72-L85 | train | |
dalekjs/dalek-driver-sauce | lib/commands/screenshot.js | function (pathname) {
pathname = pathname.replace(':browser', this.browserName);
pathname = pathname.replace(':version', this._parseBrowserVersion(this.sessionStatus.version));
pathname = pathname.replace(':timestamp', Math.round(new Date().getTime() / 1000));
pathname = pathname.replace(':osVersion', t... | javascript | function (pathname) {
pathname = pathname.replace(':browser', this.browserName);
pathname = pathname.replace(':version', this._parseBrowserVersion(this.sessionStatus.version));
pathname = pathname.replace(':timestamp', Math.round(new Date().getTime() / 1000));
pathname = pathname.replace(':osVersion', t... | [
"function",
"(",
"pathname",
")",
"{",
"pathname",
"=",
"pathname",
".",
"replace",
"(",
"':browser'",
",",
"this",
".",
"browserName",
")",
";",
"pathname",
"=",
"pathname",
".",
"replace",
"(",
"':version'",
",",
"this",
".",
"_parseBrowserVersion",
"(",
... | Return the formatted os name
@method _parseOS
@param {string} Pathname
@return {string} Formatted pathname
@private | [
"Return",
"the",
"formatted",
"os",
"name"
] | 4b3ef87a0c35a91db8456d074b0d47a3e0df58f7 | https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/screenshot.js#L121-L131 | train | |
dalekjs/dalek-driver-sauce | lib/commands/screenshot.js | function (version) {
var vs = version.replace(/[^0-9\\.]/g, '');
vs = vs.replace(/\./g, '_');
return vs;
} | javascript | function (version) {
var vs = version.replace(/[^0-9\\.]/g, '');
vs = vs.replace(/\./g, '_');
return vs;
} | [
"function",
"(",
"version",
")",
"{",
"var",
"vs",
"=",
"version",
".",
"replace",
"(",
"/",
"[^0-9\\\\.]",
"/",
"g",
",",
"''",
")",
";",
"vs",
"=",
"vs",
".",
"replace",
"(",
"/",
"\\.",
"/",
"g",
",",
"'_'",
")",
";",
"return",
"vs",
";",
... | Return the formatted os version
@method _parseOSVersion
@return {string} OS version
@private | [
"Return",
"the",
"formatted",
"os",
"version"
] | 4b3ef87a0c35a91db8456d074b0d47a3e0df58f7 | https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/screenshot.js#L157-L161 | train | |
dalekjs/dalek-driver-sauce | lib/commands/screenshot.js | function () {
var date = new Date();
var dateStr = '';
var day = date.getDate();
var month = date.getMonth();
month = (month+'').length === 1 ? '0' + month : month;
day = (day+'').length === 1 ? '0' + day : day;
dateStr += month + '_';
dateStr += day + '_';
dateStr += date.getFullY... | javascript | function () {
var date = new Date();
var dateStr = '';
var day = date.getDate();
var month = date.getMonth();
month = (month+'').length === 1 ? '0' + month : month;
day = (day+'').length === 1 ? '0' + day : day;
dateStr += month + '_';
dateStr += day + '_';
dateStr += date.getFullY... | [
"function",
"(",
")",
"{",
"var",
"date",
"=",
"new",
"Date",
"(",
")",
";",
"var",
"dateStr",
"=",
"''",
";",
"var",
"day",
"=",
"date",
".",
"getDate",
"(",
")",
";",
"var",
"month",
"=",
"date",
".",
"getMonth",
"(",
")",
";",
"month",
"=",
... | Return the formatted date
@method _parseDate
@return {string} Date
@private | [
"Return",
"the",
"formatted",
"date"
] | 4b3ef87a0c35a91db8456d074b0d47a3e0df58f7 | https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/screenshot.js#L183-L197 | train | |
dalekjs/dalek-driver-sauce | lib/commands/screenshot.js | function () {
var date = new Date();
var dateStr = this._parseDate();
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
hours = (hours+'').length === 1 ? '0' + hours : hours;
minutes = (minutes+'').length === 1 ? '0' + minutes : minutes;
seco... | javascript | function () {
var date = new Date();
var dateStr = this._parseDate();
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
hours = (hours+'').length === 1 ? '0' + hours : hours;
minutes = (minutes+'').length === 1 ? '0' + minutes : minutes;
seco... | [
"function",
"(",
")",
"{",
"var",
"date",
"=",
"new",
"Date",
"(",
")",
";",
"var",
"dateStr",
"=",
"this",
".",
"_parseDate",
"(",
")",
";",
"var",
"hours",
"=",
"date",
".",
"getHours",
"(",
")",
";",
"var",
"minutes",
"=",
"date",
".",
"getMin... | Return the formatted datetime
@method _parseDatetime
@return {string} Datetime
@private | [
"Return",
"the",
"formatted",
"datetime"
] | 4b3ef87a0c35a91db8456d074b0d47a3e0df58f7 | https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/screenshot.js#L207-L223 | train | |
andrewscwei/requiem | src/dom/setDataRegistry.js | setDataRegistry | function setDataRegistry(data) {
assertType(data, 'object', false, 'Invalid data specified');
if (!window.__private__) window.__private__ = {};
window.__private__.dataRegistry = data;
} | javascript | function setDataRegistry(data) {
assertType(data, 'object', false, 'Invalid data specified');
if (!window.__private__) window.__private__ = {};
window.__private__.dataRegistry = data;
} | [
"function",
"setDataRegistry",
"(",
"data",
")",
"{",
"assertType",
"(",
"data",
",",
"'object'",
",",
"false",
",",
"'Invalid data specified'",
")",
";",
"if",
"(",
"!",
"window",
".",
"__private__",
")",
"window",
".",
"__private__",
"=",
"{",
"}",
";",
... | Sets the data registry.
@param {Object} data - Sets the data registry.
@alias module:requiem~dom.setDataRegistry | [
"Sets",
"the",
"data",
"registry",
"."
] | c4182bfffc9841c6de5718f689ad3c2060511777 | https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/dom/setDataRegistry.js#L14-L18 | train |
mathieudutour/nplint | lib/config-initializer.js | writeFile | function writeFile(config, isJson, callback) {
try {
fs.writeFile('./.nplintrc', isJson ? JSON.stringify(config, null, 4) : yaml.safeDump(config), callback);
} catch (e) {
return callback(e);
}
} | javascript | function writeFile(config, isJson, callback) {
try {
fs.writeFile('./.nplintrc', isJson ? JSON.stringify(config, null, 4) : yaml.safeDump(config), callback);
} catch (e) {
return callback(e);
}
} | [
"function",
"writeFile",
"(",
"config",
",",
"isJson",
",",
"callback",
")",
"{",
"try",
"{",
"fs",
".",
"writeFile",
"(",
"'./.nplintrc'",
",",
"isJson",
"?",
"JSON",
".",
"stringify",
"(",
"config",
",",
"null",
",",
"4",
")",
":",
"yaml",
".",
"sa... | Create .nplintrc file in the current working directory
@param {object} config object that contains user's answers
@param {bool} isJson should config file be json or yaml
@param {function} callback function to call once the file is written.
@returns {void} | [
"Create",
".",
"nplintrc",
"file",
"in",
"the",
"current",
"working",
"directory"
] | ef444abcc6dd08fb61d5fc8ce618598d4455e08e | https://github.com/mathieudutour/nplint/blob/ef444abcc6dd08fb61d5fc8ce618598d4455e08e/lib/config-initializer.js#L14-L20 | train |
af83/nodetk | browser/static/yabble.js | function(moduleIds) {
for (var i = moduleIds.length; i--;) {
var moduleId = moduleIds[i],
module = getModule(moduleId);
if (module == null) {
module = _modules[moduleId] = {};
_fetchFunc(moduleId);
}
}
} | javascript | function(moduleIds) {
for (var i = moduleIds.length; i--;) {
var moduleId = moduleIds[i],
module = getModule(moduleId);
if (module == null) {
module = _modules[moduleId] = {};
_fetchFunc(moduleId);
}
}
} | [
"function",
"(",
"moduleIds",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"moduleIds",
".",
"length",
";",
"i",
"--",
";",
")",
"{",
"var",
"moduleId",
"=",
"moduleIds",
"[",
"i",
"]",
",",
"module",
"=",
"getModule",
"(",
"moduleId",
")",
";",
"if",
... | Begins loading modules asynchronously | [
"Begins",
"loading",
"modules",
"asynchronously"
] | bd44fcc331ed0857cc05ae3a2535a01c5e540c1e | https://github.com/af83/nodetk/blob/bd44fcc331ed0857cc05ae3a2535a01c5e540c1e/browser/static/yabble.js#L231-L241 | train | |
af83/nodetk | browser/static/yabble.js | function() {
var i = 0;
while (i<_callbacks.length) {
var deps = _callbacks[i][0],
func = _callbacks[i][1],
n = 0;
while (n<deps.length) {
if (areDeepDepsDefined(deps[n])) {
deps.splice(n, 1);
}
else {
n++;
}
}
if (!deps.length) {
_callbacks.splice(i, 1);
if (fu... | javascript | function() {
var i = 0;
while (i<_callbacks.length) {
var deps = _callbacks[i][0],
func = _callbacks[i][1],
n = 0;
while (n<deps.length) {
if (areDeepDepsDefined(deps[n])) {
deps.splice(n, 1);
}
else {
n++;
}
}
if (!deps.length) {
_callbacks.splice(i, 1);
if (fu... | [
"function",
"(",
")",
"{",
"var",
"i",
"=",
"0",
";",
"while",
"(",
"i",
"<",
"_callbacks",
".",
"length",
")",
"{",
"var",
"deps",
"=",
"_callbacks",
"[",
"i",
"]",
"[",
"0",
"]",
",",
"func",
"=",
"_callbacks",
"[",
"i",
"]",
"[",
"1",
"]",... | Checks dependency callbacks and fires as necessary | [
"Checks",
"dependency",
"callbacks",
"and",
"fires",
"as",
"necessary"
] | bd44fcc331ed0857cc05ae3a2535a01c5e540c1e | https://github.com/af83/nodetk/blob/bd44fcc331ed0857cc05ae3a2535a01c5e540c1e/browser/static/yabble.js#L266-L290 | train | |
af83/nodetk | browser/static/yabble.js | function(moduleId) {
var scriptEl = document.createElement('script');
scriptEl.type = 'text/javascript';
scriptEl.src = resolveModuleUri(moduleId);
var useStandard = !!scriptEl.addEventListener,
timeoutHandle;
var errorFunc = function() {
postLoadFunc(false);
};
var loadFunc = function() {
if ... | javascript | function(moduleId) {
var scriptEl = document.createElement('script');
scriptEl.type = 'text/javascript';
scriptEl.src = resolveModuleUri(moduleId);
var useStandard = !!scriptEl.addEventListener,
timeoutHandle;
var errorFunc = function() {
postLoadFunc(false);
};
var loadFunc = function() {
if ... | [
"function",
"(",
"moduleId",
")",
"{",
"var",
"scriptEl",
"=",
"document",
".",
"createElement",
"(",
"'script'",
")",
";",
"scriptEl",
".",
"type",
"=",
"'text/javascript'",
";",
"scriptEl",
".",
"src",
"=",
"resolveModuleUri",
"(",
"moduleId",
")",
";",
... | Load a wrapped module via script tags | [
"Load",
"a",
"wrapped",
"module",
"via",
"script",
"tags"
] | bd44fcc331ed0857cc05ae3a2535a01c5e540c1e | https://github.com/af83/nodetk/blob/bd44fcc331ed0857cc05ae3a2535a01c5e540c1e/browser/static/yabble.js#L365-L414 | train | |
bholloway/browserify-anonymous-labeler | lib/adjust-source-map.js | copyAndOffsetMapping | function copyAndOffsetMapping(existingMapping) {
var column = getColumnAfter(existingMapping.generatedLine - 1, existingMapping.generatedColumn);
var newMapping = {
generated: {
line : existingMapping.generatedLine,
column: column
}
};
if (existingMapping.source) {
... | javascript | function copyAndOffsetMapping(existingMapping) {
var column = getColumnAfter(existingMapping.generatedLine - 1, existingMapping.generatedColumn);
var newMapping = {
generated: {
line : existingMapping.generatedLine,
column: column
}
};
if (existingMapping.source) {
... | [
"function",
"copyAndOffsetMapping",
"(",
"existingMapping",
")",
"{",
"var",
"column",
"=",
"getColumnAfter",
"(",
"existingMapping",
".",
"generatedLine",
"-",
"1",
",",
"existingMapping",
".",
"generatedColumn",
")",
";",
"var",
"newMapping",
"=",
"{",
"generate... | Copy the given mapping but offset as indicated by the split source code.
@param {object} existingMapping An existing source-map mapping from a source-map consumer | [
"Copy",
"the",
"given",
"mapping",
"but",
"offset",
"as",
"indicated",
"by",
"the",
"split",
"source",
"code",
"."
] | 651b124eefe8d1a567b2a03a0b8a3dfea87c2703 | https://github.com/bholloway/browserify-anonymous-labeler/blob/651b124eefe8d1a567b2a03a0b8a3dfea87c2703/lib/adjust-source-map.js#L40-L59 | train |
jmarthernandez/chat-parser | src/mentions.js | mentionsPredicate | function mentionsPredicate(str) {
// null/empty check
if (!str) {
return false;
// has @ symbol
} else if (str.indexOf('@') < 0) {
return false;
// has @ symbol as first char
} else if (str[0] !== '@') {
return false;
// contains non-word chars
} else if ((/[^\w\s]/).test(str.slice(1))) {
... | javascript | function mentionsPredicate(str) {
// null/empty check
if (!str) {
return false;
// has @ symbol
} else if (str.indexOf('@') < 0) {
return false;
// has @ symbol as first char
} else if (str[0] !== '@') {
return false;
// contains non-word chars
} else if ((/[^\w\s]/).test(str.slice(1))) {
... | [
"function",
"mentionsPredicate",
"(",
"str",
")",
"{",
"// null/empty check",
"if",
"(",
"!",
"str",
")",
"{",
"return",
"false",
";",
"// has @ symbol",
"}",
"else",
"if",
"(",
"str",
".",
"indexOf",
"(",
"'@'",
")",
"<",
"0",
")",
"{",
"return",
"fal... | Makes sure string matches the @mention convention
@func
@param {str} | [
"Makes",
"sure",
"string",
"matches",
"the"
] | 62e7e28cca35318158e4a807b30dd8d5d88718ac | https://github.com/jmarthernandez/chat-parser/blob/62e7e28cca35318158e4a807b30dd8d5d88718ac/src/mentions.js#L6-L24 | train |
redisjs/jsr-server | lib/command/pubsub/publish.js | execute | function execute(req, res) {
// must coerce channel to string
var len = this.state.pubsub.publish(
req.conn, '' + req.args[0], req.args[1]);
res.send(null, len);
} | javascript | function execute(req, res) {
// must coerce channel to string
var len = this.state.pubsub.publish(
req.conn, '' + req.args[0], req.args[1]);
res.send(null, len);
} | [
"function",
"execute",
"(",
"req",
",",
"res",
")",
"{",
"// must coerce channel to string",
"var",
"len",
"=",
"this",
".",
"state",
".",
"pubsub",
".",
"publish",
"(",
"req",
".",
"conn",
",",
"''",
"+",
"req",
".",
"args",
"[",
"0",
"]",
",",
"req... | Respond to the PUBLISH command. | [
"Respond",
"to",
"the",
"PUBLISH",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/pubsub/publish.js#L17-L22 | train |
luthraG/states-utils | index.js | _reverseAndPrecompute | function _reverseAndPrecompute () {
STATE_NAME_STRICT = Object.keys(US_STATE_NAME_TO_CODE);
var territoryKeys = Object.keys(US_INHABITED_TERRITORIES_NAME_TO_CODE);
(STATE_NAME_STRICT || []).forEach(function(stateName) {
US_STATE_CODE_TO_NAME[US_STATE_NAME_TO_CODE[stateName]] = stateName;
U... | javascript | function _reverseAndPrecompute () {
STATE_NAME_STRICT = Object.keys(US_STATE_NAME_TO_CODE);
var territoryKeys = Object.keys(US_INHABITED_TERRITORIES_NAME_TO_CODE);
(STATE_NAME_STRICT || []).forEach(function(stateName) {
US_STATE_CODE_TO_NAME[US_STATE_NAME_TO_CODE[stateName]] = stateName;
U... | [
"function",
"_reverseAndPrecompute",
"(",
")",
"{",
"STATE_NAME_STRICT",
"=",
"Object",
".",
"keys",
"(",
"US_STATE_NAME_TO_CODE",
")",
";",
"var",
"territoryKeys",
"=",
"Object",
".",
"keys",
"(",
"US_INHABITED_TERRITORIES_NAME_TO_CODE",
")",
";",
"(",
"STATE_NAME_... | Create reverse mapping | [
"Create",
"reverse",
"mapping"
] | d5c2534b0da5f316569591274704894e0527ca2f | https://github.com/luthraG/states-utils/blob/d5c2534b0da5f316569591274704894e0527ca2f/index.js#L24-L43 | train |
luthraG/states-utils | index.js | isUSAState | function isUSAState (state, strict) {
state = state && NODE_RATIFY.isString(state) ? _toTitleCase(state) : null;
var topLevel = (US_STATE_CODE_TO_NAME[state] || US_STATE_NAME_TO_CODE[state]);
if(strict) {
return topLevel ? true : false;
} else {
return (US_INHABITED_TERRITORIES_CODE_TO_... | javascript | function isUSAState (state, strict) {
state = state && NODE_RATIFY.isString(state) ? _toTitleCase(state) : null;
var topLevel = (US_STATE_CODE_TO_NAME[state] || US_STATE_NAME_TO_CODE[state]);
if(strict) {
return topLevel ? true : false;
} else {
return (US_INHABITED_TERRITORIES_CODE_TO_... | [
"function",
"isUSAState",
"(",
"state",
",",
"strict",
")",
"{",
"state",
"=",
"state",
"&&",
"NODE_RATIFY",
".",
"isString",
"(",
"state",
")",
"?",
"_toTitleCase",
"(",
"state",
")",
":",
"null",
";",
"var",
"topLevel",
"=",
"(",
"US_STATE_CODE_TO_NAME",... | Is given state code or state name is a valid state | [
"Is",
"given",
"state",
"code",
"or",
"state",
"name",
"is",
"a",
"valid",
"state"
] | d5c2534b0da5f316569591274704894e0527ca2f | https://github.com/luthraG/states-utils/blob/d5c2534b0da5f316569591274704894e0527ca2f/index.js#L62-L71 | train |
luthraG/states-utils | index.js | getStateName | function getStateName(searchKey, strict) {
searchKey = searchKey && NODE_RATIFY.isString(searchKey) ? _toTitleCase(searchKey) : null;
var topLevel = (US_STATE_CODE_TO_NAME[searchKey] || US_CAPITAL_TO_STATE_NAME[searchKey]);
if(strict) {
return topLevel;
} else {
return (US_INHABITED_TER... | javascript | function getStateName(searchKey, strict) {
searchKey = searchKey && NODE_RATIFY.isString(searchKey) ? _toTitleCase(searchKey) : null;
var topLevel = (US_STATE_CODE_TO_NAME[searchKey] || US_CAPITAL_TO_STATE_NAME[searchKey]);
if(strict) {
return topLevel;
} else {
return (US_INHABITED_TER... | [
"function",
"getStateName",
"(",
"searchKey",
",",
"strict",
")",
"{",
"searchKey",
"=",
"searchKey",
"&&",
"NODE_RATIFY",
".",
"isString",
"(",
"searchKey",
")",
"?",
"_toTitleCase",
"(",
"searchKey",
")",
":",
"null",
";",
"var",
"topLevel",
"=",
"(",
"U... | Given a state USPS Code or state capital it finds the state name | [
"Given",
"a",
"state",
"USPS",
"Code",
"or",
"state",
"capital",
"it",
"finds",
"the",
"state",
"name"
] | d5c2534b0da5f316569591274704894e0527ca2f | https://github.com/luthraG/states-utils/blob/d5c2534b0da5f316569591274704894e0527ca2f/index.js#L90-L99 | train |
luthraG/states-utils | index.js | getUSPSCode | function getUSPSCode(searchKey, strict) {
searchKey = searchKey && NODE_RATIFY.isString(searchKey) ? _toTitleCase(searchKey) : null;
var topLevel = (US_STATE_NAME_TO_CODE[searchKey] || US_STATE_NAME_TO_CODE[US_CAPITAL_TO_STATE_NAME[searchKey]]);
if(strict) {
return topLevel;
} else {
se... | javascript | function getUSPSCode(searchKey, strict) {
searchKey = searchKey && NODE_RATIFY.isString(searchKey) ? _toTitleCase(searchKey) : null;
var topLevel = (US_STATE_NAME_TO_CODE[searchKey] || US_STATE_NAME_TO_CODE[US_CAPITAL_TO_STATE_NAME[searchKey]]);
if(strict) {
return topLevel;
} else {
se... | [
"function",
"getUSPSCode",
"(",
"searchKey",
",",
"strict",
")",
"{",
"searchKey",
"=",
"searchKey",
"&&",
"NODE_RATIFY",
".",
"isString",
"(",
"searchKey",
")",
"?",
"_toTitleCase",
"(",
"searchKey",
")",
":",
"null",
";",
"var",
"topLevel",
"=",
"(",
"US... | Given a state name or state capital it finds the USPS Code | [
"Given",
"a",
"state",
"name",
"or",
"state",
"capital",
"it",
"finds",
"the",
"USPS",
"Code"
] | d5c2534b0da5f316569591274704894e0527ca2f | https://github.com/luthraG/states-utils/blob/d5c2534b0da5f316569591274704894e0527ca2f/index.js#L104-L116 | train |
luthraG/states-utils | index.js | getStateCapital | function getStateCapital(searchKey, strict) {
searchKey = searchKey && NODE_RATIFY.isString(searchKey) ? _toTitleCase(searchKey) : null;
var topLevel = (US_STATE_NAME_TO_CAPITAL[searchKey] || US_STATE_NAME_TO_CAPITAL[US_STATE_CODE_TO_NAME[searchKey]]);
if(strict) {
return topLevel;
} else {
... | javascript | function getStateCapital(searchKey, strict) {
searchKey = searchKey && NODE_RATIFY.isString(searchKey) ? _toTitleCase(searchKey) : null;
var topLevel = (US_STATE_NAME_TO_CAPITAL[searchKey] || US_STATE_NAME_TO_CAPITAL[US_STATE_CODE_TO_NAME[searchKey]]);
if(strict) {
return topLevel;
} else {
... | [
"function",
"getStateCapital",
"(",
"searchKey",
",",
"strict",
")",
"{",
"searchKey",
"=",
"searchKey",
"&&",
"NODE_RATIFY",
".",
"isString",
"(",
"searchKey",
")",
"?",
"_toTitleCase",
"(",
"searchKey",
")",
":",
"null",
";",
"var",
"topLevel",
"=",
"(",
... | Given a state name or state USPS code it finds the state capital | [
"Given",
"a",
"state",
"name",
"or",
"state",
"USPS",
"code",
"it",
"finds",
"the",
"state",
"capital"
] | d5c2534b0da5f316569591274704894e0527ca2f | https://github.com/luthraG/states-utils/blob/d5c2534b0da5f316569591274704894e0527ca2f/index.js#L121-L132 | train |
superelement/log-saviour | index.js | log | function log() {
var args = NS ? [chalk.bold.gray(NS)] : []
for(var i=0; i<arguments.length; i++) {
var arg = arguments[i];
args.push(chalk.cyan( typeof arg === "object" ? JSON.stringify(arg) : arg ))
// adds a separator
if(i < arguments.length-1) args.push(chalk.gray("|"));
}
if(testLog) tes... | javascript | function log() {
var args = NS ? [chalk.bold.gray(NS)] : []
for(var i=0; i<arguments.length; i++) {
var arg = arguments[i];
args.push(chalk.cyan( typeof arg === "object" ? JSON.stringify(arg) : arg ))
// adds a separator
if(i < arguments.length-1) args.push(chalk.gray("|"));
}
if(testLog) tes... | [
"function",
"log",
"(",
")",
"{",
"var",
"args",
"=",
"NS",
"?",
"[",
"chalk",
".",
"bold",
".",
"gray",
"(",
"NS",
")",
"]",
":",
"[",
"]",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"arguments",
".",
"length",
";",
"i",
"++",
")",
... | coloured console log | [
"coloured",
"console",
"log"
] | a45c56d71b8af173e82f5dc12568f34eb380da51 | https://github.com/superelement/log-saviour/blob/a45c56d71b8af173e82f5dc12568f34eb380da51/index.js#L11-L22 | train |
superelement/log-saviour | index.js | logArr | function logArr(arr) {
if(arguments.length > 1) {
if(!suppressWarnings) console.warn("'logArr' only supports 1 parameter. Converting to regular 'log'.");
log(Array.prototype.slice.call(arguments));
return;
}
if(! _.isArray(arr)) {
if(!suppressWarnings) console.warn("'logArr' used, but first argu... | javascript | function logArr(arr) {
if(arguments.length > 1) {
if(!suppressWarnings) console.warn("'logArr' only supports 1 parameter. Converting to regular 'log'.");
log(Array.prototype.slice.call(arguments));
return;
}
if(! _.isArray(arr)) {
if(!suppressWarnings) console.warn("'logArr' used, but first argu... | [
"function",
"logArr",
"(",
"arr",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
">",
"1",
")",
"{",
"if",
"(",
"!",
"suppressWarnings",
")",
"console",
".",
"warn",
"(",
"\"'logArr' only supports 1 parameter. Converting to regular 'log'.\"",
")",
";",
"log",
... | coloured console log, using an array instead of parameters | [
"coloured",
"console",
"log",
"using",
"an",
"array",
"instead",
"of",
"parameters"
] | a45c56d71b8af173e82f5dc12568f34eb380da51 | https://github.com/superelement/log-saviour/blob/a45c56d71b8af173e82f5dc12568f34eb380da51/index.js#L25-L39 | train |
superelement/log-saviour | index.js | warn | function warn() {
if(suppressWarnings) return
var args = NS ? [chalk.bold.gray(NS)] : []
for(var i=0; i<arguments.length; i++) {
var arg = arguments[i];
args.push(chalk.bold.yellow.bgRed( typeof arg === "object" ? JSON.stringify(arg) : arg ))
// adds a separator
if(i < arguments.length-1) a... | javascript | function warn() {
if(suppressWarnings) return
var args = NS ? [chalk.bold.gray(NS)] : []
for(var i=0; i<arguments.length; i++) {
var arg = arguments[i];
args.push(chalk.bold.yellow.bgRed( typeof arg === "object" ? JSON.stringify(arg) : arg ))
// adds a separator
if(i < arguments.length-1) a... | [
"function",
"warn",
"(",
")",
"{",
"if",
"(",
"suppressWarnings",
")",
"return",
"var",
"args",
"=",
"NS",
"?",
"[",
"chalk",
".",
"bold",
".",
"gray",
"(",
"NS",
")",
"]",
":",
"[",
"]",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"argu... | coloured console warn | [
"coloured",
"console",
"warn"
] | a45c56d71b8af173e82f5dc12568f34eb380da51 | https://github.com/superelement/log-saviour/blob/a45c56d71b8af173e82f5dc12568f34eb380da51/index.js#L42-L56 | train |
mvolkmann/node-token-auth | index.js | configure | function configure(alg, pswd, sto) {
algorithm = alg;
password = pswd;
sessionTimeout = sto;
} | javascript | function configure(alg, pswd, sto) {
algorithm = alg;
password = pswd;
sessionTimeout = sto;
} | [
"function",
"configure",
"(",
"alg",
",",
"pswd",
",",
"sto",
")",
"{",
"algorithm",
"=",
"alg",
";",
"password",
"=",
"pswd",
";",
"sessionTimeout",
"=",
"sto",
";",
"}"
] | Configures auth token encryption and the session timeout.
@param alg the encryption algorithm name
@param pswd the encryption password
@param sto the session timeout duration in minutes | [
"Configures",
"auth",
"token",
"encryption",
"and",
"the",
"session",
"timeout",
"."
] | dfbccd0b58a02c02d96eccd14b2b96834eb024b0 | https://github.com/mvolkmann/node-token-auth/blob/dfbccd0b58a02c02d96eccd14b2b96834eb024b0/index.js#L50-L54 | train |
bholloway/browserify-incremental-plugin | index.js | pluginFactory | function pluginFactory(cache) {
// ensure cache
var internalCache = cache || {};
// create an instance of cache populater
var getCache = cacheFactory(internalCache);
// return a closure with a pluginFactory() sidecar
browserifyIncremental.pluginFactory = pluginFactory;
return browserifyIncremental;
... | javascript | function pluginFactory(cache) {
// ensure cache
var internalCache = cache || {};
// create an instance of cache populater
var getCache = cacheFactory(internalCache);
// return a closure with a pluginFactory() sidecar
browserifyIncremental.pluginFactory = pluginFactory;
return browserifyIncremental;
... | [
"function",
"pluginFactory",
"(",
"cache",
")",
"{",
"// ensure cache",
"var",
"internalCache",
"=",
"cache",
"||",
"{",
"}",
";",
"// create an instance of cache populater",
"var",
"getCache",
"=",
"cacheFactory",
"(",
"internalCache",
")",
";",
"// return a closure ... | Create a context for which multiple instances of the plugin may operate with a shared cache.
@param {object} [cache] Optional cache
@returns {function} A browserify plugin | [
"Create",
"a",
"context",
"for",
"which",
"multiple",
"instances",
"of",
"the",
"plugin",
"may",
"operate",
"with",
"a",
"shared",
"cache",
"."
] | 87656c217d6dd028f159122229f8fef412f42dd3 | https://github.com/bholloway/browserify-incremental-plugin/blob/87656c217d6dd028f159122229f8fef412f42dd3/index.js#L13-L49 | train |
bholloway/browserify-incremental-plugin | index.js | setupPipeline | function setupPipeline() {
var deps = bundler.pipeline.get('deps');
deps.push(getCache(deps._streams[0].cache));
} | javascript | function setupPipeline() {
var deps = bundler.pipeline.get('deps');
deps.push(getCache(deps._streams[0].cache));
} | [
"function",
"setupPipeline",
"(",
")",
"{",
"var",
"deps",
"=",
"bundler",
".",
"pipeline",
".",
"get",
"(",
"'deps'",
")",
";",
"deps",
".",
"push",
"(",
"getCache",
"(",
"deps",
".",
"_streams",
"[",
"0",
"]",
".",
"cache",
")",
")",
";",
"}"
] | Apply an interceptor to the pipeline. | [
"Apply",
"an",
"interceptor",
"to",
"the",
"pipeline",
"."
] | 87656c217d6dd028f159122229f8fef412f42dd3 | https://github.com/bholloway/browserify-incremental-plugin/blob/87656c217d6dd028f159122229f8fef412f42dd3/index.js#L44-L47 | train |
bholloway/browserify-incremental-plugin | index.js | cacheFactory | function cacheFactory(internalCache) {
// comparison cache will be use by getters
// since getters are persistent on the internal cache then the comparison cache also needs to be persistent
var isTestedCache = {};
/**
* Get a pipeline 'deps' stage that populates cache for incremental compile.
* Called ... | javascript | function cacheFactory(internalCache) {
// comparison cache will be use by getters
// since getters are persistent on the internal cache then the comparison cache also needs to be persistent
var isTestedCache = {};
/**
* Get a pipeline 'deps' stage that populates cache for incremental compile.
* Called ... | [
"function",
"cacheFactory",
"(",
"internalCache",
")",
"{",
"// comparison cache will be use by getters",
"// since getters are persistent on the internal cache then the comparison cache also needs to be persistent",
"var",
"isTestedCache",
"=",
"{",
"}",
";",
"/**\n * Get a pipeline ... | A factory for a pipeline 'deps' stage.
@param {object} internalCache Our internal cache
@returns {function} a closure that will get an instance for a given depsCache | [
"A",
"factory",
"for",
"a",
"pipeline",
"deps",
"stage",
"."
] | 87656c217d6dd028f159122229f8fef412f42dd3 | https://github.com/bholloway/browserify-incremental-plugin/blob/87656c217d6dd028f159122229f8fef412f42dd3/index.js#L58-L156 | train |
bholloway/browserify-incremental-plugin | index.js | defineGetterFor | function defineGetterFor(depsCache, filename) {
// instead of making the property re-definable we instead make assignment idempotent
if (!depsCache.hasOwnProperty(filename)) {
Object.defineProperty(depsCache, filename, {get: getter});
}
// create a getter
// we need to use a getter as it is... | javascript | function defineGetterFor(depsCache, filename) {
// instead of making the property re-definable we instead make assignment idempotent
if (!depsCache.hasOwnProperty(filename)) {
Object.defineProperty(depsCache, filename, {get: getter});
}
// create a getter
// we need to use a getter as it is... | [
"function",
"defineGetterFor",
"(",
"depsCache",
",",
"filename",
")",
"{",
"// instead of making the property re-definable we instead make assignment idempotent",
"if",
"(",
"!",
"depsCache",
".",
"hasOwnProperty",
"(",
"filename",
")",
")",
"{",
"Object",
".",
"definePr... | Create getter on first appearance of a given key and operate through the persistent cache objects.
However be careful not to use any closed over variables in the getter.
@param {object} depsCache The browserify cache shared across instances
@param {string} filename The key (file name) for the deps cache | [
"Create",
"getter",
"on",
"first",
"appearance",
"of",
"a",
"given",
"key",
"and",
"operate",
"through",
"the",
"persistent",
"cache",
"objects",
".",
"However",
"be",
"careful",
"not",
"to",
"use",
"any",
"closed",
"over",
"variables",
"in",
"the",
"getter"... | 87656c217d6dd028f159122229f8fef412f42dd3 | https://github.com/bholloway/browserify-incremental-plugin/blob/87656c217d6dd028f159122229f8fef412f42dd3/index.js#L124-L155 | train |
bholloway/browserify-incremental-plugin | index.js | getter | function getter() {
// not found
var cached = internalCache[filename];
if (!cached) {
return undefined;
}
// we have already tested whether the cached value is valid and deleted it if not
else if (isTestedCache[filename]) {
return cached.output;
}
// test... | javascript | function getter() {
// not found
var cached = internalCache[filename];
if (!cached) {
return undefined;
}
// we have already tested whether the cached value is valid and deleted it if not
else if (isTestedCache[filename]) {
return cached.output;
}
// test... | [
"function",
"getter",
"(",
")",
"{",
"// not found",
"var",
"cached",
"=",
"internalCache",
"[",
"filename",
"]",
";",
"if",
"(",
"!",
"cached",
")",
"{",
"return",
"undefined",
";",
"}",
"// we have already tested whether the cached value is valid and deleted it if n... | create a getter we need to use a getter as it is the only hook at which we can perform comparison the value is accessed multiple times each compile cycle but is only set at the end of the cycle getters will persist for the life of the internal cache so the test cache also needs to persist | [
"create",
"a",
"getter",
"we",
"need",
"to",
"use",
"a",
"getter",
"as",
"it",
"is",
"the",
"only",
"hook",
"at",
"which",
"we",
"can",
"perform",
"comparison",
"the",
"value",
"is",
"accessed",
"multiple",
"times",
"each",
"compile",
"cycle",
"but",
"is... | 87656c217d6dd028f159122229f8fef412f42dd3 | https://github.com/bholloway/browserify-incremental-plugin/blob/87656c217d6dd028f159122229f8fef412f42dd3/index.js#L135-L154 | train |
tx4x/git-module | lib/exe.js | getModuleConfig | function getModuleConfig(nameOrPath,modules) {
for (var i = 0; i < modules.length; i++) {
var config = modules[i];
if (config.options && (config.options.directory === nameOrPath || config.name === nameOrPath)) {
return config;
}
}
return null;
} | javascript | function getModuleConfig(nameOrPath,modules) {
for (var i = 0; i < modules.length; i++) {
var config = modules[i];
if (config.options && (config.options.directory === nameOrPath || config.name === nameOrPath)) {
return config;
}
}
return null;
} | [
"function",
"getModuleConfig",
"(",
"nameOrPath",
",",
"modules",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"modules",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"config",
"=",
"modules",
"[",
"i",
"]",
";",
"if",
"(",
"conf... | Find a module config by path or name
@param nameOrPath {string}
@param modules {object[]}
@returns {null|object} | [
"Find",
"a",
"module",
"config",
"by",
"path",
"or",
"name"
] | 93ff14eecb00c5c140f3e6413bd43404cc1dd021 | https://github.com/tx4x/git-module/blob/93ff14eecb00c5c140f3e6413bd43404cc1dd021/lib/exe.js#L24-L32 | train |
tx4x/git-module | lib/exe.js | getModules | function getModules(argv,modules){
if(argv.module){
var which = getModuleConfig(argv.module,modules);
if(which){
return [which];
}else{
return [];
}
}
return modules;
} | javascript | function getModules(argv,modules){
if(argv.module){
var which = getModuleConfig(argv.module,modules);
if(which){
return [which];
}else{
return [];
}
}
return modules;
} | [
"function",
"getModules",
"(",
"argv",
",",
"modules",
")",
"{",
"if",
"(",
"argv",
".",
"module",
")",
"{",
"var",
"which",
"=",
"getModuleConfig",
"(",
"argv",
".",
"module",
",",
"modules",
")",
";",
"if",
"(",
"which",
")",
"{",
"return",
"[",
... | Filter modules against cmd arg
@param argv {object}
@param modules {object[]}
@returns {*} | [
"Filter",
"modules",
"against",
"cmd",
"arg"
] | 93ff14eecb00c5c140f3e6413bd43404cc1dd021 | https://github.com/tx4x/git-module/blob/93ff14eecb00c5c140f3e6413bd43404cc1dd021/lib/exe.js#L94-L104 | train |
faboweb/zliq | src/utils/vdom-diff.js | removeNotNeededNodes | function removeNotNeededNodes(parentElements, newChildren, oldChildren) {
let remaining = parentElements.childNodes.length;
if (oldChildren.length !== remaining) {
console.warn(
"ZLIQ: Something other then ZLIQ has manipulated the children of the element",
parentElements,
". This can lead to s... | javascript | function removeNotNeededNodes(parentElements, newChildren, oldChildren) {
let remaining = parentElements.childNodes.length;
if (oldChildren.length !== remaining) {
console.warn(
"ZLIQ: Something other then ZLIQ has manipulated the children of the element",
parentElements,
". This can lead to s... | [
"function",
"removeNotNeededNodes",
"(",
"parentElements",
",",
"newChildren",
",",
"oldChildren",
")",
"{",
"let",
"remaining",
"=",
"parentElements",
".",
"childNodes",
".",
"length",
";",
"if",
"(",
"oldChildren",
".",
"length",
"!==",
"remaining",
")",
"{",
... | this removes nodes at the end of the children, that are not needed anymore in the current state for recycling | [
"this",
"removes",
"nodes",
"at",
"the",
"end",
"of",
"the",
"children",
"that",
"are",
"not",
"needed",
"anymore",
"in",
"the",
"current",
"state",
"for",
"recycling"
] | 1d4d5ed9631c0c29b101bcf4817ad40624b6bbea | https://github.com/faboweb/zliq/blob/1d4d5ed9631c0c29b101bcf4817ad40624b6bbea/src/utils/vdom-diff.js#L156-L178 | train |
faboweb/zliq | src/utils/vdom-diff.js | shouldRecycleElement | function shouldRecycleElement(oldElement, props, tag) {
return (
!isTextNode(oldElement) &&
oldElement.id === "" &&
!nodeTypeDiffers(oldElement, tag)
);
} | javascript | function shouldRecycleElement(oldElement, props, tag) {
return (
!isTextNode(oldElement) &&
oldElement.id === "" &&
!nodeTypeDiffers(oldElement, tag)
);
} | [
"function",
"shouldRecycleElement",
"(",
"oldElement",
",",
"props",
",",
"tag",
")",
"{",
"return",
"(",
"!",
"isTextNode",
"(",
"oldElement",
")",
"&&",
"oldElement",
".",
"id",
"===",
"\"\"",
"&&",
"!",
"nodeTypeDiffers",
"(",
"oldElement",
",",
"tag",
... | we want to recycle elements to save time on creating and inserting nodes into the dom we don't want to manipulate elements that go into the cache, because they would mutate in the cache as well | [
"we",
"want",
"to",
"recycle",
"elements",
"to",
"save",
"time",
"on",
"creating",
"and",
"inserting",
"nodes",
"into",
"the",
"dom",
"we",
"don",
"t",
"want",
"to",
"manipulate",
"elements",
"that",
"go",
"into",
"the",
"cache",
"because",
"they",
"would"... | 1d4d5ed9631c0c29b101bcf4817ad40624b6bbea | https://github.com/faboweb/zliq/blob/1d4d5ed9631c0c29b101bcf4817ad40624b6bbea/src/utils/vdom-diff.js#L345-L351 | train |
gethuman/pancakes-recipe | middleware/mw.auth.social.js | getProvider | function getProvider(providerName, providerConfig) {
return _.extend({}, providerConfig.opts, {
profile: function profile(credentials, params, get, callback) {
var proof = null;
/* eslint camelcase:0 */
if (providerConfig.useProof) {
... | javascript | function getProvider(providerName, providerConfig) {
return _.extend({}, providerConfig.opts, {
profile: function profile(credentials, params, get, callback) {
var proof = null;
/* eslint camelcase:0 */
if (providerConfig.useProof) {
... | [
"function",
"getProvider",
"(",
"providerName",
",",
"providerConfig",
")",
"{",
"return",
"_",
".",
"extend",
"(",
"{",
"}",
",",
"providerConfig",
".",
"opts",
",",
"{",
"profile",
":",
"function",
"profile",
"(",
"credentials",
",",
"params",
",",
"get"... | Get the provider info which is really opts from the config plus the
profile function which sets the values which we will store in the
user table in the database
@param providerName
@param providerConfig
@returns {*} | [
"Get",
"the",
"provider",
"info",
"which",
"is",
"really",
"opts",
"from",
"the",
"config",
"plus",
"the",
"profile",
"function",
"which",
"sets",
"the",
"values",
"which",
"we",
"will",
"store",
"in",
"the",
"user",
"table",
"in",
"the",
"database"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.auth.social.js#L18-L60 | train |
gethuman/pancakes-recipe | middleware/mw.auth.social.js | init | function init(ctx) {
var server = ctx.server;
var deferred = Q.defer();
server.register({register: require('bell')}, function (err) {
if (err) {
deferred.reject(err);
return;
}
_.each(config.security.social, function (provide... | javascript | function init(ctx) {
var server = ctx.server;
var deferred = Q.defer();
server.register({register: require('bell')}, function (err) {
if (err) {
deferred.reject(err);
return;
}
_.each(config.security.social, function (provide... | [
"function",
"init",
"(",
"ctx",
")",
"{",
"var",
"server",
"=",
"ctx",
".",
"server",
";",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"server",
".",
"register",
"(",
"{",
"register",
":",
"require",
"(",
"'bell'",
")",
"}",
",",
"f... | Use the Hapi Bell plugin to register the social auth providers
@param ctx | [
"Use",
"the",
"Hapi",
"Bell",
"plugin",
"to",
"register",
"the",
"social",
"auth",
"providers"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.auth.social.js#L66-L96 | train |
tolokoban/ToloFrameWork | ker/mod/tfw.view.language.js | findLanguageNameFromCode | function findLanguageNameFromCode( languageCode ) {
var a = 0;
var b = LANGUAGES.length;
var m = b;
var item, code, name;
languageCode = languageCode.toLowerCase();
while( b - a > 1 ) {
m = Math.floor( (a + b) / 2 );
item = LANGUAGES[m];
code = item[0];
name = item[1];
if( code == lang... | javascript | function findLanguageNameFromCode( languageCode ) {
var a = 0;
var b = LANGUAGES.length;
var m = b;
var item, code, name;
languageCode = languageCode.toLowerCase();
while( b - a > 1 ) {
m = Math.floor( (a + b) / 2 );
item = LANGUAGES[m];
code = item[0];
name = item[1];
if( code == lang... | [
"function",
"findLanguageNameFromCode",
"(",
"languageCode",
")",
"{",
"var",
"a",
"=",
"0",
";",
"var",
"b",
"=",
"LANGUAGES",
".",
"length",
";",
"var",
"m",
"=",
"b",
";",
"var",
"item",
",",
"code",
",",
"name",
";",
"languageCode",
"=",
"languageC... | Dichotomic search. | [
"Dichotomic",
"search",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/tfw.view.language.js#L135-L153 | train |
hoodiehq-archive/hoodie-plugins-manager | lib/changes_pool.js | function (db, query, callback) {
// query parameter is optional
if (!callback) {
callback = query
query = {}
}
// create a new request object
var req = {
// db name
db: db,
// authenticated url to db
db_url: url.resolve(couch_url, encodeURIComponent(db)),
/... | javascript | function (db, query, callback) {
// query parameter is optional
if (!callback) {
callback = query
query = {}
}
// create a new request object
var req = {
// db name
db: db,
// authenticated url to db
db_url: url.resolve(couch_url, encodeURIComponent(db)),
/... | [
"function",
"(",
"db",
",",
"query",
",",
"callback",
")",
"{",
"// query parameter is optional",
"if",
"(",
"!",
"callback",
")",
"{",
"callback",
"=",
"query",
"query",
"=",
"{",
"}",
"}",
"// create a new request object",
"var",
"req",
"=",
"{",
"// db na... | the public changes feed subscription function | [
"the",
"public",
"changes",
"feed",
"subscription",
"function"
] | c2d752194b3780f5fa398cccfe0d0e35988f5a0b | https://github.com/hoodiehq-archive/hoodie-plugins-manager/blob/c2d752194b3780f5fa398cccfe0d0e35988f5a0b/lib/changes_pool.js#L80-L110 | train | |
eanglay/bayon-core | lib/router.js | registerHandler | function registerHandler(routeItem, headler) {
let method = routeItem.method.toLowerCase();
debug(
'Binding "%s" to path "%s" with method "%s"',
routeItem.handler, routeItem.path, method.toUpperCase()
);
headler.actionHandler = true;
components.app[method](routeItem.path, headler);
} | javascript | function registerHandler(routeItem, headler) {
let method = routeItem.method.toLowerCase();
debug(
'Binding "%s" to path "%s" with method "%s"',
routeItem.handler, routeItem.path, method.toUpperCase()
);
headler.actionHandler = true;
components.app[method](routeItem.path, headler);
} | [
"function",
"registerHandler",
"(",
"routeItem",
",",
"headler",
")",
"{",
"let",
"method",
"=",
"routeItem",
".",
"method",
".",
"toLowerCase",
"(",
")",
";",
"debug",
"(",
"'Binding \"%s\" to path \"%s\" with method \"%s\"'",
",",
"routeItem",
".",
"handler",
",... | register route path with acually function | [
"register",
"route",
"path",
"with",
"acually",
"function"
] | 96e8ec296433bcf95aeb7d5b27d9fa275b049396 | https://github.com/eanglay/bayon-core/blob/96e8ec296433bcf95aeb7d5b27d9fa275b049396/lib/router.js#L13-L21 | train |
eanglay/bayon-core | lib/router.js | routeSolver | function routeSolver(routeItem, handler, resolver) {
switch (typeof handler) {
case 'function':
// solve as function handler
registerHandler(routeItem, null, routeItem.handler);
break;
case 'string':
// solve as controller - action handler
resolver(routeItem, handler)... | javascript | function routeSolver(routeItem, handler, resolver) {
switch (typeof handler) {
case 'function':
// solve as function handler
registerHandler(routeItem, null, routeItem.handler);
break;
case 'string':
// solve as controller - action handler
resolver(routeItem, handler)... | [
"function",
"routeSolver",
"(",
"routeItem",
",",
"handler",
",",
"resolver",
")",
"{",
"switch",
"(",
"typeof",
"handler",
")",
"{",
"case",
"'function'",
":",
"// solve as function handler",
"registerHandler",
"(",
"routeItem",
",",
"null",
",",
"routeItem",
"... | determine route's type | [
"determine",
"route",
"s",
"type"
] | 96e8ec296433bcf95aeb7d5b27d9fa275b049396 | https://github.com/eanglay/bayon-core/blob/96e8ec296433bcf95aeb7d5b27d9fa275b049396/lib/router.js#L66-L79 | train |
tolokoban/ToloFrameWork | lib/transpiler.js | transpile | function transpile( sourceCode, sourceName, minify ) {
try {
const
sourceFileName = Path.basename( sourceName ),
ast = parseToAST( sourceCode ),
transfo = Babel.transformSync( sourceCode, buildOptions( sourceFileName, minify ) ),
// transfo = Babel.transformFr... | javascript | function transpile( sourceCode, sourceName, minify ) {
try {
const
sourceFileName = Path.basename( sourceName ),
ast = parseToAST( sourceCode ),
transfo = Babel.transformSync( sourceCode, buildOptions( sourceFileName, minify ) ),
// transfo = Babel.transformFr... | [
"function",
"transpile",
"(",
"sourceCode",
",",
"sourceName",
",",
"minify",
")",
"{",
"try",
"{",
"const",
"sourceFileName",
"=",
"Path",
".",
"basename",
"(",
"sourceName",
")",
",",
"ast",
"=",
"parseToAST",
"(",
"sourceCode",
")",
",",
"transfo",
"=",... | Transpile code into Javascript equivalent that can be read on currently supported browsers.
@param {string} sourceCode - Code in cutting edge Javascript.
@param {string} sourceName - Name of the file.
@param {boolean} minify - Default `false`.
@returns {object} The transpiled code and its source map.
__code__: code com... | [
"Transpile",
"code",
"into",
"Javascript",
"equivalent",
"that",
"can",
"be",
"read",
"on",
"currently",
"supported",
"browsers",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/transpiler.js#L33-L55 | train |
copress/copress-component-oauth2 | lib/unorderedlist.js | UnorderedList | function UnorderedList(items) {
if (typeof items == 'string') {
items = items.split(' ');
}
this._items = items || [];
this.__defineGetter__('length', this._length);
} | javascript | function UnorderedList(items) {
if (typeof items == 'string') {
items = items.split(' ');
}
this._items = items || [];
this.__defineGetter__('length', this._length);
} | [
"function",
"UnorderedList",
"(",
"items",
")",
"{",
"if",
"(",
"typeof",
"items",
"==",
"'string'",
")",
"{",
"items",
"=",
"items",
".",
"split",
"(",
"' '",
")",
";",
"}",
"this",
".",
"_items",
"=",
"items",
"||",
"[",
"]",
";",
"this",
".",
... | `UnorderedList` constructor.
@api public | [
"UnorderedList",
"constructor",
"."
] | 4819f379a0d42753bfd51e237c5c3aaddee37544 | https://github.com/copress/copress-component-oauth2/blob/4819f379a0d42753bfd51e237c5c3aaddee37544/lib/unorderedlist.js#L6-L12 | train |
quartzjer/e3x-cs1a | cs1a.js | fold | function fold(count, buf)
{
if(!count || buf.length % 2) return buf;
var ret = buf.slice(0,buf.length/2);
for(i = 0; i < ret.length; i++) ret[i] = ret[i] ^ buf[i+ret.length];
return fold(count-1,ret);
} | javascript | function fold(count, buf)
{
if(!count || buf.length % 2) return buf;
var ret = buf.slice(0,buf.length/2);
for(i = 0; i < ret.length; i++) ret[i] = ret[i] ^ buf[i+ret.length];
return fold(count-1,ret);
} | [
"function",
"fold",
"(",
"count",
",",
"buf",
")",
"{",
"if",
"(",
"!",
"count",
"||",
"buf",
".",
"length",
"%",
"2",
")",
"return",
"buf",
";",
"var",
"ret",
"=",
"buf",
".",
"slice",
"(",
"0",
",",
"buf",
".",
"length",
"/",
"2",
")",
";",... | simple xor buffer folder | [
"simple",
"xor",
"buffer",
"folder"
] | 267bb9f6e2bf54cc379df090071c6c15b4718fea | https://github.com/quartzjer/e3x-cs1a/blob/267bb9f6e2bf54cc379df090071c6c15b4718fea/cs1a.js#L197-L203 | train |
OpenCrisp/Crisp.PathJS | dist/crisp-path.js | pickReverseEach | function pickReverseEach( reverse, node, callback ) {
var test = type.call( node, 'Undefined' ) ||
node==='false' ||
node===false ||
(
type.call( node, 'Boolean' ) &&
!node.valueOf()
);
if ( test ) {
pickRevers... | javascript | function pickReverseEach( reverse, node, callback ) {
var test = type.call( node, 'Undefined' ) ||
node==='false' ||
node===false ||
(
type.call( node, 'Boolean' ) &&
!node.valueOf()
);
if ( test ) {
pickRevers... | [
"function",
"pickReverseEach",
"(",
"reverse",
",",
"node",
",",
"callback",
")",
"{",
"var",
"test",
"=",
"type",
".",
"call",
"(",
"node",
",",
"'Undefined'",
")",
"||",
"node",
"===",
"'false'",
"||",
"node",
"===",
"false",
"||",
"(",
"type",
".",
... | reverse given node
@private
@param {external:Number} reverse
@param {*} node
@return {external:Boolean}
@memberOf util.path | [
"reverse",
"given",
"node"
] | e5ed81b22cdff4d8b6c157e62b8a0d3304f8a90a | https://github.com/OpenCrisp/Crisp.PathJS/blob/e5ed81b22cdff4d8b6c157e62b8a0d3304f8a90a/dist/crisp-path.js#L669-L692 | train |
thomasfr/Timeliner.Core | lib/processTokens.js | processTokens | function processTokens(tokens, callback) {
"use strict";
var processFunctions = underscore.map(tokens, function (word) {
return function (cb) {
tokenizeWord(word, cb);
};
});
async.parallel(
processFunctions,
function (error, results) {
if (error) ... | javascript | function processTokens(tokens, callback) {
"use strict";
var processFunctions = underscore.map(tokens, function (word) {
return function (cb) {
tokenizeWord(word, cb);
};
});
async.parallel(
processFunctions,
function (error, results) {
if (error) ... | [
"function",
"processTokens",
"(",
"tokens",
",",
"callback",
")",
"{",
"\"use strict\"",
";",
"var",
"processFunctions",
"=",
"underscore",
".",
"map",
"(",
"tokens",
",",
"function",
"(",
"word",
")",
"{",
"return",
"function",
"(",
"cb",
")",
"{",
"token... | Processes each word of the given tokens
@param String[] tokens Array of Strings
@param Function callback Callback function with this signature: function(error, String[])
@private | [
"Processes",
"each",
"word",
"of",
"the",
"given",
"tokens"
] | f776202c22c7ca2ee50deb1bae6130fd3dcfe7fc | https://github.com/thomasfr/Timeliner.Core/blob/f776202c22c7ca2ee50deb1bae6130fd3dcfe7fc/lib/processTokens.js#L12-L35 | train |
sumanjs/karma-suman | src/adapter.js | getRelevantStackFrom | function getRelevantStackFrom (stack) {
var filteredStack = [];
var relevantStack = [];
stack = stack.split('\n');
for (var i = 0; i < stack.length; i += 1) {
if (isExternalStackEntry(stack[i])) {
filteredStack.push(stack[i])
}
}
// If the filtered stack is empty, i.e. the error originated ... | javascript | function getRelevantStackFrom (stack) {
var filteredStack = [];
var relevantStack = [];
stack = stack.split('\n');
for (var i = 0; i < stack.length; i += 1) {
if (isExternalStackEntry(stack[i])) {
filteredStack.push(stack[i])
}
}
// If the filtered stack is empty, i.e. the error originated ... | [
"function",
"getRelevantStackFrom",
"(",
"stack",
")",
"{",
"var",
"filteredStack",
"=",
"[",
"]",
";",
"var",
"relevantStack",
"=",
"[",
"]",
";",
"stack",
"=",
"stack",
".",
"split",
"(",
"'\\n'",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
... | Returns relevant stack entries.
@param {String} stack Complete error stack trace.
@return {Array} A list of relevant stack entries. | [
"Returns",
"relevant",
"stack",
"entries",
"."
] | 7c5fa9044571c8e49f49c07abc5f493af3070dc4 | https://github.com/sumanjs/karma-suman/blob/7c5fa9044571c8e49f49c07abc5f493af3070dc4/src/adapter.js#L23-L48 | train |
sumanjs/karma-suman | src/adapter.js | formatFailedStep | function formatFailedStep (step) {
// Safari seems to have no stack trace,
// so we just return the error message:
if (!step.stack) { return step.message }
var relevantMessage = [];
var relevantStack = [];
// Remove the message prior to processing the stack to prevent issues like
// https://github.com/k... | javascript | function formatFailedStep (step) {
// Safari seems to have no stack trace,
// so we just return the error message:
if (!step.stack) { return step.message }
var relevantMessage = [];
var relevantStack = [];
// Remove the message prior to processing the stack to prevent issues like
// https://github.com/k... | [
"function",
"formatFailedStep",
"(",
"step",
")",
"{",
"// Safari seems to have no stack trace,",
"// so we just return the error message:",
"if",
"(",
"!",
"step",
".",
"stack",
")",
"{",
"return",
"step",
".",
"message",
"}",
"var",
"relevantMessage",
"=",
"[",
"]... | Custom formatter for a failed step.
Different browsers report stack trace in different ways. This function
attempts to provide a concise, relevant error message by removing the
unnecessary stack traces coming from the testing framework itself as well
as possible repetition.
@see https://github.com/karma-runner/kar... | [
"Custom",
"formatter",
"for",
"a",
"failed",
"step",
"."
] | 7c5fa9044571c8e49f49c07abc5f493af3070dc4 | https://github.com/sumanjs/karma-suman/blob/7c5fa9044571c8e49f49c07abc5f493af3070dc4/src/adapter.js#L62-L114 | train |
sumanjs/karma-suman | src/adapter.js | function (clientArguments) {
var grepRegex = /^--grep=(.*)$/;
if (Object.prototype.toString.call(clientArguments) === '[object Array]') {
var indexOfGrep = indexOf(clientArguments, '--grep');
if (indexOfGrep !== -1) {
return clientArguments[indexOfGrep + 1]
}
return map(filter(clientArgumen... | javascript | function (clientArguments) {
var grepRegex = /^--grep=(.*)$/;
if (Object.prototype.toString.call(clientArguments) === '[object Array]') {
var indexOfGrep = indexOf(clientArguments, '--grep');
if (indexOfGrep !== -1) {
return clientArguments[indexOfGrep + 1]
}
return map(filter(clientArgumen... | [
"function",
"(",
"clientArguments",
")",
"{",
"var",
"grepRegex",
"=",
"/",
"^--grep=(.*)$",
"/",
";",
"if",
"(",
"Object",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"clientArguments",
")",
"===",
"'[object Array]'",
")",
"{",
"var",
"indexOfGrep"... | Extract grep option from karma config
@param {[Array|string]} clientArguments The karma client arguments
@return {string} The value of grep option by default empty string | [
"Extract",
"grep",
"option",
"from",
"karma",
"config"
] | 7c5fa9044571c8e49f49c07abc5f493af3070dc4 | https://github.com/sumanjs/karma-suman/blob/7c5fa9044571c8e49f49c07abc5f493af3070dc4/src/adapter.js#L280-L300 | train | |
sumanjs/karma-suman | src/adapter.js | createStartFn | function createStartFn (karma, jasmineEnv) {
function setOption (option, set) {
if (option != null) {
set(option)
}
}
// This function will be assigned to `window.__karma__.start`:
return function () {
console.log('suman started.');
window.__suman.tsrq.resume();
// var clientConfig... | javascript | function createStartFn (karma, jasmineEnv) {
function setOption (option, set) {
if (option != null) {
set(option)
}
}
// This function will be assigned to `window.__karma__.start`:
return function () {
console.log('suman started.');
window.__suman.tsrq.resume();
// var clientConfig... | [
"function",
"createStartFn",
"(",
"karma",
",",
"jasmineEnv",
")",
"{",
"function",
"setOption",
"(",
"option",
",",
"set",
")",
"{",
"if",
"(",
"option",
"!=",
"null",
")",
"{",
"set",
"(",
"option",
")",
"}",
"}",
"// This function will be assigned to `win... | Karma starter function factory.
This function is invoked from the wrapper.
@see adapter.wrapper
@param {Object} karma Karma runner instance.
@param {Object} [jasmineEnv] Optional Jasmine environment for testing.
@return {Function} Karma starter function. | [
"Karma",
"starter",
"function",
"factory",
"."
] | 7c5fa9044571c8e49f49c07abc5f493af3070dc4 | https://github.com/sumanjs/karma-suman/blob/7c5fa9044571c8e49f49c07abc5f493af3070dc4/src/adapter.js#L341-L369 | train |
sendanor/nor-nopg | src/merge.js | _copy_property | function _copy_property(opts, key, a, b) {
debug.assert(opts).is('object');
debug.assert(key).is('string');
debug.assert(a).is('object');
debug.assert(b).is('object');
a[key] = b[key];
if(opts.cache && opts.cache._has_cursors && is.obj(b[key]) && b[key].hasOwnProperty('$id')) {
var f = opts.cache.findCursor(b... | javascript | function _copy_property(opts, key, a, b) {
debug.assert(opts).is('object');
debug.assert(key).is('string');
debug.assert(a).is('object');
debug.assert(b).is('object');
a[key] = b[key];
if(opts.cache && opts.cache._has_cursors && is.obj(b[key]) && b[key].hasOwnProperty('$id')) {
var f = opts.cache.findCursor(b... | [
"function",
"_copy_property",
"(",
"opts",
",",
"key",
",",
"a",
",",
"b",
")",
"{",
"debug",
".",
"assert",
"(",
"opts",
")",
".",
"is",
"(",
"'object'",
")",
";",
"debug",
".",
"assert",
"(",
"key",
")",
".",
"is",
"(",
"'string'",
")",
";",
... | Copy property from a to b
@param opts {object} Options
@param key {string} The keyword of the property
@param a {object} Copy to
@param b {object} Copy from | [
"Copy",
"property",
"from",
"a",
"to",
"b"
] | 0d99b86c1a1996b5828b56de8de23700df8bbc0c | https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/merge.js#L78-L94 | train |
sendanor/nor-nopg | src/merge.js | merge_objects_ | function merge_objects_(b) {
if(is.func(b)) {
b = b();
}
debug.assert(b).is('object');
_merge_object(opts, a, b);
} | javascript | function merge_objects_(b) {
if(is.func(b)) {
b = b();
}
debug.assert(b).is('object');
_merge_object(opts, a, b);
} | [
"function",
"merge_objects_",
"(",
"b",
")",
"{",
"if",
"(",
"is",
".",
"func",
"(",
"b",
")",
")",
"{",
"b",
"=",
"b",
"(",
")",
";",
"}",
"debug",
".",
"assert",
"(",
"b",
")",
".",
"is",
"(",
"'object'",
")",
";",
"_merge_object",
"(",
"op... | Merge `a` and `b` | [
"Merge",
"a",
"and",
"b"
] | 0d99b86c1a1996b5828b56de8de23700df8bbc0c | https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/merge.js#L239-L245 | train |
MakerCollider/node-red-contrib-smartnode-hook | html/scripts/highchart/modules/solid-gauge.src.js | function (init) {
if (!init) {
this.startAngleRad = this.yAxis.startAngleRad;
H.seriesTypes.pie.prototype.animate.call(this, init);
}
} | javascript | function (init) {
if (!init) {
this.startAngleRad = this.yAxis.startAngleRad;
H.seriesTypes.pie.prototype.animate.call(this, init);
}
} | [
"function",
"(",
"init",
")",
"{",
"if",
"(",
"!",
"init",
")",
"{",
"this",
".",
"startAngleRad",
"=",
"this",
".",
"yAxis",
".",
"startAngleRad",
";",
"H",
".",
"seriesTypes",
".",
"pie",
".",
"prototype",
".",
"animate",
".",
"call",
"(",
"this",
... | Extend the pie slice animation by animating from start angle and up | [
"Extend",
"the",
"pie",
"slice",
"animation",
"by",
"animating",
"from",
"start",
"angle",
"and",
"up"
] | 245c267e832968bad880ca009929043e82c7bc25 | https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/solid-gauge.src.js#L258-L264 | train | |
redisjs/jsr-server | lib/command/server/bgsave.js | execute | function execute(req, res) {
this.log.notice('background saving started by pid %s', process.pid);
function onSave(err) {
/* istanbul ignore next: not prepared to mock this right now */
if(err) return this.log.warning('background save failed: %s', err.message);
this.log.notice('background saving terminat... | javascript | function execute(req, res) {
this.log.notice('background saving started by pid %s', process.pid);
function onSave(err) {
/* istanbul ignore next: not prepared to mock this right now */
if(err) return this.log.warning('background save failed: %s', err.message);
this.log.notice('background saving terminat... | [
"function",
"execute",
"(",
"req",
",",
"res",
")",
"{",
"this",
".",
"log",
".",
"notice",
"(",
"'background saving started by pid %s'",
",",
"process",
".",
"pid",
")",
";",
"function",
"onSave",
"(",
"err",
")",
"{",
"/* istanbul ignore next: not prepared to ... | Respond to the BGSAVE command. | [
"Respond",
"to",
"the",
"BGSAVE",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/bgsave.js#L20-L29 | train |
redisjs/jsr-server | lib/command/server/bgsave.js | validate | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
if(Persistence.saving) throw SaveInProgress;
} | javascript | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
if(Persistence.saving) throw SaveInProgress;
} | [
"function",
"validate",
"(",
"cmd",
",",
"args",
",",
"info",
")",
"{",
"AbstractCommand",
".",
"prototype",
".",
"validate",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"if",
"(",
"Persistence",
".",
"saving",
")",
"throw",
"SaveInProgress",
... | Validate the BGSAVE command. | [
"Validate",
"the",
"BGSAVE",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/bgsave.js#L34-L37 | train |
redisjs/jsr-server | lib/slowlog.js | SlowLogRecord | function SlowLogRecord(cmd, args) {
this._now = Date.now();
this._cmd = [cmd].concat(args);
// start timer value when command execution started
this._start = process.hrtime();
} | javascript | function SlowLogRecord(cmd, args) {
this._now = Date.now();
this._cmd = [cmd].concat(args);
// start timer value when command execution started
this._start = process.hrtime();
} | [
"function",
"SlowLogRecord",
"(",
"cmd",
",",
"args",
")",
"{",
"this",
".",
"_now",
"=",
"Date",
".",
"now",
"(",
")",
";",
"this",
".",
"_cmd",
"=",
"[",
"cmd",
"]",
".",
"concat",
"(",
"args",
")",
";",
"// start timer value when command execution sta... | Encapsulates a slowlog record. | [
"Encapsulates",
"a",
"slowlog",
"record",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/slowlog.js#L8-L14 | train |
redisjs/jsr-server | lib/slowlog.js | isSlowerThan | function isSlowerThan(amount) {
// always logging
var diff = process.hrtime(this._start)
, micro = Math.round(((diff[0] * 1e9) + diff[1]) / 1e3);
if(amount === 0) return micro;
if(micro > amount) {
return micro;
}
return -1;
} | javascript | function isSlowerThan(amount) {
// always logging
var diff = process.hrtime(this._start)
, micro = Math.round(((diff[0] * 1e9) + diff[1]) / 1e3);
if(amount === 0) return micro;
if(micro > amount) {
return micro;
}
return -1;
} | [
"function",
"isSlowerThan",
"(",
"amount",
")",
"{",
"// always logging",
"var",
"diff",
"=",
"process",
".",
"hrtime",
"(",
"this",
".",
"_start",
")",
",",
"micro",
"=",
"Math",
".",
"round",
"(",
"(",
"(",
"diff",
"[",
"0",
"]",
"*",
"1e9",
")",
... | Determine if this log record took longer than
the specified amount. | [
"Determine",
"if",
"this",
"log",
"record",
"took",
"longer",
"than",
"the",
"specified",
"amount",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/slowlog.js#L20-L29 | train |
redisjs/jsr-server | lib/slowlog.js | toArray | function toArray(id, time) {
var o = [
id,
Math.round(this._now / 1000),
time,
this._cmd];
return o;
} | javascript | function toArray(id, time) {
var o = [
id,
Math.round(this._now / 1000),
time,
this._cmd];
return o;
} | [
"function",
"toArray",
"(",
"id",
",",
"time",
")",
"{",
"var",
"o",
"=",
"[",
"id",
",",
"Math",
".",
"round",
"(",
"this",
".",
"_now",
"/",
"1000",
")",
",",
"time",
",",
"this",
".",
"_cmd",
"]",
";",
"return",
"o",
";",
"}"
] | Convert this log record to an array, only called if
the command took longer than the configured slower than
amount.
@param id The id for the record.
@param time The execution time in microseconds. | [
"Convert",
"this",
"log",
"record",
"to",
"an",
"array",
"only",
"called",
"if",
"the",
"command",
"took",
"longer",
"than",
"the",
"configured",
"slower",
"than",
"amount",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/slowlog.js#L39-L46 | train |
redisjs/jsr-server | lib/slowlog.js | SlowLog | function SlowLog(conf) {
this._conf = conf;
// log commands slower than this number of microseconds
// disabled by default
this._slowerThan = -1;
// maximum length of the slow log
this._maxLen = 128;
// set up log records array
this.reset();
// log record for the current executing command
this._... | javascript | function SlowLog(conf) {
this._conf = conf;
// log commands slower than this number of microseconds
// disabled by default
this._slowerThan = -1;
// maximum length of the slow log
this._maxLen = 128;
// set up log records array
this.reset();
// log record for the current executing command
this._... | [
"function",
"SlowLog",
"(",
"conf",
")",
"{",
"this",
".",
"_conf",
"=",
"conf",
";",
"// log commands slower than this number of microseconds",
"// disabled by default",
"this",
".",
"_slowerThan",
"=",
"-",
"1",
";",
"// maximum length of the slow log",
"this",
".",
... | Encapsulates the slow log queries storage.
@param conf The server configuration. | [
"Encapsulates",
"the",
"slow",
"log",
"queries",
"storage",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/slowlog.js#L56-L99 | train |
redisjs/jsr-server | lib/slowlog.js | start | function start(cmd, args) {
if(!this.enabled) return false;
this._record = new SlowLogRecord(cmd, args);
return this._record;
} | javascript | function start(cmd, args) {
if(!this.enabled) return false;
this._record = new SlowLogRecord(cmd, args);
return this._record;
} | [
"function",
"start",
"(",
"cmd",
",",
"args",
")",
"{",
"if",
"(",
"!",
"this",
".",
"enabled",
")",
"return",
"false",
";",
"this",
".",
"_record",
"=",
"new",
"SlowLogRecord",
"(",
"cmd",
",",
"args",
")",
";",
"return",
"this",
".",
"_record",
"... | Start timing command execution. | [
"Start",
"timing",
"command",
"execution",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/slowlog.js#L104-L108 | train |
redisjs/jsr-server | lib/slowlog.js | stop | function stop() {
var time;
if(!this.enabled) return false;
time = this._record.isSlowerThan(this._slowerThan);
if(this._record && time > -1) {
this._records.unshift(this._record.toArray(id++, time));
if(this._records.length >= this._maxLen) {
this._records.pop();
}
}
} | javascript | function stop() {
var time;
if(!this.enabled) return false;
time = this._record.isSlowerThan(this._slowerThan);
if(this._record && time > -1) {
this._records.unshift(this._record.toArray(id++, time));
if(this._records.length >= this._maxLen) {
this._records.pop();
}
}
} | [
"function",
"stop",
"(",
")",
"{",
"var",
"time",
";",
"if",
"(",
"!",
"this",
".",
"enabled",
")",
"return",
"false",
";",
"time",
"=",
"this",
".",
"_record",
".",
"isSlowerThan",
"(",
"this",
".",
"_slowerThan",
")",
";",
"if",
"(",
"this",
".",... | Stop timing current command execution. | [
"Stop",
"timing",
"current",
"command",
"execution",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/slowlog.js#L113-L123 | train |
redisjs/jsr-server | lib/slowlog.js | get | function get(amount) {
amount = amount !== undefined && amount >= 0 ? amount : 10;
amount = Math.min(amount, this._records.length);
return this._records.slice(0, amount);
} | javascript | function get(amount) {
amount = amount !== undefined && amount >= 0 ? amount : 10;
amount = Math.min(amount, this._records.length);
return this._records.slice(0, amount);
} | [
"function",
"get",
"(",
"amount",
")",
"{",
"amount",
"=",
"amount",
"!==",
"undefined",
"&&",
"amount",
">=",
"0",
"?",
"amount",
":",
"10",
";",
"amount",
"=",
"Math",
".",
"min",
"(",
"amount",
",",
"this",
".",
"_records",
".",
"length",
")",
"... | Get a list of slowlog records.
Suitable for invoking from SLOWLOG GET. | [
"Get",
"a",
"list",
"of",
"slowlog",
"records",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/slowlog.js#L130-L134 | train |
redisjs/jsr-conf | lib/type/typedef.js | TypeDef | function TypeDef(arity, type, repeats) {
// arity for the parameter
this.arity = arity;
// type declarations as an array
this.type = type;
// does this value accumulate repeating declarations
this.repeats = repeats;
} | javascript | function TypeDef(arity, type, repeats) {
// arity for the parameter
this.arity = arity;
// type declarations as an array
this.type = type;
// does this value accumulate repeating declarations
this.repeats = repeats;
} | [
"function",
"TypeDef",
"(",
"arity",
",",
"type",
",",
"repeats",
")",
"{",
"// arity for the parameter",
"this",
".",
"arity",
"=",
"arity",
";",
"// type declarations as an array",
"this",
".",
"type",
"=",
"type",
";",
"// does this value accumulate repeating decla... | Encapsulates a configuration type definition. | [
"Encapsulates",
"a",
"configuration",
"type",
"definition",
"."
] | 97c5e2e77e1601c879a62dfc2d500df537eaaddd | https://github.com/redisjs/jsr-conf/blob/97c5e2e77e1601c879a62dfc2d500df537eaaddd/lib/type/typedef.js#L11-L20 | train |
redisjs/jsr-conf | lib/type/typedef.js | validate | function validate(key, values) {
if(this.arity > 0 && values.length !== this.arity) {
throw new TypeDefError(
util.format('bad arity for \'%s\', expected %s got %s',
key, this.arity, values.length));
}
var types = Array.isArray(this.type) ? this.type : [this.type]
, i
, type
, val
... | javascript | function validate(key, values) {
if(this.arity > 0 && values.length !== this.arity) {
throw new TypeDefError(
util.format('bad arity for \'%s\', expected %s got %s',
key, this.arity, values.length));
}
var types = Array.isArray(this.type) ? this.type : [this.type]
, i
, type
, val
... | [
"function",
"validate",
"(",
"key",
",",
"values",
")",
"{",
"if",
"(",
"this",
".",
"arity",
">",
"0",
"&&",
"values",
".",
"length",
"!==",
"this",
".",
"arity",
")",
"{",
"throw",
"new",
"TypeDefError",
"(",
"util",
".",
"format",
"(",
"'bad arity... | Validate an array of values against this type
definition. | [
"Validate",
"an",
"array",
"of",
"values",
"against",
"this",
"type",
"definition",
"."
] | 97c5e2e77e1601c879a62dfc2d500df537eaaddd | https://github.com/redisjs/jsr-conf/blob/97c5e2e77e1601c879a62dfc2d500df537eaaddd/lib/type/typedef.js#L26-L80 | train |
redisjs/jsr-conf | lib/type/typedef.js | encode | function encode(key, value, stringify) {
var space = ' ', val = [], i, type = this.type;
function coerce(type, val) {
var out
, enumerable = Array.isArray(type);
if(enumerable) {
if(!~type.indexOf(val)) {
throw new TypeDefError(
util.format('enum error on key \'%s\', got \'%s\... | javascript | function encode(key, value, stringify) {
var space = ' ', val = [], i, type = this.type;
function coerce(type, val) {
var out
, enumerable = Array.isArray(type);
if(enumerable) {
if(!~type.indexOf(val)) {
throw new TypeDefError(
util.format('enum error on key \'%s\', got \'%s\... | [
"function",
"encode",
"(",
"key",
",",
"value",
",",
"stringify",
")",
"{",
"var",
"space",
"=",
"' '",
",",
"val",
"=",
"[",
"]",
",",
"i",
",",
"type",
"=",
"this",
".",
"type",
";",
"function",
"coerce",
"(",
"type",
",",
"val",
")",
"{",
"v... | Encode a type value back to a string suitable for
writing to a configuration file. | [
"Encode",
"a",
"type",
"value",
"back",
"to",
"a",
"string",
"suitable",
"for",
"writing",
"to",
"a",
"configuration",
"file",
"."
] | 97c5e2e77e1601c879a62dfc2d500df537eaaddd | https://github.com/redisjs/jsr-conf/blob/97c5e2e77e1601c879a62dfc2d500df537eaaddd/lib/type/typedef.js#L86-L157 | train |
skerit/alchemy | lib/class/conduit.js | qualityCmp | function qualityCmp(a, b) {
if (a.quality === b.quality) {
return 0;
} else if (a.quality < b.quality) {
return 1;
} else {
return -1;
}
} | javascript | function qualityCmp(a, b) {
if (a.quality === b.quality) {
return 0;
} else if (a.quality < b.quality) {
return 1;
} else {
return -1;
}
} | [
"function",
"qualityCmp",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"a",
".",
"quality",
"===",
"b",
".",
"quality",
")",
"{",
"return",
"0",
";",
"}",
"else",
"if",
"(",
"a",
".",
"quality",
"<",
"b",
".",
"quality",
")",
"{",
"return",
"1",
... | Sort the parsed accept-language header array
@author Jelle De Loecker <jelle@develry.be>
@since 0.0.1
@version 0.0.1
@param {Object} a
@param {Object} b | [
"Sort",
"the",
"parsed",
"accept",
"-",
"language",
"header",
"array"
] | ede1dad07a5a737d5d1e10c2ff87fdfb057443f8 | https://github.com/skerit/alchemy/blob/ede1dad07a5a737d5d1e10c2ff87fdfb057443f8/lib/class/conduit.js#L365-L373 | train |
skerit/alchemy | lib/class/conduit.js | parseEncoding | function parseEncoding(s, i) {
var match = s.match(/^\s*(\S+?)\s*(?:;(.*))?$/);
if (!match) return null;
var encoding = match[1];
var q = 1;
if (match[2]) {
var params = match[2].split(';');
for (var i = 0; i < params.length; i ++) {
var p = params[i].trim().split('=');
if (p[0] === 'q') {
q = pars... | javascript | function parseEncoding(s, i) {
var match = s.match(/^\s*(\S+?)\s*(?:;(.*))?$/);
if (!match) return null;
var encoding = match[1];
var q = 1;
if (match[2]) {
var params = match[2].split(';');
for (var i = 0; i < params.length; i ++) {
var p = params[i].trim().split('=');
if (p[0] === 'q') {
q = pars... | [
"function",
"parseEncoding",
"(",
"s",
",",
"i",
")",
"{",
"var",
"match",
"=",
"s",
".",
"match",
"(",
"/",
"^\\s*(\\S+?)\\s*(?:;(.*))?$",
"/",
")",
";",
"if",
"(",
"!",
"match",
")",
"return",
"null",
";",
"var",
"encoding",
"=",
"match",
"[",
"1",... | Parses accept-encoding strings
@author jshttp
@author Jelle De Loecker <jelle@develry.be>
@since 0.2.0
@version 0.2.0 | [
"Parses",
"accept",
"-",
"encoding",
"strings"
] | ede1dad07a5a737d5d1e10c2ff87fdfb057443f8 | https://github.com/skerit/alchemy/blob/ede1dad07a5a737d5d1e10c2ff87fdfb057443f8/lib/class/conduit.js#L446-L469 | train |
skerit/alchemy | lib/class/conduit.js | getMagic | function getMagic() {
var mmmagic;
if (magic || magic === false) {
return magic;
}
// Get mmmagic module
mmmagic = alchemy.use('mmmagic')
if (mmmagic) {
magic = new mmmagic.Magic(mmmagic.MAGIC_MIME_TYPE);
} else {
log.error('Could not load mmmagic module');
magic = false;
}
return magic;
} | javascript | function getMagic() {
var mmmagic;
if (magic || magic === false) {
return magic;
}
// Get mmmagic module
mmmagic = alchemy.use('mmmagic')
if (mmmagic) {
magic = new mmmagic.Magic(mmmagic.MAGIC_MIME_TYPE);
} else {
log.error('Could not load mmmagic module');
magic = false;
}
return magic;
} | [
"function",
"getMagic",
"(",
")",
"{",
"var",
"mmmagic",
";",
"if",
"(",
"magic",
"||",
"magic",
"===",
"false",
")",
"{",
"return",
"magic",
";",
"}",
"// Get mmmagic module",
"mmmagic",
"=",
"alchemy",
".",
"use",
"(",
"'mmmagic'",
")",
"if",
"(",
"m... | Get the magic mimetype function
@author Jelle De Loecker <jelle@develry.be>
@since 0.3.0
@version 0.3.0 | [
"Get",
"the",
"magic",
"mimetype",
"function"
] | ede1dad07a5a737d5d1e10c2ff87fdfb057443f8 | https://github.com/skerit/alchemy/blob/ede1dad07a5a737d5d1e10c2ff87fdfb057443f8/lib/class/conduit.js#L2102-L2121 | train |
hydrojs/doc | index.js | indent | function indent(node) {
var next = node;
var i = 0;
while (next) {
++i;
next = next.suite || next.parent;
}
return Array(i).join(' ');
} | javascript | function indent(node) {
var next = node;
var i = 0;
while (next) {
++i;
next = next.suite || next.parent;
}
return Array(i).join(' ');
} | [
"function",
"indent",
"(",
"node",
")",
"{",
"var",
"next",
"=",
"node",
";",
"var",
"i",
"=",
"0",
";",
"while",
"(",
"next",
")",
"{",
"++",
"i",
";",
"next",
"=",
"next",
".",
"suite",
"||",
"next",
".",
"parent",
";",
"}",
"return",
"Array"... | Return indent for suite|test.
@param {Suite|Test} node
@returns {String}
@api private | [
"Return",
"indent",
"for",
"suite|test",
"."
] | 59741051489a97c4800f9ee362110a263a274cd0 | https://github.com/hydrojs/doc/blob/59741051489a97c4800f9ee362110a263a274cd0/index.js#L15-L23 | train |
blacksmithstudio/blockbase-express | driver.js | route | function route() {
configure()
middlewares()
for (let route of config.routes) {
if (route.type === 'view')
server[route.method](route.src, (req, res) => {
res.render(`${app.root}/views/${route.dest}.twig`, {})
})
if (... | javascript | function route() {
configure()
middlewares()
for (let route of config.routes) {
if (route.type === 'view')
server[route.method](route.src, (req, res) => {
res.render(`${app.root}/views/${route.dest}.twig`, {})
})
if (... | [
"function",
"route",
"(",
")",
"{",
"configure",
"(",
")",
"middlewares",
"(",
")",
"for",
"(",
"let",
"route",
"of",
"config",
".",
"routes",
")",
"{",
"if",
"(",
"route",
".",
"type",
"===",
"'view'",
")",
"server",
"[",
"route",
".",
"method",
"... | Initialize the routes | [
"Initialize",
"the",
"routes"
] | b9d9fb710122f38a84090f47a4bb987d07f1adc4 | https://github.com/blacksmithstudio/blockbase-express/blob/b9d9fb710122f38a84090f47a4bb987d07f1adc4/driver.js#L66-L102 | train |
blacksmithstudio/blockbase-express | driver.js | errors | function errors() {
// handling 404 errors from config.express['404_redirect'] property
if (config['404_redirect']) {
server.use(function (req, res, next) {
res.status(302)
res.writeHead(302, { 'Location': config['404_redirect'] })
res.end()
... | javascript | function errors() {
// handling 404 errors from config.express['404_redirect'] property
if (config['404_redirect']) {
server.use(function (req, res, next) {
res.status(302)
res.writeHead(302, { 'Location': config['404_redirect'] })
res.end()
... | [
"function",
"errors",
"(",
")",
"{",
"// handling 404 errors from config.express['404_redirect'] property",
"if",
"(",
"config",
"[",
"'404_redirect'",
"]",
")",
"{",
"server",
".",
"use",
"(",
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"res",
... | Register error handlers | [
"Register",
"error",
"handlers"
] | b9d9fb710122f38a84090f47a4bb987d07f1adc4 | https://github.com/blacksmithstudio/blockbase-express/blob/b9d9fb710122f38a84090f47a4bb987d07f1adc4/driver.js#L107-L137 | train |
redisjs/jsr-store | lib/command/set.js | sadd | function sadd(key /* member-1, member-N, req */) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length-1] === 'object' ? args.pop() : null
, val = this.getKey(key, req);
if(val === undefined) {
val = new Set();
this.setKey(key, val, undefined, undefined, undefined, req);
}
return... | javascript | function sadd(key /* member-1, member-N, req */) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length-1] === 'object' ? args.pop() : null
, val = this.getKey(key, req);
if(val === undefined) {
val = new Set();
this.setKey(key, val, undefined, undefined, undefined, req);
}
return... | [
"function",
"sadd",
"(",
"key",
"/* member-1, member-N, req */",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
",",
"req",
"=",
"typeof",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
"===",
"'object'",
"?",
... | Add the specified members to the set stored at key. | [
"Add",
"the",
"specified",
"members",
"to",
"the",
"set",
"stored",
"at",
"key",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/set.js#L7-L16 | train |
redisjs/jsr-store | lib/command/set.js | smembers | function smembers(key, req) {
var val = this.getKey(key, req);
if(val === undefined) return [];
return val.data;
} | javascript | function smembers(key, req) {
var val = this.getKey(key, req);
if(val === undefined) return [];
return val.data;
} | [
"function",
"smembers",
"(",
"key",
",",
"req",
")",
"{",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
";",
"if",
"(",
"val",
"===",
"undefined",
")",
"return",
"[",
"]",
";",
"return",
"val",
".",
"data",
";",
"}"
] | Returns all the members of the set value stored at key. | [
"Returns",
"all",
"the",
"members",
"of",
"the",
"set",
"value",
"stored",
"at",
"key",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/set.js#L44-L48 | train |
redisjs/jsr-store | lib/command/set.js | sismember | function sismember(key, member, req) {
var val = this.getKey(key, req);
if(val === undefined) return 0;
return val.sismember(member);
} | javascript | function sismember(key, member, req) {
var val = this.getKey(key, req);
if(val === undefined) return 0;
return val.sismember(member);
} | [
"function",
"sismember",
"(",
"key",
",",
"member",
",",
"req",
")",
"{",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
";",
"if",
"(",
"val",
"===",
"undefined",
")",
"return",
"0",
";",
"return",
"val",
".",
"sismember",
... | Returns if member is a member of the set stored at key. | [
"Returns",
"if",
"member",
"is",
"a",
"member",
"of",
"the",
"set",
"stored",
"at",
"key",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/set.js#L53-L57 | train |
redisjs/jsr-store | lib/command/set.js | spop | function spop(key, req) {
var val = this.getKey(key, req);
if(val === undefined) return null;
var element = val.spop();
if(val.scard() === 0) {
this.delKey(key, req);
}
return element;
} | javascript | function spop(key, req) {
var val = this.getKey(key, req);
if(val === undefined) return null;
var element = val.spop();
if(val.scard() === 0) {
this.delKey(key, req);
}
return element;
} | [
"function",
"spop",
"(",
"key",
",",
"req",
")",
"{",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
";",
"if",
"(",
"val",
"===",
"undefined",
")",
"return",
"null",
";",
"var",
"element",
"=",
"val",
".",
"spop",
"(",
... | Removes and returns a random element from the set value
stored at key. | [
"Removes",
"and",
"returns",
"a",
"random",
"element",
"from",
"the",
"set",
"value",
"stored",
"at",
"key",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/set.js#L63-L71 | train |
redisjs/jsr-store | lib/command/set.js | srem | function srem(key /* member-1, member-N, req */) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length-1] === 'object' ? args.pop() : null
, val = this.getKey(key, req);
if(val === undefined) return 0;
var deleted = val.srem(args);
if(val.scard() === 0) {
this.delKey(key, req);
}
... | javascript | function srem(key /* member-1, member-N, req */) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length-1] === 'object' ? args.pop() : null
, val = this.getKey(key, req);
if(val === undefined) return 0;
var deleted = val.srem(args);
if(val.scard() === 0) {
this.delKey(key, req);
}
... | [
"function",
"srem",
"(",
"key",
"/* member-1, member-N, req */",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
",",
"req",
"=",
"typeof",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
"===",
"'object'",
"?",
... | Remove the specified members from the set stored at key. | [
"Remove",
"the",
"specified",
"members",
"from",
"the",
"set",
"stored",
"at",
"key",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/set.js#L76-L86 | train |
redisjs/jsr-store | lib/command/set.js | smove | function smove(source, destination, member, req) {
var src = this.getKey(source, req)
, dest = this.getKey(destination, req);
if(src === undefined || !src.sismember(member)) return 0;
if(dest === undefined) {
dest = new Set();
this.setKey(destination, dest, undefined, undefined, undefined, req);
}
... | javascript | function smove(source, destination, member, req) {
var src = this.getKey(source, req)
, dest = this.getKey(destination, req);
if(src === undefined || !src.sismember(member)) return 0;
if(dest === undefined) {
dest = new Set();
this.setKey(destination, dest, undefined, undefined, undefined, req);
}
... | [
"function",
"smove",
"(",
"source",
",",
"destination",
",",
"member",
",",
"req",
")",
"{",
"var",
"src",
"=",
"this",
".",
"getKey",
"(",
"source",
",",
"req",
")",
",",
"dest",
"=",
"this",
".",
"getKey",
"(",
"destination",
",",
"req",
")",
";"... | Move member from the set at source to the set at destination. | [
"Move",
"member",
"from",
"the",
"set",
"at",
"source",
"to",
"the",
"set",
"at",
"destination",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/set.js#L91-L106 | train |
redisjs/jsr-store | lib/command/set.js | sunion | function sunion(/* key-1, key-N, req*/) {
var args = slice.call(arguments, 0)
, req = typeof args[args.length-1] === 'object' ? args.pop() : null
, set
, src
, i;
set = new Set();
for(i = 0;i < args.length;i++) {
src = this.getKey(args[i], req);
if(src === undefined) continue;
set.sadd... | javascript | function sunion(/* key-1, key-N, req*/) {
var args = slice.call(arguments, 0)
, req = typeof args[args.length-1] === 'object' ? args.pop() : null
, set
, src
, i;
set = new Set();
for(i = 0;i < args.length;i++) {
src = this.getKey(args[i], req);
if(src === undefined) continue;
set.sadd... | [
"function",
"sunion",
"(",
"/* key-1, key-N, req*/",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"0",
")",
",",
"req",
"=",
"typeof",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
"===",
"'object'",
"?",
"args",
".... | Returns the members of the set resulting from the union
of all the given sets. | [
"Returns",
"the",
"members",
"of",
"the",
"set",
"resulting",
"from",
"the",
"union",
"of",
"all",
"the",
"given",
"sets",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/set.js#L112-L125 | train |
redisjs/jsr-store | lib/command/set.js | sunionstore | function sunionstore(destination /* key-1, key-N, req*/) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length-1] === 'object'
? args[args.length - 1] : null;
var list = this.sunion.apply(this, args);
if(list.length) {
this.setKey(
destination, new Set(list), undefined, undefin... | javascript | function sunionstore(destination /* key-1, key-N, req*/) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length-1] === 'object'
? args[args.length - 1] : null;
var list = this.sunion.apply(this, args);
if(list.length) {
this.setKey(
destination, new Set(list), undefined, undefin... | [
"function",
"sunionstore",
"(",
"destination",
"/* key-1, key-N, req*/",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
",",
"req",
"=",
"typeof",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
"===",
"'object'",... | Stores the members of the set resulting from the union
of all the given sets. | [
"Stores",
"the",
"members",
"of",
"the",
"set",
"resulting",
"from",
"the",
"union",
"of",
"all",
"the",
"given",
"sets",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/set.js#L131-L141 | train |
redisjs/jsr-store | lib/command/set.js | sinter | function sinter(/* key-1, key-N, req*/) {
var args = slice.call(arguments, 0)
, req = typeof args[args.length-1] === 'object' ? args.pop() : null
, set = new Set()
, list
, src
, i;
for(i = 0;i < args.length;i++) {
src = this.getKey(args[i], req);
if(src === undefined) return [];
se... | javascript | function sinter(/* key-1, key-N, req*/) {
var args = slice.call(arguments, 0)
, req = typeof args[args.length-1] === 'object' ? args.pop() : null
, set = new Set()
, list
, src
, i;
for(i = 0;i < args.length;i++) {
src = this.getKey(args[i], req);
if(src === undefined) return [];
se... | [
"function",
"sinter",
"(",
"/* key-1, key-N, req*/",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"0",
")",
",",
"req",
"=",
"typeof",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
"===",
"'object'",
"?",
"args",
".... | Returns the members of the set resulting from the intersection
of all the given sets. | [
"Returns",
"the",
"members",
"of",
"the",
"set",
"resulting",
"from",
"the",
"intersection",
"of",
"all",
"the",
"given",
"sets",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/set.js#L147-L174 | train |
redisjs/jsr-store | lib/command/set.js | sinterstore | function sinterstore(destination /* key-1, key-N, req*/) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length - 1] === 'object'
? args[args.length - 1] : null;
var list = this.sinter.apply(this, args);
if(list.length) {
this.setKey(
destination, new Set(list), undefined, undef... | javascript | function sinterstore(destination /* key-1, key-N, req*/) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length - 1] === 'object'
? args[args.length - 1] : null;
var list = this.sinter.apply(this, args);
if(list.length) {
this.setKey(
destination, new Set(list), undefined, undef... | [
"function",
"sinterstore",
"(",
"destination",
"/* key-1, key-N, req*/",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
",",
"req",
"=",
"typeof",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
"===",
"'object'",... | Stores the members of the set resulting from the intersection
of all the given sets. | [
"Stores",
"the",
"members",
"of",
"the",
"set",
"resulting",
"from",
"the",
"intersection",
"of",
"all",
"the",
"given",
"sets",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/set.js#L180-L190 | train |
redisjs/jsr-store | lib/command/set.js | sdiff | function sdiff(key /* key-1, key-N, req*/) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length - 1] === 'object' ? args.pop() : null
, set = this.getKey(key, req)
, list
, src
, j
, i;
if(!set) return [];
list = set.data.slice(0);
for(j = 0;j < list.length;j++) {
... | javascript | function sdiff(key /* key-1, key-N, req*/) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length - 1] === 'object' ? args.pop() : null
, set = this.getKey(key, req)
, list
, src
, j
, i;
if(!set) return [];
list = set.data.slice(0);
for(j = 0;j < list.length;j++) {
... | [
"function",
"sdiff",
"(",
"key",
"/* key-1, key-N, req*/",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
",",
"req",
"=",
"typeof",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
"===",
"'object'",
"?",
"arg... | Returns the members of the set resulting from the difference
between the first set and successive sets. | [
"Returns",
"the",
"members",
"of",
"the",
"set",
"resulting",
"from",
"the",
"difference",
"between",
"the",
"first",
"set",
"and",
"successive",
"sets",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/set.js#L196-L222 | train |
redisjs/jsr-store | lib/command/set.js | sdiffstore | function sdiffstore(destination /* key-1, key-N, req*/) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length - 1] === 'object'
? args[args.length - 1] : null;
var list = this.sdiff.apply(this, args);
if(list.length) {
this.setKey(
destination, new Set(list), undefined, undefin... | javascript | function sdiffstore(destination /* key-1, key-N, req*/) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length - 1] === 'object'
? args[args.length - 1] : null;
var list = this.sdiff.apply(this, args);
if(list.length) {
this.setKey(
destination, new Set(list), undefined, undefin... | [
"function",
"sdiffstore",
"(",
"destination",
"/* key-1, key-N, req*/",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
",",
"req",
"=",
"typeof",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
"===",
"'object'",
... | Stores the members of the set resulting from the difference
between the first set and successive sets. | [
"Stores",
"the",
"members",
"of",
"the",
"set",
"resulting",
"from",
"the",
"difference",
"between",
"the",
"first",
"set",
"and",
"successive",
"sets",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/set.js#L228-L238 | train |
wunderbyte/grunt-spiritual-dox | tasks/spiritualdox.js | existence | function existence ( filepath ) {
var does = grunt.file.exists ( filepath );
if ( !does ) {
grunt.log.warn ( filepath + " not found." );
}
return does;
} | javascript | function existence ( filepath ) {
var does = grunt.file.exists ( filepath );
if ( !does ) {
grunt.log.warn ( filepath + " not found." );
}
return does;
} | [
"function",
"existence",
"(",
"filepath",
")",
"{",
"var",
"does",
"=",
"grunt",
".",
"file",
".",
"exists",
"(",
"filepath",
")",
";",
"if",
"(",
"!",
"does",
")",
"{",
"grunt",
".",
"log",
".",
"warn",
"(",
"filepath",
"+",
"\" not found.\"",
")",
... | Check file existence.
@param {String} filepath
@returns {boolean} | [
"Check",
"file",
"existence",
"."
] | 5afcfe31ddbf7d654166aa15b938553b61de5811 | https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/tasks/spiritualdox.js#L113-L119 | train |
0of/ver-iterator | lib/git.js | clone | function clone(url, dir) {
_child_process2['default'].execSync('git clone ' + url, { cwd: _path2['default'].resolve(dir) });
} | javascript | function clone(url, dir) {
_child_process2['default'].execSync('git clone ' + url, { cwd: _path2['default'].resolve(dir) });
} | [
"function",
"clone",
"(",
"url",
",",
"dir",
")",
"{",
"_child_process2",
"[",
"'default'",
"]",
".",
"execSync",
"(",
"'git clone '",
"+",
"url",
",",
"{",
"cwd",
":",
"_path2",
"[",
"'default'",
"]",
".",
"resolve",
"(",
"dir",
")",
"}",
")",
";",
... | git clone from specific URL
@param {String} [url] git repo URL
@param {String} [dir] the dir the repo cloned into
@public | [
"git",
"clone",
"from",
"specific",
"URL"
] | a51726c02dfd14488190860f4d90903574ed8e37 | https://github.com/0of/ver-iterator/blob/a51726c02dfd14488190860f4d90903574ed8e37/lib/git.js#L30-L32 | train |
0of/ver-iterator | lib/git.js | listTags | function listTags(localRepoDir) {
var stdout = _child_process2['default'].execSync('git tag -l', { cwd: _path2['default'].resolve(localRepoDir) });
return stdout.toString().match(/[^\r\n]+/g).filter(function (v) {
return v.length !== 0;
}).map(function (v) {
return v.trim();
});
} | javascript | function listTags(localRepoDir) {
var stdout = _child_process2['default'].execSync('git tag -l', { cwd: _path2['default'].resolve(localRepoDir) });
return stdout.toString().match(/[^\r\n]+/g).filter(function (v) {
return v.length !== 0;
}).map(function (v) {
return v.trim();
});
} | [
"function",
"listTags",
"(",
"localRepoDir",
")",
"{",
"var",
"stdout",
"=",
"_child_process2",
"[",
"'default'",
"]",
".",
"execSync",
"(",
"'git tag -l'",
",",
"{",
"cwd",
":",
"_path2",
"[",
"'default'",
"]",
".",
"resolve",
"(",
"localRepoDir",
")",
"}... | git list all the tags
@param {String} [localRepoDir] local repo dir
@public | [
"git",
"list",
"all",
"the",
"tags"
] | a51726c02dfd14488190860f4d90903574ed8e37 | https://github.com/0of/ver-iterator/blob/a51726c02dfd14488190860f4d90903574ed8e37/lib/git.js#L40-L47 | train |
NicolasBoyer/wapitis | index.js | buildIndexFile | function buildIndexFile(isProd) {
return new Promise((resolve) => {
files.readFile(path.resolve(__dirname, ".includes/index.html"), (err, html) => {
if (err) throw err;
html = html.replace("$appDesc$", wapitisConfig.appDesc);
html = html.replace("$themeColor$", wapitisConfig.themeColor);
html... | javascript | function buildIndexFile(isProd) {
return new Promise((resolve) => {
files.readFile(path.resolve(__dirname, ".includes/index.html"), (err, html) => {
if (err) throw err;
html = html.replace("$appDesc$", wapitisConfig.appDesc);
html = html.replace("$themeColor$", wapitisConfig.themeColor);
html... | [
"function",
"buildIndexFile",
"(",
"isProd",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
")",
"=>",
"{",
"files",
".",
"readFile",
"(",
"path",
".",
"resolve",
"(",
"__dirname",
",",
"\".includes/index.html\"",
")",
",",
"(",
"err",
",",
"... | Modify index file | [
"Modify",
"index",
"file"
] | e173c67f07b94f0c6b27b521f1113830a1f10302 | https://github.com/NicolasBoyer/wapitis/blob/e173c67f07b94f0c6b27b521f1113830a1f10302/index.js#L139-L154 | train |
andrewscwei/requiem | src/dom/getChildRegistry.js | getChildRegistry | function getChildRegistry(element, findClosest) {
assert((element === window) || (element instanceof Node) || !element, 'Invalid element specified');
assertType(findClosest, 'boolean', true, `The parameter 'findClosest', if specified, must be a boolean value`);
if (!element || element === document || element ===... | javascript | function getChildRegistry(element, findClosest) {
assert((element === window) || (element instanceof Node) || !element, 'Invalid element specified');
assertType(findClosest, 'boolean', true, `The parameter 'findClosest', if specified, must be a boolean value`);
if (!element || element === document || element ===... | [
"function",
"getChildRegistry",
"(",
"element",
",",
"findClosest",
")",
"{",
"assert",
"(",
"(",
"element",
"===",
"window",
")",
"||",
"(",
"element",
"instanceof",
"Node",
")",
"||",
"!",
"element",
",",
"'Invalid element specified'",
")",
";",
"assertType"... | Gets the global child registry.
@param {Node} [element] - Target element.
@param {Node} [findClosest] - Specifies whether to keep seeking for a child
registry upwards in the DOM tree if the
target element doesn't have one.
@return {Object} The child registry.
@alias module:requiem~dom.getChildRegistry | [
"Gets",
"the",
"global",
"child",
"registry",
"."
] | c4182bfffc9841c6de5718f689ad3c2060511777 | https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/dom/getChildRegistry.js#L20-L40 | train |
lang-js/translate | index.js | translate | function translate(cldr, locale, opts) {
if (typeof cldr === 'string') return augment(interpolate(cldr, opts));
opts = opts || {};
var pluralize = lookup(locale, cldr._format || opts.pluralFormat, plural);
if (Array.isArray(cldr)) cldr = convertArray(cldr, pluralize, opts);
validate(cldr, pluralize);
va... | javascript | function translate(cldr, locale, opts) {
if (typeof cldr === 'string') return augment(interpolate(cldr, opts));
opts = opts || {};
var pluralize = lookup(locale, cldr._format || opts.pluralFormat, plural);
if (Array.isArray(cldr)) cldr = convertArray(cldr, pluralize, opts);
validate(cldr, pluralize);
va... | [
"function",
"translate",
"(",
"cldr",
",",
"locale",
",",
"opts",
")",
"{",
"if",
"(",
"typeof",
"cldr",
"===",
"'string'",
")",
"return",
"augment",
"(",
"interpolate",
"(",
"cldr",
",",
"opts",
")",
")",
";",
"opts",
"=",
"opts",
"||",
"{",
"}",
... | Compile a translation function
@param {String|Array|Object} cldr
@param {String} locale
@param {Object?} opts
@return {Function} | [
"Compile",
"a",
"translation",
"function"
] | 5787347d4b08089ddfcf73349dbbd0bfa47cd1fa | https://github.com/lang-js/translate/blob/5787347d4b08089ddfcf73349dbbd0bfa47cd1fa/index.js#L37-L75 | train |
lang-js/translate | index.js | validate | function validate(cldr, pluralize) {
pluralize.formats.forEach(function(key) {
if (!cldr[key]) throw new Error('translation object missing required key "' + key + '"');
});
} | javascript | function validate(cldr, pluralize) {
pluralize.formats.forEach(function(key) {
if (!cldr[key]) throw new Error('translation object missing required key "' + key + '"');
});
} | [
"function",
"validate",
"(",
"cldr",
",",
"pluralize",
")",
"{",
"pluralize",
".",
"formats",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"if",
"(",
"!",
"cldr",
"[",
"key",
"]",
")",
"throw",
"new",
"Error",
"(",
"'translation object missing ... | Validate a cldr against a pluralize function
@param {Object} cldr
@param {Function} pluralize | [
"Validate",
"a",
"cldr",
"against",
"a",
"pluralize",
"function"
] | 5787347d4b08089ddfcf73349dbbd0bfa47cd1fa | https://github.com/lang-js/translate/blob/5787347d4b08089ddfcf73349dbbd0bfa47cd1fa/index.js#L84-L88 | train |
lang-js/translate | index.js | toFunctions | function toFunctions(cldr, pluralize, opts, paramsObj) {
return Object.keys(cldr).reduce(function(acc, key) {
if (key.indexOf('_') === 0) return acc;
var value = cldr[key];
if (typeof value !== 'string') return acc;
var t = acc[key] = interpolate(value, opts);
merge(paramsObj, t.params);
retur... | javascript | function toFunctions(cldr, pluralize, opts, paramsObj) {
return Object.keys(cldr).reduce(function(acc, key) {
if (key.indexOf('_') === 0) return acc;
var value = cldr[key];
if (typeof value !== 'string') return acc;
var t = acc[key] = interpolate(value, opts);
merge(paramsObj, t.params);
retur... | [
"function",
"toFunctions",
"(",
"cldr",
",",
"pluralize",
",",
"opts",
",",
"paramsObj",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"cldr",
")",
".",
"reduce",
"(",
"function",
"(",
"acc",
",",
"key",
")",
"{",
"if",
"(",
"key",
".",
"indexOf",
... | Convert a cldr object to an object of functions
@param {Object} cldr
@param {Function} pluralize
@param {Object} opts
@param {Object} paramsObj
@return {Object} | [
"Convert",
"a",
"cldr",
"object",
"to",
"an",
"object",
"of",
"functions"
] | 5787347d4b08089ddfcf73349dbbd0bfa47cd1fa | https://github.com/lang-js/translate/blob/5787347d4b08089ddfcf73349dbbd0bfa47cd1fa/index.js#L100-L109 | train |
lang-js/translate | index.js | discoverKey | function discoverKey(arr, discoverableKeys, defaultKey) {
if (arr.length === 0) return defaultKey;
if (arr.length === 1) return arr[0];
for (var i = 0; i < arr.length; i++) {
if (discoverableKeys[arr[i]]) return arr[i];
}
return defaultKey;
} | javascript | function discoverKey(arr, discoverableKeys, defaultKey) {
if (arr.length === 0) return defaultKey;
if (arr.length === 1) return arr[0];
for (var i = 0; i < arr.length; i++) {
if (discoverableKeys[arr[i]]) return arr[i];
}
return defaultKey;
} | [
"function",
"discoverKey",
"(",
"arr",
",",
"discoverableKeys",
",",
"defaultKey",
")",
"{",
"if",
"(",
"arr",
".",
"length",
"===",
"0",
")",
"return",
"defaultKey",
";",
"if",
"(",
"arr",
".",
"length",
"===",
"1",
")",
"return",
"arr",
"[",
"0",
"... | Auto-discover the plural key
@param {Array} keys
@param {Object} discoverableKeys
@param {String} defaultKey
@return {String} | [
"Auto",
"-",
"discover",
"the",
"plural",
"key"
] | 5787347d4b08089ddfcf73349dbbd0bfa47cd1fa | https://github.com/lang-js/translate/blob/5787347d4b08089ddfcf73349dbbd0bfa47cd1fa/index.js#L120-L127 | train |
lang-js/translate | index.js | augment | function augment(fn, keys) {
keys = keys || fn.params || [];
if (!Array.isArray(keys)) keys = Object.keys(keys);
fn.params = keys;
return fn;
} | javascript | function augment(fn, keys) {
keys = keys || fn.params || [];
if (!Array.isArray(keys)) keys = Object.keys(keys);
fn.params = keys;
return fn;
} | [
"function",
"augment",
"(",
"fn",
",",
"keys",
")",
"{",
"keys",
"=",
"keys",
"||",
"fn",
".",
"params",
"||",
"[",
"]",
";",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"keys",
")",
")",
"keys",
"=",
"Object",
".",
"keys",
"(",
"keys",
")",
... | Augment translate functions with params reduce functions
@param {Function} fn
@param {Array} keys
@return {Function} | [
"Augment",
"translate",
"functions",
"with",
"params",
"reduce",
"functions"
] | 5787347d4b08089ddfcf73349dbbd0bfa47cd1fa | https://github.com/lang-js/translate/blob/5787347d4b08089ddfcf73349dbbd0bfa47cd1fa/index.js#L137-L142 | train |
lang-js/translate | index.js | lookup | function lookup(locale, format, obj) {
if (!locale) throw new Error('missing required "locale" parameter');
locale = locale.toLowerCase().replace('-', '_');
format = format || 'cardinal';
var p = obj[format];
if (!p) throw new Error('unsupported format "' + format + '"');
var fn = p[locale] || p[locale.spli... | javascript | function lookup(locale, format, obj) {
if (!locale) throw new Error('missing required "locale" parameter');
locale = locale.toLowerCase().replace('-', '_');
format = format || 'cardinal';
var p = obj[format];
if (!p) throw new Error('unsupported format "' + format + '"');
var fn = p[locale] || p[locale.spli... | [
"function",
"lookup",
"(",
"locale",
",",
"format",
",",
"obj",
")",
"{",
"if",
"(",
"!",
"locale",
")",
"throw",
"new",
"Error",
"(",
"'missing required \"locale\" parameter'",
")",
";",
"locale",
"=",
"locale",
".",
"toLowerCase",
"(",
")",
".",
"replace... | Lookup the plural function given a locale
@param {String} locale
@param {String} format
@return {Function} | [
"Lookup",
"the",
"plural",
"function",
"given",
"a",
"locale"
] | 5787347d4b08089ddfcf73349dbbd0bfa47cd1fa | https://github.com/lang-js/translate/blob/5787347d4b08089ddfcf73349dbbd0bfa47cd1fa/index.js#L152-L162 | train |
lang-js/translate | index.js | convertArray | function convertArray(arr, pluralize, opts) {
if (arr.length !== pluralize.count) throw new Error('missing required length of plural formats: expected ' + pluralize.count + '; got ' + arr.length);
return pluralize.formats.reduce(function(acc, key, i) {
acc[key] = arr[i];
return acc;
}, {});
} | javascript | function convertArray(arr, pluralize, opts) {
if (arr.length !== pluralize.count) throw new Error('missing required length of plural formats: expected ' + pluralize.count + '; got ' + arr.length);
return pluralize.formats.reduce(function(acc, key, i) {
acc[key] = arr[i];
return acc;
}, {});
} | [
"function",
"convertArray",
"(",
"arr",
",",
"pluralize",
",",
"opts",
")",
"{",
"if",
"(",
"arr",
".",
"length",
"!==",
"pluralize",
".",
"count",
")",
"throw",
"new",
"Error",
"(",
"'missing required length of plural formats: expected '",
"+",
"pluralize",
"."... | Convert an array input to a CLDR object
@param {Array} arr
@param {Function} pluralize
@param {Object} opts
@return {Object} | [
"Convert",
"an",
"array",
"input",
"to",
"a",
"CLDR",
"object"
] | 5787347d4b08089ddfcf73349dbbd0bfa47cd1fa | https://github.com/lang-js/translate/blob/5787347d4b08089ddfcf73349dbbd0bfa47cd1fa/index.js#L173-L180 | train |
lang-js/translate | index.js | formatNumbers | function formatNumbers(prevParams, decimal) {
var params = {}, value;
for (var k in prevParams) {
value = prevParams[k];
params[k] = typeof value === 'number' ? decimal(value) : value;
}
return params;
} | javascript | function formatNumbers(prevParams, decimal) {
var params = {}, value;
for (var k in prevParams) {
value = prevParams[k];
params[k] = typeof value === 'number' ? decimal(value) : value;
}
return params;
} | [
"function",
"formatNumbers",
"(",
"prevParams",
",",
"decimal",
")",
"{",
"var",
"params",
"=",
"{",
"}",
",",
"value",
";",
"for",
"(",
"var",
"k",
"in",
"prevParams",
")",
"{",
"value",
"=",
"prevParams",
"[",
"k",
"]",
";",
"params",
"[",
"k",
"... | Format numbers with lang-js-number | [
"Format",
"numbers",
"with",
"lang",
"-",
"js",
"-",
"number"
] | 5787347d4b08089ddfcf73349dbbd0bfa47cd1fa | https://github.com/lang-js/translate/blob/5787347d4b08089ddfcf73349dbbd0bfa47cd1fa/index.js#L200-L207 | train |
fullstackers/bus.io-common | lib/controller.js | Controller | function Controller (message) {
if (!(message instanceof Message)) throw new Error('message must be an instanceof Message');
if (!(this instanceof Controller)) return new Controller(message);
debug('new controller');
events.EventEmitter.call(this);
this.message = message;
this.data = this.message.data... | javascript | function Controller (message) {
if (!(message instanceof Message)) throw new Error('message must be an instanceof Message');
if (!(this instanceof Controller)) return new Controller(message);
debug('new controller');
events.EventEmitter.call(this);
this.message = message;
this.data = this.message.data... | [
"function",
"Controller",
"(",
"message",
")",
"{",
"if",
"(",
"!",
"(",
"message",
"instanceof",
"Message",
")",
")",
"throw",
"new",
"Error",
"(",
"'message must be an instanceof Message'",
")",
";",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Controller",
... | When handling a message we use a controller
@param {Message} message
@throws Error | [
"When",
"handling",
"a",
"message",
"we",
"use",
"a",
"controller"
] | 9e081a15ba40c4233a936d4105465277da8578fd | https://github.com/fullstackers/bus.io-common/blob/9e081a15ba40c4233a936d4105465277da8578fd/lib/controller.js#L17-L31 | train |
nathanhood/postcss-js-mixins | lib/helpers.js | toRgba | function toRgba(color, opacity = false) {
color = tinycolor(color);
if (opacity) {
color.setAlpha(calcOpacity(opacity));
}
return color.toRgbString();
} | javascript | function toRgba(color, opacity = false) {
color = tinycolor(color);
if (opacity) {
color.setAlpha(calcOpacity(opacity));
}
return color.toRgbString();
} | [
"function",
"toRgba",
"(",
"color",
",",
"opacity",
"=",
"false",
")",
"{",
"color",
"=",
"tinycolor",
"(",
"color",
")",
";",
"if",
"(",
"opacity",
")",
"{",
"color",
".",
"setAlpha",
"(",
"calcOpacity",
"(",
"opacity",
")",
")",
";",
"}",
"return",... | Convert color values to RGBa
@param {string} color
@param {string|boolean} opacity
@return {string} | [
"Convert",
"color",
"values",
"to",
"RGBa"
] | b43e94b5eaa4b1f169d34ee98c65b8c94bee30b5 | https://github.com/nathanhood/postcss-js-mixins/blob/b43e94b5eaa4b1f169d34ee98c65b8c94bee30b5/lib/helpers.js#L35-L43 | train |
nathanhood/postcss-js-mixins | lib/helpers.js | isEmpty | function isEmpty(value) {
if (Array.isArray(value)) {
// If first item in array is undefined, we assume there are no parameters
// This happens as a result of using the rest operator in a mixin
return value.length === 0 || value[0] === undefined;
}
return value === undefined;
} | javascript | function isEmpty(value) {
if (Array.isArray(value)) {
// If first item in array is undefined, we assume there are no parameters
// This happens as a result of using the rest operator in a mixin
return value.length === 0 || value[0] === undefined;
}
return value === undefined;
} | [
"function",
"isEmpty",
"(",
"value",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"value",
")",
")",
"{",
"// If first item in array is undefined, we assume there are no parameters",
"// This happens as a result of using the rest operator in a mixin",
"return",
"value",
... | Determine if value is empty
@param {*} value
@return {boolean} | [
"Determine",
"if",
"value",
"is",
"empty"
] | b43e94b5eaa4b1f169d34ee98c65b8c94bee30b5 | https://github.com/nathanhood/postcss-js-mixins/blob/b43e94b5eaa4b1f169d34ee98c65b8c94bee30b5/lib/helpers.js#L61-L69 | train |
nathanhood/postcss-js-mixins | lib/helpers.js | isFraction | function isFraction(value) {
if (typeof value !== 'string') {
return false;
}
value = value.split('/');
return value.length === 2 && value[0] % 1 === 0 && value[1] % 1 === 0;
} | javascript | function isFraction(value) {
if (typeof value !== 'string') {
return false;
}
value = value.split('/');
return value.length === 2 && value[0] % 1 === 0 && value[1] % 1 === 0;
} | [
"function",
"isFraction",
"(",
"value",
")",
"{",
"if",
"(",
"typeof",
"value",
"!==",
"'string'",
")",
"{",
"return",
"false",
";",
"}",
"value",
"=",
"value",
".",
"split",
"(",
"'/'",
")",
";",
"return",
"value",
".",
"length",
"===",
"2",
"&&",
... | Determine if supplied argument is a fraction
@param {*} value
@returns {boolean} | [
"Determine",
"if",
"supplied",
"argument",
"is",
"a",
"fraction"
] | b43e94b5eaa4b1f169d34ee98c65b8c94bee30b5 | https://github.com/nathanhood/postcss-js-mixins/blob/b43e94b5eaa4b1f169d34ee98c65b8c94bee30b5/lib/helpers.js#L77-L85 | train |
nathanhood/postcss-js-mixins | lib/helpers.js | prefix | function prefix(value, prefix, ignored = []) {
if (prefix === false) {
return value;
}
if (ignored.includes(prefix)) {
return toDashCase(value);
}
return prefix + '-' + toDashCase(value);
} | javascript | function prefix(value, prefix, ignored = []) {
if (prefix === false) {
return value;
}
if (ignored.includes(prefix)) {
return toDashCase(value);
}
return prefix + '-' + toDashCase(value);
} | [
"function",
"prefix",
"(",
"value",
",",
"prefix",
",",
"ignored",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"prefix",
"===",
"false",
")",
"{",
"return",
"value",
";",
"}",
"if",
"(",
"ignored",
".",
"includes",
"(",
"prefix",
")",
")",
"{",
"return",
... | Prefixes properties with supplied prefix
@param {string} value un-prefixed string
@param {string} prefix prefix
@param {Array} ignored
@return {[string]} | [
"Prefixes",
"properties",
"with",
"supplied",
"prefix"
] | b43e94b5eaa4b1f169d34ee98c65b8c94bee30b5 | https://github.com/nathanhood/postcss-js-mixins/blob/b43e94b5eaa4b1f169d34ee98c65b8c94bee30b5/lib/helpers.js#L157-L167 | train |
nathanhood/postcss-js-mixins | lib/helpers.js | unit | function unit(value, property) {
let ignored = ['font-weight', 'opacity', 'content', 'columns', 'column-count'];
if (ignored.includes(property) || property === false || value === 0 || /\s/.test(value)) {
return value.toString();
}
if (! isUnit(value) && isNumber(value)) {
if (property === 'line-height') {
... | javascript | function unit(value, property) {
let ignored = ['font-weight', 'opacity', 'content', 'columns', 'column-count'];
if (ignored.includes(property) || property === false || value === 0 || /\s/.test(value)) {
return value.toString();
}
if (! isUnit(value) && isNumber(value)) {
if (property === 'line-height') {
... | [
"function",
"unit",
"(",
"value",
",",
"property",
")",
"{",
"let",
"ignored",
"=",
"[",
"'font-weight'",
",",
"'opacity'",
",",
"'content'",
",",
"'columns'",
",",
"'column-count'",
"]",
";",
"if",
"(",
"ignored",
".",
"includes",
"(",
"property",
")",
... | Append default unit to value if value is a unit
@param {string|number} value
@param {string|number} property
@return {string} | [
"Append",
"default",
"unit",
"to",
"value",
"if",
"value",
"is",
"a",
"unit"
] | b43e94b5eaa4b1f169d34ee98c65b8c94bee30b5 | https://github.com/nathanhood/postcss-js-mixins/blob/b43e94b5eaa4b1f169d34ee98c65b8c94bee30b5/lib/helpers.js#L225-L241 | 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.