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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
singpath/example-app | packages/tools/index.js | hookInstanbul | function hookInstanbul(opts) {
return loadJspmConfig(opts).then(loader => {
sh.echo('Registering instrumentation hook to loader...');
systemIstanbul.hookSystemJS(loader, opts.exclude(loader.baseURL));
return loader;
});
} | javascript | function hookInstanbul(opts) {
return loadJspmConfig(opts).then(loader => {
sh.echo('Registering instrumentation hook to loader...');
systemIstanbul.hookSystemJS(loader, opts.exclude(loader.baseURL));
return loader;
});
} | [
"function",
"hookInstanbul",
"(",
"opts",
")",
"{",
"return",
"loadJspmConfig",
"(",
"opts",
")",
".",
"then",
"(",
"loader",
"=>",
"{",
"sh",
".",
"echo",
"(",
"'Registering instrumentation hook to loader...'",
")",
";",
"systemIstanbul",
".",
"hookSystemJS",
"... | Resolve with a module loader which will add coverage instrumentation
to src code.
@param {{exclude: function, config: function}} opts coverage options
@return {Promise<void, Error>}
, config: {} | [
"Resolve",
"with",
"a",
"module",
"loader",
"which",
"will",
"add",
"coverage",
"instrumentation",
"to",
"src",
"code",
"."
] | 50b8d54bf5b647cf68094c18d99b3c8785e1dee6 | https://github.com/singpath/example-app/blob/50b8d54bf5b647cf68094c18d99b3c8785e1dee6/packages/tools/index.js#L159-L166 | train |
singpath/example-app | packages/tools/index.js | createReport | function createReport(coverage, opts) {
const collector = new istanbul.Collector();
const reporter = new istanbul.Reporter(null, opts.coverage);
const sync = true;
sh.echo('Creating reports...');
collector.add(coverage);
reporter.addAll(opts.reports);
reporter.write(collector, sync, () => sh.echo('Repor... | javascript | function createReport(coverage, opts) {
const collector = new istanbul.Collector();
const reporter = new istanbul.Reporter(null, opts.coverage);
const sync = true;
sh.echo('Creating reports...');
collector.add(coverage);
reporter.addAll(opts.reports);
reporter.write(collector, sync, () => sh.echo('Repor... | [
"function",
"createReport",
"(",
"coverage",
",",
"opts",
")",
"{",
"const",
"collector",
"=",
"new",
"istanbul",
".",
"Collector",
"(",
")",
";",
"const",
"reporter",
"=",
"new",
"istanbul",
".",
"Reporter",
"(",
"null",
",",
"opts",
".",
"coverage",
")... | Create lcov and text reports.
@param {Object} coverage the coverage object.
@param {{coverage: string}} opts coverage options | [
"Create",
"lcov",
"and",
"text",
"reports",
"."
] | 50b8d54bf5b647cf68094c18d99b3c8785e1dee6 | https://github.com/singpath/example-app/blob/50b8d54bf5b647cf68094c18d99b3c8785e1dee6/packages/tools/index.js#L247-L257 | train |
singpath/example-app | packages/tools/index.js | rejectHandler | function rejectHandler(err) {
process.stderr.write(`${err.stack || err}\n`);
if (sh.config.fatal) {
sh.exit(1);
}
return Promise.reject(err);
} | javascript | function rejectHandler(err) {
process.stderr.write(`${err.stack || err}\n`);
if (sh.config.fatal) {
sh.exit(1);
}
return Promise.reject(err);
} | [
"function",
"rejectHandler",
"(",
"err",
")",
"{",
"process",
".",
"stderr",
".",
"write",
"(",
"`",
"${",
"err",
".",
"stack",
"||",
"err",
"}",
"\\n",
"`",
")",
";",
"if",
"(",
"sh",
".",
"config",
".",
"fatal",
")",
"{",
"sh",
".",
"exit",
"... | Print error to stderr and exit process when shelljs "-e" option is set.
@param {Error} err error to print.
@return {Promise<void, Error>} | [
"Print",
"error",
"to",
"stderr",
"and",
"exit",
"process",
"when",
"shelljs",
"-",
"e",
"option",
"is",
"set",
"."
] | 50b8d54bf5b647cf68094c18d99b3c8785e1dee6 | https://github.com/singpath/example-app/blob/50b8d54bf5b647cf68094c18d99b3c8785e1dee6/packages/tools/index.js#L265-L273 | train |
redisjs/jsr-server | lib/command/server/save.js | execute | function execute(req, res) {
Persistence.save(this.state.store, this.state.conf);
res.send(null, Constants.OK);
} | javascript | function execute(req, res) {
Persistence.save(this.state.store, this.state.conf);
res.send(null, Constants.OK);
} | [
"function",
"execute",
"(",
"req",
",",
"res",
")",
"{",
"Persistence",
".",
"save",
"(",
"this",
".",
"state",
".",
"store",
",",
"this",
".",
"state",
".",
"conf",
")",
";",
"res",
".",
"send",
"(",
"null",
",",
"Constants",
".",
"OK",
")",
";"... | Respond to the SAVE command. | [
"Respond",
"to",
"the",
"SAVE",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/save.js#L22-L25 | train |
LaxarJS/karma-laxar | lib/adapter_post.js | function( path ) {
var normalized = [];
var parts = path.split( '/' );
for( var i = 0; i < parts.length; i++ ) {
if( parts[i] === '.' ) {
continue;
}
if( parts[i] === '..' && normalized.length && normalized[normalized.length - 1] !== '..' ) {
normal... | javascript | function( path ) {
var normalized = [];
var parts = path.split( '/' );
for( var i = 0; i < parts.length; i++ ) {
if( parts[i] === '.' ) {
continue;
}
if( parts[i] === '..' && normalized.length && normalized[normalized.length - 1] !== '..' ) {
normal... | [
"function",
"(",
"path",
")",
"{",
"var",
"normalized",
"=",
"[",
"]",
";",
"var",
"parts",
"=",
"path",
".",
"split",
"(",
"'/'",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"parts",
".",
"length",
";",
"i",
"++",
")",
"{",
... | monkey patch requirejs, to use append timestamps to sources to take advantage of karma's heavy caching it would work even without this hack, but with reloading all the files all the time | [
"monkey",
"patch",
"requirejs",
"to",
"use",
"append",
"timestamps",
"to",
"sources",
"to",
"take",
"advantage",
"of",
"karma",
"s",
"heavy",
"caching",
"it",
"would",
"work",
"even",
"without",
"this",
"hack",
"but",
"with",
"reloading",
"all",
"the",
"file... | 959680d5ae6336bb0ca86ce77eab70fde087ae9b | https://github.com/LaxarJS/karma-laxar/blob/959680d5ae6336bb0ca86ce77eab70fde087ae9b/lib/adapter_post.js#L91-L109 | train | |
panoptix-za/hotrod-dash-data | lib/query/es/esQuery.js | function(queryRunner, options) {
options = options || {};
this.queryParser = new QueryParser(options.paramValueRegEx);
var indexNameBuilder = options.indexNameBuilder || new DefaultIndexNameBuilder();
this.queryBuilder = new EsQueryBuilder(indexNameBuilder, {
defaults: options.queryDefaults
... | javascript | function(queryRunner, options) {
options = options || {};
this.queryParser = new QueryParser(options.paramValueRegEx);
var indexNameBuilder = options.indexNameBuilder || new DefaultIndexNameBuilder();
this.queryBuilder = new EsQueryBuilder(indexNameBuilder, {
defaults: options.queryDefaults
... | [
"function",
"(",
"queryRunner",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"queryParser",
"=",
"new",
"QueryParser",
"(",
"options",
".",
"paramValueRegEx",
")",
";",
"var",
"indexNameBuilder",
"=",
"options",
".... | Small facade over lower level types. Provides a smaller API for users | [
"Small",
"facade",
"over",
"lower",
"level",
"types",
".",
"Provides",
"a",
"smaller",
"API",
"for",
"users"
] | 6cd2c64b0fac2cb9aa484abcbd641fbe8c651fa2 | https://github.com/panoptix-za/hotrod-dash-data/blob/6cd2c64b0fac2cb9aa484abcbd641fbe8c651fa2/lib/query/es/esQuery.js#L8-L16 | train | |
jonschlinkert/get-first-commit | index.js | firstCommit | function firstCommit(dir, cb) {
if (typeof dir === 'function') {
return firstCommit(process.cwd(), dir);
}
if (typeof cb !== 'function') {
throw new TypeError('expected callback to be a function');
}
lazy.git(dir).log(function(err, history) {
if (err) return cb(err);
history.sort(function(a,... | javascript | function firstCommit(dir, cb) {
if (typeof dir === 'function') {
return firstCommit(process.cwd(), dir);
}
if (typeof cb !== 'function') {
throw new TypeError('expected callback to be a function');
}
lazy.git(dir).log(function(err, history) {
if (err) return cb(err);
history.sort(function(a,... | [
"function",
"firstCommit",
"(",
"dir",
",",
"cb",
")",
"{",
"if",
"(",
"typeof",
"dir",
"===",
"'function'",
")",
"{",
"return",
"firstCommit",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"dir",
")",
";",
"}",
"if",
"(",
"typeof",
"cb",
"!==",
"'fun... | Asynchronously get the first commit from a git repository.
```js
firstCommit('foo/.git', function(err, commit) {
if (err) return console.log(err);
// do stuff with commit
});
```
@param {String} `cwd` current working directory
@param {Function} `callback`
@return {Object}
@api public | [
"Asynchronously",
"get",
"the",
"first",
"commit",
"from",
"a",
"git",
"repository",
"."
] | 69668ba3be92a629d4291bf78d52219da312f07c | https://github.com/jonschlinkert/get-first-commit/blob/69668ba3be92a629d4291bf78d52219da312f07c/index.js#L28-L45 | train |
Psychopoulet/node-promfs | lib/extends/_readJSONFile.js | _readJSONFile | function _readJSONFile (file, callback) {
if ("undefined" === typeof file) {
throw new ReferenceError("missing \"file\" argument");
}
else if ("string" !== typeof file) {
throw new TypeError("\"file\" argument is not a string");
}
else if ("" === file.trim()) {
throw new Error("\"file\"... | javascript | function _readJSONFile (file, callback) {
if ("undefined" === typeof file) {
throw new ReferenceError("missing \"file\" argument");
}
else if ("string" !== typeof file) {
throw new TypeError("\"file\" argument is not a string");
}
else if ("" === file.trim()) {
throw new Error("\"file\"... | [
"function",
"_readJSONFile",
"(",
"file",
",",
"callback",
")",
"{",
"if",
"(",
"\"undefined\"",
"===",
"typeof",
"file",
")",
"{",
"throw",
"new",
"ReferenceError",
"(",
"\"missing \\\"file\\\" argument\"",
")",
";",
"}",
"else",
"if",
"(",
"\"string\"",
"!==... | methods
Async readJSONFile
@param {string} file : file to check
@param {function} callback : operation's result
@returns {void} | [
"methods",
"Async",
"readJSONFile"
] | 016e272fc58c6ef6eae5ea551a0e8873f0ac20cc | https://github.com/Psychopoulet/node-promfs/blob/016e272fc58c6ef6eae5ea551a0e8873f0ac20cc/lib/extends/_readJSONFile.js#L21-L58 | train |
jonschlinkert/question-store | index.js | QuestionsStore | function QuestionsStore(options) {
debug('initializing from <%s>', __filename);
Cache.call(this, options);
this.createStores(this, this.options);
this.listen(this);
} | javascript | function QuestionsStore(options) {
debug('initializing from <%s>', __filename);
Cache.call(this, options);
this.createStores(this, this.options);
this.listen(this);
} | [
"function",
"QuestionsStore",
"(",
"options",
")",
"{",
"debug",
"(",
"'initializing from <%s>'",
",",
"__filename",
")",
";",
"Cache",
".",
"call",
"(",
"this",
",",
"options",
")",
";",
"this",
".",
"createStores",
"(",
"this",
",",
"this",
".",
"options... | Create an instance of `QuestionsStore` with the given `options`.
```js
var QuestionsStore = new QuestionsStore(options);
```
@param {Object} `options` question store options
@api public | [
"Create",
"an",
"instance",
"of",
"QuestionsStore",
"with",
"the",
"given",
"options",
"."
] | 0c459f6e8aff2078fc23f680887f10e8c92fde26 | https://github.com/jonschlinkert/question-store/blob/0c459f6e8aff2078fc23f680887f10e8c92fde26/index.js#L28-L33 | train |
cli-kit/cli-mid-exec | index.js | error | function error(scope, err, parameters) {
if(err.code == 'EACCES') {
scope.raise(scope.errors.EPERM, parameters);
}
} | javascript | function error(scope, err, parameters) {
if(err.code == 'EACCES') {
scope.raise(scope.errors.EPERM, parameters);
}
} | [
"function",
"error",
"(",
"scope",
",",
"err",
",",
"parameters",
")",
"{",
"if",
"(",
"err",
".",
"code",
"==",
"'EACCES'",
")",
"{",
"scope",
".",
"raise",
"(",
"scope",
".",
"errors",
".",
"EPERM",
",",
"parameters",
")",
";",
"}",
"}"
] | Child process error handler.
@param scope The program scope.
@param err The Error instance.
@param parameters Message replacement parameters. | [
"Child",
"process",
"error",
"handler",
"."
] | 2105ba5ff135a7bce2b066e996a822a49322ccd3 | https://github.com/cli-kit/cli-mid-exec/blob/2105ba5ff135a7bce2b066e996a822a49322ccd3/index.js#L15-L19 | train |
cli-kit/cli-mid-exec | index.js | execute | function execute(argv, bin, args, req) {
var config = this.configure();
var errors = this.errors, scope = this, e;
var dir = config.bin || dirname(argv[1]);
var local = path.join(dir, bin);
var exists = fs.existsSync(local);
var data = {bin: bin, dir: dir, local: local, args: args};
if(!exists) {
e = ... | javascript | function execute(argv, bin, args, req) {
var config = this.configure();
var errors = this.errors, scope = this, e;
var dir = config.bin || dirname(argv[1]);
var local = path.join(dir, bin);
var exists = fs.existsSync(local);
var data = {bin: bin, dir: dir, local: local, args: args};
if(!exists) {
e = ... | [
"function",
"execute",
"(",
"argv",
",",
"bin",
",",
"args",
",",
"req",
")",
"{",
"var",
"config",
"=",
"this",
".",
"configure",
"(",
")",
";",
"var",
"errors",
"=",
"this",
".",
"errors",
",",
"scope",
"=",
"this",
",",
"e",
";",
"var",
"dir",... | Execute a command as an external program.
@param argv The program arguments.
@param cmd The command to execute.
@param args Array of arguments to pass to the command.
@param req The request object for the middleware execution. | [
"Execute",
"a",
"command",
"as",
"an",
"external",
"program",
"."
] | 2105ba5ff135a7bce2b066e996a822a49322ccd3 | https://github.com/cli-kit/cli-mid-exec/blob/2105ba5ff135a7bce2b066e996a822a49322ccd3/index.js#L29-L66 | train |
pcnsuite/pcnlint | src/mocha.js | stringMatch | function stringMatch(stringValues) {
return function(testValue) {
for (var i = stringValues.length - 1; i >= 0; i--) {
if (stringValues[i] === testValue) {
return true;
}
}
return false;
};
} | javascript | function stringMatch(stringValues) {
return function(testValue) {
for (var i = stringValues.length - 1; i >= 0; i--) {
if (stringValues[i] === testValue) {
return true;
}
}
return false;
};
} | [
"function",
"stringMatch",
"(",
"stringValues",
")",
"{",
"return",
"function",
"(",
"testValue",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"stringValues",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"if",
"(",
"stringValues"... | Verify that a given property is one of a list of strings | [
"Verify",
"that",
"a",
"given",
"property",
"is",
"one",
"of",
"a",
"list",
"of",
"strings"
] | 7f5f82d25f62aecc1ccefb99096cc416e842f7cf | https://github.com/pcnsuite/pcnlint/blob/7f5f82d25f62aecc1ccefb99096cc416e842f7cf/src/mocha.js#L13-L22 | train |
MaPhil/sicro | index.js | function (data) {
var q = _q.defer();
data = data.replace(/\'/g,"\\\'");
data = data.replace(/\"/g,'\\\"');
exec(`echo "${data}" | crontab -`, (err, stdout, stderr) => {
if (err) q.reject(err);
if(stdout)q.resolve(stdout);
else q.resolve(stderr);
});
return q.promise;
} | javascript | function (data) {
var q = _q.defer();
data = data.replace(/\'/g,"\\\'");
data = data.replace(/\"/g,'\\\"');
exec(`echo "${data}" | crontab -`, (err, stdout, stderr) => {
if (err) q.reject(err);
if(stdout)q.resolve(stdout);
else q.resolve(stderr);
});
return q.promise;
} | [
"function",
"(",
"data",
")",
"{",
"var",
"q",
"=",
"_q",
".",
"defer",
"(",
")",
";",
"data",
"=",
"data",
".",
"replace",
"(",
"/",
"\\'",
"/",
"g",
",",
"\"\\\\\\'\"",
")",
";",
"data",
"=",
"data",
".",
"replace",
"(",
"/",
"\\\"",
"/",
"... | low level to replace functionality after testing | [
"low",
"level",
"to",
"replace",
"functionality",
"after",
"testing"
] | 2bb8cf0419ed625170ff534911e605d56596a4e2 | https://github.com/MaPhil/sicro/blob/2bb8cf0419ed625170ff534911e605d56596a4e2/index.js#L18-L28 | train | |
ninjablocks/node-ninja-blocks | index.js | function(cb) {
if (typeof cb === "function") {
var opts = {
url: uri + 'user',
method: 'GET',
qs: qs,
json: true
};
request(opts,function(e,r,b) {
if (e) cb(e)
else {
if (r.statusCode==200) cb(null, b)
els... | javascript | function(cb) {
if (typeof cb === "function") {
var opts = {
url: uri + 'user',
method: 'GET',
qs: qs,
json: true
};
request(opts,function(e,r,b) {
if (e) cb(e)
else {
if (r.statusCode==200) cb(null, b)
els... | [
"function",
"(",
"cb",
")",
"{",
"if",
"(",
"typeof",
"cb",
"===",
"\"function\"",
")",
"{",
"var",
"opts",
"=",
"{",
"url",
":",
"uri",
"+",
"'user'",
",",
"method",
":",
"'GET'",
",",
"qs",
":",
"qs",
",",
"json",
":",
"true",
"}",
";",
"requ... | Fetches all the user's information. If no callback is provided
then more specific information can be requested
Example:
app.user(function(err, data) { ... })
app.user().stream(function(err,data){ ... })
@param {Function} cb
@api public | [
"Fetches",
"all",
"the",
"user",
"s",
"information",
".",
"If",
"no",
"callback",
"is",
"provided",
"then",
"more",
"specific",
"information",
"can",
"be",
"requested"
] | 283acb0f5348abf18a534666bcd2cc169e1d9974 | https://github.com/ninjablocks/node-ninja-blocks/blob/283acb0f5348abf18a534666bcd2cc169e1d9974/index.js#L32-L107 | train | |
ninjablocks/node-ninja-blocks | index.js | function(cb) {
var opts = {
url: uri + 'user/stream',
method: 'GET',
qs: qs,
json: true
};
request(opts,function(e,r,b) {
if (e) cb(e)
else {
if (r.statusCode==200) cb(null, b)
else {
... | javascript | function(cb) {
var opts = {
url: uri + 'user/stream',
method: 'GET',
qs: qs,
json: true
};
request(opts,function(e,r,b) {
if (e) cb(e)
else {
if (r.statusCode==200) cb(null, b)
else {
... | [
"function",
"(",
"cb",
")",
"{",
"var",
"opts",
"=",
"{",
"url",
":",
"uri",
"+",
"'user/stream'",
",",
"method",
":",
"'GET'",
",",
"qs",
":",
"qs",
",",
"json",
":",
"true",
"}",
";",
"request",
"(",
"opts",
",",
"function",
"(",
"e",
",",
"r... | Fetches the user's stream
Example:
app.user().stream(function(err,data){ ... })
@param {Function} cb
@api public | [
"Fetches",
"the",
"user",
"s",
"stream"
] | 283acb0f5348abf18a534666bcd2cc169e1d9974 | https://github.com/ninjablocks/node-ninja-blocks/blob/283acb0f5348abf18a534666bcd2cc169e1d9974/index.js#L63-L79 | train | |
ninjablocks/node-ninja-blocks | index.js | function(url,overwrite,cb) {
if (typeof overwrite === "function") {
cb = overwrite;
overwrite = false;
}
var opts = {
url: uri + 'device/'+device+'/callback',
method: 'POST',
qs: qs,
json: { url:url }
};
... | javascript | function(url,overwrite,cb) {
if (typeof overwrite === "function") {
cb = overwrite;
overwrite = false;
}
var opts = {
url: uri + 'device/'+device+'/callback',
method: 'POST',
qs: qs,
json: { url:url }
};
... | [
"function",
"(",
"url",
",",
"overwrite",
",",
"cb",
")",
"{",
"if",
"(",
"typeof",
"overwrite",
"===",
"\"function\"",
")",
"{",
"cb",
"=",
"overwrite",
";",
"overwrite",
"=",
"false",
";",
"}",
"var",
"opts",
"=",
"{",
"url",
":",
"uri",
"+",
"'d... | Subscribes to a device's data feed.
Optionally `overwrite`s an existing callback `url`
Default is false.
Example:
app.device(guid).subscribe('example.com',true,function(err) { ... })
@param {String} url The url that Ninja Blocks will POST data to
@param {Boolean} overwrite If a callback url exists, this flag will fo... | [
"Subscribes",
"to",
"a",
"device",
"s",
"data",
"feed",
"."
] | 283acb0f5348abf18a534666bcd2cc169e1d9974 | https://github.com/ninjablocks/node-ninja-blocks/blob/283acb0f5348abf18a534666bcd2cc169e1d9974/index.js#L174-L208 | train | |
ninjablocks/node-ninja-blocks | index.js | function(start, end, cb) {
if (typeof start === "function") {
cb = start;
start = false;
} else if (typeof end === "function") {
cb = end;
end = false;
}
if (start instanceof Date) start = start.getTime();
if (start) qs.... | javascript | function(start, end, cb) {
if (typeof start === "function") {
cb = start;
start = false;
} else if (typeof end === "function") {
cb = end;
end = false;
}
if (start instanceof Date) start = start.getTime();
if (start) qs.... | [
"function",
"(",
"start",
",",
"end",
",",
"cb",
")",
"{",
"if",
"(",
"typeof",
"start",
"===",
"\"function\"",
")",
"{",
"cb",
"=",
"start",
";",
"start",
"=",
"false",
";",
"}",
"else",
"if",
"(",
"typeof",
"end",
"===",
"\"function\"",
")",
"{",... | Fetches any historical data about this device.
Optionally specify the period's `start` and `end`
timestamp.
Example:
app.device(guid).data(start, end, function(err, data) { ... })
@param {Integer|Date} start The timestamp/datetime of the beginning of the period
@param {Integer|Date} end the timestamp/datetime of the ... | [
"Fetches",
"any",
"historical",
"data",
"about",
"this",
"device",
".",
"Optionally",
"specify",
"the",
"period",
"s",
"start",
"and",
"end",
"timestamp",
"."
] | 283acb0f5348abf18a534666bcd2cc169e1d9974 | https://github.com/ninjablocks/node-ninja-blocks/blob/283acb0f5348abf18a534666bcd2cc169e1d9974/index.js#L249-L276 | train | |
ninjablocks/node-ninja-blocks | index.js | function(filter,cb) {
if (!filter) {
filter = {};
} else if (typeof filter == "function") {
cb = filter;
filter = {};
} else if (typeof filter == "string") {
filter = {device_type:filter}; // Backwards compatibility
}
var opts = {
url: uri + 'devices... | javascript | function(filter,cb) {
if (!filter) {
filter = {};
} else if (typeof filter == "function") {
cb = filter;
filter = {};
} else if (typeof filter == "string") {
filter = {device_type:filter}; // Backwards compatibility
}
var opts = {
url: uri + 'devices... | [
"function",
"(",
"filter",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"filter",
")",
"{",
"filter",
"=",
"{",
"}",
";",
"}",
"else",
"if",
"(",
"typeof",
"filter",
"==",
"\"function\"",
")",
"{",
"cb",
"=",
"filter",
";",
"filter",
"=",
"{",
"}",
";"... | Fetches all the user's device details.
Optionally if an object is passed as the first argument,
it will filter by the parameters. If a string is provided,
it will assume it's the device type intended for filtering.
Example:
app.devices('rgbled',function(err, data) { ... })
app.devices({shortName:'On Board RGB LED'},fu... | [
"Fetches",
"all",
"the",
"user",
"s",
"device",
"details",
".",
"Optionally",
"if",
"an",
"object",
"is",
"passed",
"as",
"the",
"first",
"argument",
"it",
"will",
"filter",
"by",
"the",
"parameters",
".",
"If",
"a",
"string",
"is",
"provided",
"it",
"wi... | 283acb0f5348abf18a534666bcd2cc169e1d9974 | https://github.com/ninjablocks/node-ninja-blocks/blob/283acb0f5348abf18a534666bcd2cc169e1d9974/index.js#L317-L337 | train | |
samplx/samplx-agentdb | utils/tune-hash.js | getPrimes | function getPrimes(limit) {
var sieve = new Array(limit);
var n, j, k;
var last = Math.floor(Math.sqrt(limit));
for (n=2; n < limit; n++) {
sieve[n] = true;
}
for (n=2; n <= last;) {
for (j= n+n; j < limit; j += n) {
sieve[j] = false;
}
for (j=1; j < l... | javascript | function getPrimes(limit) {
var sieve = new Array(limit);
var n, j, k;
var last = Math.floor(Math.sqrt(limit));
for (n=2; n < limit; n++) {
sieve[n] = true;
}
for (n=2; n <= last;) {
for (j= n+n; j < limit; j += n) {
sieve[j] = false;
}
for (j=1; j < l... | [
"function",
"getPrimes",
"(",
"limit",
")",
"{",
"var",
"sieve",
"=",
"new",
"Array",
"(",
"limit",
")",
";",
"var",
"n",
",",
"j",
",",
"k",
";",
"var",
"last",
"=",
"Math",
".",
"floor",
"(",
"Math",
".",
"sqrt",
"(",
"limit",
")",
")",
";",
... | sieve of Eratosthenes to get prime numbers.
@param limit | [
"sieve",
"of",
"Eratosthenes",
"to",
"get",
"prime",
"numbers",
"."
] | 4ded3176c8a9dceb3f2017f66581929d3cfc1084 | https://github.com/samplx/samplx-agentdb/blob/4ded3176c8a9dceb3f2017f66581929d3cfc1084/utils/tune-hash.js#L42-L68 | train |
samplx/samplx-agentdb | utils/tune-hash.js | fill | function fill(size, seed, multiplier) {
var hash = new HashTable(size, seed, multiplier);
var x = agentdb.getX(1, 1); // dummy data Unknown, Unknown
agents.forEach(function (agent) {
if (agent.status < 2) {
var obj = { "a": agent.agent, "x": x };
hash.add('a', obj);
}... | javascript | function fill(size, seed, multiplier) {
var hash = new HashTable(size, seed, multiplier);
var x = agentdb.getX(1, 1); // dummy data Unknown, Unknown
agents.forEach(function (agent) {
if (agent.status < 2) {
var obj = { "a": agent.agent, "x": x };
hash.add('a', obj);
}... | [
"function",
"fill",
"(",
"size",
",",
"seed",
",",
"multiplier",
")",
"{",
"var",
"hash",
"=",
"new",
"HashTable",
"(",
"size",
",",
"seed",
",",
"multiplier",
")",
";",
"var",
"x",
"=",
"agentdb",
".",
"getX",
"(",
"1",
",",
"1",
")",
";",
"// d... | Fill the hash table with the agents.
@param size of hash table.
@param seed for hash table.
@param multiplier of hash table.
@rtype Array hash table history. | [
"Fill",
"the",
"hash",
"table",
"with",
"the",
"agents",
"."
] | 4ded3176c8a9dceb3f2017f66581929d3cfc1084 | https://github.com/samplx/samplx-agentdb/blob/4ded3176c8a9dceb3f2017f66581929d3cfc1084/utils/tune-hash.js#L78-L88 | train |
samplx/samplx-agentdb | utils/tune-hash.js | dumpHistory | function dumpHistory(history, size, depth) {
console.log("Hash table history, size="+size+", average depth="+depth);
for (var n=0; n < history.length; n++) {
console.log(" Depth=" + n + ", count=" + history[n] + ", percent=" + (history[n] / size));
}
console.log("");
} | javascript | function dumpHistory(history, size, depth) {
console.log("Hash table history, size="+size+", average depth="+depth);
for (var n=0; n < history.length; n++) {
console.log(" Depth=" + n + ", count=" + history[n] + ", percent=" + (history[n] / size));
}
console.log("");
} | [
"function",
"dumpHistory",
"(",
"history",
",",
"size",
",",
"depth",
")",
"{",
"console",
".",
"log",
"(",
"\"Hash table history, size=\"",
"+",
"size",
"+",
"\", average depth=\"",
"+",
"depth",
")",
";",
"for",
"(",
"var",
"n",
"=",
"0",
";",
"n",
"<"... | Write the hash table history to the console.
@param history Array.
@param size of the hash table.
@param depth fit estimate. | [
"Write",
"the",
"hash",
"table",
"history",
"to",
"the",
"console",
"."
] | 4ded3176c8a9dceb3f2017f66581929d3cfc1084 | https://github.com/samplx/samplx-agentdb/blob/4ded3176c8a9dceb3f2017f66581929d3cfc1084/utils/tune-hash.js#L97-L103 | train |
samplx/samplx-agentdb | utils/tune-hash.js | getDepth | function getDepth(history) {
var total= history[0];
for (var n=1; n < history.length; n++) {
total = total + (n * n * history[n]);
}
var result = total / agents.length;
// console.log("total=" + total+", result=" + result);
return result;
} | javascript | function getDepth(history) {
var total= history[0];
for (var n=1; n < history.length; n++) {
total = total + (n * n * history[n]);
}
var result = total / agents.length;
// console.log("total=" + total+", result=" + result);
return result;
} | [
"function",
"getDepth",
"(",
"history",
")",
"{",
"var",
"total",
"=",
"history",
"[",
"0",
"]",
";",
"for",
"(",
"var",
"n",
"=",
"1",
";",
"n",
"<",
"history",
".",
"length",
";",
"n",
"++",
")",
"{",
"total",
"=",
"total",
"+",
"(",
"n",
"... | find the average search depth. Include the null entries for cost.
@param history of hash table.
@rtype Number. | [
"find",
"the",
"average",
"search",
"depth",
".",
"Include",
"the",
"null",
"entries",
"for",
"cost",
"."
] | 4ded3176c8a9dceb3f2017f66581929d3cfc1084 | https://github.com/samplx/samplx-agentdb/blob/4ded3176c8a9dceb3f2017f66581929d3cfc1084/utils/tune-hash.js#L111-L119 | train |
samplx/samplx-agentdb | utils/tune-hash.js | main | function main() {
if (verbose) { console.log("Finding primes to " + UPPER); }
var primes = getPrimes(UPPER);
if (verbose) { console.log("Done."); }
var bestSize = varySize(LOWER, UPPER, 5381, 33, primes);
var bestSeed = varySeed(0, 8192, bestSize, 33);
var bestMult = varyMultiplier(2, 256, ... | javascript | function main() {
if (verbose) { console.log("Finding primes to " + UPPER); }
var primes = getPrimes(UPPER);
if (verbose) { console.log("Done."); }
var bestSize = varySize(LOWER, UPPER, 5381, 33, primes);
var bestSeed = varySeed(0, 8192, bestSize, 33);
var bestMult = varyMultiplier(2, 256, ... | [
"function",
"main",
"(",
")",
"{",
"if",
"(",
"verbose",
")",
"{",
"console",
".",
"log",
"(",
"\"Finding primes to \"",
"+",
"UPPER",
")",
";",
"}",
"var",
"primes",
"=",
"getPrimes",
"(",
"UPPER",
")",
";",
"if",
"(",
"verbose",
")",
"{",
"console"... | tune-hash table main function. | [
"tune",
"-",
"hash",
"table",
"main",
"function",
"."
] | 4ded3176c8a9dceb3f2017f66581929d3cfc1084 | https://github.com/samplx/samplx-agentdb/blob/4ded3176c8a9dceb3f2017f66581929d3cfc1084/utils/tune-hash.js#L185-L194 | train |
redisjs/jsr-loader | lib/index.js | include | function include(list) {
var cmd, clazz, i, file, j, name, newname;
for(i = 0;i < list.length;i++) {
file = list[i];
try {
clazz = require(file);
// assume it is already instantiated
if(typeof clazz === 'object') {
cmd = clazz;
}else{
cmd = new cla... | javascript | function include(list) {
var cmd, clazz, i, file, j, name, newname;
for(i = 0;i < list.length;i++) {
file = list[i];
try {
clazz = require(file);
// assume it is already instantiated
if(typeof clazz === 'object') {
cmd = clazz;
}else{
cmd = new cla... | [
"function",
"include",
"(",
"list",
")",
"{",
"var",
"cmd",
",",
"clazz",
",",
"i",
",",
"file",
",",
"j",
",",
"name",
",",
"newname",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"list",
".",
"length",
";",
"i",
"++",
")",
"{",
"file",
... | Requires the array of files. | [
"Requires",
"the",
"array",
"of",
"files",
"."
] | 93384142f6cfe1e6827c2789df76af06fa9eaf3d | https://github.com/redisjs/jsr-loader/blob/93384142f6cfe1e6827c2789df76af06fa9eaf3d/lib/index.js#L40-L114 | train |
redisjs/jsr-loader | lib/index.js | walk | function walk(files, cb, list) {
var i = 0;
list = list || [];
function check(file, cb) {
fs.stat(file, function onStat(err, stats) {
if(err) return cb(err);
if(stats.isFile() && !/\.js$/.test(file)) {
log.warning('ignoring %s', file);
return cb();
}
... | javascript | function walk(files, cb, list) {
var i = 0;
list = list || [];
function check(file, cb) {
fs.stat(file, function onStat(err, stats) {
if(err) return cb(err);
if(stats.isFile() && !/\.js$/.test(file)) {
log.warning('ignoring %s', file);
return cb();
}
... | [
"function",
"walk",
"(",
"files",
",",
"cb",
",",
"list",
")",
"{",
"var",
"i",
"=",
"0",
";",
"list",
"=",
"list",
"||",
"[",
"]",
";",
"function",
"check",
"(",
"file",
",",
"cb",
")",
"{",
"fs",
".",
"stat",
"(",
"file",
",",
"function",
"... | Walk the file list array. | [
"Walk",
"the",
"file",
"list",
"array",
"."
] | 93384142f6cfe1e6827c2789df76af06fa9eaf3d | https://github.com/redisjs/jsr-loader/blob/93384142f6cfe1e6827c2789df76af06fa9eaf3d/lib/index.js#L119-L155 | train |
tjmehta/validate-firepad-text-operation | index.js | validateTextOperationJSON | function validateTextOperationJSON (op) {
debug('validateTextOperationJSON %o', op)
assertErr(Array.isArray(op), Error, 'operation must be an array', { op: op })
assertErr(op.length, Error, 'operation cannot be empty', { op: op })
var type
var lastType = ''
op.forEach(function (item) {
if (typeof item =... | javascript | function validateTextOperationJSON (op) {
debug('validateTextOperationJSON %o', op)
assertErr(Array.isArray(op), Error, 'operation must be an array', { op: op })
assertErr(op.length, Error, 'operation cannot be empty', { op: op })
var type
var lastType = ''
op.forEach(function (item) {
if (typeof item =... | [
"function",
"validateTextOperationJSON",
"(",
"op",
")",
"{",
"debug",
"(",
"'validateTextOperationJSON %o'",
",",
"op",
")",
"assertErr",
"(",
"Array",
".",
"isArray",
"(",
"op",
")",
",",
"Error",
",",
"'operation must be an array'",
",",
"{",
"op",
":",
"op... | validate firepad text-operation json
@param {Array} op firepad text-operation json
@return {[type]} [description] | [
"validate",
"firepad",
"text",
"-",
"operation",
"json"
] | 7ebb8a390966aba0991c677a94b6e6aa62fbe5a5 | https://github.com/tjmehta/validate-firepad-text-operation/blob/7ebb8a390966aba0991c677a94b6e6aa62fbe5a5/index.js#L13-L40 | train |
ctrees/msfeature | lib/methods/findStep.js | trim | function trim(str) {
var input = str.replace(/\s\s+/g, ' ').trim();
var words = input.split(' ');
if (_.contains(LANG_WORDS, _.first(words))) {
return words.slice(1).join(' ');
}
return input;
} | javascript | function trim(str) {
var input = str.replace(/\s\s+/g, ' ').trim();
var words = input.split(' ');
if (_.contains(LANG_WORDS, _.first(words))) {
return words.slice(1).join(' ');
}
return input;
} | [
"function",
"trim",
"(",
"str",
")",
"{",
"var",
"input",
"=",
"str",
".",
"replace",
"(",
"/",
"\\s\\s+",
"/",
"g",
",",
"' '",
")",
".",
"trim",
"(",
")",
";",
"var",
"words",
"=",
"input",
".",
"split",
"(",
"' '",
")",
";",
"if",
"(",
"_"... | Sanitize input and trim first word if Gherkin lang | [
"Sanitize",
"input",
"and",
"trim",
"first",
"word",
"if",
"Gherkin",
"lang"
] | 5ee14fe11ade502ab2b47467717094ea9ea7b6ec | https://github.com/ctrees/msfeature/blob/5ee14fe11ade502ab2b47467717094ea9ea7b6ec/lib/methods/findStep.js#L16-L24 | train |
Nazariglez/perenquen | lib/pixi/src/filters/invert/InvertFilter.js | InvertFilter | function InvertFilter()
{
core.AbstractFilter.call(this,
// vertex shader
null,
// fragment shader
fs.readFileSync(__dirname + '/invert.frag', 'utf8'),
// custom uniforms
{
invert: { type: '1f', value: 1 }
}
);
} | javascript | function InvertFilter()
{
core.AbstractFilter.call(this,
// vertex shader
null,
// fragment shader
fs.readFileSync(__dirname + '/invert.frag', 'utf8'),
// custom uniforms
{
invert: { type: '1f', value: 1 }
}
);
} | [
"function",
"InvertFilter",
"(",
")",
"{",
"core",
".",
"AbstractFilter",
".",
"call",
"(",
"this",
",",
"// vertex shader",
"null",
",",
"// fragment shader",
"fs",
".",
"readFileSync",
"(",
"__dirname",
"+",
"'/invert.frag'",
",",
"'utf8'",
")",
",",
"// cus... | This inverts your Display Objects colors.
@class
@extends AbstractFilter
@memberof PIXI.filters | [
"This",
"inverts",
"your",
"Display",
"Objects",
"colors",
"."
] | e023964d05afeefebdcac4e2044819fdfa3899ae | https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/filters/invert/InvertFilter.js#L12-L24 | train |
schwarzkopfb/ellipse | lib/router.js | function (req, res, next) {
req.mounted = true
req.url = req.url.replace(remove, '')
// clear cached req.path
delete req._path
delete req._pathLength
next()
} | javascript | function (req, res, next) {
req.mounted = true
req.url = req.url.replace(remove, '')
// clear cached req.path
delete req._path
delete req._pathLength
next()
} | [
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"req",
".",
"mounted",
"=",
"true",
"req",
".",
"url",
"=",
"req",
".",
"url",
".",
"replace",
"(",
"remove",
",",
"''",
")",
"// clear cached req.path",
"delete",
"req",
".",
"_path",
"delet... | add mount middleware to the beginning of this sub-chain | [
"add",
"mount",
"middleware",
"to",
"the",
"beginning",
"of",
"this",
"sub",
"-",
"chain"
] | 4400d3bb09061893b1a76ff2983f28ad2ad0c5a7 | https://github.com/schwarzkopfb/ellipse/blob/4400d3bb09061893b1a76ff2983f28ad2ad0c5a7/lib/router.js#L293-L302 | train | |
FreeAllMedia/dovima | es5/lib/model/delete.js | deleteSelf | function deleteSelf(callback) {
var _this = this;
_flowsync2["default"].series([function (done) {
_this.beforeDelete(done);
}, function (done) {
if (_this.constructor.useSoftDelete !== undefined) {
_this.softDestroy(done);
} else {
_this.destroy(done);
}
}, function (done) {
_th... | javascript | function deleteSelf(callback) {
var _this = this;
_flowsync2["default"].series([function (done) {
_this.beforeDelete(done);
}, function (done) {
if (_this.constructor.useSoftDelete !== undefined) {
_this.softDestroy(done);
} else {
_this.destroy(done);
}
}, function (done) {
_th... | [
"function",
"deleteSelf",
"(",
"callback",
")",
"{",
"var",
"_this",
"=",
"this",
";",
"_flowsync2",
"[",
"\"default\"",
"]",
".",
"series",
"(",
"[",
"function",
"(",
"done",
")",
"{",
"_this",
".",
"beforeDelete",
"(",
"done",
")",
";",
"}",
",",
"... | Delete the model according to the prescribed strategy.
Named "deleteSelf" because "delete" is a reserved keyword in JS.
@method deleteSelf
@param {Function} callback | [
"Delete",
"the",
"model",
"according",
"to",
"the",
"prescribed",
"strategy",
"."
] | 364db634fe85c0132e32807d8cecb4959e242ccd | https://github.com/FreeAllMedia/dovima/blob/364db634fe85c0132e32807d8cecb4959e242ccd/es5/lib/model/delete.js#L39-L55 | train |
smelukov/PromiseDelay | src/main.js | inject | function inject(PromiseConstructor, extName) {
if (typeof PromiseConstructor === 'string') {
extName = PromiseConstructor;
}
extName = typeof extName === 'string' ? extName : 'delay';
PromiseConstructor =
(typeof PromiseConstructor === 'function' && PromiseConstructor) ||
(typeof Promise === 'functio... | javascript | function inject(PromiseConstructor, extName) {
if (typeof PromiseConstructor === 'string') {
extName = PromiseConstructor;
}
extName = typeof extName === 'string' ? extName : 'delay';
PromiseConstructor =
(typeof PromiseConstructor === 'function' && PromiseConstructor) ||
(typeof Promise === 'functio... | [
"function",
"inject",
"(",
"PromiseConstructor",
",",
"extName",
")",
"{",
"if",
"(",
"typeof",
"PromiseConstructor",
"===",
"'string'",
")",
"{",
"extName",
"=",
"PromiseConstructor",
";",
"}",
"extName",
"=",
"typeof",
"extName",
"===",
"'string'",
"?",
"ext... | Inject method with name `extName` to `PromiseConstructor`
@param {Function|String=} PromiseConstructor which constructor should be extended
If not defined, then default promise-constructor will be used
@param {String=} extName name of the method. If not defined, then 'delay' will be used
@returns {Function}
@throws ... | [
"Inject",
"method",
"with",
"name",
"extName",
"to",
"PromiseConstructor"
] | f304103854c4a92e94cffe21d706e4763040703f | https://github.com/smelukov/PromiseDelay/blob/f304103854c4a92e94cffe21d706e4763040703f/src/main.js#L18-L62 | train |
tolokoban/ToloFrameWork | lib/boilerplate.view.js | generate | function generate( arr, comment, _indent ) {
try {
const indent = typeof _indent !== "undefined" ? _indent : " ";
if ( arr.length === 0 ) return "";
let out = '';
if ( comment && comment.length > 0 ) {
let
len = comment.length + 3,
dashes ... | javascript | function generate( arr, comment, _indent ) {
try {
const indent = typeof _indent !== "undefined" ? _indent : " ";
if ( arr.length === 0 ) return "";
let out = '';
if ( comment && comment.length > 0 ) {
let
len = comment.length + 3,
dashes ... | [
"function",
"generate",
"(",
"arr",
",",
"comment",
",",
"_indent",
")",
"{",
"try",
"{",
"const",
"indent",
"=",
"typeof",
"_indent",
"!==",
"\"undefined\"",
"?",
"_indent",
":",
"\" \"",
";",
"if",
"(",
"arr",
".",
"length",
"===",
"0",
")",
"return... | Return the code from an array and an identation.
The code is preceded by a comment.
@param {array} arr - Array of strings and/or arrays.
@param {string} comment - Heading comment. Optional.
@param {string} _indent - Indetation before each line.
@returns {string} Readable Javascript code. | [
"Return",
"the",
"code",
"from",
"an",
"array",
"and",
"an",
"identation",
".",
"The",
"code",
"is",
"preceded",
"by",
"a",
"comment",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/boilerplate.view.js#L85-L108 | train |
tolokoban/ToloFrameWork | lib/boilerplate.view.js | buildViewStatics | function buildViewStatics( def, code ) {
try {
let statics = def[ "view.statics" ];
if ( typeof statics === 'undefined' ) return;
if ( typeof statics === 'string' ) statics = [ statics ];
else if ( !Array.isArray( statics ) ) {
throw Error( "view.statics must be a string... | javascript | function buildViewStatics( def, code ) {
try {
let statics = def[ "view.statics" ];
if ( typeof statics === 'undefined' ) return;
if ( typeof statics === 'string' ) statics = [ statics ];
else if ( !Array.isArray( statics ) ) {
throw Error( "view.statics must be a string... | [
"function",
"buildViewStatics",
"(",
"def",
",",
"code",
")",
"{",
"try",
"{",
"let",
"statics",
"=",
"def",
"[",
"\"view.statics\"",
"]",
";",
"if",
"(",
"typeof",
"statics",
"===",
"'undefined'",
")",
"return",
";",
"if",
"(",
"typeof",
"statics",
"===... | Add static functions to the current class.
@example
view.statics: ["show", "check"]
view.statics: "show" | [
"Add",
"static",
"functions",
"to",
"the",
"current",
"class",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/boilerplate.view.js#L135-L154 | train |
tolokoban/ToloFrameWork | lib/boilerplate.view.js | buildViewAttribsFire | function buildViewAttribsFire( def, code ) {
code.pm = true;
const attribs = def[ "view.attribs" ];
if ( typeof attribs !== 'object' ) return;
try {
for ( const attName of Object.keys( attribs ) ) {
const camelCaseAttName = camelCase( attName );
if ( !code.isAction( attNa... | javascript | function buildViewAttribsFire( def, code ) {
code.pm = true;
const attribs = def[ "view.attribs" ];
if ( typeof attribs !== 'object' ) return;
try {
for ( const attName of Object.keys( attribs ) ) {
const camelCaseAttName = camelCase( attName );
if ( !code.isAction( attNa... | [
"function",
"buildViewAttribsFire",
"(",
"def",
",",
"code",
")",
"{",
"code",
".",
"pm",
"=",
"true",
";",
"const",
"attribs",
"=",
"def",
"[",
"\"view.attribs\"",
"]",
";",
"if",
"(",
"typeof",
"attribs",
"!==",
"'object'",
")",
"return",
";",
"try",
... | Trigger the fire event on each attribute.
@param {[type]} def [description]
@param {[type]} code [description]
@returns {undefined} | [
"Trigger",
"the",
"fire",
"event",
"on",
"each",
"attribute",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/boilerplate.view.js#L221-L235 | train |
tolokoban/ToloFrameWork | lib/boilerplate.view.js | buildViewAttribsSpecial | function buildViewAttribsSpecial( attName, attValue, code ) {
const
type = attValue[ 0 ],
init = attValue[ 1 ];
let requireConverter = false;
try {
if ( typeof attValue.behind !== 'undefined' ) {
buildViewAttribsSpecialCodeBehind( attName, attValue.behind, code );
... | javascript | function buildViewAttribsSpecial( attName, attValue, code ) {
const
type = attValue[ 0 ],
init = attValue[ 1 ];
let requireConverter = false;
try {
if ( typeof attValue.behind !== 'undefined' ) {
buildViewAttribsSpecialCodeBehind( attName, attValue.behind, code );
... | [
"function",
"buildViewAttribsSpecial",
"(",
"attName",
",",
"attValue",
",",
"code",
")",
"{",
"const",
"type",
"=",
"attValue",
"[",
"0",
"]",
",",
"init",
"=",
"attValue",
"[",
"1",
"]",
";",
"let",
"requireConverter",
"=",
"false",
";",
"try",
"{",
... | Attribute with casting.
@example
type: {[default, primary, secondary]}
count: {integer}
content: {string ok behind: onContentChanged} | [
"Attribute",
"with",
"casting",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/boilerplate.view.js#L244-L325 | train |
tolokoban/ToloFrameWork | lib/boilerplate.view.js | buildViewAttribsInit | function buildViewAttribsInit( attName, attValue, code ) {
try {
if ( typeof attValue === "undefined" ) {
// code.section.attribs.init.push(`this.${attName} = args[${JSON.stringify(attName)}];`);
code.section.attribs.init
.push( `pm.set("${attName}", args[${JSON.strin... | javascript | function buildViewAttribsInit( attName, attValue, code ) {
try {
if ( typeof attValue === "undefined" ) {
// code.section.attribs.init.push(`this.${attName} = args[${JSON.stringify(attName)}];`);
code.section.attribs.init
.push( `pm.set("${attName}", args[${JSON.strin... | [
"function",
"buildViewAttribsInit",
"(",
"attName",
",",
"attValue",
",",
"code",
")",
"{",
"try",
"{",
"if",
"(",
"typeof",
"attValue",
"===",
"\"undefined\"",
")",
"{",
"// code.section.attribs.init.push(`this.${attName} = args[${JSON.stringify(attName)}];`);",
"code",
... | Initialize attribute with a value. Priority to the value set in the
contructor args. | [
"Initialize",
"attribute",
"with",
"a",
"value",
".",
"Priority",
"to",
"the",
"value",
"set",
"in",
"the",
"contructor",
"args",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/boilerplate.view.js#L394-L415 | train |
tolokoban/ToloFrameWork | lib/boilerplate.view.js | buildViewAttribsInitFire | function buildViewAttribsInitFire( attName, code ) {
try {
code.section.attribs.init
.push( `pm.fire("${attName}");` );
} catch ( ex ) {
bubble(
ex,
`buildViewAttribsInitFire(${attName})`
);
}
} | javascript | function buildViewAttribsInitFire( attName, code ) {
try {
code.section.attribs.init
.push( `pm.fire("${attName}");` );
} catch ( ex ) {
bubble(
ex,
`buildViewAttribsInitFire(${attName})`
);
}
} | [
"function",
"buildViewAttribsInitFire",
"(",
"attName",
",",
"code",
")",
"{",
"try",
"{",
"code",
".",
"section",
".",
"attribs",
".",
"init",
".",
"push",
"(",
"`",
"${",
"attName",
"}",
"`",
")",
";",
"}",
"catch",
"(",
"ex",
")",
"{",
"bubble",
... | Once every attribute has been set, we must fire them.
@param {[type]} attName [description]
@param {[type]} code [description]
@returns {undefined} | [
"Once",
"every",
"attribute",
"has",
"been",
"set",
"we",
"must",
"fire",
"them",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/boilerplate.view.js#L424-L434 | train |
tolokoban/ToloFrameWork | lib/boilerplate.view.js | buildFunction | function buildFunction( def, code, varName ) {
if ( isSpecial( def, "behind" ) ) {
const behindFunctionName = def[ 1 ];
code.addNeededBehindFunction( behindFunctionName );
code.that = true;
return [
"value => {",
" try {",
` CODE_BEHIND${keySyn... | javascript | function buildFunction( def, code, varName ) {
if ( isSpecial( def, "behind" ) ) {
const behindFunctionName = def[ 1 ];
code.addNeededBehindFunction( behindFunctionName );
code.that = true;
return [
"value => {",
" try {",
` CODE_BEHIND${keySyn... | [
"function",
"buildFunction",
"(",
"def",
",",
"code",
",",
"varName",
")",
"{",
"if",
"(",
"isSpecial",
"(",
"def",
",",
"\"behind\"",
")",
")",
"{",
"const",
"behindFunctionName",
"=",
"def",
"[",
"1",
"]",
";",
"code",
".",
"addNeededBehindFunction",
"... | Create the code for a function.
@example
{Behind onVarChanged}
{Toggle show-menu}
@param {object} def - Function definition.
@param {object} code - Needed for `code.section.ons`.
@param {string} varName - Name of the object owning the attribute we want to listen on.
@return {array} Resulting code as an array. | [
"Create",
"the",
"code",
"for",
"a",
"function",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/boilerplate.view.js#L820-L853 | train |
tolokoban/ToloFrameWork | lib/boilerplate.view.js | extractAttribs | function extractAttribs( def ) {
var key, val, attribs = { standard: {}, special: {}, implicit: [] };
for ( key in def ) {
val = def[ key ];
if ( RX_INTEGER.test( key ) ) {
attribs.implicit.push( val );
} else if ( RX_STD_ATT.test( key ) ) {
attribs.standard[ key ... | javascript | function extractAttribs( def ) {
var key, val, attribs = { standard: {}, special: {}, implicit: [] };
for ( key in def ) {
val = def[ key ];
if ( RX_INTEGER.test( key ) ) {
attribs.implicit.push( val );
} else if ( RX_STD_ATT.test( key ) ) {
attribs.standard[ key ... | [
"function",
"extractAttribs",
"(",
"def",
")",
"{",
"var",
"key",
",",
"val",
",",
"attribs",
"=",
"{",
"standard",
":",
"{",
"}",
",",
"special",
":",
"{",
"}",
",",
"implicit",
":",
"[",
"]",
"}",
";",
"for",
"(",
"key",
"in",
"def",
")",
"{"... | An attribute is marked as _special_ as soon as it has a dot in its name.
`view.attribs` is special, but `attribs` is not.
Attributes with a numeric key are marked as _implicit_.
@return `{ standard: {...}, special: {...}, implicit: [...] }`. | [
"An",
"attribute",
"is",
"marked",
"as",
"_special_",
"as",
"soon",
"as",
"it",
"has",
"a",
"dot",
"in",
"its",
"name",
".",
"view",
".",
"attribs",
"is",
"special",
"but",
"attribs",
"is",
"not",
".",
"Attributes",
"with",
"a",
"numeric",
"key",
"are"... | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/boilerplate.view.js#L1119-L1132 | train |
tolokoban/ToloFrameWork | lib/boilerplate.view.js | declareRootElement | function declareRootElement( def, code ) {
const rootElementName = buildElement( def, code );
code.section.elements.define.push( "//-----------------------" );
code.section.elements.define.push( "// Declare root element." );
code.section.elements.define.push(
"Object.defineProperty( this, '$', ... | javascript | function declareRootElement( def, code ) {
const rootElementName = buildElement( def, code );
code.section.elements.define.push( "//-----------------------" );
code.section.elements.define.push( "// Declare root element." );
code.section.elements.define.push(
"Object.defineProperty( this, '$', ... | [
"function",
"declareRootElement",
"(",
"def",
",",
"code",
")",
"{",
"const",
"rootElementName",
"=",
"buildElement",
"(",
"def",
",",
"code",
")",
";",
"code",
".",
"section",
".",
"elements",
".",
"define",
".",
"push",
"(",
"\"//-----------------------\"",
... | Javascript for for root variable declaration.
@param {object} def - `{View ...}`
@param {Template} code - Helper to write the Javascript code.
@return {undefined} | [
"Javascript",
"for",
"for",
"root",
"variable",
"declaration",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/boilerplate.view.js#L1435-L1450 | train |
tolokoban/ToloFrameWork | lib/boilerplate.view.js | outputAll | function outputAll( code, moduleName ) {
try {
let out = outputComments( code );
out += " module.exports = function() {\n";
out += outputNeededConstants( code );
out += ` //-------------------
// Class definition.
const ViewClass = function( args ) {
try {
i... | javascript | function outputAll( code, moduleName ) {
try {
let out = outputComments( code );
out += " module.exports = function() {\n";
out += outputNeededConstants( code );
out += ` //-------------------
// Class definition.
const ViewClass = function( args ) {
try {
i... | [
"function",
"outputAll",
"(",
"code",
",",
"moduleName",
")",
"{",
"try",
"{",
"let",
"out",
"=",
"outputComments",
"(",
"code",
")",
";",
"out",
"+=",
"\" module.exports = function() {\\n\"",
";",
"out",
"+=",
"outputNeededConstants",
"(",
"code",
")",
";",
... | Generate the JS code for the XJS module.
@param {object} code - Helper for Javascript code writing.
@param {string} moduleName - Javascript module name.
@return {string} Resulting JS code. | [
"Generate",
"the",
"JS",
"code",
"for",
"the",
"XJS",
"module",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/boilerplate.view.js#L1460-L1486 | train |
tolokoban/ToloFrameWork | lib/boilerplate.view.js | outputComments | function outputComments( code ) {
try {
let out = '';
if ( code.section.comments.length > 0 ) {
out += ` /**\n * ${code.section.comments.join("\n * ")}\n */\n`;
}
return out;
} catch ( ex ) {
bubble( ex, "outputComments" );
return null;
}
} | javascript | function outputComments( code ) {
try {
let out = '';
if ( code.section.comments.length > 0 ) {
out += ` /**\n * ${code.section.comments.join("\n * ")}\n */\n`;
}
return out;
} catch ( ex ) {
bubble( ex, "outputComments" );
return null;
}
} | [
"function",
"outputComments",
"(",
"code",
")",
"{",
"try",
"{",
"let",
"out",
"=",
"''",
";",
"if",
"(",
"code",
".",
"section",
".",
"comments",
".",
"length",
">",
"0",
")",
"{",
"out",
"+=",
"`",
"\\n",
"${",
"code",
".",
"section",
".",
"com... | Possible comments.
@param {object} code - See below.
@param {array} code.section.comments - Lines of comments.
@return {string} Resulting JS code. | [
"Possible",
"comments",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/boilerplate.view.js#L1496-L1507 | train |
tolokoban/ToloFrameWork | lib/boilerplate.view.js | outputNeededConstants | function outputNeededConstants( code ) {
try {
let out = arrayToCodeWithNewLine( code.generateRequires(), " " );
out += arrayToCodeWithNewLine( code.generateNeededBehindFunctions(), " " );
out += arrayToCodeWithNewLine( code.generateFunctions(), " " );
out += arrayToCodeWith... | javascript | function outputNeededConstants( code ) {
try {
let out = arrayToCodeWithNewLine( code.generateRequires(), " " );
out += arrayToCodeWithNewLine( code.generateNeededBehindFunctions(), " " );
out += arrayToCodeWithNewLine( code.generateFunctions(), " " );
out += arrayToCodeWith... | [
"function",
"outputNeededConstants",
"(",
"code",
")",
"{",
"try",
"{",
"let",
"out",
"=",
"arrayToCodeWithNewLine",
"(",
"code",
".",
"generateRequires",
"(",
")",
",",
"\" \"",
")",
";",
"out",
"+=",
"arrayToCodeWithNewLine",
"(",
"code",
".",
"generateNe... | Declare requires, converters, global variables, list of needed behind functions, ...
@param {object} code - Helper for Javascript code writing.
@return {string} Resulting JS code. | [
"Declare",
"requires",
"converters",
"global",
"variables",
"list",
"of",
"needed",
"behind",
"functions",
"..."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/boilerplate.view.js#L1516-L1527 | train |
tolokoban/ToloFrameWork | lib/boilerplate.view.js | outputClassBody | function outputClassBody( code ) {
try {
let out = '';
if ( code.that ) out += " const that = this;\n";
if ( code.pm ) out += " const pm = PM(this);\n";
out += generate( code.section.attribs.define, "Create attributes", " " );
out += generate( code.sectio... | javascript | function outputClassBody( code ) {
try {
let out = '';
if ( code.that ) out += " const that = this;\n";
if ( code.pm ) out += " const pm = PM(this);\n";
out += generate( code.section.attribs.define, "Create attributes", " " );
out += generate( code.sectio... | [
"function",
"outputClassBody",
"(",
"code",
")",
"{",
"try",
"{",
"let",
"out",
"=",
"''",
";",
"if",
"(",
"code",
".",
"that",
")",
"out",
"+=",
"\" const that = this;\\n\"",
";",
"if",
"(",
"code",
".",
"pm",
")",
"out",
"+=",
"\" const p... | Class body.
@param {object} code - Helper for Javascript code writing.
@return {string} Resulting JS code. | [
"Class",
"body",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/boilerplate.view.js#L1536-L1558 | train |
tolokoban/ToloFrameWork | lib/boilerplate.view.js | bubble | function bubble( ex, origin ) {
if ( typeof ex === 'string' ) {
throw Error( `${ex}\n...in ${origin}` );
}
throw Error( `${ex.message}\n...in ${origin}` );
} | javascript | function bubble( ex, origin ) {
if ( typeof ex === 'string' ) {
throw Error( `${ex}\n...in ${origin}` );
}
throw Error( `${ex.message}\n...in ${origin}` );
} | [
"function",
"bubble",
"(",
"ex",
",",
"origin",
")",
"{",
"if",
"(",
"typeof",
"ex",
"===",
"'string'",
")",
"{",
"throw",
"Error",
"(",
"`",
"${",
"ex",
"}",
"\\n",
"${",
"origin",
"}",
"`",
")",
";",
"}",
"throw",
"Error",
"(",
"`",
"${",
"ex... | Bubble an exception by providing it's origin.
@param {string|Error} ex - Exception.
@param {string} origin - From where the exception has been thrown.
@return {undefined} | [
"Bubble",
"an",
"exception",
"by",
"providing",
"it",
"s",
"origin",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/boilerplate.view.js#L1568-L1573 | train |
strekmann/libby | lib/mongostore.js | MongoStore | function MongoStore(uri, options) {
var self = this;
this.options = options || (options = {});
options.collectionName = options.collectionName || 'sessions';
// 1 day
options.ttl = options.ttl || 24 * 60 * 60 * 1000;
// 60 s
options.cleanupInterval = options.clea... | javascript | function MongoStore(uri, options) {
var self = this;
this.options = options || (options = {});
options.collectionName = options.collectionName || 'sessions';
// 1 day
options.ttl = options.ttl || 24 * 60 * 60 * 1000;
// 60 s
options.cleanupInterval = options.clea... | [
"function",
"MongoStore",
"(",
"uri",
",",
"options",
")",
"{",
"var",
"self",
"=",
"this",
";",
"this",
".",
"options",
"=",
"options",
"||",
"(",
"options",
"=",
"{",
"}",
")",
";",
"options",
".",
"collectionName",
"=",
"options",
".",
"collectionNa... | Initialize a new `MongoStore`.
@api public | [
"Initialize",
"a",
"new",
"MongoStore",
"."
] | 9a43f756cf5f43771fa70514f352a16276eb0c98 | https://github.com/strekmann/libby/blob/9a43f756cf5f43771fa70514f352a16276eb0c98/lib/mongostore.js#L19-L46 | train |
jaredhanson/crane-amqp | lib/message.js | Message | function Message(message, headers, deliveryInfo, obj) {
// Crane uses slash ('/') separators rather than period ('.')
this.topic = deliveryInfo.routingKey.replace(/\./g, '/');
this.headers = headers;
if (deliveryInfo.contentType) { this.headers['content-type'] = deliveryInfo.contentType; }
if (Buffer.isBuf... | javascript | function Message(message, headers, deliveryInfo, obj) {
// Crane uses slash ('/') separators rather than period ('.')
this.topic = deliveryInfo.routingKey.replace(/\./g, '/');
this.headers = headers;
if (deliveryInfo.contentType) { this.headers['content-type'] = deliveryInfo.contentType; }
if (Buffer.isBuf... | [
"function",
"Message",
"(",
"message",
",",
"headers",
",",
"deliveryInfo",
",",
"obj",
")",
"{",
"// Crane uses slash ('/') separators rather than period ('.')",
"this",
".",
"topic",
"=",
"deliveryInfo",
".",
"routingKey",
".",
"replace",
"(",
"/",
"\\.",
"/",
"... | `Message` constructor.
@api protected | [
"Message",
"constructor",
"."
] | 2f2a653a5567550d035daf8a2587fac0ebc9d8ce | https://github.com/jaredhanson/crane-amqp/blob/2f2a653a5567550d035daf8a2587fac0ebc9d8ce/lib/message.js#L6-L19 | train |
tombenke/proper | processor.js | function(processingQueue, phase) {
var that = this;
verbose && console.log('phase is: ' + phase, processors);
processingQueue.forEach(function(context) {
var processor = processors[phase][context.fileType];
verbose && console.log('runProcessor with ', that, context );
... | javascript | function(processingQueue, phase) {
var that = this;
verbose && console.log('phase is: ' + phase, processors);
processingQueue.forEach(function(context) {
var processor = processors[phase][context.fileType];
verbose && console.log('runProcessor with ', that, context );
... | [
"function",
"(",
"processingQueue",
",",
"phase",
")",
"{",
"var",
"that",
"=",
"this",
";",
"verbose",
"&&",
"console",
".",
"log",
"(",
"'phase is: '",
"+",
"phase",
",",
"processors",
")",
";",
"processingQueue",
".",
"forEach",
"(",
"function",
"(",
... | Runs a set of processors using their configurations
@param {Array} processingQueue The processor set with their configuration data
@return {Object} The result graph of processing | [
"Runs",
"a",
"set",
"of",
"processors",
"using",
"their",
"configurations"
] | 3f766df6ec7dbb0c4d136373a94002d00d340a48 | https://github.com/tombenke/proper/blob/3f766df6ec7dbb0c4d136373a94002d00d340a48/processor.js#L260-L271 | train | |
IMCampbell/ubcscrapr | src/index.js | getRoomSlots | function getRoomSlots (semester, minRequestSpace = 1000, verbose = false, departments = []) {
validateInput("semester", semester, [1, 2], "set");
validateInput("minRequestSpace", minRequestSpace, [0, 100000], "range");
validateInput("verbose", verbose, [true, false], "set");
validateInput("departments",... | javascript | function getRoomSlots (semester, minRequestSpace = 1000, verbose = false, departments = []) {
validateInput("semester", semester, [1, 2], "set");
validateInput("minRequestSpace", minRequestSpace, [0, 100000], "range");
validateInput("verbose", verbose, [true, false], "set");
validateInput("departments",... | [
"function",
"getRoomSlots",
"(",
"semester",
",",
"minRequestSpace",
"=",
"1000",
",",
"verbose",
"=",
"false",
",",
"departments",
"=",
"[",
"]",
")",
"{",
"validateInput",
"(",
"\"semester\"",
",",
"semester",
",",
"[",
"1",
",",
"2",
"]",
",",
"\"set\... | Returns an object containing all class sections with their weekday, time, room, building, and address
@param semester: the semester that the classes belong to
@param minRequestSpace: the minimum amount of time between requests to UBCs webserver in milliseconds
@param verbose: whether or not you want to see console.logs... | [
"Returns",
"an",
"object",
"containing",
"all",
"class",
"sections",
"with",
"their",
"weekday",
"time",
"room",
"building",
"and",
"address"
] | 42b2d5acfae16f55772f548bb5ca1ac2d2a07a4c | https://github.com/IMCampbell/ubcscrapr/blob/42b2d5acfae16f55772f548bb5ca1ac2d2a07a4c/src/index.js#L11-L17 | train |
IMCampbell/ubcscrapr | src/index.js | getHours | function getHours (verbose = false, minRequestSpace = 500) {
validateInput("verbose", verbose, [true, false], "set");
validateInput("minRequestSpace", minRequestSpace, [0, 100000], "range");
return scrapeBuildings(verbose, minRequestSpace);
} | javascript | function getHours (verbose = false, minRequestSpace = 500) {
validateInput("verbose", verbose, [true, false], "set");
validateInput("minRequestSpace", minRequestSpace, [0, 100000], "range");
return scrapeBuildings(verbose, minRequestSpace);
} | [
"function",
"getHours",
"(",
"verbose",
"=",
"false",
",",
"minRequestSpace",
"=",
"500",
")",
"{",
"validateInput",
"(",
"\"verbose\"",
",",
"verbose",
",",
"[",
"true",
",",
"false",
"]",
",",
"\"set\"",
")",
";",
"validateInput",
"(",
"\"minRequestSpace\"... | Gets the hours for all buildings listed on the Buildings and classrooms section of the student services page
@param verbose: whether or not you want to see console.logs
@param minRequestSpace: the minimum amount of time between requests to UBCs webserver in milliseconds | [
"Gets",
"the",
"hours",
"for",
"all",
"buildings",
"listed",
"on",
"the",
"Buildings",
"and",
"classrooms",
"section",
"of",
"the",
"student",
"services",
"page"
] | 42b2d5acfae16f55772f548bb5ca1ac2d2a07a4c | https://github.com/IMCampbell/ubcscrapr/blob/42b2d5acfae16f55772f548bb5ca1ac2d2a07a4c/src/index.js#L24-L28 | train |
IMCampbell/ubcscrapr | src/index.js | validateInput | function validateInput(inputName, input, acceptableValues, acceptableValueType) {
let validInput = true;
if (acceptableValueType == "range") {
if (input < Math.min(...acceptableValues) || input > Math.max(...acceptableValues)) {
validInput = false;
}
} else if (acceptableValueTyp... | javascript | function validateInput(inputName, input, acceptableValues, acceptableValueType) {
let validInput = true;
if (acceptableValueType == "range") {
if (input < Math.min(...acceptableValues) || input > Math.max(...acceptableValues)) {
validInput = false;
}
} else if (acceptableValueTyp... | [
"function",
"validateInput",
"(",
"inputName",
",",
"input",
",",
"acceptableValues",
",",
"acceptableValueType",
")",
"{",
"let",
"validInput",
"=",
"true",
";",
"if",
"(",
"acceptableValueType",
"==",
"\"range\"",
")",
"{",
"if",
"(",
"input",
"<",
"Math",
... | Function to ensure that variables passed to API are of the correct types and bounded by reasonable values.
@param inputName: the name of the variable
@param input: the value of the variable
@param acceptableValues: parameter containing valid values for input to take
@param acceptableValueType: a flag
range means that t... | [
"Function",
"to",
"ensure",
"that",
"variables",
"passed",
"to",
"API",
"are",
"of",
"the",
"correct",
"types",
"and",
"bounded",
"by",
"reasonable",
"values",
"."
] | 42b2d5acfae16f55772f548bb5ca1ac2d2a07a4c | https://github.com/IMCampbell/ubcscrapr/blob/42b2d5acfae16f55772f548bb5ca1ac2d2a07a4c/src/index.js#L39-L57 | train |
oodolabs/cupsdm | lib/parser.js | parseLine | function parseLine(line, lineno, options) {
let command = null;
const lineContinuationRegex = (options && options.lineContinuationRegex
|| TOKEN_LINE_CONTINUATION);
line = line.trim();
if (!line) {
// Ignore empty lines
return { command: null, remainder: '' };
}
if (isComment(line)) {
// Handle comment... | javascript | function parseLine(line, lineno, options) {
let command = null;
const lineContinuationRegex = (options && options.lineContinuationRegex
|| TOKEN_LINE_CONTINUATION);
line = line.trim();
if (!line) {
// Ignore empty lines
return { command: null, remainder: '' };
}
if (isComment(line)) {
// Handle comment... | [
"function",
"parseLine",
"(",
"line",
",",
"lineno",
",",
"options",
")",
"{",
"let",
"command",
"=",
"null",
";",
"const",
"lineContinuationRegex",
"=",
"(",
"options",
"&&",
"options",
".",
"lineContinuationRegex",
"||",
"TOKEN_LINE_CONTINUATION",
")",
";",
... | parse a line and return the remainder. | [
"parse",
"a",
"line",
"and",
"return",
"the",
"remainder",
"."
] | 6567c0d6fcfe6cfe999f6c13ea3b1d7ca5f529f7 | https://github.com/oodolabs/cupsdm/blob/6567c0d6fcfe6cfe999f6c13ea3b1d7ca5f529f7/lib/parser.js#L303-L344 | train |
phelpstream/svp | lib/functions/dig.js | dig | function dig(obj) {
var iterateeFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (val, key, iterableParent) {
return val;
};
// eslint-disable-line no-unused-vars
// modifierFn = v => v,
return (0, _each2.default)(obj, function iterator(itValue, key, itObj) {
var proce... | javascript | function dig(obj) {
var iterateeFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (val, key, iterableParent) {
return val;
};
// eslint-disable-line no-unused-vars
// modifierFn = v => v,
return (0, _each2.default)(obj, function iterator(itValue, key, itObj) {
var proce... | [
"function",
"dig",
"(",
"obj",
")",
"{",
"var",
"iterateeFn",
"=",
"arguments",
".",
"length",
">",
"1",
"&&",
"arguments",
"[",
"1",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"1",
"]",
":",
"function",
"(",
"val",
",",
"key",
",",
"iterablePar... | Loop recursively through an iterable data structure.
@param {*} obj The value to iterate over.
@param {Function} iterateeFn The iterateeFn to look at the data. | [
"Loop",
"recursively",
"through",
"an",
"iterable",
"data",
"structure",
"."
] | 2f99adb9c5d0709e567264bba896d6a59f6a0a59 | https://github.com/phelpstream/svp/blob/2f99adb9c5d0709e567264bba896d6a59f6a0a59/lib/functions/dig.js#L29-L55 | train |
asciidisco/grunt-backbonebuilder | lib/builder.js | function (bbsource) {
var parts = {
Header: '',
Setup: '// Initial Setup',
Events: '// Backbone.Events',
Model: '// Backbone.Model',
Collection: '// Backbone.Collection',
Router: '// Backbone.Router',
History: '// Backbone.History',
View: '// Backbone.View',
Syn... | javascript | function (bbsource) {
var parts = {
Header: '',
Setup: '// Initial Setup',
Events: '// Backbone.Events',
Model: '// Backbone.Model',
Collection: '// Backbone.Collection',
Router: '// Backbone.Router',
History: '// Backbone.History',
View: '// Backbone.View',
Syn... | [
"function",
"(",
"bbsource",
")",
"{",
"var",
"parts",
"=",
"{",
"Header",
":",
"''",
",",
"Setup",
":",
"'// Initial Setup'",
",",
"Events",
":",
"'// Backbone.Events'",
",",
"Model",
":",
"'// Backbone.Model'",
",",
"Collection",
":",
"'// Backbone.Collection'... | parts are seperated by annotations | [
"parts",
"are",
"seperated",
"by",
"annotations"
] | 767fc145bb6f713c3e3daba2fc62c2b8cd02ca67 | https://github.com/asciidisco/grunt-backbonebuilder/blob/767fc145bb6f713c3e3daba2fc62c2b8cd02ca67/lib/builder.js#L29-L57 | train | |
asciidisco/grunt-backbonebuilder | lib/builder.js | function (combinations, parts, backboneSrc) {
var src = '';
var allCombinations = [];
parts.forEach(function (part) {
allCombinations.push(combinations[_.str.capitalize(part.toLowerCase())]);
});
var neededParts = _.union.apply(_, allCombinations);
var backboneParts = getBackboneParts(ba... | javascript | function (combinations, parts, backboneSrc) {
var src = '';
var allCombinations = [];
parts.forEach(function (part) {
allCombinations.push(combinations[_.str.capitalize(part.toLowerCase())]);
});
var neededParts = _.union.apply(_, allCombinations);
var backboneParts = getBackboneParts(ba... | [
"function",
"(",
"combinations",
",",
"parts",
",",
"backboneSrc",
")",
"{",
"var",
"src",
"=",
"''",
";",
"var",
"allCombinations",
"=",
"[",
"]",
";",
"parts",
".",
"forEach",
"(",
"function",
"(",
"part",
")",
"{",
"allCombinations",
".",
"push",
"(... | glues the backbone parts together again | [
"glues",
"the",
"backbone",
"parts",
"together",
"again"
] | 767fc145bb6f713c3e3daba2fc62c2b8cd02ca67 | https://github.com/asciidisco/grunt-backbonebuilder/blob/767fc145bb6f713c3e3daba2fc62c2b8cd02ca67/lib/builder.js#L60-L114 | train | |
yoshuawuyts/named-level-store | index.js | namedLevelStore | function namedLevelStore (name) {
assert.equal(typeof name, 'string', 'named-level-store: name should be a string')
const location = path.join(process.env.HOME, '.leveldb', name)
mkdirp.sync(location)
const db = level(location)
db.location = location
return db
} | javascript | function namedLevelStore (name) {
assert.equal(typeof name, 'string', 'named-level-store: name should be a string')
const location = path.join(process.env.HOME, '.leveldb', name)
mkdirp.sync(location)
const db = level(location)
db.location = location
return db
} | [
"function",
"namedLevelStore",
"(",
"name",
")",
"{",
"assert",
".",
"equal",
"(",
"typeof",
"name",
",",
"'string'",
",",
"'named-level-store: name should be a string'",
")",
"const",
"location",
"=",
"path",
".",
"join",
"(",
"process",
".",
"env",
".",
"HOM... | Create a levelDB instance on your local machine str -> obj | [
"Create",
"a",
"levelDB",
"instance",
"on",
"your",
"local",
"machine",
"str",
"-",
">",
"obj"
] | 8a7448ff89d192a07ac718731f0680d6d4b1cff0 | https://github.com/yoshuawuyts/named-level-store/blob/8a7448ff89d192a07ac718731f0680d6d4b1cff0/index.js#L10-L17 | train |
tolokoban/ToloFrameWork | lib/source.js | removeSrcDirPrefixFromFile | function removeSrcDirPrefixFromFile( srcDir, file ) {
if ( typeof srcDir !== 'string' ) return file;
if ( typeof file !== 'string' ) return file;
if ( file.substr( 0, srcDir.length ) !== srcDir ) {
return file;
}
return file.substr( srcDir.length );
} | javascript | function removeSrcDirPrefixFromFile( srcDir, file ) {
if ( typeof srcDir !== 'string' ) return file;
if ( typeof file !== 'string' ) return file;
if ( file.substr( 0, srcDir.length ) !== srcDir ) {
return file;
}
return file.substr( srcDir.length );
} | [
"function",
"removeSrcDirPrefixFromFile",
"(",
"srcDir",
",",
"file",
")",
"{",
"if",
"(",
"typeof",
"srcDir",
"!==",
"'string'",
")",
"return",
"file",
";",
"if",
"(",
"typeof",
"file",
"!==",
"'string'",
")",
"return",
"file",
";",
"if",
"(",
"file",
"... | If present, remove the `srcDir` prefix of `file`.
@param {[type]} srcDir [description]
@param {[type]} file [description]
@returns {[type]} [description]
@example
const f = removeSrcDirPrefixFromFile;
f("/src/", "/myfile.cpp") === "/myfile.cpp";
f("/src/", "/src/myfile2.cpp") === "myfile2.cpp"; | [
"If",
"present",
"remove",
"the",
"srcDir",
"prefix",
"of",
"file",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/source.js#L233-L241 | train |
elantion/handyJS | raw/browser/ajax.js | function (value) {
if (value === null) {
return '';
}
if (value === undefined) {
return '';
}
switch (typeof value) {
case 'object' :
if (value instanceof Blob) {
return value;
} else {
return JSON.stringify(value);
}
break;
case 'string':
return value;
default :
... | javascript | function (value) {
if (value === null) {
return '';
}
if (value === undefined) {
return '';
}
switch (typeof value) {
case 'object' :
if (value instanceof Blob) {
return value;
} else {
return JSON.stringify(value);
}
break;
case 'string':
return value;
default :
... | [
"function",
"(",
"value",
")",
"{",
"if",
"(",
"value",
"===",
"null",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"value",
"===",
"undefined",
")",
"{",
"return",
"''",
";",
"}",
"switch",
"(",
"typeof",
"value",
")",
"{",
"case",
"'object'",
... | transform some type of value | [
"transform",
"some",
"type",
"of",
"value"
] | 7c503d33b668434dd70cefefd6d2f2586c069bd2 | https://github.com/elantion/handyJS/blob/7c503d33b668434dd70cefefd6d2f2586c069bd2/raw/browser/ajax.js#L57-L77 | train | |
philipbordallo/eslint-config | src/utilities/createConfig.js | createConfig | async function createConfig(optionsArgs) {
const options = {
...DEFAULT_OPTIONS,
...optionsArgs,
};
const { rules, base } = options;
const config = {
...base,
rules: base.rules || {},
};
return Object.keys(config)
.reduce(async (collection, key) => {
const previous = await collec... | javascript | async function createConfig(optionsArgs) {
const options = {
...DEFAULT_OPTIONS,
...optionsArgs,
};
const { rules, base } = options;
const config = {
...base,
rules: base.rules || {},
};
return Object.keys(config)
.reduce(async (collection, key) => {
const previous = await collec... | [
"async",
"function",
"createConfig",
"(",
"optionsArgs",
")",
"{",
"const",
"options",
"=",
"{",
"...",
"DEFAULT_OPTIONS",
",",
"...",
"optionsArgs",
",",
"}",
";",
"const",
"{",
"rules",
",",
"base",
"}",
"=",
"options",
";",
"const",
"config",
"=",
"{"... | Create an ESLint config given rules and a base config
@param {Object} optionsArgs
@returns {Promise} A promise to return a full config | [
"Create",
"an",
"ESLint",
"config",
"given",
"rules",
"and",
"a",
"base",
"config"
] | a2f1bff442fdb8ee622f842f075fa10d555302a4 | https://github.com/philipbordallo/eslint-config/blob/a2f1bff442fdb8ee622f842f075fa10d555302a4/src/utilities/createConfig.js#L14-L47 | train |
seanpk/simple-command | SimpleCommand.js | SimpleCommand | function SimpleCommand(exec, args, workdir) {
this.exec = /^win/.test(process.platform) ? findWindowsExec(exec) : exec;
this.args = args;
this.workdir = workdir;
this.setOptions();
this.commandLine = util.format('%s %s', this.exec, this.args.join(' '));
} | javascript | function SimpleCommand(exec, args, workdir) {
this.exec = /^win/.test(process.platform) ? findWindowsExec(exec) : exec;
this.args = args;
this.workdir = workdir;
this.setOptions();
this.commandLine = util.format('%s %s', this.exec, this.args.join(' '));
} | [
"function",
"SimpleCommand",
"(",
"exec",
",",
"args",
",",
"workdir",
")",
"{",
"this",
".",
"exec",
"=",
"/",
"^win",
"/",
".",
"test",
"(",
"process",
".",
"platform",
")",
"?",
"findWindowsExec",
"(",
"exec",
")",
":",
"exec",
";",
"this",
".",
... | SimpleCommand - Constructs a command to run.
@param {string} **exec** the program to run
@param {array} **args** arguments to pass to the program <br/>
__Note:__ the program is executed directly, i.e. no subshell is launched to process globs in args
@param {string} **workdir** working directory from which to ... | [
"SimpleCommand",
"-",
"Constructs",
"a",
"command",
"to",
"run",
"."
] | d250b9a9b650d5779c9ed1fbc68d9e17d10d3c87 | https://github.com/seanpk/simple-command/blob/d250b9a9b650d5779c9ed1fbc68d9e17d10d3c87/SimpleCommand.js#L18-L24 | train |
vamship/wysknd-test | lib/fs.js | function() {
var items = _utils.getArgArray(arguments);
if (items.length === 0) {
throw new Error('no folders specified to create');
}
items.forEach(function(item) {
try {
_fs.mkdirSync(item);
} catch (e) {
// Eat the ex... | javascript | function() {
var items = _utils.getArgArray(arguments);
if (items.length === 0) {
throw new Error('no folders specified to create');
}
items.forEach(function(item) {
try {
_fs.mkdirSync(item);
} catch (e) {
// Eat the ex... | [
"function",
"(",
")",
"{",
"var",
"items",
"=",
"_utils",
".",
"getArgArray",
"(",
"arguments",
")",
";",
"if",
"(",
"items",
".",
"length",
"===",
"0",
")",
"{",
"throw",
"new",
"Error",
"(",
"'no folders specified to create'",
")",
";",
"}",
"items",
... | Creates all of the folders specified in the array. | [
"Creates",
"all",
"of",
"the",
"folders",
"specified",
"in",
"the",
"array",
"."
] | b7791c42f1c1b36be7738e2c6d24748360634003 | https://github.com/vamship/wysknd-test/blob/b7791c42f1c1b36be7738e2c6d24748360634003/lib/fs.js#L11-L23 | train | |
vamship/wysknd-test | lib/fs.js | function() {
var items = _utils.getArgArray(arguments);
if (items.length === 0) {
throw new Error('no files specified to create');
}
items.forEach(function(item) {
var contents;
var linkTarget;
var filePath;
if (typeof item === ... | javascript | function() {
var items = _utils.getArgArray(arguments);
if (items.length === 0) {
throw new Error('no files specified to create');
}
items.forEach(function(item) {
var contents;
var linkTarget;
var filePath;
if (typeof item === ... | [
"function",
"(",
")",
"{",
"var",
"items",
"=",
"_utils",
".",
"getArgArray",
"(",
"arguments",
")",
";",
"if",
"(",
"items",
".",
"length",
"===",
"0",
")",
"{",
"throw",
"new",
"Error",
"(",
"'no files specified to create'",
")",
";",
"}",
"items",
"... | Creates all of the files specified in the array. | [
"Creates",
"all",
"of",
"the",
"files",
"specified",
"in",
"the",
"array",
"."
] | b7791c42f1c1b36be7738e2c6d24748360634003 | https://github.com/vamship/wysknd-test/blob/b7791c42f1c1b36be7738e2c6d24748360634003/lib/fs.js#L28-L60 | train | |
vamship/wysknd-test | lib/fs.js | function() {
var items = _utils.getArgArray(arguments);
if (items.length === 0) {
throw new Error('no files specified to clean up');
}
items.forEach(function(item) {
try {
var path = (typeof item === 'string') ? item : item.path;
_f... | javascript | function() {
var items = _utils.getArgArray(arguments);
if (items.length === 0) {
throw new Error('no files specified to clean up');
}
items.forEach(function(item) {
try {
var path = (typeof item === 'string') ? item : item.path;
_f... | [
"function",
"(",
")",
"{",
"var",
"items",
"=",
"_utils",
".",
"getArgArray",
"(",
"arguments",
")",
";",
"if",
"(",
"items",
".",
"length",
"===",
"0",
")",
"{",
"throw",
"new",
"Error",
"(",
"'no files specified to clean up'",
")",
";",
"}",
"items",
... | Cleans up all of the files specified in the array. If the file
does not exist, the resultant error will be ignored. | [
"Cleans",
"up",
"all",
"of",
"the",
"files",
"specified",
"in",
"the",
"array",
".",
"If",
"the",
"file",
"does",
"not",
"exist",
"the",
"resultant",
"error",
"will",
"be",
"ignored",
"."
] | b7791c42f1c1b36be7738e2c6d24748360634003 | https://github.com/vamship/wysknd-test/blob/b7791c42f1c1b36be7738e2c6d24748360634003/lib/fs.js#L84-L97 | train | |
jonasfj/time-chunked-stream | index.js | function(options) {
// Ensure an instance is created
if (!(this instanceof TimeChunkedStream)) {
return new TimeChunkedStream(options);
}
// Always decode strings
options.decodeStrings = true;
// Initialize base class
Transform.call(this, options);
// Create internal buffer
this._buffer = new ... | javascript | function(options) {
// Ensure an instance is created
if (!(this instanceof TimeChunkedStream)) {
return new TimeChunkedStream(options);
}
// Always decode strings
options.decodeStrings = true;
// Initialize base class
Transform.call(this, options);
// Create internal buffer
this._buffer = new ... | [
"function",
"(",
"options",
")",
"{",
"// Ensure an instance is created",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"TimeChunkedStream",
")",
")",
"{",
"return",
"new",
"TimeChunkedStream",
"(",
"options",
")",
";",
"}",
"// Always decode strings",
"options",
"."... | Construct a new TimeChunkedStream, that will buffer data for
`options.timeout` milliseconds | [
"Construct",
"a",
"new",
"TimeChunkedStream",
"that",
"will",
"buffer",
"data",
"for",
"options",
".",
"timeout",
"milliseconds"
] | 06a4378a7e133f495403f96b63cd32a3289baf5a | https://github.com/jonasfj/time-chunked-stream/blob/06a4378a7e133f495403f96b63cd32a3289baf5a/index.js#L32-L48 | train | |
vincentmac/yeoman-bootstrap | install.js | linkBootstrap | function linkBootstrap() {
fs.symlink(bootstrap, path.resolve(yeoman, 'bootstrap-less'), 'dir', function(err) {
if (err) return console.log('symlink error:', err);
return console.log('Successfully installed yeoman-bootstrap in', bootstrap,
' and created a symlink in', yeoman);
});
} | javascript | function linkBootstrap() {
fs.symlink(bootstrap, path.resolve(yeoman, 'bootstrap-less'), 'dir', function(err) {
if (err) return console.log('symlink error:', err);
return console.log('Successfully installed yeoman-bootstrap in', bootstrap,
' and created a symlink in', yeoman);
});
} | [
"function",
"linkBootstrap",
"(",
")",
"{",
"fs",
".",
"symlink",
"(",
"bootstrap",
",",
"path",
".",
"resolve",
"(",
"yeoman",
",",
"'bootstrap-less'",
")",
",",
"'dir'",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"return",
"console... | Create new symlink to the bootstrap generator | [
"Create",
"new",
"symlink",
"to",
"the",
"bootstrap",
"generator"
] | b510ebe30244fdcf957e11fd2197995a3ab71bdc | https://github.com/vincentmac/yeoman-bootstrap/blob/b510ebe30244fdcf957e11fd2197995a3ab71bdc/install.js#L39-L45 | train |
byron-dupreez/aws-stream-consumer-core | settings.js | toPropertyNamesArray | function toPropertyNamesArray(propertyNamesString, separator) {
return propertyNamesString.split(separator || PROPERTY_NAME_SEPARATOR).map(s => trim(s)).filter(s => !!s);
} | javascript | function toPropertyNamesArray(propertyNamesString, separator) {
return propertyNamesString.split(separator || PROPERTY_NAME_SEPARATOR).map(s => trim(s)).filter(s => !!s);
} | [
"function",
"toPropertyNamesArray",
"(",
"propertyNamesString",
",",
"separator",
")",
"{",
"return",
"propertyNamesString",
".",
"split",
"(",
"separator",
"||",
"PROPERTY_NAME_SEPARATOR",
")",
".",
"map",
"(",
"s",
"=>",
"trim",
"(",
"s",
")",
")",
".",
"fil... | Converts the given property names string into an array of property names
@param {string} propertyNamesString - a string of property name(s) separated by the given separator
@param {string|undefined} [separator] - the separator to use to split the property names (defaults to PROPERTY_NAME_SEPARATOR if omitted)
@returns ... | [
"Converts",
"the",
"given",
"property",
"names",
"string",
"into",
"an",
"array",
"of",
"property",
"names"
] | 9b256084297f80d373bcf483aaf68a9da176b3d7 | https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/settings.js#L436-L438 | train |
redisjs/jsr-store | lib/command/list.js | linsert | function linsert(key, beforeAfter, pivot, value, req) {
var val = this.getKey(key, req);
if(val === undefined) return 0;
return val.linsert(beforeAfter, pivot, value);
} | javascript | function linsert(key, beforeAfter, pivot, value, req) {
var val = this.getKey(key, req);
if(val === undefined) return 0;
return val.linsert(beforeAfter, pivot, value);
} | [
"function",
"linsert",
"(",
"key",
",",
"beforeAfter",
",",
"pivot",
",",
"value",
",",
"req",
")",
"{",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
";",
"if",
"(",
"val",
"===",
"undefined",
")",
"return",
"0",
";",
"r... | Inserts value in the list stored at key either before
or after the reference value pivot. | [
"Inserts",
"value",
"in",
"the",
"list",
"stored",
"at",
"key",
"either",
"before",
"or",
"after",
"the",
"reference",
"value",
"pivot",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/list.js#L24-L28 | train |
redisjs/jsr-store | lib/command/list.js | lindex | function lindex(key, index, req) {
var val = this.getKey(key, req);
if(!val) return null;
return val.lindex(index);
} | javascript | function lindex(key, index, req) {
var val = this.getKey(key, req);
if(!val) return null;
return val.lindex(index);
} | [
"function",
"lindex",
"(",
"key",
",",
"index",
",",
"req",
")",
"{",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
";",
"if",
"(",
"!",
"val",
")",
"return",
"null",
";",
"return",
"val",
".",
"lindex",
"(",
"index",
"... | Returns the list element stored at index. | [
"Returns",
"the",
"list",
"element",
"stored",
"at",
"index",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/list.js#L33-L37 | train |
redisjs/jsr-store | lib/command/list.js | lpush | function lpush(key /*value-1, value-N, req*/) {
var val = this.getKey(key, req)
, args = slice.call(arguments, 1)
, req;
if(typeof args[args.length - 1] === 'object') {
req = args.pop();
}
if(val === undefined) {
val = new List();
this.setKey(key, val, undefined, undefined, undefined, req);
... | javascript | function lpush(key /*value-1, value-N, req*/) {
var val = this.getKey(key, req)
, args = slice.call(arguments, 1)
, req;
if(typeof args[args.length - 1] === 'object') {
req = args.pop();
}
if(val === undefined) {
val = new List();
this.setKey(key, val, undefined, undefined, undefined, req);
... | [
"function",
"lpush",
"(",
"key",
"/*value-1, value-N, req*/",
")",
"{",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
",",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
",",
"req",
";",
"if",
"(",
"typ... | Insert all the specified values at the head of the list stored at key. | [
"Insert",
"all",
"the",
"specified",
"values",
"at",
"the",
"head",
"of",
"the",
"list",
"stored",
"at",
"key",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/list.js#L42-L54 | train |
redisjs/jsr-store | lib/command/list.js | lpushx | function lpushx(key, value, req) {
var val = this.getKey(key, req);
if(val === undefined) {
return 0;
}
return val.lpush([value]);
} | javascript | function lpushx(key, value, req) {
var val = this.getKey(key, req);
if(val === undefined) {
return 0;
}
return val.lpush([value]);
} | [
"function",
"lpushx",
"(",
"key",
",",
"value",
",",
"req",
")",
"{",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
";",
"if",
"(",
"val",
"===",
"undefined",
")",
"{",
"return",
"0",
";",
"}",
"return",
"val",
".",
"lp... | Insert values at the head of the list stored at key
only if key exists. | [
"Insert",
"values",
"at",
"the",
"head",
"of",
"the",
"list",
"stored",
"at",
"key",
"only",
"if",
"key",
"exists",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/list.js#L77-L83 | train |
redisjs/jsr-store | lib/command/list.js | rpushx | function rpushx(key, value, req) {
var val = this.getKey(key, req);
if(val === undefined) {
return 0;
}
return val.rpush([value]);
} | javascript | function rpushx(key, value, req) {
var val = this.getKey(key, req);
if(val === undefined) {
return 0;
}
return val.rpush([value]);
} | [
"function",
"rpushx",
"(",
"key",
",",
"value",
",",
"req",
")",
"{",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
";",
"if",
"(",
"val",
"===",
"undefined",
")",
"{",
"return",
"0",
";",
"}",
"return",
"val",
".",
"rp... | Insert values at the tail of the list stored at key
only if key exists. | [
"Insert",
"values",
"at",
"the",
"tail",
"of",
"the",
"list",
"stored",
"at",
"key",
"only",
"if",
"key",
"exists",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/list.js#L89-L95 | train |
redisjs/jsr-store | lib/command/list.js | lpop | function lpop(key, req) {
var val = this.getKey(key, req);
if(val === undefined) return null;
var element = val.lpop();
if(val.llen() === 0) {
this.delKey(key, req);
}
return element;
} | javascript | function lpop(key, req) {
var val = this.getKey(key, req);
if(val === undefined) return null;
var element = val.lpop();
if(val.llen() === 0) {
this.delKey(key, req);
}
return element;
} | [
"function",
"lpop",
"(",
"key",
",",
"req",
")",
"{",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
";",
"if",
"(",
"val",
"===",
"undefined",
")",
"return",
"null",
";",
"var",
"element",
"=",
"val",
".",
"lpop",
"(",
... | Removes and returns the first element of the list stored at key. | [
"Removes",
"and",
"returns",
"the",
"first",
"element",
"of",
"the",
"list",
"stored",
"at",
"key",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/list.js#L100-L108 | train |
redisjs/jsr-store | lib/command/list.js | lrem | function lrem(key, count, value, req) {
var val = this.getKey(key, req);
if(val === undefined) return 0;
var deleted = val.lrem(count, value);
if(val.llen() === 0) {
this.delKey(key, req);
}
return deleted;
} | javascript | function lrem(key, count, value, req) {
var val = this.getKey(key, req);
if(val === undefined) return 0;
var deleted = val.lrem(count, value);
if(val.llen() === 0) {
this.delKey(key, req);
}
return deleted;
} | [
"function",
"lrem",
"(",
"key",
",",
"count",
",",
"value",
",",
"req",
")",
"{",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
";",
"if",
"(",
"val",
"===",
"undefined",
")",
"return",
"0",
";",
"var",
"deleted",
"=",
... | Removes the first count occurrences of elements equal to value
from the list stored at key. | [
"Removes",
"the",
"first",
"count",
"occurrences",
"of",
"elements",
"equal",
"to",
"value",
"from",
"the",
"list",
"stored",
"at",
"key",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/list.js#L127-L135 | train |
redisjs/jsr-store | lib/command/list.js | ltrim | function ltrim(key, start, stop, req) {
var val = this.getKey(key, req);
if(val === undefined) return null;
val.ltrim(start, stop);
if(val.llen() === 0) {
this.delKey(key, req);
}
return OK;
} | javascript | function ltrim(key, start, stop, req) {
var val = this.getKey(key, req);
if(val === undefined) return null;
val.ltrim(start, stop);
if(val.llen() === 0) {
this.delKey(key, req);
}
return OK;
} | [
"function",
"ltrim",
"(",
"key",
",",
"start",
",",
"stop",
",",
"req",
")",
"{",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
";",
"if",
"(",
"val",
"===",
"undefined",
")",
"return",
"null",
";",
"val",
".",
"ltrim",
... | Trim an existing list so that it will contain only the specified
range of elements. | [
"Trim",
"an",
"existing",
"list",
"so",
"that",
"it",
"will",
"contain",
"only",
"the",
"specified",
"range",
"of",
"elements",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/list.js#L141-L149 | train |
redisjs/jsr-store | lib/command/list.js | lrange | function lrange(key, start, stop, req) {
var val = this.getKey(key, req);
if(val === undefined) return null;
return val.lrange(start, stop);
} | javascript | function lrange(key, start, stop, req) {
var val = this.getKey(key, req);
if(val === undefined) return null;
return val.lrange(start, stop);
} | [
"function",
"lrange",
"(",
"key",
",",
"start",
",",
"stop",
",",
"req",
")",
"{",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
";",
"if",
"(",
"val",
"===",
"undefined",
")",
"return",
"null",
";",
"return",
"val",
".",... | Returns the specified elements of the list stored at key. | [
"Returns",
"the",
"specified",
"elements",
"of",
"the",
"list",
"stored",
"at",
"key",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/list.js#L154-L158 | train |
redisjs/jsr-store | lib/command/list.js | llen | function llen(key, req) {
var val = this.getKey(key, req);
if(val === undefined) return 0;
return val.llen();
} | javascript | function llen(key, req) {
var val = this.getKey(key, req);
if(val === undefined) return 0;
return val.llen();
} | [
"function",
"llen",
"(",
"key",
",",
"req",
")",
"{",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
";",
"if",
"(",
"val",
"===",
"undefined",
")",
"return",
"0",
";",
"return",
"val",
".",
"llen",
"(",
")",
";",
"}"
] | Returns the length of the list stored at key. | [
"Returns",
"the",
"length",
"of",
"the",
"list",
"stored",
"at",
"key",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/list.js#L163-L167 | train |
rabchev/passport-oauth-wrap | example/index.js | processToken | function processToken(token, done) {
var user = _.find(users, function (item) {
return item.username === token[claims.username];
});
if (!user) {
user = {
id : token[claims.id] || currId++,
username : token[claims.username],
email : token... | javascript | function processToken(token, done) {
var user = _.find(users, function (item) {
return item.username === token[claims.username];
});
if (!user) {
user = {
id : token[claims.id] || currId++,
username : token[claims.username],
email : token... | [
"function",
"processToken",
"(",
"token",
",",
"done",
")",
"{",
"var",
"user",
"=",
"_",
".",
"find",
"(",
"users",
",",
"function",
"(",
"item",
")",
"{",
"return",
"item",
".",
"username",
"===",
"token",
"[",
"claims",
".",
"username",
"]",
";",
... | We have to build and register the user with the supplied claims from the access token. The token could be either Simple Web Token or JSON Web Token by specification. | [
"We",
"have",
"to",
"build",
"and",
"register",
"the",
"user",
"with",
"the",
"supplied",
"claims",
"from",
"the",
"access",
"token",
".",
"The",
"token",
"could",
"be",
"either",
"Simple",
"Web",
"Token",
"or",
"JSON",
"Web",
"Token",
"by",
"specification... | 7f23fe82b5614859b5024aa3317b7e07f2aecaa5 | https://github.com/rabchev/passport-oauth-wrap/blob/7f23fe82b5614859b5024aa3317b7e07f2aecaa5/example/index.js#L39-L61 | train |
seriousManual/winston-splunkstorm | index.js | function (options) {
winston.Transport.call(this, options);
options = options || {};
var apiKey = options.apiKey;
var projectId = options.projectId;
var apiHostName = options.apiHostName;
var formatter = options.formatter || 'kvp';
if (!apiKey || !projectId || !apiHostName) {
thro... | javascript | function (options) {
winston.Transport.call(this, options);
options = options || {};
var apiKey = options.apiKey;
var projectId = options.projectId;
var apiHostName = options.apiHostName;
var formatter = options.formatter || 'kvp';
if (!apiKey || !projectId || !apiHostName) {
thro... | [
"function",
"(",
"options",
")",
"{",
"winston",
".",
"Transport",
".",
"call",
"(",
"this",
",",
"options",
")",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"apiKey",
"=",
"options",
".",
"apiKey",
";",
"var",
"projectId",
"=",
"opti... | Constructor function for the Splunkstorm constructor
@param options
@constructor | [
"Constructor",
"function",
"for",
"the",
"Splunkstorm",
"constructor"
] | 9c37c83c60ad1ac8aee2ea400388805e188de4ed | https://github.com/seriousManual/winston-splunkstorm/blob/9c37c83c60ad1ac8aee2ea400388805e188de4ed/index.js#L15-L40 | train | |
tolokoban/ToloFrameWork | lib/tolojson.js | stringify | function stringify(js, indent, indentUnit) {
if (typeof indent === 'undefined') indent = '';
if (typeof indentUnit === 'undefined') indentUnit = ' ';
var t = typeof js;
if (t === 'string') {
return JSON.stringify(js);
}
if (t === 'number') {
return js;
}
if (t === 'boole... | javascript | function stringify(js, indent, indentUnit) {
if (typeof indent === 'undefined') indent = '';
if (typeof indentUnit === 'undefined') indentUnit = ' ';
var t = typeof js;
if (t === 'string') {
return JSON.stringify(js);
}
if (t === 'number') {
return js;
}
if (t === 'boole... | [
"function",
"stringify",
"(",
"js",
",",
"indent",
",",
"indentUnit",
")",
"{",
"if",
"(",
"typeof",
"indent",
"===",
"'undefined'",
")",
"indent",
"=",
"''",
";",
"if",
"(",
"typeof",
"indentUnit",
"===",
"'undefined'",
")",
"indentUnit",
"=",
"' '",
"... | ToloJSON can parse JSON with comments, and can stringify JSON with indentation and comments.
This is useful for configuration files. | [
"ToloJSON",
"can",
"parse",
"JSON",
"with",
"comments",
"and",
"can",
"stringify",
"JSON",
"with",
"indentation",
"and",
"comments",
".",
"This",
"is",
"useful",
"for",
"configuration",
"files",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/tolojson.js#L6-L56 | train |
kt3k/cli-dispatch | index.js | main | function main (action, argv, options) {
options = options || {}
const cli = new CliDispatch(action, options.actions || 'actions', options.base || callersDir())
setImmediate(() => cli.dispatch(argv))
return cli
} | javascript | function main (action, argv, options) {
options = options || {}
const cli = new CliDispatch(action, options.actions || 'actions', options.base || callersDir())
setImmediate(() => cli.dispatch(argv))
return cli
} | [
"function",
"main",
"(",
"action",
",",
"argv",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
"const",
"cli",
"=",
"new",
"CliDispatch",
"(",
"action",
",",
"options",
".",
"actions",
"||",
"'actions'",
",",
"options",
".",
"base... | Dispatches the action by the given paramters.
@param {string} action The action name
@param {object} argv The parameters for the actions
@param {string} [options.actions] The action's directory (relative path)
@param {string} [options.base] The action's base directory (absolute path)
@return {CliDispatch} | [
"Dispatches",
"the",
"action",
"by",
"the",
"given",
"paramters",
"."
] | 26ff44ab019f49bf977f5113cf261129743efcef | https://github.com/kt3k/cli-dispatch/blob/26ff44ab019f49bf977f5113cf261129743efcef/index.js#L21-L28 | train |
kt3k/cli-dispatch | index.js | lookup | function lookup (action, options) {
options = options || {}
const cli = new CliDispatch(action, options.actions || 'actions', options.base || callersDir())
return cli.lookup()
} | javascript | function lookup (action, options) {
options = options || {}
const cli = new CliDispatch(action, options.actions || 'actions', options.base || callersDir())
return cli.lookup()
} | [
"function",
"lookup",
"(",
"action",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
"const",
"cli",
"=",
"new",
"CliDispatch",
"(",
"action",
",",
"options",
".",
"actions",
"||",
"'actions'",
",",
"options",
".",
"base",
"||",
"c... | Looks up the action by the given paramters.
@param {string} action The action name
@param {string} [options.actions] The action's directory (relative path)
@param {string} [options.base] The action's base directory (absolute path)
@return {CliDispatch} | [
"Looks",
"up",
"the",
"action",
"by",
"the",
"given",
"paramters",
"."
] | 26ff44ab019f49bf977f5113cf261129743efcef | https://github.com/kt3k/cli-dispatch/blob/26ff44ab019f49bf977f5113cf261129743efcef/index.js#L37-L42 | train |
kt3k/cli-dispatch | index.js | CliDispatch | function CliDispatch (action, dir, baseDir) {
this.action = action
this.dir = dir
this.baseDir = baseDir
} | javascript | function CliDispatch (action, dir, baseDir) {
this.action = action
this.dir = dir
this.baseDir = baseDir
} | [
"function",
"CliDispatch",
"(",
"action",
",",
"dir",
",",
"baseDir",
")",
"{",
"this",
".",
"action",
"=",
"action",
"this",
".",
"dir",
"=",
"dir",
"this",
".",
"baseDir",
"=",
"baseDir",
"}"
] | CliDispatch internal class.
@param {string} action The action name
@param {string} dir The directory name (relative path)
@param {string} baseDir The base directory name (absolute path) | [
"CliDispatch",
"internal",
"class",
"."
] | 26ff44ab019f49bf977f5113cf261129743efcef | https://github.com/kt3k/cli-dispatch/blob/26ff44ab019f49bf977f5113cf261129743efcef/index.js#L50-L54 | train |
ibm-bluemix-mobile-services/bms-mca-oauth-sdk | lib/util/token-util.js | getCliendIdFromCert | function getCliendIdFromCert() {
var x509 = require('x509');
var certJson = x509.parseCert(fs.readFileSync(process.cwd()+Constant.CERTIFICATE_PATH).toString());
var cliendId = cert && cert.subject && cert.subject.commonName;
return clientId;
} | javascript | function getCliendIdFromCert() {
var x509 = require('x509');
var certJson = x509.parseCert(fs.readFileSync(process.cwd()+Constant.CERTIFICATE_PATH).toString());
var cliendId = cert && cert.subject && cert.subject.commonName;
return clientId;
} | [
"function",
"getCliendIdFromCert",
"(",
")",
"{",
"var",
"x509",
"=",
"require",
"(",
"'x509'",
")",
";",
"var",
"certJson",
"=",
"x509",
".",
"parseCert",
"(",
"fs",
".",
"readFileSync",
"(",
"process",
".",
"cwd",
"(",
")",
"+",
"Constant",
".",
"CER... | Parse the certificate, and return the clientId from the commonName field in subject.
@returns | [
"Parse",
"the",
"certificate",
"and",
"return",
"the",
"clientId",
"from",
"the",
"commonName",
"field",
"in",
"subject",
"."
] | 6a23ab1353c64ba60d8d75d0b0d3d9eaf60bed83 | https://github.com/ibm-bluemix-mobile-services/bms-mca-oauth-sdk/blob/6a23ab1353c64ba60d8d75d0b0d3d9eaf60bed83/lib/util/token-util.js#L130-L136 | train |
ibm-bluemix-mobile-services/bms-mca-oauth-sdk | lib/util/token-util.js | verifyPermission | function verifyPermission(appId,uaaCredential) {
var deferred = Q.defer();
var cloudControllerUrl = process.env.cloudControllerUrl;
if (!cloudControllerUrl) {
var errMsg = "The system variable 'cloudControllerUrl' is missing.";
ibmlogger.getLogger().error(errMsg);
deferred.reject({code:Constant.MISSING_CLOUDC... | javascript | function verifyPermission(appId,uaaCredential) {
var deferred = Q.defer();
var cloudControllerUrl = process.env.cloudControllerUrl;
if (!cloudControllerUrl) {
var errMsg = "The system variable 'cloudControllerUrl' is missing.";
ibmlogger.getLogger().error(errMsg);
deferred.reject({code:Constant.MISSING_CLOUDC... | [
"function",
"verifyPermission",
"(",
"appId",
",",
"uaaCredential",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"var",
"cloudControllerUrl",
"=",
"process",
".",
"env",
".",
"cloudControllerUrl",
";",
"if",
"(",
"!",
"cloudControllerU... | Check if the given uaa credential has permisstion to access the appid.
@param appId
@param uaaCredential
@returns | [
"Check",
"if",
"the",
"given",
"uaa",
"credential",
"has",
"permisstion",
"to",
"access",
"the",
"appid",
"."
] | 6a23ab1353c64ba60d8d75d0b0d3d9eaf60bed83 | https://github.com/ibm-bluemix-mobile-services/bms-mca-oauth-sdk/blob/6a23ab1353c64ba60d8d75d0b0d3d9eaf60bed83/lib/util/token-util.js#L144-L174 | train |
ibm-bluemix-mobile-services/bms-mca-oauth-sdk | lib/util/token-util.js | getOAuthAccessToken | function getOAuthAccessToken(appId,clientId,imfCert,properties) {
var deferred = Q.defer();
var imfServiceUrl = process.env.imfServiceUrl;
var requestUrl = imfServiceUrl+"/authorization/v1/apps/"+appId+"/token";
var requestOptions = {url: requestUrl,headers: {'Authorization': 'IMFCert '+imfCert}, form:{'grant_typ... | javascript | function getOAuthAccessToken(appId,clientId,imfCert,properties) {
var deferred = Q.defer();
var imfServiceUrl = process.env.imfServiceUrl;
var requestUrl = imfServiceUrl+"/authorization/v1/apps/"+appId+"/token";
var requestOptions = {url: requestUrl,headers: {'Authorization': 'IMFCert '+imfCert}, form:{'grant_typ... | [
"function",
"getOAuthAccessToken",
"(",
"appId",
",",
"clientId",
",",
"imfCert",
",",
"properties",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"var",
"imfServiceUrl",
"=",
"process",
".",
"env",
".",
"imfServiceUrl",
";",
"var",
... | Get the OAuth access token from IMF AZ service
@param appId
@param clientId
@param imfCert
@param properties | [
"Get",
"the",
"OAuth",
"access",
"token",
"from",
"IMF",
"AZ",
"service"
] | 6a23ab1353c64ba60d8d75d0b0d3d9eaf60bed83 | https://github.com/ibm-bluemix-mobile-services/bms-mca-oauth-sdk/blob/6a23ab1353c64ba60d8d75d0b0d3d9eaf60bed83/lib/util/token-util.js#L183-L206 | train |
derdesign/protos | lib/command.js | CommandLine | function CommandLine(commands) {
this.keys = Object.keys(commands);
this.commands = commands;
this.args = process.argv.slice(2);
this.context = this.args[0] || null;
this.help = {
before: '',
after: ''
}
} | javascript | function CommandLine(commands) {
this.keys = Object.keys(commands);
this.commands = commands;
this.args = process.argv.slice(2);
this.context = this.args[0] || null;
this.help = {
before: '',
after: ''
}
} | [
"function",
"CommandLine",
"(",
"commands",
")",
"{",
"this",
".",
"keys",
"=",
"Object",
".",
"keys",
"(",
"commands",
")",
";",
"this",
".",
"commands",
"=",
"commands",
";",
"this",
".",
"args",
"=",
"process",
".",
"argv",
".",
"slice",
"(",
"2",... | Command Line class
@private
@constructor
@class CommandLine
@param {object} commands Commands object to pass | [
"Command",
"Line",
"class"
] | 0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9 | https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/lib/command.js#L19-L28 | train |
derdesign/protos | lib/command.js | padString | function padString(str, len) {
return str.split().concat(new Array(len-str.length)).join(' ');
} | javascript | function padString(str, len) {
return str.split().concat(new Array(len-str.length)).join(' ');
} | [
"function",
"padString",
"(",
"str",
",",
"len",
")",
"{",
"return",
"str",
".",
"split",
"(",
")",
".",
"concat",
"(",
"new",
"Array",
"(",
"len",
"-",
"str",
".",
"length",
")",
")",
".",
"join",
"(",
"' '",
")",
";",
"}"
] | Pads a string a certain amount of characters | [
"Pads",
"a",
"string",
"a",
"certain",
"amount",
"of",
"characters"
] | 0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9 | https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/lib/command.js#L227-L229 | train |
MakerCollider/node-red-contrib-smartnode-hook | html/scripts/highchart/modules/data.src.js | function () {
if (this.options.switchRowsAndColumns) {
this.columns = this.rowsToColumns(this.columns);
}
// Interpret the info about series and columns
this.getColumnDistribution();
// Interpret the values into right types
this.parseTypes();
// Handle columns if a handleColumns callback is giv... | javascript | function () {
if (this.options.switchRowsAndColumns) {
this.columns = this.rowsToColumns(this.columns);
}
// Interpret the info about series and columns
this.getColumnDistribution();
// Interpret the values into right types
this.parseTypes();
// Handle columns if a handleColumns callback is giv... | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"options",
".",
"switchRowsAndColumns",
")",
"{",
"this",
".",
"columns",
"=",
"this",
".",
"rowsToColumns",
"(",
"this",
".",
"columns",
")",
";",
"}",
"// Interpret the info about series and columns",
"this"... | When the data is parsed into columns, either by CSV, table, GS or direct input,
continue with other operations. | [
"When",
"the",
"data",
"is",
"parsed",
"into",
"columns",
"either",
"by",
"CSV",
"table",
"GS",
"or",
"direct",
"input",
"continue",
"with",
"other",
"operations",
"."
] | 245c267e832968bad880ca009929043e82c7bc25 | https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/data.src.js#L153-L172 | train | |
MakerCollider/node-red-contrib-smartnode-hook | html/scripts/highchart/modules/data.src.js | function (str, inside) {
if (typeof str === 'string') {
str = str.replace(/^\s+|\s+$/g, '');
// Clear white space insdie the string, like thousands separators
if (inside && /^[0-9\s]+$/.test(str)) {
str = str.replace(/\s/g, '');
}
if (this.decimalRegex) {
str = str.replace(this.decimalRegex,... | javascript | function (str, inside) {
if (typeof str === 'string') {
str = str.replace(/^\s+|\s+$/g, '');
// Clear white space insdie the string, like thousands separators
if (inside && /^[0-9\s]+$/.test(str)) {
str = str.replace(/\s/g, '');
}
if (this.decimalRegex) {
str = str.replace(this.decimalRegex,... | [
"function",
"(",
"str",
",",
"inside",
")",
"{",
"if",
"(",
"typeof",
"str",
"===",
"'string'",
")",
"{",
"str",
"=",
"str",
".",
"replace",
"(",
"/",
"^\\s+|\\s+$",
"/",
"g",
",",
"''",
")",
";",
"// Clear white space insdie the string, like thousands separ... | Trim a string from whitespace | [
"Trim",
"a",
"string",
"from",
"whitespace"
] | 245c267e832968bad880ca009929043e82c7bc25 | https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/data.src.js#L332-L346 | train | |
gethuman/pancakes-angular | lib/ngapp/tap.track.js | doAction | function doAction() {
var now = (new Date()).getTime();
var diff = now - lastTapTime;
var isDiffElemSafeDelay = elem !== lastElemTapped && diff > 200;
var isSameElemSafeDelay = elem === lastElemTapped && diff > sameElemSafeDelay;
if (tapped && (isDiffElemSafe... | javascript | function doAction() {
var now = (new Date()).getTime();
var diff = now - lastTapTime;
var isDiffElemSafeDelay = elem !== lastElemTapped && diff > 200;
var isSameElemSafeDelay = elem === lastElemTapped && diff > sameElemSafeDelay;
if (tapped && (isDiffElemSafe... | [
"function",
"doAction",
"(",
")",
"{",
"var",
"now",
"=",
"(",
"new",
"Date",
"(",
")",
")",
".",
"getTime",
"(",
")",
";",
"var",
"diff",
"=",
"now",
"-",
"lastTapTime",
";",
"var",
"isDiffElemSafeDelay",
"=",
"elem",
"!==",
"lastElemTapped",
"&&",
... | Attempt to do the action as long as tap not already in progress | [
"Attempt",
"to",
"do",
"the",
"action",
"as",
"long",
"as",
"tap",
"not",
"already",
"in",
"progress"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/ngapp/tap.track.js#L29-L43 | train |
pratishshr/sort-o | src/sorto.js | getComparator | function getComparator(sortOrder) {
if (typeof sortOrder === 'function') {
return sortOrder;
}
const comparators = {
[ASC]: ascendingSort,
[DESC]: descendingSort,
[ASC_LENGTH]: lengthSort,
[DESC_LENGTH]: lengthReverseSort
};
return comparators[sortOrder];
} | javascript | function getComparator(sortOrder) {
if (typeof sortOrder === 'function') {
return sortOrder;
}
const comparators = {
[ASC]: ascendingSort,
[DESC]: descendingSort,
[ASC_LENGTH]: lengthSort,
[DESC_LENGTH]: lengthReverseSort
};
return comparators[sortOrder];
} | [
"function",
"getComparator",
"(",
"sortOrder",
")",
"{",
"if",
"(",
"typeof",
"sortOrder",
"===",
"'function'",
")",
"{",
"return",
"sortOrder",
";",
"}",
"const",
"comparators",
"=",
"{",
"[",
"ASC",
"]",
":",
"ascendingSort",
",",
"[",
"DESC",
"]",
":"... | Returns appropriate comparator as per the sort string.
If a function is supplied, it returns the function itself.
@param {String|Function} sortOrder
@returns {Function} | [
"Returns",
"appropriate",
"comparator",
"as",
"per",
"the",
"sort",
"string",
".",
"If",
"a",
"function",
"is",
"supplied",
"it",
"returns",
"the",
"function",
"itself",
"."
] | 5bd5d659f4ea518fd5705d5ab96e2694fb6ecfe6 | https://github.com/pratishshr/sort-o/blob/5bd5d659f4ea518fd5705d5ab96e2694fb6ecfe6/src/sorto.js#L13-L26 | train |
ryanfitzer/comment-serializer | index.js | stripAndSerializeComment | function stripAndSerializeComment( lineNumber, sourceStr ) {
// Strip comment delimiter tokens
let stripped = sourceStr
.replace( patterns.commentBegin, '' )
.replace( patterns.commentEnd, '' )
.split( '\n' )
.map( line => line.replace( rCommentLinePrefix, '' ) );
... | javascript | function stripAndSerializeComment( lineNumber, sourceStr ) {
// Strip comment delimiter tokens
let stripped = sourceStr
.replace( patterns.commentBegin, '' )
.replace( patterns.commentEnd, '' )
.split( '\n' )
.map( line => line.replace( rCommentLinePrefix, '' ) );
... | [
"function",
"stripAndSerializeComment",
"(",
"lineNumber",
",",
"sourceStr",
")",
"{",
"// Strip comment delimiter tokens",
"let",
"stripped",
"=",
"sourceStr",
".",
"replace",
"(",
"patterns",
".",
"commentBegin",
",",
"''",
")",
".",
"replace",
"(",
"patterns",
... | Strip and serialize a comment into its various parts.
- comment: the comment block stripped delimiters and leading spaces.
- preface
- tags
@param {Number} lineNumber The comment's starting line number.
@param {String} sourceStr The comment's source.
@returns {Object} | [
"Strip",
"and",
"serialize",
"a",
"comment",
"into",
"its",
"various",
"parts",
"."
] | 73c2b961f54af42d357737b4f13c137269912549 | https://github.com/ryanfitzer/comment-serializer/blob/73c2b961f54af42d357737b4f13c137269912549/index.js#L81-L123 | train |
ryanfitzer/comment-serializer | index.js | serializeTags | function serializeTags( lineNumber, tags ) {
return tags.split( /\n/ )
.reduce( function ( acc, line, index ) {
if ( !index || rTagName.test( line ) ) {
acc.push( `${line}\n` );
}
else {
acc[ acc.length - 1 ] += `${line}\n`;
... | javascript | function serializeTags( lineNumber, tags ) {
return tags.split( /\n/ )
.reduce( function ( acc, line, index ) {
if ( !index || rTagName.test( line ) ) {
acc.push( `${line}\n` );
}
else {
acc[ acc.length - 1 ] += `${line}\n`;
... | [
"function",
"serializeTags",
"(",
"lineNumber",
",",
"tags",
")",
"{",
"return",
"tags",
".",
"split",
"(",
"/",
"\\n",
"/",
")",
".",
"reduce",
"(",
"function",
"(",
"acc",
",",
"line",
",",
"index",
")",
"{",
"if",
"(",
"!",
"index",
"||",
"rTagN... | Takes a tags block and serializes it into individual tag objects.
@param {Number} lineNumber The tags block starting line number.
@param {String} tags The tags block.
@returns {Array} | [
"Takes",
"a",
"tags",
"block",
"and",
"serializes",
"it",
"into",
"individual",
"tag",
"objects",
"."
] | 73c2b961f54af42d357737b4f13c137269912549 | https://github.com/ryanfitzer/comment-serializer/blob/73c2b961f54af42d357737b4f13c137269912549/index.js#L132-L182 | train |
iopa-io/iopa-test | src/stubServer.js | StubServer | function StubServer(app) {
_classCallCheck(this, StubServer);
this._app = app;
app.createServer = this.createServer_.bind(this, app.createServer || function () { throw new Error("no registered transport provider"); });
} | javascript | function StubServer(app) {
_classCallCheck(this, StubServer);
this._app = app;
app.createServer = this.createServer_.bind(this, app.createServer || function () { throw new Error("no registered transport provider"); });
} | [
"function",
"StubServer",
"(",
"app",
")",
"{",
"_classCallCheck",
"(",
"this",
",",
"StubServer",
")",
";",
"this",
".",
"_app",
"=",
"app",
";",
"app",
".",
"createServer",
"=",
"this",
".",
"createServer_",
".",
"bind",
"(",
"this",
",",
"app",
".",... | Representes Stub Server
@class StubServer
@param app IOPA AppBuilder App
@constructor
@public | [
"Representes",
"Stub",
"Server"
] | 1fac6ea54d4e0e83f4b1278897dfa9a4dc684543 | https://github.com/iopa-io/iopa-test/blob/1fac6ea54d4e0e83f4b1278897dfa9a4dc684543/src/stubServer.js#L37-L43 | train |
Elao/validator-framework | src/validator.js | getValueAt | function getValueAt(dataObject, path)
{
if (_.isUndefined(dataObject)) {
return undefined;
}
if (!_.isString(path)) {
return dataObject;
}
var tokens = path.split('.');
var property = tokens[0];
var subpath = tokens.slice(1).join('.... | javascript | function getValueAt(dataObject, path)
{
if (_.isUndefined(dataObject)) {
return undefined;
}
if (!_.isString(path)) {
return dataObject;
}
var tokens = path.split('.');
var property = tokens[0];
var subpath = tokens.slice(1).join('.... | [
"function",
"getValueAt",
"(",
"dataObject",
",",
"path",
")",
"{",
"if",
"(",
"_",
".",
"isUndefined",
"(",
"dataObject",
")",
")",
"{",
"return",
"undefined",
";",
"}",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"path",
")",
")",
"{",
"return",
"... | Given a data object and a path, return the corresponding value
@param object data A data object
@param string path A value path with dot notation
@return mixed Return the value found at path or undefined if value doesn't exists | [
"Given",
"a",
"data",
"object",
"and",
"a",
"path",
"return",
"the",
"corresponding",
"value"
] | 77a91e655d3a65f1098e868404a59ee60d2a0f95 | https://github.com/Elao/validator-framework/blob/77a91e655d3a65f1098e868404a59ee60d2a0f95/src/validator.js#L38-L58 | train |
Elao/validator-framework | src/validator.js | matchGroups | function matchGroups(groupsConfig, wantedGroups)
{
var defaultGroups = ['default'];
var groups = _.map([groupsConfig, wantedGroups], function(grp) {
if (_.isUndefined(grp)) {
return defaultGroups;
} else if (_.isString(grp)) {
return [grp];
... | javascript | function matchGroups(groupsConfig, wantedGroups)
{
var defaultGroups = ['default'];
var groups = _.map([groupsConfig, wantedGroups], function(grp) {
if (_.isUndefined(grp)) {
return defaultGroups;
} else if (_.isString(grp)) {
return [grp];
... | [
"function",
"matchGroups",
"(",
"groupsConfig",
",",
"wantedGroups",
")",
"{",
"var",
"defaultGroups",
"=",
"[",
"'default'",
"]",
";",
"var",
"groups",
"=",
"_",
".",
"map",
"(",
"[",
"groupsConfig",
",",
"wantedGroups",
"]",
",",
"function",
"(",
"grp",
... | Given 2 lists of groups, return true if the two groups lists share common groups and false otherwise
Return the default group if the group value is invalid
@param array groupsConfig The first groups list
@param array wantedGroups The second groups list
@return boolean true if groups lists match | [
"Given",
"2",
"lists",
"of",
"groups",
"return",
"true",
"if",
"the",
"two",
"groups",
"lists",
"share",
"common",
"groups",
"and",
"false",
"otherwise",
"Return",
"the",
"default",
"group",
"if",
"the",
"group",
"value",
"is",
"invalid"
] | 77a91e655d3a65f1098e868404a59ee60d2a0f95 | https://github.com/Elao/validator-framework/blob/77a91e655d3a65f1098e868404a59ee60d2a0f95/src/validator.js#L67-L88 | train |
Elao/validator-framework | src/validator.js | RulesConfigurationError | function RulesConfigurationError(message, path)
{
var self = new Error();
self.path = path;
self.message = "Rules configuration error : "+message+(path ? " at path : "+path : "");
self.name = 'RulesConfigurationError';
self.__proto__ = RulesConfigurationErro... | javascript | function RulesConfigurationError(message, path)
{
var self = new Error();
self.path = path;
self.message = "Rules configuration error : "+message+(path ? " at path : "+path : "");
self.name = 'RulesConfigurationError';
self.__proto__ = RulesConfigurationErro... | [
"function",
"RulesConfigurationError",
"(",
"message",
",",
"path",
")",
"{",
"var",
"self",
"=",
"new",
"Error",
"(",
")",
";",
"self",
".",
"path",
"=",
"path",
";",
"self",
".",
"message",
"=",
"\"Rules configuration error : \"",
"+",
"message",
"+",
"(... | Error class for invalid rules definition
@param string message The error message
@param string path The path of the invalid definition | [
"Error",
"class",
"for",
"invalid",
"rules",
"definition"
] | 77a91e655d3a65f1098e868404a59ee60d2a0f95 | https://github.com/Elao/validator-framework/blob/77a91e655d3a65f1098e868404a59ee60d2a0f95/src/validator.js#L95-L103 | train |
Elao/validator-framework | src/validator.js | function(path, fieldValue, errors, errorsContent)
{
var e = {};
var er = {};
if (_.isArray(errors) && errors.length > 0) {
er.errors = errors;
}
if (_.isArray(errorsContent) && errorsContent.length > 0) {
er.content = errorsContent;
}
... | javascript | function(path, fieldValue, errors, errorsContent)
{
var e = {};
var er = {};
if (_.isArray(errors) && errors.length > 0) {
er.errors = errors;
}
if (_.isArray(errorsContent) && errorsContent.length > 0) {
er.content = errorsContent;
}
... | [
"function",
"(",
"path",
",",
"fieldValue",
",",
"errors",
",",
"errorsContent",
")",
"{",
"var",
"e",
"=",
"{",
"}",
";",
"var",
"er",
"=",
"{",
"}",
";",
"if",
"(",
"_",
".",
"isArray",
"(",
"errors",
")",
"&&",
"errors",
".",
"length",
">",
... | Error class to handle validation errors on a field
@param string path The field's path
@param mixed fieldValue The field value
@param array errors An array of ValidationError
@param array errorsContent An array of ValidationError on the field children | [
"Error",
"class",
"to",
"handle",
"validation",
"errors",
"on",
"a",
"field"
] | 77a91e655d3a65f1098e868404a59ee60d2a0f95 | https://github.com/Elao/validator-framework/blob/77a91e655d3a65f1098e868404a59ee60d2a0f95/src/validator.js#L313-L334 | train | |
Elao/validator-framework | src/validator.js | FieldValidator | function FieldValidator(rules, config)
{
this.rules = rules;
this.fieldLabel = undefined;
if (config) {
this.setConfig(config);
}
} | javascript | function FieldValidator(rules, config)
{
this.rules = rules;
this.fieldLabel = undefined;
if (config) {
this.setConfig(config);
}
} | [
"function",
"FieldValidator",
"(",
"rules",
",",
"config",
")",
"{",
"this",
".",
"rules",
"=",
"rules",
";",
"this",
".",
"fieldLabel",
"=",
"undefined",
";",
"if",
"(",
"config",
")",
"{",
"this",
".",
"setConfig",
"(",
"config",
")",
";",
"}",
"}"... | Object to validate rules again data field
@param array rules list of rules to apply
@param object config configuration object | [
"Object",
"to",
"validate",
"rules",
"again",
"data",
"field"
] | 77a91e655d3a65f1098e868404a59ee60d2a0f95 | https://github.com/Elao/validator-framework/blob/77a91e655d3a65f1098e868404a59ee60d2a0f95/src/validator.js#L357-L364 | train |
Elao/validator-framework | src/validator.js | Validator | function Validator(type, config)
{
this.type = type;
this.message = undefined;
this.value = undefined;
this.groups = undefined;
this.fieldValidator = undefined;
this.parent = undefined;
if (typeof(config) === 'object'... | javascript | function Validator(type, config)
{
this.type = type;
this.message = undefined;
this.value = undefined;
this.groups = undefined;
this.fieldValidator = undefined;
this.parent = undefined;
if (typeof(config) === 'object'... | [
"function",
"Validator",
"(",
"type",
",",
"config",
")",
"{",
"this",
".",
"type",
"=",
"type",
";",
"this",
".",
"message",
"=",
"undefined",
";",
"this",
".",
"value",
"=",
"undefined",
";",
"this",
".",
"groups",
"=",
"undefined",
";",
"this",
".... | Validator object validate a data based on a configured rule. It raise an error or reject a promise
@param string type The validator type (must be present in the rules objects)
@param object config The validator type configuration | [
"Validator",
"object",
"validate",
"a",
"data",
"based",
"on",
"a",
"configured",
"rule",
".",
"It",
"raise",
"an",
"error",
"or",
"reject",
"a",
"promise"
] | 77a91e655d3a65f1098e868404a59ee60d2a0f95 | https://github.com/Elao/validator-framework/blob/77a91e655d3a65f1098e868404a59ee60d2a0f95/src/validator.js#L521-L544 | 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.