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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
pageobjectmodel/pom | src/emitter.js | bubbleEvent | function bubbleEvent(eventName, toEmitter) {
this.on(eventName, (event) => {
toEmitter.emit(eventName, event.data, event);
});
} | javascript | function bubbleEvent(eventName, toEmitter) {
this.on(eventName, (event) => {
toEmitter.emit(eventName, event.data, event);
});
} | [
"function",
"bubbleEvent",
"(",
"eventName",
",",
"toEmitter",
")",
"{",
"this",
".",
"on",
"(",
"eventName",
",",
"(",
"event",
")",
"=>",
"{",
"toEmitter",
".",
"emit",
"(",
"eventName",
",",
"event",
".",
"data",
",",
"event",
")",
";",
"}",
")",
... | Bubbles event to other emitter
@param {string} eventName
@param {object} toEmitter | [
"Bubbles",
"event",
"to",
"other",
"emitter"
] | 75c566244e0520c3ca260dda261df3f4a92d8335 | https://github.com/pageobjectmodel/pom/blob/75c566244e0520c3ca260dda261df3f4a92d8335/src/emitter.js#L192-L196 | train |
pageobjectmodel/pom | src/emitter.js | getListeners | function getListeners(eventName, handler, context, args) {
if (!this.__listeners || !this.__listeners[eventName]) {
return null;
}
return this.__listeners[eventName]
.map((config) => {
if (handler !== undefined && config.fn !== handler) {
return false;
... | javascript | function getListeners(eventName, handler, context, args) {
if (!this.__listeners || !this.__listeners[eventName]) {
return null;
}
return this.__listeners[eventName]
.map((config) => {
if (handler !== undefined && config.fn !== handler) {
return false;
... | [
"function",
"getListeners",
"(",
"eventName",
",",
"handler",
",",
"context",
",",
"args",
")",
"{",
"if",
"(",
"!",
"this",
".",
"__listeners",
"||",
"!",
"this",
".",
"__listeners",
"[",
"eventName",
"]",
")",
"{",
"return",
"null",
";",
"}",
"return... | Gets all listeners that match criteria
@param {string} eventName required
@param {function} handler if defined will be used for match
@param {object} context if defined will be used for match
@param {array} args if defined will be used for match
@returns {array<EventConfig>|null} | [
"Gets",
"all",
"listeners",
"that",
"match",
"criteria"
] | 75c566244e0520c3ca260dda261df3f4a92d8335 | https://github.com/pageobjectmodel/pom/blob/75c566244e0520c3ca260dda261df3f4a92d8335/src/emitter.js#L206-L225 | train |
OpenSmartEnvironment/ose | lib/entry/index.js | init | function init(shard, eid) { // {{{2
/**
* Entry constructor
*
* @param shard {Object} Entry owner shard instance
* @param eid {Number|String} Entry id
*
* @method constructor
*/
O.inherited(this)();
this.setMaxListeners(Consts.coreListeners);
this.subjectState = this.SUBJECT_STATE.INIT;
this.shard =... | javascript | function init(shard, eid) { // {{{2
/**
* Entry constructor
*
* @param shard {Object} Entry owner shard instance
* @param eid {Number|String} Entry id
*
* @method constructor
*/
O.inherited(this)();
this.setMaxListeners(Consts.coreListeners);
this.subjectState = this.SUBJECT_STATE.INIT;
this.shard =... | [
"function",
"init",
"(",
"shard",
",",
"eid",
")",
"{",
"// {{{2",
"/**\n * Entry constructor\n *\n * @param shard {Object} Entry owner shard instance\n * @param eid {Number|String} Entry id\n *\n * @method constructor\n */",
"O",
".",
"inherited",
"(",
"this",
")",
"(",
")",
";"... | slaves {{{2
Contains all response sockets of slave entries
@property slaves
@type Object
@internal
Public {{{1 | [
"slaves",
"{{{",
"2",
"Contains",
"all",
"response",
"sockets",
"of",
"slave",
"entries"
] | 2ab051d9db6e77341c40abb9cbdae6ce586917e0 | https://github.com/OpenSmartEnvironment/ose/blob/2ab051d9db6e77341c40abb9cbdae6ce586917e0/lib/entry/index.js#L134-L173 | train |
kaelzhang/node-trait | index.js | function(key) {
if (arguments.length === 0) {
// reset all values, including non-enumerable and readonly properties
this.key_list.forEach(function(key) {
this._reset(key);
}, this);
} else {
this._reset(key);
}
} | javascript | function(key) {
if (arguments.length === 0) {
// reset all values, including non-enumerable and readonly properties
this.key_list.forEach(function(key) {
this._reset(key);
}, this);
} else {
this._reset(key);
}
} | [
"function",
"(",
"key",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"===",
"0",
")",
"{",
"// reset all values, including non-enumerable and readonly properties",
"this",
".",
"key_list",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"this",
".",
... | Reset to default value. Run this method will execute setup methods | [
"Reset",
"to",
"default",
"value",
".",
"Run",
"this",
"method",
"will",
"execute",
"setup",
"methods"
] | cd78e902baedbd16728518ba5be2fbcc48ca564f | https://github.com/kaelzhang/node-trait/blob/cd78e902baedbd16728518ba5be2fbcc48ca564f/index.js#L106-L116 | train | |
kaelzhang/node-trait | index.js | function(key) {
var attr = this.__attrs[key];
if (!attr) {
return;
}
var value = attr.value = attr._origin;
var setup = attr.type.setup;
if (setup) {
setup.call(this.host, value, key, this);
}
} | javascript | function(key) {
var attr = this.__attrs[key];
if (!attr) {
return;
}
var value = attr.value = attr._origin;
var setup = attr.type.setup;
if (setup) {
setup.call(this.host, value, key, this);
}
} | [
"function",
"(",
"key",
")",
"{",
"var",
"attr",
"=",
"this",
".",
"__attrs",
"[",
"key",
"]",
";",
"if",
"(",
"!",
"attr",
")",
"{",
"return",
";",
"}",
"var",
"value",
"=",
"attr",
".",
"value",
"=",
"attr",
".",
"_origin",
";",
"var",
"setup... | Force to unsetting a value by key, use this method carefully. | [
"Force",
"to",
"unsetting",
"a",
"value",
"by",
"key",
"use",
"this",
"method",
"carefully",
"."
] | cd78e902baedbd16728518ba5be2fbcc48ca564f | https://github.com/kaelzhang/node-trait/blob/cd78e902baedbd16728518ba5be2fbcc48ca564f/index.js#L120-L133 | train | |
jldec/pub-generator | helpers.js | resolve | function resolve(ref, context) {
if (typeof ref !== 'string') return ref;
if (/^#/.test(ref)) { ref = (context._href || '/') + ref; }
return generator.fragment$[ref];
} | javascript | function resolve(ref, context) {
if (typeof ref !== 'string') return ref;
if (/^#/.test(ref)) { ref = (context._href || '/') + ref; }
return generator.fragment$[ref];
} | [
"function",
"resolve",
"(",
"ref",
",",
"context",
")",
"{",
"if",
"(",
"typeof",
"ref",
"!==",
"'string'",
")",
"return",
"ref",
";",
"if",
"(",
"/",
"^#",
"/",
".",
"test",
"(",
"ref",
")",
")",
"{",
"ref",
"=",
"(",
"context",
".",
"_href",
... | resolve references to fragments directly or via href string | [
"resolve",
"references",
"to",
"fragments",
"directly",
"or",
"via",
"href",
"string"
] | 524081509921ac8cb897753142324d61e10afdf3 | https://github.com/jldec/pub-generator/blob/524081509921ac8cb897753142324d61e10afdf3/helpers.js#L236-L240 | train |
jldec/pub-generator | helpers.js | pageLang | function pageLang(page) {
return page.lang ||
opts.lang ||
(opts.langDirs && !u.isRootLevel(page._href) && u.topLevel(page._href)) ||
'en';
} | javascript | function pageLang(page) {
return page.lang ||
opts.lang ||
(opts.langDirs && !u.isRootLevel(page._href) && u.topLevel(page._href)) ||
'en';
} | [
"function",
"pageLang",
"(",
"page",
")",
"{",
"return",
"page",
".",
"lang",
"||",
"opts",
".",
"lang",
"||",
"(",
"opts",
".",
"langDirs",
"&&",
"!",
"u",
".",
"isRootLevel",
"(",
"page",
".",
"_href",
")",
"&&",
"u",
".",
"topLevel",
"(",
"page"... | determine language string for a page | [
"determine",
"language",
"string",
"for",
"a",
"page"
] | 524081509921ac8cb897753142324d61e10afdf3 | https://github.com/jldec/pub-generator/blob/524081509921ac8cb897753142324d61e10afdf3/helpers.js#L243-L248 | train |
jldec/pub-generator | helpers.js | defaultFragmentHtml | function defaultFragmentHtml(fragmentName, faMarkdown, html, frame) {
var f = generator.fragment$[fragmentName];
if (f) return fragmentHtml(f);
if (faMarkdown && u.find(opts.pkgs, function(pkg) {
return ('pub-pkg-font-awesome' === pkg.pkgName);
})) {
return fragmentHtml( { _txt:faMarkdown,... | javascript | function defaultFragmentHtml(fragmentName, faMarkdown, html, frame) {
var f = generator.fragment$[fragmentName];
if (f) return fragmentHtml(f);
if (faMarkdown && u.find(opts.pkgs, function(pkg) {
return ('pub-pkg-font-awesome' === pkg.pkgName);
})) {
return fragmentHtml( { _txt:faMarkdown,... | [
"function",
"defaultFragmentHtml",
"(",
"fragmentName",
",",
"faMarkdown",
",",
"html",
",",
"frame",
")",
"{",
"var",
"f",
"=",
"generator",
".",
"fragment$",
"[",
"fragmentName",
"]",
";",
"if",
"(",
"f",
")",
"return",
"fragmentHtml",
"(",
"f",
")",
"... | try user-provided fragment, then faMarkdown with font-awesome, then html treat 3rd parameter as markdown if it doesn't contain < | [
"try",
"user",
"-",
"provided",
"fragment",
"then",
"faMarkdown",
"with",
"font",
"-",
"awesome",
"then",
"html",
"treat",
"3rd",
"parameter",
"as",
"markdown",
"if",
"it",
"doesn",
"t",
"contain",
"<"
] | 524081509921ac8cb897753142324d61e10afdf3 | https://github.com/jldec/pub-generator/blob/524081509921ac8cb897753142324d61e10afdf3/helpers.js#L404-L416 | train |
socialally/air | lib/air/create.js | el | function el(tag, attrs) {
var n = el.air(create(tag));
if(attrs && n.attr) {
return n.attr(attrs);
}
return n;
} | javascript | function el(tag, attrs) {
var n = el.air(create(tag));
if(attrs && n.attr) {
return n.attr(attrs);
}
return n;
} | [
"function",
"el",
"(",
"tag",
",",
"attrs",
")",
"{",
"var",
"n",
"=",
"el",
".",
"air",
"(",
"create",
"(",
"tag",
")",
")",
";",
"if",
"(",
"attrs",
"&&",
"n",
".",
"attr",
")",
"{",
"return",
"n",
".",
"attr",
"(",
"attrs",
")",
";",
"}"... | Create a wrapped DOM element.
@param tag The element tag name.
@param attrs Object map of element attributes. | [
"Create",
"a",
"wrapped",
"DOM",
"element",
"."
] | a3d94de58aaa4930a425fbcc7266764bf6ca8ca6 | https://github.com/socialally/air/blob/a3d94de58aaa4930a425fbcc7266764bf6ca8ca6/lib/air/create.js#L25-L31 | train |
DynoSRC/dynosrc | lib/git.js | Repo | function Repo(name, username) {
this.name = name;
this.username = username;
this.isLoaded = Deferred();
this.isCloned = Deferred();
this.isClonning = false;
this.branch = null;
} | javascript | function Repo(name, username) {
this.name = name;
this.username = username;
this.isLoaded = Deferred();
this.isCloned = Deferred();
this.isClonning = false;
this.branch = null;
} | [
"function",
"Repo",
"(",
"name",
",",
"username",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"username",
"=",
"username",
";",
"this",
".",
"isLoaded",
"=",
"Deferred",
"(",
")",
";",
"this",
".",
"isCloned",
"=",
"Deferred",
"(",
... | Not used, but kinda cool. If we do need this we will swap the git shell aspect out for a stable js-git though under the good | [
"Not",
"used",
"but",
"kinda",
"cool",
".",
"If",
"we",
"do",
"need",
"this",
"we",
"will",
"swap",
"the",
"git",
"shell",
"aspect",
"out",
"for",
"a",
"stable",
"js",
"-",
"git",
"though",
"under",
"the",
"good"
] | 1a763c9310b719a51b0df56387970ecd3f08c438 | https://github.com/DynoSRC/dynosrc/blob/1a763c9310b719a51b0df56387970ecd3f08c438/lib/git.js#L82-L89 | train |
jaredhanson/antenna | lib/route.js | Route | function Route(topic, fns, options) {
options = options || {};
this.topic = topic;
this.fns = fns;
this.regexp = pattern.parse(topic
, this.keys = []
, options.sensitive
, options.strict);
} | javascript | function Route(topic, fns, options) {
options = options || {};
this.topic = topic;
this.fns = fns;
this.regexp = pattern.parse(topic
, this.keys = []
, options.sensitive
, options.strict);
} | [
"function",
"Route",
"(",
"topic",
",",
"fns",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"topic",
"=",
"topic",
";",
"this",
".",
"fns",
"=",
"fns",
";",
"this",
".",
"regexp",
"=",
"pattern",
".",
"pa... | `Route` constructor.
@api protected | [
"Route",
"constructor",
"."
] | fecfa8320a29d0f1cf22df0230f3b65a12316087 | https://github.com/jaredhanson/antenna/blob/fecfa8320a29d0f1cf22df0230f3b65a12316087/lib/route.js#L12-L20 | train |
henrytseng/angular-state-router | src/services/url-manager.js | function() {
var current = $state.current();
if(current && current.url) {
var path;
path = current.url;
// Add parameters or use default parameters
var params = current.params || {};
var query = {};
for(var name in params) {
var re = new RegExp(':'+name, 'g');
... | javascript | function() {
var current = $state.current();
if(current && current.url) {
var path;
path = current.url;
// Add parameters or use default parameters
var params = current.params || {};
var query = {};
for(var name in params) {
var re = new RegExp(':'+name, 'g');
... | [
"function",
"(",
")",
"{",
"var",
"current",
"=",
"$state",
".",
"current",
"(",
")",
";",
"if",
"(",
"current",
"&&",
"current",
".",
"url",
")",
"{",
"var",
"path",
";",
"path",
"=",
"current",
".",
"url",
";",
"// Add parameters or use default paramet... | Update URL based on state | [
"Update",
"URL",
"based",
"on",
"state"
] | 5b8147d5f5fe8a8e8453dddf61fe0b01fe5b5e9b | https://github.com/henrytseng/angular-state-router/blob/5b8147d5f5fe8a8e8453dddf61fe0b01fe5b5e9b/src/services/url-manager.js#L14-L38 | train | |
keybase/node-bitcoin | lib/lib.js | function (str) {
for (var bytes = [], i = 0; i < str.length; i++)
bytes.push(str.charCodeAt(i) & 0xFF);
return bytes;
} | javascript | function (str) {
for (var bytes = [], i = 0; i < str.length; i++)
bytes.push(str.charCodeAt(i) & 0xFF);
return bytes;
} | [
"function",
"(",
"str",
")",
"{",
"for",
"(",
"var",
"bytes",
"=",
"[",
"]",
",",
"i",
"=",
"0",
";",
"i",
"<",
"str",
".",
"length",
";",
"i",
"++",
")",
"bytes",
".",
"push",
"(",
"str",
".",
"charCodeAt",
"(",
"i",
")",
"&",
"0xFF",
")",... | Convert a string to a byte array | [
"Convert",
"a",
"string",
"to",
"a",
"byte",
"array"
] | 44d9e7279f48be95e3e7bb61110a4d76e71a977a | https://github.com/keybase/node-bitcoin/blob/44d9e7279f48be95e3e7bb61110a4d76e71a977a/lib/lib.js#L1455-L1459 | train | |
keybase/node-bitcoin | lib/lib.js | function (bytes) {
for (var str = [], i = 0; i < bytes.length; i++)
str.push(String.fromCharCode(bytes[i]));
return str.join("");
} | javascript | function (bytes) {
for (var str = [], i = 0; i < bytes.length; i++)
str.push(String.fromCharCode(bytes[i]));
return str.join("");
} | [
"function",
"(",
"bytes",
")",
"{",
"for",
"(",
"var",
"str",
"=",
"[",
"]",
",",
"i",
"=",
"0",
";",
"i",
"<",
"bytes",
".",
"length",
";",
"i",
"++",
")",
"str",
".",
"push",
"(",
"String",
".",
"fromCharCode",
"(",
"bytes",
"[",
"i",
"]",
... | Convert a byte array to a string | [
"Convert",
"a",
"byte",
"array",
"to",
"a",
"string"
] | 44d9e7279f48be95e3e7bb61110a4d76e71a977a | https://github.com/keybase/node-bitcoin/blob/44d9e7279f48be95e3e7bb61110a4d76e71a977a/lib/lib.js#L1462-L1466 | train | |
keybase/node-bitcoin | lib/lib.js | function () {
// p = 2^256 - 2^32 - 2^9 - 2^8 - 2^7 - 2^6 - 2^4 - 1
var p = ec.fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F");
var a = BigInteger.ZERO;
var b = ec.fromHex("7");
var n = ec.fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141");
var h = ... | javascript | function () {
// p = 2^256 - 2^32 - 2^9 - 2^8 - 2^7 - 2^6 - 2^4 - 1
var p = ec.fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F");
var a = BigInteger.ZERO;
var b = ec.fromHex("7");
var n = ec.fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141");
var h = ... | [
"function",
"(",
")",
"{",
"// p = 2^256 - 2^32 - 2^9 - 2^8 - 2^7 - 2^6 - 2^4 - 1",
"var",
"p",
"=",
"ec",
".",
"fromHex",
"(",
"\"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F\"",
")",
";",
"var",
"a",
"=",
"BigInteger",
".",
"ZERO",
";",
"var",
"b",... | used by Bitcoin | [
"used",
"by",
"Bitcoin"
] | 44d9e7279f48be95e3e7bb61110a4d76e71a977a | https://github.com/keybase/node-bitcoin/blob/44d9e7279f48be95e3e7bb61110a4d76e71a977a/lib/lib.js#L2391-L2403 | train | |
keybase/node-bitcoin | lib/lib.js | function (input) {
var bi = BigInteger.fromByteArrayUnsigned(input);
var chars = [];
while (bi.compareTo(B58.base) >= 0) {
var mod = bi.mod(B58.base);
chars.unshift(B58.alphabet[mod.intValue()]);
bi = bi.subtract(mod).divide(B58.base);
}
chars.unshift(B58.alphabet[bi.intValue()]);
// Con... | javascript | function (input) {
var bi = BigInteger.fromByteArrayUnsigned(input);
var chars = [];
while (bi.compareTo(B58.base) >= 0) {
var mod = bi.mod(B58.base);
chars.unshift(B58.alphabet[mod.intValue()]);
bi = bi.subtract(mod).divide(B58.base);
}
chars.unshift(B58.alphabet[bi.intValue()]);
// Con... | [
"function",
"(",
"input",
")",
"{",
"var",
"bi",
"=",
"BigInteger",
".",
"fromByteArrayUnsigned",
"(",
"input",
")",
";",
"var",
"chars",
"=",
"[",
"]",
";",
"while",
"(",
"bi",
".",
"compareTo",
"(",
"B58",
".",
"base",
")",
">=",
"0",
")",
"{",
... | Convert a byte array to a base58-encoded string.
Written by Mike Hearn for BitcoinJ.
Copyright (c) 2011 Google Inc.
Ported to JavaScript by Stefan Thomas. | [
"Convert",
"a",
"byte",
"array",
"to",
"a",
"base58",
"-",
"encoded",
"string",
"."
] | 44d9e7279f48be95e3e7bb61110a4d76e71a977a | https://github.com/keybase/node-bitcoin/blob/44d9e7279f48be95e3e7bb61110a4d76e71a977a/lib/lib.js#L2486-L2505 | train | |
keybase/node-bitcoin | lib/lib.js | function (len, val) {
var array = [];
var i = 0;
while (i < len) {
array[i++] = val;
}
return array;
} | javascript | function (len, val) {
var array = [];
var i = 0;
while (i < len) {
array[i++] = val;
}
return array;
} | [
"function",
"(",
"len",
",",
"val",
")",
"{",
"var",
"array",
"=",
"[",
"]",
";",
"var",
"i",
"=",
"0",
";",
"while",
"(",
"i",
"<",
"len",
")",
"{",
"array",
"[",
"i",
"++",
"]",
"=",
"val",
";",
"}",
"return",
"array",
";",
"}"
] | Create an array of a certain length filled with a specific value. | [
"Create",
"an",
"array",
"of",
"a",
"certain",
"length",
"filled",
"with",
"a",
"specific",
"value",
"."
] | 44d9e7279f48be95e3e7bb61110a4d76e71a977a | https://github.com/keybase/node-bitcoin/blob/44d9e7279f48be95e3e7bb61110a4d76e71a977a/lib/lib.js#L2815-L2822 | train | |
keybase/node-bitcoin | lib/lib.js | function (i) {
if (i < 0xfd) {
// unsigned char
return [i];
} else if (i <= 1 << 16) {
// unsigned short (LE)
return [0xfd, i >>> 8, i & 255];
} else if (i <= 1 << 32) {
// unsigned int (LE)
return [0xfe].concat(Crypto.util.wordsToBytes([i]));
} else {
// unsigned long long (LE)
... | javascript | function (i) {
if (i < 0xfd) {
// unsigned char
return [i];
} else if (i <= 1 << 16) {
// unsigned short (LE)
return [0xfd, i >>> 8, i & 255];
} else if (i <= 1 << 32) {
// unsigned int (LE)
return [0xfe].concat(Crypto.util.wordsToBytes([i]));
} else {
// unsigned long long (LE)
... | [
"function",
"(",
"i",
")",
"{",
"if",
"(",
"i",
"<",
"0xfd",
")",
"{",
"// unsigned char",
"return",
"[",
"i",
"]",
";",
"}",
"else",
"if",
"(",
"i",
"<=",
"1",
"<<",
"16",
")",
"{",
"// unsigned short (LE)",
"return",
"[",
"0xfd",
",",
"i",
">>>... | Turn an integer into a "var_int".
"var_int" is a variable length integer used by Bitcoin's binary format.
Returns a byte array. | [
"Turn",
"an",
"integer",
"into",
"a",
"var_int",
"."
] | 44d9e7279f48be95e3e7bb61110a4d76e71a977a | https://github.com/keybase/node-bitcoin/blob/44d9e7279f48be95e3e7bb61110a4d76e71a977a/lib/lib.js#L2830-L2844 | train | |
keybase/node-bitcoin | lib/lib.js | function (valueBuffer) {
var value = this.valueToBigInt(valueBuffer).toString();
var integerPart = value.length > 8 ? value.substr(0, value.length - 8) : '0';
var decimalPart = value.length > 8 ? value.substr(value.length - 8) : value;
while (decimalPart.length < 8) decimalPart = "0" + decimalPart;
decim... | javascript | function (valueBuffer) {
var value = this.valueToBigInt(valueBuffer).toString();
var integerPart = value.length > 8 ? value.substr(0, value.length - 8) : '0';
var decimalPart = value.length > 8 ? value.substr(value.length - 8) : value;
while (decimalPart.length < 8) decimalPart = "0" + decimalPart;
decim... | [
"function",
"(",
"valueBuffer",
")",
"{",
"var",
"value",
"=",
"this",
".",
"valueToBigInt",
"(",
"valueBuffer",
")",
".",
"toString",
"(",
")",
";",
"var",
"integerPart",
"=",
"value",
".",
"length",
">",
"8",
"?",
"value",
".",
"substr",
"(",
"0",
... | Format a Bitcoin value as a string.
Takes a BigInteger or byte-array and returns that amount of Bitcoins in a
nice standard formatting.
Examples:
12.3555
0.1234
900.99998888
34.00 | [
"Format",
"a",
"Bitcoin",
"value",
"as",
"a",
"string",
"."
] | 44d9e7279f48be95e3e7bb61110a4d76e71a977a | https://github.com/keybase/node-bitcoin/blob/44d9e7279f48be95e3e7bb61110a4d76e71a977a/lib/lib.js#L2866-L2874 | train | |
keybase/node-bitcoin | lib/lib.js | function (valueString) {
// TODO: Detect other number formats (e.g. comma as decimal separator)
var valueComp = valueString.split('.');
var integralPart = valueComp[0];
var fractionalPart = valueComp[1] || "0";
while (fractionalPart.length < 8) fractionalPart += "0";
fractionalPart = fractionalPart.re... | javascript | function (valueString) {
// TODO: Detect other number formats (e.g. comma as decimal separator)
var valueComp = valueString.split('.');
var integralPart = valueComp[0];
var fractionalPart = valueComp[1] || "0";
while (fractionalPart.length < 8) fractionalPart += "0";
fractionalPart = fractionalPart.re... | [
"function",
"(",
"valueString",
")",
"{",
"// TODO: Detect other number formats (e.g. comma as decimal separator)",
"var",
"valueComp",
"=",
"valueString",
".",
"split",
"(",
"'.'",
")",
";",
"var",
"integralPart",
"=",
"valueComp",
"[",
"0",
"]",
";",
"var",
"fract... | Parse a floating point string as a Bitcoin value.
Keep in mind that parsing user input is messy. You should always display
the parsed value back to the user to make sure we understood his input
correctly. | [
"Parse",
"a",
"floating",
"point",
"string",
"as",
"a",
"Bitcoin",
"value",
"."
] | 44d9e7279f48be95e3e7bb61110a4d76e71a977a | https://github.com/keybase/node-bitcoin/blob/44d9e7279f48be95e3e7bb61110a4d76e71a977a/lib/lib.js#L2882-L2893 | train | |
nyurik/mw-graph-shared | src/VegaWrapper.js | removeColon | function removeColon(protocol) {
return protocol && protocol.length && protocol[protocol.length - 1] === ':'
? protocol.substring(0, protocol.length - 1) : protocol;
} | javascript | function removeColon(protocol) {
return protocol && protocol.length && protocol[protocol.length - 1] === ':'
? protocol.substring(0, protocol.length - 1) : protocol;
} | [
"function",
"removeColon",
"(",
"protocol",
")",
"{",
"return",
"protocol",
"&&",
"protocol",
".",
"length",
"&&",
"protocol",
"[",
"protocol",
".",
"length",
"-",
"1",
"]",
"===",
"':'",
"?",
"protocol",
".",
"substring",
"(",
"0",
",",
"protocol",
".",... | Utility function to remove trailing colon from a protocol
@param {string} protocol
@return {string} | [
"Utility",
"function",
"to",
"remove",
"trailing",
"colon",
"from",
"a",
"protocol"
] | 0e1dd7356de18a0631680f4dd7231a3a2746093d | https://github.com/nyurik/mw-graph-shared/blob/0e1dd7356de18a0631680f4dd7231a3a2746093d/src/VegaWrapper.js#L15-L18 | train |
nyurik/mw-graph-shared | src/VegaWrapper.js | VegaWrapper | function VegaWrapper(wrapperOpts) {
var self = this;
// Copy all options into this object
self.objExtender = wrapperOpts.datalib.extend;
self.objExtender(self, wrapperOpts);
self.validators = {};
self.datalib.load.loader = function (opt, callback) {
var error = callback || function (e) ... | javascript | function VegaWrapper(wrapperOpts) {
var self = this;
// Copy all options into this object
self.objExtender = wrapperOpts.datalib.extend;
self.objExtender(self, wrapperOpts);
self.validators = {};
self.datalib.load.loader = function (opt, callback) {
var error = callback || function (e) ... | [
"function",
"VegaWrapper",
"(",
"wrapperOpts",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// Copy all options into this object",
"self",
".",
"objExtender",
"=",
"wrapperOpts",
".",
"datalib",
".",
"extend",
";",
"self",
".",
"objExtender",
"(",
"self",
",",
... | Shared library to wrap around vega code
@param {Object} wrapperOpts Configuration options
@param {Object} wrapperOpts.datalib Vega's datalib object
@param {Object} wrapperOpts.datalib.load Vega's data loader
@param {Function} wrapperOpts.datalib.load.loader Vega's data loader function
@param {Function} wrapperOpts.data... | [
"Shared",
"library",
"to",
"wrap",
"around",
"vega",
"code"
] | 0e1dd7356de18a0631680f4dd7231a3a2746093d | https://github.com/nyurik/mw-graph-shared/blob/0e1dd7356de18a0631680f4dd7231a3a2746093d/src/VegaWrapper.js#L37-L75 | train |
theboyWhoCriedWoolf/transition-manager | src/core/transitionViewManager.js | _prepareViews | function _prepareViews( actionData, paramData )
{
let linkedTranssModules = actionData.linkedVTransModules, // look into slice speed over creating new array
ViewsModuleLength = linkedTranssModules.length,
promises = [],
preparedViews = [],
actionDataClone = null,
viewCache = {},
i ... | javascript | function _prepareViews( actionData, paramData )
{
let linkedTranssModules = actionData.linkedVTransModules, // look into slice speed over creating new array
ViewsModuleLength = linkedTranssModules.length,
promises = [],
preparedViews = [],
actionDataClone = null,
viewCache = {},
i ... | [
"function",
"_prepareViews",
"(",
"actionData",
",",
"paramData",
")",
"{",
"let",
"linkedTranssModules",
"=",
"actionData",
".",
"linkedVTransModules",
",",
"// look into slice speed over creating new array",
"ViewsModuleLength",
"=",
"linkedTranssModules",
".",
"length",
... | loop through all transition modules and prepare the
views requested by the config
@param {object} actionData containing all transition types and views required
@param {object} paramData sent with the action
@return {object} promises array and pepared views array | [
"loop",
"through",
"all",
"transition",
"modules",
"and",
"prepare",
"the",
"views",
"requested",
"by",
"the",
"config"
] | a20fda0bb07c0098bf709ea03770b1ee2a855655 | https://github.com/theboyWhoCriedWoolf/transition-manager/blob/a20fda0bb07c0098bf709ea03770b1ee2a855655/src/core/transitionViewManager.js#L35-L56 | train |
theboyWhoCriedWoolf/transition-manager | src/core/transitionViewManager.js | _fetchViews | function _fetchViews( viewsToPrepare, actionDataClone, promises, viewCache )
{
const views = viewsToPrepare,
viewManager = _options.viewManager,
length = views.length,
currentViewID = actionDataClone.currentViewID,
nextViewID = actionDataClone.nextViewID;
let i = 0,
_deferred,
view... | javascript | function _fetchViews( viewsToPrepare, actionDataClone, promises, viewCache )
{
const views = viewsToPrepare,
viewManager = _options.viewManager,
length = views.length,
currentViewID = actionDataClone.currentViewID,
nextViewID = actionDataClone.nextViewID;
let i = 0,
_deferred,
view... | [
"function",
"_fetchViews",
"(",
"viewsToPrepare",
",",
"actionDataClone",
",",
"promises",
",",
"viewCache",
")",
"{",
"const",
"views",
"=",
"viewsToPrepare",
",",
"viewManager",
"=",
"_options",
".",
"viewManager",
",",
"length",
"=",
"views",
".",
"length",
... | loop through and fetch all the requested views, use viewReady
and collect a promise for each to allow the view to build up and perform
its preperation tasks if required
@param {array} views - string references
@param {object} actionDataClone - cloned data as to not override config
@param {array} promises - collect ... | [
"loop",
"through",
"and",
"fetch",
"all",
"the",
"requested",
"views",
"use",
"viewReady",
"and",
"collect",
"a",
"promise",
"for",
"each",
"to",
"allow",
"the",
"view",
"to",
"build",
"up",
"and",
"perform",
"its",
"preperation",
"tasks",
"if",
"required"
] | a20fda0bb07c0098bf709ea03770b1ee2a855655 | https://github.com/theboyWhoCriedWoolf/transition-manager/blob/a20fda0bb07c0098bf709ea03770b1ee2a855655/src/core/transitionViewManager.js#L69-L117 | train |
theboyWhoCriedWoolf/transition-manager | src/core/transitionViewManager.js | _viewRef | function _viewRef( ref, comparisonViews ) {
var index = comparisonViews.indexOf( ref );
return (index === -1 )? null : ['currentView', 'nextView'][ index ];
} | javascript | function _viewRef( ref, comparisonViews ) {
var index = comparisonViews.indexOf( ref );
return (index === -1 )? null : ['currentView', 'nextView'][ index ];
} | [
"function",
"_viewRef",
"(",
"ref",
",",
"comparisonViews",
")",
"{",
"var",
"index",
"=",
"comparisonViews",
".",
"indexOf",
"(",
"ref",
")",
";",
"return",
"(",
"index",
"===",
"-",
"1",
")",
"?",
"null",
":",
"[",
"'currentView'",
",",
"'nextView'",
... | convert view named references to either current view
or next view if the ID's match
Makes it easier to access and build generic use cases
@param {string} ref current View ID
@param {array} comparisonViews - currentView and nextView string IDS
@return {string} - new IDS if matched | [
"convert",
"view",
"named",
"references",
"to",
"either",
"current",
"view",
"or",
"next",
"view",
"if",
"the",
"ID",
"s",
"match",
"Makes",
"it",
"easier",
"to",
"access",
"and",
"build",
"generic",
"use",
"cases"
] | a20fda0bb07c0098bf709ea03770b1ee2a855655 | https://github.com/theboyWhoCriedWoolf/transition-manager/blob/a20fda0bb07c0098bf709ea03770b1ee2a855655/src/core/transitionViewManager.js#L128-L131 | train |
theboyWhoCriedWoolf/transition-manager | src/core/transitionViewManager.js | _getCached | function _getCached( cached, data )
{
if( !data ){ return cached; }
let i = -1, len = cached.length;
while (++i < len) {
cached[i].data = data;
}
return cached;
} | javascript | function _getCached( cached, data )
{
if( !data ){ return cached; }
let i = -1, len = cached.length;
while (++i < len) {
cached[i].data = data;
}
return cached;
} | [
"function",
"_getCached",
"(",
"cached",
",",
"data",
")",
"{",
"if",
"(",
"!",
"data",
")",
"{",
"return",
"cached",
";",
"}",
"let",
"i",
"=",
"-",
"1",
",",
"len",
"=",
"cached",
".",
"length",
";",
"while",
"(",
"++",
"i",
"<",
"len",
")",
... | return cached views based on action type
@param {array} cached - previously prepared views
@param {object} data - action data passed through with action
@return {array} - cached views | [
"return",
"cached",
"views",
"based",
"on",
"action",
"type"
] | a20fda0bb07c0098bf709ea03770b1ee2a855655 | https://github.com/theboyWhoCriedWoolf/transition-manager/blob/a20fda0bb07c0098bf709ea03770b1ee2a855655/src/core/transitionViewManager.js#L140-L149 | train |
theboyWhoCriedWoolf/transition-manager | src/core/transitionViewManager.js | _cloneViewState | function _cloneViewState( actionData, transitionObject, paramData ) {
return {
data : paramData,
currentViewID : actionData.currentView, // optional
nextViewID : actionData.nextView, // optional
views : {},
transitionType : transitionObject.transitionType
};
} | javascript | function _cloneViewState( actionData, transitionObject, paramData ) {
return {
data : paramData,
currentViewID : actionData.currentView, // optional
nextViewID : actionData.nextView, // optional
views : {},
transitionType : transitionObject.transitionType
};
} | [
"function",
"_cloneViewState",
"(",
"actionData",
",",
"transitionObject",
",",
"paramData",
")",
"{",
"return",
"{",
"data",
":",
"paramData",
",",
"currentViewID",
":",
"actionData",
".",
"currentView",
",",
"// optional",
"nextViewID",
":",
"actionData",
".",
... | clone the action data object
fast clone and prevents the config references to be
oweriden by instances or other settings
@param {object} actionData passed in from the config
@param {object} transitionObject - action data transition
@param {object} paramData sent with the action
@return {object} new object with an in... | [
"clone",
"the",
"action",
"data",
"object",
"fast",
"clone",
"and",
"prevents",
"the",
"config",
"references",
"to",
"be",
"oweriden",
"by",
"instances",
"or",
"other",
"settings"
] | a20fda0bb07c0098bf709ea03770b1ee2a855655 | https://github.com/theboyWhoCriedWoolf/transition-manager/blob/a20fda0bb07c0098bf709ea03770b1ee2a855655/src/core/transitionViewManager.js#L160-L168 | train |
shamoons/linguist-samples | samples/JavaScript/http.js | parserOnHeaders | function parserOnHeaders(headers, url) {
// Once we exceeded headers limit - stop collecting them
if (this.maxHeaderPairs <= 0 ||
this._headers.length < this.maxHeaderPairs) {
this._headers = this._headers.concat(headers);
}
this._url += url;
} | javascript | function parserOnHeaders(headers, url) {
// Once we exceeded headers limit - stop collecting them
if (this.maxHeaderPairs <= 0 ||
this._headers.length < this.maxHeaderPairs) {
this._headers = this._headers.concat(headers);
}
this._url += url;
} | [
"function",
"parserOnHeaders",
"(",
"headers",
",",
"url",
")",
"{",
"// Once we exceeded headers limit - stop collecting them",
"if",
"(",
"this",
".",
"maxHeaderPairs",
"<=",
"0",
"||",
"this",
".",
"_headers",
".",
"length",
"<",
"this",
".",
"maxHeaderPairs",
... | Only called in the slow case where slow means that the request headers were either fragmented across multiple TCP packets or too large to be processed in a single run. This method is also called to process trailing HTTP headers. | [
"Only",
"called",
"in",
"the",
"slow",
"case",
"where",
"slow",
"means",
"that",
"the",
"request",
"headers",
"were",
"either",
"fragmented",
"across",
"multiple",
"TCP",
"packets",
"or",
"too",
"large",
"to",
"be",
"processed",
"in",
"a",
"single",
"run",
... | 71c5ec1a535f7dde31f9e407679475f57fae0c08 | https://github.com/shamoons/linguist-samples/blob/71c5ec1a535f7dde31f9e407679475f57fae0c08/samples/JavaScript/http.js#L45-L52 | train |
zipscene/winston-daily-rotate | index.js | throwIf | function throwIf (target /*, illegal... */) {
Array.prototype.slice.call(arguments, 1).forEach(function (name) {
if (options[name]) {
throw new Error('Cannot set ' + name + ' and ' + target + 'together');
}
});
} | javascript | function throwIf (target /*, illegal... */) {
Array.prototype.slice.call(arguments, 1).forEach(function (name) {
if (options[name]) {
throw new Error('Cannot set ' + name + ' and ' + target + 'together');
}
});
} | [
"function",
"throwIf",
"(",
"target",
"/*, illegal... */",
")",
"{",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
".",
"forEach",
"(",
"function",
"(",
"name",
")",
"{",
"if",
"(",
"options",
"[",
"name",
"]",
... | Helper function which throws an `Error` in the event that any of the rest of the arguments is present in `options`. | [
"Helper",
"function",
"which",
"throws",
"an",
"Error",
"in",
"the",
"event",
"that",
"any",
"of",
"the",
"rest",
"of",
"the",
"arguments",
"is",
"present",
"in",
"options",
"."
] | 63a708572475b766061cb950e9dd1f98b20ea772 | https://github.com/zipscene/winston-daily-rotate/blob/63a708572475b766061cb950e9dd1f98b20ea772/index.js#L35-L41 | train |
mesmotronic/conbo | examples/Template.js | function()
{
this.appendView
(
new ns.MyLoadedView(this.context.addTo({templateUrl:'template-2.html'})),
new ns.MyOtherView(this.context.addTo({template:'This is an internal template using <b>options.template</b> that hates <span cb-style="favoriteColor:color">{{favoriteColor}}</span>'}))
);
... | javascript | function()
{
this.appendView
(
new ns.MyLoadedView(this.context.addTo({templateUrl:'template-2.html'})),
new ns.MyOtherView(this.context.addTo({template:'This is an internal template using <b>options.template</b> that hates <span cb-style="favoriteColor:color">{{favoriteColor}}</span>'}))
);
... | [
"function",
"(",
")",
"{",
"this",
".",
"appendView",
"(",
"new",
"ns",
".",
"MyLoadedView",
"(",
"this",
".",
"context",
".",
"addTo",
"(",
"{",
"templateUrl",
":",
"'template-2.html'",
"}",
")",
")",
",",
"new",
"ns",
".",
"MyOtherView",
"(",
"this",... | All classes have an initialize entry point | [
"All",
"classes",
"have",
"an",
"initialize",
"entry",
"point"
] | 339df613eefc48e054e115337079573ad842f717 | https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/examples/Template.js#L50-L57 | train | |
Stitchuuuu/thread-promisify | thread.js | Log | function Log() {
var args = CopyArguments(arguments);
var level = args.shift();
args.unshift("[Thread] <"+threadId+">");
args.unshift(level);
process.send({name: "thread-log", args: SerializeForProcess(args)});
} | javascript | function Log() {
var args = CopyArguments(arguments);
var level = args.shift();
args.unshift("[Thread] <"+threadId+">");
args.unshift(level);
process.send({name: "thread-log", args: SerializeForProcess(args)});
} | [
"function",
"Log",
"(",
")",
"{",
"var",
"args",
"=",
"CopyArguments",
"(",
"arguments",
")",
";",
"var",
"level",
"=",
"args",
".",
"shift",
"(",
")",
";",
"args",
".",
"unshift",
"(",
"\"[Thread] <\"",
"+",
"threadId",
"+",
"\">\"",
")",
";",
"args... | Log an information | [
"Log",
"an",
"information"
] | 5c6fc0b481520049e2078461693ceee7c27ddd53 | https://github.com/Stitchuuuu/thread-promisify/blob/5c6fc0b481520049e2078461693ceee7c27ddd53/thread.js#L14-L20 | train |
Stitchuuuu/thread-promisify | thread.js | ConvertArgs | function ConvertArgs(args, baseResponse) {
var baseResponse = Object.assign({}, baseResponse);
args.forEach(function(arg, i) {
if (typeof(arg) == "object" && arg._classname == "SerializedFunction") {
var idRemoteFunction = arg.id;
args[i] = function() {
process.se... | javascript | function ConvertArgs(args, baseResponse) {
var baseResponse = Object.assign({}, baseResponse);
args.forEach(function(arg, i) {
if (typeof(arg) == "object" && arg._classname == "SerializedFunction") {
var idRemoteFunction = arg.id;
args[i] = function() {
process.se... | [
"function",
"ConvertArgs",
"(",
"args",
",",
"baseResponse",
")",
"{",
"var",
"baseResponse",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"baseResponse",
")",
";",
"args",
".",
"forEach",
"(",
"function",
"(",
"arg",
",",
"i",
")",
"{",
"if",
"... | Convert SerializedFunction objects to function, so when called
we execute the function in the original thread | [
"Convert",
"SerializedFunction",
"objects",
"to",
"function",
"so",
"when",
"called",
"we",
"execute",
"the",
"function",
"in",
"the",
"original",
"thread"
] | 5c6fc0b481520049e2078461693ceee7c27ddd53 | https://github.com/Stitchuuuu/thread-promisify/blob/5c6fc0b481520049e2078461693ceee7c27ddd53/thread.js#L26-L37 | train |
Stitchuuuu/thread-promisify | thread.js | finalizeRequestDone | function finalizeRequestDone() {
if (PendingRequests.length) {
// If we have queued requests, we execute the next one
currentRequest = PendingRequests.shift();
Log(3, "Executing request", currentRequest.id);
executeRequest(currentRequest);
} else {
// We set a timeout in ... | javascript | function finalizeRequestDone() {
if (PendingRequests.length) {
// If we have queued requests, we execute the next one
currentRequest = PendingRequests.shift();
Log(3, "Executing request", currentRequest.id);
executeRequest(currentRequest);
} else {
// We set a timeout in ... | [
"function",
"finalizeRequestDone",
"(",
")",
"{",
"if",
"(",
"PendingRequests",
".",
"length",
")",
"{",
"// If we have queued requests, we execute the next one",
"currentRequest",
"=",
"PendingRequests",
".",
"shift",
"(",
")",
";",
"Log",
"(",
"3",
",",
"\"Executi... | Finalize a request when it is done | [
"Finalize",
"a",
"request",
"when",
"it",
"is",
"done"
] | 5c6fc0b481520049e2078461693ceee7c27ddd53 | https://github.com/Stitchuuuu/thread-promisify/blob/5c6fc0b481520049e2078461693ceee7c27ddd53/thread.js#L42-L60 | train |
CrocInc/grunt-croc-requirejs | rjs/xcss.js | _includeCSSInternal | function _includeCSSInternal (css) {
var head,
style = document.getElementById(_stylesheetTagID);
if (!style) {
// there's no our styles tag - create
style = document.createElement('style');
style.setAttribute('id', _stylesheetTagID);
style.setAttribute('type', 'text/css');
head = document.getEle... | javascript | function _includeCSSInternal (css) {
var head,
style = document.getElementById(_stylesheetTagID);
if (!style) {
// there's no our styles tag - create
style = document.createElement('style');
style.setAttribute('id', _stylesheetTagID);
style.setAttribute('type', 'text/css');
head = document.getEle... | [
"function",
"_includeCSSInternal",
"(",
"css",
")",
"{",
"var",
"head",
",",
"style",
"=",
"document",
".",
"getElementById",
"(",
"_stylesheetTagID",
")",
";",
"if",
"(",
"!",
"style",
")",
"{",
"// there's no our styles tag - create",
"style",
"=",
"document",... | Add css code into STYLE tag in HEAD. It tries to use the single STYLE tag with special ID "xcss_styles"
@param css - style | [
"Add",
"css",
"code",
"into",
"STYLE",
"tag",
"in",
"HEAD",
".",
"It",
"tries",
"to",
"use",
"the",
"single",
"STYLE",
"tag",
"with",
"special",
"ID",
"xcss_styles"
] | bc07f1b096a6484b472a72830dcacc65ca64b407 | https://github.com/CrocInc/grunt-croc-requirejs/blob/bc07f1b096a6484b472a72830dcacc65ca64b407/rjs/xcss.js#L64-L82 | train |
CrocInc/grunt-croc-requirejs | rjs/xcss.js | function (css, name) {
if (typeof css === "function") { css = css(); }
if (!css) { return; }
if (!name) {
_includeCSSInternal(css);
} else if (!_stylesheetFiles[name]) {
_includeCSSInternal(css);
_stylesheetFiles[name] = true;
}
} | javascript | function (css, name) {
if (typeof css === "function") { css = css(); }
if (!css) { return; }
if (!name) {
_includeCSSInternal(css);
} else if (!_stylesheetFiles[name]) {
_includeCSSInternal(css);
_stylesheetFiles[name] = true;
}
} | [
"function",
"(",
"css",
",",
"name",
")",
"{",
"if",
"(",
"typeof",
"css",
"===",
"\"function\"",
")",
"{",
"css",
"=",
"css",
"(",
")",
";",
"}",
"if",
"(",
"!",
"css",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"name",
")",
"{",
"_includ... | Append style element with css param's content
@param {String|Function} css Content for style element or a function which returns it
@param {String} name Name of the stylesheet to prevent duplication. | [
"Append",
"style",
"element",
"with",
"css",
"param",
"s",
"content"
] | bc07f1b096a6484b472a72830dcacc65ca64b407 | https://github.com/CrocInc/grunt-croc-requirejs/blob/bc07f1b096a6484b472a72830dcacc65ca64b407/rjs/xcss.js#L100-L109 | train | |
svipas/cachimo | src/cachimo.js | clear | function clear() {
timeouts.forEach((callback, timeout) => {
clearTimeout(timeout);
// reject Promise or execute callback which returns Error
callback();
});
const length = size();
cache.clear();
return length;
} | javascript | function clear() {
timeouts.forEach((callback, timeout) => {
clearTimeout(timeout);
// reject Promise or execute callback which returns Error
callback();
});
const length = size();
cache.clear();
return length;
} | [
"function",
"clear",
"(",
")",
"{",
"timeouts",
".",
"forEach",
"(",
"(",
"callback",
",",
"timeout",
")",
"=>",
"{",
"clearTimeout",
"(",
"timeout",
")",
";",
"// reject Promise or execute callback which returns Error",
"callback",
"(",
")",
";",
"}",
")",
";... | Removes all elements stored in cache and clears all timeouts.
@returns {number} how much elements was removed from cache | [
"Removes",
"all",
"elements",
"stored",
"in",
"cache",
"and",
"clears",
"all",
"timeouts",
"."
] | c6e53dfff29e4dcb67979c71992887ab1c51b5df | https://github.com/svipas/cachimo/blob/c6e53dfff29e4dcb67979c71992887ab1c51b5df/src/cachimo.js#L78-L89 | train |
svipas/cachimo | src/cachimo.js | put | function put(key, value, timeout, callback) {
// key type is incorrect
if (typeof key !== 'string' && typeof key !== 'number' && typeof key !== 'boolean') {
throw new TypeError(`key can be only: string | number | boolean instead of ${typeof key}`);
}
// check if key is not NaN
if (typeof key === 'number' ... | javascript | function put(key, value, timeout, callback) {
// key type is incorrect
if (typeof key !== 'string' && typeof key !== 'number' && typeof key !== 'boolean') {
throw new TypeError(`key can be only: string | number | boolean instead of ${typeof key}`);
}
// check if key is not NaN
if (typeof key === 'number' ... | [
"function",
"put",
"(",
"key",
",",
"value",
",",
"timeout",
",",
"callback",
")",
"{",
"// key type is incorrect",
"if",
"(",
"typeof",
"key",
"!==",
"'string'",
"&&",
"typeof",
"key",
"!==",
"'number'",
"&&",
"typeof",
"key",
"!==",
"'boolean'",
")",
"{"... | Stores an element in-memory with specified key and value.
If only `key` and `value` is provided it returns boolean.
true: if element was stored and key doesn't exist.
false: if key does exist.
If additionally only `timeout` is provided it returns Promise.
Element will be deleted after given `timeout` and Promise will... | [
"Stores",
"an",
"element",
"in",
"-",
"memory",
"with",
"specified",
"key",
"and",
"value",
"."
] | c6e53dfff29e4dcb67979c71992887ab1c51b5df | https://github.com/svipas/cachimo/blob/c6e53dfff29e4dcb67979c71992887ab1c51b5df/src/cachimo.js#L111-L165 | train |
synder/xpress | demo/commander/index.js | Option | function Option(flags, description) {
this.flags = flags;
this.required = ~flags.indexOf('<');
this.optional = ~flags.indexOf('[');
this.bool = !~flags.indexOf('-no-');
flags = flags.split(/[ ,|]+/);
if (flags.length > 1 && !/^[[<]/.test(flags[1])) this.short = flags.shift();
this.long = flags.shift();
... | javascript | function Option(flags, description) {
this.flags = flags;
this.required = ~flags.indexOf('<');
this.optional = ~flags.indexOf('[');
this.bool = !~flags.indexOf('-no-');
flags = flags.split(/[ ,|]+/);
if (flags.length > 1 && !/^[[<]/.test(flags[1])) this.short = flags.shift();
this.long = flags.shift();
... | [
"function",
"Option",
"(",
"flags",
",",
"description",
")",
"{",
"this",
".",
"flags",
"=",
"flags",
";",
"this",
".",
"required",
"=",
"~",
"flags",
".",
"indexOf",
"(",
"'<'",
")",
";",
"this",
".",
"optional",
"=",
"~",
"flags",
".",
"indexOf",
... | Initialize a new `Option` with the given `flags` and `description`.
@param {String} flags
@param {String} description
@api public | [
"Initialize",
"a",
"new",
"Option",
"with",
"the",
"given",
"flags",
"and",
"description",
"."
] | 4b1e89208b6f34cd78ce90b8a858592115b6ccb5 | https://github.com/synder/xpress/blob/4b1e89208b6f34cd78ce90b8a858592115b6ccb5/demo/commander/index.js#L38-L47 | train |
henrytseng/angular-state-view | src/services/view-manager.js | function() {
// Reset views
var resetPromised = {};
angular.forEach(_activeSet, function(view, id) {
resetPromised[id] = $q.when(view.reset());
});
// Empty active set
_activeSet = {};
return $q.all(resetPromised);
} | javascript | function() {
// Reset views
var resetPromised = {};
angular.forEach(_activeSet, function(view, id) {
resetPromised[id] = $q.when(view.reset());
});
// Empty active set
_activeSet = {};
return $q.all(resetPromised);
} | [
"function",
"(",
")",
"{",
"// Reset views",
"var",
"resetPromised",
"=",
"{",
"}",
";",
"angular",
".",
"forEach",
"(",
"_activeSet",
",",
"function",
"(",
"view",
",",
"id",
")",
"{",
"resetPromised",
"[",
"id",
"]",
"=",
"$q",
".",
"when",
"(",
"v... | Reset active views
@return {Promise} A promise fulfilled when currently active views are reset | [
"Reset",
"active",
"views"
] | cf27c3a5cf65289501957e4dce3b75e7abef4def | https://github.com/henrytseng/angular-state-view/blob/cf27c3a5cf65289501957e4dce3b75e7abef4def/src/services/view-manager.js#L20-L31 | train | |
henrytseng/angular-state-view | src/services/view-manager.js | function(id, view, data, controller) {
return _getTemplate(data).then(function(template) {
// Controller
if(controller) {
var current = $state.current();
return view.render(template, controller, current.locals);
// Template only
} else {
return view.render(template)... | javascript | function(id, view, data, controller) {
return _getTemplate(data).then(function(template) {
// Controller
if(controller) {
var current = $state.current();
return view.render(template, controller, current.locals);
// Template only
} else {
return view.render(template)... | [
"function",
"(",
"id",
",",
"view",
",",
"data",
",",
"controller",
")",
"{",
"return",
"_getTemplate",
"(",
"data",
")",
".",
"then",
"(",
"function",
"(",
"template",
")",
"{",
"// Controller",
"if",
"(",
"controller",
")",
"{",
"var",
"current",
"="... | Render a view
@param {String} id Unique identifier for view
@param {View} view A view instance
@param {Mixed} data Template data, String src to include or Function invocation
@return {Promise} A promise fulfilled when currently active view is rendered | [
"Render",
"a",
"view"
] | cf27c3a5cf65289501957e4dce3b75e7abef4def | https://github.com/henrytseng/angular-state-view/blob/cf27c3a5cf65289501957e4dce3b75e7abef4def/src/services/view-manager.js#L52-L65 | train | |
henrytseng/angular-state-view | src/services/view-manager.js | function(callback) {
// Activate current
var current = $state.current();
if(current) {
// Reset
_resetActive().then(function() {
// Render
var viewsPromised = {};
var templates = current.templates || {};
var controllers = current.controllers || {};
angu... | javascript | function(callback) {
// Activate current
var current = $state.current();
if(current) {
// Reset
_resetActive().then(function() {
// Render
var viewsPromised = {};
var templates = current.templates || {};
var controllers = current.controllers || {};
angu... | [
"function",
"(",
"callback",
")",
"{",
"// Activate current",
"var",
"current",
"=",
"$state",
".",
"current",
"(",
")",
";",
"if",
"(",
"current",
")",
"{",
"// Reset",
"_resetActive",
"(",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"// Render",
... | Update rendered views
@param {Function} callback A completion callback, function(err) | [
"Update",
"rendered",
"views"
] | cf27c3a5cf65289501957e4dce3b75e7abef4def | https://github.com/henrytseng/angular-state-view/blob/cf27c3a5cf65289501957e4dce3b75e7abef4def/src/services/view-manager.js#L72-L104 | train | |
henrytseng/angular-state-view | src/services/view-manager.js | function(id, view) {
// No id
if(!id) {
throw new Error('View requires an id.');
// Require unique id
} else if(_viewHash[id]) {
throw new Error('View requires a unique id');
// Add
} else {
_viewHash[id] = view;
}
// Check if view is currently active
var current... | javascript | function(id, view) {
// No id
if(!id) {
throw new Error('View requires an id.');
// Require unique id
} else if(_viewHash[id]) {
throw new Error('View requires a unique id');
// Add
} else {
_viewHash[id] = view;
}
// Check if view is currently active
var current... | [
"function",
"(",
"id",
",",
"view",
")",
"{",
"// No id",
"if",
"(",
"!",
"id",
")",
"{",
"throw",
"new",
"Error",
"(",
"'View requires an id.'",
")",
";",
"// Require unique id",
"}",
"else",
"if",
"(",
"_viewHash",
"[",
"id",
"]",
")",
"{",
"throw",
... | Register a view, also implements destroy method on view to unregister from manager
@param {String} id Unique identifier for view
@param {View} view A view instance
@return {$viewManager} Itself, chainable | [
"Register",
"a",
"view",
"also",
"implements",
"destroy",
"method",
"on",
"view",
"to",
"unregister",
"from",
"manager"
] | cf27c3a5cf65289501957e4dce3b75e7abef4def | https://github.com/henrytseng/angular-state-view/blob/cf27c3a5cf65289501957e4dce3b75e7abef4def/src/services/view-manager.js#L124-L152 | train | |
synder/xpress | demo/body-parser/lib/read.js | read | function read (req, res, next, parse, debug, options) {
var length
var opts = options || {}
var stream
// flag as parsed
req._body = true
// read options
var encoding = opts.encoding !== null
? opts.encoding || 'utf-8'
: null
var verify = opts.verify
try {
// get the content stream
... | javascript | function read (req, res, next, parse, debug, options) {
var length
var opts = options || {}
var stream
// flag as parsed
req._body = true
// read options
var encoding = opts.encoding !== null
? opts.encoding || 'utf-8'
: null
var verify = opts.verify
try {
// get the content stream
... | [
"function",
"read",
"(",
"req",
",",
"res",
",",
"next",
",",
"parse",
",",
"debug",
",",
"options",
")",
"{",
"var",
"length",
"var",
"opts",
"=",
"options",
"||",
"{",
"}",
"var",
"stream",
"// flag as parsed",
"req",
".",
"_body",
"=",
"true",
"//... | Read a request into a buffer and parse.
@param {object} req
@param {object} res
@param {function} next
@param {function} parse
@param {function} debug
@param {object} [options]
@api private | [
"Read",
"a",
"request",
"into",
"a",
"buffer",
"and",
"parse",
"."
] | 4b1e89208b6f34cd78ce90b8a858592115b6ccb5 | https://github.com/synder/xpress/blob/4b1e89208b6f34cd78ce90b8a858592115b6ccb5/demo/body-parser/lib/read.js#L38-L131 | train |
synder/xpress | demo/body-parser/lib/read.js | contentstream | function contentstream (req, debug, inflate) {
var encoding = (req.headers['content-encoding'] || 'identity').toLowerCase()
var length = req.headers['content-length']
var stream
debug('content-encoding "%s"', encoding)
if (inflate === false && encoding !== 'identity') {
throw createError(415, 'content e... | javascript | function contentstream (req, debug, inflate) {
var encoding = (req.headers['content-encoding'] || 'identity').toLowerCase()
var length = req.headers['content-length']
var stream
debug('content-encoding "%s"', encoding)
if (inflate === false && encoding !== 'identity') {
throw createError(415, 'content e... | [
"function",
"contentstream",
"(",
"req",
",",
"debug",
",",
"inflate",
")",
"{",
"var",
"encoding",
"=",
"(",
"req",
".",
"headers",
"[",
"'content-encoding'",
"]",
"||",
"'identity'",
")",
".",
"toLowerCase",
"(",
")",
"var",
"length",
"=",
"req",
".",
... | Get the content stream of the request.
@param {object} req
@param {function} debug
@param {boolean} [inflate=true]
@return {object}
@api private | [
"Get",
"the",
"content",
"stream",
"of",
"the",
"request",
"."
] | 4b1e89208b6f34cd78ce90b8a858592115b6ccb5 | https://github.com/synder/xpress/blob/4b1e89208b6f34cd78ce90b8a858592115b6ccb5/demo/body-parser/lib/read.js#L143-L176 | train |
synder/xpress | demo/body-parser/lib/read.js | setErrorStatus | function setErrorStatus (error, status) {
if (!error.status && !error.statusCode) {
error.status = status
error.statusCode = status
}
} | javascript | function setErrorStatus (error, status) {
if (!error.status && !error.statusCode) {
error.status = status
error.statusCode = status
}
} | [
"function",
"setErrorStatus",
"(",
"error",
",",
"status",
")",
"{",
"if",
"(",
"!",
"error",
".",
"status",
"&&",
"!",
"error",
".",
"statusCode",
")",
"{",
"error",
".",
"status",
"=",
"status",
"error",
".",
"statusCode",
"=",
"status",
"}",
"}"
] | Set a status on an error object, if ones does not exist
@private | [
"Set",
"a",
"status",
"on",
"an",
"error",
"object",
"if",
"ones",
"does",
"not",
"exist"
] | 4b1e89208b6f34cd78ce90b8a858592115b6ccb5 | https://github.com/synder/xpress/blob/4b1e89208b6f34cd78ce90b8a858592115b6ccb5/demo/body-parser/lib/read.js#L183-L188 | train |
jonschlinkert/file-contents | utils.js | syncContents | function syncContents(file, val) {
switch (utils.typeOf(val)) {
case 'buffer':
file._contents = val;
file._content = val.toString();
break;
case 'string':
file._contents = new Buffer(val);
file._content = val;
break;
case 'stream':
file._contents = val;
file... | javascript | function syncContents(file, val) {
switch (utils.typeOf(val)) {
case 'buffer':
file._contents = val;
file._content = val.toString();
break;
case 'string':
file._contents = new Buffer(val);
file._content = val;
break;
case 'stream':
file._contents = val;
file... | [
"function",
"syncContents",
"(",
"file",
",",
"val",
")",
"{",
"switch",
"(",
"utils",
".",
"typeOf",
"(",
"val",
")",
")",
"{",
"case",
"'buffer'",
":",
"file",
".",
"_contents",
"=",
"val",
";",
"file",
".",
"_content",
"=",
"val",
".",
"toString",... | Sync the _content and _contents properties on a view to ensure
both are set when setting either.
@param {Object} `view` instance of a `View`
@param {String|Buffer|Stream|null} `contents` contents to set on both properties | [
"Sync",
"the",
"_content",
"and",
"_contents",
"properties",
"on",
"a",
"view",
"to",
"ensure",
"both",
"are",
"set",
"when",
"setting",
"either",
"."
] | a53dcc62a1a529fc5f8b1dc0fa2a76a3196236fa | https://github.com/jonschlinkert/file-contents/blob/a53dcc62a1a529fc5f8b1dc0fa2a76a3196236fa/utils.js#L121-L143 | train |
mchalapuk/hyper-text-slider | lib/utils/elements.spec-helper.js | createElement | function createElement(nodeName) {
var elem = document.createElement(nodeName);
elem.className = [].join.call(arguments, ' ');
return elem;
} | javascript | function createElement(nodeName) {
var elem = document.createElement(nodeName);
elem.className = [].join.call(arguments, ' ');
return elem;
} | [
"function",
"createElement",
"(",
"nodeName",
")",
"{",
"var",
"elem",
"=",
"document",
".",
"createElement",
"(",
"nodeName",
")",
";",
"elem",
".",
"className",
"=",
"[",
"]",
".",
"join",
".",
"call",
"(",
"arguments",
",",
"' '",
")",
";",
"return"... | Creates element with given nodeName and className. | [
"Creates",
"element",
"with",
"given",
"nodeName",
"and",
"className",
"."
] | 2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4 | https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/utils/elements.spec-helper.js#L25-L29 | train |
mchalapuk/hyper-text-slider | lib/utils/elements.spec-helper.js | createSliderElement | function createSliderElement(slidesCount) {
var sliderElement = createElement('div', Layout.SLIDER);
for (var i = 0; i < slidesCount; ++i) {
sliderElement.appendChild(createElement('div', Layout.SLIDE));
}
return sliderElement;
} | javascript | function createSliderElement(slidesCount) {
var sliderElement = createElement('div', Layout.SLIDER);
for (var i = 0; i < slidesCount; ++i) {
sliderElement.appendChild(createElement('div', Layout.SLIDE));
}
return sliderElement;
} | [
"function",
"createSliderElement",
"(",
"slidesCount",
")",
"{",
"var",
"sliderElement",
"=",
"createElement",
"(",
"'div'",
",",
"Layout",
".",
"SLIDER",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"slidesCount",
";",
"++",
"i",
")",
"{... | Creates valid slider element containing slides of given count. | [
"Creates",
"valid",
"slider",
"element",
"containing",
"slides",
"of",
"given",
"count",
"."
] | 2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4 | https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/utils/elements.spec-helper.js#L34-L40 | train |
abarth500/density-clustering-kdtree-doping | OPTICS-KDTREE.js | OPTICS | function OPTICS(dataset, epsilon, minPts, distanceFunction) {
this.tree = null;
/** @type {number} */
this.epsilon = 1;
/** @type {number} */
this.minPts = 1;
/** @type {function} */
this.distance = this._euclideanDistance;
// temporary variables used during computation
/** @type {... | javascript | function OPTICS(dataset, epsilon, minPts, distanceFunction) {
this.tree = null;
/** @type {number} */
this.epsilon = 1;
/** @type {number} */
this.minPts = 1;
/** @type {function} */
this.distance = this._euclideanDistance;
// temporary variables used during computation
/** @type {... | [
"function",
"OPTICS",
"(",
"dataset",
",",
"epsilon",
",",
"minPts",
",",
"distanceFunction",
")",
"{",
"this",
".",
"tree",
"=",
"null",
";",
"/** @type {number} */",
"this",
".",
"epsilon",
"=",
"1",
";",
"/** @type {number} */",
"this",
".",
"minPts",
"="... | OPTICS - Ordering points to identify the clustering structure
@author Lukasz Krawczyk <contact@lukaszkrawczyk.eu>
@copyright MIT
OPTICS class constructor
@constructor
@param {Array} dataset
@param {number} epsilon
@param {number} minPts
@param {function} distanceFunction
@returns {OPTICS} | [
"OPTICS",
"-",
"Ordering",
"points",
"to",
"identify",
"the",
"clustering",
"structure"
] | 48cfdd75a1f71a65738e5ae016488109109bf308 | https://github.com/abarth500/density-clustering-kdtree-doping/blob/48cfdd75a1f71a65738e5ae016488109109bf308/OPTICS-KDTREE.js#L21-L42 | train |
abramz/gulp-render-react | lib/render-react.js | createElement | function createElement(filePath, props) {
if (!filePath || typeof filePath !== 'string' || filePath.length === 0) {
throw new Error('Expected filePath to be a string');
}
// clear the require cache if we have already imported the file (if we are watching it)
if (require.cache[filePath]) {
delete requir... | javascript | function createElement(filePath, props) {
if (!filePath || typeof filePath !== 'string' || filePath.length === 0) {
throw new Error('Expected filePath to be a string');
}
// clear the require cache if we have already imported the file (if we are watching it)
if (require.cache[filePath]) {
delete requir... | [
"function",
"createElement",
"(",
"filePath",
",",
"props",
")",
"{",
"if",
"(",
"!",
"filePath",
"||",
"typeof",
"filePath",
"!==",
"'string'",
"||",
"filePath",
".",
"length",
"===",
"0",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Expected filePath to be a ... | Requires a file containing a React component and create an instance of it
@param {String} filePath file path to the React component to render
@param {Object} props properties to apply to the element
@return {Element} the created React element
/*! Gulp Render React | MIT License | [
"Requires",
"a",
"file",
"containing",
"a",
"React",
"component",
"and",
"create",
"an",
"instance",
"of",
"it"
] | eff4c10f0070837e704aa766b82221127ef315fd | https://github.com/abramz/gulp-render-react/blob/eff4c10f0070837e704aa766b82221127ef315fd/lib/render-react.js#L14-L28 | train |
MatAtBread/nodent-transform | arboriculture.js | transformForIn | function transformForIn(node, path) {
var label = node.$label;
delete node.$label;
var idx = ident(generateSymbol("idx"));
var inArray = ident(generateSymbol("in"));
var declVars = parsePart("var $0,$1 = [];for ($0 in $2) $1.push($0)", [idx,
inArray,node.right]).body;... | javascript | function transformForIn(node, path) {
var label = node.$label;
delete node.$label;
var idx = ident(generateSymbol("idx"));
var inArray = ident(generateSymbol("in"));
var declVars = parsePart("var $0,$1 = [];for ($0 in $2) $1.push($0)", [idx,
inArray,node.right]).body;... | [
"function",
"transformForIn",
"(",
"node",
",",
"path",
")",
"{",
"var",
"label",
"=",
"node",
".",
"$label",
";",
"delete",
"node",
".",
"$label",
";",
"var",
"idx",
"=",
"ident",
"(",
"generateSymbol",
"(",
"\"idx\"",
")",
")",
";",
"var",
"inArray",... | Transform a for..in into it's iterative equivalent | [
"Transform",
"a",
"for",
"..",
"in",
"into",
"it",
"s",
"iterative",
"equivalent"
] | 40d61ad20b0a87fb83d420fd98ba01adbff73cac | https://github.com/MatAtBread/nodent-transform/blob/40d61ad20b0a87fb83d420fd98ba01adbff73cac/arboriculture.js#L1152-L1170 | train |
MatAtBread/nodent-transform | arboriculture.js | iterizeForOf | function iterizeForOf(node, path) {
if (node.body.type !== 'BlockStatement') {
node.body = {
type: 'BlockStatement',
body: [node.body]
};
}
var index, iterator, initIterator = parsePart("[$0[Symbol.iterator]()]", [node.right]).expr;
... | javascript | function iterizeForOf(node, path) {
if (node.body.type !== 'BlockStatement') {
node.body = {
type: 'BlockStatement',
body: [node.body]
};
}
var index, iterator, initIterator = parsePart("[$0[Symbol.iterator]()]", [node.right]).expr;
... | [
"function",
"iterizeForOf",
"(",
"node",
",",
"path",
")",
"{",
"if",
"(",
"node",
".",
"body",
".",
"type",
"!==",
"'BlockStatement'",
")",
"{",
"node",
".",
"body",
"=",
"{",
"type",
":",
"'BlockStatement'",
",",
"body",
":",
"[",
"node",
".",
"bod... | Transform a for..of into it's iterative equivalent | [
"Transform",
"a",
"for",
"..",
"of",
"into",
"it",
"s",
"iterative",
"equivalent"
] | 40d61ad20b0a87fb83d420fd98ba01adbff73cac | https://github.com/MatAtBread/nodent-transform/blob/40d61ad20b0a87fb83d420fd98ba01adbff73cac/arboriculture.js#L1173-L1222 | train |
MatAtBread/nodent-transform | arboriculture.js | mappableLoop | function mappableLoop(n) {
return n.type === 'AwaitExpression' && !n.$hidden || inAsyncLoop && (n.type === 'BreakStatement' || n.type === 'ContinueStatement') && n.label;
} | javascript | function mappableLoop(n) {
return n.type === 'AwaitExpression' && !n.$hidden || inAsyncLoop && (n.type === 'BreakStatement' || n.type === 'ContinueStatement') && n.label;
} | [
"function",
"mappableLoop",
"(",
"n",
")",
"{",
"return",
"n",
".",
"type",
"===",
"'AwaitExpression'",
"&&",
"!",
"n",
".",
"$hidden",
"||",
"inAsyncLoop",
"&&",
"(",
"n",
".",
"type",
"===",
"'BreakStatement'",
"||",
"n",
".",
"type",
"===",
"'Continue... | Check if the loop contains an await, or a labelled exit if we're inside an async loop | [
"Check",
"if",
"the",
"loop",
"contains",
"an",
"await",
"or",
"a",
"labelled",
"exit",
"if",
"we",
"re",
"inside",
"an",
"async",
"loop"
] | 40d61ad20b0a87fb83d420fd98ba01adbff73cac | https://github.com/MatAtBread/nodent-transform/blob/40d61ad20b0a87fb83d420fd98ba01adbff73cac/arboriculture.js#L1238-L1240 | train |
MatAtBread/nodent-transform | arboriculture.js | function (label) {
return {
type: 'ReturnStatement',
argument: {
type: 'UnaryExpression',
operator: 'void',
prefix: true,
argument: {
... | javascript | function (label) {
return {
type: 'ReturnStatement',
argument: {
type: 'UnaryExpression',
operator: 'void',
prefix: true,
argument: {
... | [
"function",
"(",
"label",
")",
"{",
"return",
"{",
"type",
":",
"'ReturnStatement'",
",",
"argument",
":",
"{",
"type",
":",
"'UnaryExpression'",
",",
"operator",
":",
"'void'",
",",
"prefix",
":",
"true",
",",
"argument",
":",
"{",
"type",
":",
"'CallEx... | How to exit the loop | [
"How",
"to",
"exit",
"the",
"loop"
] | 40d61ad20b0a87fb83d420fd98ba01adbff73cac | https://github.com/MatAtBread/nodent-transform/blob/40d61ad20b0a87fb83d420fd98ba01adbff73cac/arboriculture.js#L1544-L1558 | train | |
fknussel/custom-scripts | utils/index.js | checkRequiredFiles | function checkRequiredFiles() {
const indexHtmlExists = fse.existsSync(paths.indexHtml);
const indexJsExists = fse.existsSync(paths.indexJs);
if (!indexHtmlExists || !indexJsExists) {
logError('\nSome required files couldn\'t be found. Make sure these all exist:\n');
logError(`\t- ${paths.indexHtml}`);
... | javascript | function checkRequiredFiles() {
const indexHtmlExists = fse.existsSync(paths.indexHtml);
const indexJsExists = fse.existsSync(paths.indexJs);
if (!indexHtmlExists || !indexJsExists) {
logError('\nSome required files couldn\'t be found. Make sure these all exist:\n');
logError(`\t- ${paths.indexHtml}`);
... | [
"function",
"checkRequiredFiles",
"(",
")",
"{",
"const",
"indexHtmlExists",
"=",
"fse",
".",
"existsSync",
"(",
"paths",
".",
"indexHtml",
")",
";",
"const",
"indexJsExists",
"=",
"fse",
".",
"existsSync",
"(",
"paths",
".",
"indexJs",
")",
";",
"if",
"("... | Warn and crash if required files are missing. | [
"Warn",
"and",
"crash",
"if",
"required",
"files",
"are",
"missing",
"."
] | 801ad6f42bcde265e317d427b7ee0f371eeb0e9b | https://github.com/fknussel/custom-scripts/blob/801ad6f42bcde265e317d427b7ee0f371eeb0e9b/utils/index.js#L41-L52 | train |
fknussel/custom-scripts | utils/index.js | printErrors | function printErrors(summary, errors) {
logError(`${summary}\n`);
errors.forEach(err => {
logError(`\t- ${err.message || err}`);
});
console.log();
} | javascript | function printErrors(summary, errors) {
logError(`${summary}\n`);
errors.forEach(err => {
logError(`\t- ${err.message || err}`);
});
console.log();
} | [
"function",
"printErrors",
"(",
"summary",
",",
"errors",
")",
"{",
"logError",
"(",
"`",
"${",
"summary",
"}",
"\\n",
"`",
")",
";",
"errors",
".",
"forEach",
"(",
"err",
"=>",
"{",
"logError",
"(",
"`",
"\\t",
"${",
"err",
".",
"message",
"||",
"... | Print out a list of errors to the terminal. | [
"Print",
"out",
"a",
"list",
"of",
"errors",
"to",
"the",
"terminal",
"."
] | 801ad6f42bcde265e317d427b7ee0f371eeb0e9b | https://github.com/fknussel/custom-scripts/blob/801ad6f42bcde265e317d427b7ee0f371eeb0e9b/utils/index.js#L77-L85 | train |
vid/SenseBase | lib/pubsub.js | changeAnnotationState | function changeAnnotationState(combo, username) {
combo.annotations.forEach(function(anno) {
anno.state = combo.state;
});
contentLib.indexContentItem({uri: combo.uri}, { member: username , annotations: combo.annotations} );
} | javascript | function changeAnnotationState(combo, username) {
combo.annotations.forEach(function(anno) {
anno.state = combo.state;
});
contentLib.indexContentItem({uri: combo.uri}, { member: username , annotations: combo.annotations} );
} | [
"function",
"changeAnnotationState",
"(",
"combo",
",",
"username",
")",
"{",
"combo",
".",
"annotations",
".",
"forEach",
"(",
"function",
"(",
"anno",
")",
"{",
"anno",
".",
"state",
"=",
"combo",
".",
"state",
";",
"}",
")",
";",
"contentLib",
".",
... | Annotations functions FIXME change the state of annotations | [
"Annotations",
"functions",
"FIXME",
"change",
"the",
"state",
"of",
"annotations"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/pubsub.js#L320-L326 | train |
vid/SenseBase | lib/pubsub.js | publishUpdate | function publishUpdate(combo) {
GLOBAL.svc.indexer.retrieveByURI(combo.uri, function(err, res) {
if (!err && res && res._source) {
res = res._source;
combo.selector = 'body';
combo.text = res.text;
combo.content = res.content;
fayeClient.publish('/item/annotations/annotat... | javascript | function publishUpdate(combo) {
GLOBAL.svc.indexer.retrieveByURI(combo.uri, function(err, res) {
if (!err && res && res._source) {
res = res._source;
combo.selector = 'body';
combo.text = res.text;
combo.content = res.content;
fayeClient.publish('/item/annotations/annotat... | [
"function",
"publishUpdate",
"(",
"combo",
")",
"{",
"GLOBAL",
".",
"svc",
".",
"indexer",
".",
"retrieveByURI",
"(",
"combo",
".",
"uri",
",",
"function",
"(",
"err",
",",
"res",
")",
"{",
"if",
"(",
"!",
"err",
"&&",
"res",
"&&",
"res",
".",
"_so... | Request an update for this URI, optionally from a specific member | [
"Request",
"an",
"update",
"for",
"this",
"URI",
"optionally",
"from",
"a",
"specific",
"member"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/pubsub.js#L329-L342 | train |
vid/SenseBase | lib/pubsub.js | debounceUpdate | function debounceUpdate(combo) {
bouncedUpdates[combo.uri] = combo;
if (Object.keys(bouncedUpdates).length < bounceHold) {
clearTimeout(bounceTimeout);
bounceTimeout = setTimeout(function() {
var toDebounce = Object.keys(bouncedUpdates).map(function(b) { return bouncedUpdates[b]; }... | javascript | function debounceUpdate(combo) {
bouncedUpdates[combo.uri] = combo;
if (Object.keys(bouncedUpdates).length < bounceHold) {
clearTimeout(bounceTimeout);
bounceTimeout = setTimeout(function() {
var toDebounce = Object.keys(bouncedUpdates).map(function(b) { return bouncedUpdates[b]; }... | [
"function",
"debounceUpdate",
"(",
"combo",
")",
"{",
"bouncedUpdates",
"[",
"combo",
".",
"uri",
"]",
"=",
"combo",
";",
"if",
"(",
"Object",
".",
"keys",
"(",
"bouncedUpdates",
")",
".",
"length",
"<",
"bounceHold",
")",
"{",
"clearTimeout",
"(",
"boun... | batch updates per a size or time frame. note bounceHold may be exceeded due to the delay. | [
"batch",
"updates",
"per",
"a",
"size",
"or",
"time",
"frame",
".",
"note",
"bounceHold",
"may",
"be",
"exceeded",
"due",
"to",
"the",
"delay",
"."
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/pubsub.js#L345-L355 | train |
vid/SenseBase | lib/pubsub.js | adjureAnnotators | function adjureAnnotators(uris, annotators) {
GLOBAL.info('/item/annotations/adjure annotators'.yellow, uris, JSON.stringify(annotators));
uris.forEach(function(uri) {
annotators.forEach(function(member) {
publishUpdate({ uri: uri, member: member});
});
});
} | javascript | function adjureAnnotators(uris, annotators) {
GLOBAL.info('/item/annotations/adjure annotators'.yellow, uris, JSON.stringify(annotators));
uris.forEach(function(uri) {
annotators.forEach(function(member) {
publishUpdate({ uri: uri, member: member});
});
});
} | [
"function",
"adjureAnnotators",
"(",
"uris",
",",
"annotators",
")",
"{",
"GLOBAL",
".",
"info",
"(",
"'/item/annotations/adjure annotators'",
".",
"yellow",
",",
"uris",
",",
"JSON",
".",
"stringify",
"(",
"annotators",
")",
")",
";",
"uris",
".",
"forEach",
... | Publish annotation requests for specific annotators for the uris | [
"Publish",
"annotation",
"requests",
"for",
"specific",
"annotators",
"for",
"the",
"uris"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/pubsub.js#L358-L365 | train |
vid/SenseBase | lib/pubsub.js | adjureAnnotations | function adjureAnnotations(uris, annotations, username) {
GLOBAL.info('/item/annotations/adjure annotations'.yellow, username.blue, uris, annotations.length);
try {
var user = GLOBAL.svc.auth.getUserByUsername(username);
if (!user) {
throw new Error("no user " + username);
}
uris... | javascript | function adjureAnnotations(uris, annotations, username) {
GLOBAL.info('/item/annotations/adjure annotations'.yellow, username.blue, uris, annotations.length);
try {
var user = GLOBAL.svc.auth.getUserByUsername(username);
if (!user) {
throw new Error("no user " + username);
}
uris... | [
"function",
"adjureAnnotations",
"(",
"uris",
",",
"annotations",
",",
"username",
")",
"{",
"GLOBAL",
".",
"info",
"(",
"'/item/annotations/adjure annotations'",
".",
"yellow",
",",
"username",
".",
"blue",
",",
"uris",
",",
"annotations",
".",
"length",
")",
... | apply annotations for the uris | [
"apply",
"annotations",
"for",
"the",
"uris"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/pubsub.js#L368-L402 | train |
vid/SenseBase | lib/pubsub.js | publish | function publish(channel, data, clientID) {
if (clientID) {
channel += '/' + clientID;
}
fayeClient.publish(channel, data);
} | javascript | function publish(channel, data, clientID) {
if (clientID) {
channel += '/' + clientID;
}
fayeClient.publish(channel, data);
} | [
"function",
"publish",
"(",
"channel",
",",
"data",
",",
"clientID",
")",
"{",
"if",
"(",
"clientID",
")",
"{",
"channel",
"+=",
"'/'",
"+",
"clientID",
";",
"}",
"fayeClient",
".",
"publish",
"(",
"channel",
",",
"data",
")",
";",
"}"
] | Publish data to a general or client specific channel if clientID is present. | [
"Publish",
"data",
"to",
"a",
"general",
"or",
"client",
"specific",
"channel",
"if",
"clientID",
"is",
"present",
"."
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/pubsub.js#L405-L410 | train |
feedhenry/fh-mbaas-client | lib/MbaasClient.js | MbaasClient | function MbaasClient(envId, mbaasConf) {
this.envId = envId;
this.mbaasConfig = mbaasConf;
this.setMbaasUrl();
this.app = {};
this.admin = {};
proxy(this.app, app, this.mbaasConfig);
proxy(this.admin, admin, this.mbaasConfig);
} | javascript | function MbaasClient(envId, mbaasConf) {
this.envId = envId;
this.mbaasConfig = mbaasConf;
this.setMbaasUrl();
this.app = {};
this.admin = {};
proxy(this.app, app, this.mbaasConfig);
proxy(this.admin, admin, this.mbaasConfig);
} | [
"function",
"MbaasClient",
"(",
"envId",
",",
"mbaasConf",
")",
"{",
"this",
".",
"envId",
"=",
"envId",
";",
"this",
".",
"mbaasConfig",
"=",
"mbaasConf",
";",
"this",
".",
"setMbaasUrl",
"(",
")",
";",
"this",
".",
"app",
"=",
"{",
"}",
";",
"this"... | Create a new instance of MbaasClient
@param envId the id of the environment
@param mbaasConf the mbaas configuration
@constructor | [
"Create",
"a",
"new",
"instance",
"of",
"MbaasClient"
] | 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/MbaasClient.js#L12-L20 | train |
rat-nest/big-rat | to-float.js | roundRat | function roundRat (f) {
var a = f[0]
var b = f[1]
if (a.cmpn(0) === 0) {
return 0
}
var h = a.abs().divmod(b.abs())
var iv = h.div
var x = bn2num(iv)
var ir = h.mod
var sgn = (a.negative !== b.negative) ? -1 : 1
if (ir.cmpn(0) === 0) {
return sgn * x
}
if (x) {
var s = ctz(x) + 4
... | javascript | function roundRat (f) {
var a = f[0]
var b = f[1]
if (a.cmpn(0) === 0) {
return 0
}
var h = a.abs().divmod(b.abs())
var iv = h.div
var x = bn2num(iv)
var ir = h.mod
var sgn = (a.negative !== b.negative) ? -1 : 1
if (ir.cmpn(0) === 0) {
return sgn * x
}
if (x) {
var s = ctz(x) + 4
... | [
"function",
"roundRat",
"(",
"f",
")",
"{",
"var",
"a",
"=",
"f",
"[",
"0",
"]",
"var",
"b",
"=",
"f",
"[",
"1",
"]",
"if",
"(",
"a",
".",
"cmpn",
"(",
"0",
")",
"===",
"0",
")",
"{",
"return",
"0",
"}",
"var",
"h",
"=",
"a",
".",
"abs"... | Round a rational to the closest float | [
"Round",
"a",
"rational",
"to",
"the",
"closest",
"float"
] | 09aabcf6d51a326dce0e4bdeedb159c9ce6b0efa | https://github.com/rat-nest/big-rat/blob/09aabcf6d51a326dce0e4bdeedb159c9ce6b0efa/to-float.js#L9-L36 | train |
onecommons/base | lib/passport.js | function(req, token, refreshToken, profile, done) {
// asynchronous
process.nextTick(function() {
var User = app.userModel;
// find the user in the database based on their facebook id
User.findOne({ 'facebook.id' : profile.id }, function(err, user) {
... | javascript | function(req, token, refreshToken, profile, done) {
// asynchronous
process.nextTick(function() {
var User = app.userModel;
// find the user in the database based on their facebook id
User.findOne({ 'facebook.id' : profile.id }, function(err, user) {
... | [
"function",
"(",
"req",
",",
"token",
",",
"refreshToken",
",",
"profile",
",",
"done",
")",
"{",
"// asynchronous",
"process",
".",
"nextTick",
"(",
"function",
"(",
")",
"{",
"var",
"User",
"=",
"app",
".",
"userModel",
";",
"// find the user in the databa... | facebook will send back the token and profile | [
"facebook",
"will",
"send",
"back",
"the",
"token",
"and",
"profile"
] | 4f35d9f714d0367b0622a3504802363404290246 | https://github.com/onecommons/base/blob/4f35d9f714d0367b0622a3504802363404290246/lib/passport.js#L291-L339 | train | |
feedhenry/fh-mbaas-client | lib/admin/alerts/notifications.js | listNotifications | function listNotifications(params, cb) {
params.resourcePath = config.addURIParams(constants.NOTIFICATIONS_BASE_PATH, params);
params.method = 'GET';
params.data = params.data || {};
mbaasRequest.admin(params, cb);
} | javascript | function listNotifications(params, cb) {
params.resourcePath = config.addURIParams(constants.NOTIFICATIONS_BASE_PATH, params);
params.method = 'GET';
params.data = params.data || {};
mbaasRequest.admin(params, cb);
} | [
"function",
"listNotifications",
"(",
"params",
",",
"cb",
")",
"{",
"params",
".",
"resourcePath",
"=",
"config",
".",
"addURIParams",
"(",
"constants",
".",
"NOTIFICATIONS_BASE_PATH",
",",
"params",
")",
";",
"params",
".",
"method",
"=",
"'GET'",
";",
"pa... | List Notifications on an MBaaS
@param params
@param cb | [
"List",
"Notifications",
"on",
"an",
"MBaaS"
] | 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/admin/alerts/notifications.js#L10-L16 | train |
mchalapuk/hyper-text-slider | lib/core/boot.js | boot | function boot(containerElement) {
check(containerElement, 'containerElement').is.anInstanceOf(Element)();
var containerOptions = getEnabledOptions(containerElement);
var sliderElems = concatUnique(
[].slice.call(containerElement.querySelectorAll('.'+ Layout.SLIDER)),
[].slice.call(containerElement.qu... | javascript | function boot(containerElement) {
check(containerElement, 'containerElement').is.anInstanceOf(Element)();
var containerOptions = getEnabledOptions(containerElement);
var sliderElems = concatUnique(
[].slice.call(containerElement.querySelectorAll('.'+ Layout.SLIDER)),
[].slice.call(containerElement.qu... | [
"function",
"boot",
"(",
"containerElement",
")",
"{",
"check",
"(",
"containerElement",
",",
"'containerElement'",
")",
".",
"is",
".",
"anInstanceOf",
"(",
"Element",
")",
"(",
")",
";",
"var",
"containerOptions",
"=",
"getEnabledOptions",
"(",
"containerEleme... | Default HyperText Slider boot procedure.
For each element with ${link Layout.SLIDER} class name found in passed container
(typically document's `<body>`):
1. Adds ${link Option options class names} found on container element,
1. Creates ${link Slider} object,
2. Invokes its ${link Slider.prototype.start} method.
If ... | [
"Default",
"HyperText",
"Slider",
"boot",
"procedure",
"."
] | 2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4 | https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/core/boot.js#L53-L75 | train |
mchalapuk/hyper-text-slider | lib/core/boot.js | getEnabledOptions | function getEnabledOptions(element) {
var retVal = [];
Object.values(Option).forEach(function(option) {
if (element.classList.contains(option)) {
retVal.push(option);
}
});
return retVal;
} | javascript | function getEnabledOptions(element) {
var retVal = [];
Object.values(Option).forEach(function(option) {
if (element.classList.contains(option)) {
retVal.push(option);
}
});
return retVal;
} | [
"function",
"getEnabledOptions",
"(",
"element",
")",
"{",
"var",
"retVal",
"=",
"[",
"]",
";",
"Object",
".",
"values",
"(",
"Option",
")",
".",
"forEach",
"(",
"function",
"(",
"option",
")",
"{",
"if",
"(",
"element",
".",
"classList",
".",
"contain... | finds option class names on passed element | [
"finds",
"option",
"class",
"names",
"on",
"passed",
"element"
] | 2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4 | https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/core/boot.js#L78-L86 | train |
openmason/brook | index.js | publisher | function publisher(port) {
var socket = zeromq.socket('pub');
socket.identity = 'pub' + process.pid;
socket.connect(port);
console.log('publisher connected to ' + port);
// lets count messages / sec
var totalMessages=0;
setInterval(function() {
console.log('total messages sent = '+totalMessages);
... | javascript | function publisher(port) {
var socket = zeromq.socket('pub');
socket.identity = 'pub' + process.pid;
socket.connect(port);
console.log('publisher connected to ' + port);
// lets count messages / sec
var totalMessages=0;
setInterval(function() {
console.log('total messages sent = '+totalMessages);
... | [
"function",
"publisher",
"(",
"port",
")",
"{",
"var",
"socket",
"=",
"zeromq",
".",
"socket",
"(",
"'pub'",
")",
";",
"socket",
".",
"identity",
"=",
"'pub'",
"+",
"process",
".",
"pid",
";",
"socket",
".",
"connect",
"(",
"port",
")",
";",
"console... | lets do the publisher here | [
"lets",
"do",
"the",
"publisher",
"here"
] | 6d4e12d6c27e71948baab91d3e778fbae5a47245 | https://github.com/openmason/brook/blob/6d4e12d6c27e71948baab91d3e778fbae5a47245/index.js#L25-L45 | train |
openmason/brook | index.js | subscriber | function subscriber(port) {
var socket = zeromq.socket('sub');
socket.identity = 'sub' + process.pid;
// have to subscribe, otherwise nothing would show up
// subscribe to everything
socket.subscribe('');
var totalMessages=0;
// receive messages
socket.on('message', function(data) {
//console.log... | javascript | function subscriber(port) {
var socket = zeromq.socket('sub');
socket.identity = 'sub' + process.pid;
// have to subscribe, otherwise nothing would show up
// subscribe to everything
socket.subscribe('');
var totalMessages=0;
// receive messages
socket.on('message', function(data) {
//console.log... | [
"function",
"subscriber",
"(",
"port",
")",
"{",
"var",
"socket",
"=",
"zeromq",
".",
"socket",
"(",
"'sub'",
")",
";",
"socket",
".",
"identity",
"=",
"'sub'",
"+",
"process",
".",
"pid",
";",
"// have to subscribe, otherwise nothing would show up",
"// subscri... | lets do the subscriber here | [
"lets",
"do",
"the",
"subscriber",
"here"
] | 6d4e12d6c27e71948baab91d3e778fbae5a47245 | https://github.com/openmason/brook/blob/6d4e12d6c27e71948baab91d3e778fbae5a47245/index.js#L48-L73 | train |
openmason/brook | index.js | forwarder | function forwarder(frontPort, backPort) {
var frontSocket = zeromq.socket('sub'),
backSocket = zeromq.socket('pub');
frontSocket.identity = 'sub' + process.pid;
backSocket.identity = 'pub' + process.pid;
frontSocket.subscribe('');
frontSocket.bind(frontPort, function (err) {
console.log('bound', f... | javascript | function forwarder(frontPort, backPort) {
var frontSocket = zeromq.socket('sub'),
backSocket = zeromq.socket('pub');
frontSocket.identity = 'sub' + process.pid;
backSocket.identity = 'pub' + process.pid;
frontSocket.subscribe('');
frontSocket.bind(frontPort, function (err) {
console.log('bound', f... | [
"function",
"forwarder",
"(",
"frontPort",
",",
"backPort",
")",
"{",
"var",
"frontSocket",
"=",
"zeromq",
".",
"socket",
"(",
"'sub'",
")",
",",
"backSocket",
"=",
"zeromq",
".",
"socket",
"(",
"'pub'",
")",
";",
"frontSocket",
".",
"identity",
"=",
"'s... | create a forwarder device | [
"create",
"a",
"forwarder",
"device"
] | 6d4e12d6c27e71948baab91d3e778fbae5a47245 | https://github.com/openmason/brook/blob/6d4e12d6c27e71948baab91d3e778fbae5a47245/index.js#L76-L106 | train |
odogono/elsinore-js | src/util/loader_ex.js | createComponent | function createComponent(loader, obj) {
const entitySet = loader.entitySet;
// determine whether any attributes are refering to marked pois
obj = resolveMarkReferences(loader, obj);
// the alternative form is to use @uri
if (obj[CMD_COMPONENT_URI]) {
obj[CMD_COMPONENT] = obj[CMD_COMPONENT_... | javascript | function createComponent(loader, obj) {
const entitySet = loader.entitySet;
// determine whether any attributes are refering to marked pois
obj = resolveMarkReferences(loader, obj);
// the alternative form is to use @uri
if (obj[CMD_COMPONENT_URI]) {
obj[CMD_COMPONENT] = obj[CMD_COMPONENT_... | [
"function",
"createComponent",
"(",
"loader",
",",
"obj",
")",
"{",
"const",
"entitySet",
"=",
"loader",
".",
"entitySet",
";",
"// determine whether any attributes are refering to marked pois",
"obj",
"=",
"resolveMarkReferences",
"(",
"loader",
",",
"obj",
")",
";",... | return value; } | [
"return",
"value",
";",
"}"
] | 1ecce67ad0022646419a740def029b1ba92dd558 | https://github.com/odogono/elsinore-js/blob/1ecce67ad0022646419a740def029b1ba92dd558/src/util/loader_ex.js#L333-L365 | train |
odogono/elsinore-js | src/util/loader_ex.js | retrieveEntityByAttribute | async function retrieveEntityByAttribute(
entitySet,
componentID,
attribute,
value
) {
// Log.debug('[retrieveEntityByAttribute]', componentID, 'where', attribute, 'equals', value);
const query = Q => [
Q.all(componentID).where(Q.attr(attribute).equals(value)),
Q.limit(1)
];
... | javascript | async function retrieveEntityByAttribute(
entitySet,
componentID,
attribute,
value
) {
// Log.debug('[retrieveEntityByAttribute]', componentID, 'where', attribute, 'equals', value);
const query = Q => [
Q.all(componentID).where(Q.attr(attribute).equals(value)),
Q.limit(1)
];
... | [
"async",
"function",
"retrieveEntityByAttribute",
"(",
"entitySet",
",",
"componentID",
",",
"attribute",
",",
"value",
")",
"{",
"// Log.debug('[retrieveEntityByAttribute]', componentID, 'where', attribute, 'equals', value);",
"const",
"query",
"=",
"Q",
"=>",
"[",
"Q",
".... | Retrieves the first entity which has the specified component attribute value | [
"Retrieves",
"the",
"first",
"entity",
"which",
"has",
"the",
"specified",
"component",
"attribute",
"value"
] | 1ecce67ad0022646419a740def029b1ba92dd558 | https://github.com/odogono/elsinore-js/blob/1ecce67ad0022646419a740def029b1ba92dd558/src/util/loader_ex.js#L533-L564 | train |
webida/webida-restful-api | src/api/SessionApi.js | function(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
/**
* Callback function to receive the result of the closeSessions operation.
* @callback module:api/SessionApi~closeSessionsCallback
* @param {String} error Error message, if any.
* @param {module:model/RestOK} data T... | javascript | function(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
/**
* Callback function to receive the result of the closeSessions operation.
* @callback module:api/SessionApi~closeSessionsCallback
* @param {String} error Error message, if any.
* @param {module:model/RestOK} data T... | [
"function",
"(",
"apiClient",
")",
"{",
"this",
".",
"apiClient",
"=",
"apiClient",
"||",
"ApiClient",
".",
"instance",
";",
"/**\n * Callback function to receive the result of the closeSessions operation.\n * @callback module:api/SessionApi~closeSessionsCallback\n * @param... | Session service.
@module api/SessionApi
@version 0.7.1
Constructs a new SessionApi.
@alias module:api/SessionApi
@class
@param {module:ApiClient} apiClient Optional API client implementation to use,
default to {@link module:ApiClient#instance} if unspecified. | [
"Session",
"service",
"."
] | a14385ebe0de025b66fd4ee9655e962313528e28 | https://github.com/webida/webida-restful-api/blob/a14385ebe0de025b66fd4ee9655e962313528e28/src/api/SessionApi.js#L55-L169 | train | |
yo-components/yo-utils | lib/templating.js | relativePathTo | function relativePathTo(from, to, strip) {
var relPath = path.relative(from.replace(path.basename(from), ''), to);
if (relPath.match(/^\.\.?(\/|\\)/) === null) { relPath = './' + relPath; }
if (strip) { return relPath.replace(/((\/|\\)index\.js|\.js)$/, ''); }
return relPath;
} | javascript | function relativePathTo(from, to, strip) {
var relPath = path.relative(from.replace(path.basename(from), ''), to);
if (relPath.match(/^\.\.?(\/|\\)/) === null) { relPath = './' + relPath; }
if (strip) { return relPath.replace(/((\/|\\)index\.js|\.js)$/, ''); }
return relPath;
} | [
"function",
"relativePathTo",
"(",
"from",
",",
"to",
",",
"strip",
")",
"{",
"var",
"relPath",
"=",
"path",
".",
"relative",
"(",
"from",
".",
"replace",
"(",
"path",
".",
"basename",
"(",
"from",
")",
",",
"''",
")",
",",
"to",
")",
";",
"if",
... | Templating related utilities
@module yo-utils/lib/templating
Returns a relative path used to require the 'to' file in the 'from' file
@alias module:yo-utils/lib/templating.relativePathTo
@param {String} from - file path to the from file
@param {String} to - file path to the to file
@param {Boolean} strip - w... | [
"Templating",
"related",
"utilities"
] | 975801cee23886debf0b43e43cd76e43705f321d | https://github.com/yo-components/yo-utils/blob/975801cee23886debf0b43e43cd76e43705f321d/lib/templating.js#L26-L31 | train |
yo-components/yo-utils | lib/templating.js | filterFile | function filterFile(template) {
// Find matches for parans
var filterMatches = template.match(/\(([^)]+)\)/g);
var filters = [];
if (filterMatches) {
filterMatches.forEach(function(filter) {
filters.push(filter.replace('(', '').replace(')', ''));
template = template.replace(filter, '');
});
... | javascript | function filterFile(template) {
// Find matches for parans
var filterMatches = template.match(/\(([^)]+)\)/g);
var filters = [];
if (filterMatches) {
filterMatches.forEach(function(filter) {
filters.push(filter.replace('(', '').replace(')', ''));
template = template.replace(filter, '');
});
... | [
"function",
"filterFile",
"(",
"template",
")",
"{",
"// Find matches for parans",
"var",
"filterMatches",
"=",
"template",
".",
"match",
"(",
"/",
"\\(([^)]+)\\)",
"/",
"g",
")",
";",
"var",
"filters",
"=",
"[",
"]",
";",
"if",
"(",
"filterMatches",
")",
... | Parse a filtered filename and return the processed name and filters
@param {String} template - the file path to the template
@return {Object} - contains the processed name and filters array | [
"Parse",
"a",
"filtered",
"filename",
"and",
"return",
"the",
"processed",
"name",
"and",
"filters"
] | 975801cee23886debf0b43e43cd76e43705f321d | https://github.com/yo-components/yo-utils/blob/975801cee23886debf0b43e43cd76e43705f321d/lib/templating.js#L161-L173 | train |
yo-components/yo-utils | lib/templating.js | templateIsUsable | function templateIsUsable(self, filteredFile) {
var filters = self.config.get('filters');
var enabledFilters = [];
for (var key in filters) {
if (filters[key]) { enabledFilters.push(key); }
}
var matchedFilters = self._.intersection(filteredFile.filters, enabledFilters);
// check that all filters on fil... | javascript | function templateIsUsable(self, filteredFile) {
var filters = self.config.get('filters');
var enabledFilters = [];
for (var key in filters) {
if (filters[key]) { enabledFilters.push(key); }
}
var matchedFilters = self._.intersection(filteredFile.filters, enabledFilters);
// check that all filters on fil... | [
"function",
"templateIsUsable",
"(",
"self",
",",
"filteredFile",
")",
"{",
"var",
"filters",
"=",
"self",
".",
"config",
".",
"get",
"(",
"'filters'",
")",
";",
"var",
"enabledFilters",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"key",
"in",
"filters",
")... | Check whether or not a template is usable based on filters
@param {Object} self - the generator
@param {Object} filteredFile - the processed template object
@return {Boolean} - whether the template is usable based on filters | [
"Check",
"whether",
"or",
"not",
"a",
"template",
"is",
"usable",
"based",
"on",
"filters"
] | 975801cee23886debf0b43e43cd76e43705f321d | https://github.com/yo-components/yo-utils/blob/975801cee23886debf0b43e43cd76e43705f321d/lib/templating.js#L181-L193 | train |
synder/xpress | demo/content-disposition/index.js | format | function format(obj) {
var parameters = obj.parameters
var type = obj.type
if (!type || typeof type !== 'string' || !tokenRegExp.test(type)) {
throw new TypeError('invalid type')
}
// start with normalized type
var string = String(type).toLowerCase()
// append parameters
if (parameters && typeof ... | javascript | function format(obj) {
var parameters = obj.parameters
var type = obj.type
if (!type || typeof type !== 'string' || !tokenRegExp.test(type)) {
throw new TypeError('invalid type')
}
// start with normalized type
var string = String(type).toLowerCase()
// append parameters
if (parameters && typeof ... | [
"function",
"format",
"(",
"obj",
")",
"{",
"var",
"parameters",
"=",
"obj",
".",
"parameters",
"var",
"type",
"=",
"obj",
".",
"type",
"if",
"(",
"!",
"type",
"||",
"typeof",
"type",
"!==",
"'string'",
"||",
"!",
"tokenRegExp",
".",
"test",
"(",
"ty... | Format object to Content-Disposition header.
@param {object} obj
@param {string} obj.type
@param {object} [obj.parameters]
@return {string}
@api private | [
"Format",
"object",
"to",
"Content",
"-",
"Disposition",
"header",
"."
] | 4b1e89208b6f34cd78ce90b8a858592115b6ccb5 | https://github.com/synder/xpress/blob/4b1e89208b6f34cd78ce90b8a858592115b6ccb5/demo/content-disposition/index.js#L216-L244 | train |
synder/xpress | demo/content-disposition/index.js | pencode | function pencode(char) {
var hex = String(char)
.charCodeAt(0)
.toString(16)
.toUpperCase()
return hex.length === 1
? '%0' + hex
: '%' + hex
} | javascript | function pencode(char) {
var hex = String(char)
.charCodeAt(0)
.toString(16)
.toUpperCase()
return hex.length === 1
? '%0' + hex
: '%' + hex
} | [
"function",
"pencode",
"(",
"char",
")",
"{",
"var",
"hex",
"=",
"String",
"(",
"char",
")",
".",
"charCodeAt",
"(",
"0",
")",
".",
"toString",
"(",
"16",
")",
".",
"toUpperCase",
"(",
")",
"return",
"hex",
".",
"length",
"===",
"1",
"?",
"'%0'",
... | Percent encode a single character.
@param {string} char
@return {string}
@api private | [
"Percent",
"encode",
"a",
"single",
"character",
"."
] | 4b1e89208b6f34cd78ce90b8a858592115b6ccb5 | https://github.com/synder/xpress/blob/4b1e89208b6f34cd78ce90b8a858592115b6ccb5/demo/content-disposition/index.js#L396-L404 | train |
nodejitsu/contour | index.js | Contour | function Contour(options) {
var contour = this
, assets;
this.fuse();
//
// Add the pagelets of the required framework.
//
options = options || {};
//
// Load and optimize the pagelets, extend contour but acknowledge external
// listeners when all pagelets have been fully initialized.
//
as... | javascript | function Contour(options) {
var contour = this
, assets;
this.fuse();
//
// Add the pagelets of the required framework.
//
options = options || {};
//
// Load and optimize the pagelets, extend contour but acknowledge external
// listeners when all pagelets have been fully initialized.
//
as... | [
"function",
"Contour",
"(",
"options",
")",
"{",
"var",
"contour",
"=",
"this",
",",
"assets",
";",
"this",
".",
"fuse",
"(",
")",
";",
"//",
"// Add the pagelets of the required framework.",
"//",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"//",
"// ... | Contour will register several default HTML5 templates of Nodejitsu. These
templates can used from inside views of other projects.
Options that can be supplied
- brand {String} framework or brand to use, e.g nodejitsu or opsmezzo
- mode {String} bigpipe or standalone, defaults to bigpipe
@Constructor
@param {Object} o... | [
"Contour",
"will",
"register",
"several",
"default",
"HTML5",
"templates",
"of",
"Nodejitsu",
".",
"These",
"templates",
"can",
"used",
"from",
"inside",
"views",
"of",
"other",
"projects",
"."
] | 0828e9bd25ef1eeb97ea231c447118d9867021b6 | https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/index.js#L25-L43 | train |
NiklasGollenstede/pbq | require.js | defaultGetCallingScript | function defaultGetCallingScript(offset = 0) {
const stack = (new Error).stack.split(/$/m);
const line = stack[(/^Error/).test(stack[0]) + 1 + offset];
const parts = line.split(/@(?![^/]*?\.xpi)|\(|\s+/g);
return parts[parts.length - 1].replace(/:\d+(?::\d+)?\)?$/, '');
} | javascript | function defaultGetCallingScript(offset = 0) {
const stack = (new Error).stack.split(/$/m);
const line = stack[(/^Error/).test(stack[0]) + 1 + offset];
const parts = line.split(/@(?![^/]*?\.xpi)|\(|\s+/g);
return parts[parts.length - 1].replace(/:\d+(?::\d+)?\)?$/, '');
} | [
"function",
"defaultGetCallingScript",
"(",
"offset",
"=",
"0",
")",
"{",
"const",
"stack",
"=",
"(",
"new",
"Error",
")",
".",
"stack",
".",
"split",
"(",
"/",
"$",
"/",
"m",
")",
";",
"const",
"line",
"=",
"stack",
"[",
"(",
"/",
"^Error",
"/",
... | the other values in `loadConfig` will be interpreted later
string parsers | [
"the",
"other",
"values",
"in",
"loadConfig",
"will",
"be",
"interpreted",
"later",
"string",
"parsers"
] | bf63f17d63dc6030567a94a61490bec6254d3064 | https://github.com/NiklasGollenstede/pbq/blob/bf63f17d63dc6030567a94a61490bec6254d3064/require.js#L62-L67 | train |
NiklasGollenstede/pbq | require.js | next | function next(exp) {
exp.lastIndex = index;
const match = exp.exec(code)[0];
index = exp.lastIndex;
return match;
} | javascript | function next(exp) {
exp.lastIndex = index;
const match = exp.exec(code)[0];
index = exp.lastIndex;
return match;
} | [
"function",
"next",
"(",
"exp",
")",
"{",
"exp",
".",
"lastIndex",
"=",
"index",
";",
"const",
"match",
"=",
"exp",
".",
"exec",
"(",
"code",
")",
"[",
"0",
"]",
";",
"index",
"=",
"exp",
".",
"lastIndex",
";",
"return",
"match",
";",
"}"
] | the next position of interest | [
"the",
"next",
"position",
"of",
"interest"
] | bf63f17d63dc6030567a94a61490bec6254d3064 | https://github.com/NiklasGollenstede/pbq/blob/bf63f17d63dc6030567a94a61490bec6254d3064/require.js#L77-L82 | train |
nodejitsu/contour | assets.js | Assets | function Assets(brand, mode) {
var readable = Assets.predefine(this, Assets.predefine.READABLE)
, enumerable = Assets.predefine(this, { configurable: false })
, self = this
, i = 0
, files;
/**
* Callback to emit optimized event after all Pagelets have been optimized.
*
* @param {Error} er... | javascript | function Assets(brand, mode) {
var readable = Assets.predefine(this, Assets.predefine.READABLE)
, enumerable = Assets.predefine(this, { configurable: false })
, self = this
, i = 0
, files;
/**
* Callback to emit optimized event after all Pagelets have been optimized.
*
* @param {Error} er... | [
"function",
"Assets",
"(",
"brand",
",",
"mode",
")",
"{",
"var",
"readable",
"=",
"Assets",
".",
"predefine",
"(",
"this",
",",
"Assets",
".",
"predefine",
".",
"READABLE",
")",
",",
"enumerable",
"=",
"Assets",
".",
"predefine",
"(",
"this",
",",
"{"... | Create new collection of assets from a specific brand.
@param {String} brand nodejitsu by default.
@param {String} mode standalone || bigpipe, defaults to bigpipe.
@api public | [
"Create",
"new",
"collection",
"of",
"assets",
"from",
"a",
"specific",
"brand",
"."
] | 0828e9bd25ef1eeb97ea231c447118d9867021b6 | https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/assets.js#L23-L61 | train |
nodejitsu/contour | assets.js | next | function next(error) {
if (error) return self.emit('error', error);
if (++i === files.length) self.emit('optimized');
} | javascript | function next(error) {
if (error) return self.emit('error', error);
if (++i === files.length) self.emit('optimized');
} | [
"function",
"next",
"(",
"error",
")",
"{",
"if",
"(",
"error",
")",
"return",
"self",
".",
"emit",
"(",
"'error'",
",",
"error",
")",
";",
"if",
"(",
"++",
"i",
"===",
"files",
".",
"length",
")",
"self",
".",
"emit",
"(",
"'optimized'",
")",
";... | Callback to emit optimized event after all Pagelets have been optimized.
@param {Error} error
@api private | [
"Callback",
"to",
"emit",
"optimized",
"event",
"after",
"all",
"Pagelets",
"have",
"been",
"optimized",
"."
] | 0828e9bd25ef1eeb97ea231c447118d9867021b6 | https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/assets.js#L36-L39 | train |
jillix/flow-api | lib/_remove.js | getIn | function getIn (client, from, nodes, callback, remove) {
remove = remove || [];
const outNodes = [];
const nodeIndex = {};
const fromIndex = {};
if (from instanceof Array) {
from.forEach((node) => {fromIndex[node] = true});
} else {
from = null;
}
nodes.forEach((node)... | javascript | function getIn (client, from, nodes, callback, remove) {
remove = remove || [];
const outNodes = [];
const nodeIndex = {};
const fromIndex = {};
if (from instanceof Array) {
from.forEach((node) => {fromIndex[node] = true});
} else {
from = null;
}
nodes.forEach((node)... | [
"function",
"getIn",
"(",
"client",
",",
"from",
",",
"nodes",
",",
"callback",
",",
"remove",
")",
"{",
"remove",
"=",
"remove",
"||",
"[",
"]",
";",
"const",
"outNodes",
"=",
"[",
"]",
";",
"const",
"nodeIndex",
"=",
"{",
"}",
";",
"const",
"from... | -> from network | [
"-",
">",
"from",
"network"
] | 8c80bacbd6ab27a72000dbeaf454800e8e817efa | https://github.com/jillix/flow-api/blob/8c80bacbd6ab27a72000dbeaf454800e8e817efa/lib/_remove.js#L157-L216 | train |
FinalDevStudio/fi-khipu | lib/index.js | createPayment | function createPayment(data, callback) {
var client = new this.clients.Payments();
client.create(data, callback);
} | javascript | function createPayment(data, callback) {
var client = new this.clients.Payments();
client.create(data, callback);
} | [
"function",
"createPayment",
"(",
"data",
",",
"callback",
")",
"{",
"var",
"client",
"=",
"new",
"this",
".",
"clients",
".",
"Payments",
"(",
")",
";",
"client",
".",
"create",
"(",
"data",
",",
"callback",
")",
";",
"}"
] | Creates a new payment.
@param {Object} data - The payment fields.
@param {Function} callback - The callback method. | [
"Creates",
"a",
"new",
"payment",
"."
] | 76f5ec38e88dc2053502c320e309b74039b4d517 | https://github.com/FinalDevStudio/fi-khipu/blob/76f5ec38e88dc2053502c320e309b74039b4d517/lib/index.js#L49-L52 | train |
FinalDevStudio/fi-khipu | lib/index.js | getPaymentById | function getPaymentById(id, callback) {
var client = new this.clients.Payments();
client.getById(id, callback);
} | javascript | function getPaymentById(id, callback) {
var client = new this.clients.Payments();
client.getById(id, callback);
} | [
"function",
"getPaymentById",
"(",
"id",
",",
"callback",
")",
"{",
"var",
"client",
"=",
"new",
"this",
".",
"clients",
".",
"Payments",
"(",
")",
";",
"client",
".",
"getById",
"(",
"id",
",",
"callback",
")",
";",
"}"
] | Obtains a payment by its ID.
@param {String} id - The payment ID.
@param {Function} callback - The callback method. | [
"Obtains",
"a",
"payment",
"by",
"its",
"ID",
"."
] | 76f5ec38e88dc2053502c320e309b74039b4d517 | https://github.com/FinalDevStudio/fi-khipu/blob/76f5ec38e88dc2053502c320e309b74039b4d517/lib/index.js#L60-L63 | train |
FinalDevStudio/fi-khipu | lib/index.js | getPaymentByNotificationToken | function getPaymentByNotificationToken(token, callback) {
var client = new this.clients.Payments();
client.getByNotificationToken(token, callback);
} | javascript | function getPaymentByNotificationToken(token, callback) {
var client = new this.clients.Payments();
client.getByNotificationToken(token, callback);
} | [
"function",
"getPaymentByNotificationToken",
"(",
"token",
",",
"callback",
")",
"{",
"var",
"client",
"=",
"new",
"this",
".",
"clients",
".",
"Payments",
"(",
")",
";",
"client",
".",
"getByNotificationToken",
"(",
"token",
",",
"callback",
")",
";",
"}"
] | Obtains a payment by its notification token.
@param {String} id - The payment ID.
@param {Function} callback - The callback method. | [
"Obtains",
"a",
"payment",
"by",
"its",
"notification",
"token",
"."
] | 76f5ec38e88dc2053502c320e309b74039b4d517 | https://github.com/FinalDevStudio/fi-khipu/blob/76f5ec38e88dc2053502c320e309b74039b4d517/lib/index.js#L71-L74 | train |
FinalDevStudio/fi-khipu | lib/index.js | refundPayment | function refundPayment(id, callback) {
var client = new this.clients.Payments();
client.refund(id, callback);
} | javascript | function refundPayment(id, callback) {
var client = new this.clients.Payments();
client.refund(id, callback);
} | [
"function",
"refundPayment",
"(",
"id",
",",
"callback",
")",
"{",
"var",
"client",
"=",
"new",
"this",
".",
"clients",
".",
"Payments",
"(",
")",
";",
"client",
".",
"refund",
"(",
"id",
",",
"callback",
")",
";",
"}"
] | Refunds a payment by its ID.
@param {String} id - The payment's ID.
@param {Function} callback - The callback method. | [
"Refunds",
"a",
"payment",
"by",
"its",
"ID",
"."
] | 76f5ec38e88dc2053502c320e309b74039b4d517 | https://github.com/FinalDevStudio/fi-khipu/blob/76f5ec38e88dc2053502c320e309b74039b4d517/lib/index.js#L82-L85 | train |
linyngfly/omelo-scheduler | lib/cronTrigger.js | function(trigger, job){
this.trigger = this.decodeTrigger(trigger);
this.nextTime = this.nextExcuteTime(Date.now());
this.job = job;
} | javascript | function(trigger, job){
this.trigger = this.decodeTrigger(trigger);
this.nextTime = this.nextExcuteTime(Date.now());
this.job = job;
} | [
"function",
"(",
"trigger",
",",
"job",
")",
"{",
"this",
".",
"trigger",
"=",
"this",
".",
"decodeTrigger",
"(",
"trigger",
")",
";",
"this",
".",
"nextTime",
"=",
"this",
".",
"nextExcuteTime",
"(",
"Date",
".",
"now",
"(",
")",
")",
";",
"this",
... | The constructor of the CronTrigger
@param trigger The trigger str used to build the cronTrigger instance | [
"The",
"constructor",
"of",
"the",
"CronTrigger"
] | aa7775eb2b8b31160669c8fedccd84e2108797eb | https://github.com/linyngfly/omelo-scheduler/blob/aa7775eb2b8b31160669c8fedccd84e2108797eb/lib/cronTrigger.js#L19-L25 | train | |
linyngfly/omelo-scheduler | lib/cronTrigger.js | timeMatch | function timeMatch(value, cronTime){
if(typeof(cronTime) == 'number'){
if(cronTime == -1)
return true;
if(value == cronTime)
return true;
return false;
}else if(typeof(cronTime) == 'object' && cronTime instanceof Array){
if(value < cronTime[0] || value > cronTime[cronTime.length -1])
... | javascript | function timeMatch(value, cronTime){
if(typeof(cronTime) == 'number'){
if(cronTime == -1)
return true;
if(value == cronTime)
return true;
return false;
}else if(typeof(cronTime) == 'object' && cronTime instanceof Array){
if(value < cronTime[0] || value > cronTime[cronTime.length -1])
... | [
"function",
"timeMatch",
"(",
"value",
",",
"cronTime",
")",
"{",
"if",
"(",
"typeof",
"(",
"cronTime",
")",
"==",
"'number'",
")",
"{",
"if",
"(",
"cronTime",
"==",
"-",
"1",
")",
"return",
"true",
";",
"if",
"(",
"value",
"==",
"cronTime",
")",
"... | Match the given value to the cronTime
@param value The given value
@param cronTime The cronTime
@return The match result | [
"Match",
"the",
"given",
"value",
"to",
"the",
"cronTime"
] | aa7775eb2b8b31160669c8fedccd84e2108797eb | https://github.com/linyngfly/omelo-scheduler/blob/aa7775eb2b8b31160669c8fedccd84e2108797eb/lib/cronTrigger.js#L186-L205 | train |
linyngfly/omelo-scheduler | lib/cronTrigger.js | decodeRangeTime | function decodeRangeTime(map, timeStr){
let times = timeStr.split('-');
times[0] = Number(times[0]);
times[1] = Number(times[1]);
if(times[0] > times[1]){
console.log("Error time range");
return null;
}
for(let i = times[0]; i <= times[1]; i++){
map[i] = i;
}
} | javascript | function decodeRangeTime(map, timeStr){
let times = timeStr.split('-');
times[0] = Number(times[0]);
times[1] = Number(times[1]);
if(times[0] > times[1]){
console.log("Error time range");
return null;
}
for(let i = times[0]; i <= times[1]; i++){
map[i] = i;
}
} | [
"function",
"decodeRangeTime",
"(",
"map",
",",
"timeStr",
")",
"{",
"let",
"times",
"=",
"timeStr",
".",
"split",
"(",
"'-'",
")",
";",
"times",
"[",
"0",
"]",
"=",
"Number",
"(",
"times",
"[",
"0",
"]",
")",
";",
"times",
"[",
"1",
"]",
"=",
... | Decode time range
@param map The decode map
@param timeStr The range string, like 2-5 | [
"Decode",
"time",
"range"
] | aa7775eb2b8b31160669c8fedccd84e2108797eb | https://github.com/linyngfly/omelo-scheduler/blob/aa7775eb2b8b31160669c8fedccd84e2108797eb/lib/cronTrigger.js#L285-L298 | train |
linyngfly/omelo-scheduler | lib/cronTrigger.js | decodePeriodTime | function decodePeriodTime(map, timeStr, type){
let times = timeStr.split('/');
let min = Limit[type][0];
let max = Limit[type][1];
let remind = Number(times[0]);
let period = Number(times[1]);
if(period==0)
return;
for(let i = min; i <= max; i++){
if(i%period == remind)
map[i] = i;
}
} | javascript | function decodePeriodTime(map, timeStr, type){
let times = timeStr.split('/');
let min = Limit[type][0];
let max = Limit[type][1];
let remind = Number(times[0]);
let period = Number(times[1]);
if(period==0)
return;
for(let i = min; i <= max; i++){
if(i%period == remind)
map[i] = i;
}
} | [
"function",
"decodePeriodTime",
"(",
"map",
",",
"timeStr",
",",
"type",
")",
"{",
"let",
"times",
"=",
"timeStr",
".",
"split",
"(",
"'/'",
")",
";",
"let",
"min",
"=",
"Limit",
"[",
"type",
"]",
"[",
"0",
"]",
";",
"let",
"max",
"=",
"Limit",
"... | Compute the period timer | [
"Compute",
"the",
"period",
"timer"
] | aa7775eb2b8b31160669c8fedccd84e2108797eb | https://github.com/linyngfly/omelo-scheduler/blob/aa7775eb2b8b31160669c8fedccd84e2108797eb/lib/cronTrigger.js#L303-L318 | train |
linyngfly/omelo-scheduler | lib/cronTrigger.js | checkNum | function checkNum(nums, min, max){
if(nums == null)
return false;
if(nums == -1)
return true;
for(let i = 0; i < nums.length; i++){
if(nums[i]<min || nums[i]>max)
return false;
}
return true;
} | javascript | function checkNum(nums, min, max){
if(nums == null)
return false;
if(nums == -1)
return true;
for(let i = 0; i < nums.length; i++){
if(nums[i]<min || nums[i]>max)
return false;
}
return true;
} | [
"function",
"checkNum",
"(",
"nums",
",",
"min",
",",
"max",
")",
"{",
"if",
"(",
"nums",
"==",
"null",
")",
"return",
"false",
";",
"if",
"(",
"nums",
"==",
"-",
"1",
")",
"return",
"true",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<... | Check if the numbers are valid
@param nums The numbers array need to check
@param min Minimus value
@param max Maximam value
@return If all the numbers are in the data range | [
"Check",
"if",
"the",
"numbers",
"are",
"valid"
] | aa7775eb2b8b31160669c8fedccd84e2108797eb | https://github.com/linyngfly/omelo-scheduler/blob/aa7775eb2b8b31160669c8fedccd84e2108797eb/lib/cronTrigger.js#L327-L340 | train |
vid/SenseBase | web/lib/search.js | setupCronInput | function setupCronInput(val) {
$('input.cron').jqCron({
enabled_minute: true,
multiple_dom: true,
multiple_month: true,
multiple_mins: true,
multiple_dow: true,
multiple_time_hours: true,
multiple_time_minutes: true,
default_period: 'week',
default_value: val ||... | javascript | function setupCronInput(val) {
$('input.cron').jqCron({
enabled_minute: true,
multiple_dom: true,
multiple_month: true,
multiple_mins: true,
multiple_dow: true,
multiple_time_hours: true,
multiple_time_minutes: true,
default_period: 'week',
default_value: val ||... | [
"function",
"setupCronInput",
"(",
"val",
")",
"{",
"$",
"(",
"'input.cron'",
")",
".",
"jqCron",
"(",
"{",
"enabled_minute",
":",
"true",
",",
"multiple_dom",
":",
"true",
",",
"multiple_month",
":",
"true",
",",
"multiple_mins",
":",
"true",
",",
"multip... | set up the cron scheduler input | [
"set",
"up",
"the",
"cron",
"scheduler",
"input"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/web/lib/search.js#L120-L134 | train |
vid/SenseBase | web/lib/search.js | getSearchInput | function getSearchInput() {
var cronValue = $('#scheduleSearch').prop('checked') ? $('input.cron').val() : null, searchName = $('#searchName').val(), targetResults = $('#targetResults').val(), input = $('#searchInput').val(), searchContinue = $('#searchContinue').val(), searchCategories = $('#searchCategories').val... | javascript | function getSearchInput() {
var cronValue = $('#scheduleSearch').prop('checked') ? $('input.cron').val() : null, searchName = $('#searchName').val(), targetResults = $('#targetResults').val(), input = $('#searchInput').val(), searchContinue = $('#searchContinue').val(), searchCategories = $('#searchCategories').val... | [
"function",
"getSearchInput",
"(",
")",
"{",
"var",
"cronValue",
"=",
"$",
"(",
"'#scheduleSearch'",
")",
".",
"prop",
"(",
"'checked'",
")",
"?",
"$",
"(",
"'input.cron'",
")",
".",
"val",
"(",
")",
":",
"null",
",",
"searchName",
"=",
"$",
"(",
"'#... | convert the form values to data | [
"convert",
"the",
"form",
"values",
"to",
"data"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/web/lib/search.js#L137-L140 | train |
vid/SenseBase | web/lib/search.js | submitSearch | function submitSearch() {
var searchInput = getSearchInput();
// FIXME: SUI validation for select2 field
if (!searchInput.valid) {
alert('Please select team members');
return;
}
console.log('publishing', searchInput);
$('.search.message').html('Search results:');
$('.search.mes... | javascript | function submitSearch() {
var searchInput = getSearchInput();
// FIXME: SUI validation for select2 field
if (!searchInput.valid) {
alert('Please select team members');
return;
}
console.log('publishing', searchInput);
$('.search.message').html('Search results:');
$('.search.mes... | [
"function",
"submitSearch",
"(",
")",
"{",
"var",
"searchInput",
"=",
"getSearchInput",
"(",
")",
";",
"// FIXME: SUI validation for select2 field",
"if",
"(",
"!",
"searchInput",
".",
"valid",
")",
"{",
"alert",
"(",
"'Please select team members'",
")",
";",
"ret... | submit a new search | [
"submit",
"a",
"new",
"search"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/web/lib/search.js#L143-L168 | train |
jonschlinkert/load-helpers | index.js | Loader | function Loader(options) {
if (!(this instanceof Loader)) {
return new Loader(options);
}
this.options = options || {};
this.cache = this.options.helpers || {};
} | javascript | function Loader(options) {
if (!(this instanceof Loader)) {
return new Loader(options);
}
this.options = options || {};
this.cache = this.options.helpers || {};
} | [
"function",
"Loader",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Loader",
")",
")",
"{",
"return",
"new",
"Loader",
"(",
"options",
")",
";",
"}",
"this",
".",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
... | Create an instance of `Loader` with the given `options`.
```js
var Loader = require('load-helpers');
var loader = new Loader();
```
@param {Object} `options`
@api public | [
"Create",
"an",
"instance",
"of",
"Loader",
"with",
"the",
"given",
"options",
"."
] | 271351dfafeae911495465b83a4811f8532ad249 | https://github.com/jonschlinkert/load-helpers/blob/271351dfafeae911495465b83a4811f8532ad249/index.js#L24-L30 | train |
vadr-vr/VR-Analytics-JSCore | js/utils.js | deepClone | function deepClone(inputDict){
if (!inputDict)
return null;
const clonedDict = {};
for (let key in inputDict){
if (typeof(inputDict[key]) == 'object'){
clonedDict[key] = deepClone(inputDict[key]);
}
else{
clonedDict[key] = inputDict[key]... | javascript | function deepClone(inputDict){
if (!inputDict)
return null;
const clonedDict = {};
for (let key in inputDict){
if (typeof(inputDict[key]) == 'object'){
clonedDict[key] = deepClone(inputDict[key]);
}
else{
clonedDict[key] = inputDict[key]... | [
"function",
"deepClone",
"(",
"inputDict",
")",
"{",
"if",
"(",
"!",
"inputDict",
")",
"return",
"null",
";",
"const",
"clonedDict",
"=",
"{",
"}",
";",
"for",
"(",
"let",
"key",
"in",
"inputDict",
")",
"{",
"if",
"(",
"typeof",
"(",
"inputDict",
"["... | Deep clones dictionary
@memberof Utils
@param {object} inputDict Dictionary to clone
@returns {object} cloned dictionary | [
"Deep",
"clones",
"dictionary"
] | 7e4a493c824c2c1716360dcb6a3bfecfede5df3b | https://github.com/vadr-vr/VR-Analytics-JSCore/blob/7e4a493c824c2c1716360dcb6a3bfecfede5df3b/js/utils.js#L81-L105 | train |
vadr-vr/VR-Analytics-JSCore | js/utils.js | setCookie | function setCookie(cookieName, value, validity, useAppPrefix = true){
const appPrefix = useAppPrefix ? _getAppPrefix() : '';
const cookieString = appPrefix + cookieName + '=' + value + ';' + 'expires=' +
validity.toUTCString();
document.cookie = cookieString;
} | javascript | function setCookie(cookieName, value, validity, useAppPrefix = true){
const appPrefix = useAppPrefix ? _getAppPrefix() : '';
const cookieString = appPrefix + cookieName + '=' + value + ';' + 'expires=' +
validity.toUTCString();
document.cookie = cookieString;
} | [
"function",
"setCookie",
"(",
"cookieName",
",",
"value",
",",
"validity",
",",
"useAppPrefix",
"=",
"true",
")",
"{",
"const",
"appPrefix",
"=",
"useAppPrefix",
"?",
"_getAppPrefix",
"(",
")",
":",
"''",
";",
"const",
"cookieString",
"=",
"appPrefix",
"+",
... | Sets the cookie with the given name, value and validity. Appends appId and version information
in the cookie name automatically
@memberof Utils
@param {string} cookieName name of the cookie
@param {string} value value of the cookie
@param {Date} validity valid till date object | [
"Sets",
"the",
"cookie",
"with",
"the",
"given",
"name",
"value",
"and",
"validity",
".",
"Appends",
"appId",
"and",
"version",
"information",
"in",
"the",
"cookie",
"name",
"automatically"
] | 7e4a493c824c2c1716360dcb6a3bfecfede5df3b | https://github.com/vadr-vr/VR-Analytics-JSCore/blob/7e4a493c824c2c1716360dcb6a3bfecfede5df3b/js/utils.js#L130-L139 | 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.