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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
Frederikbh/tickspotv2-api | lib/service.js | parseArguments | function parseArguments(options, callback) {
if (_.isUndefined(options) && _.isUndefined(callback)) { // No params
return [{}, undefined];
}
if (!_.isUndefined(options) && _.isFunction(options)) { // Only callback param
callback = options;
options = {};
}
return [options, cal... | javascript | function parseArguments(options, callback) {
if (_.isUndefined(options) && _.isUndefined(callback)) { // No params
return [{}, undefined];
}
if (!_.isUndefined(options) && _.isFunction(options)) { // Only callback param
callback = options;
options = {};
}
return [options, cal... | [
"function",
"parseArguments",
"(",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"_",
".",
"isUndefined",
"(",
"options",
")",
"&&",
"_",
".",
"isUndefined",
"(",
"callback",
")",
")",
"{",
"// No params",
"return",
"[",
"{",
"}",
",",
"undefined",
... | Parses arguments provided, makes it possible to only apply a callback function | [
"Parses",
"arguments",
"provided",
"makes",
"it",
"possible",
"to",
"only",
"apply",
"a",
"callback",
"function"
] | 07fb0cdf62e9eb9cb05f74be07130c7472b2bf84 | https://github.com/Frederikbh/tickspotv2-api/blob/07fb0cdf62e9eb9cb05f74be07130c7472b2bf84/lib/service.js#L74-L83 | train |
Frederikbh/tickspotv2-api | lib/service.js | http | function http(tick, args) {
let url = 'https://www.tickspot.com/' + tick.subscriptionID + '/api/v2/';
url += args.paths.join('/') + '.json';
if (args.query) {
url += '?';
url += _.pairs(args.query).map(p => p.join('=')).join('&');
}
return url;
} | javascript | function http(tick, args) {
let url = 'https://www.tickspot.com/' + tick.subscriptionID + '/api/v2/';
url += args.paths.join('/') + '.json';
if (args.query) {
url += '?';
url += _.pairs(args.query).map(p => p.join('=')).join('&');
}
return url;
} | [
"function",
"http",
"(",
"tick",
",",
"args",
")",
"{",
"let",
"url",
"=",
"'https://www.tickspot.com/'",
"+",
"tick",
".",
"subscriptionID",
"+",
"'/api/v2/'",
";",
"url",
"+=",
"args",
".",
"paths",
".",
"join",
"(",
"'/'",
")",
"+",
"'.json'",
";",
... | Formats the url | [
"Formats",
"the",
"url"
] | 07fb0cdf62e9eb9cb05f74be07130c7472b2bf84 | https://github.com/Frederikbh/tickspotv2-api/blob/07fb0cdf62e9eb9cb05f74be07130c7472b2bf84/lib/service.js#L86-L95 | train |
Frederikbh/tickspotv2-api | lib/service.js | extractPage | function extractPage(options) {
let page = 1;
if (options && options.page) {
page = options.page;
delete options.page;
}
return page;
} | javascript | function extractPage(options) {
let page = 1;
if (options && options.page) {
page = options.page;
delete options.page;
}
return page;
} | [
"function",
"extractPage",
"(",
"options",
")",
"{",
"let",
"page",
"=",
"1",
";",
"if",
"(",
"options",
"&&",
"options",
".",
"page",
")",
"{",
"page",
"=",
"options",
".",
"page",
";",
"delete",
"options",
".",
"page",
";",
"}",
"return",
"page",
... | Extracts page from options | [
"Extracts",
"page",
"from",
"options"
] | 07fb0cdf62e9eb9cb05f74be07130c7472b2bf84 | https://github.com/Frederikbh/tickspotv2-api/blob/07fb0cdf62e9eb9cb05f74be07130c7472b2bf84/lib/service.js#L98-L105 | train |
derdesign/protos | middleware/cookie_parser/application.js | parseCookie | function parseCookie(str) {
var obj = {},
pairs = str.split(/[;,] */);
for (var pair,eqlIndex,key,val,i=0; i < pairs.length; i++) {
pair = pairs[i];
eqlIndex = pair.indexOf('=');
key = pair.substr(0, eqlIndex).trim().toLowerCase();
val = pair.substr(++eqlIndex, pair.length).trim();
if ('"' ... | javascript | function parseCookie(str) {
var obj = {},
pairs = str.split(/[;,] */);
for (var pair,eqlIndex,key,val,i=0; i < pairs.length; i++) {
pair = pairs[i];
eqlIndex = pair.indexOf('=');
key = pair.substr(0, eqlIndex).trim().toLowerCase();
val = pair.substr(++eqlIndex, pair.length).trim();
if ('"' ... | [
"function",
"parseCookie",
"(",
"str",
")",
"{",
"var",
"obj",
"=",
"{",
"}",
",",
"pairs",
"=",
"str",
".",
"split",
"(",
"/",
"[;,] *",
"/",
")",
";",
"for",
"(",
"var",
"pair",
",",
"eqlIndex",
",",
"key",
",",
"val",
",",
"i",
"=",
"0",
"... | Parses the cookie header
@param {string} str
@returns {object}
@private | [
"Parses",
"the",
"cookie",
"header"
] | 0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9 | https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/middleware/cookie_parser/application.js#L32-L56 | train |
derdesign/protos | middleware/cookie_parser/application.js | getRequestCookies | function getRequestCookies(req) {
if (req.headers.cookie != null) {
try {
return parseCookie(req.headers.cookie);
} catch (e) {
this.log(req.urlData.pathname, "Error parsing cookie header: " + e.toString());
return {};
}
} else {
return {};
}
} | javascript | function getRequestCookies(req) {
if (req.headers.cookie != null) {
try {
return parseCookie(req.headers.cookie);
} catch (e) {
this.log(req.urlData.pathname, "Error parsing cookie header: " + e.toString());
return {};
}
} else {
return {};
}
} | [
"function",
"getRequestCookies",
"(",
"req",
")",
"{",
"if",
"(",
"req",
".",
"headers",
".",
"cookie",
"!=",
"null",
")",
"{",
"try",
"{",
"return",
"parseCookie",
"(",
"req",
".",
"headers",
".",
"cookie",
")",
";",
"}",
"catch",
"(",
"e",
")",
"... | Parses the request cookies
@param {object} req
@returns {object}
@private | [
"Parses",
"the",
"request",
"cookies"
] | 0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9 | https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/middleware/cookie_parser/application.js#L66-L77 | train |
shadybones/fakery | examples/use_features.js | function(a,b){
if(b[0]=="my-id") {
var fakeResult = [];
return fakeResult;
}else return document.getElementById.apply(document,b);
} | javascript | function(a,b){
if(b[0]=="my-id") {
var fakeResult = [];
return fakeResult;
}else return document.getElementById.apply(document,b);
} | [
"function",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"b",
"[",
"0",
"]",
"==",
"\"my-id\"",
")",
"{",
"var",
"fakeResult",
"=",
"[",
"]",
";",
"return",
"fakeResult",
";",
"}",
"else",
"return",
"document",
".",
"getElementById",
".",
"apply",
"(",... | a = fake object, b = args | [
"a",
"=",
"fake",
"object",
"b",
"=",
"args"
] | 0ca9adec545595f4cdeaadbf9a3c33d0514b5061 | https://github.com/shadybones/fakery/blob/0ca9adec545595f4cdeaadbf9a3c33d0514b5061/examples/use_features.js#L23-L28 | train | |
Digznav/bilberry | git-porcelain-status.js | gitPorcelainStatus | function gitPorcelainStatus() {
return git('status --porcelain -b', stdout => {
const status = gitUtil.extractStatus(stdout);
let parsedStatus = Object.values(status.index).concat(Object.values(status.workingTree));
// Flattened
parsedStatus = parsedStatus.reduce((a, b) => a.concat(b), []);
retu... | javascript | function gitPorcelainStatus() {
return git('status --porcelain -b', stdout => {
const status = gitUtil.extractStatus(stdout);
let parsedStatus = Object.values(status.index).concat(Object.values(status.workingTree));
// Flattened
parsedStatus = parsedStatus.reduce((a, b) => a.concat(b), []);
retu... | [
"function",
"gitPorcelainStatus",
"(",
")",
"{",
"return",
"git",
"(",
"'status --porcelain -b'",
",",
"stdout",
"=>",
"{",
"const",
"status",
"=",
"gitUtil",
".",
"extractStatus",
"(",
"stdout",
")",
";",
"let",
"parsedStatus",
"=",
"Object",
".",
"values",
... | Verify the status of the repository.
@return {object} Current branch and the status of hte repository. | [
"Verify",
"the",
"status",
"of",
"the",
"repository",
"."
] | ef6db49de6c8b0d2f4f9d3e10e8a8153e39ffcc4 | https://github.com/Digznav/bilberry/blob/ef6db49de6c8b0d2f4f9d3e10e8a8153e39ffcc4/git-porcelain-status.js#L8-L22 | train |
LoveKino/ast-transfer | src/lazy/lazyCode.js | function(args, fn, type) {
this.args = args;
this.fn = fn;
this.type = type;
this.id = prefix + _code_node_id_count++;
} | javascript | function(args, fn, type) {
this.args = args;
this.fn = fn;
this.type = type;
this.id = prefix + _code_node_id_count++;
} | [
"function",
"(",
"args",
",",
"fn",
",",
"type",
")",
"{",
"this",
".",
"args",
"=",
"args",
";",
"this",
".",
"fn",
"=",
"fn",
";",
"this",
".",
"type",
"=",
"type",
";",
"this",
".",
"id",
"=",
"prefix",
"+",
"_code_node_id_count",
"++",
";",
... | Normally, when reduce a production, will new a LazyCode object
TODO fast way to indicate ancestor-descendant relationship | [
"Normally",
"when",
"reduce",
"a",
"production",
"will",
"new",
"a",
"LazyCode",
"object"
] | d0592343589e55ddee5ed9816632c7160a09d205 | https://github.com/LoveKino/ast-transfer/blob/d0592343589e55ddee5ed9816632c7160a09d205/src/lazy/lazyCode.js#L12-L18 | train | |
cli-kit/cli-help | lib/doc/gnu.js | function() {
HelpDocument.apply(this, arguments);
this.useCustom = false;
this.sections = [
HelpDocument.SYNOPSIS,
HelpDocument.DESCRIPTION,
HelpDocument.COMMANDS,
HelpDocument.OPTIONS,
HelpDocument.BUGS
]
} | javascript | function() {
HelpDocument.apply(this, arguments);
this.useCustom = false;
this.sections = [
HelpDocument.SYNOPSIS,
HelpDocument.DESCRIPTION,
HelpDocument.COMMANDS,
HelpDocument.OPTIONS,
HelpDocument.BUGS
]
} | [
"function",
"(",
")",
"{",
"HelpDocument",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"this",
".",
"useCustom",
"=",
"false",
";",
"this",
".",
"sections",
"=",
"[",
"HelpDocument",
".",
"SYNOPSIS",
",",
"HelpDocument",
".",
"DESCRIPTION",
",... | Write help as a plain text document as if it were
being sent to a tty. | [
"Write",
"help",
"as",
"a",
"plain",
"text",
"document",
"as",
"if",
"it",
"were",
"being",
"sent",
"to",
"a",
"tty",
"."
] | 09613efdd753452b466d4deb7c5391c4926e3f04 | https://github.com/cli-kit/cli-help/blob/09613efdd753452b466d4deb7c5391c4926e3f04/lib/doc/gnu.js#L12-L22 | train | |
pimbrouwers/ditto | src/index.js | clean | function clean (callback) {
if (this._clobber) {
rimraf(path.join(destination, this._clobberGlob), callback);
}
else {
callback(null);
}
} | javascript | function clean (callback) {
if (this._clobber) {
rimraf(path.join(destination, this._clobberGlob), callback);
}
else {
callback(null);
}
} | [
"function",
"clean",
"(",
"callback",
")",
"{",
"if",
"(",
"this",
".",
"_clobber",
")",
"{",
"rimraf",
"(",
"path",
".",
"join",
"(",
"destination",
",",
"this",
".",
"_clobberGlob",
")",
",",
"callback",
")",
";",
"}",
"else",
"{",
"callback",
"(",... | Clean destination if clobber
@param {Function} callback | [
"Clean",
"destination",
"if",
"clobber"
] | 0217cecdec04606e896d3339f40e75b47dea8b77 | https://github.com/pimbrouwers/ditto/blob/0217cecdec04606e896d3339f40e75b47dea8b77/src/index.js#L124-L131 | train |
pimbrouwers/ditto | src/index.js | discover | function discover (callback) {
glob(path.join(this._source, '/**/*.*'), function (err, filepaths) {
if (err) callback(err);
callback(null, filepaths);
});
} | javascript | function discover (callback) {
glob(path.join(this._source, '/**/*.*'), function (err, filepaths) {
if (err) callback(err);
callback(null, filepaths);
});
} | [
"function",
"discover",
"(",
"callback",
")",
"{",
"glob",
"(",
"path",
".",
"join",
"(",
"this",
".",
"_source",
",",
"'/**/*.*'",
")",
",",
"function",
"(",
"err",
",",
"filepaths",
")",
"{",
"if",
"(",
"err",
")",
"callback",
"(",
"err",
")",
";... | Discover & parse files in source directory
@param {Function.<Error, Array.<string>>} callback | [
"Discover",
"&",
"parse",
"files",
"in",
"source",
"directory"
] | 0217cecdec04606e896d3339f40e75b47dea8b77 | https://github.com/pimbrouwers/ditto/blob/0217cecdec04606e896d3339f40e75b47dea8b77/src/index.js#L137-L142 | train |
pimbrouwers/ditto | src/index.js | run | function run (files, callback) {
let self = this,
i = 0;
function next(err, files) {
let mw = self.middleware[i++];
if (mw) {
mw(files, self, next);
}
else {
callback(null, files);
}
};
next(null, files);
} | javascript | function run (files, callback) {
let self = this,
i = 0;
function next(err, files) {
let mw = self.middleware[i++];
if (mw) {
mw(files, self, next);
}
else {
callback(null, files);
}
};
next(null, files);
} | [
"function",
"run",
"(",
"files",
",",
"callback",
")",
"{",
"let",
"self",
"=",
"this",
",",
"i",
"=",
"0",
";",
"function",
"next",
"(",
"err",
",",
"files",
")",
"{",
"let",
"mw",
"=",
"self",
".",
"middleware",
"[",
"i",
"++",
"]",
";",
"if"... | Run middleware pipeline
@param {Function} callback | [
"Run",
"middleware",
"pipeline"
] | 0217cecdec04606e896d3339f40e75b47dea8b77 | https://github.com/pimbrouwers/ditto/blob/0217cecdec04606e896d3339f40e75b47dea8b77/src/index.js#L182-L199 | train |
pimbrouwers/ditto | src/index.js | writeFile | function writeFile (file, callback) {
fs.outputFile(path.resolve(this._destination, path.join(file.path.dir, file.path.name + file.path.ext)), file.content, function (err) {
if (err) callback(err);
callback(null);
});
} | javascript | function writeFile (file, callback) {
fs.outputFile(path.resolve(this._destination, path.join(file.path.dir, file.path.name + file.path.ext)), file.content, function (err) {
if (err) callback(err);
callback(null);
});
} | [
"function",
"writeFile",
"(",
"file",
",",
"callback",
")",
"{",
"fs",
".",
"outputFile",
"(",
"path",
".",
"resolve",
"(",
"this",
".",
"_destination",
",",
"path",
".",
"join",
"(",
"file",
".",
"path",
".",
"dir",
",",
"file",
".",
"path",
".",
... | Write file to disk
@param {Object.<DittoFile>} file DittoFile
@param {Function.<Error>} callback | [
"Write",
"file",
"to",
"disk"
] | 0217cecdec04606e896d3339f40e75b47dea8b77 | https://github.com/pimbrouwers/ditto/blob/0217cecdec04606e896d3339f40e75b47dea8b77/src/index.js#L218-L223 | train |
tolokoban/ToloFrameWork | ker/com/x-widget/x-widget.com.js | getRootChildren | function getRootChildren( root, libs, com ) {
var src = ( root.attribs.src || "" ).trim( );
if ( src.length > 0 ) {
if (!libs.fileExists( src )) {
libs.fatal( "File not found: \"" + src + "\"!" );
}
// Add a compilation dependency on the include file.
libs.addInclude( src );
var content = ... | javascript | function getRootChildren( root, libs, com ) {
var src = ( root.attribs.src || "" ).trim( );
if ( src.length > 0 ) {
if (!libs.fileExists( src )) {
libs.fatal( "File not found: \"" + src + "\"!" );
}
// Add a compilation dependency on the include file.
libs.addInclude( src );
var content = ... | [
"function",
"getRootChildren",
"(",
"root",
",",
"libs",
",",
"com",
")",
"{",
"var",
"src",
"=",
"(",
"root",
".",
"attribs",
".",
"src",
"||",
"\"\"",
")",
".",
"trim",
"(",
")",
";",
"if",
"(",
"src",
".",
"length",
">",
"0",
")",
"{",
"if",... | If root has got a `src` attribute, we load a file and put its content as children of `root`. | [
"If",
"root",
"has",
"got",
"a",
"src",
"attribute",
"we",
"load",
"a",
"file",
"and",
"put",
"its",
"content",
"as",
"children",
"of",
"root",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/com/x-widget/x-widget.com.js#L227-L238 | train |
tolokoban/ToloFrameWork | ker/com/x-widget/x-widget.com.js | getPropertiesAndBindings | function getPropertiesAndBindings( root, libs, com, indent ) {
// Attributes can have post initialization, especially for data bindings.
var postInit = {};
var hasPostInit = false;
var key,
val,
values;
var bindings;
var slots;
for ( key in root.attribs ) {
if ( key.charAt( 0 ) == '$' ) {
... | javascript | function getPropertiesAndBindings( root, libs, com, indent ) {
// Attributes can have post initialization, especially for data bindings.
var postInit = {};
var hasPostInit = false;
var key,
val,
values;
var bindings;
var slots;
for ( key in root.attribs ) {
if ( key.charAt( 0 ) == '$' ) {
... | [
"function",
"getPropertiesAndBindings",
"(",
"root",
",",
"libs",
",",
"com",
",",
"indent",
")",
"{",
"// Attributes can have post initialization, especially for data bindings.",
"var",
"postInit",
"=",
"{",
"}",
";",
"var",
"hasPostInit",
"=",
"false",
";",
"var",
... | Properties and bindings. | [
"Properties",
"and",
"bindings",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/com/x-widget/x-widget.com.js#L243-L317 | train |
vesln/sourcery | lib/resource.js | Resource | function Resource(attributes) {
this.engine = engine;
this.name = !this.name ? this.name : this.name.toLowerCase();
this.queryParams = {};
this.attributes = {};
this.load(attributes || {});
} | javascript | function Resource(attributes) {
this.engine = engine;
this.name = !this.name ? this.name : this.name.toLowerCase();
this.queryParams = {};
this.attributes = {};
this.load(attributes || {});
} | [
"function",
"Resource",
"(",
"attributes",
")",
"{",
"this",
".",
"engine",
"=",
"engine",
";",
"this",
".",
"name",
"=",
"!",
"this",
".",
"name",
"?",
"this",
".",
"name",
":",
"this",
".",
"name",
".",
"toLowerCase",
"(",
")",
";",
"this",
".",
... | Base resource. All resources inherit from it.
@param {Object} attributes to be set
@constructor | [
"Base",
"resource",
".",
"All",
"resources",
"inherit",
"from",
"it",
"."
] | e3e7c3de6bbb2d0e1ef0a546fb9af00d10653ce5 | https://github.com/vesln/sourcery/blob/e3e7c3de6bbb2d0e1ef0a546fb9af00d10653ce5/lib/resource.js#L29-L35 | train |
redisjs/jsr-server | lib/daemon.js | daemonize | function daemonize(file, conf, args) {
/* istanbul ignore next: never parse argv in test env */
args = args || process.argv.slice(2);
args.unshift(file);
var logfile = conf.get(ConfigKey.LOGFILE) || '/dev/null'
//var logfile = conf.get(ConfigKey.LOGFILE) || 'daemon.log'
, out = fs.openSync(logfile, 'a')
... | javascript | function daemonize(file, conf, args) {
/* istanbul ignore next: never parse argv in test env */
args = args || process.argv.slice(2);
args.unshift(file);
var logfile = conf.get(ConfigKey.LOGFILE) || '/dev/null'
//var logfile = conf.get(ConfigKey.LOGFILE) || 'daemon.log'
, out = fs.openSync(logfile, 'a')
... | [
"function",
"daemonize",
"(",
"file",
",",
"conf",
",",
"args",
")",
"{",
"/* istanbul ignore next: never parse argv in test env */",
"args",
"=",
"args",
"||",
"process",
".",
"argv",
".",
"slice",
"(",
"2",
")",
";",
"args",
".",
"unshift",
"(",
"file",
")... | Create the daemon process. | [
"Create",
"the",
"daemon",
"process",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/daemon.js#L14-L38 | train |
redisjs/jsr-server | lib/daemon.js | write | function write(conf) {
var contents = process.pid + EOL
, file = conf.get(ConfigKey.PIDFILE);
// can be the empty string
if(file) {
try {
fs.writeFileSync(file, contents);
log.notice('wrote pid %s to %s', process.pid, file);
}catch(e) {
log.warning('failed to write pid file (%s): %s'... | javascript | function write(conf) {
var contents = process.pid + EOL
, file = conf.get(ConfigKey.PIDFILE);
// can be the empty string
if(file) {
try {
fs.writeFileSync(file, contents);
log.notice('wrote pid %s to %s', process.pid, file);
}catch(e) {
log.warning('failed to write pid file (%s): %s'... | [
"function",
"write",
"(",
"conf",
")",
"{",
"var",
"contents",
"=",
"process",
".",
"pid",
"+",
"EOL",
",",
"file",
"=",
"conf",
".",
"get",
"(",
"ConfigKey",
".",
"PIDFILE",
")",
";",
"// can be the empty string",
"if",
"(",
"file",
")",
"{",
"try",
... | Write the pid file. | [
"Write",
"the",
"pid",
"file",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/daemon.js#L43-L55 | train |
redisjs/jsr-server | lib/daemon.js | remove | function remove(conf) {
var file = conf.get(ConfigKey.PIDFILE);
// can be the empty string
if(file) {
log.notice('removing pid file %s', file);
try {
fs.unlinkSync(file);
}catch(e) {
log.warning('failed to remove pid file (%s): %s', file, e.message);
}
}
} | javascript | function remove(conf) {
var file = conf.get(ConfigKey.PIDFILE);
// can be the empty string
if(file) {
log.notice('removing pid file %s', file);
try {
fs.unlinkSync(file);
}catch(e) {
log.warning('failed to remove pid file (%s): %s', file, e.message);
}
}
} | [
"function",
"remove",
"(",
"conf",
")",
"{",
"var",
"file",
"=",
"conf",
".",
"get",
"(",
"ConfigKey",
".",
"PIDFILE",
")",
";",
"// can be the empty string",
"if",
"(",
"file",
")",
"{",
"log",
".",
"notice",
"(",
"'removing pid file %s'",
",",
"file",
... | Remove the pid file. | [
"Remove",
"the",
"pid",
"file",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/daemon.js#L60-L71 | train |
Lindurion/closure-pro-build | 3p/closure-library-20130212/third_party/closure/goog/dojo/dom/query.js | function(node, root) {
var pn = node.parentNode;
while (pn) {
if (pn == root) {
break;
}
pn = pn.parentNode;
}
return !!pn;
} | javascript | function(node, root) {
var pn = node.parentNode;
while (pn) {
if (pn == root) {
break;
}
pn = pn.parentNode;
}
return !!pn;
} | [
"function",
"(",
"node",
",",
"root",
")",
"{",
"var",
"pn",
"=",
"node",
".",
"parentNode",
";",
"while",
"(",
"pn",
")",
"{",
"if",
"(",
"pn",
"==",
"root",
")",
"{",
"break",
";",
"}",
"pn",
"=",
"pn",
".",
"parentNode",
";",
"}",
"return",
... | test to see if node is below root | [
"test",
"to",
"see",
"if",
"node",
"is",
"below",
"root"
] | c279d0fcc3a65969d2fe965f55e627b074792f1a | https://github.com/Lindurion/closure-pro-build/blob/c279d0fcc3a65969d2fe965f55e627b074792f1a/3p/closure-library-20130212/third_party/closure/goog/dojo/dom/query.js#L988-L997 | train | |
Lindurion/closure-pro-build | 3p/closure-library-20130212/third_party/closure/goog/dojo/dom/query.js | function(node, bag) {
if (!bag) {
return 1;
}
var id = _nodeUID(node);
if (!bag[id]) {
return bag[id] = 1;
}
return 0;
} | javascript | function(node, bag) {
if (!bag) {
return 1;
}
var id = _nodeUID(node);
if (!bag[id]) {
return bag[id] = 1;
}
return 0;
} | [
"function",
"(",
"node",
",",
"bag",
")",
"{",
"if",
"(",
"!",
"bag",
")",
"{",
"return",
"1",
";",
"}",
"var",
"id",
"=",
"_nodeUID",
"(",
"node",
")",
";",
"if",
"(",
"!",
"bag",
"[",
"id",
"]",
")",
"{",
"return",
"bag",
"[",
"id",
"]",
... | determine if a node in is unique in a 'bag'. In this case we don't want to flatten a list of unique items, but rather just tell if the item in question is already in the bag. Normally we'd just use hash lookup to do this for us but IE's DOM is busted so we can't really count on that. On the upside, it gives us a built ... | [
"determine",
"if",
"a",
"node",
"in",
"is",
"unique",
"in",
"a",
"bag",
".",
"In",
"this",
"case",
"we",
"don",
"t",
"want",
"to",
"flatten",
"a",
"list",
"of",
"unique",
"items",
"but",
"rather",
"just",
"tell",
"if",
"the",
"item",
"in",
"question"... | c279d0fcc3a65969d2fe965f55e627b074792f1a | https://github.com/Lindurion/closure-pro-build/blob/c279d0fcc3a65969d2fe965f55e627b074792f1a/3p/closure-library-20130212/third_party/closure/goog/dojo/dom/query.js#L1402-L1411 | train | |
Lindurion/closure-pro-build | 3p/closure-library-20130212/third_party/closure/goog/dojo/dom/query.js | function(query, root) {
// NOTE: elementsById is not currently supported
// NOTE: ignores xpath-ish queries for now
//Set list constructor to desired value. This can change
//between calls, so always re-assign here.
if (!query) {
return [];
}
if (query.constructor == Array) {
... | javascript | function(query, root) {
// NOTE: elementsById is not currently supported
// NOTE: ignores xpath-ish queries for now
//Set list constructor to desired value. This can change
//between calls, so always re-assign here.
if (!query) {
return [];
}
if (query.constructor == Array) {
... | [
"function",
"(",
"query",
",",
"root",
")",
"{",
"// NOTE: elementsById is not currently supported",
"// NOTE: ignores xpath-ish queries for now",
"//Set list constructor to desired value. This can change",
"//between calls, so always re-assign here.",
"if",
"(",
"!",
"query",
")",
"... | The main executor. Type specification from above.
@param {string|Array} query The query.
@param {(string|Node)=} root The root.
@return {!Array} The elements that matched the query. | [
"The",
"main",
"executor",
".",
"Type",
"specification",
"from",
"above",
"."
] | c279d0fcc3a65969d2fe965f55e627b074792f1a | https://github.com/Lindurion/closure-pro-build/blob/c279d0fcc3a65969d2fe965f55e627b074792f1a/3p/closure-library-20130212/third_party/closure/goog/dojo/dom/query.js#L1472-L1525 | train | |
novemberborn/legendary | lib/private/resolution.js | Propagator | function Propagator(
constructor, transforms,
cancellable, signalCancelled) {
this._constructor = constructor || promise.Promise;
this._transforms = transforms;
this._cancellable = cancellable === true;
this._signalCancelled = signalCancelled;
this._state = INITIALIZED;
this._resolved = false;
th... | javascript | function Propagator(
constructor, transforms,
cancellable, signalCancelled) {
this._constructor = constructor || promise.Promise;
this._transforms = transforms;
this._cancellable = cancellable === true;
this._signalCancelled = signalCancelled;
this._state = INITIALIZED;
this._resolved = false;
th... | [
"function",
"Propagator",
"(",
"constructor",
",",
"transforms",
",",
"cancellable",
",",
"signalCancelled",
")",
"{",
"this",
".",
"_constructor",
"=",
"constructor",
"||",
"promise",
".",
"Promise",
";",
"this",
".",
"_transforms",
"=",
"transforms",
";",
"t... | Propagators propagate the state of a promise to added callbacks, optionally transforming it first. The transformation may result in a thenable. The propagator will only attempt to resolve the state of the thenable when callbacks are added. | [
"Propagators",
"propagate",
"the",
"state",
"of",
"a",
"promise",
"to",
"added",
"callbacks",
"optionally",
"transforming",
"it",
"first",
".",
"The",
"transformation",
"may",
"result",
"in",
"a",
"thenable",
".",
"The",
"propagator",
"will",
"only",
"attempt",
... | 8420f2dd20e2e3eaced51385fb6b0dc65b81a9fc | https://github.com/novemberborn/legendary/blob/8420f2dd20e2e3eaced51385fb6b0dc65b81a9fc/lib/private/resolution.js#L62-L81 | train |
wscn-FED/wscn-react-vendor | dist/wscn-react-vendor.js | nodeIsRenderedByOtherInstance | function nodeIsRenderedByOtherInstance(container) {
var rootEl = getReactRootElementInContainer(container);
return !!(rootEl && isReactNode(rootEl) && !ReactDOMComponentTree.getInstanceFromNode(rootEl));
} | javascript | function nodeIsRenderedByOtherInstance(container) {
var rootEl = getReactRootElementInContainer(container);
return !!(rootEl && isReactNode(rootEl) && !ReactDOMComponentTree.getInstanceFromNode(rootEl));
} | [
"function",
"nodeIsRenderedByOtherInstance",
"(",
"container",
")",
"{",
"var",
"rootEl",
"=",
"getReactRootElementInContainer",
"(",
"container",
")",
";",
"return",
"!",
"!",
"(",
"rootEl",
"&&",
"isReactNode",
"(",
"rootEl",
")",
"&&",
"!",
"ReactDOMComponentTr... | True if the supplied DOM node is a React DOM element and
it has been rendered by another copy of React.
@param {?DOMElement} node The candidate DOM node.
@return {boolean} True if the DOM has been rendered by another copy of React
@internal | [
"True",
"if",
"the",
"supplied",
"DOM",
"node",
"is",
"a",
"React",
"DOM",
"element",
"and",
"it",
"has",
"been",
"rendered",
"by",
"another",
"copy",
"of",
"React",
"."
] | 4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2 | https://github.com/wscn-FED/wscn-react-vendor/blob/4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2/dist/wscn-react-vendor.js#L12418-L12421 | train |
wscn-FED/wscn-react-vendor | dist/wscn-react-vendor.js | isReactNode | function isReactNode(node) {
return isValidContainer(node) && (node.hasAttribute(ROOT_ATTR_NAME) || node.hasAttribute(ATTR_NAME));
} | javascript | function isReactNode(node) {
return isValidContainer(node) && (node.hasAttribute(ROOT_ATTR_NAME) || node.hasAttribute(ATTR_NAME));
} | [
"function",
"isReactNode",
"(",
"node",
")",
"{",
"return",
"isValidContainer",
"(",
"node",
")",
"&&",
"(",
"node",
".",
"hasAttribute",
"(",
"ROOT_ATTR_NAME",
")",
"||",
"node",
".",
"hasAttribute",
"(",
"ATTR_NAME",
")",
")",
";",
"}"
] | True if the supplied DOM node is a valid React node element.
@param {?DOMElement} node The candidate DOM node.
@return {boolean} True if the DOM is a valid React DOM node.
@internal | [
"True",
"if",
"the",
"supplied",
"DOM",
"node",
"is",
"a",
"valid",
"React",
"node",
"element",
"."
] | 4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2 | https://github.com/wscn-FED/wscn-react-vendor/blob/4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2/dist/wscn-react-vendor.js#L12441-L12443 | train |
wscn-FED/wscn-react-vendor | dist/wscn-react-vendor.js | function (root, className) {
var all = ReactTestUtils.scryRenderedDOMComponentsWithClass(root, className);
if (all.length !== 1) {
throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for class:' + className);
}
return all[0];
} | javascript | function (root, className) {
var all = ReactTestUtils.scryRenderedDOMComponentsWithClass(root, className);
if (all.length !== 1) {
throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for class:' + className);
}
return all[0];
} | [
"function",
"(",
"root",
",",
"className",
")",
"{",
"var",
"all",
"=",
"ReactTestUtils",
".",
"scryRenderedDOMComponentsWithClass",
"(",
"root",
",",
"className",
")",
";",
"if",
"(",
"all",
".",
"length",
"!==",
"1",
")",
"{",
"throw",
"new",
"Error",
... | Like scryRenderedDOMComponentsWithClass but expects there to be one result,
and returns that one result, or throws exception if there is any other
number of matches besides one.
@return {!ReactDOMComponent} The one match. | [
"Like",
"scryRenderedDOMComponentsWithClass",
"but",
"expects",
"there",
"to",
"be",
"one",
"result",
"and",
"returns",
"that",
"one",
"result",
"or",
"throws",
"exception",
"if",
"there",
"is",
"any",
"other",
"number",
"of",
"matches",
"besides",
"one",
"."
] | 4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2 | https://github.com/wscn-FED/wscn-react-vendor/blob/4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2/dist/wscn-react-vendor.js#L15590-L15596 | train | |
wscn-FED/wscn-react-vendor | dist/wscn-react-vendor.js | function (root, tagName) {
return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
return ReactTestUtils.isDOMComponent(inst) && inst.tagName.toUpperCase() === tagName.toUpperCase();
});
} | javascript | function (root, tagName) {
return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
return ReactTestUtils.isDOMComponent(inst) && inst.tagName.toUpperCase() === tagName.toUpperCase();
});
} | [
"function",
"(",
"root",
",",
"tagName",
")",
"{",
"return",
"ReactTestUtils",
".",
"findAllInRenderedTree",
"(",
"root",
",",
"function",
"(",
"inst",
")",
"{",
"return",
"ReactTestUtils",
".",
"isDOMComponent",
"(",
"inst",
")",
"&&",
"inst",
".",
"tagName... | Finds all instance of components in the rendered tree that are DOM
components with the tag name matching `tagName`.
@return {array} an array of all the matches. | [
"Finds",
"all",
"instance",
"of",
"components",
"in",
"the",
"rendered",
"tree",
"that",
"are",
"DOM",
"components",
"with",
"the",
"tag",
"name",
"matching",
"tagName",
"."
] | 4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2 | https://github.com/wscn-FED/wscn-react-vendor/blob/4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2/dist/wscn-react-vendor.js#L15603-L15607 | train | |
wscn-FED/wscn-react-vendor | dist/wscn-react-vendor.js | function (root, tagName) {
var all = ReactTestUtils.scryRenderedDOMComponentsWithTag(root, tagName);
if (all.length !== 1) {
throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for tag:' + tagName);
}
return all[0];
} | javascript | function (root, tagName) {
var all = ReactTestUtils.scryRenderedDOMComponentsWithTag(root, tagName);
if (all.length !== 1) {
throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for tag:' + tagName);
}
return all[0];
} | [
"function",
"(",
"root",
",",
"tagName",
")",
"{",
"var",
"all",
"=",
"ReactTestUtils",
".",
"scryRenderedDOMComponentsWithTag",
"(",
"root",
",",
"tagName",
")",
";",
"if",
"(",
"all",
".",
"length",
"!==",
"1",
")",
"{",
"throw",
"new",
"Error",
"(",
... | Like scryRenderedDOMComponentsWithTag but expects there to be one result,
and returns that one result, or throws exception if there is any other
number of matches besides one.
@return {!ReactDOMComponent} The one match. | [
"Like",
"scryRenderedDOMComponentsWithTag",
"but",
"expects",
"there",
"to",
"be",
"one",
"result",
"and",
"returns",
"that",
"one",
"result",
"or",
"throws",
"exception",
"if",
"there",
"is",
"any",
"other",
"number",
"of",
"matches",
"besides",
"one",
"."
] | 4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2 | https://github.com/wscn-FED/wscn-react-vendor/blob/4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2/dist/wscn-react-vendor.js#L15615-L15621 | train | |
wscn-FED/wscn-react-vendor | dist/wscn-react-vendor.js | function (root, componentType) {
return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
return ReactTestUtils.isCompositeComponentWithType(inst, componentType);
});
} | javascript | function (root, componentType) {
return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
return ReactTestUtils.isCompositeComponentWithType(inst, componentType);
});
} | [
"function",
"(",
"root",
",",
"componentType",
")",
"{",
"return",
"ReactTestUtils",
".",
"findAllInRenderedTree",
"(",
"root",
",",
"function",
"(",
"inst",
")",
"{",
"return",
"ReactTestUtils",
".",
"isCompositeComponentWithType",
"(",
"inst",
",",
"componentTyp... | Finds all instances of components with type equal to `componentType`.
@return {array} an array of all the matches. | [
"Finds",
"all",
"instances",
"of",
"components",
"with",
"type",
"equal",
"to",
"componentType",
"."
] | 4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2 | https://github.com/wscn-FED/wscn-react-vendor/blob/4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2/dist/wscn-react-vendor.js#L15627-L15631 | train | |
wscn-FED/wscn-react-vendor | dist/wscn-react-vendor.js | function (root, componentType) {
var all = ReactTestUtils.scryRenderedComponentsWithType(root, componentType);
if (all.length !== 1) {
throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for componentType:' + componentType);
}
return all[0];
} | javascript | function (root, componentType) {
var all = ReactTestUtils.scryRenderedComponentsWithType(root, componentType);
if (all.length !== 1) {
throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for componentType:' + componentType);
}
return all[0];
} | [
"function",
"(",
"root",
",",
"componentType",
")",
"{",
"var",
"all",
"=",
"ReactTestUtils",
".",
"scryRenderedComponentsWithType",
"(",
"root",
",",
"componentType",
")",
";",
"if",
"(",
"all",
".",
"length",
"!==",
"1",
")",
"{",
"throw",
"new",
"Error"... | Same as `scryRenderedComponentsWithType` but expects there to be one result
and returns that one result, or throws exception if there is any other
number of matches besides one.
@return {!ReactComponent} The one match. | [
"Same",
"as",
"scryRenderedComponentsWithType",
"but",
"expects",
"there",
"to",
"be",
"one",
"result",
"and",
"returns",
"that",
"one",
"result",
"or",
"throws",
"exception",
"if",
"there",
"is",
"any",
"other",
"number",
"of",
"matches",
"besides",
"one",
".... | 4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2 | https://github.com/wscn-FED/wscn-react-vendor/blob/4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2/dist/wscn-react-vendor.js#L15639-L15645 | train | |
wscn-FED/wscn-react-vendor | dist/wscn-react-vendor.js | function (topLevelType, node, fakeNativeEvent) {
fakeNativeEvent.target = node;
ReactBrowserEventEmitter.ReactEventListener.dispatchEvent(topLevelType, fakeNativeEvent);
} | javascript | function (topLevelType, node, fakeNativeEvent) {
fakeNativeEvent.target = node;
ReactBrowserEventEmitter.ReactEventListener.dispatchEvent(topLevelType, fakeNativeEvent);
} | [
"function",
"(",
"topLevelType",
",",
"node",
",",
"fakeNativeEvent",
")",
"{",
"fakeNativeEvent",
".",
"target",
"=",
"node",
";",
"ReactBrowserEventEmitter",
".",
"ReactEventListener",
".",
"dispatchEvent",
"(",
"topLevelType",
",",
"fakeNativeEvent",
")",
";",
... | Simulates a top level event being dispatched from a raw event that occurred
on an `Element` node.
@param {Object} topLevelType A type from `EventConstants.topLevelTypes`
@param {!Element} node The dom to simulate an event occurring on.
@param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent. | [
"Simulates",
"a",
"top",
"level",
"event",
"being",
"dispatched",
"from",
"a",
"raw",
"event",
"that",
"occurred",
"on",
"an",
"Element",
"node",
"."
] | 4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2 | https://github.com/wscn-FED/wscn-react-vendor/blob/4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2/dist/wscn-react-vendor.js#L15677-L15680 | train | |
wscn-FED/wscn-react-vendor | dist/wscn-react-vendor.js | matchesSelector | function matchesSelector(element, selector) {
var matchesImpl = element.matches || element.webkitMatchesSelector || element.mozMatchesSelector || element.msMatchesSelector || function (s) {
return matchesSelector_SLOW(element, s);
};
return matchesImpl.call(element, selector);
} | javascript | function matchesSelector(element, selector) {
var matchesImpl = element.matches || element.webkitMatchesSelector || element.mozMatchesSelector || element.msMatchesSelector || function (s) {
return matchesSelector_SLOW(element, s);
};
return matchesImpl.call(element, selector);
} | [
"function",
"matchesSelector",
"(",
"element",
",",
"selector",
")",
"{",
"var",
"matchesImpl",
"=",
"element",
".",
"matches",
"||",
"element",
".",
"webkitMatchesSelector",
"||",
"element",
".",
"mozMatchesSelector",
"||",
"element",
".",
"msMatchesSelector",
"|... | Tests whether the element matches the selector specified
@param {DOMNode|DOMWindow} element the element that we are querying
@param {string} selector the CSS selector
@return {boolean} true if the element matches the selector, false if not | [
"Tests",
"whether",
"the",
"element",
"matches",
"the",
"selector",
"specified"
] | 4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2 | https://github.com/wscn-FED/wscn-react-vendor/blob/4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2/dist/wscn-react-vendor.js#L21658-L21663 | train |
radixdlt/radixdlt-js-lite | src/connection-handler.js | registerApp | function registerApp(name, description, permissions) {
const CONNECTION = new Connection();
return new Promise((resolve, reject) => {
CONNECTION.register(name, description, permissions)
.then(() => resolve(new ConnectionHandler(CONNECTION)))
.catch((error) => reject(error));
});
} | javascript | function registerApp(name, description, permissions) {
const CONNECTION = new Connection();
return new Promise((resolve, reject) => {
CONNECTION.register(name, description, permissions)
.then(() => resolve(new ConnectionHandler(CONNECTION)))
.catch((error) => reject(error));
});
} | [
"function",
"registerApp",
"(",
"name",
",",
"description",
",",
"permissions",
")",
"{",
"const",
"CONNECTION",
"=",
"new",
"Connection",
"(",
")",
";",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"CONNECTION",
".",
"... | Register an App.
@param {string} name - App's name.
@param {string} description - App's description.
@param {string[]} permissions - Permissions requested by this App.
@returns {Promise} | [
"Register",
"an",
"App",
"."
] | 8ee699d9eed3c7f843ea45c81f2924dfb419d903 | https://github.com/radixdlt/radixdlt-js-lite/blob/8ee699d9eed3c7f843ea45c81f2924dfb419d903/src/connection-handler.js#L65-L73 | train |
radixdlt/radixdlt-js-lite | src/connection-handler.js | connectApp | function connectApp(token) {
const CONNECTION = new Connection();
return new Promise((resolve, reject) => {
CONNECTION.connect(token)
.then(() => resolve(new ConnectionHandler(CONNECTION)))
.catch((error) => reject(error));
});
} | javascript | function connectApp(token) {
const CONNECTION = new Connection();
return new Promise((resolve, reject) => {
CONNECTION.connect(token)
.then(() => resolve(new ConnectionHandler(CONNECTION)))
.catch((error) => reject(error));
});
} | [
"function",
"connectApp",
"(",
"token",
")",
"{",
"const",
"CONNECTION",
"=",
"new",
"Connection",
"(",
")",
";",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"CONNECTION",
".",
"connect",
"(",
"token",
")",
".",
"the... | Re-connects an App with a valid token.
@param {string} token - Auth token.
@returns {Promise} | [
"Re",
"-",
"connects",
"an",
"App",
"with",
"a",
"valid",
"token",
"."
] | 8ee699d9eed3c7f843ea45c81f2924dfb419d903 | https://github.com/radixdlt/radixdlt-js-lite/blob/8ee699d9eed3c7f843ea45c81f2924dfb419d903/src/connection-handler.js#L80-L88 | train |
darrylwest/node-messaging-commons | browser/browser-messaging-commons.js | function(options) {
'use strict';
var client = this,
log = options.log,
socketHost = options.socketHost,
hubName = options.hubName,
hub;
/**
* open the public/private channels to begin exchanges
*/
this.subscribe = function(channelName, handler, callback) {
... | javascript | function(options) {
'use strict';
var client = this,
log = options.log,
socketHost = options.socketHost,
hubName = options.hubName,
hub;
/**
* open the public/private channels to begin exchanges
*/
this.subscribe = function(channelName, handler, callback) {
... | [
"function",
"(",
"options",
")",
"{",
"'use strict'",
";",
"var",
"client",
"=",
"this",
",",
"log",
"=",
"options",
".",
"log",
",",
"socketHost",
"=",
"options",
".",
"socketHost",
",",
"hubName",
"=",
"options",
".",
"hubName",
",",
"hub",
";",
"/**... | AbstractMessageClient - browser side base class
@author: darryl.west@roundpeg.com
@created: 8/31/14 | [
"AbstractMessageClient",
"-",
"browser",
"side",
"base",
"class"
] | 31907d87ced947075013a79f879e71a310eb52e1 | https://github.com/darrylwest/node-messaging-commons/blob/31907d87ced947075013a79f879e71a310eb52e1/browser/browser-messaging-commons.js#L7-L88 | train | |
pzlr/build-core | lib/block.js | validateCache | function validateCache(path, cache) {
const
{mtime} = fs.statSync(path);
return {
mtime,
fromCache: Boolean(cache[path] && Sugar.Date.is(mtime, cache[path].mtime))
};
} | javascript | function validateCache(path, cache) {
const
{mtime} = fs.statSync(path);
return {
mtime,
fromCache: Boolean(cache[path] && Sugar.Date.is(mtime, cache[path].mtime))
};
} | [
"function",
"validateCache",
"(",
"path",
",",
"cache",
")",
"{",
"const",
"{",
"mtime",
"}",
"=",
"fs",
".",
"statSync",
"(",
"path",
")",
";",
"return",
"{",
"mtime",
",",
"fromCache",
":",
"Boolean",
"(",
"cache",
"[",
"path",
"]",
"&&",
"Sugar",
... | Validates a file by the specified path and return meta information
@param {string} path
@param {!Object} cache - cache object
@returns {{mtime: !Object, fromCache: boolean}} | [
"Validates",
"a",
"file",
"by",
"the",
"specified",
"path",
"and",
"return",
"meta",
"information"
] | 11e20eda500682b9fa62c7804c66be1714df0df4 | https://github.com/pzlr/build-core/blob/11e20eda500682b9fa62c7804c66be1714df0df4/lib/block.js#L30-L38 | train |
pzlr/build-core | lib/block.js | getFile | function getFile(path) {
const
cache = validateCache(path, filesCache);
if (!cache.fromCache) {
filesCache[path] = {
mtime: cache.mtime,
content: fs.readFileSync(path, 'utf-8')
};
}
return filesCache[path].content;
} | javascript | function getFile(path) {
const
cache = validateCache(path, filesCache);
if (!cache.fromCache) {
filesCache[path] = {
mtime: cache.mtime,
content: fs.readFileSync(path, 'utf-8')
};
}
return filesCache[path].content;
} | [
"function",
"getFile",
"(",
"path",
")",
"{",
"const",
"cache",
"=",
"validateCache",
"(",
"path",
",",
"filesCache",
")",
";",
"if",
"(",
"!",
"cache",
".",
"fromCache",
")",
"{",
"filesCache",
"[",
"path",
"]",
"=",
"{",
"mtime",
":",
"cache",
".",... | Returns a file content by the specified path
@param {string} path
@returns {string} | [
"Returns",
"a",
"file",
"content",
"by",
"the",
"specified",
"path"
] | 11e20eda500682b9fa62c7804c66be1714df0df4 | https://github.com/pzlr/build-core/blob/11e20eda500682b9fa62c7804c66be1714df0df4/lib/block.js#L46-L58 | train |
gethuman/pancakes-recipe | utils/bulk.change.js | BulkChange | function BulkChange(model) {
this.model = model;
this.bulk = model.collection.initializeUnorderedBulkOp();
this.isChange = false;
} | javascript | function BulkChange(model) {
this.model = model;
this.bulk = model.collection.initializeUnorderedBulkOp();
this.isChange = false;
} | [
"function",
"BulkChange",
"(",
"model",
")",
"{",
"this",
".",
"model",
"=",
"model",
";",
"this",
".",
"bulk",
"=",
"model",
".",
"collection",
".",
"initializeUnorderedBulkOp",
"(",
")",
";",
"this",
".",
"isChange",
"=",
"false",
";",
"}"
] | Constructor used to start the undordered bulk operation
@param model
@constructor | [
"Constructor",
"used",
"to",
"start",
"the",
"undordered",
"bulk",
"operation"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/utils/bulk.change.js#L14-L18 | train |
quantumpayments/media | bin/view.js | getMediaByBuffer | function getMediaByBuffer (uri, cert, mode, user, safe, bufferURI) {
var bufferPath = root
if (bufferURI) {
bufferPath += '/../' + url.parse(bufferURI).path
}
return new Promise(function (resolve, reject) {
// var bufferPath = __dirname + '/../data/buffer/image/'
debug('bufferPath', bufferPath)
... | javascript | function getMediaByBuffer (uri, cert, mode, user, safe, bufferURI) {
var bufferPath = root
if (bufferURI) {
bufferPath += '/../' + url.parse(bufferURI).path
}
return new Promise(function (resolve, reject) {
// var bufferPath = __dirname + '/../data/buffer/image/'
debug('bufferPath', bufferPath)
... | [
"function",
"getMediaByBuffer",
"(",
"uri",
",",
"cert",
",",
"mode",
",",
"user",
",",
"safe",
",",
"bufferURI",
")",
"{",
"var",
"bufferPath",
"=",
"root",
"if",
"(",
"bufferURI",
")",
"{",
"bufferPath",
"+=",
"'/../'",
"+",
"url",
".",
"parse",
"(",... | Get Media item from buffer
@param {string} uri The uri to get it from.
@param {string} cert Location of an X.509 cert.
@param {string} mode Mode api | http | buffer.
@param {string} user The WebID of the user.
@param {number} safe Whether safe search is on.
@param {string} bufferURI The ... | [
"Get",
"Media",
"item",
"from",
"buffer"
] | b53034e6dd2a94dca950e60a49e403aceaa1cdf1 | https://github.com/quantumpayments/media/blob/b53034e6dd2a94dca950e60a49e403aceaa1cdf1/bin/view.js#L104-L140 | train |
quantumpayments/media | bin/view.js | addMediaToBuffer | function addMediaToBuffer (uri, cert, mode, user, safe, bufferURI) {
// var bufferPath = root
// if (bufferURI) {
// bufferPath += '/../' + url.parse(bufferURI).path
// }
setTimeout(() => {
try {
// fs.unlinkSync(lastFile)
} catch (e) {
console.error(e)
}
var params = {}
para... | javascript | function addMediaToBuffer (uri, cert, mode, user, safe, bufferURI) {
// var bufferPath = root
// if (bufferURI) {
// bufferPath += '/../' + url.parse(bufferURI).path
// }
setTimeout(() => {
try {
// fs.unlinkSync(lastFile)
} catch (e) {
console.error(e)
}
var params = {}
para... | [
"function",
"addMediaToBuffer",
"(",
"uri",
",",
"cert",
",",
"mode",
",",
"user",
",",
"safe",
",",
"bufferURI",
")",
"{",
"// var bufferPath = root",
"// if (bufferURI) {",
"// bufferPath += '/../' + url.parse(bufferURI).path",
"// }",
"setTimeout",
"(",
"(",
")",
... | Adds media to buffer
@param {string} uri The uri to get it from.
@param {string} cert Location of an X.509 cert.
@param {string} mode Mode api | http | buffer.
@param {string} user The WebID of the user.
@param {number} safe Whether safe search is on.
@param {string} bufferURI The URI of... | [
"Adds",
"media",
"to",
"buffer"
] | b53034e6dd2a94dca950e60a49e403aceaa1cdf1 | https://github.com/quantumpayments/media/blob/b53034e6dd2a94dca950e60a49e403aceaa1cdf1/bin/view.js#L152-L199 | train |
quantumpayments/media | bin/view.js | copyMedia | function copyMedia (path, to, cert, callback) {
var hookPath = __dirname + '/../data/buffer/hook.sh'
debug('copyMedia', path, to, cert)
if (/^http/.test(to)) {
debug('using http')
var parsed = url.parse(to)
debug('parsed', parsed)
var domain = url.parse(to).domain
var file = url.parse(to).pa... | javascript | function copyMedia (path, to, cert, callback) {
var hookPath = __dirname + '/../data/buffer/hook.sh'
debug('copyMedia', path, to, cert)
if (/^http/.test(to)) {
debug('using http')
var parsed = url.parse(to)
debug('parsed', parsed)
var domain = url.parse(to).domain
var file = url.parse(to).pa... | [
"function",
"copyMedia",
"(",
"path",
",",
"to",
",",
"cert",
",",
"callback",
")",
"{",
"var",
"hookPath",
"=",
"__dirname",
"+",
"'/../data/buffer/hook.sh'",
"debug",
"(",
"'copyMedia'",
",",
"path",
",",
"to",
",",
"cert",
")",
"if",
"(",
"/",
"^http"... | copy media from one place to another
@param {string} path from where to copy
@param {string} to where to copy to
@param {string} cert path to certificate
@param {Function} callback callback | [
"copy",
"media",
"from",
"one",
"place",
"to",
"another"
] | b53034e6dd2a94dca950e60a49e403aceaa1cdf1 | https://github.com/quantumpayments/media/blob/b53034e6dd2a94dca950e60a49e403aceaa1cdf1/bin/view.js#L208-L266 | train |
quantumpayments/media | bin/view.js | getMediaByAPI | function getMediaByAPI (uri, cert, mode, user, safe, bufferURI) {
return new Promise(function (resolve, reject) {
balance(user).then((ret) => {
return ret
}).then(function (ret) {
if (ret >= algos.getRandomUnseenImage.cost) {
qpm_media.getRandomUnseenImage().then(function (row) {
... | javascript | function getMediaByAPI (uri, cert, mode, user, safe, bufferURI) {
return new Promise(function (resolve, reject) {
balance(user).then((ret) => {
return ret
}).then(function (ret) {
if (ret >= algos.getRandomUnseenImage.cost) {
qpm_media.getRandomUnseenImage().then(function (row) {
... | [
"function",
"getMediaByAPI",
"(",
"uri",
",",
"cert",
",",
"mode",
",",
"user",
",",
"safe",
",",
"bufferURI",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"balance",
"(",
"user",
")",
".",
"then",
"... | Get Media item from API
@param {string} uri The uri to get it from.
@param {string} cert Location of an X.509 cert.
@param {string} mode Mode api | http | buffer.
@param {string} user The WebID of the user.
@param {number} safe Whether safe search is on.
@param {string} bufferURI The URI... | [
"Get",
"Media",
"item",
"from",
"API"
] | b53034e6dd2a94dca950e60a49e403aceaa1cdf1 | https://github.com/quantumpayments/media/blob/b53034e6dd2a94dca950e60a49e403aceaa1cdf1/bin/view.js#L278-L304 | train |
quantumpayments/media | bin/view.js | getMediaByHTTP | function getMediaByHTTP (uri, cert, mode, user, safe, bufferURI) {
return new Promise(function (resolve, reject) {
var cookiePath = __dirname + '/../data/cookie.json'
var cookies = readCookie(cookiePath)
if (cookies) {
options.headers['Set-Cookie'] = 'connect.sid=' + sid + '; Path=/; HttpOnly; Sec... | javascript | function getMediaByHTTP (uri, cert, mode, user, safe, bufferURI) {
return new Promise(function (resolve, reject) {
var cookiePath = __dirname + '/../data/cookie.json'
var cookies = readCookie(cookiePath)
if (cookies) {
options.headers['Set-Cookie'] = 'connect.sid=' + sid + '; Path=/; HttpOnly; Sec... | [
"function",
"getMediaByHTTP",
"(",
"uri",
",",
"cert",
",",
"mode",
",",
"user",
",",
"safe",
",",
"bufferURI",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"var",
"cookiePath",
"=",
"__dirname",
"+",
... | Get Media item from HTTP
@param {string} uri The uri to get it from.
@param {string} cert Location of an X.509 cert.
@param {string} mode Mode api | http | buffer.
@param {string} user The WebID of the user.
@param {number} safe Whether safe search is on.
@param {string} bufferURI The UR... | [
"Get",
"Media",
"item",
"from",
"HTTP"
] | b53034e6dd2a94dca950e60a49e403aceaa1cdf1 | https://github.com/quantumpayments/media/blob/b53034e6dd2a94dca950e60a49e403aceaa1cdf1/bin/view.js#L316-L346 | train |
quantumpayments/media | bin/view.js | getNextFile | function getNextFile (files, type) {
for (var i = 0; i < files.length; i++) {
var file = files[i]
if (/.ttl$/.test(file)) {
continue
}
return file
}
} | javascript | function getNextFile (files, type) {
for (var i = 0; i < files.length; i++) {
var file = files[i]
if (/.ttl$/.test(file)) {
continue
}
return file
}
} | [
"function",
"getNextFile",
"(",
"files",
",",
"type",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"files",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"file",
"=",
"files",
"[",
"i",
"]",
"if",
"(",
"/",
".ttl$",
"/",
".",
... | Gets the next file in a buffer
@param {array} files Array of files
@param {number} type Type of file to get
@return {string} Path to file | [
"Gets",
"the",
"next",
"file",
"in",
"a",
"buffer"
] | b53034e6dd2a94dca950e60a49e403aceaa1cdf1 | https://github.com/quantumpayments/media/blob/b53034e6dd2a94dca950e60a49e403aceaa1cdf1/bin/view.js#L470-L478 | train |
cemtopkaya/kuark-db | src/db_uyariServisi.js | f_todo_secildi | function f_todo_secildi(_uyari) {
l.info("f_todo_secildi");
//bu uyarı için atanmış kullanıcı id lerini çek
var kullanici_idleri = f_uye_id_array(_uyari);
return _uyari.RENDER.Sonuc.Data.map(function (_elm) {
var detay = f_detay_olustur(schema.SABIT.UYARI.TODO,... | javascript | function f_todo_secildi(_uyari) {
l.info("f_todo_secildi");
//bu uyarı için atanmış kullanıcı id lerini çek
var kullanici_idleri = f_uye_id_array(_uyari);
return _uyari.RENDER.Sonuc.Data.map(function (_elm) {
var detay = f_detay_olustur(schema.SABIT.UYARI.TODO,... | [
"function",
"f_todo_secildi",
"(",
"_uyari",
")",
"{",
"l",
".",
"info",
"(",
"\"f_todo_secildi\"",
")",
";",
"//bu uyarı için atanmış kullanıcı id lerini çek\r",
"var",
"kullanici_idleri",
"=",
"f_uye_id_array",
"(",
"_uyari",
")",
";",
"return",
"_uyari",
".",
"RE... | endregion region TO-DO | [
"endregion",
"region",
"TO",
"-",
"DO"
] | d584aaf51f65a013bec79220a05007bd70767ac2 | https://github.com/cemtopkaya/kuark-db/blob/d584aaf51f65a013bec79220a05007bd70767ac2/src/db_uyariServisi.js#L409-L430 | train |
squirkle/dig-it | lib/dig.js | getProp | function getProp (obj, path, isArray) {
var next;
path = _.isString(path) ? path.split('.') : path;
// We have more traversing to do
if (path.length > 1) {
next = path.shift();
if (_.isArray(obj[next])) {
isArray = true;
var arr = _.compact(_.flatten(obj[next].map(function (el, i) {
... | javascript | function getProp (obj, path, isArray) {
var next;
path = _.isString(path) ? path.split('.') : path;
// We have more traversing to do
if (path.length > 1) {
next = path.shift();
if (_.isArray(obj[next])) {
isArray = true;
var arr = _.compact(_.flatten(obj[next].map(function (el, i) {
... | [
"function",
"getProp",
"(",
"obj",
",",
"path",
",",
"isArray",
")",
"{",
"var",
"next",
";",
"path",
"=",
"_",
".",
"isString",
"(",
"path",
")",
"?",
"path",
".",
"split",
"(",
"'.'",
")",
":",
"path",
";",
"// We have more traversing to do",
"if",
... | returns value of property at path, or array of properties if there is an array in the path | [
"returns",
"value",
"of",
"property",
"at",
"path",
"or",
"array",
"of",
"properties",
"if",
"there",
"is",
"an",
"array",
"in",
"the",
"path"
] | 471a44ba7d3bd7f12b3977522234c740a9b76ada | https://github.com/squirkle/dig-it/blob/471a44ba7d3bd7f12b3977522234c740a9b76ada/lib/dig.js#L8-L37 | train |
moov2/grunt-orchard-development | tasks/build-themes.js | function () {
var dest = path.join(options.dest, themes[count]);
// deletes theme is already exists.
if (fs.exists(dest)) {
fs.rmdir(dest);
}
mv(path.join(options.themes, themes[count], 'dist'), dest, {mkdirp: true}, function() {
... | javascript | function () {
var dest = path.join(options.dest, themes[count]);
// deletes theme is already exists.
if (fs.exists(dest)) {
fs.rmdir(dest);
}
mv(path.join(options.themes, themes[count], 'dist'), dest, {mkdirp: true}, function() {
... | [
"function",
"(",
")",
"{",
"var",
"dest",
"=",
"path",
".",
"join",
"(",
"options",
".",
"dest",
",",
"themes",
"[",
"count",
"]",
")",
";",
"// deletes theme is already exists.",
"if",
"(",
"fs",
".",
"exists",
"(",
"dest",
")",
")",
"{",
"fs",
".",... | Deletes the existing theme and copies the distributable ready theme
into position. | [
"Deletes",
"the",
"existing",
"theme",
"and",
"copies",
"the",
"distributable",
"ready",
"theme",
"into",
"position",
"."
] | 658c5bae73f894469d099a7c2d735f9cda08d0cc | https://github.com/moov2/grunt-orchard-development/blob/658c5bae73f894469d099a7c2d735f9cda08d0cc/tasks/build-themes.js#L111-L122 | train | |
vmarkdown/vremark-parse | packages/vremark-toc/mdast-util-toc/lib/search.js | search | function search(root, expression, maxDepth) {
var length = root.children.length;
var depth = null;
var lookingForToc = expression !== null;
var map = [];
var headingIndex;
var closingIndex;
if (!lookingForToc) {
headingIndex = -1;
}
slugs.reset();
/*
* Visit all h... | javascript | function search(root, expression, maxDepth) {
var length = root.children.length;
var depth = null;
var lookingForToc = expression !== null;
var map = [];
var headingIndex;
var closingIndex;
if (!lookingForToc) {
headingIndex = -1;
}
slugs.reset();
/*
* Visit all h... | [
"function",
"search",
"(",
"root",
",",
"expression",
",",
"maxDepth",
")",
"{",
"var",
"length",
"=",
"root",
".",
"children",
".",
"length",
";",
"var",
"depth",
"=",
"null",
";",
"var",
"lookingForToc",
"=",
"expression",
"!==",
"null",
";",
"var",
... | Search a node for a location.
@param {Node} root - Parent to search in.
@param {RegExp} expression - Heading-content to search
for.
@param {number} maxDepth - Maximum-depth to include.
@return {Object} - Results. | [
"Search",
"a",
"node",
"for",
"a",
"location",
"."
] | d7b353dcb5d021eeceb40f3c505ece893202db7a | https://github.com/vmarkdown/vremark-parse/blob/d7b353dcb5d021eeceb40f3c505ece893202db7a/packages/vremark-toc/mdast-util-toc/lib/search.js#L31-L98 | train |
tcrowe/opti-node-watch | src/index.js | colorErrors | function colorErrors(stdLine) {
// lazy load chalk
if (chalk === undefined) {
chalk = require("chalk");
}
return colorErrorPatterns.reduce((op, pattern) => {
const matches = pattern.exec(op);
if (matches !== null && matches.length > 0) {
op = op.replace(pattern, chalk.red(matches[0]));
}... | javascript | function colorErrors(stdLine) {
// lazy load chalk
if (chalk === undefined) {
chalk = require("chalk");
}
return colorErrorPatterns.reduce((op, pattern) => {
const matches = pattern.exec(op);
if (matches !== null && matches.length > 0) {
op = op.replace(pattern, chalk.red(matches[0]));
}... | [
"function",
"colorErrors",
"(",
"stdLine",
")",
"{",
"// lazy load chalk",
"if",
"(",
"chalk",
"===",
"undefined",
")",
"{",
"chalk",
"=",
"require",
"(",
"\"chalk\"",
")",
";",
"}",
"return",
"colorErrorPatterns",
".",
"reduce",
"(",
"(",
"op",
",",
"patt... | Take a string from stderr and color error types
@private
@method colorErrors
@param {string} stdLine
@returns {string} | [
"Take",
"a",
"string",
"from",
"stderr",
"and",
"color",
"error",
"types"
] | 70fc10ebcf7bf307b3424127b01ad41480eb7501 | https://github.com/tcrowe/opti-node-watch/blob/70fc10ebcf7bf307b3424127b01ad41480eb7501/src/index.js#L101-L116 | train |
tcrowe/opti-node-watch | src/index.js | writeError | function writeError(chunk) {
// in production give the output as-is
if (NODE_ENV === "production") {
return this.queue(chunk);
}
clearTimeout(errorTimer);
errorChunks.push(chunk.toString());
errorTimer = setTimeout(() => {
this.queue(formatErrors(errorChunks.join("")));
}, 10);
... | javascript | function writeError(chunk) {
// in production give the output as-is
if (NODE_ENV === "production") {
return this.queue(chunk);
}
clearTimeout(errorTimer);
errorChunks.push(chunk.toString());
errorTimer = setTimeout(() => {
this.queue(formatErrors(errorChunks.join("")));
}, 10);
... | [
"function",
"writeError",
"(",
"chunk",
")",
"{",
"// in production give the output as-is",
"if",
"(",
"NODE_ENV",
"===",
"\"production\"",
")",
"{",
"return",
"this",
".",
"queue",
"(",
"chunk",
")",
";",
"}",
"clearTimeout",
"(",
"errorTimer",
")",
";",
"err... | Used with through module to help us format errors and proxy
stderr output
@private
@method writeError
@param {string|buffer} chunk | [
"Used",
"with",
"through",
"module",
"to",
"help",
"us",
"format",
"errors",
"and",
"proxy",
"stderr",
"output"
] | 70fc10ebcf7bf307b3424127b01ad41480eb7501 | https://github.com/tcrowe/opti-node-watch/blob/70fc10ebcf7bf307b3424127b01ad41480eb7501/src/index.js#L233-L244 | train |
tcrowe/opti-node-watch | src/index.js | respawn | function respawn() {
if (isNil(proc) === false) {
proc.stderr.removeAllListeners();
proc.stderr.end();
proc.stderr.unpipe();
proc.stdout.removeAllListeners();
proc.stdout.end();
proc.stdout.unpipe();
proc.removeAllListeners();
proc.kill();
}
const { env } = p... | javascript | function respawn() {
if (isNil(proc) === false) {
proc.stderr.removeAllListeners();
proc.stderr.end();
proc.stderr.unpipe();
proc.stdout.removeAllListeners();
proc.stdout.end();
proc.stdout.unpipe();
proc.removeAllListeners();
proc.kill();
}
const { env } = p... | [
"function",
"respawn",
"(",
")",
"{",
"if",
"(",
"isNil",
"(",
"proc",
")",
"===",
"false",
")",
"{",
"proc",
".",
"stderr",
".",
"removeAllListeners",
"(",
")",
";",
"proc",
".",
"stderr",
".",
"end",
"(",
")",
";",
"proc",
".",
"stderr",
".",
"... | Restart the child process
@private
@method respawn | [
"Restart",
"the",
"child",
"process"
] | 70fc10ebcf7bf307b3424127b01ad41480eb7501 | https://github.com/tcrowe/opti-node-watch/blob/70fc10ebcf7bf307b3424127b01ad41480eb7501/src/index.js#L278-L328 | train |
jeandesravines/promisify | lib/helper/promisify.js | promisify | function promisify(data, prevent = false) {
let promisified;
if (typeof data === 'function') {
promisified = (...args) => new Promise((resolve, reject) => {
data.call(data, ...args.concat((error, ...args) => {
error ? reject(error) : resolve.call(data, ...args);
}));
});
} else if (ty... | javascript | function promisify(data, prevent = false) {
let promisified;
if (typeof data === 'function') {
promisified = (...args) => new Promise((resolve, reject) => {
data.call(data, ...args.concat((error, ...args) => {
error ? reject(error) : resolve.call(data, ...args);
}));
});
} else if (ty... | [
"function",
"promisify",
"(",
"data",
",",
"prevent",
"=",
"false",
")",
"{",
"let",
"promisified",
";",
"if",
"(",
"typeof",
"data",
"===",
"'function'",
")",
"{",
"promisified",
"=",
"(",
"...",
"args",
")",
"=>",
"new",
"Promise",
"(",
"(",
"resolve... | Promisify a function
@param {function|Object|string} data
@param {boolean} [prevent]
@return {function(...[*]): Promise} a function wich returns a Promise | [
"Promisify",
"a",
"function"
] | 62d09982d25d879c7d0aad57b13ebaa0a7b11723 | https://github.com/jeandesravines/promisify/blob/62d09982d25d879c7d0aad57b13ebaa0a7b11723/lib/helper/promisify.js#L13-L33 | train |
redisjs/jsr-conf | lib/decoder.js | Decoder | function Decoder(conf, options, file) {
Transform.call(this);
this._writableState.objectMode = true;
this._readableState.objectMode = true;
this.eol = options.eol;
this.conf = conf;
this.file = file;
this.lineNumber = 0;
} | javascript | function Decoder(conf, options, file) {
Transform.call(this);
this._writableState.objectMode = true;
this._readableState.objectMode = true;
this.eol = options.eol;
this.conf = conf;
this.file = file;
this.lineNumber = 0;
} | [
"function",
"Decoder",
"(",
"conf",
",",
"options",
",",
"file",
")",
"{",
"Transform",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"_writableState",
".",
"objectMode",
"=",
"true",
";",
"this",
".",
"_readableState",
".",
"objectMode",
"=",
"true",... | Configuration file decoder. | [
"Configuration",
"file",
"decoder",
"."
] | 97c5e2e77e1601c879a62dfc2d500df537eaaddd | https://github.com/redisjs/jsr-conf/blob/97c5e2e77e1601c879a62dfc2d500df537eaaddd/lib/decoder.js#L10-L20 | train |
redisjs/jsr-conf | lib/decoder.js | _transform | function _transform(chunk, encoding, cb) {
this.emit('lines', chunk);
try {
this.parse(chunk);
}catch(e) {
this.emit('error', e);
}
cb();
} | javascript | function _transform(chunk, encoding, cb) {
this.emit('lines', chunk);
try {
this.parse(chunk);
}catch(e) {
this.emit('error', e);
}
cb();
} | [
"function",
"_transform",
"(",
"chunk",
",",
"encoding",
",",
"cb",
")",
"{",
"this",
".",
"emit",
"(",
"'lines'",
",",
"chunk",
")",
";",
"try",
"{",
"this",
".",
"parse",
"(",
"chunk",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"this",
".",
... | Transform function. | [
"Transform",
"function",
"."
] | 97c5e2e77e1601c879a62dfc2d500df537eaaddd | https://github.com/redisjs/jsr-conf/blob/97c5e2e77e1601c879a62dfc2d500df537eaaddd/lib/decoder.js#L27-L38 | train |
redisjs/jsr-conf | lib/decoder.js | parse | function parse(lines) {
var i, line, key, parts, values;
for(i = 0;i < lines.length;i++) {
line = lines[i];
this.lineNumber++;
// ignore comments and whitespace lines
if(COMMENT.test(line) || WHITESPACE.test(line)) {
continue;
// got something to parse
}else{
// strip empty en... | javascript | function parse(lines) {
var i, line, key, parts, values;
for(i = 0;i < lines.length;i++) {
line = lines[i];
this.lineNumber++;
// ignore comments and whitespace lines
if(COMMENT.test(line) || WHITESPACE.test(line)) {
continue;
// got something to parse
}else{
// strip empty en... | [
"function",
"parse",
"(",
"lines",
")",
"{",
"var",
"i",
",",
"line",
",",
"key",
",",
"parts",
",",
"values",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"lines",
".",
"length",
";",
"i",
"++",
")",
"{",
"line",
"=",
"lines",
"[",
"i",
... | Synchronous line parser. | [
"Synchronous",
"line",
"parser",
"."
] | 97c5e2e77e1601c879a62dfc2d500df537eaaddd | https://github.com/redisjs/jsr-conf/blob/97c5e2e77e1601c879a62dfc2d500df537eaaddd/lib/decoder.js#L43-L73 | train |
tjmehta/mongooseware | lib/base-middleware.js | BaseMiddleware | function BaseMiddleware (Model, key) {
// constructor
var instance = function (req, res, next) {
return instance.exec()(req, res, next);
};
instance.Model = Model;
instance.methodChain = [];
instance.__proto__ = this.__proto__;
instance.setKey = function (key) {
key = key || Model.modelName.toLo... | javascript | function BaseMiddleware (Model, key) {
// constructor
var instance = function (req, res, next) {
return instance.exec()(req, res, next);
};
instance.Model = Model;
instance.methodChain = [];
instance.__proto__ = this.__proto__;
instance.setKey = function (key) {
key = key || Model.modelName.toLo... | [
"function",
"BaseMiddleware",
"(",
"Model",
",",
"key",
")",
"{",
"// constructor",
"var",
"instance",
"=",
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"return",
"instance",
".",
"exec",
"(",
")",
"(",
"req",
",",
"res",
",",
"next",
"... | uses Model and key from closure
@param {Object} Model
@param {String} key
@return {Object} | [
"uses",
"Model",
"and",
"key",
"from",
"closure"
] | c62ce0bac82880826b3528231e08f5e5b3efdb83 | https://github.com/tjmehta/mongooseware/blob/c62ce0bac82880826b3528231e08f5e5b3efdb83/lib/base-middleware.js#L18-L35 | train |
xsolon/spexplorerjs | webapi/src/components/sp/api/sp.web.js | function (url, site, ctx, loadFunc) {
return $.Deferred(function (dfd) {
ctx = ctx || SP.ClientContext.get_current();
site = site || ctx.get_site();
var web = (url) ? (typeof url == "string") ? site.openWeb(url) : url : ctx.get_web();
var res = loadFunc && loadFunc(web) || ctx.load(web);
ctx.executeQ... | javascript | function (url, site, ctx, loadFunc) {
return $.Deferred(function (dfd) {
ctx = ctx || SP.ClientContext.get_current();
site = site || ctx.get_site();
var web = (url) ? (typeof url == "string") ? site.openWeb(url) : url : ctx.get_web();
var res = loadFunc && loadFunc(web) || ctx.load(web);
ctx.executeQ... | [
"function",
"(",
"url",
",",
"site",
",",
"ctx",
",",
"loadFunc",
")",
"{",
"return",
"$",
".",
"Deferred",
"(",
"function",
"(",
"dfd",
")",
"{",
"ctx",
"=",
"ctx",
"||",
"SP",
".",
"ClientContext",
".",
"get_current",
"(",
")",
";",
"site",
"=",
... | Load an existing site
fails if site doesn't exist
@param {string} url - site relative url of web
@param {spsite} site- site reference, if null will load from current context
@param {ClientContext} ctx - SharePoint client context, if null the current context will be used
@param {function} loadFunc - function run before ... | [
"Load",
"an",
"existing",
"site",
"fails",
"if",
"site",
"doesn",
"t",
"exist"
] | 4e9b410864afb731f88e84414984fa18ac5705f1 | https://github.com/xsolon/spexplorerjs/blob/4e9b410864afb731f88e84414984fa18ac5705f1/webapi/src/components/sp/api/sp.web.js#L40-L57 | train | |
redisjs/jsr-server | lib/command/transaction/watch.js | execute | function execute(req, res) {
req.conn.watch(req.args, req.db);
res.send(null, Constants.OK);
} | javascript | function execute(req, res) {
req.conn.watch(req.args, req.db);
res.send(null, Constants.OK);
} | [
"function",
"execute",
"(",
"req",
",",
"res",
")",
"{",
"req",
".",
"conn",
".",
"watch",
"(",
"req",
".",
"args",
",",
"req",
".",
"db",
")",
";",
"res",
".",
"send",
"(",
"null",
",",
"Constants",
".",
"OK",
")",
";",
"}"
] | Respond to the WATCH command. | [
"Respond",
"to",
"the",
"WATCH",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/transaction/watch.js#L19-L22 | train |
vkiding/judpack-lib | src/cordova/platform.js | getPlatformDetailsFromDir | function getPlatformDetailsFromDir(dir, platformIfKnown){
var libDir = path.resolve(dir);
var platform;
var version;
try {
var pkg = require(path.join(libDir, 'package'));
platform = platformFromName(pkg.name);
version = pkg.version;
} catch(e) {
// Older platforms d... | javascript | function getPlatformDetailsFromDir(dir, platformIfKnown){
var libDir = path.resolve(dir);
var platform;
var version;
try {
var pkg = require(path.join(libDir, 'package'));
platform = platformFromName(pkg.name);
version = pkg.version;
} catch(e) {
// Older platforms d... | [
"function",
"getPlatformDetailsFromDir",
"(",
"dir",
",",
"platformIfKnown",
")",
"{",
"var",
"libDir",
"=",
"path",
".",
"resolve",
"(",
"dir",
")",
";",
"var",
"platform",
";",
"var",
"version",
";",
"try",
"{",
"var",
"pkg",
"=",
"require",
"(",
"path... | Returns a Promise Gets platform details from a directory | [
"Returns",
"a",
"Promise",
"Gets",
"platform",
"details",
"from",
"a",
"directory"
] | 8657cecfec68221109279106adca8dbc81f430f4 | https://github.com/vkiding/judpack-lib/blob/8657cecfec68221109279106adca8dbc81f430f4/src/cordova/platform.js#L333-L362 | train |
vkiding/judpack-lib | src/cordova/platform.js | hostSupports | function hostSupports(platform) {
var p = platforms[platform] || {},
hostos = p.hostos || null;
if (!hostos)
return true;
if (hostos.indexOf('*') >= 0)
return true;
if (hostos.indexOf(process.platform) >= 0)
return true;
return false;
} | javascript | function hostSupports(platform) {
var p = platforms[platform] || {},
hostos = p.hostos || null;
if (!hostos)
return true;
if (hostos.indexOf('*') >= 0)
return true;
if (hostos.indexOf(process.platform) >= 0)
return true;
return false;
} | [
"function",
"hostSupports",
"(",
"platform",
")",
"{",
"var",
"p",
"=",
"platforms",
"[",
"platform",
"]",
"||",
"{",
"}",
",",
"hostos",
"=",
"p",
".",
"hostos",
"||",
"null",
";",
"if",
"(",
"!",
"hostos",
")",
"return",
"true",
";",
"if",
"(",
... | Used to prevent attempts of installing platforms that are not supported on the host OS. E.g. ios on linux. | [
"Used",
"to",
"prevent",
"attempts",
"of",
"installing",
"platforms",
"that",
"are",
"not",
"supported",
"on",
"the",
"host",
"OS",
".",
"E",
".",
"g",
".",
"ios",
"on",
"linux",
"."
] | 8657cecfec68221109279106adca8dbc81f430f4 | https://github.com/vkiding/judpack-lib/blob/8657cecfec68221109279106adca8dbc81f430f4/src/cordova/platform.js#L660-L670 | train |
vivaxy/react-pianist | docs/js/common.js | mixSpecIntoComponent | function mixSpecIntoComponent(Constructor, spec) {
if (!spec) {
if (false) {
var typeofSpec = typeof spec;
var isMixinValid = typeofSpec === 'object' && spec !== null;
process.env.NODE_ENV !== 'production' ? warning(isMixinValid, '%s: You\'re attempting to include a mixin that is either n... | javascript | function mixSpecIntoComponent(Constructor, spec) {
if (!spec) {
if (false) {
var typeofSpec = typeof spec;
var isMixinValid = typeofSpec === 'object' && spec !== null;
process.env.NODE_ENV !== 'production' ? warning(isMixinValid, '%s: You\'re attempting to include a mixin that is either n... | [
"function",
"mixSpecIntoComponent",
"(",
"Constructor",
",",
"spec",
")",
"{",
"if",
"(",
"!",
"spec",
")",
"{",
"if",
"(",
"false",
")",
"{",
"var",
"typeofSpec",
"=",
"typeof",
"spec",
";",
"var",
"isMixinValid",
"=",
"typeofSpec",
"===",
"'object'",
"... | Mixin helper which handles policy validation and reserved
specification keys when building React classes. | [
"Mixin",
"helper",
"which",
"handles",
"policy",
"validation",
"and",
"reserved",
"specification",
"keys",
"when",
"building",
"React",
"classes",
"."
] | 5923bf5e67dfd011e6b034024b0b11ff8ef19300 | https://github.com/vivaxy/react-pianist/blob/5923bf5e67dfd011e6b034024b0b11ff8ef19300/docs/js/common.js#L2214-L2294 | train |
vivaxy/react-pianist | docs/js/common.js | function (event) {
var dispatchConfig = event.dispatchConfig;
if (dispatchConfig.registrationName) {
return EventPluginRegistry.registrationNameModules[dispatchConfig.registrationName] || null;
}
if (dispatchConfig.phasedRegistrationNames !== undefined) {
// pulling phasedRegistrationN... | javascript | function (event) {
var dispatchConfig = event.dispatchConfig;
if (dispatchConfig.registrationName) {
return EventPluginRegistry.registrationNameModules[dispatchConfig.registrationName] || null;
}
if (dispatchConfig.phasedRegistrationNames !== undefined) {
// pulling phasedRegistrationN... | [
"function",
"(",
"event",
")",
"{",
"var",
"dispatchConfig",
"=",
"event",
".",
"dispatchConfig",
";",
"if",
"(",
"dispatchConfig",
".",
"registrationName",
")",
"{",
"return",
"EventPluginRegistry",
".",
"registrationNameModules",
"[",
"dispatchConfig",
".",
"reg... | Looks up the plugin for the supplied event.
@param {object} event A synthetic event.
@return {?object} The plugin that created the supplied event.
@internal | [
"Looks",
"up",
"the",
"plugin",
"for",
"the",
"supplied",
"event",
"."
] | 5923bf5e67dfd011e6b034024b0b11ff8ef19300 | https://github.com/vivaxy/react-pianist/blob/5923bf5e67dfd011e6b034024b0b11ff8ef19300/docs/js/common.js#L5020-L5041 | train | |
vivaxy/react-pianist | docs/js/common.js | function () {
eventPluginOrder = null;
for (var pluginName in namesToPlugins) {
if (namesToPlugins.hasOwnProperty(pluginName)) {
delete namesToPlugins[pluginName];
}
}
EventPluginRegistry.plugins.length = 0;
var eventNameDispatchConfigs = EventPluginRegistry.eventNameDi... | javascript | function () {
eventPluginOrder = null;
for (var pluginName in namesToPlugins) {
if (namesToPlugins.hasOwnProperty(pluginName)) {
delete namesToPlugins[pluginName];
}
}
EventPluginRegistry.plugins.length = 0;
var eventNameDispatchConfigs = EventPluginRegistry.eventNameDi... | [
"function",
"(",
")",
"{",
"eventPluginOrder",
"=",
"null",
";",
"for",
"(",
"var",
"pluginName",
"in",
"namesToPlugins",
")",
"{",
"if",
"(",
"namesToPlugins",
".",
"hasOwnProperty",
"(",
"pluginName",
")",
")",
"{",
"delete",
"namesToPlugins",
"[",
"plugin... | Exposed for unit testing.
@private | [
"Exposed",
"for",
"unit",
"testing",
"."
] | 5923bf5e67dfd011e6b034024b0b11ff8ef19300 | https://github.com/vivaxy/react-pianist/blob/5923bf5e67dfd011e6b034024b0b11ff8ef19300/docs/js/common.js#L5047-L5078 | train | |
vivaxy/react-pianist | docs/js/common.js | asap | function asap(callback, context) {
!batchingStrategy.isBatchingUpdates ? false ? invariant(false, 'ReactUpdates.asap: Can\'t enqueue an asap callback in a context whereupdates are not being batched.') : _prodInvariant('125') : void 0;
asapCallbackQueue.enqueue(callback, context);
asapEnqueued = true;
} | javascript | function asap(callback, context) {
!batchingStrategy.isBatchingUpdates ? false ? invariant(false, 'ReactUpdates.asap: Can\'t enqueue an asap callback in a context whereupdates are not being batched.') : _prodInvariant('125') : void 0;
asapCallbackQueue.enqueue(callback, context);
asapEnqueued = true;
} | [
"function",
"asap",
"(",
"callback",
",",
"context",
")",
"{",
"!",
"batchingStrategy",
".",
"isBatchingUpdates",
"?",
"false",
"?",
"invariant",
"(",
"false",
",",
"'ReactUpdates.asap: Can\\'t enqueue an asap callback in a context whereupdates are not being batched.'",
")",
... | Enqueue a callback to be run at the end of the current batching cycle. Throws
if no updates are currently being performed. | [
"Enqueue",
"a",
"callback",
"to",
"be",
"run",
"at",
"the",
"end",
"of",
"the",
"current",
"batching",
"cycle",
".",
"Throws",
"if",
"no",
"updates",
"are",
"currently",
"being",
"performed",
"."
] | 5923bf5e67dfd011e6b034024b0b11ff8ef19300 | https://github.com/vivaxy/react-pianist/blob/5923bf5e67dfd011e6b034024b0b11ff8ef19300/docs/js/common.js#L6565-L6569 | train |
vivaxy/react-pianist | docs/js/common.js | unmountComponentFromNode | function unmountComponentFromNode(instance, container, safely) {
if (false) {
ReactInstrumentation.debugTool.onBeginFlush();
}
ReactReconciler.unmountComponent(instance, safely);
if (false) {
ReactInstrumentation.debugTool.onEndFlush();
}
if (container.nodeType === DOC_NODE_TYPE) {
co... | javascript | function unmountComponentFromNode(instance, container, safely) {
if (false) {
ReactInstrumentation.debugTool.onBeginFlush();
}
ReactReconciler.unmountComponent(instance, safely);
if (false) {
ReactInstrumentation.debugTool.onEndFlush();
}
if (container.nodeType === DOC_NODE_TYPE) {
co... | [
"function",
"unmountComponentFromNode",
"(",
"instance",
",",
"container",
",",
"safely",
")",
"{",
"if",
"(",
"false",
")",
"{",
"ReactInstrumentation",
".",
"debugTool",
".",
"onBeginFlush",
"(",
")",
";",
"}",
"ReactReconciler",
".",
"unmountComponent",
"(",
... | Unmounts a component and removes it from the DOM.
@param {ReactComponent} instance React component instance.
@param {DOMElement} container DOM element to unmount from.
@final
@internal
@see {ReactMount.unmountComponentAtNode} | [
"Unmounts",
"a",
"component",
"and",
"removes",
"it",
"from",
"the",
"DOM",
"."
] | 5923bf5e67dfd011e6b034024b0b11ff8ef19300 | https://github.com/vivaxy/react-pianist/blob/5923bf5e67dfd011e6b034024b0b11ff8ef19300/docs/js/common.js#L19247-L19264 | train |
vivaxy/react-pianist | docs/js/common.js | function (nextElement, container, shouldReuseMarkup, context) {
// Various parts of our code (such as ReactCompositeComponent's
// _renderValidatedComponent) assume that calls to render aren't nested;
// verify that that's the case.
false ? warning(ReactCurrentOwner.current == null, '_renderNewRoot... | javascript | function (nextElement, container, shouldReuseMarkup, context) {
// Various parts of our code (such as ReactCompositeComponent's
// _renderValidatedComponent) assume that calls to render aren't nested;
// verify that that's the case.
false ? warning(ReactCurrentOwner.current == null, '_renderNewRoot... | [
"function",
"(",
"nextElement",
",",
"container",
",",
"shouldReuseMarkup",
",",
"context",
")",
"{",
"// Various parts of our code (such as ReactCompositeComponent's",
"// _renderValidatedComponent) assume that calls to render aren't nested;",
"// verify that that's the case.",
"false",... | Render a new component into the DOM. Hooked by hooks!
@param {ReactElement} nextElement element to render
@param {DOMElement} container container to render into
@param {boolean} shouldReuseMarkup if we should skip the markup insertion
@return {ReactComponent} nextComponent | [
"Render",
"a",
"new",
"component",
"into",
"the",
"DOM",
".",
"Hooked",
"by",
"hooks!"
] | 5923bf5e67dfd011e6b034024b0b11ff8ef19300 | https://github.com/vivaxy/react-pianist/blob/5923bf5e67dfd011e6b034024b0b11ff8ef19300/docs/js/common.js#L19413-L19434 | train | |
vivaxy/react-pianist | docs/js/common.js | dispatch | function dispatch(action) {
if (!(0, _isPlainObject2['default'])(action)) {
throw new Error('Actions must be plain objects. ' + 'Use custom middleware for async actions.');
}
if (typeof action.type === 'undefined') {
throw new Error('Actions may not have an undefined "type" property. ' + ... | javascript | function dispatch(action) {
if (!(0, _isPlainObject2['default'])(action)) {
throw new Error('Actions must be plain objects. ' + 'Use custom middleware for async actions.');
}
if (typeof action.type === 'undefined') {
throw new Error('Actions may not have an undefined "type" property. ' + ... | [
"function",
"dispatch",
"(",
"action",
")",
"{",
"if",
"(",
"!",
"(",
"0",
",",
"_isPlainObject2",
"[",
"'default'",
"]",
")",
"(",
"action",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Actions must be plain objects. '",
"+",
"'Use custom middleware for asy... | Dispatches an action. It is the only way to trigger a state change.
The `reducer` function, used to create the store, will be called with the
current state tree and the given `action`. Its return value will
be considered the **next** state of the tree, and the change listeners
will be notified.
The base implementatio... | [
"Dispatches",
"an",
"action",
".",
"It",
"is",
"the",
"only",
"way",
"to",
"trigger",
"a",
"state",
"change",
"."
] | 5923bf5e67dfd011e6b034024b0b11ff8ef19300 | https://github.com/vivaxy/react-pianist/blob/5923bf5e67dfd011e6b034024b0b11ff8ef19300/docs/js/common.js#L20746-L20772 | train |
redisjs/jsr-conf | lib/configuration.js | Configuration | function Configuration(options, parent) {
options = options || {};
this.options = options;
// delimiter used to split and join lines
this.options.eol = options.eol || EOL;
// parent reference - used by includes
this._parent = parent;
// file path to primary configuration file loaded
this._file = null... | javascript | function Configuration(options, parent) {
options = options || {};
this.options = options;
// delimiter used to split and join lines
this.options.eol = options.eol || EOL;
// parent reference - used by includes
this._parent = parent;
// file path to primary configuration file loaded
this._file = null... | [
"function",
"Configuration",
"(",
"options",
",",
"parent",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"options",
"=",
"options",
";",
"// delimiter used to split and join lines",
"this",
".",
"options",
".",
"eol",
"=",
"options",
... | Encapsulates a configuration file.
Fields are exposed on this instance as public properties
for easy read access, however writing should be performed using
the set() method to ensure the document knows which config parameters
have been changed.
@param options Configuration options.
@param parent A parent configuratio... | [
"Encapsulates",
"a",
"configuration",
"file",
"."
] | 97c5e2e77e1601c879a62dfc2d500df537eaaddd | https://github.com/redisjs/jsr-conf/blob/97c5e2e77e1601c879a62dfc2d500df537eaaddd/lib/configuration.js#L32-L69 | train |
redisjs/jsr-conf | lib/configuration.js | get | function get(key, stringify) {
var val = this._data[key] ? this._data[key].value :
(DEFAULTS[key] !== undefined ? DEFAULTS[key] : undefined);
if(val === undefined) return null;
if(stringify) {
val = this.encode(key, val, true);
}
return val;
} | javascript | function get(key, stringify) {
var val = this._data[key] ? this._data[key].value :
(DEFAULTS[key] !== undefined ? DEFAULTS[key] : undefined);
if(val === undefined) return null;
if(stringify) {
val = this.encode(key, val, true);
}
return val;
} | [
"function",
"get",
"(",
"key",
",",
"stringify",
")",
"{",
"var",
"val",
"=",
"this",
".",
"_data",
"[",
"key",
"]",
"?",
"this",
".",
"_data",
"[",
"key",
"]",
".",
"value",
":",
"(",
"DEFAULTS",
"[",
"key",
"]",
"!==",
"undefined",
"?",
"DEFAUL... | Get a configuration property.
@param key The configuration key.
@param stringify Whether to coerce the value to a string. | [
"Get",
"a",
"configuration",
"property",
"."
] | 97c5e2e77e1601c879a62dfc2d500df537eaaddd | https://github.com/redisjs/jsr-conf/blob/97c5e2e77e1601c879a62dfc2d500df537eaaddd/lib/configuration.js#L115-L124 | train |
redisjs/jsr-conf | lib/configuration.js | validate | function validate(key, values) {
var typedef, value;
if(!~Keys.indexOf(key)) {
throw new Error('unknown configuration key: ' + key);
}
// retrieve the type definition
typedef = Types[key];
// validate on the typedef
try {
value = typedef.validate(key, values);
}catch(e) {
// got a more sp... | javascript | function validate(key, values) {
var typedef, value;
if(!~Keys.indexOf(key)) {
throw new Error('unknown configuration key: ' + key);
}
// retrieve the type definition
typedef = Types[key];
// validate on the typedef
try {
value = typedef.validate(key, values);
}catch(e) {
// got a more sp... | [
"function",
"validate",
"(",
"key",
",",
"values",
")",
"{",
"var",
"typedef",
",",
"value",
";",
"if",
"(",
"!",
"~",
"Keys",
".",
"indexOf",
"(",
"key",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'unknown configuration key: '",
"+",
"key",
")",
... | Validate a key and array of values.
@param key The configuration key.
@param values The array of string values. | [
"Validate",
"a",
"key",
"and",
"array",
"of",
"values",
"."
] | 97c5e2e77e1601c879a62dfc2d500df537eaaddd | https://github.com/redisjs/jsr-conf/blob/97c5e2e77e1601c879a62dfc2d500df537eaaddd/lib/configuration.js#L132-L155 | train |
redisjs/jsr-conf | lib/configuration.js | onLoad | function onLoad() {
var k, o, v;
for(k in this._data) {
o = this._data[k];
v = o.value;
try {
this.verify(k, v);
if(k === Types.SLAVEOF) {
if(this.get(Types.CLUSTER_ENABLED) && v) {
throw new Error('slaveof directive not allowed in cluster mode');
}
}
}ca... | javascript | function onLoad() {
var k, o, v;
for(k in this._data) {
o = this._data[k];
v = o.value;
try {
this.verify(k, v);
if(k === Types.SLAVEOF) {
if(this.get(Types.CLUSTER_ENABLED) && v) {
throw new Error('slaveof directive not allowed in cluster mode');
}
}
}ca... | [
"function",
"onLoad",
"(",
")",
"{",
"var",
"k",
",",
"o",
",",
"v",
";",
"for",
"(",
"k",
"in",
"this",
".",
"_data",
")",
"{",
"o",
"=",
"this",
".",
"_data",
"[",
"k",
"]",
";",
"v",
"=",
"o",
".",
"value",
";",
"try",
"{",
"this",
"."... | Post load validation. | [
"Post",
"load",
"validation",
"."
] | 97c5e2e77e1601c879a62dfc2d500df537eaaddd | https://github.com/redisjs/jsr-conf/blob/97c5e2e77e1601c879a62dfc2d500df537eaaddd/lib/configuration.js#L180-L200 | train |
redisjs/jsr-conf | lib/configuration.js | set | function set(key, value, lineno, child) {
// keys can be passed as buffers
// we need a string
key = '' + key;
//console.error('%s=%s', key, value);
var typedef = Types[key]
, exists = this._data[key]
, val = exists || {value: null, lineno: !child ? lineno : undefined}
, changed = false;
if(!l... | javascript | function set(key, value, lineno, child) {
// keys can be passed as buffers
// we need a string
key = '' + key;
//console.error('%s=%s', key, value);
var typedef = Types[key]
, exists = this._data[key]
, val = exists || {value: null, lineno: !child ? lineno : undefined}
, changed = false;
if(!l... | [
"function",
"set",
"(",
"key",
",",
"value",
",",
"lineno",
",",
"child",
")",
"{",
"// keys can be passed as buffers",
"// we need a string",
"key",
"=",
"''",
"+",
"key",
";",
"//console.error('%s=%s', key, value);",
"var",
"typedef",
"=",
"Types",
"[",
"key",
... | Update the in-memory configuration.
Designed to be used by CONFIG SET the key should already
have been validated.
Internally when adding keys first time around a lineno specifies
where in the file the declaration is, otherwise when modifying via
CONFIG SET a lineno should not be specified and the key is tracked
as ha... | [
"Update",
"the",
"in",
"-",
"memory",
"configuration",
"."
] | 97c5e2e77e1601c879a62dfc2d500df537eaaddd | https://github.com/redisjs/jsr-conf/blob/97c5e2e77e1601c879a62dfc2d500df537eaaddd/lib/configuration.js#L221-L287 | train |
redisjs/jsr-conf | lib/configuration.js | directives | function directives(def) {
// mock line number for error messages
var lineno = 1
, k
, v
// inline directive, not from a file
, file = 'directive override (argv)';
function addDirective(k, v) {
// must be strings split into an array
// they are parsed and validated
v = ('' + v).split(... | javascript | function directives(def) {
// mock line number for error messages
var lineno = 1
, k
, v
// inline directive, not from a file
, file = 'directive override (argv)';
function addDirective(k, v) {
// must be strings split into an array
// they are parsed and validated
v = ('' + v).split(... | [
"function",
"directives",
"(",
"def",
")",
"{",
"// mock line number for error messages",
"var",
"lineno",
"=",
"1",
",",
"k",
",",
"v",
"// inline directive, not from a file",
",",
"file",
"=",
"'directive override (argv)'",
";",
"function",
"addDirective",
"(",
"k",... | Merge configuration directive overrides into this instance.
Should be invoked after the file and all includes have been loaded
and parsed.
@param def An object containing key value configuration pairs. | [
"Merge",
"configuration",
"directive",
"overrides",
"into",
"this",
"instance",
"."
] | 97c5e2e77e1601c879a62dfc2d500df537eaaddd | https://github.com/redisjs/jsr-conf/blob/97c5e2e77e1601c879a62dfc2d500df537eaaddd/lib/configuration.js#L297-L331 | train |
redisjs/jsr-conf | lib/configuration.js | load | function load(opts, cb) {
if(typeof opts === 'function') {
cb = opts;
opts = undefined;
}
if(typeof opts === 'string') {
file = opts;
}else if(typeof opts === 'object') {
file = opts.file;
}
if(file === undefined) file = DEFAULT_FILE;
var sync = typeof cb !== 'function'
, stream
... | javascript | function load(opts, cb) {
if(typeof opts === 'function') {
cb = opts;
opts = undefined;
}
if(typeof opts === 'string') {
file = opts;
}else if(typeof opts === 'object') {
file = opts.file;
}
if(file === undefined) file = DEFAULT_FILE;
var sync = typeof cb !== 'function'
, stream
... | [
"function",
"load",
"(",
"opts",
",",
"cb",
")",
"{",
"if",
"(",
"typeof",
"opts",
"===",
"'function'",
")",
"{",
"cb",
"=",
"opts",
";",
"opts",
"=",
"undefined",
";",
"}",
"if",
"(",
"typeof",
"opts",
"===",
"'string'",
")",
"{",
"file",
"=",
"... | Read a file and pipe it to a decoder. | [
"Read",
"a",
"file",
"and",
"pipe",
"it",
"to",
"a",
"decoder",
"."
] | 97c5e2e77e1601c879a62dfc2d500df537eaaddd | https://github.com/redisjs/jsr-conf/blob/97c5e2e77e1601c879a62dfc2d500df537eaaddd/lib/configuration.js#L336-L425 | train |
redisjs/jsr-conf | lib/configuration.js | write | function write(file, cb) {
if(file === undefined) file = this._file;
if(file === DEFAULT_FILE) {
return this.emit(
'error', new Error('cannot write to default configuration'));
}
var sync = typeof cb !== 'function'
, stream
, save
, encoder = new Encoder(this.options)
, lines = this.... | javascript | function write(file, cb) {
if(file === undefined) file = this._file;
if(file === DEFAULT_FILE) {
return this.emit(
'error', new Error('cannot write to default configuration'));
}
var sync = typeof cb !== 'function'
, stream
, save
, encoder = new Encoder(this.options)
, lines = this.... | [
"function",
"write",
"(",
"file",
",",
"cb",
")",
"{",
"if",
"(",
"file",
"===",
"undefined",
")",
"file",
"=",
"this",
".",
"_file",
";",
"if",
"(",
"file",
"===",
"DEFAULT_FILE",
")",
"{",
"return",
"this",
".",
"emit",
"(",
"'error'",
",",
"new"... | Write the in-memory configuration to a file or stream. | [
"Write",
"the",
"in",
"-",
"memory",
"configuration",
"to",
"a",
"file",
"or",
"stream",
"."
] | 97c5e2e77e1601c879a62dfc2d500df537eaaddd | https://github.com/redisjs/jsr-conf/blob/97c5e2e77e1601c879a62dfc2d500df537eaaddd/lib/configuration.js#L430-L537 | train |
redisjs/jsr-conf | lib/configuration.js | writeLines | function writeLines() {
var chunk = lines.slice(i * size, (i * size) + size);
// all done
if(!chunk.length) {
return encoder.end();
}
// ensure we get correct line break between
// line chunks, the encoder joins lines on EOL
// this means that the last line in the chunk array
// ... | javascript | function writeLines() {
var chunk = lines.slice(i * size, (i * size) + size);
// all done
if(!chunk.length) {
return encoder.end();
}
// ensure we get correct line break between
// line chunks, the encoder joins lines on EOL
// this means that the last line in the chunk array
// ... | [
"function",
"writeLines",
"(",
")",
"{",
"var",
"chunk",
"=",
"lines",
".",
"slice",
"(",
"i",
"*",
"size",
",",
"(",
"i",
"*",
"size",
")",
"+",
"size",
")",
";",
"// all done",
"if",
"(",
"!",
"chunk",
".",
"length",
")",
"{",
"return",
"encode... | split the work for larger config files | [
"split",
"the",
"work",
"for",
"larger",
"config",
"files"
] | 97c5e2e77e1601c879a62dfc2d500df537eaaddd | https://github.com/redisjs/jsr-conf/blob/97c5e2e77e1601c879a62dfc2d500df537eaaddd/lib/configuration.js#L513-L533 | train |
meltmedia/node-usher | lib/decider/version.js | handleFailure | function handleFailure(err) {
// Respond back to SWF failing the workflow
winston.log('error', 'An problem occured in the execution of workflow: %s, failing due to: ', self.name, err.stack);
decisionTask.response.fail('Workflow failed', err, function (err) {
if (err) {
winston.log('error', 'Un... | javascript | function handleFailure(err) {
// Respond back to SWF failing the workflow
winston.log('error', 'An problem occured in the execution of workflow: %s, failing due to: ', self.name, err.stack);
decisionTask.response.fail('Workflow failed', err, function (err) {
if (err) {
winston.log('error', 'Un... | [
"function",
"handleFailure",
"(",
"err",
")",
"{",
"// Respond back to SWF failing the workflow",
"winston",
".",
"log",
"(",
"'error'",
",",
"'An problem occured in the execution of workflow: %s, failing due to: '",
",",
"self",
".",
"name",
",",
"err",
".",
"stack",
")"... | When something goes wrong and we can't make a decision | [
"When",
"something",
"goes",
"wrong",
"and",
"we",
"can",
"t",
"make",
"a",
"decision"
] | fe6183bf7097f84bef935e8d9c19463accc08ad6 | https://github.com/meltmedia/node-usher/blob/fe6183bf7097f84bef935e8d9c19463accc08ad6/lib/decider/version.js#L106-L115 | train |
meltmedia/node-usher | lib/decider/version.js | handleSuccess | function handleSuccess() {
// If any activities failed, we need to fail the workflow
if (context.failed()) {
winston.log('warn', 'One of more activities failed in workflow: %s, marking workflow as failed', self.name);
// Respond back to SWF failing the workflow
decisionTask.response.fail('Ac... | javascript | function handleSuccess() {
// If any activities failed, we need to fail the workflow
if (context.failed()) {
winston.log('warn', 'One of more activities failed in workflow: %s, marking workflow as failed', self.name);
// Respond back to SWF failing the workflow
decisionTask.response.fail('Ac... | [
"function",
"handleSuccess",
"(",
")",
"{",
"// If any activities failed, we need to fail the workflow",
"if",
"(",
"context",
".",
"failed",
"(",
")",
")",
"{",
"winston",
".",
"log",
"(",
"'warn'",
",",
"'One of more activities failed in workflow: %s, marking workflow as ... | When we have made a decision | [
"When",
"we",
"have",
"made",
"a",
"decision"
] | fe6183bf7097f84bef935e8d9c19463accc08ad6 | https://github.com/meltmedia/node-usher/blob/fe6183bf7097f84bef935e8d9c19463accc08ad6/lib/decider/version.js#L118-L160 | train |
cdaringe/mock-package-install | src/index.js | function (opts) {
opts = opts || {}
opts = defaults(opts, {
nodeModulesDir: path.resolve(process.cwd(), 'node_modules'),
package: rpkg.gen(opts.package)
})
fs.mkdirpSync(path.resolve(opts.nodeModulesDir, opts.package.name))
fs.writeFileSync(
path.resolve(opts.nodeModulesDir, opts.p... | javascript | function (opts) {
opts = opts || {}
opts = defaults(opts, {
nodeModulesDir: path.resolve(process.cwd(), 'node_modules'),
package: rpkg.gen(opts.package)
})
fs.mkdirpSync(path.resolve(opts.nodeModulesDir, opts.package.name))
fs.writeFileSync(
path.resolve(opts.nodeModulesDir, opts.p... | [
"function",
"(",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
"opts",
"=",
"defaults",
"(",
"opts",
",",
"{",
"nodeModulesDir",
":",
"path",
".",
"resolve",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"'node_modules'",
")",
",",
"package",
... | Installs mock package into node_modules & updates the corresponding package.json file
@param {object} opts
@param {object} [opts.package] JS object package.json. random package used if none provided
@param {string} [opts.nodeModulesDir] path to node_modules dir to install mock package into. looks for cwd/node_modules b... | [
"Installs",
"mock",
"package",
"into",
"node_modules",
"&",
"updates",
"the",
"corresponding",
"package",
".",
"json",
"file"
] | a4c6561a6b2c538dd727447b11fdc3d18cdb3feb | https://github.com/cdaringe/mock-package-install/blob/a4c6561a6b2c538dd727447b11fdc3d18cdb3feb/src/index.js#L29-L48 | train | |
cdaringe/mock-package-install | src/index.js | function (opts) {
var name
if (opts && opts.name) name = opts.name
if (opts && opts.package && opts.package.name) name = opts.package.name
if (!name) throw new TypeError('package name missing')
opts = defaults(opts, {
nodeModulesDir: path.resolve(process.cwd(), 'node_modules')
})
fs.re... | javascript | function (opts) {
var name
if (opts && opts.name) name = opts.name
if (opts && opts.package && opts.package.name) name = opts.package.name
if (!name) throw new TypeError('package name missing')
opts = defaults(opts, {
nodeModulesDir: path.resolve(process.cwd(), 'node_modules')
})
fs.re... | [
"function",
"(",
"opts",
")",
"{",
"var",
"name",
"if",
"(",
"opts",
"&&",
"opts",
".",
"name",
")",
"name",
"=",
"opts",
".",
"name",
"if",
"(",
"opts",
"&&",
"opts",
".",
"package",
"&&",
"opts",
".",
"package",
".",
"name",
")",
"name",
"=",
... | remove mock package
@param {object} opts
@param {string} opts.name package name to remove
@param {string} [opts.package.name] may be used instead of opts.name for consistency w/ install API
@param {string} [opts.nodeModulesDir] path to node_modules dir
@param {string} [opts.targetPackage] path to package.json file to u... | [
"remove",
"mock",
"package"
] | a4c6561a6b2c538dd727447b11fdc3d18cdb3feb | https://github.com/cdaringe/mock-package-install/blob/a4c6561a6b2c538dd727447b11fdc3d18cdb3feb/src/index.js#L59-L74 | train | |
redisjs/jsr-store | lib/type/zset.js | SortedSet | function SortedSet(source) {
HashMap.call(this);
this._rtype = TYPE_NAMES.ZSET;
if(source) {
for(var k in source) {
this.setKey(k, source[k]);
}
}
} | javascript | function SortedSet(source) {
HashMap.call(this);
this._rtype = TYPE_NAMES.ZSET;
if(source) {
for(var k in source) {
this.setKey(k, source[k]);
}
}
} | [
"function",
"SortedSet",
"(",
"source",
")",
"{",
"HashMap",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"_rtype",
"=",
"TYPE_NAMES",
".",
"ZSET",
";",
"if",
"(",
"source",
")",
"{",
"for",
"(",
"var",
"k",
"in",
"source",
")",
"{",
"this",
... | Represents the sorted set type. | [
"Represents",
"the",
"sorted",
"set",
"type",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/type/zset.js#L11-L19 | train |
redisjs/jsr-store | lib/type/zset.js | zadd | function zadd(members) {
var i
, c = 0
, score
, member;
for(i = 0;i < members.length;i+=2) {
score = members[i];
if(INFINITY[score] !== undefined) {
score = INFINITY[score];
}
member = members[i + 1];
if(this.zrank(member) === null) {
c++;
}
// this will add or u... | javascript | function zadd(members) {
var i
, c = 0
, score
, member;
for(i = 0;i < members.length;i+=2) {
score = members[i];
if(INFINITY[score] !== undefined) {
score = INFINITY[score];
}
member = members[i + 1];
if(this.zrank(member) === null) {
c++;
}
// this will add or u... | [
"function",
"zadd",
"(",
"members",
")",
"{",
"var",
"i",
",",
"c",
"=",
"0",
",",
"score",
",",
"member",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"members",
".",
"length",
";",
"i",
"+=",
"2",
")",
"{",
"score",
"=",
"members",
"[",
... | Adds all the specified members with the specified
scores to the sorted set. | [
"Adds",
"all",
"the",
"specified",
"members",
"with",
"the",
"specified",
"scores",
"to",
"the",
"sorted",
"set",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/type/zset.js#L27-L45 | train |
redisjs/jsr-store | lib/type/zset.js | zrem | function zrem(members) {
var i
, c = 0;
for(i = 0;i < members.length;i++) {
c += this.delKey(members[i]);
}
return c;
} | javascript | function zrem(members) {
var i
, c = 0;
for(i = 0;i < members.length;i++) {
c += this.delKey(members[i]);
}
return c;
} | [
"function",
"zrem",
"(",
"members",
")",
"{",
"var",
"i",
",",
"c",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"members",
".",
"length",
";",
"i",
"++",
")",
"{",
"c",
"+=",
"this",
".",
"delKey",
"(",
"members",
"[",
"i",
"]"... | Removes the specified members from the sorted set. | [
"Removes",
"the",
"specified",
"members",
"from",
"the",
"sorted",
"set",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/type/zset.js#L50-L57 | train |
redisjs/jsr-store | lib/type/zset.js | zrank | function zrank(member) {
if(this._data[member] === undefined) return null;
for(var i = 0;i < this._keys.length;i++) {
if(this.memberEqual(member, this._keys[i].m)) {
return i;
}
}
return null;
} | javascript | function zrank(member) {
if(this._data[member] === undefined) return null;
for(var i = 0;i < this._keys.length;i++) {
if(this.memberEqual(member, this._keys[i].m)) {
return i;
}
}
return null;
} | [
"function",
"zrank",
"(",
"member",
")",
"{",
"if",
"(",
"this",
".",
"_data",
"[",
"member",
"]",
"===",
"undefined",
")",
"return",
"null",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"_keys",
".",
"length",
";",
"i",
"... | Returns the rank of member in the sorted set. | [
"Returns",
"the",
"rank",
"of",
"member",
"in",
"the",
"sorted",
"set",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/type/zset.js#L69-L77 | train |
redisjs/jsr-store | lib/type/zset.js | zincrby | function zincrby(increment, member) {
var score = parseFloat(this._data[member]) || 0;
score += parseFloat(increment);
this.setKey(member, score);
return score;
} | javascript | function zincrby(increment, member) {
var score = parseFloat(this._data[member]) || 0;
score += parseFloat(increment);
this.setKey(member, score);
return score;
} | [
"function",
"zincrby",
"(",
"increment",
",",
"member",
")",
"{",
"var",
"score",
"=",
"parseFloat",
"(",
"this",
".",
"_data",
"[",
"member",
"]",
")",
"||",
"0",
";",
"score",
"+=",
"parseFloat",
"(",
"increment",
")",
";",
"this",
".",
"setKey",
"... | Increments the score of member by increment. | [
"Increments",
"the",
"score",
"of",
"member",
"by",
"increment",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/type/zset.js#L105-L110 | train |
redisjs/jsr-server | lib/command/server/config.js | set | function set(req, res) {
var key = '' + req.args[0]
, value = req.args[1];
// already validated the config key/value so should be ok
// to update the in-memory config, some config verification
// methods perform side-effects, eg: dir
this.conf.set(key, value);
res.send(null, Constants.OK);
if(key ===... | javascript | function set(req, res) {
var key = '' + req.args[0]
, value = req.args[1];
// already validated the config key/value so should be ok
// to update the in-memory config, some config verification
// methods perform side-effects, eg: dir
this.conf.set(key, value);
res.send(null, Constants.OK);
if(key ===... | [
"function",
"set",
"(",
"req",
",",
"res",
")",
"{",
"var",
"key",
"=",
"''",
"+",
"req",
".",
"args",
"[",
"0",
"]",
",",
"value",
"=",
"req",
".",
"args",
"[",
"1",
"]",
";",
"// already validated the config key/value so should be ok",
"// to update the ... | Respond to the SET subcommand. | [
"Respond",
"to",
"the",
"SET",
"subcommand",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/config.js#L41-L53 | train |
redisjs/jsr-server | lib/command/server/config.js | rewrite | function rewrite(req, res) {
/* istanbul ignore next: tough to mock fs write error */
function onError(err) {
this.conf.removeAllListeners('error');
this.conf.removeAllListeners('write');
res.send(err);
}
function onWrite() {
this.conf.removeAllListeners('error');
this.conf.removeAllListen... | javascript | function rewrite(req, res) {
/* istanbul ignore next: tough to mock fs write error */
function onError(err) {
this.conf.removeAllListeners('error');
this.conf.removeAllListeners('write');
res.send(err);
}
function onWrite() {
this.conf.removeAllListeners('error');
this.conf.removeAllListen... | [
"function",
"rewrite",
"(",
"req",
",",
"res",
")",
"{",
"/* istanbul ignore next: tough to mock fs write error */",
"function",
"onError",
"(",
"err",
")",
"{",
"this",
".",
"conf",
".",
"removeAllListeners",
"(",
"'error'",
")",
";",
"this",
".",
"conf",
".",
... | Respond to the REWRITE subcommand. | [
"Respond",
"to",
"the",
"REWRITE",
"subcommand",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/config.js#L58-L75 | train |
redisjs/jsr-server | lib/command/server/config.js | resetstat | function resetstat(req, res) {
this.stats.reset();
res.send(null, Constants.OK);
} | javascript | function resetstat(req, res) {
this.stats.reset();
res.send(null, Constants.OK);
} | [
"function",
"resetstat",
"(",
"req",
",",
"res",
")",
"{",
"this",
".",
"stats",
".",
"reset",
"(",
")",
";",
"res",
".",
"send",
"(",
"null",
",",
"Constants",
".",
"OK",
")",
";",
"}"
] | Respond to the RESETSTAT subcommand. | [
"Respond",
"to",
"the",
"RESETSTAT",
"subcommand",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/config.js#L80-L83 | train |
redisjs/jsr-server | lib/command/server/config.js | validate | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var sub = info.command.sub
, cmd = '' + sub.cmd
, args = sub.args
, key
, val
, verified;
if(cmd === Constants.SUBCOMMAND.config.set.name) {
key = '' + args[0];
val = '' + args[1];
// ... | javascript | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var sub = info.command.sub
, cmd = '' + sub.cmd
, args = sub.args
, key
, val
, verified;
if(cmd === Constants.SUBCOMMAND.config.set.name) {
key = '' + args[0];
val = '' + args[1];
// ... | [
"function",
"validate",
"(",
"cmd",
",",
"args",
",",
"info",
")",
"{",
"AbstractCommand",
".",
"prototype",
".",
"validate",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"var",
"sub",
"=",
"info",
".",
"command",
".",
"sub",
",",
"cmd",
"=... | Validate the CONFIG subcommands. | [
"Validate",
"the",
"CONFIG",
"subcommands",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/config.js#L88-L126 | train |
psnider/tv4-via-typenames | amd/tv4-via-typenames.js | registerSchema | function registerSchema(schema) {
var typename = getTypenameFromSchemaID(schema.id);
var registered_schema = tv4.getSchema(schema.id);
if (registered_schema == null) {
var is_draft_schema = (schema.id === exports.DRAFT_SCHEMA_ID);
if (!is_draft_schema) {
i... | javascript | function registerSchema(schema) {
var typename = getTypenameFromSchemaID(schema.id);
var registered_schema = tv4.getSchema(schema.id);
if (registered_schema == null) {
var is_draft_schema = (schema.id === exports.DRAFT_SCHEMA_ID);
if (!is_draft_schema) {
i... | [
"function",
"registerSchema",
"(",
"schema",
")",
"{",
"var",
"typename",
"=",
"getTypenameFromSchemaID",
"(",
"schema",
".",
"id",
")",
";",
"var",
"registered_schema",
"=",
"tv4",
".",
"getSchema",
"(",
"schema",
".",
"id",
")",
";",
"if",
"(",
"register... | Regisiter the schema with the schema validation system. The schema is validated by this function, and registered only if it is valid. If a schema with this schema's typename has already been registered, then this returns true with no other action. @return true if successful, or if the schema had already been registered... | [
"Regisiter",
"the",
"schema",
"with",
"the",
"schema",
"validation",
"system",
".",
"The",
"schema",
"is",
"validated",
"by",
"this",
"function",
"and",
"registered",
"only",
"if",
"it",
"is",
"valid",
".",
"If",
"a",
"schema",
"with",
"this",
"schema",
"s... | 15a19de0a0fd2adf9f8a31d15103fbe28efa83c9 | https://github.com/psnider/tv4-via-typenames/blob/15a19de0a0fd2adf9f8a31d15103fbe28efa83c9/amd/tv4-via-typenames.js#L60-L89 | train |
psnider/tv4-via-typenames | amd/tv4-via-typenames.js | tv4_validate | function tv4_validate(typename, query) {
var id = getSchemaIDFromTypename(typename);
var schema = tv4.getSchema(id);
if (schema == null) {
var error = { code: 0, message: 'Schema not found', dataPath: '', schemaPath: id };
return { valid: false, missing: [], errors: [erro... | javascript | function tv4_validate(typename, query) {
var id = getSchemaIDFromTypename(typename);
var schema = tv4.getSchema(id);
if (schema == null) {
var error = { code: 0, message: 'Schema not found', dataPath: '', schemaPath: id };
return { valid: false, missing: [], errors: [erro... | [
"function",
"tv4_validate",
"(",
"typename",
",",
"query",
")",
"{",
"var",
"id",
"=",
"getSchemaIDFromTypename",
"(",
"typename",
")",
";",
"var",
"schema",
"=",
"tv4",
".",
"getSchema",
"(",
"id",
")",
";",
"if",
"(",
"schema",
"==",
"null",
")",
"{"... | Validate the given JSON against the schema for typename. | [
"Validate",
"the",
"given",
"JSON",
"against",
"the",
"schema",
"for",
"typename",
"."
] | 15a19de0a0fd2adf9f8a31d15103fbe28efa83c9 | https://github.com/psnider/tv4-via-typenames/blob/15a19de0a0fd2adf9f8a31d15103fbe28efa83c9/amd/tv4-via-typenames.js#L91-L100 | train |
psnider/tv4-via-typenames | amd/tv4-via-typenames.js | tv4_validateSchema | function tv4_validateSchema(schema) {
var is_draft_schema = (schema.id === exports.DRAFT_SCHEMA_ID);
var draft_schema = (is_draft_schema) ? schema : tv4.getSchema(exports.DRAFT_SCHEMA_ID);
var report = tv4.validateMultiple(schema, draft_schema);
return report;
} | javascript | function tv4_validateSchema(schema) {
var is_draft_schema = (schema.id === exports.DRAFT_SCHEMA_ID);
var draft_schema = (is_draft_schema) ? schema : tv4.getSchema(exports.DRAFT_SCHEMA_ID);
var report = tv4.validateMultiple(schema, draft_schema);
return report;
} | [
"function",
"tv4_validateSchema",
"(",
"schema",
")",
"{",
"var",
"is_draft_schema",
"=",
"(",
"schema",
".",
"id",
"===",
"exports",
".",
"DRAFT_SCHEMA_ID",
")",
";",
"var",
"draft_schema",
"=",
"(",
"is_draft_schema",
")",
"?",
"schema",
":",
"tv4",
".",
... | Validate the given schema. | [
"Validate",
"the",
"given",
"schema",
"."
] | 15a19de0a0fd2adf9f8a31d15103fbe28efa83c9 | https://github.com/psnider/tv4-via-typenames/blob/15a19de0a0fd2adf9f8a31d15103fbe28efa83c9/amd/tv4-via-typenames.js#L102-L107 | train |
kristianmandrup/ai-core | lib/utils/io.js | mutateJsonFile | function mutateJsonFile(targetPath, source, mutator) {
if (!mutator) {
mutator = source;
source = null;
}
let sourceConfig = source;
try {
// console.log('targetPath', targetPath);
let targetConfig = readJson(targetPath);
// console.log('source', source);
if (typeof source === 'string'... | javascript | function mutateJsonFile(targetPath, source, mutator) {
if (!mutator) {
mutator = source;
source = null;
}
let sourceConfig = source;
try {
// console.log('targetPath', targetPath);
let targetConfig = readJson(targetPath);
// console.log('source', source);
if (typeof source === 'string'... | [
"function",
"mutateJsonFile",
"(",
"targetPath",
",",
"source",
",",
"mutator",
")",
"{",
"if",
"(",
"!",
"mutator",
")",
"{",
"mutator",
"=",
"source",
";",
"source",
"=",
"null",
";",
"}",
"let",
"sourceConfig",
"=",
"source",
";",
"try",
"{",
"// co... | source must be a filePath to a json file or an Object | [
"source",
"must",
"be",
"a",
"filePath",
"to",
"a",
"json",
"file",
"or",
"an",
"Object"
] | c8968c44b4149a157f2e47c7051805ffc7bd99ed | https://github.com/kristianmandrup/ai-core/blob/c8968c44b4149a157f2e47c7051805ffc7bd99ed/lib/utils/io.js#L101-L127 | train |
skerit/alchemy-menu | assets/scripts/menu/menu_manager.js | detree | function detree(items, children, parent_id) {
var item,
i;
for (i = 0; i < children.length; i++) {
item = children[i];
if (parent_id) {
item.parent = parent_id;
}
items.push(item);
if (item.children) {
detree(items, item.children, item.id);
}
delete item.children;
}
} | javascript | function detree(items, children, parent_id) {
var item,
i;
for (i = 0; i < children.length; i++) {
item = children[i];
if (parent_id) {
item.parent = parent_id;
}
items.push(item);
if (item.children) {
detree(items, item.children, item.id);
}
delete item.children;
}
} | [
"function",
"detree",
"(",
"items",
",",
"children",
",",
"parent_id",
")",
"{",
"var",
"item",
",",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"children",
".",
"length",
";",
"i",
"++",
")",
"{",
"item",
"=",
"children",
"[",
"i",
"]"... | Convert a nestable source data tree into a simple list
@author Jelle De Loecker <jelle@develry.be>
@since 0.0.1
@version 0.0.1
@param {Array} items
@param {Object} children
@param {String} parent_id | [
"Convert",
"a",
"nestable",
"source",
"data",
"tree",
"into",
"a",
"simple",
"list"
] | 9614241a63f40fdbf81b6bd1dc96e9bed8334c33 | https://github.com/skerit/alchemy-menu/blob/9614241a63f40fdbf81b6bd1dc96e9bed8334c33/assets/scripts/menu/menu_manager.js#L282-L303 | train |
vkiding/judpack-common | src/PluginInfo/PluginInfo.js | _getTags | function _getTags(pelem, tag, platform, transform) {
var platformTag = pelem.find('./platform[@name="' + platform + '"]');
var tagsInRoot = pelem.findall(tag);
tagsInRoot = tagsInRoot || [];
var tagsInPlatform = platformTag ? platformTag.findall(tag) : [];
var tags = tagsInRoot.concat(tagsInPlatform... | javascript | function _getTags(pelem, tag, platform, transform) {
var platformTag = pelem.find('./platform[@name="' + platform + '"]');
var tagsInRoot = pelem.findall(tag);
tagsInRoot = tagsInRoot || [];
var tagsInPlatform = platformTag ? platformTag.findall(tag) : [];
var tags = tagsInRoot.concat(tagsInPlatform... | [
"function",
"_getTags",
"(",
"pelem",
",",
"tag",
",",
"platform",
",",
"transform",
")",
"{",
"var",
"platformTag",
"=",
"pelem",
".",
"find",
"(",
"'./platform[@name=\"'",
"+",
"platform",
"+",
"'\"]'",
")",
";",
"var",
"tagsInRoot",
"=",
"pelem",
".",
... | Helper function used by most of the getSomething methods of PluginInfo. Get all elements of a given name. Both in root and in platform sections for the given platform. If transform is given and is a function, it is applied to each element. | [
"Helper",
"function",
"used",
"by",
"most",
"of",
"the",
"getSomething",
"methods",
"of",
"PluginInfo",
".",
"Get",
"all",
"elements",
"of",
"a",
"given",
"name",
".",
"Both",
"in",
"root",
"and",
"in",
"platform",
"sections",
"for",
"the",
"given",
"platf... | 5b87d3f1cb10c2c867243e3a692d39b4bb189dd4 | https://github.com/vkiding/judpack-common/blob/5b87d3f1cb10c2c867243e3a692d39b4bb189dd4/src/PluginInfo/PluginInfo.js#L390-L400 | train |
andrewscwei/requiem | src/helpers/hasOwnValue.js | hasOwnValue | function hasOwnValue(object, value) {
assertType(object, 'object', false, 'Invalid object specified');
for (let k in object) {
if (object.hasOwnProperty(k) && (object[k] === value)) return true;
}
return false;
} | javascript | function hasOwnValue(object, value) {
assertType(object, 'object', false, 'Invalid object specified');
for (let k in object) {
if (object.hasOwnProperty(k) && (object[k] === value)) return true;
}
return false;
} | [
"function",
"hasOwnValue",
"(",
"object",
",",
"value",
")",
"{",
"assertType",
"(",
"object",
",",
"'object'",
",",
"false",
",",
"'Invalid object specified'",
")",
";",
"for",
"(",
"let",
"k",
"in",
"object",
")",
"{",
"if",
"(",
"object",
".",
"hasOwn... | Checks if an object literal has the specified value in one of its keys.
@param {Object} object - Target object literal.
@param {*} value - Value to check.
@return {boolean} True if value is found, false otherwise.
@alias module:requiem~helpers.hasOwnValue | [
"Checks",
"if",
"an",
"object",
"literal",
"has",
"the",
"specified",
"value",
"in",
"one",
"of",
"its",
"keys",
"."
] | c4182bfffc9841c6de5718f689ad3c2060511777 | https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/helpers/hasOwnValue.js#L17-L25 | train |
bigpipe/bootstrap-pagelet | index.js | render | function render() {
var framework = this._bigpipe._framework
, bootstrap = this
, data;
data = this.keys.reduce(function reduce(memo, key) {
memo[key] = bootstrap[key];
return memo;
}, {});
//
// Adds initial HTML headers to the queue. The first flush will
// push out t... | javascript | function render() {
var framework = this._bigpipe._framework
, bootstrap = this
, data;
data = this.keys.reduce(function reduce(memo, key) {
memo[key] = bootstrap[key];
return memo;
}, {});
//
// Adds initial HTML headers to the queue. The first flush will
// push out t... | [
"function",
"render",
"(",
")",
"{",
"var",
"framework",
"=",
"this",
".",
"_bigpipe",
".",
"_framework",
",",
"bootstrap",
"=",
"this",
",",
"data",
";",
"data",
"=",
"this",
".",
"keys",
".",
"reduce",
"(",
"function",
"reduce",
"(",
"memo",
",",
"... | Render the HTML template with the data provided. Temper provides a minimal
templater to handle data in HTML templates. Data has to be specifically
provided, properties of `this` are not enumerable and would not be included.
@returns {Pagelet} this
@api public | [
"Render",
"the",
"HTML",
"template",
"with",
"the",
"data",
"provided",
".",
"Temper",
"provides",
"a",
"minimal",
"templater",
"to",
"handle",
"data",
"in",
"HTML",
"templates",
".",
"Data",
"has",
"to",
"be",
"specifically",
"provided",
"properties",
"of",
... | cf03e008aca36e413edd067ff8d83e2f1f59ed9f | https://github.com/bigpipe/bootstrap-pagelet/blob/cf03e008aca36e413edd067ff8d83e2f1f59ed9f/index.js#L109-L139 | train |
bigpipe/bootstrap-pagelet | index.js | contentTypeHeader | function contentTypeHeader(type) {
if (this._res.headersSent) return this.debug(
'Headers already sent, ignoring content type change: %s', contentTypes[type]
);
this.contentType = contentTypes[type];
this._res.setHeader('Content-Type', this.contentType);
} | javascript | function contentTypeHeader(type) {
if (this._res.headersSent) return this.debug(
'Headers already sent, ignoring content type change: %s', contentTypes[type]
);
this.contentType = contentTypes[type];
this._res.setHeader('Content-Type', this.contentType);
} | [
"function",
"contentTypeHeader",
"(",
"type",
")",
"{",
"if",
"(",
"this",
".",
"_res",
".",
"headersSent",
")",
"return",
"this",
".",
"debug",
"(",
"'Headers already sent, ignoring content type change: %s'",
",",
"contentTypes",
"[",
"type",
"]",
")",
";",
"th... | Change the contentType header if possible.
@param {String} type html|json
@api private | [
"Change",
"the",
"contentType",
"header",
"if",
"possible",
"."
] | cf03e008aca36e413edd067ff8d83e2f1f59ed9f | https://github.com/bigpipe/bootstrap-pagelet/blob/cf03e008aca36e413edd067ff8d83e2f1f59ed9f/index.js#L147-L154 | train |
bigpipe/bootstrap-pagelet | index.js | queue | function queue(name, parent, data) {
this.length--;
//
// Object was queued, transform the response type to application/json.
//
if ('object' === typeof data && this._contentType !== contentTypes.json) {
this.emit('contentType', 'json');
}
this._queue.push({
parent: parent,
... | javascript | function queue(name, parent, data) {
this.length--;
//
// Object was queued, transform the response type to application/json.
//
if ('object' === typeof data && this._contentType !== contentTypes.json) {
this.emit('contentType', 'json');
}
this._queue.push({
parent: parent,
... | [
"function",
"queue",
"(",
"name",
",",
"parent",
",",
"data",
")",
"{",
"this",
".",
"length",
"--",
";",
"//",
"// Object was queued, transform the response type to application/json.",
"//",
"if",
"(",
"'object'",
"===",
"typeof",
"data",
"&&",
"this",
".",
"_c... | Add fragment of data to the queue.
@param {String} name Pagelet name that queued the content.
@param {String} parent Pagelet parent that queued the content.
@param {Mixed} data Output to be send to the response
@returns {Pagelet} this
@api public | [
"Add",
"fragment",
"of",
"data",
"to",
"the",
"queue",
"."
] | cf03e008aca36e413edd067ff8d83e2f1f59ed9f | https://github.com/bigpipe/bootstrap-pagelet/blob/cf03e008aca36e413edd067ff8d83e2f1f59ed9f/index.js#L165-L182 | train |
bigpipe/bootstrap-pagelet | index.js | join | function join() {
var pagelet = this
, result = this._queue.map(function flatten(fragment) {
if (!fragment.name || !fragment.view) return '';
return fragment.view;
});
try {
result = this._contentType === contentTypes.json
? JSON.stringify(result.shift())
... | javascript | function join() {
var pagelet = this
, result = this._queue.map(function flatten(fragment) {
if (!fragment.name || !fragment.view) return '';
return fragment.view;
});
try {
result = this._contentType === contentTypes.json
? JSON.stringify(result.shift())
... | [
"function",
"join",
"(",
")",
"{",
"var",
"pagelet",
"=",
"this",
",",
"result",
"=",
"this",
".",
"_queue",
".",
"map",
"(",
"function",
"flatten",
"(",
"fragment",
")",
"{",
"if",
"(",
"!",
"fragment",
".",
"name",
"||",
"!",
"fragment",
".",
"vi... | Joins all the data fragments in the queue.
@return {Mixed} Object by pagelet name or HTML string
@api private | [
"Joins",
"all",
"the",
"data",
"fragments",
"in",
"the",
"queue",
"."
] | cf03e008aca36e413edd067ff8d83e2f1f59ed9f | https://github.com/bigpipe/bootstrap-pagelet/blob/cf03e008aca36e413edd067ff8d83e2f1f59ed9f/index.js#L190-L208 | 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.