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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
redisjs/jsr-error | lib/index.js | CommandArgLength | function CommandArgLength(cmd) {
this.name = CommandArgLength.name;
if(arguments.length > 1) {
cmd = slice.call(arguments, 0).join(' ');
}
StoreError.apply(
this, [null, 'wrong number of arguments for \'%s\' command', cmd]);
} | javascript | function CommandArgLength(cmd) {
this.name = CommandArgLength.name;
if(arguments.length > 1) {
cmd = slice.call(arguments, 0).join(' ');
}
StoreError.apply(
this, [null, 'wrong number of arguments for \'%s\' command', cmd]);
} | [
"function",
"CommandArgLength",
"(",
"cmd",
")",
"{",
"this",
".",
"name",
"=",
"CommandArgLength",
".",
"name",
";",
"if",
"(",
"arguments",
".",
"length",
">",
"1",
")",
"{",
"cmd",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"0",
")",
".",
... | Encapsulates an argument length error. | [
"Encapsulates",
"an",
"argument",
"length",
"error",
"."
] | f27ff57f90683895643d0ecc44feaf9bf8a18ae3 | https://github.com/redisjs/jsr-error/blob/f27ff57f90683895643d0ecc44feaf9bf8a18ae3/lib/index.js#L45-L52 | train |
redisjs/jsr-error | lib/index.js | ConfigValue | function ConfigValue(key, value) {
this.name = ConfigValue.name;
StoreError.apply(
this, [null, 'invalid argument \'%s\' for CONFIG SET \'%s\'', value, key]);
} | javascript | function ConfigValue(key, value) {
this.name = ConfigValue.name;
StoreError.apply(
this, [null, 'invalid argument \'%s\' for CONFIG SET \'%s\'', value, key]);
} | [
"function",
"ConfigValue",
"(",
"key",
",",
"value",
")",
"{",
"this",
".",
"name",
"=",
"ConfigValue",
".",
"name",
";",
"StoreError",
".",
"apply",
"(",
"this",
",",
"[",
"null",
",",
"'invalid argument \\'%s\\' for CONFIG SET \\'%s\\''",
",",
"value",
",",
... | Encapsulates a config value error. | [
"Encapsulates",
"a",
"config",
"value",
"error",
"."
] | f27ff57f90683895643d0ecc44feaf9bf8a18ae3 | https://github.com/redisjs/jsr-error/blob/f27ff57f90683895643d0ecc44feaf9bf8a18ae3/lib/index.js#L70-L74 | train |
DScheglov/merest-swagger | lib/model-api-app.js | exposeSwagger | function exposeSwagger(path, options) {
if (typeof path !== 'string') {
options = path;
path = null;
}
path = path || '/swagger.json';
options = options || {};
var needCors = options.cors; delete options.cors;
var beautify = options.beautify; delete options.beautify;
beautify = beautify =... | javascript | function exposeSwagger(path, options) {
if (typeof path !== 'string') {
options = path;
path = null;
}
path = path || '/swagger.json';
options = options || {};
var needCors = options.cors; delete options.cors;
var beautify = options.beautify; delete options.beautify;
beautify = beautify =... | [
"function",
"exposeSwagger",
"(",
"path",
",",
"options",
")",
"{",
"if",
"(",
"typeof",
"path",
"!==",
"'string'",
")",
"{",
"options",
"=",
"path",
";",
"path",
"=",
"null",
";",
"}",
"path",
"=",
"path",
"||",
"'/swagger.json'",
";",
"options",
"=",... | exposeSwagger exposes the swagger document. If document is not created
the method forces model description;
@param {String} [path='/swagger.json'] path to mount swagger document
@param {Object} [options] options for swagger document exposition
@param {boolean} [options.cors=true] should the swagger doc be ex... | [
"exposeSwagger",
"exposes",
"the",
"swagger",
"document",
".",
"If",
"document",
"is",
"not",
"created",
"the",
"method",
"forces",
"model",
"description",
";"
] | 764ef9464dcfe5bf3f355293c2a9cb45eb42e49e | https://github.com/DScheglov/merest-swagger/blob/764ef9464dcfe5bf3f355293c2a9cb45eb42e49e/lib/model-api-app.js#L37-L57 | train |
DScheglov/merest-swagger | lib/model-api-app.js | exposeSwaggerUi | function exposeSwaggerUi(path, options) {
if (typeof path !== 'string') {
options = path;
path = null;
}
options = options || {};
var swaggerDoc = options.swaggerDoc; delete options.swaggerDoc;
if (!this.__swaggerDocURL) {
this.exposeSwagger(swaggerDoc || '', options);
};
var ui... | javascript | function exposeSwaggerUi(path, options) {
if (typeof path !== 'string') {
options = path;
path = null;
}
options = options || {};
var swaggerDoc = options.swaggerDoc; delete options.swaggerDoc;
if (!this.__swaggerDocURL) {
this.exposeSwagger(swaggerDoc || '', options);
};
var ui... | [
"function",
"exposeSwaggerUi",
"(",
"path",
",",
"options",
")",
"{",
"if",
"(",
"typeof",
"path",
"!==",
"'string'",
")",
"{",
"options",
"=",
"path",
";",
"path",
"=",
"null",
";",
"}",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"swagge... | exposeSwaggerUi exposes swagger ui application
@param {String} [path='/swagger-ui'] the path to mount swagger ui app
@param {Object} [options] options to expose swagger ui
@param {String} [options.swaggerDoc='/swagger.json'] the path to mount swagger document
@param {boolean} [options.cors=true] should the... | [
"exposeSwaggerUi",
"exposes",
"swagger",
"ui",
"application"
] | 764ef9464dcfe5bf3f355293c2a9cb45eb42e49e | https://github.com/DScheglov/merest-swagger/blob/764ef9464dcfe5bf3f355293c2a9cb45eb42e49e/lib/model-api-app.js#L75-L94 | train |
samplx/samplx-agentdb | prepublish.js | getJSON | function getJSON(jsonUrl, done) {
var parsedUrl = url.parse(jsonUrl);
var options = {
"host" : parsedUrl.hostname,
"hostname": parsedUrl.hostname,
"port" : parsedUrl.port || 80,
"path" : parsedUrl.pathname,
"method" : "GET",
// "agent" : false,
};
... | javascript | function getJSON(jsonUrl, done) {
var parsedUrl = url.parse(jsonUrl);
var options = {
"host" : parsedUrl.hostname,
"hostname": parsedUrl.hostname,
"port" : parsedUrl.port || 80,
"path" : parsedUrl.pathname,
"method" : "GET",
// "agent" : false,
};
... | [
"function",
"getJSON",
"(",
"jsonUrl",
",",
"done",
")",
"{",
"var",
"parsedUrl",
"=",
"url",
".",
"parse",
"(",
"jsonUrl",
")",
";",
"var",
"options",
"=",
"{",
"\"host\"",
":",
"parsedUrl",
".",
"hostname",
",",
"\"hostname\"",
":",
"parsedUrl",
".",
... | Download JSON object from a remote URL.
@param path to request.
@param done callback. | [
"Download",
"JSON",
"object",
"from",
"a",
"remote",
"URL",
"."
] | 4ded3176c8a9dceb3f2017f66581929d3cfc1084 | https://github.com/samplx/samplx-agentdb/blob/4ded3176c8a9dceb3f2017f66581929d3cfc1084/prepublish.js#L49-L81 | train |
samplx/samplx-agentdb | prepublish.js | main | function main() {
var database = fs.createWriteStream('./lib/database-min.js', { flags: 'w', encoding: 'utf8' });
var testFile;
fs.mkdir('./data', 493, function (error) { // 493 == 0755 (no octal in strict mode.)
// ignore errors.
});
database.write("// Do not edit this file, your ch... | javascript | function main() {
var database = fs.createWriteStream('./lib/database-min.js', { flags: 'w', encoding: 'utf8' });
var testFile;
fs.mkdir('./data', 493, function (error) { // 493 == 0755 (no octal in strict mode.)
// ignore errors.
});
database.write("// Do not edit this file, your ch... | [
"function",
"main",
"(",
")",
"{",
"var",
"database",
"=",
"fs",
".",
"createWriteStream",
"(",
"'./lib/database-min.js'",
",",
"{",
"flags",
":",
"'w'",
",",
"encoding",
":",
"'utf8'",
"}",
")",
";",
"var",
"testFile",
";",
"fs",
".",
"mkdir",
"(",
"'... | Main entry point for prepublish script. | [
"Main",
"entry",
"point",
"for",
"prepublish",
"script",
"."
] | 4ded3176c8a9dceb3f2017f66581929d3cfc1084 | https://github.com/samplx/samplx-agentdb/blob/4ded3176c8a9dceb3f2017f66581929d3cfc1084/prepublish.js#L86-L146 | train |
gethuman/pancakes-recipe | utils/date.utils.js | datePlusFrequency | function datePlusFrequency(date, frequency) {
var minutes;
date = date || new Date(); // default is today
frequency = frequency || 'hourly'; // default is hourly
switch (frequency) {
case 'none':
minutes = 525949; // set far in future
brea... | javascript | function datePlusFrequency(date, frequency) {
var minutes;
date = date || new Date(); // default is today
frequency = frequency || 'hourly'; // default is hourly
switch (frequency) {
case 'none':
minutes = 525949; // set far in future
brea... | [
"function",
"datePlusFrequency",
"(",
"date",
",",
"frequency",
")",
"{",
"var",
"minutes",
";",
"date",
"=",
"date",
"||",
"new",
"Date",
"(",
")",
";",
"// default is today",
"frequency",
"=",
"frequency",
"||",
"'hourly'",
";",
"// default is hourly",
"swit... | Get a date in the future based off the frequency
@param date The starting date
@param frequency [none, instant, hourly, daily, weekly] | [
"Get",
"a",
"date",
"in",
"the",
"future",
"based",
"off",
"the",
"frequency"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/utils/date.utils.js#L15-L42 | train |
gethuman/pancakes-recipe | utils/date.utils.js | serializeAllDates | function serializeAllDates(obj) {
// if it is a date, then return serialized version
if (_.isDate(obj)) {
return serializeDate(obj);
}
// if array or object, loop over it
if (_.isArray(obj) || _.isObject(obj)) {
_.forEach(obj, function (item, key) {
... | javascript | function serializeAllDates(obj) {
// if it is a date, then return serialized version
if (_.isDate(obj)) {
return serializeDate(obj);
}
// if array or object, loop over it
if (_.isArray(obj) || _.isObject(obj)) {
_.forEach(obj, function (item, key) {
... | [
"function",
"serializeAllDates",
"(",
"obj",
")",
"{",
"// if it is a date, then return serialized version",
"if",
"(",
"_",
".",
"isDate",
"(",
"obj",
")",
")",
"{",
"return",
"serializeDate",
"(",
"obj",
")",
";",
"}",
"// if array or object, loop over it",
"if",
... | Recursively go through object and convert dates
@param obj | [
"Recursively",
"go",
"through",
"object",
"and",
"convert",
"dates"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/utils/date.utils.js#L62-L77 | train |
clear/mongojs-hooks | mongojs-hooks.js | function (object) {
var result = { };
for (var i in object) {
if (!object.hasOwnProperty(i)) continue;
if (isObject(object[i])) {
var flatObject = this.flatten(object[i]);
for (var x in flatObject) {
if (!flatObject.hasOwnProperty(x)) continue;
result[i + '.' + x] = flatObject[x]... | javascript | function (object) {
var result = { };
for (var i in object) {
if (!object.hasOwnProperty(i)) continue;
if (isObject(object[i])) {
var flatObject = this.flatten(object[i]);
for (var x in flatObject) {
if (!flatObject.hasOwnProperty(x)) continue;
result[i + '.' + x] = flatObject[x]... | [
"function",
"(",
"object",
")",
"{",
"var",
"result",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"i",
"in",
"object",
")",
"{",
"if",
"(",
"!",
"object",
".",
"hasOwnProperty",
"(",
"i",
")",
")",
"continue",
";",
"if",
"(",
"isObject",
"(",
"object"... | Flattens an object into dot-notation | [
"Flattens",
"an",
"object",
"into",
"dot",
"-",
"notation"
] | 858b36cb49788f4c89478e2a4c400c652053171a | https://github.com/clear/mongojs-hooks/blob/858b36cb49788f4c89478e2a4c400c652053171a/mongojs-hooks.js#L123-L142 | train | |
tea-noma/tea-macro | lib/tea-macro/tea-macro.js | readFileSync_ | function readFileSync_(path){
if(file_values_[path]){
return file_values_[path];
}
try {
file_values_[path]=fs.readFileSync(path,'utf-8');
return file_values_[path];
}catch(e){
return null;
}
} | javascript | function readFileSync_(path){
if(file_values_[path]){
return file_values_[path];
}
try {
file_values_[path]=fs.readFileSync(path,'utf-8');
return file_values_[path];
}catch(e){
return null;
}
} | [
"function",
"readFileSync_",
"(",
"path",
")",
"{",
"if",
"(",
"file_values_",
"[",
"path",
"]",
")",
"{",
"return",
"file_values_",
"[",
"path",
"]",
";",
"}",
"try",
"{",
"file_values_",
"[",
"path",
"]",
"=",
"fs",
".",
"readFileSync",
"(",
"path",
... | read file with cache
@param path file path
@return file buffer | [
"read",
"file",
"with",
"cache"
] | 44fb3d48bc4044ae04ad13fc390ab468094be199 | https://github.com/tea-noma/tea-macro/blob/44fb3d48bc4044ae04ad13fc390ab468094be199/lib/tea-macro/tea-macro.js#L61-L71 | train |
tea-noma/tea-macro | lib/tea-macro/tea-macro.js | function(doc){
var vs=doc.split("\r\n");
if(vs.length==1){
vs=doc.split("\n");
}
if(vs[vs.length-1]==''){
vs.pop();
}
return vs;
} | javascript | function(doc){
var vs=doc.split("\r\n");
if(vs.length==1){
vs=doc.split("\n");
}
if(vs[vs.length-1]==''){
vs.pop();
}
return vs;
} | [
"function",
"(",
"doc",
")",
"{",
"var",
"vs",
"=",
"doc",
".",
"split",
"(",
"\"\\r\\n\"",
")",
";",
"if",
"(",
"vs",
".",
"length",
"==",
"1",
")",
"{",
"vs",
"=",
"doc",
".",
"split",
"(",
"\"\\n\"",
")",
";",
"}",
"if",
"(",
"vs",
"[",
... | split string by line terminator
@param doc target document
@return splited document | [
"split",
"string",
"by",
"line",
"terminator"
] | 44fb3d48bc4044ae04ad13fc390ab468094be199 | https://github.com/tea-noma/tea-macro/blob/44fb3d48bc4044ae04ad13fc390ab468094be199/lib/tea-macro/tea-macro.js#L77-L86 | train | |
tea-noma/tea-macro | lib/tea-macro/tea-macro.js | toExpr | function toExpr(value,line){
var token=[];
var ctoken=token;
var newToken;
var stacks=[];
var c;
var ss='';
for(var i=0;i<value.length;i++){
c=value[i];
switch(c){
case ' ':
case "\t":
case ",":
if(ss!=""){
ctoken.push(ss);
ss="";
}
break;
case '(':
if(ss!=""){
console.log("wa... | javascript | function toExpr(value,line){
var token=[];
var ctoken=token;
var newToken;
var stacks=[];
var c;
var ss='';
for(var i=0;i<value.length;i++){
c=value[i];
switch(c){
case ' ':
case "\t":
case ",":
if(ss!=""){
ctoken.push(ss);
ss="";
}
break;
case '(':
if(ss!=""){
console.log("wa... | [
"function",
"toExpr",
"(",
"value",
",",
"line",
")",
"{",
"var",
"token",
"=",
"[",
"]",
";",
"var",
"ctoken",
"=",
"token",
";",
"var",
"newToken",
";",
"var",
"stacks",
"=",
"[",
"]",
";",
"var",
"c",
";",
"var",
"ss",
"=",
"''",
";",
"for",... | convert expression string to expression object
@param value (LISP style) expression string
@param line line number
@return expression object | [
"convert",
"expression",
"string",
"to",
"expression",
"object"
] | 44fb3d48bc4044ae04ad13fc390ab468094be199 | https://github.com/tea-noma/tea-macro/blob/44fb3d48bc4044ae04ad13fc390ab468094be199/lib/tea-macro/tea-macro.js#L123-L183 | train |
tea-noma/tea-macro | lib/tea-macro/tea-macro.js | makeFromFile | function makeFromFile(makefile,target){
var read;
var basedir='.';
if(makefile){
read = fs.createReadStream(makefile, {encoding: 'utf8'});
basedir=mpath.dirname(makefile);
}else{
process.stdin.resume();
process.stdin.setEncoding('utf8');
read = process.stdin;
}
read.on('data', function (data){
try {
... | javascript | function makeFromFile(makefile,target){
var read;
var basedir='.';
if(makefile){
read = fs.createReadStream(makefile, {encoding: 'utf8'});
basedir=mpath.dirname(makefile);
}else{
process.stdin.resume();
process.stdin.setEncoding('utf8');
read = process.stdin;
}
read.on('data', function (data){
try {
... | [
"function",
"makeFromFile",
"(",
"makefile",
",",
"target",
")",
"{",
"var",
"read",
";",
"var",
"basedir",
"=",
"'.'",
";",
"if",
"(",
"makefile",
")",
"{",
"read",
"=",
"fs",
".",
"createReadStream",
"(",
"makefile",
",",
"{",
"encoding",
":",
"'utf8... | make from file
@param makefile path of make file
@param target make target. if null, all targets are compiled. | [
"make",
"from",
"file"
] | 44fb3d48bc4044ae04ad13fc390ab468094be199 | https://github.com/tea-noma/tea-macro/blob/44fb3d48bc4044ae04ad13fc390ab468094be199/lib/tea-macro/tea-macro.js#L706-L725 | train |
aureooms/js-grammar | lib/ll1/_parse_lazy.js | _parse_lazy | function _parse_lazy(eof, productions, table, rule, tape, nonterminal, production) {
var shallow_materialize =
/*#__PURE__*/
function () {
var _ref = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(expected) {
return regeneratorRuntime.wrap(function _callee$(_context) {... | javascript | function _parse_lazy(eof, productions, table, rule, tape, nonterminal, production) {
var shallow_materialize =
/*#__PURE__*/
function () {
var _ref = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(expected) {
return regeneratorRuntime.wrap(function _callee$(_context) {... | [
"function",
"_parse_lazy",
"(",
"eof",
",",
"productions",
",",
"table",
",",
"rule",
",",
"tape",
",",
"nonterminal",
",",
"production",
")",
"{",
"var",
"shallow_materialize",
"=",
"/*#__PURE__*/",
"function",
"(",
")",
"{",
"var",
"_ref",
"=",
"_asyncToGe... | Table-driven predictive lazy parsing.
@param {Object} eof - The end-of-file symbol.
@param {Map} productions - The ll1 productions.
@param {Map} table - The symbol table.
@param {Array} rule - The production rule in use.
@param {Tape} tape - The tape from which to read the symbols from.
@param {String} nonterminal - T... | [
"Table",
"-",
"driven",
"predictive",
"lazy",
"parsing",
"."
] | 28c4d1a3175327b33766c34539eab317303e26c5 | https://github.com/aureooms/js-grammar/blob/28c4d1a3175327b33766c34539eab317303e26c5/lib/ll1/_parse_lazy.js#L30-L67 | train |
unclechu/node-njst | lib/parser.js | complexReturn | function complexReturn(result, data) {
var complex = new String(result);
for (var key in data) {
complex[key] = data[key];
}
return complex;
} | javascript | function complexReturn(result, data) {
var complex = new String(result);
for (var key in data) {
complex[key] = data[key];
}
return complex;
} | [
"function",
"complexReturn",
"(",
"result",
",",
"data",
")",
"{",
"var",
"complex",
"=",
"new",
"String",
"(",
"result",
")",
";",
"for",
"(",
"var",
"key",
"in",
"data",
")",
"{",
"complex",
"[",
"key",
"]",
"=",
"data",
"[",
"key",
"]",
";",
"... | Merge and returns result parsed string as object with additional properties.
@property {string} result.status is "success" or "error"
@returns {string} String-object with additional properties | [
"Merge",
"and",
"returns",
"result",
"parsed",
"string",
"as",
"object",
"with",
"additional",
"properties",
"."
] | b934b24a70b134eff49cf0db991e4d404695067e | https://github.com/unclechu/node-njst/blob/b934b24a70b134eff49cf0db991e4d404695067e/lib/parser.js#L147-L153 | train |
Wizcorp/panopticon | lib/Sample.js | Sample | function Sample(val, timeStamp, persistObj) {
this.min = val;
this.max = val;
this.sigma = new StandardDeviation(val);
this.average = new Average(val);
this.timeStamp = timeStamp;
if (persistObj) {
var that = this;
persistObj.on('reset', function (timeStamp) {
that.reset(timeStamp);
});
}
} | javascript | function Sample(val, timeStamp, persistObj) {
this.min = val;
this.max = val;
this.sigma = new StandardDeviation(val);
this.average = new Average(val);
this.timeStamp = timeStamp;
if (persistObj) {
var that = this;
persistObj.on('reset', function (timeStamp) {
that.reset(timeStamp);
});
}
} | [
"function",
"Sample",
"(",
"val",
",",
"timeStamp",
",",
"persistObj",
")",
"{",
"this",
".",
"min",
"=",
"val",
";",
"this",
".",
"max",
"=",
"val",
";",
"this",
".",
"sigma",
"=",
"new",
"StandardDeviation",
"(",
"val",
")",
";",
"this",
".",
"av... | Sample taker object constructor.
@param {Number} val This first value is used to initialise the sample.
@param {Number} timeStamp A unix time stamp (in ms).
@param {Object} persistObj If we are persisting then we don't initialise.
@constructor
@alias module:Sample | [
"Sample",
"taker",
"object",
"constructor",
"."
] | e0d660cd5287b45aafdb5a91e54affa7364b14e0 | https://github.com/Wizcorp/panopticon/blob/e0d660cd5287b45aafdb5a91e54affa7364b14e0/lib/Sample.js#L15-L29 | train |
tolokoban/ToloFrameWork | lib/compiler-com.js | isHtmlFileUptodate | function isHtmlFileUptodate(source) {
var dependencies = source.tag("dependencies") || [];
var i, dep, file, prj = source.prj(),
stat,
mtime = source.modificationTime();
for (i = 0 ; i < dependencies.length ; i++) {
dep = dependencies[i];
file = prj.srcOrLibPath(dep);
if (fil... | javascript | function isHtmlFileUptodate(source) {
var dependencies = source.tag("dependencies") || [];
var i, dep, file, prj = source.prj(),
stat,
mtime = source.modificationTime();
for (i = 0 ; i < dependencies.length ; i++) {
dep = dependencies[i];
file = prj.srcOrLibPath(dep);
if (fil... | [
"function",
"isHtmlFileUptodate",
"(",
"source",
")",
"{",
"var",
"dependencies",
"=",
"source",
".",
"tag",
"(",
"\"dependencies\"",
")",
"||",
"[",
"]",
";",
"var",
"i",
",",
"dep",
",",
"file",
",",
"prj",
"=",
"source",
".",
"prj",
"(",
")",
",",... | To be uptodate, an HTML page must be more recent that all its dependencies. | [
"To",
"be",
"uptodate",
"an",
"HTML",
"page",
"must",
"be",
"more",
"recent",
"that",
"all",
"its",
"dependencies",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/compiler-com.js#L138-L152 | train |
tjmehta/mongooseware | lib/middleware-class-factories/collection.js | function (item, req, eachReq, res, next) {
eachReq.item = item;
eachReq[indexKey] = index;
index++;
next();
} | javascript | function (item, req, eachReq, res, next) {
eachReq.item = item;
eachReq[indexKey] = index;
index++;
next();
} | [
"function",
"(",
"item",
",",
"req",
",",
"eachReq",
",",
"res",
",",
"next",
")",
"{",
"eachReq",
".",
"item",
"=",
"item",
";",
"eachReq",
"[",
"indexKey",
"]",
"=",
"index",
";",
"index",
"++",
";",
"next",
"(",
")",
";",
"}"
] | self.collectionKey is correct here | [
"self",
".",
"collectionKey",
"is",
"correct",
"here"
] | c62ce0bac82880826b3528231e08f5e5b3efdb83 | https://github.com/tjmehta/mongooseware/blob/c62ce0bac82880826b3528231e08f5e5b3efdb83/lib/middleware-class-factories/collection.js#L45-L50 | train | |
gethuman/pancakes-hapi | lib/pancakes.hapi.plugin.js | PancakesHapiPlugin | function PancakesHapiPlugin(opts) {
this.pancakes = opts.pluginOptions.pancakes;
this.jangular = opts.pluginOptions.jangular;
} | javascript | function PancakesHapiPlugin(opts) {
this.pancakes = opts.pluginOptions.pancakes;
this.jangular = opts.pluginOptions.jangular;
} | [
"function",
"PancakesHapiPlugin",
"(",
"opts",
")",
"{",
"this",
".",
"pancakes",
"=",
"opts",
".",
"pluginOptions",
".",
"pancakes",
";",
"this",
".",
"jangular",
"=",
"opts",
".",
"pluginOptions",
".",
"jangular",
";",
"}"
] | Constructor sets up the plugin
@param opts
@constructor | [
"Constructor",
"sets",
"up",
"the",
"plugin"
] | 1167cd7564cd8949c446c6fd8d95185f52b14492 | https://github.com/gethuman/pancakes-hapi/blob/1167cd7564cd8949c446c6fd8d95185f52b14492/lib/pancakes.hapi.plugin.js#L16-L19 | train |
mdasberg/angular-test-setup | app/todo/todo.controller.js | _fetch | function _fetch() {
vm.error = undefined;
service.get({}, function (todos) {
vm.todos = todos;
}, function () {
vm.todos = [];
vm.error = 'An error occurred when fetching available todos';
});
} | javascript | function _fetch() {
vm.error = undefined;
service.get({}, function (todos) {
vm.todos = todos;
}, function () {
vm.todos = [];
vm.error = 'An error occurred when fetching available todos';
});
} | [
"function",
"_fetch",
"(",
")",
"{",
"vm",
".",
"error",
"=",
"undefined",
";",
"service",
".",
"get",
"(",
"{",
"}",
",",
"function",
"(",
"todos",
")",
"{",
"vm",
".",
"todos",
"=",
"todos",
";",
"}",
",",
"function",
"(",
")",
"{",
"vm",
"."... | Fetch the todo's
@private | [
"Fetch",
"the",
"todo",
"s"
] | 4a1ef0742bac233b94e7c3682e8158c00aa87552 | https://github.com/mdasberg/angular-test-setup/blob/4a1ef0742bac233b94e7c3682e8158c00aa87552/app/todo/todo.controller.js#L25-L33 | train |
mdasberg/angular-test-setup | app/todo/todo.controller.js | add | function add() {
vm.error = undefined;
service.add({
description: vm.description
}, function() {
_fetch();
}, function() {
vm.error = 'An error occurred when adding a todo';
});
vm.description = '';
... | javascript | function add() {
vm.error = undefined;
service.add({
description: vm.description
}, function() {
_fetch();
}, function() {
vm.error = 'An error occurred when adding a todo';
});
vm.description = '';
... | [
"function",
"add",
"(",
")",
"{",
"vm",
".",
"error",
"=",
"undefined",
";",
"service",
".",
"add",
"(",
"{",
"description",
":",
"vm",
".",
"description",
"}",
",",
"function",
"(",
")",
"{",
"_fetch",
"(",
")",
";",
"}",
",",
"function",
"(",
"... | Add the given todo.
@param todo The todo | [
"Add",
"the",
"given",
"todo",
"."
] | 4a1ef0742bac233b94e7c3682e8158c00aa87552 | https://github.com/mdasberg/angular-test-setup/blob/4a1ef0742bac233b94e7c3682e8158c00aa87552/app/todo/todo.controller.js#L39-L49 | train |
mdasberg/angular-test-setup | app/todo/todo.controller.js | complete | function complete(todo) {
vm.error = undefined;
service.complete(todo, function() {
_fetch();
}, function() {
vm.error = 'An error occurred when completing a todo';
});
} | javascript | function complete(todo) {
vm.error = undefined;
service.complete(todo, function() {
_fetch();
}, function() {
vm.error = 'An error occurred when completing a todo';
});
} | [
"function",
"complete",
"(",
"todo",
")",
"{",
"vm",
".",
"error",
"=",
"undefined",
";",
"service",
".",
"complete",
"(",
"todo",
",",
"function",
"(",
")",
"{",
"_fetch",
"(",
")",
";",
"}",
",",
"function",
"(",
")",
"{",
"vm",
".",
"error",
"... | Complete the given todo.
@param todo The todo | [
"Complete",
"the",
"given",
"todo",
"."
] | 4a1ef0742bac233b94e7c3682e8158c00aa87552 | https://github.com/mdasberg/angular-test-setup/blob/4a1ef0742bac233b94e7c3682e8158c00aa87552/app/todo/todo.controller.js#L55-L62 | train |
mdasberg/angular-test-setup | app/todo/todo.controller.js | archive | function archive() {
vm.error = undefined;
var promises = [];
vm.todos.filter(function (todo) {
return todo.completed;
}).forEach(function (todo) {
promises.push(_archive(todo));
});
$q.all(promises).then(function (... | javascript | function archive() {
vm.error = undefined;
var promises = [];
vm.todos.filter(function (todo) {
return todo.completed;
}).forEach(function (todo) {
promises.push(_archive(todo));
});
$q.all(promises).then(function (... | [
"function",
"archive",
"(",
")",
"{",
"vm",
".",
"error",
"=",
"undefined",
";",
"var",
"promises",
"=",
"[",
"]",
";",
"vm",
".",
"todos",
".",
"filter",
"(",
"function",
"(",
"todo",
")",
"{",
"return",
"todo",
".",
"completed",
";",
"}",
")",
... | Archive the completed todo's. | [
"Archive",
"the",
"completed",
"todo",
"s",
"."
] | 4a1ef0742bac233b94e7c3682e8158c00aa87552 | https://github.com/mdasberg/angular-test-setup/blob/4a1ef0742bac233b94e7c3682e8158c00aa87552/app/todo/todo.controller.js#L65-L79 | train |
mdasberg/angular-test-setup | app/todo/todo.controller.js | _archive | function _archive(todo) {
var deferred = $q.defer();
service.archive(todo, function () {
return deferred.resolve();
}, function () {
return deferred.reject();
});
return deferred.promise;
} | javascript | function _archive(todo) {
var deferred = $q.defer();
service.archive(todo, function () {
return deferred.resolve();
}, function () {
return deferred.reject();
});
return deferred.promise;
} | [
"function",
"_archive",
"(",
"todo",
")",
"{",
"var",
"deferred",
"=",
"$q",
".",
"defer",
"(",
")",
";",
"service",
".",
"archive",
"(",
"todo",
",",
"function",
"(",
")",
"{",
"return",
"deferred",
".",
"resolve",
"(",
")",
";",
"}",
",",
"functi... | Archive the given todo.
@param todo The todo.
@private | [
"Archive",
"the",
"given",
"todo",
"."
] | 4a1ef0742bac233b94e7c3682e8158c00aa87552 | https://github.com/mdasberg/angular-test-setup/blob/4a1ef0742bac233b94e7c3682e8158c00aa87552/app/todo/todo.controller.js#L96-L104 | train |
tgi-io/tgi-interface-bootstrap | dist/tgi-interface-bootstrap.js | function (args) {
if (false === (this instanceof Session)) throw new Error('new operator required');
args = args || {};
if (!args.attributes) {
args.attributes = [];
}
var userModelID = new Attribute.ModelID(new User());
args.attributes.push(new Attribute({name: 'userID', type: 'Model', value: userModel... | javascript | function (args) {
if (false === (this instanceof Session)) throw new Error('new operator required');
args = args || {};
if (!args.attributes) {
args.attributes = [];
}
var userModelID = new Attribute.ModelID(new User());
args.attributes.push(new Attribute({name: 'userID', type: 'Model', value: userModel... | [
"function",
"(",
"args",
")",
"{",
"if",
"(",
"false",
"===",
"(",
"this",
"instanceof",
"Session",
")",
")",
"throw",
"new",
"Error",
"(",
"'new operator required'",
")",
";",
"args",
"=",
"args",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"args",
".",
... | tequila
session-model
Model Constructor | [
"tequila",
"session",
"-",
"model",
"Model",
"Constructor"
] | 5681a8806cb855d3e2035b95e22502ae581bfd18 | https://github.com/tgi-io/tgi-interface-bootstrap/blob/5681a8806cb855d3e2035b95e22502ae581bfd18/dist/tgi-interface-bootstrap.js#L2525-L2541 | train | |
tgi-io/tgi-interface-bootstrap | dist/tgi-interface-bootstrap.js | function (args) {
if (false === (this instanceof User)) throw new Error('new operator required');
args = args || {};
if (!args.attributes) {
args.attributes = [];
}
args.attributes.push(new Attribute({name: 'name', type: 'String(20)'}));
args.attributes.push(new Attribute({name: 'active', type: 'Boolean... | javascript | function (args) {
if (false === (this instanceof User)) throw new Error('new operator required');
args = args || {};
if (!args.attributes) {
args.attributes = [];
}
args.attributes.push(new Attribute({name: 'name', type: 'String(20)'}));
args.attributes.push(new Attribute({name: 'active', type: 'Boolean... | [
"function",
"(",
"args",
")",
"{",
"if",
"(",
"false",
"===",
"(",
"this",
"instanceof",
"User",
")",
")",
"throw",
"new",
"Error",
"(",
"'new operator required'",
")",
";",
"args",
"=",
"args",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"args",
".",
"at... | tequila
user-core-model
Model Constructor | [
"tequila",
"user",
"-",
"core",
"-",
"model",
"Model",
"Constructor"
] | 5681a8806cb855d3e2035b95e22502ae581bfd18 | https://github.com/tgi-io/tgi-interface-bootstrap/blob/5681a8806cb855d3e2035b95e22502ae581bfd18/dist/tgi-interface-bootstrap.js#L2636-L2651 | train | |
tgi-io/tgi-interface-bootstrap | dist/tgi-interface-bootstrap.js | Workspace | function Workspace(args) {
if (false === (this instanceof Workspace)) throw new Error('new operator required');
args = args || {};
if (!args.attributes) {
args.attributes = [];
}
var userModelID = new Attribute.ModelID(new User());
args.attributes.push(new Attribute({name: 'user', type: 'Model', value: ... | javascript | function Workspace(args) {
if (false === (this instanceof Workspace)) throw new Error('new operator required');
args = args || {};
if (!args.attributes) {
args.attributes = [];
}
var userModelID = new Attribute.ModelID(new User());
args.attributes.push(new Attribute({name: 'user', type: 'Model', value: ... | [
"function",
"Workspace",
"(",
"args",
")",
"{",
"if",
"(",
"false",
"===",
"(",
"this",
"instanceof",
"Workspace",
")",
")",
"throw",
"new",
"Error",
"(",
"'new operator required'",
")",
";",
"args",
"=",
"args",
"||",
"{",
"}",
";",
"if",
"(",
"!",
... | tequila
workspace-class | [
"tequila",
"workspace",
"-",
"class"
] | 5681a8806cb855d3e2035b95e22502ae581bfd18 | https://github.com/tgi-io/tgi-interface-bootstrap/blob/5681a8806cb855d3e2035b95e22502ae581bfd18/dist/tgi-interface-bootstrap.js#L2658-L2673 | train |
tgi-io/tgi-interface-bootstrap | dist/tgi-interface-bootstrap.js | function (args) {
if (false === (this instanceof MemoryStore)) throw new Error('new operator required');
args = args || {};
this.storeType = args.storeType || "MemoryStore";
this.name = args.name || 'a ' + this.storeType;
this.storeProperty = {
isReady: true,
canGetModel: true,
canPutModel: true,
... | javascript | function (args) {
if (false === (this instanceof MemoryStore)) throw new Error('new operator required');
args = args || {};
this.storeType = args.storeType || "MemoryStore";
this.name = args.name || 'a ' + this.storeType;
this.storeProperty = {
isReady: true,
canGetModel: true,
canPutModel: true,
... | [
"function",
"(",
"args",
")",
"{",
"if",
"(",
"false",
"===",
"(",
"this",
"instanceof",
"MemoryStore",
")",
")",
"throw",
"new",
"Error",
"(",
"'new operator required'",
")",
";",
"args",
"=",
"args",
"||",
"{",
"}",
";",
"this",
".",
"storeType",
"="... | tequila
memory-store
Constructor | [
"tequila",
"memory",
"-",
"store",
"Constructor"
] | 5681a8806cb855d3e2035b95e22502ae581bfd18 | https://github.com/tgi-io/tgi-interface-bootstrap/blob/5681a8806cb855d3e2035b95e22502ae581bfd18/dist/tgi-interface-bootstrap.js#L2686-L2705 | train | |
tgi-io/tgi-interface-bootstrap | dist/tgi-interface-bootstrap.js | renderText | function renderText(text) {
var textDiv = addEle(panel.panelForm, 'div', indent ? 'col-sm-offset-3' : '');
textDiv.innerHTML = marked(text.get());
text.onEvent('StateChange', function () {
textDiv.innerHTML = marked(text.get());
});
panel.textListeners.push(text); // so we can avoid leakage on... | javascript | function renderText(text) {
var textDiv = addEle(panel.panelForm, 'div', indent ? 'col-sm-offset-3' : '');
textDiv.innerHTML = marked(text.get());
text.onEvent('StateChange', function () {
textDiv.innerHTML = marked(text.get());
});
panel.textListeners.push(text); // so we can avoid leakage on... | [
"function",
"renderText",
"(",
"text",
")",
"{",
"var",
"textDiv",
"=",
"addEle",
"(",
"panel",
".",
"panelForm",
",",
"'div'",
",",
"indent",
"?",
"'col-sm-offset-3'",
":",
"''",
")",
";",
"textDiv",
".",
"innerHTML",
"=",
"marked",
"(",
"text",
".",
... | function to render Attribute | [
"function",
"to",
"render",
"Attribute"
] | 5681a8806cb855d3e2035b95e22502ae581bfd18 | https://github.com/tgi-io/tgi-interface-bootstrap/blob/5681a8806cb855d3e2035b95e22502ae581bfd18/dist/tgi-interface-bootstrap.js#L3473-L3480 | train |
tgi-io/tgi-interface-bootstrap | dist/tgi-interface-bootstrap.js | function (event) {
switch (attribute.type) {
case 'Date':
attribute.value = (input.value === '') ? null : attribute.coerce(input.value);
if (attribute.value != null) {
var mm = attribute.value.getMonth() + 1;
var dd = attribute.value.getDate();
var y... | javascript | function (event) {
switch (attribute.type) {
case 'Date':
attribute.value = (input.value === '') ? null : attribute.coerce(input.value);
if (attribute.value != null) {
var mm = attribute.value.getMonth() + 1;
var dd = attribute.value.getDate();
var y... | [
"function",
"(",
"event",
")",
"{",
"switch",
"(",
"attribute",
".",
"type",
")",
"{",
"case",
"'Date'",
":",
"attribute",
".",
"value",
"=",
"(",
"input",
".",
"value",
"===",
"''",
")",
"?",
"null",
":",
"attribute",
".",
"coerce",
"(",
"input",
... | When focus lost on attribute - validate it | [
"When",
"focus",
"lost",
"on",
"attribute",
"-",
"validate",
"it"
] | 5681a8806cb855d3e2035b95e22502ae581bfd18 | https://github.com/tgi-io/tgi-interface-bootstrap/blob/5681a8806cb855d3e2035b95e22502ae581bfd18/dist/tgi-interface-bootstrap.js#L3657-L3680 | train | |
tgi-io/tgi-interface-bootstrap | dist/tgi-interface-bootstrap.js | renderHelpText | function renderHelpText(text) {
if (text) {
if (!helpTextDiv) {
helpTextDiv = document.createElement("div");
helpTextDiv.className = 'col-sm-9 col-sm-offset-3 has-error';
formGroup.appendChild(helpTextDiv);
}
helpTextDiv.innerHTML = '<span style="display: bloc... | javascript | function renderHelpText(text) {
if (text) {
if (!helpTextDiv) {
helpTextDiv = document.createElement("div");
helpTextDiv.className = 'col-sm-9 col-sm-offset-3 has-error';
formGroup.appendChild(helpTextDiv);
}
helpTextDiv.innerHTML = '<span style="display: bloc... | [
"function",
"renderHelpText",
"(",
"text",
")",
"{",
"if",
"(",
"text",
")",
"{",
"if",
"(",
"!",
"helpTextDiv",
")",
"{",
"helpTextDiv",
"=",
"document",
".",
"createElement",
"(",
"\"div\"",
")",
";",
"helpTextDiv",
".",
"className",
"=",
"'col-sm-9 col-... | so we can avoid leakage on deleting panel
For attribute error display | [
"so",
"we",
"can",
"avoid",
"leakage",
"on",
"deleting",
"panel",
"For",
"attribute",
"error",
"display"
] | 5681a8806cb855d3e2035b95e22502ae581bfd18 | https://github.com/tgi-io/tgi-interface-bootstrap/blob/5681a8806cb855d3e2035b95e22502ae581bfd18/dist/tgi-interface-bootstrap.js#L3723-L3745 | train |
tgi-io/tgi-interface-bootstrap | dist/tgi-interface-bootstrap.js | renderList | function renderList(list, theme) {
var txtDiv = document.createElement("table");
txtDiv.className = 'table table-condensed table-bordered table-hover-' + theme;
//bootstrapInterface.info(txtDiv.className);
/**
* Header
*/
var tHead = addEle(txtDiv, 'thead');
var tHeadRow = addEle(tH... | javascript | function renderList(list, theme) {
var txtDiv = document.createElement("table");
txtDiv.className = 'table table-condensed table-bordered table-hover-' + theme;
//bootstrapInterface.info(txtDiv.className);
/**
* Header
*/
var tHead = addEle(txtDiv, 'thead');
var tHeadRow = addEle(tH... | [
"function",
"renderList",
"(",
"list",
",",
"theme",
")",
"{",
"var",
"txtDiv",
"=",
"document",
".",
"createElement",
"(",
"\"table\"",
")",
";",
"txtDiv",
".",
"className",
"=",
"'table table-condensed table-bordered table-hover-'",
"+",
"theme",
";",
"//bootstr... | function to render List | [
"function",
"to",
"render",
"List"
] | 5681a8806cb855d3e2035b95e22502ae581bfd18 | https://github.com/tgi-io/tgi-interface-bootstrap/blob/5681a8806cb855d3e2035b95e22502ae581bfd18/dist/tgi-interface-bootstrap.js#L3751-L3818 | train |
tgi-io/tgi-interface-bootstrap | dist/tgi-interface-bootstrap.js | renderCommand | function renderCommand(command) {
if (!panel.buttonDiv) {
var formGroup = addEle(panel.panelForm, 'div', 'form-group');
panel.buttonDiv = addEle(formGroup, 'div', indent ? 'col-sm-offset-3 col-sm-9' : 'col-sm-9');
}
var cmdTheme = command.theme || 'default';
var button = addEle(panel.button... | javascript | function renderCommand(command) {
if (!panel.buttonDiv) {
var formGroup = addEle(panel.panelForm, 'div', 'form-group');
panel.buttonDiv = addEle(formGroup, 'div', indent ? 'col-sm-offset-3 col-sm-9' : 'col-sm-9');
}
var cmdTheme = command.theme || 'default';
var button = addEle(panel.button... | [
"function",
"renderCommand",
"(",
"command",
")",
"{",
"if",
"(",
"!",
"panel",
".",
"buttonDiv",
")",
"{",
"var",
"formGroup",
"=",
"addEle",
"(",
"panel",
".",
"panelForm",
",",
"'div'",
",",
"'form-group'",
")",
";",
"panel",
".",
"buttonDiv",
"=",
... | function to render Command | [
"function",
"to",
"render",
"Command"
] | 5681a8806cb855d3e2035b95e22502ae581bfd18 | https://github.com/tgi-io/tgi-interface-bootstrap/blob/5681a8806cb855d3e2035b95e22502ae581bfd18/dist/tgi-interface-bootstrap.js#L3823-L3848 | train |
byron-dupreez/aws-stream-consumer-core | tracking.js | setUnusableRecord | function setUnusableRecord(state, unusableRecord) {
Object.defineProperty(state, 'unusableRecord',
{value: unusableRecord, writable: true, configurable: true, enumerable: false});
} | javascript | function setUnusableRecord(state, unusableRecord) {
Object.defineProperty(state, 'unusableRecord',
{value: unusableRecord, writable: true, configurable: true, enumerable: false});
} | [
"function",
"setUnusableRecord",
"(",
"state",
",",
"unusableRecord",
")",
"{",
"Object",
".",
"defineProperty",
"(",
"state",
",",
"'unusableRecord'",
",",
"{",
"value",
":",
"unusableRecord",
",",
"writable",
":",
"true",
",",
"configurable",
":",
"true",
",... | Sets the given unusable record on its given state that is being tracked for the unusable record.
@param {UnusableRecordState} state - the tracked state to be updated
@param {UnusableRecord} unusableRecord - the unusable record to which this state belongs | [
"Sets",
"the",
"given",
"unusable",
"record",
"on",
"its",
"given",
"state",
"that",
"is",
"being",
"tracked",
"for",
"the",
"unusable",
"record",
"."
] | 9b256084297f80d373bcf483aaf68a9da176b3d7 | https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/tracking.js#L76-L79 | train |
byron-dupreez/aws-stream-consumer-core | tracking.js | setUserRecord | function setUserRecord(state, userRecord) {
Object.defineProperty(state, 'userRecord',
{value: userRecord, writable: true, configurable: true, enumerable: false});
} | javascript | function setUserRecord(state, userRecord) {
Object.defineProperty(state, 'userRecord',
{value: userRecord, writable: true, configurable: true, enumerable: false});
} | [
"function",
"setUserRecord",
"(",
"state",
",",
"userRecord",
")",
"{",
"Object",
".",
"defineProperty",
"(",
"state",
",",
"'userRecord'",
",",
"{",
"value",
":",
"userRecord",
",",
"writable",
":",
"true",
",",
"configurable",
":",
"true",
",",
"enumerable... | Sets the given user record on the given state that is being tracked for a message.
@param {MessageState} state - the tracked state to be updated
@param {UserRecord} userRecord - the user record to link to the state | [
"Sets",
"the",
"given",
"user",
"record",
"on",
"the",
"given",
"state",
"that",
"is",
"being",
"tracked",
"for",
"a",
"message",
"."
] | 9b256084297f80d373bcf483aaf68a9da176b3d7 | https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/tracking.js#L86-L89 | train |
byron-dupreez/aws-stream-consumer-core | tracking.js | setRecord | function setRecord(state, record) {
Object.defineProperty(state, 'record', {value: record, writable: true, configurable: true, enumerable: false});
} | javascript | function setRecord(state, record) {
Object.defineProperty(state, 'record', {value: record, writable: true, configurable: true, enumerable: false});
} | [
"function",
"setRecord",
"(",
"state",
",",
"record",
")",
"{",
"Object",
".",
"defineProperty",
"(",
"state",
",",
"'record'",
",",
"{",
"value",
":",
"record",
",",
"writable",
":",
"true",
",",
"configurable",
":",
"true",
",",
"enumerable",
":",
"fal... | Sets the given record on the given state that is being tracked for a message or unusable record.
@param {MessageState|UnusableRecordState} state - the tracked state to be updated
@param {Record} record - the record to link to the state | [
"Sets",
"the",
"given",
"record",
"on",
"the",
"given",
"state",
"that",
"is",
"being",
"tracked",
"for",
"a",
"message",
"or",
"unusable",
"record",
"."
] | 9b256084297f80d373bcf483aaf68a9da176b3d7 | https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/tracking.js#L96-L98 | train |
byron-dupreez/aws-stream-consumer-core | tracking.js | deleteLegacyState | function deleteLegacyState(trackedItem, context) {
const taskTrackingName = Settings.getLegacyTaskTrackingName(context);
return taskTrackingName && trackedItem ? delete trackedItem[taskTrackingName] : true;
} | javascript | function deleteLegacyState(trackedItem, context) {
const taskTrackingName = Settings.getLegacyTaskTrackingName(context);
return taskTrackingName && trackedItem ? delete trackedItem[taskTrackingName] : true;
} | [
"function",
"deleteLegacyState",
"(",
"trackedItem",
",",
"context",
")",
"{",
"const",
"taskTrackingName",
"=",
"Settings",
".",
"getLegacyTaskTrackingName",
"(",
"context",
")",
";",
"return",
"taskTrackingName",
"&&",
"trackedItem",
"?",
"delete",
"trackedItem",
... | Deletes any legacy task tracking state attached directly to the tracked item from previous runs of older versions of
aws-stream-consumer.
@param {TrackedItem} trackedItem - the tracked item from which to remove its legacy tracked state
@param {StreamConsumerContext} context - the context to use to resolve the name of t... | [
"Deletes",
"any",
"legacy",
"task",
"tracking",
"state",
"attached",
"directly",
"to",
"the",
"tracked",
"item",
"from",
"previous",
"runs",
"of",
"older",
"versions",
"of",
"aws",
"-",
"stream",
"-",
"consumer",
"."
] | 9b256084297f80d373bcf483aaf68a9da176b3d7 | https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/tracking.js#L154-L157 | train |
jonschlinkert/lint-templates | index.js | data | function data(app, file, key) {
var o = has(app.options, key);
var c = has(app.cache.data, key);
var d = has(file.data, key);
if (!c && !d && !o) {
set(file.data, key, comment(key, 'property'));
console.log(warning(' missing variable:'));
}
} | javascript | function data(app, file, key) {
var o = has(app.options, key);
var c = has(app.cache.data, key);
var d = has(file.data, key);
if (!c && !d && !o) {
set(file.data, key, comment(key, 'property'));
console.log(warning(' missing variable:'));
}
} | [
"function",
"data",
"(",
"app",
",",
"file",
",",
"key",
")",
"{",
"var",
"o",
"=",
"has",
"(",
"app",
".",
"options",
",",
"key",
")",
";",
"var",
"c",
"=",
"has",
"(",
"app",
".",
"cache",
".",
"data",
",",
"key",
")",
";",
"var",
"d",
"=... | Find missing data.
@param {Object} `app`
@param {Object} `file`
@param {String} `key`
@return {Object} | [
"Find",
"missing",
"data",
"."
] | a84aaaae1d7218c1a7671071c3264ef53bbb0732 | https://github.com/jonschlinkert/lint-templates/blob/a84aaaae1d7218c1a7671071c3264ef53bbb0732/index.js#L48-L56 | train |
jonschlinkert/lint-templates | index.js | helper | function helper(app, file, key, re) {
var h = get(app._.asyncHelpers, key);
var a = get(app._.helpers, key);
if (!h && !a) {
set(file.data, key, function () {
return comment(key, 'helper');
});
if (re.test(file.content)) {
var message = 'MISSING helper: "' + key + '".\n';
// rethro... | javascript | function helper(app, file, key, re) {
var h = get(app._.asyncHelpers, key);
var a = get(app._.helpers, key);
if (!h && !a) {
set(file.data, key, function () {
return comment(key, 'helper');
});
if (re.test(file.content)) {
var message = 'MISSING helper: "' + key + '".\n';
// rethro... | [
"function",
"helper",
"(",
"app",
",",
"file",
",",
"key",
",",
"re",
")",
"{",
"var",
"h",
"=",
"get",
"(",
"app",
".",
"_",
".",
"asyncHelpers",
",",
"key",
")",
";",
"var",
"a",
"=",
"get",
"(",
"app",
".",
"_",
".",
"helpers",
",",
"key",... | Find missing helpers.
@param {Object} `app`
@param {Object} `file`
@param {String} `key`
@return {Object} | [
"Find",
"missing",
"helpers",
"."
] | a84aaaae1d7218c1a7671071c3264ef53bbb0732 | https://github.com/jonschlinkert/lint-templates/blob/a84aaaae1d7218c1a7671071c3264ef53bbb0732/index.js#L67-L85 | train |
jonschlinkert/lint-templates | index.js | rethrow | function rethrow(err, fp, str, re) {
var lines = str.split('\n');
var len = lines.length, i = 0;
var res = '';
while (len--) {
var line = lines[i++];
if (re.test(line)) {
error(err, fp, i, str);
break;
}
}
} | javascript | function rethrow(err, fp, str, re) {
var lines = str.split('\n');
var len = lines.length, i = 0;
var res = '';
while (len--) {
var line = lines[i++];
if (re.test(line)) {
error(err, fp, i, str);
break;
}
}
} | [
"function",
"rethrow",
"(",
"err",
",",
"fp",
",",
"str",
",",
"re",
")",
"{",
"var",
"lines",
"=",
"str",
".",
"split",
"(",
"'\\n'",
")",
";",
"var",
"len",
"=",
"lines",
".",
"length",
",",
"i",
"=",
"0",
";",
"var",
"res",
"=",
"''",
";",... | Re-throw an error to get the line number and
postion to help with debuging.
@param {Error} `err` Pass an `Error` object
@param {Object} `fp` Pass `file.path`
@param {Object} `str` The content string
@param {Object} `re` RegExp to use for matching the template delimiters
@return {Object} | [
"Re",
"-",
"throw",
"an",
"error",
"to",
"get",
"the",
"line",
"number",
"and",
"postion",
"to",
"help",
"with",
"debuging",
"."
] | a84aaaae1d7218c1a7671071c3264ef53bbb0732 | https://github.com/jonschlinkert/lint-templates/blob/a84aaaae1d7218c1a7671071c3264ef53bbb0732/index.js#L115-L127 | train |
derdesign/protos | drivers/sqlite.js | SQLite | function SQLite(config) {
/*jshint bitwise: false */
var self = this;
config = config || {};
config.mode = config.mode || (sqlite3.OPEN_READWRITE | sqlite3.OPEN_CREATE);
if (!config.filename) {
// Exit if no filename provided
throw new Error("No filename provided for SQLite Driver");
... | javascript | function SQLite(config) {
/*jshint bitwise: false */
var self = this;
config = config || {};
config.mode = config.mode || (sqlite3.OPEN_READWRITE | sqlite3.OPEN_CREATE);
if (!config.filename) {
// Exit if no filename provided
throw new Error("No filename provided for SQLite Driver");
... | [
"function",
"SQLite",
"(",
"config",
")",
"{",
"/*jshint bitwise: false */",
"var",
"self",
"=",
"this",
";",
"config",
"=",
"config",
"||",
"{",
"}",
";",
"config",
".",
"mode",
"=",
"config",
".",
"mode",
"||",
"(",
"sqlite3",
".",
"OPEN_READWRITE",
"|... | SQLite Driver class
Driver configuration
config: {
filename: "data/mydb.sqlite"
}
@class SQLite
@extends Driver
@constructor
@param {object} app Application instance
@param {object} config Driver configuration | [
"SQLite",
"Driver",
"class"
] | 0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9 | https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/drivers/sqlite.js#L27-L68 | train |
deftly/node-deftly | src/dispatcher.js | createStacks | function createStacks (state) {
const serviceErrors = state.config.service.errors || {}
_.each(state.resources, function (resource) {
const resourceErrors = resource.errors
_.each(resource.actions, function (action, actionName) {
action.name = actionName
const actionErrors = action.errors
... | javascript | function createStacks (state) {
const serviceErrors = state.config.service.errors || {}
_.each(state.resources, function (resource) {
const resourceErrors = resource.errors
_.each(resource.actions, function (action, actionName) {
action.name = actionName
const actionErrors = action.errors
... | [
"function",
"createStacks",
"(",
"state",
")",
"{",
"const",
"serviceErrors",
"=",
"state",
".",
"config",
".",
"service",
".",
"errors",
"||",
"{",
"}",
"_",
".",
"each",
"(",
"state",
".",
"resources",
",",
"function",
"(",
"resource",
")",
"{",
"con... | iterate over all resources and actions and create the middleware and transform stacks for each resource!action pair | [
"iterate",
"over",
"all",
"resources",
"and",
"actions",
"and",
"create",
"the",
"middleware",
"and",
"transform",
"stacks",
"for",
"each",
"resource!action",
"pair"
] | 0c34205fd6726356b69bcdd6dec4fcba55027af6 | https://github.com/deftly/node-deftly/blob/0c34205fd6726356b69bcdd6dec4fcba55027af6/src/dispatcher.js#L35-L60 | train |
deftly/node-deftly | src/dispatcher.js | defaultErrorStrategy | function defaultErrorStrategy (env, error) {
return {
status: 500,
error: error,
data: `An unhandled error of '${error.name}' occurred at ${env.resource} - ${env.action}`
}
} | javascript | function defaultErrorStrategy (env, error) {
return {
status: 500,
error: error,
data: `An unhandled error of '${error.name}' occurred at ${env.resource} - ${env.action}`
}
} | [
"function",
"defaultErrorStrategy",
"(",
"env",
",",
"error",
")",
"{",
"return",
"{",
"status",
":",
"500",
",",
"error",
":",
"error",
",",
"data",
":",
"`",
"${",
"error",
".",
"name",
"}",
"${",
"env",
".",
"resource",
"}",
"${",
"env",
".",
"a... | not ideal perhaps, but something has to happen | [
"not",
"ideal",
"perhaps",
"but",
"something",
"has",
"to",
"happen"
] | 0c34205fd6726356b69bcdd6dec4fcba55027af6 | https://github.com/deftly/node-deftly/blob/0c34205fd6726356b69bcdd6dec4fcba55027af6/src/dispatcher.js#L63-L69 | train |
deftly/node-deftly | src/dispatcher.js | getProperty | function getProperty (service, resource, action, propertySpec) {
const parts = propertySpec.split('.')
var target
switch (parts[ 0 ]) {
case 'action':
target = action
break
case 'resource':
target = resource
break
default:
target = service
}
const property = parts[ 1 ... | javascript | function getProperty (service, resource, action, propertySpec) {
const parts = propertySpec.split('.')
var target
switch (parts[ 0 ]) {
case 'action':
target = action
break
case 'resource':
target = resource
break
default:
target = service
}
const property = parts[ 1 ... | [
"function",
"getProperty",
"(",
"service",
",",
"resource",
",",
"action",
",",
"propertySpec",
")",
"{",
"const",
"parts",
"=",
"propertySpec",
".",
"split",
"(",
"'.'",
")",
"var",
"target",
"switch",
"(",
"parts",
"[",
"0",
"]",
")",
"{",
"case",
"'... | given a property specifier "service|resource|action.propertyName" find the property value | [
"given",
"a",
"property",
"specifier",
"service|resource|action",
".",
"propertyName",
"find",
"the",
"property",
"value"
] | 0c34205fd6726356b69bcdd6dec4fcba55027af6 | https://github.com/deftly/node-deftly/blob/0c34205fd6726356b69bcdd6dec4fcba55027af6/src/dispatcher.js#L110-L125 | train |
bnt44/wykop-es6 | dist/index.js | md5 | function md5() {
var string = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0];
return crypto.createHash('md5').update(new Buffer(string, 'utf-8')).digest("hex");
} | javascript | function md5() {
var string = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0];
return crypto.createHash('md5').update(new Buffer(string, 'utf-8')).digest("hex");
} | [
"function",
"md5",
"(",
")",
"{",
"var",
"string",
"=",
"arguments",
".",
"length",
"<=",
"0",
"||",
"arguments",
"[",
"0",
"]",
"===",
"undefined",
"?",
"''",
":",
"arguments",
"[",
"0",
"]",
";",
"return",
"crypto",
".",
"createHash",
"(",
"'md5'",... | create md5 hash | [
"create",
"md5",
"hash"
] | 56657f4bfff4355276d2e6988be15c661c00c48c | https://github.com/bnt44/wykop-es6/blob/56657f4bfff4355276d2e6988be15c661c00c48c/dist/index.js#L16-L20 | train |
queicherius/lets-fetch | src/index.js | single | function single (url, options = {}) {
let tries = 1
// Execute the request and retry if there are errors (and the
// retry decider decided that we should try our luck again)
const callRequest = () => request(url, options).catch(err => {
if (internalRetry(++tries, err)) {
return wait(callRequest, inte... | javascript | function single (url, options = {}) {
let tries = 1
// Execute the request and retry if there are errors (and the
// retry decider decided that we should try our luck again)
const callRequest = () => request(url, options).catch(err => {
if (internalRetry(++tries, err)) {
return wait(callRequest, inte... | [
"function",
"single",
"(",
"url",
",",
"options",
"=",
"{",
"}",
")",
"{",
"let",
"tries",
"=",
"1",
"// Execute the request and retry if there are errors (and the",
"// retry decider decided that we should try our luck again)",
"const",
"callRequest",
"=",
"(",
")",
"=>"... | Request a single url | [
"Request",
"a",
"single",
"url"
] | bee7ad804ecb554e3bac40c2009ff32601902c8e | https://github.com/queicherius/lets-fetch/blob/bee7ad804ecb554e3bac40c2009ff32601902c8e/src/index.js#L29-L43 | train |
queicherius/lets-fetch | src/index.js | request | function request (url, options) {
options = Object.assign({}, defaultOptions, options)
let savedContent
let savedResponse
return new Promise((resolve, reject) => {
fetch(url, options)
.then(handleResponse)
.then(handleBody)
.catch(handleError)
function handleResponse (response) {
... | javascript | function request (url, options) {
options = Object.assign({}, defaultOptions, options)
let savedContent
let savedResponse
return new Promise((resolve, reject) => {
fetch(url, options)
.then(handleResponse)
.then(handleBody)
.catch(handleError)
function handleResponse (response) {
... | [
"function",
"request",
"(",
"url",
",",
"options",
")",
"{",
"options",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"defaultOptions",
",",
"options",
")",
"let",
"savedContent",
"let",
"savedResponse",
"return",
"new",
"Promise",
"(",
"(",
"resolve",... | Send a request using the underlying fetch API | [
"Send",
"a",
"request",
"using",
"the",
"underlying",
"fetch",
"API"
] | bee7ad804ecb554e3bac40c2009ff32601902c8e | https://github.com/queicherius/lets-fetch/blob/bee7ad804ecb554e3bac40c2009ff32601902c8e/src/index.js#L46-L96 | train |
queicherius/lets-fetch | src/index.js | many | function many (urls, options = {}) {
let flowMethod = (options.waitTime) ? flow.series : flow.parallel
// Call the single method while respecting the wait time in between tasks
const callSingle = (url) => single(url, options)
.then(content => wait(() => content, options.waitTime))
// Map over the urls and... | javascript | function many (urls, options = {}) {
let flowMethod = (options.waitTime) ? flow.series : flow.parallel
// Call the single method while respecting the wait time in between tasks
const callSingle = (url) => single(url, options)
.then(content => wait(() => content, options.waitTime))
// Map over the urls and... | [
"function",
"many",
"(",
"urls",
",",
"options",
"=",
"{",
"}",
")",
"{",
"let",
"flowMethod",
"=",
"(",
"options",
".",
"waitTime",
")",
"?",
"flow",
".",
"series",
":",
"flow",
".",
"parallel",
"// Call the single method while respecting the wait time in betwe... | Request multiple pages | [
"Request",
"multiple",
"pages"
] | bee7ad804ecb554e3bac40c2009ff32601902c8e | https://github.com/queicherius/lets-fetch/blob/bee7ad804ecb554e3bac40c2009ff32601902c8e/src/index.js#L99-L109 | train |
gethuman/pancakes-recipe | utils/jwt.js | generateForUser | function generateForUser(user, existingToken) {
existingToken = existingToken || {};
var privateKey = config.security.token.privateKey;
var decryptedToken = _.extend(existingToken, { _id: user._id, authToken: user.authToken });
return jsonwebtoken.sign(decryptedToken, privateKey);
... | javascript | function generateForUser(user, existingToken) {
existingToken = existingToken || {};
var privateKey = config.security.token.privateKey;
var decryptedToken = _.extend(existingToken, { _id: user._id, authToken: user.authToken });
return jsonwebtoken.sign(decryptedToken, privateKey);
... | [
"function",
"generateForUser",
"(",
"user",
",",
"existingToken",
")",
"{",
"existingToken",
"=",
"existingToken",
"||",
"{",
"}",
";",
"var",
"privateKey",
"=",
"config",
".",
"security",
".",
"token",
".",
"privateKey",
";",
"var",
"decryptedToken",
"=",
"... | Simple function to generate a JWT based off a user
@param user
@param existingToken Optional, pass in if there is an existing token we are adding to
@returns {*} | [
"Simple",
"function",
"to",
"generate",
"a",
"JWT",
"based",
"off",
"a",
"user"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/utils/jwt.js#L15-L22 | train |
redisjs/jsr-server | lib/command/pubsub/psubscribe.js | execute | function execute(req, res) {
this.state.pubsub.psubscribe(req.conn, req.args);
} | javascript | function execute(req, res) {
this.state.pubsub.psubscribe(req.conn, req.args);
} | [
"function",
"execute",
"(",
"req",
",",
"res",
")",
"{",
"this",
".",
"state",
".",
"pubsub",
".",
"psubscribe",
"(",
"req",
".",
"conn",
",",
"req",
".",
"args",
")",
";",
"}"
] | Respond to the PSUBSCRIBE command. | [
"Respond",
"to",
"the",
"PSUBSCRIBE",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/pubsub/psubscribe.js#L17-L19 | train |
woyorus/syncsocket | src/channel.js | Channel | function Channel(server, opts) {
this.server = server;
opts = opts || {};
this.channelId = opts.channelId;
this.timeserver = opts.timeserver || this.server.timeserverUrl();
this.clients = [];
this.clientStates = {};
// Hackery
this.setMaxListeners(150);
this.clockClient = new Cloc... | javascript | function Channel(server, opts) {
this.server = server;
opts = opts || {};
this.channelId = opts.channelId;
this.timeserver = opts.timeserver || this.server.timeserverUrl();
this.clients = [];
this.clientStates = {};
// Hackery
this.setMaxListeners(150);
this.clockClient = new Cloc... | [
"function",
"Channel",
"(",
"server",
",",
"opts",
")",
"{",
"this",
".",
"server",
"=",
"server",
";",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"this",
".",
"channelId",
"=",
"opts",
".",
"channelId",
";",
"this",
".",
"timeserver",
"=",
"opts",
... | Channel constructor.
@type {Channel}
@param {Server} server The server object
@param {object} opts Options
@param {string} opts.channelId The channel id (string). If not passed, will generate a random one
@param {string} opts.timeserver The timeserver which channel will use (if not set, will use the server's default)
@... | [
"Channel",
"constructor",
"."
] | 793c35ed99178055aa8278a3fc006256333503e4 | https://github.com/woyorus/syncsocket/blob/793c35ed99178055aa8278a3fc006256333503e4/src/channel.js#L21-L35 | train |
docLoop/core | docloop-error-handling.js | catchAsyncErrors | function catchAsyncErrors(fn) {
return async (...args) => {
try{ await Promise.resolve(fn(...args)).catch(args[2])}
catch(e){ args[2](e) }
}
} | javascript | function catchAsyncErrors(fn) {
return async (...args) => {
try{ await Promise.resolve(fn(...args)).catch(args[2])}
catch(e){ args[2](e) }
}
} | [
"function",
"catchAsyncErrors",
"(",
"fn",
")",
"{",
"return",
"async",
"(",
"...",
"args",
")",
"=>",
"{",
"try",
"{",
"await",
"Promise",
".",
"resolve",
"(",
"fn",
"(",
"...",
"args",
")",
")",
".",
"catch",
"(",
"args",
"[",
"2",
"]",
")",
"}... | Wrapper for express request handlers to catch rejected promises or async methods.
@memberof module:docloop
@param {Function} fn Express request handler to wrap
@return {Function} Wrapped request handler | [
"Wrapper",
"for",
"express",
"request",
"handlers",
"to",
"catch",
"rejected",
"promises",
"or",
"async",
"methods",
"."
] | 111870e3dcc537997fa31dee485e355e487af794 | https://github.com/docLoop/core/blob/111870e3dcc537997fa31dee485e355e487af794/docloop-error-handling.js#L39-L44 | train |
BenjaminLykins/command-line-arguments | lib/command-line-arguments.js | isLastLevel | function isLastLevel(arr){
//console.log("isLastLevel(" + arr + ")");
if(!arr){
return true;
}
for(var i = 0; i < arr.length; i++){
if(typeof arr[i] === 'number');
else if(arr[i].substring(0,1) === '-'){
//console.log("->false");
return false;
}
}
//console.log("-> true");
retu... | javascript | function isLastLevel(arr){
//console.log("isLastLevel(" + arr + ")");
if(!arr){
return true;
}
for(var i = 0; i < arr.length; i++){
if(typeof arr[i] === 'number');
else if(arr[i].substring(0,1) === '-'){
//console.log("->false");
return false;
}
}
//console.log("-> true");
retu... | [
"function",
"isLastLevel",
"(",
"arr",
")",
"{",
"//console.log(\"isLastLevel(\" + arr + \")\");",
"if",
"(",
"!",
"arr",
")",
"{",
"return",
"true",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"arr",
".",
"length",
";",
"i",
"++",
")",
... | Returns true if there are no more sublevels after current level | [
"Returns",
"true",
"if",
"there",
"are",
"no",
"more",
"sublevels",
"after",
"current",
"level"
] | f8839c55991ac2d9f20477e551529ed706d850f5 | https://github.com/BenjaminLykins/command-line-arguments/blob/f8839c55991ac2d9f20477e551529ed706d850f5/lib/command-line-arguments.js#L15-L29 | train |
fullstackers/bus.io-common | lib/message.js | Message | function Message () {
if (!(this instanceof Message)) {
if (typeof arguments[0] === 'object' && arguments[0] instanceof Message) {
debug('message is a message so return it');
return arguments[0];
}
else {
debug('creating new message and initializing with arguments');
var m = new M... | javascript | function Message () {
if (!(this instanceof Message)) {
if (typeof arguments[0] === 'object' && arguments[0] instanceof Message) {
debug('message is a message so return it');
return arguments[0];
}
else {
debug('creating new message and initializing with arguments');
var m = new M... | [
"function",
"Message",
"(",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Message",
")",
")",
"{",
"if",
"(",
"typeof",
"arguments",
"[",
"0",
"]",
"===",
"'object'",
"&&",
"arguments",
"[",
"0",
"]",
"instanceof",
"Message",
")",
"{",
"debug... | A message represents an action performed by an actor on target with the content | [
"A",
"message",
"represents",
"an",
"action",
"performed",
"by",
"an",
"actor",
"on",
"target",
"with",
"the",
"content"
] | 9e081a15ba40c4233a936d4105465277da8578fd | https://github.com/fullstackers/bus.io-common/blob/9e081a15ba40c4233a936d4105465277da8578fd/lib/message.js#L13-L35 | train |
lemonde/knex-schema-filter | lib/filter.js | filterSchemas | function filterSchemas(schemas, tableNames, callback) {
if (! (schemas || []).length || ! (tableNames || []).length)
return process.nextTick(_.partial(callback, null, schemas || []));
var schemasMap = _.indexBy(schemas, 'tableName');
var filteredSchemas = _.chain(schemasMap).pick(tableNames).toArray().value(... | javascript | function filterSchemas(schemas, tableNames, callback) {
if (! (schemas || []).length || ! (tableNames || []).length)
return process.nextTick(_.partial(callback, null, schemas || []));
var schemasMap = _.indexBy(schemas, 'tableName');
var filteredSchemas = _.chain(schemasMap).pick(tableNames).toArray().value(... | [
"function",
"filterSchemas",
"(",
"schemas",
",",
"tableNames",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"(",
"schemas",
"||",
"[",
"]",
")",
".",
"length",
"||",
"!",
"(",
"tableNames",
"||",
"[",
"]",
")",
".",
"length",
")",
"return",
"process",... | Filter provided schemas using tableNames and
include schemas dependencies.
@param {[Schema]} schemas
@param {[String]} tableNames
@param {Function} callback | [
"Filter",
"provided",
"schemas",
"using",
"tableNames",
"and",
"include",
"schemas",
"dependencies",
"."
] | 13c65c88de40f7df18332712d1f0e5262a42611e | https://github.com/lemonde/knex-schema-filter/blob/13c65c88de40f7df18332712d1f0e5262a42611e/lib/filter.js#L20-L27 | train |
lemonde/knex-schema-filter | lib/filter.js | resolveSchemasDeps | function resolveSchemasDeps(schemas, schemasMap, callback) {
async.reduce(schemas, [], function (result, schema, next) {
tryAndDelay(resolveSchemaDeps, result, schema, schemasMap, next);
}, function (err, result) {
return err ? callback(err) : callback(null, _.uniq(result));
});
} | javascript | function resolveSchemasDeps(schemas, schemasMap, callback) {
async.reduce(schemas, [], function (result, schema, next) {
tryAndDelay(resolveSchemaDeps, result, schema, schemasMap, next);
}, function (err, result) {
return err ? callback(err) : callback(null, _.uniq(result));
});
} | [
"function",
"resolveSchemasDeps",
"(",
"schemas",
",",
"schemasMap",
",",
"callback",
")",
"{",
"async",
".",
"reduce",
"(",
"schemas",
",",
"[",
"]",
",",
"function",
"(",
"result",
",",
"schema",
",",
"next",
")",
"{",
"tryAndDelay",
"(",
"resolveSchemaD... | Resolve provided schemas dependencies.
@param {[Schema]} schemas
@param {Object} schemasMap
@param {Function} callback | [
"Resolve",
"provided",
"schemas",
"dependencies",
"."
] | 13c65c88de40f7df18332712d1f0e5262a42611e | https://github.com/lemonde/knex-schema-filter/blob/13c65c88de40f7df18332712d1f0e5262a42611e/lib/filter.js#L37-L43 | train |
lemonde/knex-schema-filter | lib/filter.js | resolveSchemaDeps | function resolveSchemaDeps(result, schema, schemasMap) {
if (! (schema.deps || []).length) return result.concat([ schema ]);
return schema.deps.reduce(function (result, tableName) {
return (result.indexOf(schemasMap[tableName]) >= 0) ?
result :
result.concat(resolveSchemaDeps(result, sche... | javascript | function resolveSchemaDeps(result, schema, schemasMap) {
if (! (schema.deps || []).length) return result.concat([ schema ]);
return schema.deps.reduce(function (result, tableName) {
return (result.indexOf(schemasMap[tableName]) >= 0) ?
result :
result.concat(resolveSchemaDeps(result, sche... | [
"function",
"resolveSchemaDeps",
"(",
"result",
",",
"schema",
",",
"schemasMap",
")",
"{",
"if",
"(",
"!",
"(",
"schema",
".",
"deps",
"||",
"[",
"]",
")",
".",
"length",
")",
"return",
"result",
".",
"concat",
"(",
"[",
"schema",
"]",
")",
";",
"... | Resolve provided schema dependencies.
@param {[Schema]} result
@param {Schema} schema
@param {Object} schemasMap
@return {[String]} - table names | [
"Resolve",
"provided",
"schema",
"dependencies",
"."
] | 13c65c88de40f7df18332712d1f0e5262a42611e | https://github.com/lemonde/knex-schema-filter/blob/13c65c88de40f7df18332712d1f0e5262a42611e/lib/filter.js#L54-L62 | train |
lemonde/knex-schema-filter | lib/filter.js | tryAndDelay | function tryAndDelay(fn) {
var args = _.chain(arguments).rest().initial().value();
var callback = _.last(arguments);
try {
process.nextTick(_.partial(callback, null, fn.apply(null, args)));
} catch (err) {
process.nextTick(_.partial(callback, err));
}
} | javascript | function tryAndDelay(fn) {
var args = _.chain(arguments).rest().initial().value();
var callback = _.last(arguments);
try {
process.nextTick(_.partial(callback, null, fn.apply(null, args)));
} catch (err) {
process.nextTick(_.partial(callback, err));
}
} | [
"function",
"tryAndDelay",
"(",
"fn",
")",
"{",
"var",
"args",
"=",
"_",
".",
"chain",
"(",
"arguments",
")",
".",
"rest",
"(",
")",
".",
"initial",
"(",
")",
".",
"value",
"(",
")",
";",
"var",
"callback",
"=",
"_",
".",
"last",
"(",
"arguments"... | Execute provided synchrone function as asynchrone.
@param {Function} fn
@param {*...} args
@param {Function} callback | [
"Execute",
"provided",
"synchrone",
"function",
"as",
"asynchrone",
"."
] | 13c65c88de40f7df18332712d1f0e5262a42611e | https://github.com/lemonde/knex-schema-filter/blob/13c65c88de40f7df18332712d1f0e5262a42611e/lib/filter.js#L72-L80 | train |
gethuman/pancakes-angular | lib/ngapp/service.helper.js | genServiceMethod | function genServiceMethod(method) {
return function (req) {
return ajax.send(method.url, method.httpMethod, req, method.resourceName);
};
} | javascript | function genServiceMethod(method) {
return function (req) {
return ajax.send(method.url, method.httpMethod, req, method.resourceName);
};
} | [
"function",
"genServiceMethod",
"(",
"method",
")",
"{",
"return",
"function",
"(",
"req",
")",
"{",
"return",
"ajax",
".",
"send",
"(",
"method",
".",
"url",
",",
"method",
".",
"httpMethod",
",",
"req",
",",
"method",
".",
"resourceName",
")",
";",
"... | Generate a service method
@param method
@returns {Function} | [
"Generate",
"a",
"service",
"method"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/ngapp/service.helper.js#L14-L18 | train |
gethuman/pancakes-angular | lib/ngapp/service.helper.js | genService | function genService(methods) {
var service = {};
for (var methodName in methods) {
if (methods.hasOwnProperty(methodName)) {
service[methodName] = genServiceMethod(methods[methodName]);
}
}
return service;
} | javascript | function genService(methods) {
var service = {};
for (var methodName in methods) {
if (methods.hasOwnProperty(methodName)) {
service[methodName] = genServiceMethod(methods[methodName]);
}
}
return service;
} | [
"function",
"genService",
"(",
"methods",
")",
"{",
"var",
"service",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"methodName",
"in",
"methods",
")",
"{",
"if",
"(",
"methods",
".",
"hasOwnProperty",
"(",
"methodName",
")",
")",
"{",
"service",
"[",
"method... | Generate a service based on a set of methods
@param methods | [
"Generate",
"a",
"service",
"based",
"on",
"a",
"set",
"of",
"methods"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/ngapp/service.helper.js#L24-L34 | train |
mattmccray/blam.js | bench/lib/benchmark.js | reverse | function reverse() {
var upperIndex,
value,
index = -1,
object = Object(this),
length = object.length >>> 0,
middle = floor(length / 2);
if (length > 1) {
while (++index < middle) {
upperIndex = length - index - 1;
value = upperIndex in object ? obj... | javascript | function reverse() {
var upperIndex,
value,
index = -1,
object = Object(this),
length = object.length >>> 0,
middle = floor(length / 2);
if (length > 1) {
while (++index < middle) {
upperIndex = length - index - 1;
value = upperIndex in object ? obj... | [
"function",
"reverse",
"(",
")",
"{",
"var",
"upperIndex",
",",
"value",
",",
"index",
"=",
"-",
"1",
",",
"object",
"=",
"Object",
"(",
"this",
")",
",",
"length",
"=",
"object",
".",
"length",
">>>",
"0",
",",
"middle",
"=",
"floor",
"(",
"length... | Rearrange the host array's elements in reverse order.
@memberOf Benchmark.Suite
@returns {Array} The reversed array. | [
"Rearrange",
"the",
"host",
"array",
"s",
"elements",
"in",
"reverse",
"order",
"."
] | a535b6fe9679b687897ac0dc18b26585a5c3a114 | https://github.com/mattmccray/blam.js/blob/a535b6fe9679b687897ac0dc18b26585a5c3a114/bench/lib/benchmark.js#L602-L627 | train |
mattmccray/blam.js | bench/lib/benchmark.js | slice | function slice(start, end) {
var index = -1,
object = Object(this),
length = object.length >>> 0,
result = [];
start = toInteger(start);
start = start < 0 ? max(length + start, 0) : min(start, length);
start--;
end = end == null ? length : toInteger(end);
end = end < 0 ?... | javascript | function slice(start, end) {
var index = -1,
object = Object(this),
length = object.length >>> 0,
result = [];
start = toInteger(start);
start = start < 0 ? max(length + start, 0) : min(start, length);
start--;
end = end == null ? length : toInteger(end);
end = end < 0 ?... | [
"function",
"slice",
"(",
"start",
",",
"end",
")",
"{",
"var",
"index",
"=",
"-",
"1",
",",
"object",
"=",
"Object",
"(",
"this",
")",
",",
"length",
"=",
"object",
".",
"length",
">>>",
"0",
",",
"result",
"=",
"[",
"]",
";",
"start",
"=",
"t... | Creates an array of the host array's elements from the start index up to,
but not including, the end index.
@memberOf Benchmark.Suite
@param {Number} start The starting index.
@param {Number} end The end index.
@returns {Array} The new array. | [
"Creates",
"an",
"array",
"of",
"the",
"host",
"array",
"s",
"elements",
"from",
"the",
"start",
"index",
"up",
"to",
"but",
"not",
"including",
"the",
"end",
"index",
"."
] | a535b6fe9679b687897ac0dc18b26585a5c3a114 | https://github.com/mattmccray/blam.js/blob/a535b6fe9679b687897ac0dc18b26585a5c3a114/bench/lib/benchmark.js#L648-L666 | train |
mattmccray/blam.js | bench/lib/benchmark.js | toInteger | function toInteger(value) {
value = +value;
return value === 0 || !isFinite(value) ? value || 0 : value - (value % 1);
} | javascript | function toInteger(value) {
value = +value;
return value === 0 || !isFinite(value) ? value || 0 : value - (value % 1);
} | [
"function",
"toInteger",
"(",
"value",
")",
"{",
"value",
"=",
"+",
"value",
";",
"return",
"value",
"===",
"0",
"||",
"!",
"isFinite",
"(",
"value",
")",
"?",
"value",
"||",
"0",
":",
"value",
"-",
"(",
"value",
"%",
"1",
")",
";",
"}"
] | Converts the specified `value` to an integer.
@private
@param {Mixed} value The value to convert.
@returns {Number} The resulting integer. | [
"Converts",
"the",
"specified",
"value",
"to",
"an",
"integer",
"."
] | a535b6fe9679b687897ac0dc18b26585a5c3a114 | https://github.com/mattmccray/blam.js/blob/a535b6fe9679b687897ac0dc18b26585a5c3a114/bench/lib/benchmark.js#L695-L698 | train |
mattmccray/blam.js | bench/lib/benchmark.js | isArguments | function isArguments() {
// lazy define
isArguments = function(value) {
return toString.call(value) == '[object Arguments]';
};
if (noArgumentsClass) {
isArguments = function(value) {
return hasKey(value, 'callee') &&
!(propertyIsEnumerable && propertyIsEnumerable.call(valu... | javascript | function isArguments() {
// lazy define
isArguments = function(value) {
return toString.call(value) == '[object Arguments]';
};
if (noArgumentsClass) {
isArguments = function(value) {
return hasKey(value, 'callee') &&
!(propertyIsEnumerable && propertyIsEnumerable.call(valu... | [
"function",
"isArguments",
"(",
")",
"{",
"// lazy define",
"isArguments",
"=",
"function",
"(",
"value",
")",
"{",
"return",
"toString",
".",
"call",
"(",
"value",
")",
"==",
"'[object Arguments]'",
";",
"}",
";",
"if",
"(",
"noArgumentsClass",
")",
"{",
... | Checks if a value is an `arguments` object.
@private
@param {Mixed} value The value to check.
@returns {Boolean} Returns `true` if the value is an `arguments` object, else `false`. | [
"Checks",
"if",
"a",
"value",
"is",
"an",
"arguments",
"object",
"."
] | a535b6fe9679b687897ac0dc18b26585a5c3a114 | https://github.com/mattmccray/blam.js/blob/a535b6fe9679b687897ac0dc18b26585a5c3a114/bench/lib/benchmark.js#L944-L956 | train |
mattmccray/blam.js | bench/lib/benchmark.js | isObject | function isObject(value) {
var ctor,
result = !!value && toString.call(value) == '[object Object]';
if (result && noArgumentsClass) {
// avoid false positives for `arguments` objects in IE < 9
result = !isArguments(value);
}
if (result) {
// IE < 9 presents nodes like `Object`... | javascript | function isObject(value) {
var ctor,
result = !!value && toString.call(value) == '[object Object]';
if (result && noArgumentsClass) {
// avoid false positives for `arguments` objects in IE < 9
result = !isArguments(value);
}
if (result) {
// IE < 9 presents nodes like `Object`... | [
"function",
"isObject",
"(",
"value",
")",
"{",
"var",
"ctor",
",",
"result",
"=",
"!",
"!",
"value",
"&&",
"toString",
".",
"call",
"(",
"value",
")",
"==",
"'[object Object]'",
";",
"if",
"(",
"result",
"&&",
"noArgumentsClass",
")",
"{",
"// avoid fal... | Checks if the specified `value` is an object created by the `Object`
constructor assuming objects created by the `Object` constructor have no
inherited enumerable properties and assuming there are no `Object.prototype`
extensions.
@private
@param {Mixed} value The value to check.
@returns {Boolean} Returns `true` if `... | [
"Checks",
"if",
"the",
"specified",
"value",
"is",
"an",
"object",
"created",
"by",
"the",
"Object",
"constructor",
"assuming",
"objects",
"created",
"by",
"the",
"Object",
"constructor",
"have",
"no",
"inherited",
"enumerable",
"properties",
"and",
"assuming",
... | a535b6fe9679b687897ac0dc18b26585a5c3a114 | https://github.com/mattmccray/blam.js/blob/a535b6fe9679b687897ac0dc18b26585a5c3a114/bench/lib/benchmark.js#L996-L1019 | train |
mattmccray/blam.js | bench/lib/benchmark.js | methodize | function methodize(fn) {
return function() {
var args = [this];
args.push.apply(args, arguments);
return fn.apply(null, args);
};
} | javascript | function methodize(fn) {
return function() {
var args = [this];
args.push.apply(args, arguments);
return fn.apply(null, args);
};
} | [
"function",
"methodize",
"(",
"fn",
")",
"{",
"return",
"function",
"(",
")",
"{",
"var",
"args",
"=",
"[",
"this",
"]",
";",
"args",
".",
"push",
".",
"apply",
"(",
"args",
",",
"arguments",
")",
";",
"return",
"fn",
".",
"apply",
"(",
"null",
"... | Wraps a function and passes `this` to the original function as the
first argument.
@private
@param {Function} fn The function to be wrapped.
@returns {Function} The new function. | [
"Wraps",
"a",
"function",
"and",
"passes",
"this",
"to",
"the",
"original",
"function",
"as",
"the",
"first",
"argument",
"."
] | a535b6fe9679b687897ac0dc18b26585a5c3a114 | https://github.com/mattmccray/blam.js/blob/a535b6fe9679b687897ac0dc18b26585a5c3a114/bench/lib/benchmark.js#L1040-L1046 | train |
mattmccray/blam.js | bench/lib/benchmark.js | runScript | function runScript(code) {
var anchor = freeDefine ? define.amd : Benchmark,
script = doc.createElement('script'),
sibling = doc.getElementsByTagName('script')[0],
parent = sibling.parentNode,
prop = uid + 'runScript',
prefix = '(' + (freeDefine ? 'define.amd.' : 'Benchmark.'... | javascript | function runScript(code) {
var anchor = freeDefine ? define.amd : Benchmark,
script = doc.createElement('script'),
sibling = doc.getElementsByTagName('script')[0],
parent = sibling.parentNode,
prop = uid + 'runScript',
prefix = '(' + (freeDefine ? 'define.amd.' : 'Benchmark.'... | [
"function",
"runScript",
"(",
"code",
")",
"{",
"var",
"anchor",
"=",
"freeDefine",
"?",
"define",
".",
"amd",
":",
"Benchmark",
",",
"script",
"=",
"doc",
".",
"createElement",
"(",
"'script'",
")",
",",
"sibling",
"=",
"doc",
".",
"getElementsByTagName",... | Runs a snippet of JavaScript via script injection.
@private
@param {String} code The code to run. | [
"Runs",
"a",
"snippet",
"of",
"JavaScript",
"via",
"script",
"injection",
"."
] | a535b6fe9679b687897ac0dc18b26585a5c3a114 | https://github.com/mattmccray/blam.js/blob/a535b6fe9679b687897ac0dc18b26585a5c3a114/bench/lib/benchmark.js#L1077-L1100 | train |
mattmccray/blam.js | bench/lib/benchmark.js | getMarkerKey | function getMarkerKey(object) {
// avoid collisions with existing keys
var result = uid;
while (object[result] && object[result].constructor != Marker) {
result += 1;
}
return result;
} | javascript | function getMarkerKey(object) {
// avoid collisions with existing keys
var result = uid;
while (object[result] && object[result].constructor != Marker) {
result += 1;
}
return result;
} | [
"function",
"getMarkerKey",
"(",
"object",
")",
"{",
"// avoid collisions with existing keys",
"var",
"result",
"=",
"uid",
";",
"while",
"(",
"object",
"[",
"result",
"]",
"&&",
"object",
"[",
"result",
"]",
".",
"constructor",
"!=",
"Marker",
")",
"{",
"re... | Gets an available marker key for the given object. | [
"Gets",
"an",
"available",
"marker",
"key",
"for",
"the",
"given",
"object",
"."
] | a535b6fe9679b687897ac0dc18b26585a5c3a114 | https://github.com/mattmccray/blam.js/blob/a535b6fe9679b687897ac0dc18b26585a5c3a114/bench/lib/benchmark.js#L1220-L1227 | train |
mattmccray/blam.js | bench/lib/benchmark.js | each | function each(object, callback, thisArg) {
var result = object;
object = Object(object);
var fn = callback,
index = -1,
length = object.length,
isSnapshot = !!(object.snapshotItem && (length = object.snapshotLength)),
isSplittable = (noCharByIndex || noCharByOwnIndex) && isC... | javascript | function each(object, callback, thisArg) {
var result = object;
object = Object(object);
var fn = callback,
index = -1,
length = object.length,
isSnapshot = !!(object.snapshotItem && (length = object.snapshotLength)),
isSplittable = (noCharByIndex || noCharByOwnIndex) && isC... | [
"function",
"each",
"(",
"object",
",",
"callback",
",",
"thisArg",
")",
"{",
"var",
"result",
"=",
"object",
";",
"object",
"=",
"Object",
"(",
"object",
")",
";",
"var",
"fn",
"=",
"callback",
",",
"index",
"=",
"-",
"1",
",",
"length",
"=",
"obj... | An iteration utility for arrays and objects.
Callbacks may terminate the loop by explicitly returning `false`.
@static
@memberOf Benchmark
@param {Array|Object} object The object to iterate over.
@param {Function} callback The function called per iteration.
@param {Mixed} thisArg The `this` binding for the callback.
@... | [
"An",
"iteration",
"utility",
"for",
"arrays",
"and",
"objects",
".",
"Callbacks",
"may",
"terminate",
"the",
"loop",
"by",
"explicitly",
"returning",
"false",
"."
] | a535b6fe9679b687897ac0dc18b26585a5c3a114 | https://github.com/mattmccray/blam.js/blob/a535b6fe9679b687897ac0dc18b26585a5c3a114/bench/lib/benchmark.js#L1344-L1379 | train |
mattmccray/blam.js | bench/lib/benchmark.js | hasKey | function hasKey() {
// lazy define for worst case fallback (not as accurate)
hasKey = function(object, key) {
var parent = object != null && (object.constructor || Object).prototype;
return !!parent && key in Object(object) && !(key in parent && object[key] === parent[key]);
};
// for modern... | javascript | function hasKey() {
// lazy define for worst case fallback (not as accurate)
hasKey = function(object, key) {
var parent = object != null && (object.constructor || Object).prototype;
return !!parent && key in Object(object) && !(key in parent && object[key] === parent[key]);
};
// for modern... | [
"function",
"hasKey",
"(",
")",
"{",
"// lazy define for worst case fallback (not as accurate)",
"hasKey",
"=",
"function",
"(",
"object",
",",
"key",
")",
"{",
"var",
"parent",
"=",
"object",
"!=",
"null",
"&&",
"(",
"object",
".",
"constructor",
"||",
"Object"... | Checks if an object has the specified key as a direct property.
@static
@memberOf Benchmark
@param {Object} object The object to check.
@param {String} key The key to check for.
@returns {Boolean} Returns `true` if key is a direct property, else `false`. | [
"Checks",
"if",
"an",
"object",
"has",
"the",
"specified",
"key",
"as",
"a",
"direct",
"property",
"."
] | a535b6fe9679b687897ac0dc18b26585a5c3a114 | https://github.com/mattmccray/blam.js/blob/a535b6fe9679b687897ac0dc18b26585a5c3a114/bench/lib/benchmark.js#L1516-L1540 | train |
mattmccray/blam.js | bench/lib/benchmark.js | interpolate | function interpolate(string, object) {
forOwn(object, function(value, key) {
// escape regexp special characters in `key`
string = string.replace(RegExp('#\\{' + key.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1') + '\\}', 'g'), value);
});
return string;
} | javascript | function interpolate(string, object) {
forOwn(object, function(value, key) {
// escape regexp special characters in `key`
string = string.replace(RegExp('#\\{' + key.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1') + '\\}', 'g'), value);
});
return string;
} | [
"function",
"interpolate",
"(",
"string",
",",
"object",
")",
"{",
"forOwn",
"(",
"object",
",",
"function",
"(",
"value",
",",
"key",
")",
"{",
"// escape regexp special characters in `key`",
"string",
"=",
"string",
".",
"replace",
"(",
"RegExp",
"(",
"'#\\\... | Modify a string by replacing named tokens with matching object property values.
@static
@memberOf Benchmark
@param {String} string The string to modify.
@param {Object} object The template object.
@returns {String} The modified string. | [
"Modify",
"a",
"string",
"by",
"replacing",
"named",
"tokens",
"with",
"matching",
"object",
"property",
"values",
"."
] | a535b6fe9679b687897ac0dc18b26585a5c3a114 | https://github.com/mattmccray/blam.js/blob/a535b6fe9679b687897ac0dc18b26585a5c3a114/bench/lib/benchmark.js#L1574-L1580 | train |
mattmccray/blam.js | bench/lib/benchmark.js | join | function join(object, separator1, separator2) {
var result = [],
length = (object = Object(object)).length,
arrayLike = length === length >>> 0;
separator2 || (separator2 = ': ');
each(object, function(value, key) {
result.push(arrayLike ? value : key + separator2 + value);
});
... | javascript | function join(object, separator1, separator2) {
var result = [],
length = (object = Object(object)).length,
arrayLike = length === length >>> 0;
separator2 || (separator2 = ': ');
each(object, function(value, key) {
result.push(arrayLike ? value : key + separator2 + value);
});
... | [
"function",
"join",
"(",
"object",
",",
"separator1",
",",
"separator2",
")",
"{",
"var",
"result",
"=",
"[",
"]",
",",
"length",
"=",
"(",
"object",
"=",
"Object",
"(",
"object",
")",
")",
".",
"length",
",",
"arrayLike",
"=",
"length",
"===",
"leng... | Creates a string of joined array values or object key-value pairs.
@static
@memberOf Benchmark
@param {Array|Object} object The object to operate on.
@param {String} [separator1=','] The separator used between key-value pairs.
@param {String} [separator2=': '] The separator used between keys and values.
@returns {Stri... | [
"Creates",
"a",
"string",
"of",
"joined",
"array",
"values",
"or",
"object",
"key",
"-",
"value",
"pairs",
"."
] | a535b6fe9679b687897ac0dc18b26585a5c3a114 | https://github.com/mattmccray/blam.js/blob/a535b6fe9679b687897ac0dc18b26585a5c3a114/bench/lib/benchmark.js#L1775-L1785 | train |
mattmccray/blam.js | bench/lib/benchmark.js | pluck | function pluck(array, property) {
return map(array, function(object) {
return object == null ? undefined : object[property];
});
} | javascript | function pluck(array, property) {
return map(array, function(object) {
return object == null ? undefined : object[property];
});
} | [
"function",
"pluck",
"(",
"array",
",",
"property",
")",
"{",
"return",
"map",
"(",
"array",
",",
"function",
"(",
"object",
")",
"{",
"return",
"object",
"==",
"null",
"?",
"undefined",
":",
"object",
"[",
"property",
"]",
";",
"}",
")",
";",
"}"
] | Retrieves the value of a specified property from all items in an array.
@static
@memberOf Benchmark
@param {Array} array The array to iterate over.
@param {String} property The property to pluck.
@returns {Array} A new array of property values. | [
"Retrieves",
"the",
"value",
"of",
"a",
"specified",
"property",
"from",
"all",
"items",
"in",
"an",
"array",
"."
] | a535b6fe9679b687897ac0dc18b26585a5c3a114 | https://github.com/mattmccray/blam.js/blob/a535b6fe9679b687897ac0dc18b26585a5c3a114/bench/lib/benchmark.js#L1813-L1817 | train |
mattmccray/blam.js | bench/lib/benchmark.js | enqueue | function enqueue(count) {
while (count--) {
queue.push(bench.clone({
'_original': bench,
'events': {
'abort': [update],
'cycle': [update],
'error': [update],
'start': [update]
}
}));
}
} | javascript | function enqueue(count) {
while (count--) {
queue.push(bench.clone({
'_original': bench,
'events': {
'abort': [update],
'cycle': [update],
'error': [update],
'start': [update]
}
}));
}
} | [
"function",
"enqueue",
"(",
"count",
")",
"{",
"while",
"(",
"count",
"--",
")",
"{",
"queue",
".",
"push",
"(",
"bench",
".",
"clone",
"(",
"{",
"'_original'",
":",
"bench",
",",
"'events'",
":",
"{",
"'abort'",
":",
"[",
"update",
"]",
",",
"'cyc... | Adds a number of clones to the queue. | [
"Adds",
"a",
"number",
"of",
"clones",
"to",
"the",
"queue",
"."
] | a535b6fe9679b687897ac0dc18b26585a5c3a114 | https://github.com/mattmccray/blam.js/blob/a535b6fe9679b687897ac0dc18b26585a5c3a114/bench/lib/benchmark.js#L2661-L2673 | train |
mattmccray/blam.js | bench/lib/benchmark.js | evaluate | function evaluate(event) {
var critical,
df,
mean,
moe,
rme,
sd,
sem,
variance,
clone = event.target,
done = bench.aborted,
now = +new Date,
size = sample.push(clone.times.period),
maxedOut = si... | javascript | function evaluate(event) {
var critical,
df,
mean,
moe,
rme,
sd,
sem,
variance,
clone = event.target,
done = bench.aborted,
now = +new Date,
size = sample.push(clone.times.period),
maxedOut = si... | [
"function",
"evaluate",
"(",
"event",
")",
"{",
"var",
"critical",
",",
"df",
",",
"mean",
",",
"moe",
",",
"rme",
",",
"sd",
",",
"sem",
",",
"variance",
",",
"clone",
"=",
"event",
".",
"target",
",",
"done",
"=",
"bench",
".",
"aborted",
",",
... | Determines if more clones should be queued or if cycling should stop. | [
"Determines",
"if",
"more",
"clones",
"should",
"be",
"queued",
"or",
"if",
"cycling",
"should",
"stop",
"."
] | a535b6fe9679b687897ac0dc18b26585a5c3a114 | https://github.com/mattmccray/blam.js/blob/a535b6fe9679b687897ac0dc18b26585a5c3a114/bench/lib/benchmark.js#L2709-L2782 | train |
tuunanen/camelton | lib/obs.js | isObjectObject | function isObjectObject(object) {
return _.isObject(object) && !_.isArray(object) && !_.isFunction(object);
} | javascript | function isObjectObject(object) {
return _.isObject(object) && !_.isArray(object) && !_.isFunction(object);
} | [
"function",
"isObjectObject",
"(",
"object",
")",
"{",
"return",
"_",
".",
"isObject",
"(",
"object",
")",
"&&",
"!",
"_",
".",
"isArray",
"(",
"object",
")",
"&&",
"!",
"_",
".",
"isFunction",
"(",
"object",
")",
";",
"}"
] | Is given variable a plain object, i.e. not a function or Array.
@see http://underscorejs.org/#isObject
@param {object} object
@returns {boolean} Result of the checks. | [
"Is",
"given",
"variable",
"a",
"plain",
"object",
"i",
".",
"e",
".",
"not",
"a",
"function",
"or",
"Array",
"."
] | 2beee32431e1b2867396e25f560f8dbd53535041 | https://github.com/tuunanen/camelton/blob/2beee32431e1b2867396e25f560f8dbd53535041/lib/obs.js#L21-L23 | train |
tuunanen/camelton | lib/obs.js | getObjectSchema | function getObjectSchema(object) {
var outputObject = {};
if (isObjectObject(object)) {
Object.keys(object).forEach(function(key) {
outputObject[key] = isObjectObject(object[key]) ? getObjectSchema(object[key]) : '';
});
}
return outputObject;
} | javascript | function getObjectSchema(object) {
var outputObject = {};
if (isObjectObject(object)) {
Object.keys(object).forEach(function(key) {
outputObject[key] = isObjectObject(object[key]) ? getObjectSchema(object[key]) : '';
});
}
return outputObject;
} | [
"function",
"getObjectSchema",
"(",
"object",
")",
"{",
"var",
"outputObject",
"=",
"{",
"}",
";",
"if",
"(",
"isObjectObject",
"(",
"object",
")",
")",
"{",
"Object",
".",
"keys",
"(",
"object",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
... | Create an object schema - an object with keys and empty strings as values.
@param {object} object
@returns {object} Object schema. An object with keys and empty strings as
values. | [
"Create",
"an",
"object",
"schema",
"-",
"an",
"object",
"with",
"keys",
"and",
"empty",
"strings",
"as",
"values",
"."
] | 2beee32431e1b2867396e25f560f8dbd53535041 | https://github.com/tuunanen/camelton/blob/2beee32431e1b2867396e25f560f8dbd53535041/lib/obs.js#L43-L53 | train |
tuunanen/camelton | lib/obs.js | mergeObjectSchema | function mergeObjectSchema(object, other, options) {
var settings = options || {},
prune = settings.prune || false,
placeholder = settings.placeholder || false,
source, sourceKeys,
keysDiff,
outputObject, i, value;
// Don't bother doing anything with non-plain objects.
if (!isObject... | javascript | function mergeObjectSchema(object, other, options) {
var settings = options || {},
prune = settings.prune || false,
placeholder = settings.placeholder || false,
source, sourceKeys,
keysDiff,
outputObject, i, value;
// Don't bother doing anything with non-plain objects.
if (!isObject... | [
"function",
"mergeObjectSchema",
"(",
"object",
",",
"other",
",",
"options",
")",
"{",
"var",
"settings",
"=",
"options",
"||",
"{",
"}",
",",
"prune",
"=",
"settings",
".",
"prune",
"||",
"false",
",",
"placeholder",
"=",
"settings",
".",
"placeholder",
... | Merge object schemas together. Original object properties and
values are preserved.
@param {object} object
@param {object} other
@param {object} options
@param {bool} options.prune - Prune extra properties found in destination
objects
@param {bool} options.placeholder - Add source object key as a value for
empty desti... | [
"Merge",
"object",
"schemas",
"together",
".",
"Original",
"object",
"properties",
"and",
"values",
"are",
"preserved",
"."
] | 2beee32431e1b2867396e25f560f8dbd53535041 | https://github.com/tuunanen/camelton/blob/2beee32431e1b2867396e25f560f8dbd53535041/lib/obs.js#L68-L127 | train |
tuunanen/camelton | lib/obs.js | sortObjectSchema | function sortObjectSchema(object, options) {
var sort = {asc: sortAsc, desc: sortDesc},
keys = Object.keys(object),
outputObject = {};
if (options.sort) {
keys.sort(sort[options.sort]);
}
keys.forEach(function(key, index) {
if (isObjectObject(object[key])) {
object[key] = sortObjectS... | javascript | function sortObjectSchema(object, options) {
var sort = {asc: sortAsc, desc: sortDesc},
keys = Object.keys(object),
outputObject = {};
if (options.sort) {
keys.sort(sort[options.sort]);
}
keys.forEach(function(key, index) {
if (isObjectObject(object[key])) {
object[key] = sortObjectS... | [
"function",
"sortObjectSchema",
"(",
"object",
",",
"options",
")",
"{",
"var",
"sort",
"=",
"{",
"asc",
":",
"sortAsc",
",",
"desc",
":",
"sortDesc",
"}",
",",
"keys",
"=",
"Object",
".",
"keys",
"(",
"object",
")",
",",
"outputObject",
"=",
"{",
"}... | Sort object schema.
@param {object} object
@param {object} options
@returns {object} Sorted object schema. | [
"Sort",
"object",
"schema",
"."
] | 2beee32431e1b2867396e25f560f8dbd53535041 | https://github.com/tuunanen/camelton/blob/2beee32431e1b2867396e25f560f8dbd53535041/lib/obs.js#L136-L153 | train |
Lindurion/closure-pro-build | lib/dir-manager.js | createOutputDirsAsync | function createOutputDirsAsync(buildOptions) {
var outputDirs = new OutputDirs(buildOptions);
var tasks = [];
tasks.push(makeDirAndParents(outputDirs.tmp));
tasks.push(makeDirAndParents(outputDirs.gen));
tasks.push(makeDirAndParents(outputDirs.build));
return kew.all(tasks)
.then(function() { return... | javascript | function createOutputDirsAsync(buildOptions) {
var outputDirs = new OutputDirs(buildOptions);
var tasks = [];
tasks.push(makeDirAndParents(outputDirs.tmp));
tasks.push(makeDirAndParents(outputDirs.gen));
tasks.push(makeDirAndParents(outputDirs.build));
return kew.all(tasks)
.then(function() { return... | [
"function",
"createOutputDirsAsync",
"(",
"buildOptions",
")",
"{",
"var",
"outputDirs",
"=",
"new",
"OutputDirs",
"(",
"buildOptions",
")",
";",
"var",
"tasks",
"=",
"[",
"]",
";",
"tasks",
".",
"push",
"(",
"makeDirAndParents",
"(",
"outputDirs",
".",
"tmp... | Creates output directories specified by buildOptions and returns a future
OutputDirs object with tmp, gen, and build properties for the created paths.
@param {!Object} buildOptions Specifies options specific to this build (like
debug/release); see README.md for option documentation.
@return {!Promise.<!OutputDirs>} | [
"Creates",
"output",
"directories",
"specified",
"by",
"buildOptions",
"and",
"returns",
"a",
"future",
"OutputDirs",
"object",
"with",
"tmp",
"gen",
"and",
"build",
"properties",
"for",
"the",
"created",
"paths",
"."
] | c279d0fcc3a65969d2fe965f55e627b074792f1a | https://github.com/Lindurion/closure-pro-build/blob/c279d0fcc3a65969d2fe965f55e627b074792f1a/lib/dir-manager.js#L32-L42 | train |
molecuel/gridfs-uploader | lib/uploadServer.js | GFSuploadServer | function GFSuploadServer(mongoose, port, ssloptions, routes, listen, defaultcallback, authcallback) {
this.port = port;
this.ssloptions = ssloptions;
this.routes = routes;
this.listen = listen;
this.authcallback = authcallback;
this.mongoose = mongoose;
if(defaultcallback) {
this.defaultcallback = def... | javascript | function GFSuploadServer(mongoose, port, ssloptions, routes, listen, defaultcallback, authcallback) {
this.port = port;
this.ssloptions = ssloptions;
this.routes = routes;
this.listen = listen;
this.authcallback = authcallback;
this.mongoose = mongoose;
if(defaultcallback) {
this.defaultcallback = def... | [
"function",
"GFSuploadServer",
"(",
"mongoose",
",",
"port",
",",
"ssloptions",
",",
"routes",
",",
"listen",
",",
"defaultcallback",
",",
"authcallback",
")",
"{",
"this",
".",
"port",
"=",
"port",
";",
"this",
".",
"ssloptions",
"=",
"ssloptions",
";",
"... | Constructor for the module class
@this {GFSuploadServer}
@constructor
@param {Object} mongoose The mongoose object from your application
@param {Integer} port The port of the server instance
@param {Array} ssloptions Options like certificate etc for the SSL express server instance
@param {Array} routes Array of objec... | [
"Constructor",
"for",
"the",
"module",
"class"
] | 3a0a97d70de39e348881f7eca34a99dd7408454f | https://github.com/molecuel/gridfs-uploader/blob/3a0a97d70de39e348881f7eca34a99dd7408454f/lib/uploadServer.js#L65-L81 | train |
redisjs/jsr-server | lib/command/database/list/lset.js | validate | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var index = parseInt(args[1])
, value = info.db.getKey(args[0], info);
if(value === undefined) {
throw NoSuchKey;
}else if(isNaN(index) || (index < 0 || index >= value.getLength())) {
throw IndexRange;
... | javascript | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var index = parseInt(args[1])
, value = info.db.getKey(args[0], info);
if(value === undefined) {
throw NoSuchKey;
}else if(isNaN(index) || (index < 0 || index >= value.getLength())) {
throw IndexRange;
... | [
"function",
"validate",
"(",
"cmd",
",",
"args",
",",
"info",
")",
"{",
"AbstractCommand",
".",
"prototype",
".",
"validate",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"var",
"index",
"=",
"parseInt",
"(",
"args",
"[",
"1",
"]",
")",
","... | Validate the LSET command. | [
"Validate",
"the",
"LSET",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/database/list/lset.js#L20-L30 | train |
vkiding/judpack-common | src/ConfigParser/ConfigParser.js | ConfigParser | function ConfigParser(path) {
this.path = path;
try {
this.doc = xml.parseElementtreeSync(path);
this.cdvNamespacePrefix = getCordovaNamespacePrefix(this.doc);
et.register_namespace(this.cdvNamespacePrefix, 'http://cordova.apache.org/ns/1.0');
} catch (e) {
console.error('Par... | javascript | function ConfigParser(path) {
this.path = path;
try {
this.doc = xml.parseElementtreeSync(path);
this.cdvNamespacePrefix = getCordovaNamespacePrefix(this.doc);
et.register_namespace(this.cdvNamespacePrefix, 'http://cordova.apache.org/ns/1.0');
} catch (e) {
console.error('Par... | [
"function",
"ConfigParser",
"(",
"path",
")",
"{",
"this",
".",
"path",
"=",
"path",
";",
"try",
"{",
"this",
".",
"doc",
"=",
"xml",
".",
"parseElementtreeSync",
"(",
"path",
")",
";",
"this",
".",
"cdvNamespacePrefix",
"=",
"getCordovaNamespacePrefix",
"... | Wraps a config.xml file | [
"Wraps",
"a",
"config",
".",
"xml",
"file"
] | 5b87d3f1cb10c2c867243e3a692d39b4bb189dd4 | https://github.com/vkiding/judpack-common/blob/5b87d3f1cb10c2c867243e3a692d39b4bb189dd4/src/ConfigParser/ConfigParser.js#L30-L44 | train |
vkiding/judpack-common | src/ConfigParser/ConfigParser.js | findElementAttributeValue | function findElementAttributeValue(attributeName, elems) {
elems = Array.isArray(elems) ? elems : [ elems ];
var value = elems.filter(function (elem) {
return elem.attrib.name.toLowerCase() === attributeName.toLowerCase();
}).map(function (filteredElems) {
return filteredElems.attrib.value... | javascript | function findElementAttributeValue(attributeName, elems) {
elems = Array.isArray(elems) ? elems : [ elems ];
var value = elems.filter(function (elem) {
return elem.attrib.name.toLowerCase() === attributeName.toLowerCase();
}).map(function (filteredElems) {
return filteredElems.attrib.value... | [
"function",
"findElementAttributeValue",
"(",
"attributeName",
",",
"elems",
")",
"{",
"elems",
"=",
"Array",
".",
"isArray",
"(",
"elems",
")",
"?",
"elems",
":",
"[",
"elems",
"]",
";",
"var",
"value",
"=",
"elems",
".",
"filter",
"(",
"function",
"(",... | Finds the value of an element's attribute
@param {String} attributeName Name of the attribute to search for
@param {Array} elems An array of ElementTree nodes
@return {String} | [
"Finds",
"the",
"value",
"of",
"an",
"element",
"s",
"attribute"
] | 5b87d3f1cb10c2c867243e3a692d39b4bb189dd4 | https://github.com/vkiding/judpack-common/blob/5b87d3f1cb10c2c867243e3a692d39b4bb189dd4/src/ConfigParser/ConfigParser.js#L79-L90 | train |
vkiding/judpack-common | src/ConfigParser/ConfigParser.js | function(platform, resourceName) {
var ret = [],
staticResources = [];
if (platform) { // platform specific icons
this.doc.findall('platform[@name=\'' + platform + '\']/' + resourceName).forEach(function(elt){
elt.platform = platform; // mark as platform specific ... | javascript | function(platform, resourceName) {
var ret = [],
staticResources = [];
if (platform) { // platform specific icons
this.doc.findall('platform[@name=\'' + platform + '\']/' + resourceName).forEach(function(elt){
elt.platform = platform; // mark as platform specific ... | [
"function",
"(",
"platform",
",",
"resourceName",
")",
"{",
"var",
"ret",
"=",
"[",
"]",
",",
"staticResources",
"=",
"[",
"]",
";",
"if",
"(",
"platform",
")",
"{",
"// platform specific icons",
"this",
".",
"doc",
".",
"findall",
"(",
"'platform[@name=\\... | Returns all resources for the platform specified.
@param {String} platform The platform.
@param {string} resourceName Type of static resources to return.
"icon" and "splash" currently supported.
@return {Array} Resources for the platform specified. | [
"Returns",
"all",
"resources",
"for",
"the",
"platform",
"specified",
"."
] | 5b87d3f1cb10c2c867243e3a692d39b4bb189dd4 | https://github.com/vkiding/judpack-common/blob/5b87d3f1cb10c2c867243e3a692d39b4bb189dd4/src/ConfigParser/ConfigParser.js#L177-L239 | train | |
vkiding/judpack-common | src/ConfigParser/ConfigParser.js | function (attributes, variables) {
if (!attributes && !attributes.name) return;
var el = new et.Element('plugin');
el.attrib.name = attributes.name;
if (attributes.spec) {
el.attrib.spec = attributes.spec;
}
// support arbitrary object as variables source
... | javascript | function (attributes, variables) {
if (!attributes && !attributes.name) return;
var el = new et.Element('plugin');
el.attrib.name = attributes.name;
if (attributes.spec) {
el.attrib.spec = attributes.spec;
}
// support arbitrary object as variables source
... | [
"function",
"(",
"attributes",
",",
"variables",
")",
"{",
"if",
"(",
"!",
"attributes",
"&&",
"!",
"attributes",
".",
"name",
")",
"return",
";",
"var",
"el",
"=",
"new",
"et",
".",
"Element",
"(",
"'plugin'",
")",
";",
"el",
".",
"attrib",
".",
"... | Adds a plugin element. Does not check for duplicates.
@name addPlugin
@function
@param {object} attributes name and spec are supported
@param {Array|object} variables name, value or arbitary object | [
"Adds",
"a",
"plugin",
"element",
".",
"Does",
"not",
"check",
"for",
"duplicates",
"."
] | 5b87d3f1cb10c2c867243e3a692d39b4bb189dd4 | https://github.com/vkiding/judpack-common/blob/5b87d3f1cb10c2c867243e3a692d39b4bb189dd4/src/ConfigParser/ConfigParser.js#L314-L336 | train | |
vkiding/judpack-common | src/ConfigParser/ConfigParser.js | function(id){
if(!id){
return undefined;
}
var pluginElement = this.doc.find('./plugin/[@name="' + id + '"]');
if (null === pluginElement) {
var legacyFeature = this.doc.find('./feature/param[@name="id"][@value="' + id + '"]/..');
if(legacyFeature){
... | javascript | function(id){
if(!id){
return undefined;
}
var pluginElement = this.doc.find('./plugin/[@name="' + id + '"]');
if (null === pluginElement) {
var legacyFeature = this.doc.find('./feature/param[@name="id"][@value="' + id + '"]/..');
if(legacyFeature){
... | [
"function",
"(",
"id",
")",
"{",
"if",
"(",
"!",
"id",
")",
"{",
"return",
"undefined",
";",
"}",
"var",
"pluginElement",
"=",
"this",
".",
"doc",
".",
"find",
"(",
"'./plugin/[@name=\"'",
"+",
"id",
"+",
"'\"]'",
")",
";",
"if",
"(",
"null",
"==="... | Retrives the plugin with the given id or null if not found.
This function also returns any plugin's that
were defined using the legacy <feature> tags.
@name getPlugin
@function
@param {String} id
@returns {object} plugin including any variables | [
"Retrives",
"the",
"plugin",
"with",
"the",
"given",
"id",
"or",
"null",
"if",
"not",
"found",
"."
] | 5b87d3f1cb10c2c867243e3a692d39b4bb189dd4 | https://github.com/vkiding/judpack-common/blob/5b87d3f1cb10c2c867243e3a692d39b4bb189dd4/src/ConfigParser/ConfigParser.js#L347-L374 | train | |
vkiding/judpack-common | src/ConfigParser/ConfigParser.js | function(name, attributes) {
var el = et.Element(name);
for (var a in attributes) {
el.attrib[a] = attributes[a];
}
this.doc.getroot().append(el);
} | javascript | function(name, attributes) {
var el = et.Element(name);
for (var a in attributes) {
el.attrib[a] = attributes[a];
}
this.doc.getroot().append(el);
} | [
"function",
"(",
"name",
",",
"attributes",
")",
"{",
"var",
"el",
"=",
"et",
".",
"Element",
"(",
"name",
")",
";",
"for",
"(",
"var",
"a",
"in",
"attributes",
")",
"{",
"el",
".",
"attrib",
"[",
"a",
"]",
"=",
"attributes",
"[",
"a",
"]",
";"... | Add any element to the root | [
"Add",
"any",
"element",
"to",
"the",
"root"
] | 5b87d3f1cb10c2c867243e3a692d39b4bb189dd4 | https://github.com/vkiding/judpack-common/blob/5b87d3f1cb10c2c867243e3a692d39b4bb189dd4/src/ConfigParser/ConfigParser.js#L399-L405 | train | |
vkiding/judpack-common | src/ConfigParser/ConfigParser.js | function(name, spec){
if(!name) return;
var el = et.Element('engine');
el.attrib.name = name;
if(spec){
el.attrib.spec = spec;
}
this.doc.getroot().append(el);
} | javascript | function(name, spec){
if(!name) return;
var el = et.Element('engine');
el.attrib.name = name;
if(spec){
el.attrib.spec = spec;
}
this.doc.getroot().append(el);
} | [
"function",
"(",
"name",
",",
"spec",
")",
"{",
"if",
"(",
"!",
"name",
")",
"return",
";",
"var",
"el",
"=",
"et",
".",
"Element",
"(",
"'engine'",
")",
";",
"el",
".",
"attrib",
".",
"name",
"=",
"name",
";",
"if",
"(",
"spec",
")",
"{",
"e... | Adds an engine. Does not check for duplicates.
@param {String} name the engine name
@param {String} spec engine source location or version (optional) | [
"Adds",
"an",
"engine",
".",
"Does",
"not",
"check",
"for",
"duplicates",
"."
] | 5b87d3f1cb10c2c867243e3a692d39b4bb189dd4 | https://github.com/vkiding/judpack-common/blob/5b87d3f1cb10c2c867243e3a692d39b4bb189dd4/src/ConfigParser/ConfigParser.js#L412-L420 | train | |
vkiding/judpack-common | src/ConfigParser/ConfigParser.js | function(name){
var engines = this.doc.findall('./engine/[@name="' +name+'"]');
for(var i=0; i < engines.length; i++){
var children = this.doc.getroot().getchildren();
var idx = children.indexOf(engines[i]);
if(idx > -1){
children.splice(idx,1);
... | javascript | function(name){
var engines = this.doc.findall('./engine/[@name="' +name+'"]');
for(var i=0; i < engines.length; i++){
var children = this.doc.getroot().getchildren();
var idx = children.indexOf(engines[i]);
if(idx > -1){
children.splice(idx,1);
... | [
"function",
"(",
"name",
")",
"{",
"var",
"engines",
"=",
"this",
".",
"doc",
".",
"findall",
"(",
"'./engine/[@name=\"'",
"+",
"name",
"+",
"'\"]'",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"engines",
".",
"length",
";",
"i",
"... | Removes all the engines with given name
@param {String} name the engine name. | [
"Removes",
"all",
"the",
"engines",
"with",
"given",
"name"
] | 5b87d3f1cb10c2c867243e3a692d39b4bb189dd4 | https://github.com/vkiding/judpack-common/blob/5b87d3f1cb10c2c867243e3a692d39b4bb189dd4/src/ConfigParser/ConfigParser.js#L425-L434 | train | |
akshat1/simian-color-functions | src/index.js | resolveFraction | function resolveFraction(frac) {
frac = `${frac}`;
if (Patterns.Percentage.test(frac)) {
return parseFloat(frac) / 100;
} else if (Patterns.Number.test(frac)) {
return parseFloat(frac);
} else
throw new Error('Unknown fraction format: ', inp);
} | javascript | function resolveFraction(frac) {
frac = `${frac}`;
if (Patterns.Percentage.test(frac)) {
return parseFloat(frac) / 100;
} else if (Patterns.Number.test(frac)) {
return parseFloat(frac);
} else
throw new Error('Unknown fraction format: ', inp);
} | [
"function",
"resolveFraction",
"(",
"frac",
")",
"{",
"frac",
"=",
"`",
"${",
"frac",
"}",
"`",
";",
"if",
"(",
"Patterns",
".",
"Percentage",
".",
"test",
"(",
"frac",
")",
")",
"{",
"return",
"parseFloat",
"(",
"frac",
")",
"/",
"100",
";",
"}",
... | Get a decimal value from a percentage or a number.
@param {String|Number} frac - the value to be converted to a decimal fraction
@return - a decimal value equivalent to the input
@example
resolveFraction('25%'); // 0.25
resolveFraction('0.25'); // 0.25 | [
"Get",
"a",
"decimal",
"value",
"from",
"a",
"percentage",
"or",
"a",
"number",
"."
] | 824e485d6a9e1eaaa47193153c1ce4133b07d99b | https://github.com/akshat1/simian-color-functions/blob/824e485d6a9e1eaaa47193153c1ce4133b07d99b/src/index.js#L28-L36 | train |
atd-schubert/node-stream-lib | lib/event.js | function (name, data, origin, priority) {
this.timestamp = Date.now();
this.name = name;
this.data = data;
this.origin = origin;
this.priority = priority || 1;
} | javascript | function (name, data, origin, priority) {
this.timestamp = Date.now();
this.name = name;
this.data = data;
this.origin = origin;
this.priority = priority || 1;
} | [
"function",
"(",
"name",
",",
"data",
",",
"origin",
",",
"priority",
")",
"{",
"this",
".",
"timestamp",
"=",
"Date",
".",
"now",
"(",
")",
";",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"data",
"=",
"data",
";",
"this",
".",
"origin",... | Events piping through streams
@author Arne Schubert <atd.schubert@gmail.com>
@param {String} name - name of the event
@param {*} data - On event binded data
@param {EventStream} origin - EventStream that sends the data
@param {number} [priority=0] - Priority of this message
@constructor
@memberOf streamLib
@augments st... | [
"Events",
"piping",
"through",
"streams"
] | 90f27042fae84d2fbdbf9d28149b0673997f151a | https://github.com/atd-schubert/node-stream-lib/blob/90f27042fae84d2fbdbf9d28149b0673997f151a/lib/event.js#L18-L24 | train | |
atd-schubert/node-stream-lib | lib/event.js | streamOn | function streamOn(name, fn) {
var str,
handle;
if (typeof name === 'string') {
str = name;
name = {
test: function (val) {
return val === str;
}
};
}
/**
* @callback {EventStream.... | javascript | function streamOn(name, fn) {
var str,
handle;
if (typeof name === 'string') {
str = name;
name = {
test: function (val) {
return val === str;
}
};
}
/**
* @callback {EventStream.... | [
"function",
"streamOn",
"(",
"name",
",",
"fn",
")",
"{",
"var",
"str",
",",
"handle",
";",
"if",
"(",
"typeof",
"name",
"===",
"'string'",
")",
"{",
"str",
"=",
"name",
";",
"name",
"=",
"{",
"test",
":",
"function",
"(",
"val",
")",
"{",
"retur... | Receive an event from a stream
@param {string|RegExp|{test:function}} name - Name of the events that should be listened
@param {function} fn - Function to execute when receiving event
@returns {EventStream.handle} | [
"Receive",
"an",
"event",
"from",
"a",
"stream"
] | 90f27042fae84d2fbdbf9d28149b0673997f151a | https://github.com/atd-schubert/node-stream-lib/blob/90f27042fae84d2fbdbf9d28149b0673997f151a/lib/event.js#L99-L122 | train |
atd-schubert/node-stream-lib | lib/event.js | function (handle) {
var pos = this.eventStreamListeners.indexOf(handle);
if (pos === -1) {
return false;
}
this.eventStreamListeners.splice(this.eventStreamListeners.indexOf(handle), 1);
return true;
} | javascript | function (handle) {
var pos = this.eventStreamListeners.indexOf(handle);
if (pos === -1) {
return false;
}
this.eventStreamListeners.splice(this.eventStreamListeners.indexOf(handle), 1);
return true;
} | [
"function",
"(",
"handle",
")",
"{",
"var",
"pos",
"=",
"this",
".",
"eventStreamListeners",
".",
"indexOf",
"(",
"handle",
")",
";",
"if",
"(",
"pos",
"===",
"-",
"1",
")",
"{",
"return",
"false",
";",
"}",
"this",
".",
"eventStreamListeners",
".",
... | Remove a receiver
@param {EventStream.handle} handle - Handle from receiver creation
@returns {boolean} | [
"Remove",
"a",
"receiver"
] | 90f27042fae84d2fbdbf9d28149b0673997f151a | https://github.com/atd-schubert/node-stream-lib/blob/90f27042fae84d2fbdbf9d28149b0673997f151a/lib/event.js#L155-L162 | train | |
atd-schubert/node-stream-lib | lib/event.js | function (emitter, eventPrefix) {
var self = this,
oldEmit = emitter.emit;
eventPrefix = eventPrefix || '';
emitter.emit = function (name, data) {
oldEmit.apply(emitter, arguments);
self.send(eventPrefix + name, data);
};
return this;
} | javascript | function (emitter, eventPrefix) {
var self = this,
oldEmit = emitter.emit;
eventPrefix = eventPrefix || '';
emitter.emit = function (name, data) {
oldEmit.apply(emitter, arguments);
self.send(eventPrefix + name, data);
};
return this;
} | [
"function",
"(",
"emitter",
",",
"eventPrefix",
")",
"{",
"var",
"self",
"=",
"this",
",",
"oldEmit",
"=",
"emitter",
".",
"emit",
";",
"eventPrefix",
"=",
"eventPrefix",
"||",
"''",
";",
"emitter",
".",
"emit",
"=",
"function",
"(",
"name",
",",
"data... | Send emitted events from an event emitter on event stream with prefix
@param {events.EventEmitter} emitter - Event Emitter
@param {string} [eventPrefix=""] - Prefix events with this prefix on event stream
@returns {EventStream} | [
"Send",
"emitted",
"events",
"from",
"an",
"event",
"emitter",
"on",
"event",
"stream",
"with",
"prefix"
] | 90f27042fae84d2fbdbf9d28149b0673997f151a | https://github.com/atd-schubert/node-stream-lib/blob/90f27042fae84d2fbdbf9d28149b0673997f151a/lib/event.js#L170-L181 | train | |
atd-schubert/node-stream-lib | lib/event.js | function (listener, eventPrefix) {
var lastName;
eventPrefix = eventPrefix || '';
this.receive({
test: function (val) {
lastName = val;
return true;
}
}, function (data) {
listener.emit(eventPrefix + lastName, data);
... | javascript | function (listener, eventPrefix) {
var lastName;
eventPrefix = eventPrefix || '';
this.receive({
test: function (val) {
lastName = val;
return true;
}
}, function (data) {
listener.emit(eventPrefix + lastName, data);
... | [
"function",
"(",
"listener",
",",
"eventPrefix",
")",
"{",
"var",
"lastName",
";",
"eventPrefix",
"=",
"eventPrefix",
"||",
"''",
";",
"this",
".",
"receive",
"(",
"{",
"test",
":",
"function",
"(",
"val",
")",
"{",
"lastName",
"=",
"val",
";",
"return... | Emits received events from event stream on a normal event emitter with prefix
@param {events.EventEmitter} listener - Event Emitter
@param {string} [eventPrefix=""] - Prefix streamed events with this prefix on event emitter
@returns {EventStream} | [
"Emits",
"received",
"events",
"from",
"event",
"stream",
"on",
"a",
"normal",
"event",
"emitter",
"with",
"prefix"
] | 90f27042fae84d2fbdbf9d28149b0673997f151a | https://github.com/atd-schubert/node-stream-lib/blob/90f27042fae84d2fbdbf9d28149b0673997f151a/lib/event.js#L188-L202 | train | |
willscott/grunt-jasmine-chromeapp | tasks/jasmine-chromeapp/log.js | captureLogs | function captureLogs() {
'use strict';
console.log('Now capturing logs');
var methods = [ 'debug', 'info', 'log', 'warn', 'error' ];
methods.forEach(function (mthd) {
var realMethod = 'real' + mthd,
report = captureLog.bind({}, mthd);
console[realMethod] = console[mthd];
console[mthd] = functi... | javascript | function captureLogs() {
'use strict';
console.log('Now capturing logs');
var methods = [ 'debug', 'info', 'log', 'warn', 'error' ];
methods.forEach(function (mthd) {
var realMethod = 'real' + mthd,
report = captureLog.bind({}, mthd);
console[realMethod] = console[mthd];
console[mthd] = functi... | [
"function",
"captureLogs",
"(",
")",
"{",
"'use strict'",
";",
"console",
".",
"log",
"(",
"'Now capturing logs'",
")",
";",
"var",
"methods",
"=",
"[",
"'debug'",
",",
"'info'",
",",
"'log'",
",",
"'warn'",
",",
"'error'",
"]",
";",
"methods",
".",
"for... | This will intercept logs and get their output back to the shell. | [
"This",
"will",
"intercept",
"logs",
"and",
"get",
"their",
"output",
"back",
"to",
"the",
"shell",
"."
] | 8582a56e0fd3c559948656fae157082910c45055 | https://github.com/willscott/grunt-jasmine-chromeapp/blob/8582a56e0fd3c559948656fae157082910c45055/tasks/jasmine-chromeapp/log.js#L10-L23 | train |
polo2ro/restitute | src/controller.js | saveItemController | function saveItemController(method, path) {
restController.call(this, method, path);
var ctrl = this;
/**
* Save item controller use this method to output a service as a rest
* service
* Output the saved document with the $outcome property
*
* @param {apiService} service
* @pa... | javascript | function saveItemController(method, path) {
restController.call(this, method, path);
var ctrl = this;
/**
* Save item controller use this method to output a service as a rest
* service
* Output the saved document with the $outcome property
*
* @param {apiService} service
* @pa... | [
"function",
"saveItemController",
"(",
"method",
",",
"path",
")",
"{",
"restController",
".",
"call",
"(",
"this",
",",
"method",
",",
"path",
")",
";",
"var",
"ctrl",
"=",
"this",
";",
"/**\n * Save item controller use this method to output a service as a rest\n... | Base class for create or update an item
@param {string} method post|put
@param {string} path | [
"Base",
"class",
"for",
"create",
"or",
"update",
"an",
"item"
] | 532f10b01469f76b8a60f5be624ebf562ebfcf55 | https://github.com/polo2ro/restitute/blob/532f10b01469f76b8a60f5be624ebf562ebfcf55/src/controller.js#L358-L382 | train |
polo2ro/restitute | src/controller.js | deleteItemController | function deleteItemController(path) {
restController.call(this, 'delete', path);
var ctrl = this;
/**
* Delete controller use this method to output a service as a rest
* service
* Output the deleted document with the $outcome property
*
* @param {apiService} service
*
* @... | javascript | function deleteItemController(path) {
restController.call(this, 'delete', path);
var ctrl = this;
/**
* Delete controller use this method to output a service as a rest
* service
* Output the deleted document with the $outcome property
*
* @param {apiService} service
*
* @... | [
"function",
"deleteItemController",
"(",
"path",
")",
"{",
"restController",
".",
"call",
"(",
"this",
",",
"'delete'",
",",
"path",
")",
";",
"var",
"ctrl",
"=",
"this",
";",
"/**\n * Delete controller use this method to output a service as a rest\n * service\n ... | DELETE request with an id
output json with the deleted item data and outcome informations
@param {String} path | [
"DELETE",
"request",
"with",
"an",
"id",
"output",
"json",
"with",
"the",
"deleted",
"item",
"data",
"and",
"outcome",
"informations"
] | 532f10b01469f76b8a60f5be624ebf562ebfcf55 | https://github.com/polo2ro/restitute/blob/532f10b01469f76b8a60f5be624ebf562ebfcf55/src/controller.js#L421-L444 | train |
elliot-a/grunt-git-batch-clone | tasks/batch_git_clone.js | deleteOldFiles | function deleteOldFiles(path){
var deferred = Q.defer();
// Don't delete existing files & folders if overwrite is off
if(options.overWrite !== false){
grunt.log.writeln('---> Deleting folder ==> '+path);
rimraf(path, function(err){
if(err) {
grunt.log.warn('-... | javascript | function deleteOldFiles(path){
var deferred = Q.defer();
// Don't delete existing files & folders if overwrite is off
if(options.overWrite !== false){
grunt.log.writeln('---> Deleting folder ==> '+path);
rimraf(path, function(err){
if(err) {
grunt.log.warn('-... | [
"function",
"deleteOldFiles",
"(",
"path",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"// Don't delete existing files & folders if overwrite is off",
"if",
"(",
"options",
".",
"overWrite",
"!==",
"false",
")",
"{",
"grunt",
".",
"log",
... | delete the repo folder before repopulating it | [
"delete",
"the",
"repo",
"folder",
"before",
"repopulating",
"it"
] | 3419d6366f78286e978f568783cbb5dabe8fd219 | https://github.com/elliot-a/grunt-git-batch-clone/blob/3419d6366f78286e978f568783cbb5dabe8fd219/tasks/batch_git_clone.js#L60-L87 | 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.