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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
goliney/coderoom | lib/utils.js | readTemplate | function readTemplate() {
return fs.readFileSync(path.resolve.apply(null, [__dirname, settings.paths.templates, ...arguments]), 'utf8');
} | javascript | function readTemplate() {
return fs.readFileSync(path.resolve.apply(null, [__dirname, settings.paths.templates, ...arguments]), 'utf8');
} | [
"function",
"readTemplate",
"(",
")",
"{",
"return",
"fs",
".",
"readFileSync",
"(",
"path",
".",
"resolve",
".",
"apply",
"(",
"null",
",",
"[",
"__dirname",
",",
"settings",
".",
"paths",
".",
"templates",
",",
"...",
"arguments",
"]",
")",
",",
"'ut... | Synchronously read file from templates folder.
@param {...string} variative number of paths that form relative path to template
@returns {string} | [
"Synchronously",
"read",
"file",
"from",
"templates",
"folder",
"."
] | a8c30d45ae724dfc87348ffba5474cf62c10911c | https://github.com/goliney/coderoom/blob/a8c30d45ae724dfc87348ffba5474cf62c10911c/lib/utils.js#L27-L29 | train |
YR/component | src/index.js | shouldBeStateless | function shouldBeStateless(definition, preferStateless) {
if (!preferStateless) {
return false;
}
if (runtime.isServer && (definition.getChildContext === undefined && definition.init === undefined)) {
return true;
}
// Not stateless if contains anything more than render and static properties
for (... | javascript | function shouldBeStateless(definition, preferStateless) {
if (!preferStateless) {
return false;
}
if (runtime.isServer && (definition.getChildContext === undefined && definition.init === undefined)) {
return true;
}
// Not stateless if contains anything more than render and static properties
for (... | [
"function",
"shouldBeStateless",
"(",
"definition",
",",
"preferStateless",
")",
"{",
"if",
"(",
"!",
"preferStateless",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"runtime",
".",
"isServer",
"&&",
"(",
"definition",
".",
"getChildContext",
"===",
"un... | Determine if 'definition' is stateless
@param {Object} definition
@param {Boolean} preferStateless
@returns {Boolean} | [
"Determine",
"if",
"definition",
"is",
"stateless"
] | 688a381f9478f75aed00032cae78df3f20d3a6dd | https://github.com/YR/component/blob/688a381f9478f75aed00032cae78df3f20d3a6dd/src/index.js#L98-L115 | train |
freshout-dev/thulium | etc/EJS/ejs_fulljslint.js | quit | function quit(m, l, ch) {
throw {
name: 'JSLintError',
line: l,
character: ch,
message: m + " (" + Math.floor((l / lines.length) * 100) +
"% scanned)."
};
} | javascript | function quit(m, l, ch) {
throw {
name: 'JSLintError',
line: l,
character: ch,
message: m + " (" + Math.floor((l / lines.length) * 100) +
"% scanned)."
};
} | [
"function",
"quit",
"(",
"m",
",",
"l",
",",
"ch",
")",
"{",
"throw",
"{",
"name",
":",
"'JSLintError'",
",",
"line",
":",
"l",
",",
"character",
":",
"ch",
",",
"message",
":",
"m",
"+",
"\" (\"",
"+",
"Math",
".",
"floor",
"(",
"(",
"l",
"/",... | Produce an error warning. | [
"Produce",
"an",
"error",
"warning",
"."
] | ba3173e700fbe810ce13063e7ad46e9b05bb49e7 | https://github.com/freshout-dev/thulium/blob/ba3173e700fbe810ce13063e7ad46e9b05bb49e7/etc/EJS/ejs_fulljslint.js#L560-L568 | train |
freshout-dev/thulium | etc/EJS/ejs_fulljslint.js | parse | function parse(rbp, initial) {
var left;
var o;
if (nexttoken.id === '(end)') {
error("Unexpected early end of program.", token);
}
advance();
if (option.adsafe && token.value === 'ADSAFE') {
if (nexttoken.id !== '.' || !(peek(0).identifier) ||
... | javascript | function parse(rbp, initial) {
var left;
var o;
if (nexttoken.id === '(end)') {
error("Unexpected early end of program.", token);
}
advance();
if (option.adsafe && token.value === 'ADSAFE') {
if (nexttoken.id !== '.' || !(peek(0).identifier) ||
... | [
"function",
"parse",
"(",
"rbp",
",",
"initial",
")",
"{",
"var",
"left",
";",
"var",
"o",
";",
"if",
"(",
"nexttoken",
".",
"id",
"===",
"'(end)'",
")",
"{",
"error",
"(",
"\"Unexpected early end of program.\"",
",",
"token",
")",
";",
"}",
"advance",
... | .nud Null denotation .fud First null denotation .led Left denotation lbp Left binding power rbp Right binding power They are key to the parsing method called Top Down Operator Precedence. | [
".",
"nud",
"Null",
"denotation",
".",
"fud",
"First",
"null",
"denotation",
".",
"led",
"Left",
"denotation",
"lbp",
"Left",
"binding",
"power",
"rbp",
"Right",
"binding",
"power",
"They",
"are",
"key",
"to",
"the",
"parsing",
"method",
"called",
"Top",
"... | ba3173e700fbe810ce13063e7ad46e9b05bb49e7 | https://github.com/freshout-dev/thulium/blob/ba3173e700fbe810ce13063e7ad46e9b05bb49e7/etc/EJS/ejs_fulljslint.js#L1428-L1483 | train |
freshout-dev/thulium | etc/EJS/ejs_fulljslint.js | symbol | function symbol(s, p) {
var x = syntax[s];
if (!x || typeof x !== 'object') {
syntax[s] = x = {
id: s,
lbp: p,
value: s
};
}
return x;
} | javascript | function symbol(s, p) {
var x = syntax[s];
if (!x || typeof x !== 'object') {
syntax[s] = x = {
id: s,
lbp: p,
value: s
};
}
return x;
} | [
"function",
"symbol",
"(",
"s",
",",
"p",
")",
"{",
"var",
"x",
"=",
"syntax",
"[",
"s",
"]",
";",
"if",
"(",
"!",
"x",
"||",
"typeof",
"x",
"!==",
"'object'",
")",
"{",
"syntax",
"[",
"s",
"]",
"=",
"x",
"=",
"{",
"id",
":",
"s",
",",
"l... | Parasitic constructors for making the symbols that will be inherited by tokens. | [
"Parasitic",
"constructors",
"for",
"making",
"the",
"symbols",
"that",
"will",
"be",
"inherited",
"by",
"tokens",
"."
] | ba3173e700fbe810ce13063e7ad46e9b05bb49e7 | https://github.com/freshout-dev/thulium/blob/ba3173e700fbe810ce13063e7ad46e9b05bb49e7/etc/EJS/ejs_fulljslint.js#L1543-L1553 | train |
freshout-dev/thulium | etc/EJS/ejs_fulljslint.js | function (s, o) {
if (o) {
if (o.adsafe) {
o.browser = false;
o.debug = false;
o.eqeqeq = true;
o.evil = false;
o.forin = false;
o.on = false;
o.rhino = false;
... | javascript | function (s, o) {
if (o) {
if (o.adsafe) {
o.browser = false;
o.debug = false;
o.eqeqeq = true;
o.evil = false;
o.forin = false;
o.on = false;
o.rhino = false;
... | [
"function",
"(",
"s",
",",
"o",
")",
"{",
"if",
"(",
"o",
")",
"{",
"if",
"(",
"o",
".",
"adsafe",
")",
"{",
"o",
".",
"browser",
"=",
"false",
";",
"o",
".",
"debug",
"=",
"false",
";",
"o",
".",
"eqeqeq",
"=",
"true",
";",
"o",
".",
"ev... | The actual JSLINT function itself. | [
"The",
"actual",
"JSLINT",
"function",
"itself",
"."
] | ba3173e700fbe810ce13063e7ad46e9b05bb49e7 | https://github.com/freshout-dev/thulium/blob/ba3173e700fbe810ce13063e7ad46e9b05bb49e7/etc/EJS/ejs_fulljslint.js#L3584-L3647 | train | |
angular-translate/angular-translate-extractor | index.js | function (objSrc, objDest) {
if (_.isObject(objDest)) {
Object.getOwnPropertyNames(objDest).forEach(function (index) {
if (_.isObject(objDest[index])) {
objDest[index] = _recurseExtend(objSrc[index], objDest[index]);
}
else {
... | javascript | function (objSrc, objDest) {
if (_.isObject(objDest)) {
Object.getOwnPropertyNames(objDest).forEach(function (index) {
if (_.isObject(objDest[index])) {
objDest[index] = _recurseExtend(objSrc[index], objDest[index]);
}
else {
... | [
"function",
"(",
"objSrc",
",",
"objDest",
")",
"{",
"if",
"(",
"_",
".",
"isObject",
"(",
"objDest",
")",
")",
"{",
"Object",
".",
"getOwnPropertyNames",
"(",
"objDest",
")",
".",
"forEach",
"(",
"function",
"(",
"index",
")",
"{",
"if",
"(",
"_",
... | Merge recursively objDest into objSrc | [
"Merge",
"recursively",
"objDest",
"into",
"objSrc"
] | e635405c8061df6594660fcb8c7f83927687c99e | https://github.com/angular-translate/angular-translate-extractor/blob/e635405c8061df6594660fcb8c7f83927687c99e/index.js#L299-L311 | train | |
teux/webpack-koa-middleware | index.js | sendStats | function sendStats(socket, stats, force) {
if (!socket || !stats) return;
if (!force && stats && stats.assets && stats.assets.every(function (asset) {
return !asset.emitted;
})) return;
socket.emit("hash", stats.hash);
if (stats.errors.length > 0)
socket.emit("errors", stats.errors);... | javascript | function sendStats(socket, stats, force) {
if (!socket || !stats) return;
if (!force && stats && stats.assets && stats.assets.every(function (asset) {
return !asset.emitted;
})) return;
socket.emit("hash", stats.hash);
if (stats.errors.length > 0)
socket.emit("errors", stats.errors);... | [
"function",
"sendStats",
"(",
"socket",
",",
"stats",
",",
"force",
")",
"{",
"if",
"(",
"!",
"socket",
"||",
"!",
"stats",
")",
"return",
";",
"if",
"(",
"!",
"force",
"&&",
"stats",
"&&",
"stats",
".",
"assets",
"&&",
"stats",
".",
"assets",
".",... | Sends signals and stats in socket
@param {WebSocket} socket
@param {Object} stats Webpack generated stats
@param {Boolean} force | [
"Sends",
"signals",
"and",
"stats",
"in",
"socket"
] | 557a979eb7b6dd0da40dadc465bc45024aadc20b | https://github.com/teux/webpack-koa-middleware/blob/557a979eb7b6dd0da40dadc465bc45024aadc20b/index.js#L42-L54 | train |
teux/webpack-koa-middleware | index.js | function (url) {
return new Promise(function (resolve, reject) {
middleware(new MockReq(url), new MockRes(url, resolve), reject);
});
} | javascript | function (url) {
return new Promise(function (resolve, reject) {
middleware(new MockReq(url), new MockRes(url, resolve), reject);
});
} | [
"function",
"(",
"url",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"middleware",
"(",
"new",
"MockReq",
"(",
"url",
")",
",",
"new",
"MockRes",
"(",
"url",
",",
"resolve",
")",
",",
"reject",
")",
... | Calls webpack middleware in express manner.
@param {String} url
@returns {Promise} | [
"Calls",
"webpack",
"middleware",
"in",
"express",
"manner",
"."
] | 557a979eb7b6dd0da40dadc465bc45024aadc20b | https://github.com/teux/webpack-koa-middleware/blob/557a979eb7b6dd0da40dadc465bc45024aadc20b/index.js#L99-L103 | train | |
alexyoung/pop | lib/site_builder.js | SiteBuilder | function SiteBuilder(config, fileMap) {
this.config = config;
this.root = config.root;
var helperFile = path.join(this.root, '_lib', 'helpers.js');
if (existsSync(helperFile)) {
userHelpers = require(helperFile);
}
var filterFile = path.join(this.root, '_lib', 'filters.js');
if (existsSync(filterFil... | javascript | function SiteBuilder(config, fileMap) {
this.config = config;
this.root = config.root;
var helperFile = path.join(this.root, '_lib', 'helpers.js');
if (existsSync(helperFile)) {
userHelpers = require(helperFile);
}
var filterFile = path.join(this.root, '_lib', 'filters.js');
if (existsSync(filterFil... | [
"function",
"SiteBuilder",
"(",
"config",
",",
"fileMap",
")",
"{",
"this",
".",
"config",
"=",
"config",
";",
"this",
".",
"root",
"=",
"config",
".",
"root",
";",
"var",
"helperFile",
"=",
"path",
".",
"join",
"(",
"this",
".",
"root",
",",
"'_lib'... | Initialize `SiteBuilder` with a config object and `FileMap`.
@param {Object} Config options
@param {FileMap} A `FileMap` object
@api public | [
"Initialize",
"SiteBuilder",
"with",
"a",
"config",
"object",
"and",
"FileMap",
"."
] | 8a0b3f2605cb58e8ae6b34f1373dde00610e9858 | https://github.com/alexyoung/pop/blob/8a0b3f2605cb58e8ae6b34f1373dde00610e9858/lib/site_builder.js#L35-L62 | train |
JanitorTechnology/selfapi | selfapi.js | API | function API (parameters) {
// Own API resource prefix (e.g. '/resource').
this.path = parameters.path || null;
// Own documentation.
this.title = parameters.title || null;
this.description = parameters.description || null;
// Own test setup functions.
this.beforeEachTest = parameters.beforeEachTest || ... | javascript | function API (parameters) {
// Own API resource prefix (e.g. '/resource').
this.path = parameters.path || null;
// Own documentation.
this.title = parameters.title || null;
this.description = parameters.description || null;
// Own test setup functions.
this.beforeEachTest = parameters.beforeEachTest || ... | [
"function",
"API",
"(",
"parameters",
")",
"{",
"// Own API resource prefix (e.g. '/resource').",
"this",
".",
"path",
"=",
"parameters",
".",
"path",
"||",
"null",
";",
"// Own documentation.",
"this",
".",
"title",
"=",
"parameters",
".",
"title",
"||",
"null",
... | Simple, self-documenting and self-testing API system. | [
"Simple",
"self",
"-",
"documenting",
"and",
"self",
"-",
"testing",
"API",
"system",
"."
] | 8d6bbea299c9a8acef92a9c476b941660d0ef982 | https://github.com/JanitorTechnology/selfapi/blob/8d6bbea299c9a8acef92a9c476b941660d0ef982/selfapi.js#L15-L35 | train |
JanitorTechnology/selfapi | selfapi.js | function (method, path, parameters) {
if (!this.parent) {
return;
}
var fullPath = normalizePath(path, this.path);
this.parent.exportHandler(method, fullPath, parameters);
} | javascript | function (method, path, parameters) {
if (!this.parent) {
return;
}
var fullPath = normalizePath(path, this.path);
this.parent.exportHandler(method, fullPath, parameters);
} | [
"function",
"(",
"method",
",",
"path",
",",
"parameters",
")",
"{",
"if",
"(",
"!",
"this",
".",
"parent",
")",
"{",
"return",
";",
"}",
"var",
"fullPath",
"=",
"normalizePath",
"(",
"path",
",",
"this",
".",
"path",
")",
";",
"this",
".",
"parent... | Backpropagate a new request handler up the API resource tree in order to register it at the root. | [
"Backpropagate",
"a",
"new",
"request",
"handler",
"up",
"the",
"API",
"resource",
"tree",
"in",
"order",
"to",
"register",
"it",
"at",
"the",
"root",
"."
] | 8d6bbea299c9a8acef92a9c476b941660d0ef982 | https://github.com/JanitorTechnology/selfapi/blob/8d6bbea299c9a8acef92a9c476b941660d0ef982/selfapi.js#L106-L112 | train | |
JanitorTechnology/selfapi | selfapi.js | function (baseUrl, callback) {
var self = this;
var tests = [];
// Export own request handler examples as test functions.
for (var method in self.handlers) {
var handler = self.handlers[method];
if (!handler.examples) {
throw (
'Handler ' + method.toUpperCase() + ' ' + thi... | javascript | function (baseUrl, callback) {
var self = this;
var tests = [];
// Export own request handler examples as test functions.
for (var method in self.handlers) {
var handler = self.handlers[method];
if (!handler.examples) {
throw (
'Handler ' + method.toUpperCase() + ' ' + thi... | [
"function",
"(",
"baseUrl",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"tests",
"=",
"[",
"]",
";",
"// Export own request handler examples as test functions.",
"for",
"(",
"var",
"method",
"in",
"self",
".",
"handlers",
")",
"{",
"va... | Export all request handler examples as self-test functions. | [
"Export",
"all",
"request",
"handler",
"examples",
"as",
"self",
"-",
"test",
"functions",
"."
] | 8d6bbea299c9a8acef92a9c476b941660d0ef982 | https://github.com/JanitorTechnology/selfapi/blob/8d6bbea299c9a8acef92a9c476b941660d0ef982/selfapi.js#L129-L169 | train | |
JanitorTechnology/selfapi | selfapi.js | function (baseUrl) {
var fullUrl = url.parse(String(baseUrl || '/'));
fullUrl.pathname = normalizePath(this.path, fullUrl.pathname);
fullUrl = url.format(fullUrl);
var routes = {};
Object.keys(this.children).forEach(function (child) {
routes[child.replace(/^\//, '')] = nodepath.join(fullUrl, ... | javascript | function (baseUrl) {
var fullUrl = url.parse(String(baseUrl || '/'));
fullUrl.pathname = normalizePath(this.path, fullUrl.pathname);
fullUrl = url.format(fullUrl);
var routes = {};
Object.keys(this.children).forEach(function (child) {
routes[child.replace(/^\//, '')] = nodepath.join(fullUrl, ... | [
"function",
"(",
"baseUrl",
")",
"{",
"var",
"fullUrl",
"=",
"url",
".",
"parse",
"(",
"String",
"(",
"baseUrl",
"||",
"'/'",
")",
")",
";",
"fullUrl",
".",
"pathname",
"=",
"normalizePath",
"(",
"this",
".",
"path",
",",
"fullUrl",
".",
"pathname",
... | Build index routes. | [
"Build",
"index",
"routes",
"."
] | 8d6bbea299c9a8acef92a9c476b941660d0ef982 | https://github.com/JanitorTechnology/selfapi/blob/8d6bbea299c9a8acef92a9c476b941660d0ef982/selfapi.js#L394-L404 | train | |
JanitorTechnology/selfapi | selfapi.js | function (basePath, anchors) {
var fullPath = normalizePath(this.path, basePath) || '/';
anchors = anchors || [];
function getAnchor (title) {
var anchor = String(title).toLowerCase()
.replace(/[\s\-]+/g, ' ')
.replace(/[^a-z0-9 ]/g, '')
.trim()
.replace(/ /g, '-');
... | javascript | function (basePath, anchors) {
var fullPath = normalizePath(this.path, basePath) || '/';
anchors = anchors || [];
function getAnchor (title) {
var anchor = String(title).toLowerCase()
.replace(/[\s\-]+/g, ' ')
.replace(/[^a-z0-9 ]/g, '')
.trim()
.replace(/ /g, '-');
... | [
"function",
"(",
"basePath",
",",
"anchors",
")",
"{",
"var",
"fullPath",
"=",
"normalizePath",
"(",
"this",
".",
"path",
",",
"basePath",
")",
"||",
"'/'",
";",
"anchors",
"=",
"anchors",
"||",
"[",
"]",
";",
"function",
"getAnchor",
"(",
"title",
")"... | Export API documentation as HTML. | [
"Export",
"API",
"documentation",
"as",
"HTML",
"."
] | 8d6bbea299c9a8acef92a9c476b941660d0ef982 | https://github.com/JanitorTechnology/selfapi/blob/8d6bbea299c9a8acef92a9c476b941660d0ef982/selfapi.js#L407-L505 | train | |
JanitorTechnology/selfapi | selfapi.js | function (basePath) {
var fullPath = normalizePath(this.path, basePath) || '/';
var markdown = '';
if (this.title) {
markdown += '# ' + this.title + '\n\n';
}
if (this.description) {
markdown += this.description + '\n\n';
}
// Export own request handlers.
for (var method in... | javascript | function (basePath) {
var fullPath = normalizePath(this.path, basePath) || '/';
var markdown = '';
if (this.title) {
markdown += '# ' + this.title + '\n\n';
}
if (this.description) {
markdown += this.description + '\n\n';
}
// Export own request handlers.
for (var method in... | [
"function",
"(",
"basePath",
")",
"{",
"var",
"fullPath",
"=",
"normalizePath",
"(",
"this",
".",
"path",
",",
"basePath",
")",
"||",
"'/'",
";",
"var",
"markdown",
"=",
"''",
";",
"if",
"(",
"this",
".",
"title",
")",
"{",
"markdown",
"+=",
"'# '",
... | Export API documentation as Markdown. | [
"Export",
"API",
"documentation",
"as",
"Markdown",
"."
] | 8d6bbea299c9a8acef92a9c476b941660d0ef982 | https://github.com/JanitorTechnology/selfapi/blob/8d6bbea299c9a8acef92a9c476b941660d0ef982/selfapi.js#L508-L589 | train | |
JanitorTechnology/selfapi | selfapi.js | isServerApp | function isServerApp (app) {
return !!(app && (app.use || app.handle) && app.get && app.post);
} | javascript | function isServerApp (app) {
return !!(app && (app.use || app.handle) && app.get && app.post);
} | [
"function",
"isServerApp",
"(",
"app",
")",
"{",
"return",
"!",
"!",
"(",
"app",
"&&",
"(",
"app",
".",
"use",
"||",
"app",
".",
"handle",
")",
"&&",
"app",
".",
"get",
"&&",
"app",
".",
"post",
")",
";",
"}"
] | Detect if `app` is an express-like server. | [
"Detect",
"if",
"app",
"is",
"an",
"express",
"-",
"like",
"server",
"."
] | 8d6bbea299c9a8acef92a9c476b941660d0ef982 | https://github.com/JanitorTechnology/selfapi/blob/8d6bbea299c9a8acef92a9c476b941660d0ef982/selfapi.js#L608-L610 | train |
JanitorTechnology/selfapi | selfapi.js | getHandlerExporter | function getHandlerExporter (app) {
if (!isServerApp(app)) {
return null;
}
// `app` is an express-like server app.
return function (method, path, parameters) {
// Support restify.
if (method === 'del' && ('delete' in app)) {
method = 'delete';
}
app[method](path, parameters.handler);... | javascript | function getHandlerExporter (app) {
if (!isServerApp(app)) {
return null;
}
// `app` is an express-like server app.
return function (method, path, parameters) {
// Support restify.
if (method === 'del' && ('delete' in app)) {
method = 'delete';
}
app[method](path, parameters.handler);... | [
"function",
"getHandlerExporter",
"(",
"app",
")",
"{",
"if",
"(",
"!",
"isServerApp",
"(",
"app",
")",
")",
"{",
"return",
"null",
";",
"}",
"// `app` is an express-like server app.",
"return",
"function",
"(",
"method",
",",
"path",
",",
"parameters",
")",
... | Try to create a handler exporter function for a given server app. | [
"Try",
"to",
"create",
"a",
"handler",
"exporter",
"function",
"for",
"a",
"given",
"server",
"app",
"."
] | 8d6bbea299c9a8acef92a9c476b941660d0ef982 | https://github.com/JanitorTechnology/selfapi/blob/8d6bbea299c9a8acef92a9c476b941660d0ef982/selfapi.js#L613-L626 | train |
JanitorTechnology/selfapi | selfapi.js | jsonStringifyWithFunctions | function jsonStringifyWithFunctions (value) {
function replacer (key, value) {
if (typeof value === 'function') {
// Stringify this function, and slightly minify it.
value = String(value).replace(/\s+/g, ' ');
}
return options.jsonStringifyReplacer(key, value);
}
return JSON.stringify(valu... | javascript | function jsonStringifyWithFunctions (value) {
function replacer (key, value) {
if (typeof value === 'function') {
// Stringify this function, and slightly minify it.
value = String(value).replace(/\s+/g, ' ');
}
return options.jsonStringifyReplacer(key, value);
}
return JSON.stringify(valu... | [
"function",
"jsonStringifyWithFunctions",
"(",
"value",
")",
"{",
"function",
"replacer",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"typeof",
"value",
"===",
"'function'",
")",
"{",
"// Stringify this function, and slightly minify it.",
"value",
"=",
"String",
... | Stringify everything, including Function bodies. | [
"Stringify",
"everything",
"including",
"Function",
"bodies",
"."
] | 8d6bbea299c9a8acef92a9c476b941660d0ef982 | https://github.com/JanitorTechnology/selfapi/blob/8d6bbea299c9a8acef92a9c476b941660d0ef982/selfapi.js#L651-L660 | train |
3rd-Eden/shrinkwrap | module.js | Module | function Module(data, range, depth) {
this._id = data.name +'@'+ range; // An unique id that identifies this module.
this.released = data.released; // The date this version go released.
this.licenses = data.licenses; // The licensing.
this.version = data.version; // The version of the... | javascript | function Module(data, range, depth) {
this._id = data.name +'@'+ range; // An unique id that identifies this module.
this.released = data.released; // The date this version go released.
this.licenses = data.licenses; // The licensing.
this.version = data.version; // The version of the... | [
"function",
"Module",
"(",
"data",
",",
"range",
",",
"depth",
")",
"{",
"this",
".",
"_id",
"=",
"data",
".",
"name",
"+",
"'@'",
"+",
"range",
";",
"// An unique id that identifies this module.",
"this",
".",
"released",
"=",
"data",
".",
"released",
";"... | The representation of a single module.
@constructor
@param {Object} data The module data.
@param {String} range The semver range used to get this version.
@param {Number} depth How deeply nested was this module.
@api private | [
"The",
"representation",
"of",
"a",
"single",
"module",
"."
] | 60e0004e4092896e9ba6bd0d83bdc22a973812da | https://github.com/3rd-Eden/shrinkwrap/blob/60e0004e4092896e9ba6bd0d83bdc22a973812da/module.js#L14-L26 | train |
dominictarr/level-scuttlebutt | index.js | checkOld | function checkOld (id, ts) {
return false
if(sources[id] && sources[id] >= ts) return true
sources[id] = ts
} | javascript | function checkOld (id, ts) {
return false
if(sources[id] && sources[id] >= ts) return true
sources[id] = ts
} | [
"function",
"checkOld",
"(",
"id",
",",
"ts",
")",
"{",
"return",
"false",
"if",
"(",
"sources",
"[",
"id",
"]",
"&&",
"sources",
"[",
"id",
"]",
">=",
"ts",
")",
"return",
"true",
"sources",
"[",
"id",
"]",
"=",
"ts",
"}"
] | WHY DID I DO THIS? - remove this and it works. but it seems to be problem with r-array... | [
"WHY",
"DID",
"I",
"DO",
"THIS?",
"-",
"remove",
"this",
"and",
"it",
"works",
".",
"but",
"it",
"seems",
"to",
"be",
"problem",
"with",
"r",
"-",
"array",
"..."
] | fe0f9b68579b391e6995a5ca250ebc54a7fa93a3 | https://github.com/dominictarr/level-scuttlebutt/blob/fe0f9b68579b391e6995a5ca250ebc54a7fa93a3/index.js#L39-L43 | train |
dominictarr/level-scuttlebutt | index.js | onUpdate | function onUpdate (update) {
var value = update[0], ts = update[1], id = update[2]
insertBatch (id, key, ts, JSON.stringify(value), scuttlebutt)
} | javascript | function onUpdate (update) {
var value = update[0], ts = update[1], id = update[2]
insertBatch (id, key, ts, JSON.stringify(value), scuttlebutt)
} | [
"function",
"onUpdate",
"(",
"update",
")",
"{",
"var",
"value",
"=",
"update",
"[",
"0",
"]",
",",
"ts",
"=",
"update",
"[",
"1",
"]",
",",
"id",
"=",
"update",
"[",
"2",
"]",
"insertBatch",
"(",
"id",
",",
"key",
",",
"ts",
",",
"JSON",
".",
... | write the update twice, the first time, to store the document. maybe change scuttlebutt so that value is always a string? If i write a bunch of batches, will they come out in order? because I think updates are expected in order, or it will break. | [
"write",
"the",
"update",
"twice",
"the",
"first",
"time",
"to",
"store",
"the",
"document",
".",
"maybe",
"change",
"scuttlebutt",
"so",
"that",
"value",
"is",
"always",
"a",
"string?",
"If",
"i",
"write",
"a",
"bunch",
"of",
"batches",
"will",
"they",
... | fe0f9b68579b391e6995a5ca250ebc54a7fa93a3 | https://github.com/dominictarr/level-scuttlebutt/blob/fe0f9b68579b391e6995a5ca250ebc54a7fa93a3/index.js#L188-L191 | train |
sfrdmn/node-route-order | index.js | freeVariableWeight | function freeVariableWeight(sliced) {
return sliced.reduce(function(acc, part, i) {
// If is bound part
if (!/^:.+$/.test(part)) {
// Weight is positively correlated to indexes of bound parts
acc += Math.pow(i + 1, sliced.length)
}
return acc
}, 0)
} | javascript | function freeVariableWeight(sliced) {
return sliced.reduce(function(acc, part, i) {
// If is bound part
if (!/^:.+$/.test(part)) {
// Weight is positively correlated to indexes of bound parts
acc += Math.pow(i + 1, sliced.length)
}
return acc
}, 0)
} | [
"function",
"freeVariableWeight",
"(",
"sliced",
")",
"{",
"return",
"sliced",
".",
"reduce",
"(",
"function",
"(",
"acc",
",",
"part",
",",
"i",
")",
"{",
"// If is bound part",
"if",
"(",
"!",
"/",
"^:.+$",
"/",
".",
"test",
"(",
"part",
")",
")",
... | Takes a sliced path and returns an integer representing the
"weight" of its free variables. More specific routes are heavier
Intuitively: when a free variable is at the base of a path e.g.
'/:resource', this is more generic than '/resourceName/:id' and thus has
a lower weight
Weight can only be used to compare paths ... | [
"Takes",
"a",
"sliced",
"path",
"and",
"returns",
"an",
"integer",
"representing",
"the",
"weight",
"of",
"its",
"free",
"variables",
".",
"More",
"specific",
"routes",
"are",
"heavier"
] | b0d695a3096968729b38e045cd9f7dc03148da6d | https://github.com/sfrdmn/node-route-order/blob/b0d695a3096968729b38e045cd9f7dc03148da6d/index.js#L54-L63 | train |
theThings/jailed-node | lib/Connection.js | BasicConnection | function BasicConnection() {
var _this = this
this._disconnected = false
this._messageHandler = function() {
}
this._disconnectHandler = function() {
}
var childArgs = []
process.execArgv.forEach(function(arg) {
if (arg.indexOf('--debug-brk') !== -1) {
var _debugPort = parseInt(arg.substr(1... | javascript | function BasicConnection() {
var _this = this
this._disconnected = false
this._messageHandler = function() {
}
this._disconnectHandler = function() {
}
var childArgs = []
process.execArgv.forEach(function(arg) {
if (arg.indexOf('--debug-brk') !== -1) {
var _debugPort = parseInt(arg.substr(1... | [
"function",
"BasicConnection",
"(",
")",
"{",
"var",
"_this",
"=",
"this",
"this",
".",
"_disconnected",
"=",
"false",
"this",
".",
"_messageHandler",
"=",
"function",
"(",
")",
"{",
"}",
"this",
".",
"_disconnectHandler",
"=",
"function",
"(",
")",
"{",
... | Platform-dependent implementation of the BasicConnection
object, initializes the plugin site and provides the basic
messaging-based connection with it
For Node.js the plugin is created as a forked process | [
"Platform",
"-",
"dependent",
"implementation",
"of",
"the",
"BasicConnection",
"object",
"initializes",
"the",
"plugin",
"site",
"and",
"provides",
"the",
"basic",
"messaging",
"-",
"based",
"connection",
"with",
"it"
] | 6e453d97e74fbd1c0b27b982084f6fd7c1aa0173 | https://github.com/theThings/jailed-node/blob/6e453d97e74fbd1c0b27b982084f6fd7c1aa0173/lib/Connection.js#L21-L56 | train |
thlorenz/6bit-encoder | 6bit-encoder.js | decode2 | function decode2(s) {
assert.equal(s.length, 2)
const [ upper, lower ] = s
return (decode(upper) << 6) | decode(lower)
} | javascript | function decode2(s) {
assert.equal(s.length, 2)
const [ upper, lower ] = s
return (decode(upper) << 6) | decode(lower)
} | [
"function",
"decode2",
"(",
"s",
")",
"{",
"assert",
".",
"equal",
"(",
"s",
".",
"length",
",",
"2",
")",
"const",
"[",
"upper",
",",
"lower",
"]",
"=",
"s",
"return",
"(",
"decode",
"(",
"upper",
")",
"<<",
"6",
")",
"|",
"decode",
"(",
"lowe... | Decodes two chars into a 12 bit number
@name decode2
@param {String} s the chars to decode
@returns {Number} a 12 bit number | [
"Decodes",
"two",
"chars",
"into",
"a",
"12",
"bit",
"number"
] | ea0449137b3c155dcd59bc37c852efa35240dddd | https://github.com/thlorenz/6bit-encoder/blob/ea0449137b3c155dcd59bc37c852efa35240dddd/6bit-encoder.js#L82-L86 | train |
thlorenz/6bit-encoder | 6bit-encoder.js | decode3 | function decode3(s) {
assert.equal(s.length, 3)
const [ upper, mid, lower ] = s
return (decode(upper) << 12) | (decode(mid) << 6) | decode(lower)
} | javascript | function decode3(s) {
assert.equal(s.length, 3)
const [ upper, mid, lower ] = s
return (decode(upper) << 12) | (decode(mid) << 6) | decode(lower)
} | [
"function",
"decode3",
"(",
"s",
")",
"{",
"assert",
".",
"equal",
"(",
"s",
".",
"length",
",",
"3",
")",
"const",
"[",
"upper",
",",
"mid",
",",
"lower",
"]",
"=",
"s",
"return",
"(",
"decode",
"(",
"upper",
")",
"<<",
"12",
")",
"|",
"(",
... | Decodes three chars into an 18 bit number
@name decode3
@param {String} s the chars to decode
@returns {Number} an 18 bit number | [
"Decodes",
"three",
"chars",
"into",
"an",
"18",
"bit",
"number"
] | ea0449137b3c155dcd59bc37c852efa35240dddd | https://github.com/thlorenz/6bit-encoder/blob/ea0449137b3c155dcd59bc37c852efa35240dddd/6bit-encoder.js#L96-L100 | train |
thlorenz/6bit-encoder | 6bit-encoder.js | decode4 | function decode4(s) {
assert.equal(s.length, 4)
const [ upper, belowUpper, aboveLower, lower ] = s
return (decode(upper) << 18) | (decode(belowUpper) << 12)
| (decode(aboveLower) << 6) | decode(lower)
} | javascript | function decode4(s) {
assert.equal(s.length, 4)
const [ upper, belowUpper, aboveLower, lower ] = s
return (decode(upper) << 18) | (decode(belowUpper) << 12)
| (decode(aboveLower) << 6) | decode(lower)
} | [
"function",
"decode4",
"(",
"s",
")",
"{",
"assert",
".",
"equal",
"(",
"s",
".",
"length",
",",
"4",
")",
"const",
"[",
"upper",
",",
"belowUpper",
",",
"aboveLower",
",",
"lower",
"]",
"=",
"s",
"return",
"(",
"decode",
"(",
"upper",
")",
"<<",
... | Decodes four chars into an 24 bit number
@name decode4
@param {String} s the chars to decode
@returns {Number} a 24 bit number | [
"Decodes",
"four",
"chars",
"into",
"an",
"24",
"bit",
"number"
] | ea0449137b3c155dcd59bc37c852efa35240dddd | https://github.com/thlorenz/6bit-encoder/blob/ea0449137b3c155dcd59bc37c852efa35240dddd/6bit-encoder.js#L110-L115 | train |
thlorenz/6bit-encoder | 6bit-encoder.js | decode5 | function decode5(s) {
assert.equal(s.length, 5)
const [ upper, belowUpper, mid, aboveLower, lower ] = s
return (decode(upper) << 24) | (decode(belowUpper) << 18)
| (decode(mid) << 12) | (decode(aboveLower) << 6) | decode(lower)
} | javascript | function decode5(s) {
assert.equal(s.length, 5)
const [ upper, belowUpper, mid, aboveLower, lower ] = s
return (decode(upper) << 24) | (decode(belowUpper) << 18)
| (decode(mid) << 12) | (decode(aboveLower) << 6) | decode(lower)
} | [
"function",
"decode5",
"(",
"s",
")",
"{",
"assert",
".",
"equal",
"(",
"s",
".",
"length",
",",
"5",
")",
"const",
"[",
"upper",
",",
"belowUpper",
",",
"mid",
",",
"aboveLower",
",",
"lower",
"]",
"=",
"s",
"return",
"(",
"decode",
"(",
"upper",
... | Decodes five chars into an 30 bit number
@name decode5
@param {String} s the chars to decode
@returns {Number} a 30 bit number | [
"Decodes",
"five",
"chars",
"into",
"an",
"30",
"bit",
"number"
] | ea0449137b3c155dcd59bc37c852efa35240dddd | https://github.com/thlorenz/6bit-encoder/blob/ea0449137b3c155dcd59bc37c852efa35240dddd/6bit-encoder.js#L125-L130 | train |
thlorenz/6bit-encoder | 6bit-encoder.js | encode2 | function encode2(n) {
assert(0 <= n && n <= 0xfff, ENCODE_OUTOFBOUNDS + n)
// 12 bits -> 2 digits
const lower = isolate(n, 0, 6)
const upper = isolate(n, 6, 6)
return encode(upper) + encode(lower)
} | javascript | function encode2(n) {
assert(0 <= n && n <= 0xfff, ENCODE_OUTOFBOUNDS + n)
// 12 bits -> 2 digits
const lower = isolate(n, 0, 6)
const upper = isolate(n, 6, 6)
return encode(upper) + encode(lower)
} | [
"function",
"encode2",
"(",
"n",
")",
"{",
"assert",
"(",
"0",
"<=",
"n",
"&&",
"n",
"<=",
"0xfff",
",",
"ENCODE_OUTOFBOUNDS",
"+",
"n",
")",
"// 12 bits -> 2 digits",
"const",
"lower",
"=",
"isolate",
"(",
"n",
",",
"0",
",",
"6",
")",
"const",
"upp... | Encodes a 12 bit number into two URL safe chars
@name encode2
@param {Number} n a 12 bit number
@returns {String} the chars | [
"Encodes",
"a",
"12",
"bit",
"number",
"into",
"two",
"URL",
"safe",
"chars"
] | ea0449137b3c155dcd59bc37c852efa35240dddd | https://github.com/thlorenz/6bit-encoder/blob/ea0449137b3c155dcd59bc37c852efa35240dddd/6bit-encoder.js#L154-L160 | train |
thlorenz/6bit-encoder | 6bit-encoder.js | encode3 | function encode3(n) {
assert(0 <= n && n <= 0x3ffff, ENCODE_OUTOFBOUNDS + n)
// 18 bits -> 3 digits
const lower = isolate(n, 0, 6)
const mid = isolate(n, 6, 6)
const upper = isolate(n, 12, 6)
return encode(upper) + encode(mid) + encode(lower)
} | javascript | function encode3(n) {
assert(0 <= n && n <= 0x3ffff, ENCODE_OUTOFBOUNDS + n)
// 18 bits -> 3 digits
const lower = isolate(n, 0, 6)
const mid = isolate(n, 6, 6)
const upper = isolate(n, 12, 6)
return encode(upper) + encode(mid) + encode(lower)
} | [
"function",
"encode3",
"(",
"n",
")",
"{",
"assert",
"(",
"0",
"<=",
"n",
"&&",
"n",
"<=",
"0x3ffff",
",",
"ENCODE_OUTOFBOUNDS",
"+",
"n",
")",
"// 18 bits -> 3 digits",
"const",
"lower",
"=",
"isolate",
"(",
"n",
",",
"0",
",",
"6",
")",
"const",
"m... | Encodes a 18 bit number into three URL safe chars
@name encode3
@param {Number} n a 18 bit number
@returns {String} the chars | [
"Encodes",
"a",
"18",
"bit",
"number",
"into",
"three",
"URL",
"safe",
"chars"
] | ea0449137b3c155dcd59bc37c852efa35240dddd | https://github.com/thlorenz/6bit-encoder/blob/ea0449137b3c155dcd59bc37c852efa35240dddd/6bit-encoder.js#L170-L177 | train |
thlorenz/6bit-encoder | 6bit-encoder.js | encode4 | function encode4(n) {
assert(0 <= n && n <= 0xffffff, ENCODE_OUTOFBOUNDS + n)
// 24 bits -> 4 digits
const lower = isolate(n, 0, 6)
const aboveLower = isolate(n, 6, 6)
const belowUpper = isolate(n, 12, 6)
const upper = isolate(n, 18, 6)
return encode(upper) + encode(belowUpper)
+ encode(aboveLower) + ... | javascript | function encode4(n) {
assert(0 <= n && n <= 0xffffff, ENCODE_OUTOFBOUNDS + n)
// 24 bits -> 4 digits
const lower = isolate(n, 0, 6)
const aboveLower = isolate(n, 6, 6)
const belowUpper = isolate(n, 12, 6)
const upper = isolate(n, 18, 6)
return encode(upper) + encode(belowUpper)
+ encode(aboveLower) + ... | [
"function",
"encode4",
"(",
"n",
")",
"{",
"assert",
"(",
"0",
"<=",
"n",
"&&",
"n",
"<=",
"0xffffff",
",",
"ENCODE_OUTOFBOUNDS",
"+",
"n",
")",
"// 24 bits -> 4 digits",
"const",
"lower",
"=",
"isolate",
"(",
"n",
",",
"0",
",",
"6",
")",
"const",
"... | Encodes a 24 bit number into four URL safe chars
@name encode4
@param {Number} n a 24 bit number
@returns {String} the chars | [
"Encodes",
"a",
"24",
"bit",
"number",
"into",
"four",
"URL",
"safe",
"chars"
] | ea0449137b3c155dcd59bc37c852efa35240dddd | https://github.com/thlorenz/6bit-encoder/blob/ea0449137b3c155dcd59bc37c852efa35240dddd/6bit-encoder.js#L187-L196 | train |
thlorenz/6bit-encoder | 6bit-encoder.js | encode5 | function encode5(n) {
assert(0 <= n && n <= 0x3fffffff, ENCODE_OUTOFBOUNDS + n)
// 30 bits -> 5 digits
const lower = isolate(n, 0, 6)
const aboveLower = isolate(n, 6, 6)
const mid = isolate(n, 12, 6)
const belowUpper = isolate(n, 18, 6)
const upper = isolate(n, 24, 6)
return encode(upper) + encode(below... | javascript | function encode5(n) {
assert(0 <= n && n <= 0x3fffffff, ENCODE_OUTOFBOUNDS + n)
// 30 bits -> 5 digits
const lower = isolate(n, 0, 6)
const aboveLower = isolate(n, 6, 6)
const mid = isolate(n, 12, 6)
const belowUpper = isolate(n, 18, 6)
const upper = isolate(n, 24, 6)
return encode(upper) + encode(below... | [
"function",
"encode5",
"(",
"n",
")",
"{",
"assert",
"(",
"0",
"<=",
"n",
"&&",
"n",
"<=",
"0x3fffffff",
",",
"ENCODE_OUTOFBOUNDS",
"+",
"n",
")",
"// 30 bits -> 5 digits",
"const",
"lower",
"=",
"isolate",
"(",
"n",
",",
"0",
",",
"6",
")",
"const",
... | Encodes a 30 bit number into five URL safe chars
@name encode5
@param {Number} n a 30 bit number
@returns {String} the chars | [
"Encodes",
"a",
"30",
"bit",
"number",
"into",
"five",
"URL",
"safe",
"chars"
] | ea0449137b3c155dcd59bc37c852efa35240dddd | https://github.com/thlorenz/6bit-encoder/blob/ea0449137b3c155dcd59bc37c852efa35240dddd/6bit-encoder.js#L206-L216 | train |
thlorenz/6bit-encoder | 6bit-encoder.js | decodeFor | function decodeFor(n) {
return (
n === 1 ? decode
: n === 2 ? decode2
: n === 3 ? decode3
: n === 4 ? decode4
: decode5
)
} | javascript | function decodeFor(n) {
return (
n === 1 ? decode
: n === 2 ? decode2
: n === 3 ? decode3
: n === 4 ? decode4
: decode5
)
} | [
"function",
"decodeFor",
"(",
"n",
")",
"{",
"return",
"(",
"n",
"===",
"1",
"?",
"decode",
":",
"n",
"===",
"2",
"?",
"decode2",
":",
"n",
"===",
"3",
"?",
"decode3",
":",
"n",
"===",
"4",
"?",
"decode4",
":",
"decode5",
")",
"}"
] | Get a decode function to decode n chars
@name decodeFor
@param {Number} n the number of chars to decode
@returns {function} the matching decoding function | [
"Get",
"a",
"decode",
"function",
"to",
"decode",
"n",
"chars"
] | ea0449137b3c155dcd59bc37c852efa35240dddd | https://github.com/thlorenz/6bit-encoder/blob/ea0449137b3c155dcd59bc37c852efa35240dddd/6bit-encoder.js#L226-L234 | train |
jakubchadim/nightmare-react-utils | src/actions.js | function (selector, done) {
this.evaluate_now((selector) => {
let element = document.querySelector(selector)
if (!element) {
return false
}
for (let key in element) {
if (key.startsWith('__reactInternalInstance$')) {
return true
}
}
return false
}, done, selector)... | javascript | function (selector, done) {
this.evaluate_now((selector) => {
let element = document.querySelector(selector)
if (!element) {
return false
}
for (let key in element) {
if (key.startsWith('__reactInternalInstance$')) {
return true
}
}
return false
}, done, selector)... | [
"function",
"(",
"selector",
",",
"done",
")",
"{",
"this",
".",
"evaluate_now",
"(",
"(",
"selector",
")",
"=>",
"{",
"let",
"element",
"=",
"document",
".",
"querySelector",
"(",
"selector",
")",
"if",
"(",
"!",
"element",
")",
"{",
"return",
"false"... | Check if react element exists
@param {String} selector
@param {Function} done
@return {Boolean} | [
"Check",
"if",
"react",
"element",
"exists"
] | b36cf50e0016f59fdd4a53cc57f5b0e239394ce6 | https://github.com/jakubchadim/nightmare-react-utils/blob/b36cf50e0016f59fdd4a53cc57f5b0e239394ce6/src/actions.js#L13-L28 | train | |
jakubchadim/nightmare-react-utils | src/actions.js | function (selector, done) {
this.evaluate_now((selector) => {
let element = document.querySelector(selector)
if (!element) {
return null
}
for (let key in element) {
if (key.startsWith('__reactInternalInstance$')) {
const compInternals = element[key]._currentElement
const ... | javascript | function (selector, done) {
this.evaluate_now((selector) => {
let element = document.querySelector(selector)
if (!element) {
return null
}
for (let key in element) {
if (key.startsWith('__reactInternalInstance$')) {
const compInternals = element[key]._currentElement
const ... | [
"function",
"(",
"selector",
",",
"done",
")",
"{",
"this",
".",
"evaluate_now",
"(",
"(",
"selector",
")",
"=>",
"{",
"let",
"element",
"=",
"document",
".",
"querySelector",
"(",
"selector",
")",
"if",
"(",
"!",
"element",
")",
"{",
"return",
"null",... | Find react element by selector and return his values
@param {String} selector
@param {Function} done
@return {{state: Object, props: Object, context: Object}} | [
"Find",
"react",
"element",
"by",
"selector",
"and",
"return",
"his",
"values"
] | b36cf50e0016f59fdd4a53cc57f5b0e239394ce6 | https://github.com/jakubchadim/nightmare-react-utils/blob/b36cf50e0016f59fdd4a53cc57f5b0e239394ce6/src/actions.js#L37-L59 | train | |
jakubchadim/nightmare-react-utils | src/actions.js | function (selector, done) {
this.evaluate_now((selector) => {
let elements = document.querySelectorAll(selector)
if (!elements.length) {
return []
}
elements = [].slice.call(elements) // Convert to array
return elements.map(element => {
for (let key in element) {
if (key.star... | javascript | function (selector, done) {
this.evaluate_now((selector) => {
let elements = document.querySelectorAll(selector)
if (!elements.length) {
return []
}
elements = [].slice.call(elements) // Convert to array
return elements.map(element => {
for (let key in element) {
if (key.star... | [
"function",
"(",
"selector",
",",
"done",
")",
"{",
"this",
".",
"evaluate_now",
"(",
"(",
"selector",
")",
"=>",
"{",
"let",
"elements",
"=",
"document",
".",
"querySelectorAll",
"(",
"selector",
")",
"if",
"(",
"!",
"elements",
".",
"length",
")",
"{... | Find all react elements by selector and return their values
@param {String} selector
@param {Function} done
@return {Array} | [
"Find",
"all",
"react",
"elements",
"by",
"selector",
"and",
"return",
"their",
"values"
] | b36cf50e0016f59fdd4a53cc57f5b0e239394ce6 | https://github.com/jakubchadim/nightmare-react-utils/blob/b36cf50e0016f59fdd4a53cc57f5b0e239394ce6/src/actions.js#L68-L92 | train | |
jakubchadim/nightmare-react-utils | src/actions.js | waitfn | function waitfn () {
const softTimeout = this.timeout || null
const callback = this.callback
let executionTimer
let softTimeoutTimer
let self = arguments[0]
let args = sliced(arguments)
let done = args[args.length - 1]
let timeoutTimer = setTimeout(function () {
clearTimeout(executionTimer)
cl... | javascript | function waitfn () {
const softTimeout = this.timeout || null
const callback = this.callback
let executionTimer
let softTimeoutTimer
let self = arguments[0]
let args = sliced(arguments)
let done = args[args.length - 1]
let timeoutTimer = setTimeout(function () {
clearTimeout(executionTimer)
cl... | [
"function",
"waitfn",
"(",
")",
"{",
"const",
"softTimeout",
"=",
"this",
".",
"timeout",
"||",
"null",
"const",
"callback",
"=",
"this",
".",
"callback",
"let",
"executionTimer",
"let",
"softTimeoutTimer",
"let",
"self",
"=",
"arguments",
"[",
"0",
"]",
"... | Wait until evaluated function returns true.
@param {Nightmare} self
@param {Function} fn
@param {...} args
@param {Function} done | [
"Wait",
"until",
"evaluated",
"function",
"returns",
"true",
"."
] | b36cf50e0016f59fdd4a53cc57f5b0e239394ce6 | https://github.com/jakubchadim/nightmare-react-utils/blob/b36cf50e0016f59fdd4a53cc57f5b0e239394ce6/src/actions.js#L146-L193 | train |
jakubchadim/nightmare-react-utils | src/actions.js | waitelem | function waitelem (self, selector, done) {
let elementPresent
eval('elementPresent = function() {' + // eslint-disable-line
` var element = document.querySelector('${selector}');` +
' if (!element) { return null }' +
' for (let key in element) {' +
' if (key.startsWith(\'__reactInternalInstanc... | javascript | function waitelem (self, selector, done) {
let elementPresent
eval('elementPresent = function() {' + // eslint-disable-line
` var element = document.querySelector('${selector}');` +
' if (!element) { return null }' +
' for (let key in element) {' +
' if (key.startsWith(\'__reactInternalInstanc... | [
"function",
"waitelem",
"(",
"self",
",",
"selector",
",",
"done",
")",
"{",
"let",
"elementPresent",
"eval",
"(",
"'elementPresent = function() {'",
"+",
"// eslint-disable-line",
"`",
"${",
"selector",
"}",
"`",
"+",
"' if (!element) { return null }'",
"+",
"' f... | Wait for a specified selector to exist.
@param {Nightmare} self
@param {String} selector
@param {Function} done | [
"Wait",
"for",
"a",
"specified",
"selector",
"to",
"exist",
"."
] | b36cf50e0016f59fdd4a53cc57f5b0e239394ce6 | https://github.com/jakubchadim/nightmare-react-utils/blob/b36cf50e0016f59fdd4a53cc57f5b0e239394ce6/src/actions.js#L202-L218 | train |
VisionistInc/jibe | app.js | function(io) {
// chat routes
router.use('/chat', chatRoutes);
// ops routes
router.use('/ops', opsRoutes);
// ShareJS built-in REST routes
router.use('/docs', shareRoutes);
if(io) {
io.of('/chat').on('connection', chatHandler);
}
router.use('/lib', expr... | javascript | function(io) {
// chat routes
router.use('/chat', chatRoutes);
// ops routes
router.use('/ops', opsRoutes);
// ShareJS built-in REST routes
router.use('/docs', shareRoutes);
if(io) {
io.of('/chat').on('connection', chatHandler);
}
router.use('/lib', expr... | [
"function",
"(",
"io",
")",
"{",
"// chat routes",
"router",
".",
"use",
"(",
"'/chat'",
",",
"chatRoutes",
")",
";",
"// ops routes",
"router",
".",
"use",
"(",
"'/ops'",
",",
"opsRoutes",
")",
";",
"// ShareJS built-in REST routes",
"router",
".",
"use",
"... | This function creates and returns an Express 4 Router.
As a side effect, creates the necessary socket channels using the given
socketIO object.
Example usage:
var express = require('express'),
app = express(),
server = require('http').createServer(app),
io = require('socket.io').listen(server);
var jibe = require('... | [
"This",
"function",
"creates",
"and",
"returns",
"an",
"Express",
"4",
"Router",
"."
] | 3a154c0d86a3bcf8980c5104daec099ec738a4e0 | https://github.com/VisionistInc/jibe/blob/3a154c0d86a3bcf8980c5104daec099ec738a4e0/app.js#L62-L80 | train | |
oscmejia/libs | lib/libs/format.js | decimal | function decimal(_num, _precision) {
// If _num is undefined, assing 0
if(_num === undefined) _num = 0;
// If _precision is undefined, assigned 2
if(_precision === undefined) _num = 2;
n = Math.abs(_num);
var sign = '';
if(_num < 0)
sign = '-';
return sign + n.toFixed(_precision... | javascript | function decimal(_num, _precision) {
// If _num is undefined, assing 0
if(_num === undefined) _num = 0;
// If _precision is undefined, assigned 2
if(_precision === undefined) _num = 2;
n = Math.abs(_num);
var sign = '';
if(_num < 0)
sign = '-';
return sign + n.toFixed(_precision... | [
"function",
"decimal",
"(",
"_num",
",",
"_precision",
")",
"{",
"// If _num is undefined, assing 0\t",
"if",
"(",
"_num",
"===",
"undefined",
")",
"_num",
"=",
"0",
";",
"// If _precision is undefined, assigned 2",
"if",
"(",
"_precision",
"===",
"undefined",
")",
... | Returns a string of a number with the given presicion.
@param {Number} _num
@param {int} _precision
@api public | [
"Returns",
"a",
"string",
"of",
"a",
"number",
"with",
"the",
"given",
"presicion",
"."
] | 81f8654af6ee922963e6cc3f6cda96ffa75142cf | https://github.com/oscmejia/libs/blob/81f8654af6ee922963e6cc3f6cda96ffa75142cf/lib/libs/format.js#L25-L40 | train |
BlackWaspTech/wasp-graphql | _internal/configureFetch.js | configureFetch | function configureFetch(init) {
// If the user only provided a query string
if (typeof init === 'string') {
var request = {
method: init.method || 'POST',
headers: init.headers || {
'Content-Type': 'application/json',
Accept: 'application/json'
},
body: JSON.stri... | javascript | function configureFetch(init) {
// If the user only provided a query string
if (typeof init === 'string') {
var request = {
method: init.method || 'POST',
headers: init.headers || {
'Content-Type': 'application/json',
Accept: 'application/json'
},
body: JSON.stri... | [
"function",
"configureFetch",
"(",
"init",
")",
"{",
"// If the user only provided a query string\r",
"if",
"(",
"typeof",
"init",
"===",
"'string'",
")",
"{",
"var",
"request",
"=",
"{",
"method",
":",
"init",
".",
"method",
"||",
"'POST'",
",",
"headers",
":... | Generates the settings necessary for a successful GraphQL request.
@param {(string|Object)} init - Option(s) provided by the user
@returns {string} - A parsable JSON string | [
"Generates",
"the",
"settings",
"necessary",
"for",
"a",
"successful",
"GraphQL",
"request",
"."
] | 5857b82b6eda9bb5dea5f0a881cd910b1bb3944a | https://github.com/BlackWaspTech/wasp-graphql/blob/5857b82b6eda9bb5dea5f0a881cd910b1bb3944a/_internal/configureFetch.js#L11-L52 | train |
feedhenry-raincatcher/raincatcher-angularjs | demo/mobile/src/app/sync/syncGlobalManager.js | createGlobalManagerService | function createGlobalManagerService($http, authService) {
//Init the sync service
syncNetworkInit.initSync($http).catch(function(error) {
logger.getLogger().error("Failed to initialize sync", error);
});
var syncManager = new SyncManager();
authService.setLoginListener(function(profileData) {
syncMana... | javascript | function createGlobalManagerService($http, authService) {
//Init the sync service
syncNetworkInit.initSync($http).catch(function(error) {
logger.getLogger().error("Failed to initialize sync", error);
});
var syncManager = new SyncManager();
authService.setLoginListener(function(profileData) {
syncMana... | [
"function",
"createGlobalManagerService",
"(",
"$http",
",",
"authService",
")",
"{",
"//Init the sync service",
"syncNetworkInit",
".",
"initSync",
"(",
"$http",
")",
".",
"catch",
"(",
"function",
"(",
"error",
")",
"{",
"logger",
".",
"getLogger",
"(",
")",
... | Service to manage init all of the sync data sets.
@param $q
@returns {{}}
@constructor | [
"Service",
"to",
"manage",
"init",
"all",
"of",
"the",
"sync",
"data",
"sets",
"."
] | b394689227901e18871ad9edd0ec226c5e6839e1 | https://github.com/feedhenry-raincatcher/raincatcher-angularjs/blob/b394689227901e18871ad9edd0ec226c5e6839e1/demo/mobile/src/app/sync/syncGlobalManager.js#L117-L131 | train |
chjj/rondo | lib/io.js | function(path) {
var loc = window.location;
if (path[path.length-1] === '/') {
path = path.slice(0, -1);
}
if (~path.indexOf('//')) {
return path;
}
var auth = /^[^:\/]+:\/\/[^\/]+/.exec(loc.href)[0];
if (path[0] === '/') {
path = auth + path;
} else {
path = path.replace(/^\.?\//, ... | javascript | function(path) {
var loc = window.location;
if (path[path.length-1] === '/') {
path = path.slice(0, -1);
}
if (~path.indexOf('//')) {
return path;
}
var auth = /^[^:\/]+:\/\/[^\/]+/.exec(loc.href)[0];
if (path[0] === '/') {
path = auth + path;
} else {
path = path.replace(/^\.?\//, ... | [
"function",
"(",
"path",
")",
"{",
"var",
"loc",
"=",
"window",
".",
"location",
";",
"if",
"(",
"path",
"[",
"path",
".",
"length",
"-",
"1",
"]",
"===",
"'/'",
")",
"{",
"path",
"=",
"path",
".",
"slice",
"(",
"0",
",",
"-",
"1",
")",
";",
... | XXX this needs cleaning, add a parsePath method | [
"XXX",
"this",
"needs",
"cleaning",
"add",
"a",
"parsePath",
"method"
] | 5a0643a2e4ce74e25240517e1cf423df5a188008 | https://github.com/chjj/rondo/blob/5a0643a2e4ce74e25240517e1cf423df5a188008/lib/io.js#L51-L73 | train | |
alexyoung/pop | lib/file_map.js | FileMap | function FileMap(config) {
this.config = config || {};
this.config.exclude = config && config.exclude ? config.exclude : [];
this.config.exclude.push('/_site');
this.ignoreDotFiles = true;
this.root = config.root;
this.files = [];
this.events = new EventEmitter();
this.filesLeft = 0;
this.dirsLeft = 1... | javascript | function FileMap(config) {
this.config = config || {};
this.config.exclude = config && config.exclude ? config.exclude : [];
this.config.exclude.push('/_site');
this.ignoreDotFiles = true;
this.root = config.root;
this.files = [];
this.events = new EventEmitter();
this.filesLeft = 0;
this.dirsLeft = 1... | [
"function",
"FileMap",
"(",
"config",
")",
"{",
"this",
".",
"config",
"=",
"config",
"||",
"{",
"}",
";",
"this",
".",
"config",
".",
"exclude",
"=",
"config",
"&&",
"config",
".",
"exclude",
"?",
"config",
".",
"exclude",
":",
"[",
"]",
";",
"thi... | Initialize `FileMap` with a config object.
@param {Object} options
@api public | [
"Initialize",
"FileMap",
"with",
"a",
"config",
"object",
"."
] | 8a0b3f2605cb58e8ae6b34f1373dde00610e9858 | https://github.com/alexyoung/pop/blob/8a0b3f2605cb58e8ae6b34f1373dde00610e9858/lib/file_map.js#L21-L31 | train |
diosney/json2pot | utils.js | dotFlatten | function dotFlatten(object, optSep) {
let flattenedMap = {};
if (!object) {
throw new Error('`object` should be a proper Object non null nor undefined.');
}
let sep = optSep || '.';
dotFlattenFn(object, sep, flattenedMap);
return flattenedMap;
} | javascript | function dotFlatten(object, optSep) {
let flattenedMap = {};
if (!object) {
throw new Error('`object` should be a proper Object non null nor undefined.');
}
let sep = optSep || '.';
dotFlattenFn(object, sep, flattenedMap);
return flattenedMap;
} | [
"function",
"dotFlatten",
"(",
"object",
",",
"optSep",
")",
"{",
"let",
"flattenedMap",
"=",
"{",
"}",
";",
"if",
"(",
"!",
"object",
")",
"{",
"throw",
"new",
"Error",
"(",
"'`object` should be a proper Object non null nor undefined.'",
")",
";",
"}",
"let",... | Flattens an object tree down to an object of only one level with property
names with the dotted full path to the leave data.
Ex: { 'a.b.c.d': 23, 'a.b.c.e': 54 }
Usage: `dotFlatten(object)`
Usage: `dotFlatten(object, ',')`
@param {Object} object - The object to process.
@param {String} [optSep] ... | [
"Flattens",
"an",
"object",
"tree",
"down",
"to",
"an",
"object",
"of",
"only",
"one",
"level",
"with",
"property",
"names",
"with",
"the",
"dotted",
"full",
"path",
"to",
"the",
"leave",
"data",
"."
] | a46c8dc0f479141824d05330d7b31cf72a5e8aa1 | https://github.com/diosney/json2pot/blob/a46c8dc0f479141824d05330d7b31cf72a5e8aa1/utils.js#L19-L29 | train |
diosney/json2pot | utils.js | dotFlattenFn | function dotFlattenFn(object, sep, flattenedMap, optPathSoFar) {
let levelKeys = Object.keys(object);
for (let i = 0, j = levelKeys.length; i < j; i++) {
let key = levelKeys[i];
let value = object[key];
let pathSoFar = cloneDeep(optPathSoFar) || [];
pathSoFar.push(key);
if (isPlainO... | javascript | function dotFlattenFn(object, sep, flattenedMap, optPathSoFar) {
let levelKeys = Object.keys(object);
for (let i = 0, j = levelKeys.length; i < j; i++) {
let key = levelKeys[i];
let value = object[key];
let pathSoFar = cloneDeep(optPathSoFar) || [];
pathSoFar.push(key);
if (isPlainO... | [
"function",
"dotFlattenFn",
"(",
"object",
",",
"sep",
",",
"flattenedMap",
",",
"optPathSoFar",
")",
"{",
"let",
"levelKeys",
"=",
"Object",
".",
"keys",
"(",
"object",
")",
";",
"for",
"(",
"let",
"i",
"=",
"0",
",",
"j",
"=",
"levelKeys",
".",
"le... | The real workhorse of the `dotFlatten` function.
A recursive function that fills a map when found the object leaves.
@param {Object} object
@param {String} sep - The separator between nested properties.
@param {Object} flattenedMap - The resulting object map of the flattening process.
@param {Ar... | [
"The",
"real",
"workhorse",
"of",
"the",
"dotFlatten",
"function",
".",
"A",
"recursive",
"function",
"that",
"fills",
"a",
"map",
"when",
"found",
"the",
"object",
"leaves",
"."
] | a46c8dc0f479141824d05330d7b31cf72a5e8aa1 | https://github.com/diosney/json2pot/blob/a46c8dc0f479141824d05330d7b31cf72a5e8aa1/utils.js#L41-L58 | train |
chovy/shapeshift | index.js | get | function get(url, opts){
opts = opts || {};
return requestp(_.extend(defaults, opts, {
url: url
}));
} | javascript | function get(url, opts){
opts = opts || {};
return requestp(_.extend(defaults, opts, {
url: url
}));
} | [
"function",
"get",
"(",
"url",
",",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"return",
"requestp",
"(",
"_",
".",
"extend",
"(",
"defaults",
",",
"opts",
",",
"{",
"url",
":",
"url",
"}",
")",
")",
";",
"}"
] | todo add support for callbacks instead of promises with options arg | [
"todo",
"add",
"support",
"for",
"callbacks",
"instead",
"of",
"promises",
"with",
"options",
"arg"
] | f6699fc7df74e10bf8fe79ee81bce5d72a47df54 | https://github.com/chovy/shapeshift/blob/f6699fc7df74e10bf8fe79ee81bce5d72a47df54/index.js#L13-L19 | train |
smfoote/tornado | src/compiler/visitors/visitor.js | normalizeFns | function normalizeFns(fns) {
Object.keys(fns).forEach(function(key) {
var handler = fns[key];
if (typeof handler === 'function') {
fns[key] = {
enter: handler,
leave: noop
};
}
});
} | javascript | function normalizeFns(fns) {
Object.keys(fns).forEach(function(key) {
var handler = fns[key];
if (typeof handler === 'function') {
fns[key] = {
enter: handler,
leave: noop
};
}
});
} | [
"function",
"normalizeFns",
"(",
"fns",
")",
"{",
"Object",
".",
"keys",
"(",
"fns",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"var",
"handler",
"=",
"fns",
"[",
"key",
"]",
";",
"if",
"(",
"typeof",
"handler",
"===",
"'function'",
... | visit can be an object with enter leave or a function if it is a function, run this on enter | [
"visit",
"can",
"be",
"an",
"object",
"with",
"enter",
"leave",
"or",
"a",
"function",
"if",
"it",
"is",
"a",
"function",
"run",
"this",
"on",
"enter"
] | e70f35c56ee9887390843cce96ee8bf5fa491501 | https://github.com/smfoote/tornado/blob/e70f35c56ee9887390843cce96ee8bf5fa491501/src/compiler/visitors/visitor.js#L15-L25 | train |
kengz/poly-socketio | src/global-client.js | init | function init(options) {
options = options || {}
var port = options.port || 6466
global.client = global.client || socketIOClient(`http://localhost:${port}`)
client = global.client
log.debug(`Started global js socketIO client for ${process.env.ADAPTER} at ${port}`)
client.emit('join', ioid) // first join for... | javascript | function init(options) {
options = options || {}
var port = options.port || 6466
global.client = global.client || socketIOClient(`http://localhost:${port}`)
client = global.client
log.debug(`Started global js socketIO client for ${process.env.ADAPTER} at ${port}`)
client.emit('join', ioid) // first join for... | [
"function",
"init",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
"var",
"port",
"=",
"options",
".",
"port",
"||",
"6466",
"global",
".",
"client",
"=",
"global",
".",
"client",
"||",
"socketIOClient",
"(",
"`",
"${",
"port",
... | init a global client at port | [
"init",
"a",
"global",
"client",
"at",
"port"
] | 261f84d3b4267a6d1a36eadd6526ddb45369973e | https://github.com/kengz/poly-socketio/blob/261f84d3b4267a6d1a36eadd6526ddb45369973e/src/global-client.js#L12-L26 | train |
kengz/poly-socketio | src/global-client.js | pass | function pass(to, input) {
var defer = cdefer()
clientPass(defer.resolve, to, input)
return defer.promise.catch((err) => {
console.log(`global-client-js promise exception with input: ${input}, to: ${JSON.stringify(to)}`)
})
} | javascript | function pass(to, input) {
var defer = cdefer()
clientPass(defer.resolve, to, input)
return defer.promise.catch((err) => {
console.log(`global-client-js promise exception with input: ${input}, to: ${JSON.stringify(to)}`)
})
} | [
"function",
"pass",
"(",
"to",
",",
"input",
")",
"{",
"var",
"defer",
"=",
"cdefer",
"(",
")",
"clientPass",
"(",
"defer",
".",
"resolve",
",",
"to",
",",
"input",
")",
"return",
"defer",
".",
"promise",
".",
"catch",
"(",
"(",
"err",
")",
"=>",
... | Pass that returns a promise for getting client replies conveniently.
Has promise timeout of 60s; is properly binded.
@param {string|JSON} to Name of the to script, or a JSON msg containing at least to, input
@param {*} input Input for the client to pass
@return {Promise} The promise object that will be re... | [
"Pass",
"that",
"returns",
"a",
"promise",
"for",
"getting",
"client",
"replies",
"conveniently",
".",
"Has",
"promise",
"timeout",
"of",
"60s",
";",
"is",
"properly",
"binded",
"."
] | 261f84d3b4267a6d1a36eadd6526ddb45369973e | https://github.com/kengz/poly-socketio/blob/261f84d3b4267a6d1a36eadd6526ddb45369973e/src/global-client.js#L35-L41 | train |
kengz/poly-socketio | src/global-client.js | cdefer | function cdefer() {
const maxWait = 20000
var resolve, reject
var promise = new Promise((...args) => {
resolve = args[0]
reject = args[1]
})
.timeout(maxWait)
return {
resolve: resolve,
reject: reject,
promise: promise
}
} | javascript | function cdefer() {
const maxWait = 20000
var resolve, reject
var promise = new Promise((...args) => {
resolve = args[0]
reject = args[1]
})
.timeout(maxWait)
return {
resolve: resolve,
reject: reject,
promise: promise
}
} | [
"function",
"cdefer",
"(",
")",
"{",
"const",
"maxWait",
"=",
"20000",
"var",
"resolve",
",",
"reject",
"var",
"promise",
"=",
"new",
"Promise",
"(",
"(",
"...",
"args",
")",
"=>",
"{",
"resolve",
"=",
"args",
"[",
"0",
"]",
"reject",
"=",
"args",
... | Promise constructor using defer pattern to expose its promise, resolve, reject. Has a timeout of 60s.
@return {defer} The Promise.defer legacy msg.
/* istanbul ignore next | [
"Promise",
"constructor",
"using",
"defer",
"pattern",
"to",
"expose",
"its",
"promise",
"resolve",
"reject",
".",
"Has",
"a",
"timeout",
"of",
"60s",
"."
] | 261f84d3b4267a6d1a36eadd6526ddb45369973e | https://github.com/kengz/poly-socketio/blob/261f84d3b4267a6d1a36eadd6526ddb45369973e/src/global-client.js#L88-L101 | train |
simbo/metalsmith-better-excerpts | lib/index.js | getExcerptByMoreTag | function getExcerptByMoreTag(file, regExp) {
var excerpt = false,
contents = file.contents.toString();
contents = cheerio.load('<root>' + contents + '</root>', {decodeEntities: false})('root').html();
var match = contents.search(regExp);
if (match > -1) {
excerpt = contents.slice(0, matc... | javascript | function getExcerptByMoreTag(file, regExp) {
var excerpt = false,
contents = file.contents.toString();
contents = cheerio.load('<root>' + contents + '</root>', {decodeEntities: false})('root').html();
var match = contents.search(regExp);
if (match > -1) {
excerpt = contents.slice(0, matc... | [
"function",
"getExcerptByMoreTag",
"(",
"file",
",",
"regExp",
")",
"{",
"var",
"excerpt",
"=",
"false",
",",
"contents",
"=",
"file",
".",
"contents",
".",
"toString",
"(",
")",
";",
"contents",
"=",
"cheerio",
".",
"load",
"(",
"'<root>'",
"+",
"conten... | retrieve excerpt from file object by extracting contents until a 'more' tag
@param {Object} file file object
@param {RegExp} regExp 'more' tag regexp
@return {mixed} excerpt string or false | [
"retrieve",
"excerpt",
"from",
"file",
"object",
"by",
"extracting",
"contents",
"until",
"a",
"more",
"tag"
] | ccc9535ec8e8491eda50fabc2d433c8053435924 | https://github.com/simbo/metalsmith-better-excerpts/blob/ccc9535ec8e8491eda50fabc2d433c8053435924/lib/index.js#L57-L67 | train |
simbo/metalsmith-better-excerpts | lib/index.js | getExcerptByFirstParagraph | function getExcerptByFirstParagraph(file) {
var $ = cheerio.load(file.contents.toString(), {decodeEntities: false}),
p = $('p').first(),
excerpt = p.length ? p.html().trim() : false;
if (excerpt) {
excerpt = v.unescapeHtml(excerpt);
}
return excerpt;
} | javascript | function getExcerptByFirstParagraph(file) {
var $ = cheerio.load(file.contents.toString(), {decodeEntities: false}),
p = $('p').first(),
excerpt = p.length ? p.html().trim() : false;
if (excerpt) {
excerpt = v.unescapeHtml(excerpt);
}
return excerpt;
} | [
"function",
"getExcerptByFirstParagraph",
"(",
"file",
")",
"{",
"var",
"$",
"=",
"cheerio",
".",
"load",
"(",
"file",
".",
"contents",
".",
"toString",
"(",
")",
",",
"{",
"decodeEntities",
":",
"false",
"}",
")",
",",
"p",
"=",
"$",
"(",
"'p'",
")"... | retrieve excerpt from file object by extracting the first p's contents
@param {Object} file file object
@return {mixed} excerpt string or false | [
"retrieve",
"excerpt",
"from",
"file",
"object",
"by",
"extracting",
"the",
"first",
"p",
"s",
"contents"
] | ccc9535ec8e8491eda50fabc2d433c8053435924 | https://github.com/simbo/metalsmith-better-excerpts/blob/ccc9535ec8e8491eda50fabc2d433c8053435924/lib/index.js#L76-L84 | train |
quorrajs/Positron | lib/support/str.js | is | function is(pattern, value) {
if (pattern == value) return true;
pattern = regexQuote(pattern);
// Asterisks are translated into zero-or-more regular expression wildcards
// to make it convenient to check if the strings starts with the given
// pattern such as "library/*", making any string check ... | javascript | function is(pattern, value) {
if (pattern == value) return true;
pattern = regexQuote(pattern);
// Asterisks are translated into zero-or-more regular expression wildcards
// to make it convenient to check if the strings starts with the given
// pattern such as "library/*", making any string check ... | [
"function",
"is",
"(",
"pattern",
",",
"value",
")",
"{",
"if",
"(",
"pattern",
"==",
"value",
")",
"return",
"true",
";",
"pattern",
"=",
"regexQuote",
"(",
"pattern",
")",
";",
"// Asterisks are translated into zero-or-more regular expression wildcards",
"// to ma... | Determine if a given string matches a given pattern.
@param {string} pattern
@param {string} value
@return bool | [
"Determine",
"if",
"a",
"given",
"string",
"matches",
"a",
"given",
"pattern",
"."
] | a4bad5a5f581743d1885405c11ae26600fb957af | https://github.com/quorrajs/Positron/blob/a4bad5a5f581743d1885405c11ae26600fb957af/lib/support/str.js#L25-L37 | train |
quorrajs/Positron | lib/support/str.js | quickRandom | function quickRandom(length) {
length = length || 16;
var pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
return str_shuffle(pool.repeat(5)).substr(0, length);
} | javascript | function quickRandom(length) {
length = length || 16;
var pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
return str_shuffle(pool.repeat(5)).substr(0, length);
} | [
"function",
"quickRandom",
"(",
"length",
")",
"{",
"length",
"=",
"length",
"||",
"16",
";",
"var",
"pool",
"=",
"'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'",
";",
"return",
"str_shuffle",
"(",
"pool",
".",
"repeat",
"(",
"5",
")",
")",
".... | Generate a "random" alpha-numeric string.
Should not be considered sufficient for cryptography, etc.
@param {number} [length]
@return {string} | [
"Generate",
"a",
"random",
"alpha",
"-",
"numeric",
"string",
"."
] | a4bad5a5f581743d1885405c11ae26600fb957af | https://github.com/quorrajs/Positron/blob/a4bad5a5f581743d1885405c11ae26600fb957af/lib/support/str.js#L77-L82 | train |
Kurento/kurento-module-chroma-js | lib/complexTypes/WindowParam.js | WindowParam | function WindowParam(windowParamDict){
if(!(this instanceof WindowParam))
return new WindowParam(windowParamDict)
windowParamDict = windowParamDict || {}
// Check windowParamDict has the required fields
//
// checkType('int', 'windowParamDict.topRightCornerX', windowParamDict.topRightCornerX, {required... | javascript | function WindowParam(windowParamDict){
if(!(this instanceof WindowParam))
return new WindowParam(windowParamDict)
windowParamDict = windowParamDict || {}
// Check windowParamDict has the required fields
//
// checkType('int', 'windowParamDict.topRightCornerX', windowParamDict.topRightCornerX, {required... | [
"function",
"WindowParam",
"(",
"windowParamDict",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"WindowParam",
")",
")",
"return",
"new",
"WindowParam",
"(",
"windowParamDict",
")",
"windowParamDict",
"=",
"windowParamDict",
"||",
"{",
"}",
"// Check win... | Parameter representing a window in a video stream.
It is used in command and constructor for media elements.
All units are in pixels, X runs from left to right, Y from top to bottom.
@constructor module:chroma/complexTypes.WindowParam
@property {external:Integer} topRightCornerX
X coordinate of the left upper point o... | [
"Parameter",
"representing",
"a",
"window",
"in",
"a",
"video",
"stream",
".",
"It",
"is",
"used",
"in",
"command",
"and",
"constructor",
"for",
"media",
"elements",
".",
"All",
"units",
"are",
"in",
"pixels",
"X",
"runs",
"from",
"left",
"to",
"right",
... | 4cd3a7504016bfb4cfd469be751a016a644fc0ba | https://github.com/Kurento/kurento-module-chroma-js/blob/4cd3a7504016bfb4cfd469be751a016a644fc0ba/lib/complexTypes/WindowParam.js#L45-L88 | train |
brewster/imagine | lib/imagine/source_downloader.js | function () {
// Create request options from parsed source URL
var options = url.parse(this.source, false);
// Add on some defaults
extend(options, {
method: 'get',
headers: {
host: options.host,
accept: 'image/*'
}
});
// Determine https/http from source URL
... | javascript | function () {
// Create request options from parsed source URL
var options = url.parse(this.source, false);
// Add on some defaults
extend(options, {
method: 'get',
headers: {
host: options.host,
accept: 'image/*'
}
});
// Determine https/http from source URL
... | [
"function",
"(",
")",
"{",
"// Create request options from parsed source URL",
"var",
"options",
"=",
"url",
".",
"parse",
"(",
"this",
".",
"source",
",",
"false",
")",
";",
"// Add on some defaults",
"extend",
"(",
"options",
",",
"{",
"method",
":",
"'get'",
... | Simply start the request when we're ready to go | [
"Simply",
"start",
"the",
"request",
"when",
"we",
"re",
"ready",
"to",
"go"
] | 42782ff6365f225f1fb9d90d3a654791286ef023 | https://github.com/brewster/imagine/blob/42782ff6365f225f1fb9d90d3a654791286ef023/lib/imagine/source_downloader.js#L18-L43 | train | |
excellalabs/ngComponentRouter | angular_1_router.js | normalizeRouteConfig | function normalizeRouteConfig(config, registry) {
if (config instanceof route_config_decorator_1.AsyncRoute) {
var wrappedLoader = wrapLoaderToReconfigureRegistry(config.loader, registry);
return new route_config_decorator_1.AsyncRoute({
path: config.path,
loader: wrappedLoad... | javascript | function normalizeRouteConfig(config, registry) {
if (config instanceof route_config_decorator_1.AsyncRoute) {
var wrappedLoader = wrapLoaderToReconfigureRegistry(config.loader, registry);
return new route_config_decorator_1.AsyncRoute({
path: config.path,
loader: wrappedLoad... | [
"function",
"normalizeRouteConfig",
"(",
"config",
",",
"registry",
")",
"{",
"if",
"(",
"config",
"instanceof",
"route_config_decorator_1",
".",
"AsyncRoute",
")",
"{",
"var",
"wrappedLoader",
"=",
"wrapLoaderToReconfigureRegistry",
"(",
"config",
".",
"loader",
",... | Given a JS Object that represents a route config, returns a corresponding Route, AsyncRoute,
AuxRoute or Redirect object.
Also wraps an AsyncRoute's loader function to add the loaded component's route config to the
`RouteRegistry`. | [
"Given",
"a",
"JS",
"Object",
"that",
"represents",
"a",
"route",
"config",
"returns",
"a",
"corresponding",
"Route",
"AsyncRoute",
"AuxRoute",
"or",
"Redirect",
"object",
"."
] | b2240385bf542987916e07aa0d8712c962963f2d | https://github.com/excellalabs/ngComponentRouter/blob/b2240385bf542987916e07aa0d8712c962963f2d/angular_1_router.js#L1134-L1201 | train |
excellalabs/ngComponentRouter | angular_1_router.js | ParamRoutePath | function ParamRoutePath(routePath) {
this.routePath = routePath;
this.terminal = true;
this._assertValidPath(routePath);
this._parsePathString(routePath);
this.specificity = this._calculateSpecificity();
this.hash = this._calculateHash();
var lastSegment = this._s... | javascript | function ParamRoutePath(routePath) {
this.routePath = routePath;
this.terminal = true;
this._assertValidPath(routePath);
this._parsePathString(routePath);
this.specificity = this._calculateSpecificity();
this.hash = this._calculateHash();
var lastSegment = this._s... | [
"function",
"ParamRoutePath",
"(",
"routePath",
")",
"{",
"this",
".",
"routePath",
"=",
"routePath",
";",
"this",
".",
"terminal",
"=",
"true",
";",
"this",
".",
"_assertValidPath",
"(",
"routePath",
")",
";",
"this",
".",
"_parsePathString",
"(",
"routePat... | Takes a string representing the matcher DSL | [
"Takes",
"a",
"string",
"representing",
"the",
"matcher",
"DSL"
] | b2240385bf542987916e07aa0d8712c962963f2d | https://github.com/excellalabs/ngComponentRouter/blob/b2240385bf542987916e07aa0d8712c962963f2d/angular_1_router.js#L1610-L1619 | train |
gurmukhp/gulp-svg-json-spritesheet | index.js | convertToJson | function convertToJson(callback) {
var output = new File(file);
output.contents = new Buffer(JSON.stringify(spritesheet, null, '\t'));
output.path = file;
this.push(output);
callback();
} | javascript | function convertToJson(callback) {
var output = new File(file);
output.contents = new Buffer(JSON.stringify(spritesheet, null, '\t'));
output.path = file;
this.push(output);
callback();
} | [
"function",
"convertToJson",
"(",
"callback",
")",
"{",
"var",
"output",
"=",
"new",
"File",
"(",
"file",
")",
";",
"output",
".",
"contents",
"=",
"new",
"Buffer",
"(",
"JSON",
".",
"stringify",
"(",
"spritesheet",
",",
"null",
",",
"'\\t'",
")",
")",... | Once all files have been compressed, return compressed JSON file.
@param {Function} callback | [
"Once",
"all",
"files",
"have",
"been",
"compressed",
"return",
"compressed",
"JSON",
"file",
"."
] | 393f629cad491365c0fc65b290b81f036432d50a | https://github.com/gurmukhp/gulp-svg-json-spritesheet/blob/393f629cad491365c0fc65b290b81f036432d50a/index.js#L64-L70 | train |
freshout-dev/thulium | lib/Thulium/Parser.js | function( callback ){
var tm = this;
setTimeout(function () {
var returnValue;
//check for template existance.
if (tm.template) {
tm._tokenize();
returnValue = tm._tokens;
// execute callback.
if (callback) {
callback( returnValu... | javascript | function( callback ){
var tm = this;
setTimeout(function () {
var returnValue;
//check for template existance.
if (tm.template) {
tm._tokenize();
returnValue = tm._tokens;
// execute callback.
if (callback) {
callback( returnValu... | [
"function",
"(",
"callback",
")",
"{",
"var",
"tm",
"=",
"this",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"var",
"returnValue",
";",
"//check for template existance.",
"if",
"(",
"tm",
".",
"template",
")",
"{",
"tm",
".",
"_tokenize",
"(",
")"... | Creates the token array and sends them to a callback | [
"Creates",
"the",
"token",
"array",
"and",
"sends",
"them",
"to",
"a",
"callback"
] | ba3173e700fbe810ce13063e7ad46e9b05bb49e7 | https://github.com/freshout-dev/thulium/blob/ba3173e700fbe810ce13063e7ad46e9b05bb49e7/lib/Thulium/Parser.js#L75-L94 | train | |
freshout-dev/thulium | lib/Thulium/Parser.js | function () {
var i;
i = this._openPrints.indexOf(this._openBrackets);
// if print indicators where found
if (i >= 0) {
// close it
this._tokens.push({
type : "closePrintIndicator"
});
// remove the print from the stack
this._openPrints.splice(i... | javascript | function () {
var i;
i = this._openPrints.indexOf(this._openBrackets);
// if print indicators where found
if (i >= 0) {
// close it
this._tokens.push({
type : "closePrintIndicator"
});
// remove the print from the stack
this._openPrints.splice(i... | [
"function",
"(",
")",
"{",
"var",
"i",
";",
"i",
"=",
"this",
".",
"_openPrints",
".",
"indexOf",
"(",
"this",
".",
"_openBrackets",
")",
";",
"// if print indicators where found",
"if",
"(",
"i",
">=",
"0",
")",
"{",
"// close it",
"this",
".",
"_tokens... | Remove the printIndicator buffer if no open brackets were found. | [
"Remove",
"the",
"printIndicator",
"buffer",
"if",
"no",
"open",
"brackets",
"were",
"found",
"."
] | ba3173e700fbe810ce13063e7ad46e9b05bb49e7 | https://github.com/freshout-dev/thulium/blob/ba3173e700fbe810ce13063e7ad46e9b05bb49e7/lib/Thulium/Parser.js#L249-L262 | train | |
mgcrea/gulp-nginclude | src/index.js | readSource | function readSource(src) {
var cwd = path.dirname(file.path);
if (options.assetsDirs && options.assetsDirs.length) {
var basename = path.basename(cwd);
if (options.assetsDirs.indexOf(basename) === -1) {
options.assetsDirs.unshift(path.basename(cwd));
}
src = path.jo... | javascript | function readSource(src) {
var cwd = path.dirname(file.path);
if (options.assetsDirs && options.assetsDirs.length) {
var basename = path.basename(cwd);
if (options.assetsDirs.indexOf(basename) === -1) {
options.assetsDirs.unshift(path.basename(cwd));
}
src = path.jo... | [
"function",
"readSource",
"(",
"src",
")",
"{",
"var",
"cwd",
"=",
"path",
".",
"dirname",
"(",
"file",
".",
"path",
")",
";",
"if",
"(",
"options",
".",
"assetsDirs",
"&&",
"options",
".",
"assetsDirs",
".",
"length",
")",
"{",
"var",
"basename",
"=... | This function receives an ng-include src and tries to read it from the filesystem | [
"This",
"function",
"receives",
"an",
"ng",
"-",
"include",
"src",
"and",
"tries",
"to",
"read",
"it",
"from",
"the",
"filesystem"
] | d9bfbf6c5d0f120f67827aa42fdb98ddc9177862 | https://github.com/mgcrea/gulp-nginclude/blob/d9bfbf6c5d0f120f67827aa42fdb98ddc9177862/src/index.js#L25-L38 | train |
edus44/express-deliver | lib/response/success.js | normalizeResult | function normalizeResult(result){
if (!result || result._isResponseData !== true)
return ResponseData(result,{default:true})
return result
} | javascript | function normalizeResult(result){
if (!result || result._isResponseData !== true)
return ResponseData(result,{default:true})
return result
} | [
"function",
"normalizeResult",
"(",
"result",
")",
"{",
"if",
"(",
"!",
"result",
"||",
"result",
".",
"_isResponseData",
"!==",
"true",
")",
"return",
"ResponseData",
"(",
"result",
",",
"{",
"default",
":",
"true",
"}",
")",
"return",
"result",
"}"
] | Tries to return a ResponseData object
@param {any} result
@return {ResponseData} | [
"Tries",
"to",
"return",
"a",
"ResponseData",
"object"
] | 895abfaf2e5e48a00b4fef943dccaffcbf244780 | https://github.com/edus44/express-deliver/blob/895abfaf2e5e48a00b4fef943dccaffcbf244780/lib/response/success.js#L25-L29 | train |
edus44/express-deliver | lib/response/success.js | defaultTransformSuccess | function defaultTransformSuccess(value,options){
if (options.default === true){
return {
status:true,
data:value
}
}
if (options.appendStatus !== false){
let obj = typeof value == 'object' ? value : {}
return Object.assign(obj,{status:true})
}... | javascript | function defaultTransformSuccess(value,options){
if (options.default === true){
return {
status:true,
data:value
}
}
if (options.appendStatus !== false){
let obj = typeof value == 'object' ? value : {}
return Object.assign(obj,{status:true})
}... | [
"function",
"defaultTransformSuccess",
"(",
"value",
",",
"options",
")",
"{",
"if",
"(",
"options",
".",
"default",
"===",
"true",
")",
"{",
"return",
"{",
"status",
":",
"true",
",",
"data",
":",
"value",
"}",
"}",
"if",
"(",
"options",
".",
"appendS... | Transform the responseData
@param {any} value
@param {Object} options
@param {Request} req
@returns {Object} | [
"Transform",
"the",
"responseData"
] | 895abfaf2e5e48a00b4fef943dccaffcbf244780 | https://github.com/edus44/express-deliver/blob/895abfaf2e5e48a00b4fef943dccaffcbf244780/lib/response/success.js#L40-L54 | train |
fibo/strict-mode | index.js | strictMode | function strictMode (callback) {
'use strict'
// The module api is in *Locked* state, so it will not change
// see http://nodejs.org/api/modules.html
// that is why I just copyed and pasted the orig module wrapper.
//
// By the way, in test.js there is a test that checks if the content of
// *origWrapper... | javascript | function strictMode (callback) {
'use strict'
// The module api is in *Locked* state, so it will not change
// see http://nodejs.org/api/modules.html
// that is why I just copyed and pasted the orig module wrapper.
//
// By the way, in test.js there is a test that checks if the content of
// *origWrapper... | [
"function",
"strictMode",
"(",
"callback",
")",
"{",
"'use strict'",
"// The module api is in *Locked* state, so it will not change",
"// see http://nodejs.org/api/modules.html",
"// that is why I just copyed and pasted the orig module wrapper.",
"//",
"// By the way, in test.js there is a tes... | Wraps module `exports`
See [Usage](http://g14n.info/strict-mode#usage)
@param {Function} callback containing caller package's exports statements | [
"Wraps",
"module",
"exports"
] | f0039a08bdd7835af64610cafdd2caab554cd700 | https://github.com/fibo/strict-mode/blob/f0039a08bdd7835af64610cafdd2caab554cd700/index.js#L9-L50 | train |
sapegin/textlint-rule-diacritics | index.js | getWords | function getWords(words) {
const defaults = loadJson('./words.json');
const extras = typeof words === 'string' ? loadJson(words) : words;
return defaults.concat(extras);
} | javascript | function getWords(words) {
const defaults = loadJson('./words.json');
const extras = typeof words === 'string' ? loadJson(words) : words;
return defaults.concat(extras);
} | [
"function",
"getWords",
"(",
"words",
")",
"{",
"const",
"defaults",
"=",
"loadJson",
"(",
"'./words.json'",
")",
";",
"const",
"extras",
"=",
"typeof",
"words",
"===",
"'string'",
"?",
"loadJson",
"(",
"words",
")",
":",
"words",
";",
"return",
"defaults"... | Load all default words joined with additional worsd from a config file
@param {string|string[]} words
@return {string[]} | [
"Load",
"all",
"default",
"words",
"joined",
"with",
"additional",
"worsd",
"from",
"a",
"config",
"file"
] | 5dcb40c9ec128bc147325783ed4859fa66baaecf | https://github.com/sapegin/textlint-rule-diacritics/blob/5dcb40c9ec128bc147325783ed4859fa66baaecf/index.js#L54-L58 | train |
sapegin/textlint-rule-diacritics | index.js | loadJson | function loadJson(filepath) {
const json = fs.readFileSync(require.resolve(filepath), 'utf8');
return JSON.parse(stripJsonComments(json));
} | javascript | function loadJson(filepath) {
const json = fs.readFileSync(require.resolve(filepath), 'utf8');
return JSON.parse(stripJsonComments(json));
} | [
"function",
"loadJson",
"(",
"filepath",
")",
"{",
"const",
"json",
"=",
"fs",
".",
"readFileSync",
"(",
"require",
".",
"resolve",
"(",
"filepath",
")",
",",
"'utf8'",
")",
";",
"return",
"JSON",
".",
"parse",
"(",
"stripJsonComments",
"(",
"json",
")",... | Load JSON file, strip comments.
@param {string} filepath
@return {object} | [
"Load",
"JSON",
"file",
"strip",
"comments",
"."
] | 5dcb40c9ec128bc147325783ed4859fa66baaecf | https://github.com/sapegin/textlint-rule-diacritics/blob/5dcb40c9ec128bc147325783ed4859fa66baaecf/index.js#L66-L69 | train |
sapegin/textlint-rule-diacritics | index.js | getCorrection | function getCorrection(words, match) {
for (const word of words) {
const pattern = getPattern(word);
if (!getRegExp([pattern]).test(match)) {
continue;
}
const corrected = match.replace(new RegExp(`\\b${pattern}`, 'i'), word);
return matchCasing(corrected, match);
}
return false;
} | javascript | function getCorrection(words, match) {
for (const word of words) {
const pattern = getPattern(word);
if (!getRegExp([pattern]).test(match)) {
continue;
}
const corrected = match.replace(new RegExp(`\\b${pattern}`, 'i'), word);
return matchCasing(corrected, match);
}
return false;
} | [
"function",
"getCorrection",
"(",
"words",
",",
"match",
")",
"{",
"for",
"(",
"const",
"word",
"of",
"words",
")",
"{",
"const",
"pattern",
"=",
"getPattern",
"(",
"word",
")",
";",
"if",
"(",
"!",
"getRegExp",
"(",
"[",
"pattern",
"]",
")",
".",
... | Return a correct word based on found incorrect word.
Keeps case and suffix of an original word.
@param {string[]} words
@param {string} match
@return {string|boolean} | [
"Return",
"a",
"correct",
"word",
"based",
"on",
"found",
"incorrect",
"word",
".",
"Keeps",
"case",
"and",
"suffix",
"of",
"an",
"original",
"word",
"."
] | 5dcb40c9ec128bc147325783ed4859fa66baaecf | https://github.com/sapegin/textlint-rule-diacritics/blob/5dcb40c9ec128bc147325783ed4859fa66baaecf/index.js#L127-L139 | train |
brewster/imagine | lib/imagine/server.js | function () {
// Determine https vs. http
this.server = this.ssl ?
https.createServer(this.ssl) :
http.createServer();
// Bind to the request
this.server.on('request', this.handle.bind(this));
} | javascript | function () {
// Determine https vs. http
this.server = this.ssl ?
https.createServer(this.ssl) :
http.createServer();
// Bind to the request
this.server.on('request', this.handle.bind(this));
} | [
"function",
"(",
")",
"{",
"// Determine https vs. http",
"this",
".",
"server",
"=",
"this",
".",
"ssl",
"?",
"https",
".",
"createServer",
"(",
"this",
".",
"ssl",
")",
":",
"http",
".",
"createServer",
"(",
")",
";",
"// Bind to the request",
"this",
".... | Create a new server | [
"Create",
"a",
"new",
"server"
] | 42782ff6365f225f1fb9d90d3a654791286ef023 | https://github.com/brewster/imagine/blob/42782ff6365f225f1fb9d90d3a654791286ef023/lib/imagine/server.js#L43-L51 | train | |
partageit/vegetables | lib/generate.js | function(folder, dest) {
try {
fs.mkdirSync(dest, '0755');
} catch (e) {}
var files = fs.readdirSync(folder);
var indexFile = templatesManager.getFolderIndex(files);
logger.debug('Index file for "%s": "%s"', folder, indexFile);
files.forEach(function(file) {
if (config.exclude.indexOf(file) === -1) {
... | javascript | function(folder, dest) {
try {
fs.mkdirSync(dest, '0755');
} catch (e) {}
var files = fs.readdirSync(folder);
var indexFile = templatesManager.getFolderIndex(files);
logger.debug('Index file for "%s": "%s"', folder, indexFile);
files.forEach(function(file) {
if (config.exclude.indexOf(file) === -1) {
... | [
"function",
"(",
"folder",
",",
"dest",
")",
"{",
"try",
"{",
"fs",
".",
"mkdirSync",
"(",
"dest",
",",
"'0755'",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"}",
"var",
"files",
"=",
"fs",
".",
"readdirSync",
"(",
"folder",
")",
";",
"var",
"i... | filename => filename, path, versions Function to discover Markdown files and copy media files | [
"filename",
"=",
">",
"filename",
"path",
"versions",
"Function",
"to",
"discover",
"Markdown",
"files",
"and",
"copy",
"media",
"files"
] | 1aca3ee726885427974e3f0f88e6c2f5fe884e74 | https://github.com/partageit/vegetables/blob/1aca3ee726885427974e3f0f88e6c2f5fe884e74/lib/generate.js#L28-L62 | train | |
partageit/vegetables | lib/generate.js | function(commands) {
if (!commands || (commands.length === 0)) {
return true;
}
if (typeof commands === 'string') {
commands = [commands];
}
return commands.every(function(command) {
logger.info('Starting command "%s"...', command);
var result = exec(
command,
{cwd: path.resolve('.')}
)... | javascript | function(commands) {
if (!commands || (commands.length === 0)) {
return true;
}
if (typeof commands === 'string') {
commands = [commands];
}
return commands.every(function(command) {
logger.info('Starting command "%s"...', command);
var result = exec(
command,
{cwd: path.resolve('.')}
)... | [
"function",
"(",
"commands",
")",
"{",
"if",
"(",
"!",
"commands",
"||",
"(",
"commands",
".",
"length",
"===",
"0",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"typeof",
"commands",
"===",
"'string'",
")",
"{",
"commands",
"=",
"[",
"com... | Function to start before and after commands | [
"Function",
"to",
"start",
"before",
"and",
"after",
"commands"
] | 1aca3ee726885427974e3f0f88e6c2f5fe884e74 | https://github.com/partageit/vegetables/blob/1aca3ee726885427974e3f0f88e6c2f5fe884e74/lib/generate.js#L65-L86 | train | |
edloidas/roll-parser | src/roller.js | rollClassic | function rollClassic( roll ) {
const data = roll instanceof Roll ? roll : convertToRoll( roll );
const { dice, count, modifier } = data;
const rolls = [ ...new Array( count ) ].map(() => randomRoll( dice ));
const summ = rolls.reduce(( prev, curr ) => prev + curr, 0 );
const result = normalizeRollResult( sum... | javascript | function rollClassic( roll ) {
const data = roll instanceof Roll ? roll : convertToRoll( roll );
const { dice, count, modifier } = data;
const rolls = [ ...new Array( count ) ].map(() => randomRoll( dice ));
const summ = rolls.reduce(( prev, curr ) => prev + curr, 0 );
const result = normalizeRollResult( sum... | [
"function",
"rollClassic",
"(",
"roll",
")",
"{",
"const",
"data",
"=",
"roll",
"instanceof",
"Roll",
"?",
"roll",
":",
"convertToRoll",
"(",
"roll",
")",
";",
"const",
"{",
"dice",
",",
"count",
",",
"modifier",
"}",
"=",
"data",
";",
"const",
"rolls"... | Rolls the dice from `Roll` object.
@func
@since v2.0.0
@param {Roll} roll - `Roll` object or similar
@return {Result}
@see roll
@see rollWod
@example
rollClassic(new Roll(10, 2, -1)); //=> { notation: '2d10-1', value: 14, rolls: [ 7, 8 ] }
rollClassic({ dice: 6 }); //=> { notation: 'd6', value: 4, rolls: [ 4 ] } | [
"Rolls",
"the",
"dice",
"from",
"Roll",
"object",
"."
] | 38912b298edb0a4d67ba1c796d7ac159ebaf7901 | https://github.com/edloidas/roll-parser/blob/38912b298edb0a4d67ba1c796d7ac159ebaf7901/src/roller.js#L22-L31 | train |
edloidas/roll-parser | src/roller.js | rollWod | function rollWod( roll ) {
const data = roll instanceof WodRoll ? roll : convertToWodRoll( roll );
const { dice, count, again, success, fail } = data;
const rolls = [];
let i = count;
while ( i > 0 ) {
const value = randomRoll( dice );
rolls.push( value );
// Check for "10 Again" flag
// `re... | javascript | function rollWod( roll ) {
const data = roll instanceof WodRoll ? roll : convertToWodRoll( roll );
const { dice, count, again, success, fail } = data;
const rolls = [];
let i = count;
while ( i > 0 ) {
const value = randomRoll( dice );
rolls.push( value );
// Check for "10 Again" flag
// `re... | [
"function",
"rollWod",
"(",
"roll",
")",
"{",
"const",
"data",
"=",
"roll",
"instanceof",
"WodRoll",
"?",
"roll",
":",
"convertToWodRoll",
"(",
"roll",
")",
";",
"const",
"{",
"dice",
",",
"count",
",",
"again",
",",
"success",
",",
"fail",
"}",
"=",
... | Rolls the dice from `WodRoll` object.
@func
@since v2.0.0
@param {WodRoll} roll - `WodRoll` object or similar
@return {Result}
@see roll
@see rollClassic
@example
rollWod(new WodRoll(10, 4, true, 8)); //=> { notation: '4d10!>8', value: 2, rolls: [3,10,7,9,5] }
rollWod({ dice: 8, count: 3 }); //=> { notation: '3d8>6', ... | [
"Rolls",
"the",
"dice",
"from",
"WodRoll",
"object",
"."
] | 38912b298edb0a4d67ba1c796d7ac159ebaf7901 | https://github.com/edloidas/roll-parser/blob/38912b298edb0a4d67ba1c796d7ac159ebaf7901/src/roller.js#L46-L74 | train |
edloidas/roll-parser | src/roller.js | rollAny | function rollAny( roll ) {
if ( roll instanceof Roll ) {
return rollClassic( roll );
} else if ( roll instanceof WodRoll ) {
return rollWod( roll );
}
return isDefined( roll ) ? rollAny( convertToAnyRoll( roll )) : null;
} | javascript | function rollAny( roll ) {
if ( roll instanceof Roll ) {
return rollClassic( roll );
} else if ( roll instanceof WodRoll ) {
return rollWod( roll );
}
return isDefined( roll ) ? rollAny( convertToAnyRoll( roll )) : null;
} | [
"function",
"rollAny",
"(",
"roll",
")",
"{",
"if",
"(",
"roll",
"instanceof",
"Roll",
")",
"{",
"return",
"rollClassic",
"(",
"roll",
")",
";",
"}",
"else",
"if",
"(",
"roll",
"instanceof",
"WodRoll",
")",
"{",
"return",
"rollWod",
"(",
"roll",
")",
... | Rolls the dice from `Roll` or `WodRoll` objects.
@func
@alias roll
@since v2.0.0
@param {Roll|WodRoll|Object} roll - `Roll`, `WodRoll` or similar object.
@return {Result} Returns `Result` for defined parameters, otherwise returns `null`.
@see rollClassic
@see rollWod
@example
roll(new Roll(10, 2, -1)); //=> { notation... | [
"Rolls",
"the",
"dice",
"from",
"Roll",
"or",
"WodRoll",
"objects",
"."
] | 38912b298edb0a4d67ba1c796d7ac159ebaf7901 | https://github.com/edloidas/roll-parser/blob/38912b298edb0a4d67ba1c796d7ac159ebaf7901/src/roller.js#L93-L100 | train |
luoyjx/koa-rest-mongoose | lib/index.js | KoaRestMongoose | function KoaRestMongoose(options) {
if (!(this instanceof KoaRestMongoose)) {
return new KoaRestMongoose(options);
}
options = options || {};
debug('options: ', options);
// api url prefix
this.prefix = null;
if (options.prefix !== null && typeof options.prefix !== 'undefined') {
// add `/` if... | javascript | function KoaRestMongoose(options) {
if (!(this instanceof KoaRestMongoose)) {
return new KoaRestMongoose(options);
}
options = options || {};
debug('options: ', options);
// api url prefix
this.prefix = null;
if (options.prefix !== null && typeof options.prefix !== 'undefined') {
// add `/` if... | [
"function",
"KoaRestMongoose",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"KoaRestMongoose",
")",
")",
"{",
"return",
"new",
"KoaRestMongoose",
"(",
"options",
")",
";",
"}",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"debu... | Create a KoaRestMongoose instance.
@param {Object} options | [
"Create",
"a",
"KoaRestMongoose",
"instance",
"."
] | 322e4b6623ff0f708df383c7dd76bee76e90be81 | https://github.com/luoyjx/koa-rest-mongoose/blob/322e4b6623ff0f708df383c7dd76bee76e90be81/lib/index.js#L21-L64 | train |
fex-team/yog-bigpipe | scripts/bigpipe.js | function () {
var i, len;
// eval scripts.
if (data.scripts && data.scripts.length) {
for (i = 0, len = data.scripts.length; i < len; i++) {
Util.globalEval(data.scripts[i]);
}
... | javascript | function () {
var i, len;
// eval scripts.
if (data.scripts && data.scripts.length) {
for (i = 0, len = data.scripts.length; i < len; i++) {
Util.globalEval(data.scripts[i]);
}
... | [
"function",
"(",
")",
"{",
"var",
"i",
",",
"len",
";",
"// eval scripts.",
"if",
"(",
"data",
".",
"scripts",
"&&",
"data",
".",
"scripts",
".",
"length",
")",
"{",
"for",
"(",
"i",
"=",
"0",
",",
"len",
"=",
"data",
".",
"scripts",
".",
"length... | exec data.scripts | [
"exec",
"data",
".",
"scripts"
] | 5c9c761d1940f1ea5b4d46b9f1ed3da8a20db21d | https://github.com/fex-team/yog-bigpipe/blob/5c9c761d1940f1ea5b4d46b9f1ed3da8a20db21d/scripts/bigpipe.js#L419-L430 | train | |
fex-team/yog-bigpipe | scripts/bigpipe.js | function (obj) {
if (!resourceChecked) {
Util.saveLoadedRes();
resourceChecked = true;
}
currReqID = obj.reqID;
// console.log('arrive', obj.id);
this.trigger('pageletarrive', obj);
va... | javascript | function (obj) {
if (!resourceChecked) {
Util.saveLoadedRes();
resourceChecked = true;
}
currReqID = obj.reqID;
// console.log('arrive', obj.id);
this.trigger('pageletarrive', obj);
va... | [
"function",
"(",
"obj",
")",
"{",
"if",
"(",
"!",
"resourceChecked",
")",
"{",
"Util",
".",
"saveLoadedRes",
"(",
")",
";",
"resourceChecked",
"=",
"true",
";",
"}",
"currReqID",
"=",
"obj",
".",
"reqID",
";",
"// console.log('arrive', obj.id);",
"this",
"... | This is method will be executed automaticlly. - after chunk output pagelet. - after async load quickling pagelet. | [
"This",
"is",
"method",
"will",
"be",
"executed",
"automaticlly",
".",
"-",
"after",
"chunk",
"output",
"pagelet",
".",
"-",
"after",
"async",
"load",
"quickling",
"pagelet",
"."
] | 5c9c761d1940f1ea5b4d46b9f1ed3da8a20db21d | https://github.com/fex-team/yog-bigpipe/blob/5c9c761d1940f1ea5b4d46b9f1ed3da8a20db21d/scripts/bigpipe.js#L465-L493 | train | |
willmark/file-compare | index.js | checkCommonArgs | function checkCommonArgs(args) {
if (args.length < 2) throw new Error("File1, File2, and callback required");
if (typeof args.at(1) != "string") throw new Error("File2 required");
if (typeof args.at(0) != "string") throw new Error("File1 required");
if (!args.callbackGiven()) throw new E... | javascript | function checkCommonArgs(args) {
if (args.length < 2) throw new Error("File1, File2, and callback required");
if (typeof args.at(1) != "string") throw new Error("File2 required");
if (typeof args.at(0) != "string") throw new Error("File1 required");
if (!args.callbackGiven()) throw new E... | [
"function",
"checkCommonArgs",
"(",
"args",
")",
"{",
"if",
"(",
"args",
".",
"length",
"<",
"2",
")",
"throw",
"new",
"Error",
"(",
"\"File1, File2, and callback required\"",
")",
";",
"if",
"(",
"typeof",
"args",
".",
"at",
"(",
"1",
")",
"!=",
"\"stri... | Common argument checking for crop and resize | [
"Common",
"argument",
"checking",
"for",
"crop",
"and",
"resize"
] | 1878fef8d54c527a5106e1995c4557251d9bd550 | https://github.com/willmark/file-compare/blob/1878fef8d54c527a5106e1995c4557251d9bd550/index.js#L19-L24 | train |
willmark/file-compare | index.js | computeHash | function computeHash(filename, algo, callback) {
var crypto = require('crypto');
var fs = require('fs');
var chksum = crypto.createHash(algo);
var s = fs.ReadStream(filename);
s.on('error', function (err) {
//no file, hash will be zero
callback(0, err);
});
s.on('data', fun... | javascript | function computeHash(filename, algo, callback) {
var crypto = require('crypto');
var fs = require('fs');
var chksum = crypto.createHash(algo);
var s = fs.ReadStream(filename);
s.on('error', function (err) {
//no file, hash will be zero
callback(0, err);
});
s.on('data', fun... | [
"function",
"computeHash",
"(",
"filename",
",",
"algo",
",",
"callback",
")",
"{",
"var",
"crypto",
"=",
"require",
"(",
"'crypto'",
")",
";",
"var",
"fs",
"=",
"require",
"(",
"'fs'",
")",
";",
"var",
"chksum",
"=",
"crypto",
".",
"createHash",
"(",
... | Create a new hash of given file name | [
"Create",
"a",
"new",
"hash",
"of",
"given",
"file",
"name"
] | 1878fef8d54c527a5106e1995c4557251d9bd550 | https://github.com/willmark/file-compare/blob/1878fef8d54c527a5106e1995c4557251d9bd550/index.js#L54-L74 | train |
edloidas/roll-parser | src/object/WodRoll.js | WodRoll | function WodRoll( dice = 10, count = 1, again = false, success = 6, fail ) {
this.dice = positiveInteger( dice );
this.count = positiveInteger( count );
this.again = !!again;
[ this.fail, this.success ] = normalizeWodBorders( fail, success, this.dice );
} | javascript | function WodRoll( dice = 10, count = 1, again = false, success = 6, fail ) {
this.dice = positiveInteger( dice );
this.count = positiveInteger( count );
this.again = !!again;
[ this.fail, this.success ] = normalizeWodBorders( fail, success, this.dice );
} | [
"function",
"WodRoll",
"(",
"dice",
"=",
"10",
",",
"count",
"=",
"1",
",",
"again",
"=",
"false",
",",
"success",
"=",
"6",
",",
"fail",
")",
"{",
"this",
".",
"dice",
"=",
"positiveInteger",
"(",
"dice",
")",
";",
"this",
".",
"count",
"=",
"po... | A class that represents a dice roll from World of Darkness setting
@class
@classdesc A class that represents a dice roll from World of Darkness setting
@since v2.0.0
@param {Number} dice - A number of dice faces
@param {Number} count - A number of dices
@param {Boolean} again - A flag for "10 Again" rolls policy
@param... | [
"A",
"class",
"that",
"represents",
"a",
"dice",
"roll",
"from",
"World",
"of",
"Darkness",
"setting"
] | 38912b298edb0a4d67ba1c796d7ac159ebaf7901 | https://github.com/edloidas/roll-parser/blob/38912b298edb0a4d67ba1c796d7ac159ebaf7901/src/object/WodRoll.js#L18-L23 | train |
bestander/pong-box2d | physics/box2dPhysics.js | Physics | function Physics(width, height, ballRadius) {
this._height = height;
this._width = width;
this._ballRadius = ballRadius || 0.2;
this._world = null;
this._ballScored = function () {
};
this._paddleFixtures = {};
this._init();
} | javascript | function Physics(width, height, ballRadius) {
this._height = height;
this._width = width;
this._ballRadius = ballRadius || 0.2;
this._world = null;
this._ballScored = function () {
};
this._paddleFixtures = {};
this._init();
} | [
"function",
"Physics",
"(",
"width",
",",
"height",
",",
"ballRadius",
")",
"{",
"this",
".",
"_height",
"=",
"height",
";",
"this",
".",
"_width",
"=",
"width",
";",
"this",
".",
"_ballRadius",
"=",
"ballRadius",
"||",
"0.2",
";",
"this",
".",
"_world... | Initialize physics environment
@param width field width
@param height field height
@param ballRadius ball game radius
@constructor | [
"Initialize",
"physics",
"environment"
] | 18e6d14a38d4bb552a22a19b0c00b05e02d2cc5b | https://github.com/bestander/pong-box2d/blob/18e6d14a38d4bb552a22a19b0c00b05e02d2cc5b/physics/box2dPhysics.js#L37-L46 | train |
amobiz/json-normalizer | lib/deref.js | deref | function deref(theSchema, optionalOptions, callbackFn) {
var root, loaders, error, options, callback;
options = optionalOptions || {};
if (typeof options === 'function') {
callback = options;
} else {
callback = callbackFn;
}
root = _.cloneDeep(theSchema);
loaders = _loaders(require('./loader/local'), opt... | javascript | function deref(theSchema, optionalOptions, callbackFn) {
var root, loaders, error, options, callback;
options = optionalOptions || {};
if (typeof options === 'function') {
callback = options;
} else {
callback = callbackFn;
}
root = _.cloneDeep(theSchema);
loaders = _loaders(require('./loader/local'), opt... | [
"function",
"deref",
"(",
"theSchema",
",",
"optionalOptions",
",",
"callbackFn",
")",
"{",
"var",
"root",
",",
"loaders",
",",
"error",
",",
"options",
",",
"callback",
";",
"options",
"=",
"optionalOptions",
"||",
"{",
"}",
";",
"if",
"(",
"typeof",
"o... | Dereference a schema that using JSON references.
Default implementation supports only local references,
i.e. references that starts with “#“.
Custom loaders can be provided via the options object.
@context don't care.
@param theSchema: string
@param optionalOptions.loader | optionalOptions.loaders: function | [functi... | [
"Dereference",
"a",
"schema",
"that",
"using",
"JSON",
"references",
"."
] | 76a8ab1db2da4600dbd28c5c6c7fd11e43c0dd55 | https://github.com/amobiz/json-normalizer/blob/76a8ab1db2da4600dbd28c5c6c7fd11e43c0dd55/lib/deref.js#L26-L83 | train |
mrfishie/detect-log | index.js | logAll | function logAll(files, cb) {
_walkAll(files, function(err, node) {
if (err) {
exports.log(err.name + ': ' + err.message + ' in ' + err.file + ':' + err.line + ':' + err.column);
if (cb) cb(err);
}
exports.log('Found console.' + node.type + ' at ' + node.file + ':' + ... | javascript | function logAll(files, cb) {
_walkAll(files, function(err, node) {
if (err) {
exports.log(err.name + ': ' + err.message + ' in ' + err.file + ':' + err.line + ':' + err.column);
if (cb) cb(err);
}
exports.log('Found console.' + node.type + ' at ' + node.file + ':' + ... | [
"function",
"logAll",
"(",
"files",
",",
"cb",
")",
"{",
"_walkAll",
"(",
"files",
",",
"function",
"(",
"err",
",",
"node",
")",
"{",
"if",
"(",
"err",
")",
"{",
"exports",
".",
"log",
"(",
"err",
".",
"name",
"+",
"': '",
"+",
"err",
".",
"me... | Logs all found instances of console.log and calls the callback specifying if there were any instances, or an error
if one occurred
@param {String} files A file glob
@param {Function?} cb Called with arguments <Error, Array>. If there was an error it will not be called again,
otherwise it will be called at the end with... | [
"Logs",
"all",
"found",
"instances",
"of",
"console",
".",
"log",
"and",
"calls",
"the",
"callback",
"specifying",
"if",
"there",
"were",
"any",
"instances",
"or",
"an",
"error",
"if",
"one",
"occurred"
] | 7a42e0a727fd57edf908423bf17e74c639788b9d | https://github.com/mrfishie/detect-log/blob/7a42e0a727fd57edf908423bf17e74c639788b9d/index.js#L38-L50 | train |
mrfishie/detect-log | index.js | getAll | function getAll(files, cb) {
walkAll(files)
.then(function(allNodes) {
if (cb) cb(null, allNodes);
})
.catch(function(err) {
if (cb) cb(err, []);
});
} | javascript | function getAll(files, cb) {
walkAll(files)
.then(function(allNodes) {
if (cb) cb(null, allNodes);
})
.catch(function(err) {
if (cb) cb(err, []);
});
} | [
"function",
"getAll",
"(",
"files",
",",
"cb",
")",
"{",
"walkAll",
"(",
"files",
")",
".",
"then",
"(",
"function",
"(",
"allNodes",
")",
"{",
"if",
"(",
"cb",
")",
"cb",
"(",
"null",
",",
"allNodes",
")",
";",
"}",
")",
".",
"catch",
"(",
"fu... | Gets a list of all found console.logs
@param {String} files A file glob
@param {Function?} cb Called with arguments <Error, Array>. If an error occurred the error will be passed with an
empty array, otherwise error will be null and an array will be passed. | [
"Gets",
"a",
"list",
"of",
"all",
"found",
"console",
".",
"logs"
] | 7a42e0a727fd57edf908423bf17e74c639788b9d | https://github.com/mrfishie/detect-log/blob/7a42e0a727fd57edf908423bf17e74c639788b9d/index.js#L61-L69 | train |
quorrajs/Positron | lib/foundation/Application.js | App | function App() {
require('colors');
/**
* All of the developer defined middlewares.
*
* @var {Array}
* @protected
*/
this.__middlewares = [];
/**
* The filter instance
* @var {Object}
*/
this.filter;
/**
* The list of loaded service providers.
... | javascript | function App() {
require('colors');
/**
* All of the developer defined middlewares.
*
* @var {Array}
* @protected
*/
this.__middlewares = [];
/**
* The filter instance
* @var {Object}
*/
this.filter;
/**
* The list of loaded service providers.
... | [
"function",
"App",
"(",
")",
"{",
"require",
"(",
"'colors'",
")",
";",
"/**\n * All of the developer defined middlewares.\n *\n * @var {Array}\n * @protected\n */",
"this",
".",
"__middlewares",
"=",
"[",
"]",
";",
"/**\n * The filter instance\n * @va... | Create a Quorra application.
@extend Container
@return {Function}
@api public | [
"Create",
"a",
"Quorra",
"application",
"."
] | a4bad5a5f581743d1885405c11ae26600fb957af | https://github.com/quorrajs/Positron/blob/a4bad5a5f581743d1885405c11ae26600fb957af/lib/foundation/Application.js#L47-L138 | train |
gribnoysup/nfield-api | api.js | checkRequiredParameter | function checkRequiredParameter (param) {
return (
typeof param === 'function' || typeof param === 'undefined' || param === '' || param === null || (typeof param === 'number' && isNaN(param))
);
} | javascript | function checkRequiredParameter (param) {
return (
typeof param === 'function' || typeof param === 'undefined' || param === '' || param === null || (typeof param === 'number' && isNaN(param))
);
} | [
"function",
"checkRequiredParameter",
"(",
"param",
")",
"{",
"return",
"(",
"typeof",
"param",
"===",
"'function'",
"||",
"typeof",
"param",
"===",
"'undefined'",
"||",
"param",
"===",
"''",
"||",
"param",
"===",
"null",
"||",
"(",
"typeof",
"param",
"===",... | Check if specific required request parameter is valid | [
"Check",
"if",
"specific",
"required",
"request",
"parameter",
"is",
"valid"
] | fcd635255fad2fc483d0e9045ecf7faba04378d9 | https://github.com/gribnoysup/nfield-api/blob/fcd635255fad2fc483d0e9045ecf7faba04378d9/api.js#L26-L30 | train |
gribnoysup/nfield-api | api.js | checkIfOnlyOneRequired | function checkIfOnlyOneRequired (defaultParams) {
var keys = Object.keys(defaultParams);
var i, key;
var onlyOne = '';
for (i = 0; i < keys.length; i++){
key = keys[i];
if (defaultParams[key] === '') {
if (onlyOne !== '') return false;
onlyOne = key;
}
}
return onlyOne;
} | javascript | function checkIfOnlyOneRequired (defaultParams) {
var keys = Object.keys(defaultParams);
var i, key;
var onlyOne = '';
for (i = 0; i < keys.length; i++){
key = keys[i];
if (defaultParams[key] === '') {
if (onlyOne !== '') return false;
onlyOne = key;
}
}
return onlyOne;
} | [
"function",
"checkIfOnlyOneRequired",
"(",
"defaultParams",
")",
"{",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"defaultParams",
")",
";",
"var",
"i",
",",
"key",
";",
"var",
"onlyOne",
"=",
"''",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
... | Check if default parameters has only one required param
Returns false if there are more than one, or a param name if there is only one | [
"Check",
"if",
"default",
"parameters",
"has",
"only",
"one",
"required",
"param"
] | fcd635255fad2fc483d0e9045ecf7faba04378d9 | https://github.com/gribnoysup/nfield-api/blob/fcd635255fad2fc483d0e9045ecf7faba04378d9/api.js#L37-L51 | train |
gribnoysup/nfield-api | api.js | normalizeRequestParameters | function normalizeRequestParameters (defaultsObject, paramsName, requestParams) {
var promise = new Promise(function (resolve, reject) {
var defaultParams;
var onlyOne;
// First check if we have a default parameters object with this name
if (typeof defaultsObject[paramsName] !== 'object') reject(ne... | javascript | function normalizeRequestParameters (defaultsObject, paramsName, requestParams) {
var promise = new Promise(function (resolve, reject) {
var defaultParams;
var onlyOne;
// First check if we have a default parameters object with this name
if (typeof defaultsObject[paramsName] !== 'object') reject(ne... | [
"function",
"normalizeRequestParameters",
"(",
"defaultsObject",
",",
"paramsName",
",",
"requestParams",
")",
"{",
"var",
"promise",
"=",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"var",
"defaultParams",
";",
"var",
"onlyOne",
... | Return a promise with normalized request parameters or an error | [
"Return",
"a",
"promise",
"with",
"normalized",
"request",
"parameters",
"or",
"an",
"error"
] | fcd635255fad2fc483d0e9045ecf7faba04378d9 | https://github.com/gribnoysup/nfield-api/blob/fcd635255fad2fc483d0e9045ecf7faba04378d9/api.js#L56-L96 | train |
gribnoysup/nfield-api | api.js | signIn | function signIn (defOptions, credentials, callback) {
var promise = normalizeRequestParameters(defaults, 'SignIn', credentials).then(function (credentials) {
var options = {
method : 'POST',
uri : 'v1/SignIn',
json : credentials
};
extend(true, options, defOptions);
return... | javascript | function signIn (defOptions, credentials, callback) {
var promise = normalizeRequestParameters(defaults, 'SignIn', credentials).then(function (credentials) {
var options = {
method : 'POST',
uri : 'v1/SignIn',
json : credentials
};
extend(true, options, defOptions);
return... | [
"function",
"signIn",
"(",
"defOptions",
",",
"credentials",
",",
"callback",
")",
"{",
"var",
"promise",
"=",
"normalizeRequestParameters",
"(",
"defaults",
",",
"'SignIn'",
",",
"credentials",
")",
".",
"then",
"(",
"function",
"(",
"credentials",
")",
"{",
... | Sign in to Nfield API
{@link https://api.nfieldmr.com/help/api/post-v1-signin} | [
"Sign",
"in",
"to",
"Nfield",
"API"
] | fcd635255fad2fc483d0e9045ecf7faba04378d9 | https://github.com/gribnoysup/nfield-api/blob/fcd635255fad2fc483d0e9045ecf7faba04378d9/api.js#L103-L119 | train |
gribnoysup/nfield-api | api.js | requestWithTokenCheck | function requestWithTokenCheck (defOptions, credentials, token, options, callback) {
var returnedPromise;
options.headers = options.headers || {};
extend(true, options, defOptions);
if (Date.now() - token.Timestamp > tokenUpdateTime) {
returnedPromise = signIn(defOptions, credentials).then(function (d... | javascript | function requestWithTokenCheck (defOptions, credentials, token, options, callback) {
var returnedPromise;
options.headers = options.headers || {};
extend(true, options, defOptions);
if (Date.now() - token.Timestamp > tokenUpdateTime) {
returnedPromise = signIn(defOptions, credentials).then(function (d... | [
"function",
"requestWithTokenCheck",
"(",
"defOptions",
",",
"credentials",
",",
"token",
",",
"options",
",",
"callback",
")",
"{",
"var",
"returnedPromise",
";",
"options",
".",
"headers",
"=",
"options",
".",
"headers",
"||",
"{",
"}",
";",
"extend",
"(",... | Wrapper function for all Nfield API requests that checks if API token is not outdated, and refreshes it otherwise | [
"Wrapper",
"function",
"for",
"all",
"Nfield",
"API",
"requests",
"that",
"checks",
"if",
"API",
"token",
"is",
"not",
"outdated",
"and",
"refreshes",
"it",
"otherwise"
] | fcd635255fad2fc483d0e9045ecf7faba04378d9 | https://github.com/gribnoysup/nfield-api/blob/fcd635255fad2fc483d0e9045ecf7faba04378d9/api.js#L124-L148 | train |
gribnoysup/nfield-api | api.js | removeSurveyLanguages | function removeSurveyLanguages (defOptions, credentials, token, requestParams, callback) {
var promise = normalizeRequestParameters(defaults, 'RemoveSurveyLanguages', requestParams).then(function (params) {
var options = {
method : 'DELETE',
uri : `v1/Surveys/${params.SurveyId}/Languages/${p... | javascript | function removeSurveyLanguages (defOptions, credentials, token, requestParams, callback) {
var promise = normalizeRequestParameters(defaults, 'RemoveSurveyLanguages', requestParams).then(function (params) {
var options = {
method : 'DELETE',
uri : `v1/Surveys/${params.SurveyId}/Languages/${p... | [
"function",
"removeSurveyLanguages",
"(",
"defOptions",
",",
"credentials",
",",
"token",
",",
"requestParams",
",",
"callback",
")",
"{",
"var",
"promise",
"=",
"normalizeRequestParameters",
"(",
"defaults",
",",
"'RemoveSurveyLanguages'",
",",
"requestParams",
")",
... | Remove existing language
{@link https://api.nfieldmr.com/help/api/delete-v1-surveys-surveyid-languages-languageid} | [
"Remove",
"existing",
"language"
] | fcd635255fad2fc483d0e9045ecf7faba04378d9 | https://github.com/gribnoysup/nfield-api/blob/fcd635255fad2fc483d0e9045ecf7faba04378d9/api.js#L393-L407 | train |
gribnoysup/nfield-api | api.js | getSurveySettings | function getSurveySettings (defOptions, credentials, token, surveyId, callback) {
if (typeof surveyId === 'function') callback = surveyId;
if (checkRequiredParameter(surveyId)) return Promise.reject(Error(`Missing required parameter 'SurveyId'`)).nodeify(callback);
var options = {
method : 'GET',
ur... | javascript | function getSurveySettings (defOptions, credentials, token, surveyId, callback) {
if (typeof surveyId === 'function') callback = surveyId;
if (checkRequiredParameter(surveyId)) return Promise.reject(Error(`Missing required parameter 'SurveyId'`)).nodeify(callback);
var options = {
method : 'GET',
ur... | [
"function",
"getSurveySettings",
"(",
"defOptions",
",",
"credentials",
",",
"token",
",",
"surveyId",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"surveyId",
"===",
"'function'",
")",
"callback",
"=",
"surveyId",
";",
"if",
"(",
"checkRequiredParameter",
... | Retrieve survey settings
{@link https://api.nfieldmr.com/help/api/get-v1-surveys-surveyid-settings} | [
"Retrieve",
"survey",
"settings"
] | fcd635255fad2fc483d0e9045ecf7faba04378d9 | https://github.com/gribnoysup/nfield-api/blob/fcd635255fad2fc483d0e9045ecf7faba04378d9/api.js#L414-L425 | train |
andreypopp/react-app-middleware | index.js | evaluatePromise | function evaluatePromise() {
var promise = kew.defer();
var args = utils.toArray(arguments);
args.push(promise.makeNodeResolver());
/*jshint validthis:true */
evaluate.apply(this, args);
return promise;
} | javascript | function evaluatePromise() {
var promise = kew.defer();
var args = utils.toArray(arguments);
args.push(promise.makeNodeResolver());
/*jshint validthis:true */
evaluate.apply(this, args);
return promise;
} | [
"function",
"evaluatePromise",
"(",
")",
"{",
"var",
"promise",
"=",
"kew",
".",
"defer",
"(",
")",
";",
"var",
"args",
"=",
"utils",
".",
"toArray",
"(",
"arguments",
")",
";",
"args",
".",
"push",
"(",
"promise",
".",
"makeNodeResolver",
"(",
")",
... | Like evaluate from react-app-server-runtime but exposes Promise API | [
"Like",
"evaluate",
"from",
"react",
"-",
"app",
"-",
"server",
"-",
"runtime",
"but",
"exposes",
"Promise",
"API"
] | 20288fde7916894b84f01ef5640b3dadd98a0bfb | https://github.com/andreypopp/react-app-middleware/blob/20288fde7916894b84f01ef5640b3dadd98a0bfb/index.js#L46-L53 | train |
andreypopp/react-app-middleware | index.js | makeLocation | function makeLocation(req, origin) {
var protocol = !!req.connection.verifyPeer ? 'https://' : 'http://',
reqOrigin = origin || (protocol + req.headers.host);
return url.parse(reqOrigin + req.originalUrl);
} | javascript | function makeLocation(req, origin) {
var protocol = !!req.connection.verifyPeer ? 'https://' : 'http://',
reqOrigin = origin || (protocol + req.headers.host);
return url.parse(reqOrigin + req.originalUrl);
} | [
"function",
"makeLocation",
"(",
"req",
",",
"origin",
")",
"{",
"var",
"protocol",
"=",
"!",
"!",
"req",
".",
"connection",
".",
"verifyPeer",
"?",
"'https://'",
":",
"'http://'",
",",
"reqOrigin",
"=",
"origin",
"||",
"(",
"protocol",
"+",
"req",
".",
... | Create window.location-like object from express request
@param {ExpressRequest} req
@param {String} origin | [
"Create",
"window",
".",
"location",
"-",
"like",
"object",
"from",
"express",
"request"
] | 20288fde7916894b84f01ef5640b3dadd98a0bfb | https://github.com/andreypopp/react-app-middleware/blob/20288fde7916894b84f01ef5640b3dadd98a0bfb/index.js#L61-L65 | train |
andreypopp/react-app-middleware | index.js | servePage | function servePage(bundle, opts) {
opts = opts || {};
if (typeof bundle !== 'function') {
bundle = bundler.create(bundle, opts);
}
return function(req, res, next) {
var location = makeLocation(req, opts.origin);
var clientReq = request.createRequestFromLocation(location);
bundle()
.then(... | javascript | function servePage(bundle, opts) {
opts = opts || {};
if (typeof bundle !== 'function') {
bundle = bundler.create(bundle, opts);
}
return function(req, res, next) {
var location = makeLocation(req, opts.origin);
var clientReq = request.createRequestFromLocation(location);
bundle()
.then(... | [
"function",
"servePage",
"(",
"bundle",
",",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"if",
"(",
"typeof",
"bundle",
"!==",
"'function'",
")",
"{",
"bundle",
"=",
"bundler",
".",
"create",
"(",
"bundle",
",",
"opts",
")",
";",
"}... | Middleware for serving pre-rendered React UI
@param {Bundler|Browserify|ModuleId} bundle
@param {Options} opts | [
"Middleware",
"for",
"serving",
"pre",
"-",
"rendered",
"React",
"UI"
] | 20288fde7916894b84f01ef5640b3dadd98a0bfb | https://github.com/andreypopp/react-app-middleware/blob/20288fde7916894b84f01ef5640b3dadd98a0bfb/index.js#L73-L106 | train |
75lb/argv-tools | index.js | expandCombinedShortArg | function expandCombinedShortArg (arg) {
/* remove initial hypen */
arg = arg.slice(1)
return arg.split('').map(letter => '-' + letter)
} | javascript | function expandCombinedShortArg (arg) {
/* remove initial hypen */
arg = arg.slice(1)
return arg.split('').map(letter => '-' + letter)
} | [
"function",
"expandCombinedShortArg",
"(",
"arg",
")",
"{",
"/* remove initial hypen */",
"arg",
"=",
"arg",
".",
"slice",
"(",
"1",
")",
"return",
"arg",
".",
"split",
"(",
"''",
")",
".",
"map",
"(",
"letter",
"=>",
"'-'",
"+",
"letter",
")",
"}"
] | Expand a combined short option.
@param {string} - the string to expand, e.g. `-ab`
@returns {string[]}
@static | [
"Expand",
"a",
"combined",
"short",
"option",
"."
] | 624e9249623003a1cadb4cbecd2c428366039e80 | https://github.com/75lb/argv-tools/blob/624e9249623003a1cadb4cbecd2c428366039e80/index.js#L102-L106 | train |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/panel/plugin.js | function( index )
{
if ( index == -1 )
return;
var links = this.element.getElementsByTag( 'a' );
var item = links.getItem( this._.focusIndex = index );
// Safari need focus on the iframe window first(#3389), but we need
// lock the blur to avoid hiding the panel.
if ( CKEDITOR.env.webk... | javascript | function( index )
{
if ( index == -1 )
return;
var links = this.element.getElementsByTag( 'a' );
var item = links.getItem( this._.focusIndex = index );
// Safari need focus on the iframe window first(#3389), but we need
// lock the blur to avoid hiding the panel.
if ( CKEDITOR.env.webk... | [
"function",
"(",
"index",
")",
"{",
"if",
"(",
"index",
"==",
"-",
"1",
")",
"return",
";",
"var",
"links",
"=",
"this",
".",
"element",
".",
"getElementsByTag",
"(",
"'a'",
")",
";",
"var",
"item",
"=",
"links",
".",
"getItem",
"(",
"this",
".",
... | Mark the item specified by the index as current activated. | [
"Mark",
"the",
"item",
"specified",
"by",
"the",
"index",
"as",
"current",
"activated",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/panel/plugin.js#L305-L319 | train | |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | subscribe | function subscribe (state, topic, subscription, options, context) {
assert(typeof topic, 'string', 'Arbiter.subscribe', 'strings', 'topics');
options = merge(state.options, options);
var
ancestor = addTopicLine(
topic, ancestorTopicSearch(topic, state._topics)
),
node = insert(
... | javascript | function subscribe (state, topic, subscription, options, context) {
assert(typeof topic, 'string', 'Arbiter.subscribe', 'strings', 'topics');
options = merge(state.options, options);
var
ancestor = addTopicLine(
topic, ancestorTopicSearch(topic, state._topics)
),
node = insert(
... | [
"function",
"subscribe",
"(",
"state",
",",
"topic",
",",
"subscription",
",",
"options",
",",
"context",
")",
"{",
"assert",
"(",
"typeof",
"topic",
",",
"'string'",
",",
"'Arbiter.subscribe'",
",",
"'strings'",
",",
"'topics'",
")",
";",
"options",
"=",
... | `Arbiter.subscribe` registers a subscription to a topic and its
descendants. When a publication occurs it will be notified. The behavior
can be modified by using the options parameter. `options.priority`
establishes the order to notify subscribers when multiple subscribers
exist. The other option is `ignorePersisted`. ... | [
"Arbiter",
".",
"subscribe",
"registers",
"a",
"subscription",
"to",
"a",
"topic",
"and",
"its",
"descendants",
".",
"When",
"a",
"publication",
"occurs",
"it",
"will",
"be",
"notified",
".",
"The",
"behavior",
"can",
"be",
"modified",
"by",
"using",
"the",
... | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L127-L164 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | publish | function publish (state, topic, data, options) {
assert(typeof topic, 'string', 'Arbiter.publish', 'strings', 'topics');
options = merge(state.options, options);
var args = [state, topic, data, options];
if (options.sync) {
return hierarchicalTopicDispatcher(state, topic, data, options);
}
... | javascript | function publish (state, topic, data, options) {
assert(typeof topic, 'string', 'Arbiter.publish', 'strings', 'topics');
options = merge(state.options, options);
var args = [state, topic, data, options];
if (options.sync) {
return hierarchicalTopicDispatcher(state, topic, data, options);
}
... | [
"function",
"publish",
"(",
"state",
",",
"topic",
",",
"data",
",",
"options",
")",
"{",
"assert",
"(",
"typeof",
"topic",
",",
"'string'",
",",
"'Arbiter.publish'",
",",
"'strings'",
",",
"'topics'",
")",
";",
"options",
"=",
"merge",
"(",
"state",
"."... | `Arbiter.publish` notifies all subscribers of a publication by invoking
their subscription function with the data and topic associated with the
publication.
@function publish
@memberof Arbiter
@param {Topic} topic All subscribers to this topic, will be notified of
the publication
@param {Object} [data] This data is t... | [
"Arbiter",
".",
"publish",
"notifies",
"all",
"subscribers",
"of",
"a",
"publication",
"by",
"invoking",
"their",
"subscription",
"function",
"with",
"the",
"data",
"and",
"topic",
"associated",
"with",
"the",
"publication",
"."
] | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L224-L234 | 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.