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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
morulus/import-sub | resolve.js | matchToHolders | function matchToHolders(match, tag) {
return object(match.map(function(val, index) {
return [tag+":"+index, val];
}));
} | javascript | function matchToHolders(match, tag) {
return object(match.map(function(val, index) {
return [tag+":"+index, val];
}));
} | [
"function",
"matchToHolders",
"(",
"match",
",",
"tag",
")",
"{",
"return",
"object",
"(",
"match",
".",
"map",
"(",
"function",
"(",
"val",
",",
"index",
")",
"{",
"return",
"[",
"tag",
"+",
"\":\"",
"+",
"index",
",",
"val",
"]",
";",
"}",
")",
... | Transform regExpr exec result to hashmap with tagged keys | [
"Transform",
"regExpr",
"exec",
"result",
"to",
"hashmap",
"with",
"tagged",
"keys"
] | c5e33545bdc2b09714028ef6c44185a3ee59db3c | https://github.com/morulus/import-sub/blob/c5e33545bdc2b09714028ef6c44185a3ee59db3c/resolve.js#L122-L126 | train |
morulus/import-sub | resolve.js | filterValidRule | function filterValidRule(rule) {
return (rule.hasOwnProperty('match')&&typeof rule.match === "object")
&& (rule.hasOwnProperty('use') && (
typeof rule.use === "object"
|| typeof rule.use === "function"
))
&& (
(rule.match.hasOwnProperty('request'))
|| (rule.match.hasOwnProperty('base'))
)
} | javascript | function filterValidRule(rule) {
return (rule.hasOwnProperty('match')&&typeof rule.match === "object")
&& (rule.hasOwnProperty('use') && (
typeof rule.use === "object"
|| typeof rule.use === "function"
))
&& (
(rule.match.hasOwnProperty('request'))
|| (rule.match.hasOwnProperty('base'))
)
} | [
"function",
"filterValidRule",
"(",
"rule",
")",
"{",
"return",
"(",
"rule",
".",
"hasOwnProperty",
"(",
"'match'",
")",
"&&",
"typeof",
"rule",
".",
"match",
"===",
"\"object\"",
")",
"&&",
"(",
"rule",
".",
"hasOwnProperty",
"(",
"'use'",
")",
"&&",
"(... | Filter rules with `use` prop | [
"Filter",
"rules",
"with",
"use",
"prop"
] | c5e33545bdc2b09714028ef6c44185a3ee59db3c | https://github.com/morulus/import-sub/blob/c5e33545bdc2b09714028ef6c44185a3ee59db3c/resolve.js#L130-L140 | train |
morulus/import-sub | resolve.js | mapDefaults | function mapDefaults(rule) {
return Object.assign({}, rule, {
match: Object.assign({
request: defaultExpr,
base: defaultExpr,
module: defaultExpr
}, rule.match),
use: rule.use,
});
} | javascript | function mapDefaults(rule) {
return Object.assign({}, rule, {
match: Object.assign({
request: defaultExpr,
base: defaultExpr,
module: defaultExpr
}, rule.match),
use: rule.use,
});
} | [
"function",
"mapDefaults",
"(",
"rule",
")",
"{",
"return",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"rule",
",",
"{",
"match",
":",
"Object",
".",
"assign",
"(",
"{",
"request",
":",
"defaultExpr",
",",
"base",
":",
"defaultExpr",
",",
"module",
... | Merge with defaults | [
"Merge",
"with",
"defaults"
] | c5e33545bdc2b09714028ef6c44185a3ee59db3c | https://github.com/morulus/import-sub/blob/c5e33545bdc2b09714028ef6c44185a3ee59db3c/resolve.js#L144-L153 | train |
morulus/import-sub | resolve.js | wrapPlaceholders | function wrapPlaceholders(placeholders) {
const keys = Object.keys(placeholders);
const wrappedPlaceholders = {};
for (let i = 0; i < keys.length; i++) {
wrappedPlaceholders['<'+keys[i]+'>'] = placeholders[keys[i]];
}
return wrappedPlaceholders;
} | javascript | function wrapPlaceholders(placeholders) {
const keys = Object.keys(placeholders);
const wrappedPlaceholders = {};
for (let i = 0; i < keys.length; i++) {
wrappedPlaceholders['<'+keys[i]+'>'] = placeholders[keys[i]];
}
return wrappedPlaceholders;
} | [
"function",
"wrapPlaceholders",
"(",
"placeholders",
")",
"{",
"const",
"keys",
"=",
"Object",
".",
"keys",
"(",
"placeholders",
")",
";",
"const",
"wrappedPlaceholders",
"=",
"{",
"}",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",... | Wrap placeholders with scobes | [
"Wrap",
"placeholders",
"with",
"scobes"
] | c5e33545bdc2b09714028ef6c44185a3ee59db3c | https://github.com/morulus/import-sub/blob/c5e33545bdc2b09714028ef6c44185a3ee59db3c/resolve.js#L157-L166 | train |
morulus/import-sub | resolve.js | isRequiresEarlyResolve | function isRequiresEarlyResolve(rules) {
for (let i = 0; i < rules.length; ++i) {
if (
Object.prototype.hasOwnProperty.call(rules[i], 'module') ||
(Object.prototype.hasOwnProperty.call(rules[i], 'append') && rules[i].append)
) {
return true;
}
}
return false;
} | javascript | function isRequiresEarlyResolve(rules) {
for (let i = 0; i < rules.length; ++i) {
if (
Object.prototype.hasOwnProperty.call(rules[i], 'module') ||
(Object.prototype.hasOwnProperty.call(rules[i], 'append') && rules[i].append)
) {
return true;
}
}
return false;
} | [
"function",
"isRequiresEarlyResolve",
"(",
"rules",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"rules",
".",
"length",
";",
"++",
"i",
")",
"{",
"if",
"(",
"Object",
".",
"prototype",
".",
"hasOwnProperty",
".",
"call",
"(",
"rules",
... | Search module in rules existing | [
"Search",
"module",
"in",
"rules",
"existing"
] | c5e33545bdc2b09714028ef6c44185a3ee59db3c | https://github.com/morulus/import-sub/blob/c5e33545bdc2b09714028ef6c44185a3ee59db3c/resolve.js#L177-L187 | train |
OctaveWealth/passy | lib/random.js | toArray | function toArray (id) {
if (!isValid(id)) throw new Error('random#toArray: Need valid id');
// Decode
var result = [];
for (var i = 0; i < id.length; i++) {
result.push(baseURL.ALPHABET.indexOf(id[i]));
}
return result;
} | javascript | function toArray (id) {
if (!isValid(id)) throw new Error('random#toArray: Need valid id');
// Decode
var result = [];
for (var i = 0; i < id.length; i++) {
result.push(baseURL.ALPHABET.indexOf(id[i]));
}
return result;
} | [
"function",
"toArray",
"(",
"id",
")",
"{",
"if",
"(",
"!",
"isValid",
"(",
"id",
")",
")",
"throw",
"new",
"Error",
"(",
"'random#toArray: Need valid id'",
")",
";",
"// Decode",
"var",
"result",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",... | Convert a random id to Integer Array
@param {string} id The id to convert.
@return {Array.<number>} result | [
"Convert",
"a",
"random",
"id",
"to",
"Integer",
"Array"
] | 6e357b018952f73e8570b89eda95393780328fab | https://github.com/OctaveWealth/passy/blob/6e357b018952f73e8570b89eda95393780328fab/lib/random.js#L56-L64 | train |
impomezia/sjmp-node | lib/sjmp.js | request | function request(packet, json) {
return _create(packet, 1, (METHODS[packet.method] || '') + packet.resource, json);
} | javascript | function request(packet, json) {
return _create(packet, 1, (METHODS[packet.method] || '') + packet.resource, json);
} | [
"function",
"request",
"(",
"packet",
",",
"json",
")",
"{",
"return",
"_create",
"(",
"packet",
",",
"1",
",",
"(",
"METHODS",
"[",
"packet",
".",
"method",
"]",
"||",
"''",
")",
"+",
"packet",
".",
"resource",
",",
"json",
")",
";",
"}"
] | Serialize request to array or JSON.
@param {Object} packet
@param {String} packet.resource
@param {String} packet.id
@param {*} packet.body
@param {Number|String} [packet.date]
@param {Object} [packet.headers]
@param {String} [packet.method] "get", "search", "post", "put"... | [
"Serialize",
"request",
"to",
"array",
"or",
"JSON",
"."
] | 801a1bbdc8805b2e4c09721148684d43cae5a1e3 | https://github.com/impomezia/sjmp-node/blob/801a1bbdc8805b2e4c09721148684d43cae5a1e3/lib/sjmp.js#L38-L40 | train |
impomezia/sjmp-node | lib/sjmp.js | reply | function reply(packet, json) {
return _create(packet, packet.status || 500, (METHODS[packet.method] || '') + packet.resource, json);
} | javascript | function reply(packet, json) {
return _create(packet, packet.status || 500, (METHODS[packet.method] || '') + packet.resource, json);
} | [
"function",
"reply",
"(",
"packet",
",",
"json",
")",
"{",
"return",
"_create",
"(",
"packet",
",",
"packet",
".",
"status",
"||",
"500",
",",
"(",
"METHODS",
"[",
"packet",
".",
"method",
"]",
"||",
"''",
")",
"+",
"packet",
".",
"resource",
",",
... | Serialize reply to array or JSON.
@param {Object} packet
@param {String} packet.method "get", "search", "post", "put", "delete", "sub", "unsub".
@param {String} packet.resource
@param {String} packet.id
@param {*} packet.body
@param {Number} [packet.status]
@param {Number... | [
"Serialize",
"reply",
"to",
"array",
"or",
"JSON",
"."
] | 801a1bbdc8805b2e4c09721148684d43cae5a1e3 | https://github.com/impomezia/sjmp-node/blob/801a1bbdc8805b2e4c09721148684d43cae5a1e3/lib/sjmp.js#L56-L58 | train |
frozzare/vecka | lib/vecka.js | function () {
var date = new Date();
date.setHours(0, 0, 0);
date.setDate(date.getDate() + 4 - (date.getDay() || 7));
return Math.ceil((((date - new Date(date.getFullYear(), 0, 1)) / 8.64e7) + 1) / 7);
} | javascript | function () {
var date = new Date();
date.setHours(0, 0, 0);
date.setDate(date.getDate() + 4 - (date.getDay() || 7));
return Math.ceil((((date - new Date(date.getFullYear(), 0, 1)) / 8.64e7) + 1) / 7);
} | [
"function",
"(",
")",
"{",
"var",
"date",
"=",
"new",
"Date",
"(",
")",
";",
"date",
".",
"setHours",
"(",
"0",
",",
"0",
",",
"0",
")",
";",
"date",
".",
"setDate",
"(",
"date",
".",
"getDate",
"(",
")",
"+",
"4",
"-",
"(",
"date",
".",
"g... | Get current week number.
@return {Number} | [
"Get",
"current",
"week",
"number",
"."
] | b9dd4144536b9a29620e668ecbde99aeda1debc0 | https://github.com/frozzare/vecka/blob/b9dd4144536b9a29620e668ecbde99aeda1debc0/lib/vecka.js#L11-L16 | train | |
yaru22/co-couchbase | lib/util.js | methodQualified | function methodQualified(name, func) {
var funcStr = func.toString();
// Only public methodds (i.e. methods that do not start with '_') which have
// 'callback' as last parameter are qualified for thunkification.
return (/^[^_]/.test(name) &&
/function.*\(.*,?.*callback\)/.test(funcStr));
} | javascript | function methodQualified(name, func) {
var funcStr = func.toString();
// Only public methodds (i.e. methods that do not start with '_') which have
// 'callback' as last parameter are qualified for thunkification.
return (/^[^_]/.test(name) &&
/function.*\(.*,?.*callback\)/.test(funcStr));
} | [
"function",
"methodQualified",
"(",
"name",
",",
"func",
")",
"{",
"var",
"funcStr",
"=",
"func",
".",
"toString",
"(",
")",
";",
"// Only public methodds (i.e. methods that do not start with '_') which have",
"// 'callback' as last parameter are qualified for thunkification.",
... | Given method name and its function, determine if it qualifies for thunkification.
@param {String} name Method name.
@param {Function} func Function object for the method.
@return {Boolean} True if the method is qualified for thunkification. | [
"Given",
"method",
"name",
"and",
"its",
"function",
"determine",
"if",
"it",
"qualifies",
"for",
"thunkification",
"."
] | 1937f289a18d4a7ea8cdeac03c245a6a56d9f590 | https://github.com/yaru22/co-couchbase/blob/1937f289a18d4a7ea8cdeac03c245a6a56d9f590/lib/util.js#L9-L15 | train |
ValeriiVasin/grunt-node-deploy | tasks/deployHelper.js | registerUserTasks | function registerUserTasks() {
var tasks = options.tasks,
task = that.task.bind(that),
before = that.before.bind(that),
after = that.after.bind(that),
taskName;
// register user tasks
for (taskName in tasks) {
if ( tasks.hasOwnProperty(taskName) ) {
task(ta... | javascript | function registerUserTasks() {
var tasks = options.tasks,
task = that.task.bind(that),
before = that.before.bind(that),
after = that.after.bind(that),
taskName;
// register user tasks
for (taskName in tasks) {
if ( tasks.hasOwnProperty(taskName) ) {
task(ta... | [
"function",
"registerUserTasks",
"(",
")",
"{",
"var",
"tasks",
"=",
"options",
".",
"tasks",
",",
"task",
"=",
"that",
".",
"task",
".",
"bind",
"(",
"that",
")",
",",
"before",
"=",
"that",
".",
"before",
".",
"bind",
"(",
"that",
")",
",",
"afte... | Register user-callbacks defined tasks | [
"Register",
"user",
"-",
"callbacks",
"defined",
"tasks"
] | 74304c4954732602494b555d98fe359c57b71887 | https://github.com/ValeriiVasin/grunt-node-deploy/blob/74304c4954732602494b555d98fe359c57b71887/tasks/deployHelper.js#L149-L179 | train |
mrwest808/johan | src/object/proto.js | combine | function combine(...objects) {
inv(Array.isArray(objects) && objects.length > 0,
'You must pass at least one object to instantiate'
);
inv(objects.every(isObj),
'Expecting only plain objects as parameter(s)'
);
return assign({}, ...objects);
} | javascript | function combine(...objects) {
inv(Array.isArray(objects) && objects.length > 0,
'You must pass at least one object to instantiate'
);
inv(objects.every(isObj),
'Expecting only plain objects as parameter(s)'
);
return assign({}, ...objects);
} | [
"function",
"combine",
"(",
"...",
"objects",
")",
"{",
"inv",
"(",
"Array",
".",
"isArray",
"(",
"objects",
")",
"&&",
"objects",
".",
"length",
">",
"0",
",",
"'You must pass at least one object to instantiate'",
")",
";",
"inv",
"(",
"objects",
".",
"ever... | Assign one or more objects.
@param {...Object} ...objects
@return {Object} | [
"Assign",
"one",
"or",
"more",
"objects",
"."
] | 9e2bf0c1c924ec548d8f648e8a3a50e6fe3fa15b | https://github.com/mrwest808/johan/blob/9e2bf0c1c924ec548d8f648e8a3a50e6fe3fa15b/src/object/proto.js#L14-L24 | train |
Pocketbrain/native-ads-web-ad-library | src/adConfiguration/fetchConfiguration.js | fetchConfiguration | function fetchConfiguration(environment, applicationId, callback) {
if(!applicationId) {
logger.error("No application ID specified");
return;
}
var deviceDetails = deviceDetector.getDeviceDetails();
var pathname = environment.getPathname();
var formFactor = deviceDetails.formFactor... | javascript | function fetchConfiguration(environment, applicationId, callback) {
if(!applicationId) {
logger.error("No application ID specified");
return;
}
var deviceDetails = deviceDetector.getDeviceDetails();
var pathname = environment.getPathname();
var formFactor = deviceDetails.formFactor... | [
"function",
"fetchConfiguration",
"(",
"environment",
",",
"applicationId",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"applicationId",
")",
"{",
"logger",
".",
"error",
"(",
"\"No application ID specified\"",
")",
";",
"return",
";",
"}",
"var",
"deviceDetails"... | Fetch the ad configurations to load on the current page from the server
@param environment - The environment specific implementations
@param applicationId - The applicationId to fetch ad configurations for
@param callback - The callback to execute when the configurations are retrieved | [
"Fetch",
"the",
"ad",
"configurations",
"to",
"load",
"on",
"the",
"current",
"page",
"from",
"the",
"server"
] | aafee1c42e0569ee77f334fc2c4eb71eb146957e | https://github.com/Pocketbrain/native-ads-web-ad-library/blob/aafee1c42e0569ee77f334fc2c4eb71eb146957e/src/adConfiguration/fetchConfiguration.js#L16-L55 | train |
evaisse/jsonconsole | jsonconsole.js | write | function write(src, lvl, obj) {
var stack = null;
var lvlInt = levels[lvl];
var msg;
if ( typeof process.env.LOG_LEVEL == "string"
&& levels[process.env.LOG_LEVEL.toLowerCase()] > lvlInt) {
return false;
}
if (process.env.JSONCONSOLE_DISABLE_JSON_OUTPUT) {
return sr... | javascript | function write(src, lvl, obj) {
var stack = null;
var lvlInt = levels[lvl];
var msg;
if ( typeof process.env.LOG_LEVEL == "string"
&& levels[process.env.LOG_LEVEL.toLowerCase()] > lvlInt) {
return false;
}
if (process.env.JSONCONSOLE_DISABLE_JSON_OUTPUT) {
return sr... | [
"function",
"write",
"(",
"src",
",",
"lvl",
",",
"obj",
")",
"{",
"var",
"stack",
"=",
"null",
";",
"var",
"lvlInt",
"=",
"levels",
"[",
"lvl",
"]",
";",
"var",
"msg",
";",
"if",
"(",
"typeof",
"process",
".",
"env",
".",
"LOG_LEVEL",
"==",
"\"s... | Write JSON log line to stderr & stdout
@param {Stream} src stderr or stdout
@param {String} lvl a given string level by calling console.{level}()
@param {Object} obj Any object that will be filtered
@return {Boolean} false if logging has aborted | [
"Write",
"JSON",
"log",
"line",
"to",
"stderr",
"&",
"stdout"
] | d5b29d44542d4e276d1660fdda0c6b47436b5774 | https://github.com/evaisse/jsonconsole/blob/d5b29d44542d4e276d1660fdda0c6b47436b5774/jsonconsole.js#L92-L151 | train |
evaisse/jsonconsole | jsonconsole.js | replace | function replace() {
if (!isOriginal) return;
else isOriginal = false;
function replaceWith(fn) {
return function() {
/* eslint prefer-rest-params:0 */
// todo: once node v4 support dropped, use rest parameter instead
fn.apply(logger, Array.from(arguments));
... | javascript | function replace() {
if (!isOriginal) return;
else isOriginal = false;
function replaceWith(fn) {
return function() {
/* eslint prefer-rest-params:0 */
// todo: once node v4 support dropped, use rest parameter instead
fn.apply(logger, Array.from(arguments));
... | [
"function",
"replace",
"(",
")",
"{",
"if",
"(",
"!",
"isOriginal",
")",
"return",
";",
"else",
"isOriginal",
"=",
"false",
";",
"function",
"replaceWith",
"(",
"fn",
")",
"{",
"return",
"function",
"(",
")",
"{",
"/* eslint prefer-rest-params:0 */",
"// tod... | Replace global console api | [
"Replace",
"global",
"console",
"api"
] | d5b29d44542d4e276d1660fdda0c6b47436b5774 | https://github.com/evaisse/jsonconsole/blob/d5b29d44542d4e276d1660fdda0c6b47436b5774/jsonconsole.js#L165-L186 | train |
evaisse/jsonconsole | jsonconsole.js | restore | function restore() {
if (isOriginal) return;
else isOriginal = true;
['log', 'debug', 'info', 'warn', 'error'].forEach((item) => {
console[item] = originalConsoleFunctions[item];
});
} | javascript | function restore() {
if (isOriginal) return;
else isOriginal = true;
['log', 'debug', 'info', 'warn', 'error'].forEach((item) => {
console[item] = originalConsoleFunctions[item];
});
} | [
"function",
"restore",
"(",
")",
"{",
"if",
"(",
"isOriginal",
")",
"return",
";",
"else",
"isOriginal",
"=",
"true",
";",
"[",
"'log'",
",",
"'debug'",
",",
"'info'",
",",
"'warn'",
",",
"'error'",
"]",
".",
"forEach",
"(",
"(",
"item",
")",
"=>",
... | Restore original console api | [
"Restore",
"original",
"console",
"api"
] | d5b29d44542d4e276d1660fdda0c6b47436b5774 | https://github.com/evaisse/jsonconsole/blob/d5b29d44542d4e276d1660fdda0c6b47436b5774/jsonconsole.js#L191-L197 | train |
evaisse/jsonconsole | jsonconsole.js | setup | function setup(userOptions) {
Object.assign(options, userOptions);
/*
Try to automatically grab the app name from the root directory
*/
if (!options.root) {
try {
var p = require(path.dirname(process.mainModule.filename) + '/package.json');
options.root = pat... | javascript | function setup(userOptions) {
Object.assign(options, userOptions);
/*
Try to automatically grab the app name from the root directory
*/
if (!options.root) {
try {
var p = require(path.dirname(process.mainModule.filename) + '/package.json');
options.root = pat... | [
"function",
"setup",
"(",
"userOptions",
")",
"{",
"Object",
".",
"assign",
"(",
"options",
",",
"userOptions",
")",
";",
"/*\n Try to automatically grab the app name from the root directory\n */",
"if",
"(",
"!",
"options",
".",
"root",
")",
"{",
"try",
... | Setup JSON console
@param {Object} userOptions [description]
@return {Function} a restore function that restore the behavior of classic console | [
"Setup",
"JSON",
"console"
] | d5b29d44542d4e276d1660fdda0c6b47436b5774 | https://github.com/evaisse/jsonconsole/blob/d5b29d44542d4e276d1660fdda0c6b47436b5774/jsonconsole.js#L206-L241 | train |
phated/grunt-enyo | tasks/init/enyo/root/enyo/source/touch/TranslateScrollStrategy.js | function(inX, inY) {
var o = inX + "px, " + inY + "px" + (this.accel ? ",0" : "");
enyo.dom.transformValue(this.$.client, this.translation, o);
} | javascript | function(inX, inY) {
var o = inX + "px, " + inY + "px" + (this.accel ? ",0" : "");
enyo.dom.transformValue(this.$.client, this.translation, o);
} | [
"function",
"(",
"inX",
",",
"inY",
")",
"{",
"var",
"o",
"=",
"inX",
"+",
"\"px, \"",
"+",
"inY",
"+",
"\"px\"",
"+",
"(",
"this",
".",
"accel",
"?",
"\",0\"",
":",
"\"\"",
")",
";",
"enyo",
".",
"dom",
".",
"transformValue",
"(",
"this",
".",
... | While moving, scroller uses translate. | [
"While",
"moving",
"scroller",
"uses",
"translate",
"."
] | d2990ee4cd85eea8db4108c43086c6d8c3c90c30 | https://github.com/phated/grunt-enyo/blob/d2990ee4cd85eea8db4108c43086c6d8c3c90c30/tasks/init/enyo/root/enyo/source/touch/TranslateScrollStrategy.js#L109-L112 | train | |
bredele/deus | index.js | deus | function deus(one, two, fn) {
var types = [one, two];
var type = function(args, arg) {
var idx = index(types, typeof arg);
if(idx > -1 && !args[idx]) args[idx] = arg;
else if(arg) args.splice(args.length, 0, arg);
};
return function() {
var args = [,,];
for(var i = 0, l = arguments.length; ... | javascript | function deus(one, two, fn) {
var types = [one, two];
var type = function(args, arg) {
var idx = index(types, typeof arg);
if(idx > -1 && !args[idx]) args[idx] = arg;
else if(arg) args.splice(args.length, 0, arg);
};
return function() {
var args = [,,];
for(var i = 0, l = arguments.length; ... | [
"function",
"deus",
"(",
"one",
",",
"two",
",",
"fn",
")",
"{",
"var",
"types",
"=",
"[",
"one",
",",
"two",
"]",
";",
"var",
"type",
"=",
"function",
"(",
"args",
",",
"arg",
")",
"{",
"var",
"idx",
"=",
"index",
"(",
"types",
",",
"typeof",
... | Make two arguments function flexible.
@param {String} one
@param {String} two
@return {Function}
@api public | [
"Make",
"two",
"arguments",
"function",
"flexible",
"."
] | 4d6ff76f6e5d2b73361556ab93bbb186729974ea | https://github.com/bredele/deus/blob/4d6ff76f6e5d2b73361556ab93bbb186729974ea/index.js#L26-L41 | train |
wshager/l3n | lib/doc.js | ensureDoc | function ensureDoc($node) {
// FIXME if isVNode(node) use cx on node
var cx = (0, _vnode.getContext)(this, inode);
return (0, _just.default)($node).pipe((0, _operators.concatMap)(function (node) {
if (!(0, _vnode.isVNode)(node)) {
var type = cx.getType(node);
if (type == 9 || type == 11) {
... | javascript | function ensureDoc($node) {
// FIXME if isVNode(node) use cx on node
var cx = (0, _vnode.getContext)(this, inode);
return (0, _just.default)($node).pipe((0, _operators.concatMap)(function (node) {
if (!(0, _vnode.isVNode)(node)) {
var type = cx.getType(node);
if (type == 9 || type == 11) {
... | [
"function",
"ensureDoc",
"(",
"$node",
")",
"{",
"// FIXME if isVNode(node) use cx on node",
"var",
"cx",
"=",
"(",
"0",
",",
"_vnode",
".",
"getContext",
")",
"(",
"this",
",",
"inode",
")",
";",
"return",
"(",
"0",
",",
"_just",
".",
"default",
")",
"(... | Document-related functions
@module doc
Wraps a document into a document-fragment if it doesn't have a document root
@param {any} $node Observable, VNode or any kind of node mathing the provided document implementation context
@return {Observable} Observable yielding a single VNode | [
"Document",
"-",
"related",
"functions"
] | 700496b9172a29efb3864eae920744d08acb1dc8 | https://github.com/wshager/l3n/blob/700496b9172a29efb3864eae920744d08acb1dc8/lib/doc.js#L35-L69 | train |
tjhart/broccoli-tree-to-json | index.js | Tree2Json | function Tree2Json(inputTree) {
if (!(this instanceof Tree2Json)) return new Tree2Json(inputTree);
this.inputTree = inputTree.replace(/\/$/, '');
this.walker = new TreeTraverser(inputTree, this);
} | javascript | function Tree2Json(inputTree) {
if (!(this instanceof Tree2Json)) return new Tree2Json(inputTree);
this.inputTree = inputTree.replace(/\/$/, '');
this.walker = new TreeTraverser(inputTree, this);
} | [
"function",
"Tree2Json",
"(",
"inputTree",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Tree2Json",
")",
")",
"return",
"new",
"Tree2Json",
"(",
"inputTree",
")",
";",
"this",
".",
"inputTree",
"=",
"inputTree",
".",
"replace",
"(",
"/",
"\\/$",... | Take an input tree, and roll it up into a JSON document.
The resulting document will be named `srcDir.json`. it will have
key names associated with each of the file and directories that `srcDir` contains.
If the key represents the file, then the stringified file contents will be the value of the key.
If the key represe... | [
"Take",
"an",
"input",
"tree",
"and",
"roll",
"it",
"up",
"into",
"a",
"JSON",
"document",
".",
"The",
"resulting",
"document",
"will",
"be",
"named",
"srcDir",
".",
"json",
".",
"it",
"will",
"have",
"key",
"names",
"associated",
"with",
"each",
"of",
... | d8e069f35d626a7c86d9857cc45462a7d5c72b97 | https://github.com/tjhart/broccoli-tree-to-json/blob/d8e069f35d626a7c86d9857cc45462a7d5c72b97/index.js#L23-L28 | train |
pwstegman/pw-stat | index.js | cov | function cov(x) {
// Useful variables
let N = x.length;
// Step 1: Find expected value for each variable (columns are variables, rows are samples)
let E = [];
for (let c = 0; c < x[0].length; c++) {
let u = 0;
for (let r = 0; r < N; r++) {
u += x[r][c];
}
E.push(u / N);
}
// Step 2: Center each vari... | javascript | function cov(x) {
// Useful variables
let N = x.length;
// Step 1: Find expected value for each variable (columns are variables, rows are samples)
let E = [];
for (let c = 0; c < x[0].length; c++) {
let u = 0;
for (let r = 0; r < N; r++) {
u += x[r][c];
}
E.push(u / N);
}
// Step 2: Center each vari... | [
"function",
"cov",
"(",
"x",
")",
"{",
"// Useful variables",
"let",
"N",
"=",
"x",
".",
"length",
";",
"// Step 1: Find expected value for each variable (columns are variables, rows are samples)",
"let",
"E",
"=",
"[",
"]",
";",
"for",
"(",
"let",
"c",
"=",
"0",
... | Returns the covariance matrix for a given matrix.
@param {number[][]} x - A matrix where rows are samples and columns are variables. | [
"Returns",
"the",
"covariance",
"matrix",
"for",
"a",
"given",
"matrix",
"."
] | f0d75c54ae5d9484630b568b8077e8271f4caf38 | https://github.com/pwstegman/pw-stat/blob/f0d75c54ae5d9484630b568b8077e8271f4caf38/index.js#L5-L51 | train |
pwstegman/pw-stat | index.js | mean | function mean(x) {
let result = [];
for(let c = 0; c<x[0].length; c++){
result.push(0);
}
for (let r = 0; r < x.length; r++) {
for(let c = 0; c<x[r].length; c++){
result[c] += x[r][c];
}
}
for(let c = 0; c<x[0].length; c++){
result[c] /= x.length;
}
return result;
} | javascript | function mean(x) {
let result = [];
for(let c = 0; c<x[0].length; c++){
result.push(0);
}
for (let r = 0; r < x.length; r++) {
for(let c = 0; c<x[r].length; c++){
result[c] += x[r][c];
}
}
for(let c = 0; c<x[0].length; c++){
result[c] /= x.length;
}
return result;
} | [
"function",
"mean",
"(",
"x",
")",
"{",
"let",
"result",
"=",
"[",
"]",
";",
"for",
"(",
"let",
"c",
"=",
"0",
";",
"c",
"<",
"x",
"[",
"0",
"]",
".",
"length",
";",
"c",
"++",
")",
"{",
"result",
".",
"push",
"(",
"0",
")",
";",
"}",
"... | Returns the mean of each column in the provided matrix.
@param {number[][]} x - Two-dimensional matrix. | [
"Returns",
"the",
"mean",
"of",
"each",
"column",
"in",
"the",
"provided",
"matrix",
"."
] | f0d75c54ae5d9484630b568b8077e8271f4caf38 | https://github.com/pwstegman/pw-stat/blob/f0d75c54ae5d9484630b568b8077e8271f4caf38/index.js#L57-L75 | train |
changecoin/changetip-javascript | src/changetip.js | function (config) {
config = config || {};
this.api_key = config.api_key;
this.host = config.host || undefined;
this.api_version = config.api_version || undefined;
this.dev_mode = config.dev_mode || false;
return this;
} | javascript | function (config) {
config = config || {};
this.api_key = config.api_key;
this.host = config.host || undefined;
this.api_version = config.api_version || undefined;
this.dev_mode = config.dev_mode || false;
return this;
} | [
"function",
"(",
"config",
")",
"{",
"config",
"=",
"config",
"||",
"{",
"}",
";",
"this",
".",
"api_key",
"=",
"config",
".",
"api_key",
";",
"this",
".",
"host",
"=",
"config",
".",
"host",
"||",
"undefined",
";",
"this",
".",
"api_version",
"=",
... | Initializes the class for remote API Calls
@param {ChangeTipConfig} config
@returns {ChangeTip} | [
"Initializes",
"the",
"class",
"for",
"remote",
"API",
"Calls"
] | 093a7abedbdb69e7ffc08236cec001c1630cf5e1 | https://github.com/changecoin/changetip-javascript/blob/093a7abedbdb69e7ffc08236cec001c1630cf5e1/src/changetip.js#L86-L93 | train | |
changecoin/changetip-javascript | src/changetip.js | function (context_uid, sender, receiver, channel, message, meta) {
if (!this.api_key) throw new ChangeTipException(300);
if (!channel) throw new ChangeTipException(301);
var deferred = Q.defer(),
data;
data = {
context_uid: context_uid,
sender: sende... | javascript | function (context_uid, sender, receiver, channel, message, meta) {
if (!this.api_key) throw new ChangeTipException(300);
if (!channel) throw new ChangeTipException(301);
var deferred = Q.defer(),
data;
data = {
context_uid: context_uid,
sender: sende... | [
"function",
"(",
"context_uid",
",",
"sender",
",",
"receiver",
",",
"channel",
",",
"message",
",",
"meta",
")",
"{",
"if",
"(",
"!",
"this",
".",
"api_key",
")",
"throw",
"new",
"ChangeTipException",
"(",
"300",
")",
";",
"if",
"(",
"!",
"channel",
... | Sends a tip via the ChangeTip API
@param context_uid {number|string} Unique ID for this tip
@param {number|string} sender username/identifier for the tip sender
@param {number|string} receiver username/identifier for the tip receiever
@param {string} channel Origin channel for this tip (twitter, github, slack, etc)
@pa... | [
"Sends",
"a",
"tip",
"via",
"the",
"ChangeTip",
"API"
] | 093a7abedbdb69e7ffc08236cec001c1630cf5e1 | https://github.com/changecoin/changetip-javascript/blob/093a7abedbdb69e7ffc08236cec001c1630cf5e1/src/changetip.js#L105-L123 | train | |
changecoin/changetip-javascript | src/changetip.js | function (tips, channel) {
if (!this.api_key) throw new ChangeTipException(300);
var deferred = Q.defer(),
params;
params = {
tips: tips instanceof Array ? tips.join(",") : tips,
channel: channel || ''
};
this._send_request({}, 'tips', param... | javascript | function (tips, channel) {
if (!this.api_key) throw new ChangeTipException(300);
var deferred = Q.defer(),
params;
params = {
tips: tips instanceof Array ? tips.join(",") : tips,
channel: channel || ''
};
this._send_request({}, 'tips', param... | [
"function",
"(",
"tips",
",",
"channel",
")",
"{",
"if",
"(",
"!",
"this",
".",
"api_key",
")",
"throw",
"new",
"ChangeTipException",
"(",
"300",
")",
";",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
",",
"params",
";",
"params",
"=",
"{",... | Retrieve tips from the ChangeTip API
@param {string|string[]} tips Single or collection of tip identifiers to retrieve
@param {string} [channel] Channel to filter results. (github, twitter, slack, etc)
@returns {promise.promise|jQuery.promise|promise|Q.promise|jQuery.ready.promise|l.promise} | [
"Retrieve",
"tips",
"from",
"the",
"ChangeTip",
"API"
] | 093a7abedbdb69e7ffc08236cec001c1630cf5e1 | https://github.com/changecoin/changetip-javascript/blob/093a7abedbdb69e7ffc08236cec001c1630cf5e1/src/changetip.js#L131-L144 | train | |
changecoin/changetip-javascript | src/changetip.js | function (data, path, params, method, deferred) {
var options, query_params, req,
dataString = JSON.stringify(data);
query_params = querystring.stringify(params);
options = {
host: this.host,
port: 443,
path: '/v' + this.api_version + '/' + path ... | javascript | function (data, path, params, method, deferred) {
var options, query_params, req,
dataString = JSON.stringify(data);
query_params = querystring.stringify(params);
options = {
host: this.host,
port: 443,
path: '/v' + this.api_version + '/' + path ... | [
"function",
"(",
"data",
",",
"path",
",",
"params",
",",
"method",
",",
"deferred",
")",
"{",
"var",
"options",
",",
"query_params",
",",
"req",
",",
"dataString",
"=",
"JSON",
".",
"stringify",
"(",
"data",
")",
";",
"query_params",
"=",
"querystring",... | Sends a request
@param {Object} data JSON Object with data payload
@param {String} path API Path
@param {Object} params Query Parameters to be sent along with this request
@param {Methods} method HTTP Method
@param deferred Deferred Object
@param deferred.promise Deferred Promise Object
@param deferred.resolve Deferred... | [
"Sends",
"a",
"request"
] | 093a7abedbdb69e7ffc08236cec001c1630cf5e1 | https://github.com/changecoin/changetip-javascript/blob/093a7abedbdb69e7ffc08236cec001c1630cf5e1/src/changetip.js#L158-L196 | train | |
zouloux/grunt-deployer | tasks/gruntDeployer.js | quickTemplate | function quickTemplate (pTemplate, pValues)
{
return pTemplate.replace(templateRegex, function(i, pMatch) {
return pValues[pMatch];
});
} | javascript | function quickTemplate (pTemplate, pValues)
{
return pTemplate.replace(templateRegex, function(i, pMatch) {
return pValues[pMatch];
});
} | [
"function",
"quickTemplate",
"(",
"pTemplate",
",",
"pValues",
")",
"{",
"return",
"pTemplate",
".",
"replace",
"(",
"templateRegex",
",",
"function",
"(",
"i",
",",
"pMatch",
")",
"{",
"return",
"pValues",
"[",
"pMatch",
"]",
";",
"}",
")",
";",
"}"
] | Quick and dirty template method | [
"Quick",
"and",
"dirty",
"template",
"method"
] | e9877b8683c5c5344b1738677ad07699ee09d051 | https://github.com/zouloux/grunt-deployer/blob/e9877b8683c5c5344b1738677ad07699ee09d051/tasks/gruntDeployer.js#L25-L30 | train |
hpcloud/hpcloud-js | lib/objectstorage/objectinfo.js | ObjectInfo | function ObjectInfo(name, contentType) {
this._name = name;
this._type = contentType || ObjectInfo.DEFAULT_CONTENT_TYPE;
this._partial = false;
} | javascript | function ObjectInfo(name, contentType) {
this._name = name;
this._type = contentType || ObjectInfo.DEFAULT_CONTENT_TYPE;
this._partial = false;
} | [
"function",
"ObjectInfo",
"(",
"name",
",",
"contentType",
")",
"{",
"this",
".",
"_name",
"=",
"name",
";",
"this",
".",
"_type",
"=",
"contentType",
"||",
"ObjectInfo",
".",
"DEFAULT_CONTENT_TYPE",
";",
"this",
".",
"_partial",
"=",
"false",
";",
"}"
] | Build a new ObjectInfo instance.
This represents the data about an object. It is used under the
following circumstances:
- SAVING: When creating a new object, you declare the object as
ObjectInfo. When saving, you will save with an ObjectInfo and a Stream
of data. See Container.save().
- LISTING: When calling Contain... | [
"Build",
"a",
"new",
"ObjectInfo",
"instance",
"."
] | c457ea3ee6a21e361d1af0af70d64622b6910208 | https://github.com/hpcloud/hpcloud-js/blob/c457ea3ee6a21e361d1af0af70d64622b6910208/lib/objectstorage/objectinfo.js#L49-L53 | train |
mazaid/check | examples/functions.js | initCheckApi | function initCheckApi(logger, config) {
return new Promise((resolve, reject) => {
var check = new Check(logger, config);
var promises = [];
var checkers = require('mazaid-checkers');
for (var checker of checkers) {
promises.push(check.add(checker));
}
... | javascript | function initCheckApi(logger, config) {
return new Promise((resolve, reject) => {
var check = new Check(logger, config);
var promises = [];
var checkers = require('mazaid-checkers');
for (var checker of checkers) {
promises.push(check.add(checker));
}
... | [
"function",
"initCheckApi",
"(",
"logger",
",",
"config",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"var",
"check",
"=",
"new",
"Check",
"(",
"logger",
",",
"config",
")",
";",
"var",
"promises",
"=",
"... | init check api, add ping checker
@return {Promise} | [
"init",
"check",
"api",
"add",
"ping",
"checker"
] | 9bd0f7c5b44b1c996c2c805ae2a3c480c7009409 | https://github.com/mazaid/check/blob/9bd0f7c5b44b1c996c2c805ae2a3c480c7009409/examples/functions.js#L19-L45 | train |
mazaid/check | examples/functions.js | runCheckTask | function runCheckTask(logger, checkTask) {
return new Promise((resolve, reject) => {
// create check task object
// raw.id = uuid();
// var checkTask = new CheckTask(raw);
// validate check task
checkTask.validate(logger)
.then((checkTask) => {
... | javascript | function runCheckTask(logger, checkTask) {
return new Promise((resolve, reject) => {
// create check task object
// raw.id = uuid();
// var checkTask = new CheckTask(raw);
// validate check task
checkTask.validate(logger)
.then((checkTask) => {
... | [
"function",
"runCheckTask",
"(",
"logger",
",",
"checkTask",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"// create check task object",
"// raw.id = uuid();",
"// var checkTask = new CheckTask(raw);",
"// validate check task",... | exec check task
@param {Object} checkTask
@return {Promise} | [
"exec",
"check",
"task"
] | 9bd0f7c5b44b1c996c2c805ae2a3c480c7009409 | https://github.com/mazaid/check/blob/9bd0f7c5b44b1c996c2c805ae2a3c480c7009409/examples/functions.js#L54-L123 | train |
peteromano/jetrunner | example/vendor/mocha/support/compile.js | parseRequires | function parseRequires(js) {
return js
.replace(/require\('events'\)/g, "require('browser/events')")
.replace(/require\('debug'\)/g, "require('browser/debug')")
.replace(/require\('path'\)/g, "require('browser/path')")
.replace(/require\('diff'\)/g, "require('browser/diff')")
.replace(/require\('t... | javascript | function parseRequires(js) {
return js
.replace(/require\('events'\)/g, "require('browser/events')")
.replace(/require\('debug'\)/g, "require('browser/debug')")
.replace(/require\('path'\)/g, "require('browser/path')")
.replace(/require\('diff'\)/g, "require('browser/diff')")
.replace(/require\('t... | [
"function",
"parseRequires",
"(",
"js",
")",
"{",
"return",
"js",
".",
"replace",
"(",
"/",
"require\\('events'\\)",
"/",
"g",
",",
"\"require('browser/events')\"",
")",
".",
"replace",
"(",
"/",
"require\\('debug'\\)",
"/",
"g",
",",
"\"require('browser/debug')\"... | Parse requires. | [
"Parse",
"requires",
"."
] | 1882e0ee83d31fe1c799b42848c8c1357a62c995 | https://github.com/peteromano/jetrunner/blob/1882e0ee83d31fe1c799b42848c8c1357a62c995/example/vendor/mocha/support/compile.js#L44-L52 | train |
jlindsey/grunt-reconfigure | tasks/reconfigure.js | function(obj, parts) {
if (parts.length === 0) { return true; }
var key = parts.shift();
if (!_(obj).has(key)) {
return false;
} else {
return hasKeyPath(obj[key], parts);
}
} | javascript | function(obj, parts) {
if (parts.length === 0) { return true; }
var key = parts.shift();
if (!_(obj).has(key)) {
return false;
} else {
return hasKeyPath(obj[key], parts);
}
} | [
"function",
"(",
"obj",
",",
"parts",
")",
"{",
"if",
"(",
"parts",
".",
"length",
"===",
"0",
")",
"{",
"return",
"true",
";",
"}",
"var",
"key",
"=",
"parts",
".",
"shift",
"(",
")",
";",
"if",
"(",
"!",
"_",
"(",
"obj",
")",
".",
"has",
... | Recursively step through the provided object and return whether it contains the provided keypath. | [
"Recursively",
"step",
"through",
"the",
"provided",
"object",
"and",
"return",
"whether",
"it",
"contains",
"the",
"provided",
"keypath",
"."
] | eebb9485eeeea39e3783b54a48792f5e6d956095 | https://github.com/jlindsey/grunt-reconfigure/blob/eebb9485eeeea39e3783b54a48792f5e6d956095/tasks/reconfigure.js#L26-L36 | train | |
jlindsey/grunt-reconfigure | tasks/reconfigure.js | function(obj, env, keypath) {
if (!_.isObject(obj) || _.isArray(obj)) { return; }
if (hasKeyPath(obj, ['options', 'reconfigureOverrides', env])) {
var options = obj.options,
overrides = obj.options.reconfigureOverrides[env];
for (var key in overrides) {
var update = {
... | javascript | function(obj, env, keypath) {
if (!_.isObject(obj) || _.isArray(obj)) { return; }
if (hasKeyPath(obj, ['options', 'reconfigureOverrides', env])) {
var options = obj.options,
overrides = obj.options.reconfigureOverrides[env];
for (var key in overrides) {
var update = {
... | [
"function",
"(",
"obj",
",",
"env",
",",
"keypath",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isObject",
"(",
"obj",
")",
"||",
"_",
".",
"isArray",
"(",
"obj",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"hasKeyPath",
"(",
"obj",
",",
"[",
"'op... | Recursively step through the provided object, searching for an `options` object with `reconfigureOverrides` containing the provided `env`. If it finds one, it resets any keys and values found inside on the containing `options` object. | [
"Recursively",
"step",
"through",
"the",
"provided",
"object",
"searching",
"for",
"an",
"options",
"object",
"with",
"reconfigureOverrides",
"containing",
"the",
"provided",
"env",
".",
"If",
"it",
"finds",
"one",
"it",
"resets",
"any",
"keys",
"and",
"values",... | eebb9485eeeea39e3783b54a48792f5e6d956095 | https://github.com/jlindsey/grunt-reconfigure/blob/eebb9485eeeea39e3783b54a48792f5e6d956095/tasks/reconfigure.js#L44-L72 | train | |
Pocketbrain/native-ads-web-ad-library | src/util/logger.js | pushLogEntry | function pushLogEntry(logEntry) {
var logger = window[appSettings.loggerVar];
if (logger) {
logger.logs.push(logEntry);
if (window.console) {
if (typeof console.error === "function" && typeof console.warn === "function") {
switch (logEntry.type) {
... | javascript | function pushLogEntry(logEntry) {
var logger = window[appSettings.loggerVar];
if (logger) {
logger.logs.push(logEntry);
if (window.console) {
if (typeof console.error === "function" && typeof console.warn === "function") {
switch (logEntry.type) {
... | [
"function",
"pushLogEntry",
"(",
"logEntry",
")",
"{",
"var",
"logger",
"=",
"window",
"[",
"appSettings",
".",
"loggerVar",
"]",
";",
"if",
"(",
"logger",
")",
"{",
"logger",
".",
"logs",
".",
"push",
"(",
"logEntry",
")",
";",
"if",
"(",
"window",
... | Push a logEntry to the array of logs and output it to the console
@param logEntry The logEntry to process | [
"Push",
"a",
"logEntry",
"to",
"the",
"array",
"of",
"logs",
"and",
"output",
"it",
"to",
"the",
"console"
] | aafee1c42e0569ee77f334fc2c4eb71eb146957e | https://github.com/Pocketbrain/native-ads-web-ad-library/blob/aafee1c42e0569ee77f334fc2c4eb71eb146957e/src/util/logger.js#L50-L83 | train |
Pocketbrain/native-ads-web-ad-library | src/util/logger.js | getCurrentTimeString | function getCurrentTimeString() {
var today = new Date();
var hh = today.getHours();
var mm = today.getMinutes(); //January is 0
var ss = today.getSeconds();
var ms = today.getMilliseconds();
if (hh < 10) {
hh = '0' + hh;
}
if (mm < 10) {
mm = '0' + mm;
}
if (s... | javascript | function getCurrentTimeString() {
var today = new Date();
var hh = today.getHours();
var mm = today.getMinutes(); //January is 0
var ss = today.getSeconds();
var ms = today.getMilliseconds();
if (hh < 10) {
hh = '0' + hh;
}
if (mm < 10) {
mm = '0' + mm;
}
if (s... | [
"function",
"getCurrentTimeString",
"(",
")",
"{",
"var",
"today",
"=",
"new",
"Date",
"(",
")",
";",
"var",
"hh",
"=",
"today",
".",
"getHours",
"(",
")",
";",
"var",
"mm",
"=",
"today",
".",
"getMinutes",
"(",
")",
";",
"//January is 0",
"var",
"ss... | Get the current time as a string
@returns {string} - the current time in a hh:mm:ss string | [
"Get",
"the",
"current",
"time",
"as",
"a",
"string"
] | aafee1c42e0569ee77f334fc2c4eb71eb146957e | https://github.com/Pocketbrain/native-ads-web-ad-library/blob/aafee1c42e0569ee77f334fc2c4eb71eb146957e/src/util/logger.js#L89-L113 | train |
darrencruse/sugarlisp-core | reader.js | read_from_source | function read_from_source(codestr, filenameOrLexer, options) {
var lexer;
if(typeof filenameOrLexer === 'string') {
lexer = initLexerFor(codestr, filenameOrLexer, options);
}
else {
lexer = filenameOrLexer;
lexer.set_source_text(codestr, options);
}
// read the forms
var forms = read(lexer);... | javascript | function read_from_source(codestr, filenameOrLexer, options) {
var lexer;
if(typeof filenameOrLexer === 'string') {
lexer = initLexerFor(codestr, filenameOrLexer, options);
}
else {
lexer = filenameOrLexer;
lexer.set_source_text(codestr, options);
}
// read the forms
var forms = read(lexer);... | [
"function",
"read_from_source",
"(",
"codestr",
",",
"filenameOrLexer",
",",
"options",
")",
"{",
"var",
"lexer",
";",
"if",
"(",
"typeof",
"filenameOrLexer",
"===",
"'string'",
")",
"{",
"lexer",
"=",
"initLexerFor",
"(",
"codestr",
",",
"filenameOrLexer",
",... | Read the expressions in the provided source code string.
@param codestr = the source code as a string e.g. from reading a source file.
@param filenameOrLexer = the name of source file (or the Lexer for the file)
@return the list (see sl-types) of the expressions in codestr. | [
"Read",
"the",
"expressions",
"in",
"the",
"provided",
"source",
"code",
"string",
"."
] | c6ff983ebc3d60268054d6fe046db4aff6c5f78c | https://github.com/darrencruse/sugarlisp-core/blob/c6ff983ebc3d60268054d6fe046db4aff6c5f78c/reader.js#L55-L77 | train |
darrencruse/sugarlisp-core | reader.js | unuse_dialect | function unuse_dialect(dialectName, lexer, options) {
options = options || {};
if(dialectName && options.validate &&
lexer.dialects[0].name !== dialectName)
{
lexer.error('Attempt to exit dialect "' + dialectName + '" while "' +
lexer.dialects[0].name + '" was still active');
}
slinfo('removing... | javascript | function unuse_dialect(dialectName, lexer, options) {
options = options || {};
if(dialectName && options.validate &&
lexer.dialects[0].name !== dialectName)
{
lexer.error('Attempt to exit dialect "' + dialectName + '" while "' +
lexer.dialects[0].name + '" was still active');
}
slinfo('removing... | [
"function",
"unuse_dialect",
"(",
"dialectName",
",",
"lexer",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"if",
"(",
"dialectName",
"&&",
"options",
".",
"validate",
"&&",
"lexer",
".",
"dialects",
"[",
"0",
"]",
".",
"na... | stop using a dialect
Whereas "use_dialect" enters the scope of a dialect, "unuse_dialect"
exits that scope.
@params dialectName = the name of the dialect to stop using, or if
undefined the most recent dialect "used" in the one that's "unused"
@params lexer = the lexer for the file being "unused" from.
note: if opti... | [
"stop",
"using",
"a",
"dialect"
] | c6ff983ebc3d60268054d6fe046db4aff6c5f78c | https://github.com/darrencruse/sugarlisp-core/blob/c6ff983ebc3d60268054d6fe046db4aff6c5f78c/reader.js#L354-L370 | train |
darrencruse/sugarlisp-core | reader.js | invokeInitDialectFunctions | function invokeInitDialectFunctions(dialect, lexer, options) {
var initfnkey = "__init";
if(dialect[initfnkey]) {
dialect[initfnkey](lexer, dialect, options);
}
if(dialect.lextab[initfnkey]) {
dialect.lextab[initfnkey](lexer, dialect, options);
}
if(dialect.readtab[initfnkey]) {
dialect.readtab[... | javascript | function invokeInitDialectFunctions(dialect, lexer, options) {
var initfnkey = "__init";
if(dialect[initfnkey]) {
dialect[initfnkey](lexer, dialect, options);
}
if(dialect.lextab[initfnkey]) {
dialect.lextab[initfnkey](lexer, dialect, options);
}
if(dialect.readtab[initfnkey]) {
dialect.readtab[... | [
"function",
"invokeInitDialectFunctions",
"(",
"dialect",
",",
"lexer",
",",
"options",
")",
"{",
"var",
"initfnkey",
"=",
"\"__init\"",
";",
"if",
"(",
"dialect",
"[",
"initfnkey",
"]",
")",
"{",
"dialect",
"[",
"initfnkey",
"]",
"(",
"lexer",
",",
"diale... | Init dialect functions can optionally be used to initialize things
at the time a dialect is "used".
They can be placed on the dialect, it's lextab, readtab, or gentab,
under a key named "__init" (note we use two underscores).
They receive as arguments the lexer, the dialect, and the overall
options (as passed to "rea... | [
"Init",
"dialect",
"functions",
"can",
"optionally",
"be",
"used",
"to",
"initialize",
"things",
"at",
"the",
"time",
"a",
"dialect",
"is",
"used",
"."
] | c6ff983ebc3d60268054d6fe046db4aff6c5f78c | https://github.com/darrencruse/sugarlisp-core/blob/c6ff983ebc3d60268054d6fe046db4aff6c5f78c/reader.js#L382-L396 | train |
darrencruse/sugarlisp-core | reader.js | read | function read(lexer, precedence) {
precedence = precedence || 0;
var form = read_via_closest_dialect(lexer);
// are we a prefix unary operator?
var leftForm = form;
if(sl.isAtom(form)) {
var opSpec = getOperatorSpecFor(form, lexer.dialects);
if(opSpec && isEnabled(opSpec.prefix) && opSpec.prefix.tr... | javascript | function read(lexer, precedence) {
precedence = precedence || 0;
var form = read_via_closest_dialect(lexer);
// are we a prefix unary operator?
var leftForm = form;
if(sl.isAtom(form)) {
var opSpec = getOperatorSpecFor(form, lexer.dialects);
if(opSpec && isEnabled(opSpec.prefix) && opSpec.prefix.tr... | [
"function",
"read",
"(",
"lexer",
",",
"precedence",
")",
"{",
"precedence",
"=",
"precedence",
"||",
"0",
";",
"var",
"form",
"=",
"read_via_closest_dialect",
"(",
"lexer",
")",
";",
"// are we a prefix unary operator?",
"var",
"leftForm",
"=",
"form",
";",
"... | Read the form at the current position in the source.
@param lexer = the lexer that is reading the source file.
@param precedence = internal use only (don't pass)
@return the list (see sl-types) for the expression that was read. | [
"Read",
"the",
"form",
"at",
"the",
"current",
"position",
"in",
"the",
"source",
"."
] | c6ff983ebc3d60268054d6fe046db4aff6c5f78c | https://github.com/darrencruse/sugarlisp-core/blob/c6ff983ebc3d60268054d6fe046db4aff6c5f78c/reader.js#L404-L460 | train |
darrencruse/sugarlisp-core | reader.js | read_via_closest_dialect | function read_via_closest_dialect(lexer, options) {
trace(lexer.message_src_loc("", lexer, {file:false}));
// options allow this function to be used when a readtab
// handler needs to read by invoking a handler that it's
// overridden, without knowing what dialect was overridden.
// (see invoke_readfn_overri... | javascript | function read_via_closest_dialect(lexer, options) {
trace(lexer.message_src_loc("", lexer, {file:false}));
// options allow this function to be used when a readtab
// handler needs to read by invoking a handler that it's
// overridden, without knowing what dialect was overridden.
// (see invoke_readfn_overri... | [
"function",
"read_via_closest_dialect",
"(",
"lexer",
",",
"options",
")",
"{",
"trace",
"(",
"lexer",
".",
"message_src_loc",
"(",
"\"\"",
",",
"lexer",
",",
"{",
"file",
":",
"false",
"}",
")",
")",
";",
"// options allow this function to be used when a readtab"... | Read the form under the current position, using the closest scoped
dialect that contains a matching entry in it's readtab.
If such an entry returns "reader.retry", try the
*next* closest dialect with a match (and so on) until one
of the dialect's reads the form, otherwise it gets read by
the closest "__default" handle... | [
"Read",
"the",
"form",
"under",
"the",
"current",
"position",
"using",
"the",
"closest",
"scoped",
"dialect",
"that",
"contains",
"a",
"matching",
"entry",
"in",
"it",
"s",
"readtab",
"."
] | c6ff983ebc3d60268054d6fe046db4aff6c5f78c | https://github.com/darrencruse/sugarlisp-core/blob/c6ff983ebc3d60268054d6fe046db4aff6c5f78c/reader.js#L479-L546 | train |
darrencruse/sugarlisp-core | reader.js | pop_local_dialects | function pop_local_dialects(lexer, list) {
if(list && list.length > 0) {
// we go in reverse order since the most recently
// used (pushed) dialects will be at the end
for(var i = list.length-1; i >= 0; i--) {
if(list[i].dialect) {
unuse_dialect(list[i].dialect, lexer);
}
}
}
} | javascript | function pop_local_dialects(lexer, list) {
if(list && list.length > 0) {
// we go in reverse order since the most recently
// used (pushed) dialects will be at the end
for(var i = list.length-1; i >= 0; i--) {
if(list[i].dialect) {
unuse_dialect(list[i].dialect, lexer);
}
}
}
} | [
"function",
"pop_local_dialects",
"(",
"lexer",
",",
"list",
")",
"{",
"if",
"(",
"list",
"&&",
"list",
".",
"length",
">",
"0",
")",
"{",
"// we go in reverse order since the most recently",
"// used (pushed) dialects will be at the end",
"for",
"(",
"var",
"i",
"=... | pop any local dialects enabled within the scope of the
provided list.
note: here we intentionally look just one level down at
the *direct* children of the list, since "grandchildren"
have scopes of their own that are "popped" separately. | [
"pop",
"any",
"local",
"dialects",
"enabled",
"within",
"the",
"scope",
"of",
"the",
"provided",
"list",
"."
] | c6ff983ebc3d60268054d6fe046db4aff6c5f78c | https://github.com/darrencruse/sugarlisp-core/blob/c6ff983ebc3d60268054d6fe046db4aff6c5f78c/reader.js#L809-L819 | train |
darrencruse/sugarlisp-core | reader.js | read_delimited_text | function read_delimited_text(lexer, start, end, options) {
options = options || {includeDelimiters: true};
var delimited = lexer.next_delimited_token(start, end, options);
return sl.atom(delimited);
} | javascript | function read_delimited_text(lexer, start, end, options) {
options = options || {includeDelimiters: true};
var delimited = lexer.next_delimited_token(start, end, options);
return sl.atom(delimited);
} | [
"function",
"read_delimited_text",
"(",
"lexer",
",",
"start",
",",
"end",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"includeDelimiters",
":",
"true",
"}",
";",
"var",
"delimited",
"=",
"lexer",
".",
"next_delimited_token",
"(",
"start"... | scan some delimited text and get it as a string atom
lexer.options.omitDelimiters = whether to include the include the delimiters or not | [
"scan",
"some",
"delimited",
"text",
"and",
"get",
"it",
"as",
"a",
"string",
"atom",
"lexer",
".",
"options",
".",
"omitDelimiters",
"=",
"whether",
"to",
"include",
"the",
"include",
"the",
"delimiters",
"or",
"not"
] | c6ff983ebc3d60268054d6fe046db4aff6c5f78c | https://github.com/darrencruse/sugarlisp-core/blob/c6ff983ebc3d60268054d6fe046db4aff6c5f78c/reader.js#L849-L853 | train |
darrencruse/sugarlisp-core | reader.js | symbol | function symbol(lexer, text) {
var token = lexer.next_token(text);
return sl.atom(text, {token: token});
} | javascript | function symbol(lexer, text) {
var token = lexer.next_token(text);
return sl.atom(text, {token: token});
} | [
"function",
"symbol",
"(",
"lexer",
",",
"text",
")",
"{",
"var",
"token",
"=",
"lexer",
".",
"next_token",
"(",
"text",
")",
";",
"return",
"sl",
".",
"atom",
"(",
"text",
",",
"{",
"token",
":",
"token",
"}",
")",
";",
"}"
] | A symbol
Use reader.symbol in their readtab to ensure the lexer
scans the specified token text correctly as a symbol. | [
"A",
"symbol",
"Use",
"reader",
".",
"symbol",
"in",
"their",
"readtab",
"to",
"ensure",
"the",
"lexer",
"scans",
"the",
"specified",
"token",
"text",
"correctly",
"as",
"a",
"symbol",
"."
] | c6ff983ebc3d60268054d6fe046db4aff6c5f78c | https://github.com/darrencruse/sugarlisp-core/blob/c6ff983ebc3d60268054d6fe046db4aff6c5f78c/reader.js#L1211-L1214 | train |
Knorcedger/mongoose-schema-extender | index.js | callback | function callback(req, res, resolve, reject, error, result, permissions,
action) {
if (error) {
reqlog.error('internal server error', error);
if (exports.handleErrors) {
responseBuilder.error(req, res, 'INTERNAL_SERVER_ERROR');
} else {
reject(error);
}
} else {
// filter the result attributes to sen... | javascript | function callback(req, res, resolve, reject, error, result, permissions,
action) {
if (error) {
reqlog.error('internal server error', error);
if (exports.handleErrors) {
responseBuilder.error(req, res, 'INTERNAL_SERVER_ERROR');
} else {
reject(error);
}
} else {
// filter the result attributes to sen... | [
"function",
"callback",
"(",
"req",
",",
"res",
",",
"resolve",
",",
"reject",
",",
"error",
",",
"result",
",",
"permissions",
",",
"action",
")",
"{",
"if",
"(",
"error",
")",
"{",
"reqlog",
".",
"error",
"(",
"'internal server error'",
",",
"error",
... | Query callback. Handles errors, filters attributes
@method callback
@param {object} req The request object
@param {object} res The response object
@param {function} resolve The promise resolve
@param {function} reject The promise reject
@param {object} error The query error... | [
"Query",
"callback",
".",
"Handles",
"errors",
"filters",
"attributes"
] | 6878d7bee4a1a4befb8698dd9d1787242c6be395 | https://github.com/Knorcedger/mongoose-schema-extender/blob/6878d7bee4a1a4befb8698dd9d1787242c6be395/index.js#L183-L232 | train |
Knorcedger/mongoose-schema-extender | index.js | filterAttributes | function filterAttributes(object, permissions) {
if (object) {
var userType = req.activeUser && req.activeUser.type || 'null';
for (var attribute in object._doc) {
if (object._doc.hasOwnProperty(attribute)) {
// dont return this attribute when:
if (!permissions[attribute] || // if this attribute i... | javascript | function filterAttributes(object, permissions) {
if (object) {
var userType = req.activeUser && req.activeUser.type || 'null';
for (var attribute in object._doc) {
if (object._doc.hasOwnProperty(attribute)) {
// dont return this attribute when:
if (!permissions[attribute] || // if this attribute i... | [
"function",
"filterAttributes",
"(",
"object",
",",
"permissions",
")",
"{",
"if",
"(",
"object",
")",
"{",
"var",
"userType",
"=",
"req",
".",
"activeUser",
"&&",
"req",
".",
"activeUser",
".",
"type",
"||",
"'null'",
";",
"for",
"(",
"var",
"attribute"... | Delete the attributes that the activeUser cant see
@method filterAttributes
@param {object} object The result object
@param {object} permissions The permissions object
@return {object} The filtered object | [
"Delete",
"the",
"attributes",
"that",
"the",
"activeUser",
"cant",
"see"
] | 6878d7bee4a1a4befb8698dd9d1787242c6be395 | https://github.com/Knorcedger/mongoose-schema-extender/blob/6878d7bee4a1a4befb8698dd9d1787242c6be395/index.js#L213-L231 | train |
Industryswarm/isnode-mod-data | lib/mongodb/mongodb/lib/operations/cursor_ops.js | hasNext | function hasNext(cursor, callback) {
const Cursor = require('../cursor');
if (cursor.s.currentDoc) {
return callback(null, true);
}
if (cursor.isNotified()) {
return callback(null, false);
}
nextObject(cursor, (err, doc) => {
if (err) return callback(err, null);
if (cursor.s.state === Cur... | javascript | function hasNext(cursor, callback) {
const Cursor = require('../cursor');
if (cursor.s.currentDoc) {
return callback(null, true);
}
if (cursor.isNotified()) {
return callback(null, false);
}
nextObject(cursor, (err, doc) => {
if (err) return callback(err, null);
if (cursor.s.state === Cur... | [
"function",
"hasNext",
"(",
"cursor",
",",
"callback",
")",
"{",
"const",
"Cursor",
"=",
"require",
"(",
"'../cursor'",
")",
";",
"if",
"(",
"cursor",
".",
"s",
".",
"currentDoc",
")",
"{",
"return",
"callback",
"(",
"null",
",",
"true",
")",
";",
"}... | Check if there is any document still available in the cursor.
@method
@param {Cursor} cursor The Cursor instance on which to run.
@param {Cursor~resultCallback} [callback] The result callback. | [
"Check",
"if",
"there",
"is",
"any",
"document",
"still",
"available",
"in",
"the",
"cursor",
"."
] | 5adc639b88a0d72cbeef23a6b5df7f4540745089 | https://github.com/Industryswarm/isnode-mod-data/blob/5adc639b88a0d72cbeef23a6b5df7f4540745089/lib/mongodb/mongodb/lib/operations/cursor_ops.js#L116-L134 | train |
Industryswarm/isnode-mod-data | lib/mongodb/mongodb/lib/operations/cursor_ops.js | nextObject | function nextObject(cursor, callback) {
const Cursor = require('../cursor');
if (cursor.s.state === Cursor.CLOSED || (cursor.isDead && cursor.isDead()))
return handleCallback(
callback,
MongoError.create({ message: 'Cursor is closed', driver: true })
);
if (cursor.s.state === Cursor.INIT && c... | javascript | function nextObject(cursor, callback) {
const Cursor = require('../cursor');
if (cursor.s.state === Cursor.CLOSED || (cursor.isDead && cursor.isDead()))
return handleCallback(
callback,
MongoError.create({ message: 'Cursor is closed', driver: true })
);
if (cursor.s.state === Cursor.INIT && c... | [
"function",
"nextObject",
"(",
"cursor",
",",
"callback",
")",
"{",
"const",
"Cursor",
"=",
"require",
"(",
"'../cursor'",
")",
";",
"if",
"(",
"cursor",
".",
"s",
".",
"state",
"===",
"Cursor",
".",
"CLOSED",
"||",
"(",
"cursor",
".",
"isDead",
"&&",
... | Get the next available document from the cursor, returns null if no more documents are available. | [
"Get",
"the",
"next",
"available",
"document",
"from",
"the",
"cursor",
"returns",
"null",
"if",
"no",
"more",
"documents",
"are",
"available",
"."
] | 5adc639b88a0d72cbeef23a6b5df7f4540745089 | https://github.com/Industryswarm/isnode-mod-data/blob/5adc639b88a0d72cbeef23a6b5df7f4540745089/lib/mongodb/mongodb/lib/operations/cursor_ops.js#L167-L189 | train |
Industryswarm/isnode-mod-data | lib/mongodb/mongodb/lib/operations/cursor_ops.js | toArray | function toArray(cursor, callback) {
const Cursor = require('../cursor');
const items = [];
// Reset cursor
cursor.rewind();
cursor.s.state = Cursor.INIT;
// Fetch all the documents
const fetchDocs = () => {
cursor._next((err, doc) => {
if (err) {
return cursor._endSession
?... | javascript | function toArray(cursor, callback) {
const Cursor = require('../cursor');
const items = [];
// Reset cursor
cursor.rewind();
cursor.s.state = Cursor.INIT;
// Fetch all the documents
const fetchDocs = () => {
cursor._next((err, doc) => {
if (err) {
return cursor._endSession
?... | [
"function",
"toArray",
"(",
"cursor",
",",
"callback",
")",
"{",
"const",
"Cursor",
"=",
"require",
"(",
"'../cursor'",
")",
";",
"const",
"items",
"=",
"[",
"]",
";",
"// Reset cursor",
"cursor",
".",
"rewind",
"(",
")",
";",
"cursor",
".",
"s",
".",
... | Returns an array of documents. See Cursor.prototype.toArray for more information.
@method
@param {Cursor} cursor The Cursor instance from which to get the next document.
@param {Cursor~toArrayResultCallback} [callback] The result callback. | [
"Returns",
"an",
"array",
"of",
"documents",
".",
"See",
"Cursor",
".",
"prototype",
".",
"toArray",
"for",
"more",
"information",
"."
] | 5adc639b88a0d72cbeef23a6b5df7f4540745089 | https://github.com/Industryswarm/isnode-mod-data/blob/5adc639b88a0d72cbeef23a6b5df7f4540745089/lib/mongodb/mongodb/lib/operations/cursor_ops.js#L198-L240 | train |
composi/idb | src/index.js | get | function get(key, store = getDefaultStore()) {
let req
return store[IDBStore]('readonly', store => {
req = store.get(key)
}).then(() => req.result)
} | javascript | function get(key, store = getDefaultStore()) {
let req
return store[IDBStore]('readonly', store => {
req = store.get(key)
}).then(() => req.result)
} | [
"function",
"get",
"(",
"key",
",",
"store",
"=",
"getDefaultStore",
"(",
")",
")",
"{",
"let",
"req",
"return",
"store",
"[",
"IDBStore",
"]",
"(",
"'readonly'",
",",
"store",
"=>",
"{",
"req",
"=",
"store",
".",
"get",
"(",
"key",
")",
"}",
")",
... | Get a value based on the provided key.
@param {string} key The key to use.
@param {any} store A default value provided by IDB.
@return {Promise} Promise | [
"Get",
"a",
"value",
"based",
"on",
"the",
"provided",
"key",
"."
] | f64c25ec2b90d23b04820722bac758bc869f0871 | https://github.com/composi/idb/blob/f64c25ec2b90d23b04820722bac758bc869f0871/src/index.js#L53-L58 | train |
constantology/id8 | src/Source.js | function( config ) {
!is_obj( config ) || Object.keys( config ).forEach( function( key ) {
if ( typeof config[key] == 'function' && typeof this[key] == 'function' ) // this allows you to override a method for a
this[__override__]( key, config[key] ); // specific instance of a Class, rather than requ... | javascript | function( config ) {
!is_obj( config ) || Object.keys( config ).forEach( function( key ) {
if ( typeof config[key] == 'function' && typeof this[key] == 'function' ) // this allows you to override a method for a
this[__override__]( key, config[key] ); // specific instance of a Class, rather than requ... | [
"function",
"(",
"config",
")",
"{",
"!",
"is_obj",
"(",
"config",
")",
"||",
"Object",
".",
"keys",
"(",
"config",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"if",
"(",
"typeof",
"config",
"[",
"key",
"]",
"==",
"'function'",
"&&"... | this is set by `beforeinstance` to avoid weird behaviour constructor methods | [
"this",
"is",
"set",
"by",
"beforeinstance",
"to",
"avoid",
"weird",
"behaviour",
"constructor",
"methods"
] | 8e97cbf56406da2cd53f825fa4f24ae2263971ce | https://github.com/constantology/id8/blob/8e97cbf56406da2cd53f825fa4f24ae2263971ce/src/Source.js#L115-L124 | train | |
antonycourtney/tabli-core | lib/js/tabWindow.js | makeBookmarkedTabItem | function makeBookmarkedTabItem(bm) {
var urlStr = bm.url;
if (!urlStr) {
console.error('makeBookmarkedTabItem: Malformed bookmark: missing URL!: ', bm);
urlStr = ''; // better than null or undefined!
}
if (bm.title === undefined) {
console.warn('makeBookmarkedTabItem: Bookmark title undefined (igno... | javascript | function makeBookmarkedTabItem(bm) {
var urlStr = bm.url;
if (!urlStr) {
console.error('makeBookmarkedTabItem: Malformed bookmark: missing URL!: ', bm);
urlStr = ''; // better than null or undefined!
}
if (bm.title === undefined) {
console.warn('makeBookmarkedTabItem: Bookmark title undefined (igno... | [
"function",
"makeBookmarkedTabItem",
"(",
"bm",
")",
"{",
"var",
"urlStr",
"=",
"bm",
".",
"url",
";",
"if",
"(",
"!",
"urlStr",
")",
"{",
"console",
".",
"error",
"(",
"'makeBookmarkedTabItem: Malformed bookmark: missing URL!: '",
",",
"bm",
")",
";",
"urlStr... | Initialize a TabItem from a bookmark
Returned TabItem is closed (not associated with an open tab) | [
"Initialize",
"a",
"TabItem",
"from",
"a",
"bookmark"
] | 76cc540891421bc6c8bdcf00f277ebb6e716fdd9 | https://github.com/antonycourtney/tabli-core/blob/76cc540891421bc6c8bdcf00f277ebb6e716fdd9/lib/js/tabWindow.js#L97-L119 | train |
antonycourtney/tabli-core | lib/js/tabWindow.js | makeOpenTabItem | function makeOpenTabItem(tab) {
var urlStr = tab.url;
if (!urlStr) {
console.error('malformed tab -- no URL: ', tab);
urlStr = '';
}
/*
if (!tab.title) {
console.warn("tab missing title (ignoring...): ", tab);
}
*/
var tabItem = new TabItem({
url: urlStr,
audible: tab.audible,
... | javascript | function makeOpenTabItem(tab) {
var urlStr = tab.url;
if (!urlStr) {
console.error('malformed tab -- no URL: ', tab);
urlStr = '';
}
/*
if (!tab.title) {
console.warn("tab missing title (ignoring...): ", tab);
}
*/
var tabItem = new TabItem({
url: urlStr,
audible: tab.audible,
... | [
"function",
"makeOpenTabItem",
"(",
"tab",
")",
"{",
"var",
"urlStr",
"=",
"tab",
".",
"url",
";",
"if",
"(",
"!",
"urlStr",
")",
"{",
"console",
".",
"error",
"(",
"'malformed tab -- no URL: '",
",",
"tab",
")",
";",
"urlStr",
"=",
"''",
";",
"}",
"... | Initialize a TabItem from an open Chrome tab | [
"Initialize",
"a",
"TabItem",
"from",
"an",
"open",
"Chrome",
"tab"
] | 76cc540891421bc6c8bdcf00f277ebb6e716fdd9 | https://github.com/antonycourtney/tabli-core/blob/76cc540891421bc6c8bdcf00f277ebb6e716fdd9/lib/js/tabWindow.js#L124-L146 | train |
antonycourtney/tabli-core | lib/js/tabWindow.js | mergeOpenTabs | function mergeOpenTabs(tabItems, openTabs) {
var tabInfo = getOpenTabInfo(tabItems, openTabs);
/* TODO: Use algorithm from OLDtabWindow.js to determine tab order.
* For now, let's just concat open and closed tabs, in their sorted order.
*/
var openTabItems = tabInfo.get(true, Immutable.Seq()).sortBy(functi... | javascript | function mergeOpenTabs(tabItems, openTabs) {
var tabInfo = getOpenTabInfo(tabItems, openTabs);
/* TODO: Use algorithm from OLDtabWindow.js to determine tab order.
* For now, let's just concat open and closed tabs, in their sorted order.
*/
var openTabItems = tabInfo.get(true, Immutable.Seq()).sortBy(functi... | [
"function",
"mergeOpenTabs",
"(",
"tabItems",
",",
"openTabs",
")",
"{",
"var",
"tabInfo",
"=",
"getOpenTabInfo",
"(",
"tabItems",
",",
"openTabs",
")",
";",
"/* TODO: Use algorithm from OLDtabWindow.js to determine tab order.\n * For now, let's just concat open and closed tabs... | Merge currently open tabs from an open Chrome window with tabItem state of a saved
tabWindow
@param {Seq<TabItem>} tabItems -- previous TabItem state
@param {[Tab]} openTabs -- currently open tabs from Chrome window
@returns {Seq<TabItem>} TabItems reflecting current window state | [
"Merge",
"currently",
"open",
"tabs",
"from",
"an",
"open",
"Chrome",
"window",
"with",
"tabItem",
"state",
"of",
"a",
"saved",
"tabWindow"
] | 76cc540891421bc6c8bdcf00f277ebb6e716fdd9 | https://github.com/antonycourtney/tabli-core/blob/76cc540891421bc6c8bdcf00f277ebb6e716fdd9/lib/js/tabWindow.js#L370-L386 | train |
antonycourtney/tabli-core | lib/js/tabWindow.js | updateWindow | function updateWindow(tabWindow, chromeWindow) {
// console.log("updateWindow: ", tabWindow.toJS(), chromeWindow);
var mergedTabItems = mergeOpenTabs(tabWindow.tabItems, chromeWindow.tabs);
var updWindow = tabWindow.set('tabItems', mergedTabItems).set('focused', chromeWindow.focused).set('open', true).set('openWi... | javascript | function updateWindow(tabWindow, chromeWindow) {
// console.log("updateWindow: ", tabWindow.toJS(), chromeWindow);
var mergedTabItems = mergeOpenTabs(tabWindow.tabItems, chromeWindow.tabs);
var updWindow = tabWindow.set('tabItems', mergedTabItems).set('focused', chromeWindow.focused).set('open', true).set('openWi... | [
"function",
"updateWindow",
"(",
"tabWindow",
",",
"chromeWindow",
")",
"{",
"// console.log(\"updateWindow: \", tabWindow.toJS(), chromeWindow);",
"var",
"mergedTabItems",
"=",
"mergeOpenTabs",
"(",
"tabWindow",
".",
"tabItems",
",",
"chromeWindow",
".",
"tabs",
")",
";"... | update a TabWindow from a current snapshot of the Chrome Window
@param {TabWindow} tabWindow - TabWindow to be updated
@param {ChromeWindow} chromeWindow - current snapshot of Chrome window state
@return {TabWindow} Updated TabWindow | [
"update",
"a",
"TabWindow",
"from",
"a",
"current",
"snapshot",
"of",
"the",
"Chrome",
"Window"
] | 76cc540891421bc6c8bdcf00f277ebb6e716fdd9 | https://github.com/antonycourtney/tabli-core/blob/76cc540891421bc6c8bdcf00f277ebb6e716fdd9/lib/js/tabWindow.js#L396-L401 | train |
antonycourtney/tabli-core | lib/js/tabWindow.js | saveTab | function saveTab(tabWindow, tabItem, tabNode) {
var _tabWindow$tabItems$f3 = tabWindow.tabItems.findEntry(function (ti) {
return ti.open && ti.openTabId === tabItem.openTabId;
});
var _tabWindow$tabItems$f4 = _slicedToArray(_tabWindow$tabItems$f3, 1);
var index = _tabWindow$tabItems$f4[0];
var updTabI... | javascript | function saveTab(tabWindow, tabItem, tabNode) {
var _tabWindow$tabItems$f3 = tabWindow.tabItems.findEntry(function (ti) {
return ti.open && ti.openTabId === tabItem.openTabId;
});
var _tabWindow$tabItems$f4 = _slicedToArray(_tabWindow$tabItems$f3, 1);
var index = _tabWindow$tabItems$f4[0];
var updTabI... | [
"function",
"saveTab",
"(",
"tabWindow",
",",
"tabItem",
",",
"tabNode",
")",
"{",
"var",
"_tabWindow$tabItems$f3",
"=",
"tabWindow",
".",
"tabItems",
".",
"findEntry",
"(",
"function",
"(",
"ti",
")",
"{",
"return",
"ti",
".",
"open",
"&&",
"ti",
".",
"... | Update a tab's saved state
@param {TabWindow} tabWindow - tab window with tab that's been closed
@param {TabItem} tabItem -- open tab that has been saved
@param {BookmarkTreeNode} tabNode -- bookmark node for saved bookmark
@return {TabWindow} tabWindow with tabItems updated to reflect saved state | [
"Update",
"a",
"tab",
"s",
"saved",
"state"
] | 76cc540891421bc6c8bdcf00f277ebb6e716fdd9 | https://github.com/antonycourtney/tabli-core/blob/76cc540891421bc6c8bdcf00f277ebb6e716fdd9/lib/js/tabWindow.js#L445-L460 | train |
terryweiss/papyrus-core | document/probe.js | pushin | function pushin( path, record, setter, newValue ) {
var context = record;
var parent = record;
var lastPart = null;
var _i;
var _len;
var part;
var keys;
for ( _i = 0, _len = path.length; _i < _len; _i++ ) {
part = path[_i];
lastPart = part;
parent = context;
context = context[part];
if ( sys.isNull(... | javascript | function pushin( path, record, setter, newValue ) {
var context = record;
var parent = record;
var lastPart = null;
var _i;
var _len;
var part;
var keys;
for ( _i = 0, _len = path.length; _i < _len; _i++ ) {
part = path[_i];
lastPart = part;
parent = context;
context = context[part];
if ( sys.isNull(... | [
"function",
"pushin",
"(",
"path",
",",
"record",
",",
"setter",
",",
"newValue",
")",
"{",
"var",
"context",
"=",
"record",
";",
"var",
"parent",
"=",
"record",
";",
"var",
"lastPart",
"=",
"null",
";",
"var",
"_i",
";",
"var",
"_len",
";",
"var",
... | This will write the value into a record at the path, creating intervening objects if they don't exist
@private
@param {array} path The split path of the element to work with
@param {object} record The record to reach into
@param {string} setter The set command, defaults to $set
@param {object} newValue The value to wri... | [
"This",
"will",
"write",
"the",
"value",
"into",
"a",
"record",
"at",
"the",
"path",
"creating",
"intervening",
"objects",
"if",
"they",
"don",
"t",
"exist"
] | d80fbcc2a8d07492477bab49df41c536e9a9230b | https://github.com/terryweiss/papyrus-core/blob/d80fbcc2a8d07492477bab49df41c536e9a9230b/document/probe.js#L199-L340 | train |
forfuturellc/svc-fbr | src/lib/fs.js | handle | function handle(options, callback) {
if (_.isString(options)) {
options = { path: options };
}
if (_.isObject(options)) {
const opts = { };
_.merge(opts, config, options);
options = opts;
} else {
options = _.cloneDeep(config);
}
options.path = options.path || config.get("home");
ret... | javascript | function handle(options, callback) {
if (_.isString(options)) {
options = { path: options };
}
if (_.isObject(options)) {
const opts = { };
_.merge(opts, config, options);
options = opts;
} else {
options = _.cloneDeep(config);
}
options.path = options.path || config.get("home");
ret... | [
"function",
"handle",
"(",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"_",
".",
"isString",
"(",
"options",
")",
")",
"{",
"options",
"=",
"{",
"path",
":",
"options",
"}",
";",
"}",
"if",
"(",
"_",
".",
"isObject",
"(",
"options",
")",
")"... | Handling requests for browsing file-system
@param {Object|String} options
@param {Function} callback | [
"Handling",
"requests",
"for",
"browsing",
"file",
"-",
"system"
] | 8c07c71d6423d1dbd4f903a032dea0bfec63894e | https://github.com/forfuturellc/svc-fbr/blob/8c07c71d6423d1dbd4f903a032dea0bfec63894e/src/lib/fs.js#L29-L59 | train |
fd/fd-angular-core | lib/Component.js | Component | function Component(opts) {
if (typeof opts === "function") {
var _constructor = opts;opts = null;
return register(_constructor);
}
opts = opts || {};
var _opts = opts;
var _opts$restrict = _opts.restrict;
var restrict = _opts$restrict === undefined ? "EA" : _opts$restrict;
var _opts$replace = _opts.replace;... | javascript | function Component(opts) {
if (typeof opts === "function") {
var _constructor = opts;opts = null;
return register(_constructor);
}
opts = opts || {};
var _opts = opts;
var _opts$restrict = _opts.restrict;
var restrict = _opts$restrict === undefined ? "EA" : _opts$restrict;
var _opts$replace = _opts.replace;... | [
"function",
"Component",
"(",
"opts",
")",
"{",
"if",
"(",
"typeof",
"opts",
"===",
"\"function\"",
")",
"{",
"var",
"_constructor",
"=",
"opts",
";",
"opts",
"=",
"null",
";",
"return",
"register",
"(",
"_constructor",
")",
";",
"}",
"opts",
"=",
"opt... | Declare an angular Component directive.
@function Component
@param {Object} [opts]
@param {String} [opts.name]
@param {String} [opts.restrict="EA"]
@param {Boolean} [opts.restrict="false"]
@param {Boolean} [opts.transclude="EA"]
@param {Object} [opts.scope={}]
@param {String} [opts.template]
@param {String} [opts.tem... | [
"Declare",
"an",
"angular",
"Component",
"directive",
"."
] | e4206c90310e9fcf440abbd5aa9b12d97ed6c9a6 | https://github.com/fd/fd-angular-core/blob/e4206c90310e9fcf440abbd5aa9b12d97ed6c9a6/lib/Component.js#L38-L90 | train |
Majiir/safesocket | safesocket.js | safesocket | function safesocket (expected, fn) {
return function () {
var _args = [];
for (var idx in arguments) {
_args.push(arguments[idx]);
}
var args = _args.filter(notFunction).slice(0, expected);
for (var i = args.length; i < expected; i++) {
args.push(undefined);
}
var arg = _args.pop();
args.push((... | javascript | function safesocket (expected, fn) {
return function () {
var _args = [];
for (var idx in arguments) {
_args.push(arguments[idx]);
}
var args = _args.filter(notFunction).slice(0, expected);
for (var i = args.length; i < expected; i++) {
args.push(undefined);
}
var arg = _args.pop();
args.push((... | [
"function",
"safesocket",
"(",
"expected",
",",
"fn",
")",
"{",
"return",
"function",
"(",
")",
"{",
"var",
"_args",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"idx",
"in",
"arguments",
")",
"{",
"_args",
".",
"push",
"(",
"arguments",
"[",
"idx",
"]",... | Wraps socket.io event handlers to prevent crashes from certain malicious inputs. | [
"Wraps",
"socket",
".",
"io",
"event",
"handlers",
"to",
"prevent",
"crashes",
"from",
"certain",
"malicious",
"inputs",
"."
] | afcb81cc8d861f0f6099c6731c1333265443aa33 | https://github.com/Majiir/safesocket/blob/afcb81cc8d861f0f6099c6731c1333265443aa33/safesocket.js#L11-L28 | train |
Acconut/scrib | lib/scrib.js | Scrib | function Scrib(adapters, callback) {
EventEmitter.call(this);
// Convert array to object
if(Array.isArray(adapters)) {
var am = adapters;
adapters = {};
am.forEach(function(m) {
adapters[m] = {};
});
}
var all = [],
self = this;
... | javascript | function Scrib(adapters, callback) {
EventEmitter.call(this);
// Convert array to object
if(Array.isArray(adapters)) {
var am = adapters;
adapters = {};
am.forEach(function(m) {
adapters[m] = {};
});
}
var all = [],
self = this;
... | [
"function",
"Scrib",
"(",
"adapters",
",",
"callback",
")",
"{",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"// Convert array to object",
"if",
"(",
"Array",
".",
"isArray",
"(",
"adapters",
")",
")",
"{",
"var",
"am",
"=",
"adapters",
";",
"ada... | Initalizes a new logger
@param {Array|Object} adapters Array containing adapters to load or object with adapters as keys and options as values
@param {Function} callback Callback function | [
"Initalizes",
"a",
"new",
"logger"
] | 9a1dae602c0badcd00fe2dad88c07e89029dd402 | https://github.com/Acconut/scrib/blob/9a1dae602c0badcd00fe2dad88c07e89029dd402/lib/scrib.js#L12-L44 | train |
mgesmundo/authorify-client | lib/class/Header.js | function(header, key, cert) {
var parsedHeader;
if (header) {
if (!header.isBase64()) {
throw new CError('missing header or wrong format').log();
} else {
parsedHeader = JSON.parse(forge.util.decode64(header));
this.isModeAllowed.call(this, parsedH... | javascript | function(header, key, cert) {
var parsedHeader;
if (header) {
if (!header.isBase64()) {
throw new CError('missing header or wrong format').log();
} else {
parsedHeader = JSON.parse(forge.util.decode64(header));
this.isModeAllowed.call(this, parsedH... | [
"function",
"(",
"header",
",",
"key",
",",
"cert",
")",
"{",
"var",
"parsedHeader",
";",
"if",
"(",
"header",
")",
"{",
"if",
"(",
"!",
"header",
".",
"isBase64",
"(",
")",
")",
"{",
"throw",
"new",
"CError",
"(",
"'missing header or wrong format'",
"... | Parse the Authorization header
@param {String} header The Authorization header in Base64 format
@param {String} key The private RSA key
@param {String} cert The public X.509 certificate
@return {Object} The parsed header
@static | [
"Parse",
"the",
"Authorization",
"header"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/lib/class/Header.js#L57-L114 | train | |
mgesmundo/authorify-client | lib/class/Header.js | function(data) {
try {
data = data || this.getContent();
return this.keychain.sign(JSON.stringify(data));
} catch(e) {
throw new CError({
body: {
code: 'ImATeapot',
message: 'unable to sign content',
cause: e
}
}).log('b... | javascript | function(data) {
try {
data = data || this.getContent();
return this.keychain.sign(JSON.stringify(data));
} catch(e) {
throw new CError({
body: {
code: 'ImATeapot',
message: 'unable to sign content',
cause: e
}
}).log('b... | [
"function",
"(",
"data",
")",
"{",
"try",
"{",
"data",
"=",
"data",
"||",
"this",
".",
"getContent",
"(",
")",
";",
"return",
"this",
".",
"keychain",
".",
"sign",
"(",
"JSON",
".",
"stringify",
"(",
"data",
")",
")",
";",
"}",
"catch",
"(",
"e",... | Generate a signature for for data or content property
@param {String/Object} data The data to sign or content if missing
@return {String} The signature in Base64 format | [
"Generate",
"a",
"signature",
"for",
"for",
"data",
"or",
"content",
"property"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/lib/class/Header.js#L183-L196 | train | |
mgesmundo/authorify-client | lib/class/Header.js | function() {
var content = this.getContent();
var out = {
payload: this.getPayload(),
content: this.cryptContent(content),
signature: this.generateSignature()
};
if (debug) {
log.debug('%s encode with sid %s', app.name, out.payload.sid);
log.debug('%s enco... | javascript | function() {
var content = this.getContent();
var out = {
payload: this.getPayload(),
content: this.cryptContent(content),
signature: this.generateSignature()
};
if (debug) {
log.debug('%s encode with sid %s', app.name, out.payload.sid);
log.debug('%s enco... | [
"function",
"(",
")",
"{",
"var",
"content",
"=",
"this",
".",
"getContent",
"(",
")",
";",
"var",
"out",
"=",
"{",
"payload",
":",
"this",
".",
"getPayload",
"(",
")",
",",
"content",
":",
"this",
".",
"cryptContent",
"(",
"content",
")",
",",
"si... | Encode the header including payload, content and signature
@return {String} The encoded header in Base64 format | [
"Encode",
"the",
"header",
"including",
"payload",
"content",
"and",
"signature"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/lib/class/Header.js#L220-L233 | train | |
Barandis/xduce | src/modules/iteration.js | stringIterator | function stringIterator(str) {
let index = 0;
return {
next() {
return index < bmpLength(str)
? {
value: bmpCharAt(str, index++),
done: false
}
: {
done: true
};
}
};
} | javascript | function stringIterator(str) {
let index = 0;
return {
next() {
return index < bmpLength(str)
? {
value: bmpCharAt(str, index++),
done: false
}
: {
done: true
};
}
};
} | [
"function",
"stringIterator",
"(",
"str",
")",
"{",
"let",
"index",
"=",
"0",
";",
"return",
"{",
"next",
"(",
")",
"{",
"return",
"index",
"<",
"bmpLength",
"(",
"str",
")",
"?",
"{",
"value",
":",
"bmpCharAt",
"(",
"str",
",",
"index",
"++",
")",... | Creates an iterator over strings. ES2015 strings already satisfy the iterator protocol, so this function will not
be used for them. This is for ES5 strings where the iterator protocol doesn't exist. As with ES2015 iterators, it
takes into account double-width BMP characters and will return the entire character as a two... | [
"Creates",
"an",
"iterator",
"over",
"strings",
".",
"ES2015",
"strings",
"already",
"satisfy",
"the",
"iterator",
"protocol",
"so",
"this",
"function",
"will",
"not",
"be",
"used",
"for",
"them",
".",
"This",
"is",
"for",
"ES5",
"strings",
"where",
"the",
... | b454f154f7663475670d4802e28e98ade8c468e7 | https://github.com/Barandis/xduce/blob/b454f154f7663475670d4802e28e98ade8c468e7/src/modules/iteration.js#L48-L62 | train |
Barandis/xduce | src/modules/iteration.js | objectIterator | function objectIterator(obj, sort, kv = false) {
let keys = Object.keys(obj);
keys = typeof sort === 'function' ? keys.sort(sort) : keys.sort();
let index = 0;
return {
next() {
if (index < keys.length) {
const k = keys[index++];
const value = {};
if (kv) {
value.k =... | javascript | function objectIterator(obj, sort, kv = false) {
let keys = Object.keys(obj);
keys = typeof sort === 'function' ? keys.sort(sort) : keys.sort();
let index = 0;
return {
next() {
if (index < keys.length) {
const k = keys[index++];
const value = {};
if (kv) {
value.k =... | [
"function",
"objectIterator",
"(",
"obj",
",",
"sort",
",",
"kv",
"=",
"false",
")",
"{",
"let",
"keys",
"=",
"Object",
".",
"keys",
"(",
"obj",
")",
";",
"keys",
"=",
"typeof",
"sort",
"===",
"'function'",
"?",
"keys",
".",
"sort",
"(",
"sort",
")... | Creates an iterator over objcts.
Objects are not generally iterable, as there is no defined order for an object, and each "element" of an object
actually has two values, unlike any other collection (a key and a property). However, it's tremendously useful to
be able to use at least some transformers with objects as we... | [
"Creates",
"an",
"iterator",
"over",
"objcts",
"."
] | b454f154f7663475670d4802e28e98ade8c468e7 | https://github.com/Barandis/xduce/blob/b454f154f7663475670d4802e28e98ade8c468e7/src/modules/iteration.js#L191-L217 | train |
Barandis/xduce | src/modules/iteration.js | functionIterator | function functionIterator(fn) {
return function* () {
let current;
let index = 0;
for (;;) {
current = fn(index++, current);
if (current === undefined) {
break;
}
yield current;
}
}();
} | javascript | function functionIterator(fn) {
return function* () {
let current;
let index = 0;
for (;;) {
current = fn(index++, current);
if (current === undefined) {
break;
}
yield current;
}
}();
} | [
"function",
"functionIterator",
"(",
"fn",
")",
"{",
"return",
"function",
"*",
"(",
")",
"{",
"let",
"current",
";",
"let",
"index",
"=",
"0",
";",
"for",
"(",
";",
";",
")",
"{",
"current",
"=",
"fn",
"(",
"index",
"++",
",",
"current",
")",
";... | Creates an iterator that runs a function for each `next` value.
The function in question is provided two arguments: the current 0-based index (which starts at `0` and increases by
one for each run) and the return value for the prior calling of the function (which is `undefined` if the function
has not yet been run). T... | [
"Creates",
"an",
"iterator",
"that",
"runs",
"a",
"function",
"for",
"each",
"next",
"value",
"."
] | b454f154f7663475670d4802e28e98ade8c468e7 | https://github.com/Barandis/xduce/blob/b454f154f7663475670d4802e28e98ade8c468e7/src/modules/iteration.js#L238-L251 | train |
Barandis/xduce | src/modules/iteration.js | isKvFormObject | function isKvFormObject(obj) {
const keys = Object.keys(obj);
if (keys.length !== 2) {
return false;
}
return !!~keys.indexOf('k') && !!~keys.indexOf('v');
} | javascript | function isKvFormObject(obj) {
const keys = Object.keys(obj);
if (keys.length !== 2) {
return false;
}
return !!~keys.indexOf('k') && !!~keys.indexOf('v');
} | [
"function",
"isKvFormObject",
"(",
"obj",
")",
"{",
"const",
"keys",
"=",
"Object",
".",
"keys",
"(",
"obj",
")",
";",
"if",
"(",
"keys",
".",
"length",
"!==",
"2",
")",
"{",
"return",
"false",
";",
"}",
"return",
"!",
"!",
"~",
"keys",
".",
"ind... | Determines whether an object is in kv-form. This used by the reducers that must recognize this form and reduce those
elements back into key-value form.
This determination is made by simply checking that the object has exactly two properties and that they are named
`k` and `v`.
@private
@param {object} obj The object... | [
"Determines",
"whether",
"an",
"object",
"is",
"in",
"kv",
"-",
"form",
".",
"This",
"used",
"by",
"the",
"reducers",
"that",
"must",
"recognize",
"this",
"form",
"and",
"reduce",
"those",
"elements",
"back",
"into",
"key",
"-",
"value",
"form",
"."
] | b454f154f7663475670d4802e28e98ade8c468e7 | https://github.com/Barandis/xduce/blob/b454f154f7663475670d4802e28e98ade8c468e7/src/modules/iteration.js#L265-L271 | train |
Barandis/xduce | src/modules/iteration.js | isIterable | function isIterable(obj) {
return isImplemented(obj, 'iterator') || isString(obj) || isArray(obj) || isObject(obj);
} | javascript | function isIterable(obj) {
return isImplemented(obj, 'iterator') || isString(obj) || isArray(obj) || isObject(obj);
} | [
"function",
"isIterable",
"(",
"obj",
")",
"{",
"return",
"isImplemented",
"(",
"obj",
",",
"'iterator'",
")",
"||",
"isString",
"(",
"obj",
")",
"||",
"isArray",
"(",
"obj",
")",
"||",
"isObject",
"(",
"obj",
")",
";",
"}"
] | Determines whether the passed object is iterable, in terms of what 'iterable' means to this library. In other words,
objects and ES5 arrays and strings will return `true`, as will objects with a `next` function. For that reason this
function is only really useful within the library and therefore isn't exported.
@priva... | [
"Determines",
"whether",
"the",
"passed",
"object",
"is",
"iterable",
"in",
"terms",
"of",
"what",
"iterable",
"means",
"to",
"this",
"library",
".",
"In",
"other",
"words",
"objects",
"and",
"ES5",
"arrays",
"and",
"strings",
"will",
"return",
"true",
"as",... | b454f154f7663475670d4802e28e98ade8c468e7 | https://github.com/Barandis/xduce/blob/b454f154f7663475670d4802e28e98ade8c468e7/src/modules/iteration.js#L392-L394 | train |
hillscottc/nostra | dist/sentence_mgr.js | relationship | function relationship(mood) {
var verb = void 0,
talk = void 0;
if (mood === "good") {
verb = "strengthened";
talk = "discussion";
} else {
verb = "strained";
talk = "argument";
}
var familiar_people = _word_library2.default.getWords("familiar_people");
var conversation_topics = _wor... | javascript | function relationship(mood) {
var verb = void 0,
talk = void 0;
if (mood === "good") {
verb = "strengthened";
talk = "discussion";
} else {
verb = "strained";
talk = "argument";
}
var familiar_people = _word_library2.default.getWords("familiar_people");
var conversation_topics = _wor... | [
"function",
"relationship",
"(",
"mood",
")",
"{",
"var",
"verb",
"=",
"void",
"0",
",",
"talk",
"=",
"void",
"0",
";",
"if",
"(",
"mood",
"===",
"\"good\"",
")",
"{",
"verb",
"=",
"\"strengthened\"",
";",
"talk",
"=",
"\"discussion\"",
";",
"}",
"el... | Generate a mood-based sentence about a relationship
@param mood
@returns {*} | [
"Generate",
"a",
"mood",
"-",
"based",
"sentence",
"about",
"a",
"relationship"
] | 1801c8e19f7fab91dd29fea07195789d41624915 | https://github.com/hillscottc/nostra/blob/1801c8e19f7fab91dd29fea07195789d41624915/dist/sentence_mgr.js#L24-L46 | train |
hillscottc/nostra | dist/sentence_mgr.js | datePredict | function datePredict() {
var daysAhead = Math.floor(Math.random() * 5) + 2;
var day = new Date();
day.setDate(day.getDate() + daysAhead);
var monthStr = (0, _dateformat2.default)(day, "mmmm");
var dayStr = (0, _dateformat2.default)(day, "d");
var rnum = Math.floor(Math.random() * 10);
var str = void 0;
... | javascript | function datePredict() {
var daysAhead = Math.floor(Math.random() * 5) + 2;
var day = new Date();
day.setDate(day.getDate() + daysAhead);
var monthStr = (0, _dateformat2.default)(day, "mmmm");
var dayStr = (0, _dateformat2.default)(day, "d");
var rnum = Math.floor(Math.random() * 10);
var str = void 0;
... | [
"function",
"datePredict",
"(",
")",
"{",
"var",
"daysAhead",
"=",
"Math",
".",
"floor",
"(",
"Math",
".",
"random",
"(",
")",
"*",
"5",
")",
"+",
"2",
";",
"var",
"day",
"=",
"new",
"Date",
"(",
")",
";",
"day",
".",
"setDate",
"(",
"day",
"."... | Generate a random prediction sentence containing a date.
@returns {*} | [
"Generate",
"a",
"random",
"prediction",
"sentence",
"containing",
"a",
"date",
"."
] | 1801c8e19f7fab91dd29fea07195789d41624915 | https://github.com/hillscottc/nostra/blob/1801c8e19f7fab91dd29fea07195789d41624915/dist/sentence_mgr.js#L121-L139 | train |
futagoza/efe | index.js | modifyStatsObject | function modifyStatsObject ( stats, path ) {
stats.path = path;
stats.basename = fs.basename(path);
stats.dirname = fs.dirname(path);
stats.extname = fs.extname(path);
return stats;
} | javascript | function modifyStatsObject ( stats, path ) {
stats.path = path;
stats.basename = fs.basename(path);
stats.dirname = fs.dirname(path);
stats.extname = fs.extname(path);
return stats;
} | [
"function",
"modifyStatsObject",
"(",
"stats",
",",
"path",
")",
"{",
"stats",
".",
"path",
"=",
"path",
";",
"stats",
".",
"basename",
"=",
"fs",
".",
"basename",
"(",
"path",
")",
";",
"stats",
".",
"dirname",
"=",
"fs",
".",
"dirname",
"(",
"path"... | Update the `stats` object returned by methods using `fs.Stats`. | [
"Update",
"the",
"stats",
"object",
"returned",
"by",
"methods",
"using",
"fs",
".",
"Stats",
"."
] | bd7b0e73006672a8d7620f32f731d87d793eb57c | https://github.com/futagoza/efe/blob/bd7b0e73006672a8d7620f32f731d87d793eb57c/index.js#L110-L116 | train |
andrepolischuk/ies | index.js | parse | function parse() {
var msie = /MSIE.(\d+)/i.exec(ua);
var rv = /Trident.+rv:(\d+)/i.exec(ua);
var version = msie || rv || undefined;
return version ? +version[1] : version;
} | javascript | function parse() {
var msie = /MSIE.(\d+)/i.exec(ua);
var rv = /Trident.+rv:(\d+)/i.exec(ua);
var version = msie || rv || undefined;
return version ? +version[1] : version;
} | [
"function",
"parse",
"(",
")",
"{",
"var",
"msie",
"=",
"/",
"MSIE.(\\d+)",
"/",
"i",
".",
"exec",
"(",
"ua",
")",
";",
"var",
"rv",
"=",
"/",
"Trident.+rv:(\\d+)",
"/",
"i",
".",
"exec",
"(",
"ua",
")",
";",
"var",
"version",
"=",
"msie",
"||",
... | Get IE major version number
@return {Number}
@api private | [
"Get",
"IE",
"major",
"version",
"number"
] | 2641e787897fd1602e5a0bd8bd4bd8e56418f1bf | https://github.com/andrepolischuk/ies/blob/2641e787897fd1602e5a0bd8bd4bd8e56418f1bf/index.js#L23-L28 | train |
creationix/git-node-platform | fs.js | stat | function stat(path, callback) {
if (!callback) return stat.bind(this, path);
fs.lstat(path, function (err, stat) {
if (err) return callback(err);
var ctime = stat.ctime / 1000;
var cseconds = Math.floor(ctime);
var mtime = stat.mtime / 1000;
var mseconds = Math.floor(mtime);
var mode;
if... | javascript | function stat(path, callback) {
if (!callback) return stat.bind(this, path);
fs.lstat(path, function (err, stat) {
if (err) return callback(err);
var ctime = stat.ctime / 1000;
var cseconds = Math.floor(ctime);
var mtime = stat.mtime / 1000;
var mseconds = Math.floor(mtime);
var mode;
if... | [
"function",
"stat",
"(",
"path",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"callback",
")",
"return",
"stat",
".",
"bind",
"(",
"this",
",",
"path",
")",
";",
"fs",
".",
"lstat",
"(",
"path",
",",
"function",
"(",
"err",
",",
"stat",
")",
"{",
... | Given a path, return a continuable for the stat object. | [
"Given",
"a",
"path",
"return",
"a",
"continuable",
"for",
"the",
"stat",
"object",
"."
] | fa9b0367e3b92b6f4f50d93b0d2d7ba93cb27fb9 | https://github.com/creationix/git-node-platform/blob/fa9b0367e3b92b6f4f50d93b0d2d7ba93cb27fb9/fs.js#L44-L73 | train |
shinuza/captain-core | lib/models/posts.js | find | function find(param) {
var fn
, asInt = Number(param);
fn = isNaN(asInt) ? findBySlug : findById;
fn.apply(null, arguments);
} | javascript | function find(param) {
var fn
, asInt = Number(param);
fn = isNaN(asInt) ? findBySlug : findById;
fn.apply(null, arguments);
} | [
"function",
"find",
"(",
"param",
")",
"{",
"var",
"fn",
",",
"asInt",
"=",
"Number",
"(",
"param",
")",
";",
"fn",
"=",
"isNaN",
"(",
"asInt",
")",
"?",
"findBySlug",
":",
"findById",
";",
"fn",
".",
"apply",
"(",
"null",
",",
"arguments",
")",
... | Smart find, uses findBySlug or findById
@param {*} param | [
"Smart",
"find",
"uses",
"findBySlug",
"or",
"findById"
] | 02f3a404cdfca608e8726bbacc33e32fec484b21 | https://github.com/shinuza/captain-core/blob/02f3a404cdfca608e8726bbacc33e32fec484b21/lib/models/posts.js#L53-L59 | train |
shinuza/captain-core | lib/models/posts.js | update | function update(id, body, cb) {
body.updated_at = new Date();
var q = qb.update(id, body);
db.getClient(function(err, client, done) {
client.query(q[0], q[1], function(err, r) {
var result = r && r.rows[0];
if(!err && !result) { err = new exceptions.NotFound(); }
if(err) {
cb(err);
... | javascript | function update(id, body, cb) {
body.updated_at = new Date();
var q = qb.update(id, body);
db.getClient(function(err, client, done) {
client.query(q[0], q[1], function(err, r) {
var result = r && r.rows[0];
if(!err && !result) { err = new exceptions.NotFound(); }
if(err) {
cb(err);
... | [
"function",
"update",
"(",
"id",
",",
"body",
",",
"cb",
")",
"{",
"body",
".",
"updated_at",
"=",
"new",
"Date",
"(",
")",
";",
"var",
"q",
"=",
"qb",
".",
"update",
"(",
"id",
",",
"body",
")",
";",
"db",
".",
"getClient",
"(",
"function",
"(... | Updates post with `id`
`cb` is passed the updated post or exceptions.NotFound
@param {Number} id
@param {Object} body
@param {Function} cb | [
"Updates",
"post",
"with",
"id"
] | 02f3a404cdfca608e8726bbacc33e32fec484b21 | https://github.com/shinuza/captain-core/blob/02f3a404cdfca608e8726bbacc33e32fec484b21/lib/models/posts.js#L165-L182 | train |
shinuza/captain-core | lib/models/posts.js | archive | function archive(cb) {
db.getClient(function(err, client, done) {
client.query(qb.select() + ' WHERE published = true', function(err, r) {
if(err) {
cb(err);
done(err);
} else {
cb(null, r.rows);
done();
}
});
});
} | javascript | function archive(cb) {
db.getClient(function(err, client, done) {
client.query(qb.select() + ' WHERE published = true', function(err, r) {
if(err) {
cb(err);
done(err);
} else {
cb(null, r.rows);
done();
}
});
});
} | [
"function",
"archive",
"(",
"cb",
")",
"{",
"db",
".",
"getClient",
"(",
"function",
"(",
"err",
",",
"client",
",",
"done",
")",
"{",
"client",
".",
"query",
"(",
"qb",
".",
"select",
"(",
")",
"+",
"' WHERE published = true'",
",",
"function",
"(",
... | Returns all published posts without pagination support
@param {Function} cb | [
"Returns",
"all",
"published",
"posts",
"without",
"pagination",
"support"
] | 02f3a404cdfca608e8726bbacc33e32fec484b21 | https://github.com/shinuza/captain-core/blob/02f3a404cdfca608e8726bbacc33e32fec484b21/lib/models/posts.js#L341-L353 | train |
ronanyeah/ooft | src/methods.js | getTargetSize | function getTargetSize(size, buffer) {
size *= 1000000; // Converting to MB to B.
// 10% is default.
buffer = 1 + (buffer ? buffer / 100 : 0.1);
return Math.round(size * buffer);
} | javascript | function getTargetSize(size, buffer) {
size *= 1000000; // Converting to MB to B.
// 10% is default.
buffer = 1 + (buffer ? buffer / 100 : 0.1);
return Math.round(size * buffer);
} | [
"function",
"getTargetSize",
"(",
"size",
",",
"buffer",
")",
"{",
"size",
"*=",
"1000000",
";",
"// Converting to MB to B.",
"// 10% is default.",
"buffer",
"=",
"1",
"+",
"(",
"buffer",
"?",
"buffer",
"/",
"100",
":",
"0.1",
")",
";",
"return",
"Math",
"... | Gets the desired file size for the resize.
@param {number} size Desired size in MB.
@param {number} buffer Range of tolerance for target size, 0-100.
@returns {number} Desired file size in bytes. | [
"Gets",
"the",
"desired",
"file",
"size",
"for",
"the",
"resize",
"."
] | a86d9db656a7ebd84915ec4e0d5f474a4b87031b | https://github.com/ronanyeah/ooft/blob/a86d9db656a7ebd84915ec4e0d5f474a4b87031b/src/methods.js#L16-L23 | train |
ronanyeah/ooft | src/methods.js | shrinkImage | function shrinkImage(base64Image, targetSize) {
return new Promise( (resolve, reject) => {
let canvas = document.createElement('canvas');
let image = new Image();
image.onload = _ => {
canvas.height = image.naturalHeight;
canvas.width = image.naturalWidth;
canvas.getContext('2d'... | javascript | function shrinkImage(base64Image, targetSize) {
return new Promise( (resolve, reject) => {
let canvas = document.createElement('canvas');
let image = new Image();
image.onload = _ => {
canvas.height = image.naturalHeight;
canvas.width = image.naturalWidth;
canvas.getContext('2d'... | [
"function",
"shrinkImage",
"(",
"base64Image",
",",
"targetSize",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"let",
"canvas",
"=",
"document",
".",
"createElement",
"(",
"'canvas'",
")",
";",
"let",
"image",
... | Rewrites base64 image using canvas until it is down to desired file size.
@param {string} base64Image Base64 image string.
@param {number} targetSize Desired file size in bytes.
@returns {string} Base64 string of resized image. | [
"Rewrites",
"base64",
"image",
"using",
"canvas",
"until",
"it",
"is",
"down",
"to",
"desired",
"file",
"size",
"."
] | a86d9db656a7ebd84915ec4e0d5f474a4b87031b | https://github.com/ronanyeah/ooft/blob/a86d9db656a7ebd84915ec4e0d5f474a4b87031b/src/methods.js#L31-L60 | train |
ronanyeah/ooft | src/methods.js | base64ToBlob | function base64ToBlob(base64Image, contentType) {
// http://stackoverflow.com/questions/16245767/creating-a-blob-from-a-base64-string-in-javascript
// Remove leading 'data:image/jpeg;base64,' or 'data:image/png;base64,'
base64Image = base64Image.split(',')[1];
let byteCharacters = atob(base64Image);
// htt... | javascript | function base64ToBlob(base64Image, contentType) {
// http://stackoverflow.com/questions/16245767/creating-a-blob-from-a-base64-string-in-javascript
// Remove leading 'data:image/jpeg;base64,' or 'data:image/png;base64,'
base64Image = base64Image.split(',')[1];
let byteCharacters = atob(base64Image);
// htt... | [
"function",
"base64ToBlob",
"(",
"base64Image",
",",
"contentType",
")",
"{",
"// http://stackoverflow.com/questions/16245767/creating-a-blob-from-a-base64-string-in-javascript",
"// Remove leading 'data:image/jpeg;base64,' or 'data:image/png;base64,'",
"base64Image",
"=",
"base64Image",
"... | Converts Base64 image into a blob file.
@param {string} base64Image Base64 image string.
@param {string} contentType 'image/jpg' or 'image/png'.
@returns {file} Image file as a blob. | [
"Converts",
"Base64",
"image",
"into",
"a",
"blob",
"file",
"."
] | a86d9db656a7ebd84915ec4e0d5f474a4b87031b | https://github.com/ronanyeah/ooft/blob/a86d9db656a7ebd84915ec4e0d5f474a4b87031b/src/methods.js#L68-L87 | train |
ronanyeah/ooft | src/methods.js | convertImageToBase64 | function convertImageToBase64(image) {
let fileReader = new FileReader();
return new Promise( (resolve, reject) => {
fileReader.onload = fileLoadedEvent => resolve(fileLoadedEvent.target.result);
fileReader.readAsDataURL(image);
});
} | javascript | function convertImageToBase64(image) {
let fileReader = new FileReader();
return new Promise( (resolve, reject) => {
fileReader.onload = fileLoadedEvent => resolve(fileLoadedEvent.target.result);
fileReader.readAsDataURL(image);
});
} | [
"function",
"convertImageToBase64",
"(",
"image",
")",
"{",
"let",
"fileReader",
"=",
"new",
"FileReader",
"(",
")",
";",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"fileReader",
".",
"onload",
"=",
"fileLoadedEvent",
"... | Gets image height and width in pixels.
@param {file} image Image file as a blob.
@returns {string} Base64 image string. | [
"Gets",
"image",
"height",
"and",
"width",
"in",
"pixels",
"."
] | a86d9db656a7ebd84915ec4e0d5f474a4b87031b | https://github.com/ronanyeah/ooft/blob/a86d9db656a7ebd84915ec4e0d5f474a4b87031b/src/methods.js#L94-L104 | train |
wigy/chronicles_of_grunt | lib/server.js | handler | function handler(req, res) {
var path = cog.getConfig('options.api_data');
var urlRegex = cog.getConfig('options.api_url_regex');
var url = req.url.replace(/^\//, '').replace(/\/$/, '');
console.log(req.method + ' ' + req.url);
// Find the JSON-data file and serve it, if URL p... | javascript | function handler(req, res) {
var path = cog.getConfig('options.api_data');
var urlRegex = cog.getConfig('options.api_url_regex');
var url = req.url.replace(/^\//, '').replace(/\/$/, '');
console.log(req.method + ' ' + req.url);
// Find the JSON-data file and serve it, if URL p... | [
"function",
"handler",
"(",
"req",
",",
"res",
")",
"{",
"var",
"path",
"=",
"cog",
".",
"getConfig",
"(",
"'options.api_data'",
")",
";",
"var",
"urlRegex",
"=",
"cog",
".",
"getConfig",
"(",
"'options.api_url_regex'",
")",
";",
"var",
"url",
"=",
"req"... | This is the development server used by CoG. | [
"This",
"is",
"the",
"development",
"server",
"used",
"by",
"CoG",
"."
] | c5f089a6f391a0ca625fcb81ef51907713471bb3 | https://github.com/wigy/chronicles_of_grunt/blob/c5f089a6f391a0ca625fcb81ef51907713471bb3/lib/server.js#L28-L50 | train |
MCluck90/clairvoyant | src/reporter.js | function(name, type, filename, code) {
this.name = name;
this.type = type;
this.filename = filename;
this.code = code;
} | javascript | function(name, type, filename, code) {
this.name = name;
this.type = type;
this.filename = filename;
this.code = code;
} | [
"function",
"(",
"name",
",",
"type",
",",
"filename",
",",
"code",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"type",
"=",
"type",
";",
"this",
".",
"filename",
"=",
"filename",
";",
"this",
".",
"code",
"=",
"code",
";",
"}"
... | Represents a single System
@param {string} name - Name of the System
@param {string} type - System, RenderSystem, or BehaviorSystem
@param {string} filename - File path
@param {string} code - Code generated for the System
@constructor | [
"Represents",
"a",
"single",
"System"
] | 4c347499c5fe0f561a53e180d141884b1fa8c21b | https://github.com/MCluck90/clairvoyant/blob/4c347499c5fe0f561a53e180d141884b1fa8c21b/src/reporter.js#L107-L112 | train | |
lukin0110/vorto | vorto.js | vorto | function vorto() {
var length = arguments.length;
var format, options, callback;
if (typeof arguments[length-1] !== 'function') {
throw new Error('The last argument must be a callback function: function(err, version){...}');
} else {
callback = arguments[length-1];
}
if (length... | javascript | function vorto() {
var length = arguments.length;
var format, options, callback;
if (typeof arguments[length-1] !== 'function') {
throw new Error('The last argument must be a callback function: function(err, version){...}');
} else {
callback = arguments[length-1];
}
if (length... | [
"function",
"vorto",
"(",
")",
"{",
"var",
"length",
"=",
"arguments",
".",
"length",
";",
"var",
"format",
",",
"options",
",",
"callback",
";",
"if",
"(",
"typeof",
"arguments",
"[",
"length",
"-",
"1",
"]",
"!==",
"'function'",
")",
"{",
"throw",
... | Init function that might take 3 parameters. It checks the input parameters and will throw errors if they're not
valid or wrongly ordered.
The callback is always required.
vorto([format][, options], callback); | [
"Init",
"function",
"that",
"might",
"take",
"3",
"parameters",
".",
"It",
"checks",
"the",
"input",
"parameters",
"and",
"will",
"throw",
"errors",
"if",
"they",
"re",
"not",
"valid",
"or",
"wrongly",
"ordered",
"."
] | a25ab42e38a7e530ece3f9d0b33d8489f0acc1e9 | https://github.com/lukin0110/vorto/blob/a25ab42e38a7e530ece3f9d0b33d8489f0acc1e9/vorto.js#L18-L70 | train |
lukin0110/vorto | vorto.js | packageVersion | function packageVersion(repo) {
var location = repo ? path.join(repo, 'package.json') : './package.json';
var pack = require(location);
return pack['version'];
} | javascript | function packageVersion(repo) {
var location = repo ? path.join(repo, 'package.json') : './package.json';
var pack = require(location);
return pack['version'];
} | [
"function",
"packageVersion",
"(",
"repo",
")",
"{",
"var",
"location",
"=",
"repo",
"?",
"path",
".",
"join",
"(",
"repo",
",",
"'package.json'",
")",
":",
"'./package.json'",
";",
"var",
"pack",
"=",
"require",
"(",
"location",
")",
";",
"return",
"pac... | Load the version from package.json
@param {string} repo | [
"Load",
"the",
"version",
"from",
"package",
".",
"json"
] | a25ab42e38a7e530ece3f9d0b33d8489f0acc1e9 | https://github.com/lukin0110/vorto/blob/a25ab42e38a7e530ece3f9d0b33d8489f0acc1e9/vorto.js#L90-L94 | train |
rranauro/boxspringjs | boxspring.js | function(name, value, iType) {
var type = iType
, coded
, attach = {
'_attachments': this.get('_attachments') || {}
}
, types = {
"html": {"content_type":"text\/html"},
"text": {"content_type":"text\/plain"},
"xml": {"content_type":"text\/plain"},
"jpeg": {"content_type":"image\/jpeg"... | javascript | function(name, value, iType) {
var type = iType
, coded
, attach = {
'_attachments': this.get('_attachments') || {}
}
, types = {
"html": {"content_type":"text\/html"},
"text": {"content_type":"text\/plain"},
"xml": {"content_type":"text\/plain"},
"jpeg": {"content_type":"image\/jpeg"... | [
"function",
"(",
"name",
",",
"value",
",",
"iType",
")",
"{",
"var",
"type",
"=",
"iType",
",",
"coded",
",",
"attach",
"=",
"{",
"'_attachments'",
":",
"this",
".",
"get",
"(",
"'_attachments'",
")",
"||",
"{",
"}",
"}",
",",
"types",
"=",
"{",
... | configure the URL for an attachment | [
"configure",
"the",
"URL",
"for",
"an",
"attachment"
] | 43fd13ae45ba5b16ba9144084b96748a1cd8c0ea | https://github.com/rranauro/boxspringjs/blob/43fd13ae45ba5b16ba9144084b96748a1cd8c0ea/boxspring.js#L649-L685 | train | |
observing/eventreactor | lib/index.js | EventReactor | function EventReactor(options, proto) {
// allow initialization without a new prefix
if (!(this instanceof EventReactor)) return new EventReactor(options, proto);
options = options || {};
this.restore = {};
// don't attach the extra event reactor methods, we are going to apply them
// manually... | javascript | function EventReactor(options, proto) {
// allow initialization without a new prefix
if (!(this instanceof EventReactor)) return new EventReactor(options, proto);
options = options || {};
this.restore = {};
// don't attach the extra event reactor methods, we are going to apply them
// manually... | [
"function",
"EventReactor",
"(",
"options",
",",
"proto",
")",
"{",
"// allow initialization without a new prefix",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"EventReactor",
")",
")",
"return",
"new",
"EventReactor",
"(",
"options",
",",
"proto",
")",
";",
"opt... | The EventReactor plugin that allows you to extend update the EventEmitter
prototype.
@constructor
@param {Object} options
@param {Prototype} proto prototype that needs to be extended
@api public | [
"The",
"EventReactor",
"plugin",
"that",
"allows",
"you",
"to",
"extend",
"update",
"the",
"EventEmitter",
"prototype",
"."
] | 1609083bf56c5ac77809997cd29882910dc2aedf | https://github.com/observing/eventreactor/blob/1609083bf56c5ac77809997cd29882910dc2aedf/lib/index.js#L49-L72 | train |
observing/eventreactor | lib/index.js | every | function every() {
for (
var args = slice.call(arguments, 0)
, callback = args.pop()
, length = args.length
, i = 0;
i < length;
this.on(args[i++], callback)
){}
return this;
} | javascript | function every() {
for (
var args = slice.call(arguments, 0)
, callback = args.pop()
, length = args.length
, i = 0;
i < length;
this.on(args[i++], callback)
){}
return this;
} | [
"function",
"every",
"(",
")",
"{",
"for",
"(",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"0",
")",
",",
"callback",
"=",
"args",
".",
"pop",
"(",
")",
",",
"length",
"=",
"args",
".",
"length",
",",
"i",
"=",
"0",
";",
... | Apply the same callback to every given event.
@param {String} .. events
@param {Function} callback last argument is always the callback
@api private | [
"Apply",
"the",
"same",
"callback",
"to",
"every",
"given",
"event",
"."
] | 1609083bf56c5ac77809997cd29882910dc2aedf | https://github.com/observing/eventreactor/blob/1609083bf56c5ac77809997cd29882910dc2aedf/lib/index.js#L172-L184 | train |
observing/eventreactor | lib/index.js | handle | function handle() {
for (
var i = 0
, length = args.length;
i < length;
self.removeListener(args[i++], handle)
){}
// call the function as last as the function might be calling on of
// events that where in our either queue, so ... | javascript | function handle() {
for (
var i = 0
, length = args.length;
i < length;
self.removeListener(args[i++], handle)
){}
// call the function as last as the function might be calling on of
// events that where in our either queue, so ... | [
"function",
"handle",
"(",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"length",
"=",
"args",
".",
"length",
";",
"i",
"<",
"length",
";",
"self",
".",
"removeListener",
"(",
"args",
"[",
"i",
"++",
"]",
",",
"handle",
")",
")",
"{",
"}",
... | Handler for all the calls so every remaining event listener is removed
removed properly before we call the callback.
@api private | [
"Handler",
"for",
"all",
"the",
"calls",
"so",
"every",
"remaining",
"event",
"listener",
"is",
"removed",
"removed",
"properly",
"before",
"we",
"call",
"the",
"callback",
"."
] | 1609083bf56c5ac77809997cd29882910dc2aedf | https://github.com/observing/eventreactor/blob/1609083bf56c5ac77809997cd29882910dc2aedf/lib/index.js#L201-L214 | train |
observing/eventreactor | lib/index.js | handle | function handle() {
self.removeListener(event, reset);
callback.apply(self, [event].concat(args));
} | javascript | function handle() {
self.removeListener(event, reset);
callback.apply(self, [event].concat(args));
} | [
"function",
"handle",
"(",
")",
"{",
"self",
".",
"removeListener",
"(",
"event",
",",
"reset",
")",
";",
"callback",
".",
"apply",
"(",
"self",
",",
"[",
"event",
"]",
".",
"concat",
"(",
"args",
")",
")",
";",
"}"
] | Handle the idle callback as the setTimeout got triggerd.
@api private | [
"Handle",
"the",
"idle",
"callback",
"as",
"the",
"setTimeout",
"got",
"triggerd",
"."
] | 1609083bf56c5ac77809997cd29882910dc2aedf | https://github.com/observing/eventreactor/blob/1609083bf56c5ac77809997cd29882910dc2aedf/lib/index.js#L317-L320 | train |
observing/eventreactor | lib/index.js | reset | function reset() {
clearTimeout(timer);
self.idle.apply(self, [event, callback, timeout].concat(args));
} | javascript | function reset() {
clearTimeout(timer);
self.idle.apply(self, [event, callback, timeout].concat(args));
} | [
"function",
"reset",
"(",
")",
"{",
"clearTimeout",
"(",
"timer",
")",
";",
"self",
".",
"idle",
".",
"apply",
"(",
"self",
",",
"[",
"event",
",",
"callback",
",",
"timeout",
"]",
".",
"concat",
"(",
"args",
")",
")",
";",
"}"
] | Reset the timeout timer again as the event was triggerd.
@api private | [
"Reset",
"the",
"timeout",
"timer",
"again",
"as",
"the",
"event",
"was",
"triggerd",
"."
] | 1609083bf56c5ac77809997cd29882910dc2aedf | https://github.com/observing/eventreactor/blob/1609083bf56c5ac77809997cd29882910dc2aedf/lib/index.js#L327-L331 | train |
ugate/pulses | index.js | listen | function listen(pw, type, listener, fnm, rf, cbtype, passes) {
var fn = function pulseListener(flow, artery, pulse) {
if (!rf || !(artery instanceof cat.Artery) || !(pulse instanceof cat.Pulse) || flow instanceof Error)
return arguments.length ? fn._callback.apply(pw, Array.prototype.slice.call(... | javascript | function listen(pw, type, listener, fnm, rf, cbtype, passes) {
var fn = function pulseListener(flow, artery, pulse) {
if (!rf || !(artery instanceof cat.Artery) || !(pulse instanceof cat.Pulse) || flow instanceof Error)
return arguments.length ? fn._callback.apply(pw, Array.prototype.slice.call(... | [
"function",
"listen",
"(",
"pw",
",",
"type",
",",
"listener",
",",
"fnm",
",",
"rf",
",",
"cbtype",
",",
"passes",
")",
"{",
"var",
"fn",
"=",
"function",
"pulseListener",
"(",
"flow",
",",
"artery",
",",
"pulse",
")",
"{",
"if",
"(",
"!",
"rf",
... | Listens for incoming events using event emitter's add listener function, but with optional error handling and pulse event only capabilities
@private
@arg {PulseEmitter} pw the pulse emitter
@arg {String} type the event type
@arg {function} listener the function to execute when the event type is emitted
@arg {String} [... | [
"Listens",
"for",
"incoming",
"events",
"using",
"event",
"emitter",
"s",
"add",
"listener",
"function",
"but",
"with",
"optional",
"error",
"handling",
"and",
"pulse",
"event",
"only",
"capabilities"
] | 214b186e1b72bed9c99c0a7903c70de4eca3c259 | https://github.com/ugate/pulses/blob/214b186e1b72bed9c99c0a7903c70de4eca3c259/index.js#L196-L225 | train |
mhelgeson/b9 | src/connect/index.js | complete | function complete ( err, msg ){
b9.off('hello', success ); // cleanup
// optional callback, error-first...
if ( typeof callback == 'function' ){
callback( err, msg );
}
} | javascript | function complete ( err, msg ){
b9.off('hello', success ); // cleanup
// optional callback, error-first...
if ( typeof callback == 'function' ){
callback( err, msg );
}
} | [
"function",
"complete",
"(",
"err",
",",
"msg",
")",
"{",
"b9",
".",
"off",
"(",
"'hello'",
",",
"success",
")",
";",
"// cleanup",
"// optional callback, error-first...",
"if",
"(",
"typeof",
"callback",
"==",
"'function'",
")",
"{",
"callback",
"(",
"err",... | handle complete callback... | [
"handle",
"complete",
"callback",
"..."
] | 5f7ad9ac7c3fa586b06f6460b70a42c50b34e6f1 | https://github.com/mhelgeson/b9/blob/5f7ad9ac7c3fa586b06f6460b70a42c50b34e6f1/src/connect/index.js#L43-L49 | train |
mhelgeson/b9 | src/connect/index.js | receive | function receive ( str ){
ping(); // clear/schedule next ping
var msg = typeof str === 'string' ? JSON.parse( str ) : str;
b9.emit('rtm.read', msg, replyTo( null ) );
// acknowledge that a pending message was sent successfully
if ( msg.reply_to ){
delete pending[ msg.reply_to ];
}
else... | javascript | function receive ( str ){
ping(); // clear/schedule next ping
var msg = typeof str === 'string' ? JSON.parse( str ) : str;
b9.emit('rtm.read', msg, replyTo( null ) );
// acknowledge that a pending message was sent successfully
if ( msg.reply_to ){
delete pending[ msg.reply_to ];
}
else... | [
"function",
"receive",
"(",
"str",
")",
"{",
"ping",
"(",
")",
";",
"// clear/schedule next ping",
"var",
"msg",
"=",
"typeof",
"str",
"===",
"'string'",
"?",
"JSON",
".",
"parse",
"(",
"str",
")",
":",
"str",
";",
"b9",
".",
"emit",
"(",
"'rtm.read'",... | handle a websocket message
@private method | [
"handle",
"a",
"websocket",
"message"
] | 5f7ad9ac7c3fa586b06f6460b70a42c50b34e6f1 | https://github.com/mhelgeson/b9/blob/5f7ad9ac7c3fa586b06f6460b70a42c50b34e6f1/src/connect/index.js#L115-L126 | train |
mhelgeson/b9 | src/connect/index.js | ping | function ping (){
clearTimeout( ping.timer );
ping.timer = setTimeout(function(){
b9.send({ type: 'ping', time: Date.now() });
}, b9._interval );
} | javascript | function ping (){
clearTimeout( ping.timer );
ping.timer = setTimeout(function(){
b9.send({ type: 'ping', time: Date.now() });
}, b9._interval );
} | [
"function",
"ping",
"(",
")",
"{",
"clearTimeout",
"(",
"ping",
".",
"timer",
")",
";",
"ping",
".",
"timer",
"=",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"b9",
".",
"send",
"(",
"{",
"type",
":",
"'ping'",
",",
"time",
":",
"Date",
".",
"n... | keep the connection alive
@private method | [
"keep",
"the",
"connection",
"alive"
] | 5f7ad9ac7c3fa586b06f6460b70a42c50b34e6f1 | https://github.com/mhelgeson/b9/blob/5f7ad9ac7c3fa586b06f6460b70a42c50b34e6f1/src/connect/index.js#L142-L147 | train |
BladeRunnerJS/jstd-mocha | src/asserts.js | assertEqualsDelta | function assertEqualsDelta(msg, expected, actual, epsilon) {
var args = this.argsWithOptionalMsg_(arguments, 4);
jstestdriver.assertCount++;
msg = args[0];
expected = args[1];
actual = args[2];
epsilon = args[3];
if (!compareDelta_(expected, actual, epsilon)) {
this.fail(msg + 'expected ' + epsilon + ' within... | javascript | function assertEqualsDelta(msg, expected, actual, epsilon) {
var args = this.argsWithOptionalMsg_(arguments, 4);
jstestdriver.assertCount++;
msg = args[0];
expected = args[1];
actual = args[2];
epsilon = args[3];
if (!compareDelta_(expected, actual, epsilon)) {
this.fail(msg + 'expected ' + epsilon + ' within... | [
"function",
"assertEqualsDelta",
"(",
"msg",
",",
"expected",
",",
"actual",
",",
"epsilon",
")",
"{",
"var",
"args",
"=",
"this",
".",
"argsWithOptionalMsg_",
"(",
"arguments",
",",
"4",
")",
";",
"jstestdriver",
".",
"assertCount",
"++",
";",
"msg",
"=",... | Asserts that two doubles, or the elements of two arrays of doubles,
are equal to within a positive delta. | [
"Asserts",
"that",
"two",
"doubles",
"or",
"the",
"elements",
"of",
"two",
"arrays",
"of",
"doubles",
"are",
"equal",
"to",
"within",
"a",
"positive",
"delta",
"."
] | ac5f524763f644873dfa22d920e9780e3d73c737 | https://github.com/BladeRunnerJS/jstd-mocha/blob/ac5f524763f644873dfa22d920e9780e3d73c737/src/asserts.js#L568-L582 | train |
waitingsong/node-rxwalker | rollup.config.js | parseName | function parseName(name) {
if (name) {
const arr = name.split('.')
const len = arr.length
if (len > 2) {
return arr.slice(0, -1).join('.')
}
else if (len === 2 || len === 1) {
return arr[0]
}
}
return name
} | javascript | function parseName(name) {
if (name) {
const arr = name.split('.')
const len = arr.length
if (len > 2) {
return arr.slice(0, -1).join('.')
}
else if (len === 2 || len === 1) {
return arr[0]
}
}
return name
} | [
"function",
"parseName",
"(",
"name",
")",
"{",
"if",
"(",
"name",
")",
"{",
"const",
"arr",
"=",
"name",
".",
"split",
"(",
"'.'",
")",
"const",
"len",
"=",
"arr",
".",
"length",
"if",
"(",
"len",
">",
"2",
")",
"{",
"return",
"arr",
".",
"sli... | remove pkg.name extension if exists | [
"remove",
"pkg",
".",
"name",
"extension",
"if",
"exists"
] | b08dae4940329f98229dd38e60da54b7426436ab | https://github.com/waitingsong/node-rxwalker/blob/b08dae4940329f98229dd38e60da54b7426436ab/rollup.config.js#L165-L178 | train |
altshift/altshift | lib/altshift/core/class.js | function (object) {
var methodName;
methodName = this.test(object, true);
if (methodName !== true) {
throw new exports.NotImplementedError({
code: 'interface',
message: 'Object %(object) does not implement %(interface)#%(method)()',
/... | javascript | function (object) {
var methodName;
methodName = this.test(object, true);
if (methodName !== true) {
throw new exports.NotImplementedError({
code: 'interface',
message: 'Object %(object) does not implement %(interface)#%(method)()',
/... | [
"function",
"(",
"object",
")",
"{",
"var",
"methodName",
";",
"methodName",
"=",
"this",
".",
"test",
"(",
"object",
",",
"true",
")",
";",
"if",
"(",
"methodName",
"!==",
"true",
")",
"{",
"throw",
"new",
"exports",
".",
"NotImplementedError",
"(",
"... | Throw error if object does not have all methods
@param {Object} object
@return this | [
"Throw",
"error",
"if",
"object",
"does",
"not",
"have",
"all",
"methods"
] | 5c051157e6f558636c8e12081b6707caa66249de | https://github.com/altshift/altshift/blob/5c051157e6f558636c8e12081b6707caa66249de/lib/altshift/core/class.js#L118-L134 | train | |
altshift/altshift | lib/altshift/core/class.js | function (object, returnName) {
var methodName;
for (methodName in this.methods) {
if (!(object[methodName] instanceof Function)) {
return returnName ? methodName : false;
}
}
return true;
} | javascript | function (object, returnName) {
var methodName;
for (methodName in this.methods) {
if (!(object[methodName] instanceof Function)) {
return returnName ? methodName : false;
}
}
return true;
} | [
"function",
"(",
"object",
",",
"returnName",
")",
"{",
"var",
"methodName",
";",
"for",
"(",
"methodName",
"in",
"this",
".",
"methods",
")",
"{",
"if",
"(",
"!",
"(",
"object",
"[",
"methodName",
"]",
"instanceof",
"Function",
")",
")",
"{",
"return"... | Return false or the missing method name in object if method is missing in object
@param {Object} object
@param {boolean} returnName
@return {boolean|string} | [
"Return",
"false",
"or",
"the",
"missing",
"method",
"name",
"in",
"object",
"if",
"method",
"is",
"missing",
"in",
"object"
] | 5c051157e6f558636c8e12081b6707caa66249de | https://github.com/altshift/altshift/blob/5c051157e6f558636c8e12081b6707caa66249de/lib/altshift/core/class.js#L143-L151 | train | |
altshift/altshift | lib/altshift/core/class.js | function (_module) {
if (! this.name) {
throw new exports.ValueError({message: 'name is empty'});
}
var _exports = _module.exports || _module;
_exports[this.name] = this;
return this;
} | javascript | function (_module) {
if (! this.name) {
throw new exports.ValueError({message: 'name is empty'});
}
var _exports = _module.exports || _module;
_exports[this.name] = this;
return this;
} | [
"function",
"(",
"_module",
")",
"{",
"if",
"(",
"!",
"this",
".",
"name",
")",
"{",
"throw",
"new",
"exports",
".",
"ValueError",
"(",
"{",
"message",
":",
"'name is empty'",
"}",
")",
";",
"}",
"var",
"_exports",
"=",
"_module",
".",
"exports",
"||... | Export this interface into _exports
@return this | [
"Export",
"this",
"interface",
"into",
"_exports"
] | 5c051157e6f558636c8e12081b6707caa66249de | https://github.com/altshift/altshift/blob/5c051157e6f558636c8e12081b6707caa66249de/lib/altshift/core/class.js#L158-L165 | 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.