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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
greggman/HappyFunTimes | server/player.js | function(client, relayServer, id) {
this.client = client;
this.relayServer = relayServer;
this.id = id;
debug("" + id + ": start player");
var addPlayerToGame = function(data) {
var game = this.relayServer.addPlayerToGame(this, data.gameId, data.data);
if (!game) {
// TODO: Make this URL set f... | javascript | function(client, relayServer, id) {
this.client = client;
this.relayServer = relayServer;
this.id = id;
debug("" + id + ": start player");
var addPlayerToGame = function(data) {
var game = this.relayServer.addPlayerToGame(this, data.gameId, data.data);
if (!game) {
// TODO: Make this URL set f... | [
"function",
"(",
"client",
",",
"relayServer",
",",
"id",
")",
"{",
"this",
".",
"client",
"=",
"client",
";",
"this",
".",
"relayServer",
"=",
"relayServer",
";",
"this",
".",
"id",
"=",
"id",
";",
"debug",
"(",
"\"\"",
"+",
"id",
"+",
"\": start pl... | A Player in a game.
@constructor
@param {!Client} client The websocket for this player
@param {!RelayServer} relayServer The server managing this
player.
@param {string} id a unique id for this player. | [
"A",
"Player",
"in",
"a",
"game",
"."
] | 1c29e334ef9eca269980f5fc2b73894452688490 | https://github.com/greggman/HappyFunTimes/blob/1c29e334ef9eca269980f5fc2b73894452688490/server/player.js#L45-L112 | train | |
greggman/HappyFunTimes | server/game-group.js | function(gameId, relayServer, options) {
options = options || {};
this.options = options;
this.gameId = gameId;
this.relayServer = relayServer;
this.games = []; // first game is the "master"
this.nextGameId = 0; // start at 0 because it's easy to switch games with (gameNum + numGames + dir) % numGames
} | javascript | function(gameId, relayServer, options) {
options = options || {};
this.options = options;
this.gameId = gameId;
this.relayServer = relayServer;
this.games = []; // first game is the "master"
this.nextGameId = 0; // start at 0 because it's easy to switch games with (gameNum + numGames + dir) % numGames
} | [
"function",
"(",
"gameId",
",",
"relayServer",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"options",
"=",
"options",
";",
"this",
".",
"gameId",
"=",
"gameId",
";",
"this",
".",
"relayServer",
"=",
"relayServ... | Represents a group of games.
Normally a group only has 1 game but
for situations where we need more than
1 game ... | [
"Represents",
"a",
"group",
"of",
"games",
"."
] | 1c29e334ef9eca269980f5fc2b73894452688490 | https://github.com/greggman/HappyFunTimes/blob/1c29e334ef9eca269980f5fc2b73894452688490/server/game-group.js#L45-L52 | train | |
greggman/HappyFunTimes | src/hft/scripts/misc/misc.js | function(str, opt_obj) {
var dst = opt_obj || {};
try {
var q = str.indexOf("?");
var e = str.indexOf("#");
if (e < 0) {
e = str.length;
}
var query = str.substring(q + 1, e);
searchStringToObject(query, dst);
} catch (e) {
console.error(e);
}
return... | javascript | function(str, opt_obj) {
var dst = opt_obj || {};
try {
var q = str.indexOf("?");
var e = str.indexOf("#");
if (e < 0) {
e = str.length;
}
var query = str.substring(q + 1, e);
searchStringToObject(query, dst);
} catch (e) {
console.error(e);
}
return... | [
"function",
"(",
"str",
",",
"opt_obj",
")",
"{",
"var",
"dst",
"=",
"opt_obj",
"||",
"{",
"}",
";",
"try",
"{",
"var",
"q",
"=",
"str",
".",
"indexOf",
"(",
"\"?\"",
")",
";",
"var",
"e",
"=",
"str",
".",
"indexOf",
"(",
"\"#\"",
")",
";",
"... | Reads the query values from a URL like string.
@param {String} url URL like string eg. http://foo?key=value
@param {Object} [opt_obj] Object to attach key values to
@return {Object} Object with key values from URL
@memberOf module:Misc | [
"Reads",
"the",
"query",
"values",
"from",
"a",
"URL",
"like",
"string",
"."
] | 1c29e334ef9eca269980f5fc2b73894452688490 | https://github.com/greggman/HappyFunTimes/blob/1c29e334ef9eca269980f5fc2b73894452688490/src/hft/scripts/misc/misc.js#L132-L146 | train | |
greggman/HappyFunTimes | src/hft/scripts/misc/misc.js | gotoIFrame | function gotoIFrame(src) {
var iframe = document.createElement("iframe");
iframe.style.display = "none";
iframe.src = src;
document.body.appendChild(iframe);
return iframe;
} | javascript | function gotoIFrame(src) {
var iframe = document.createElement("iframe");
iframe.style.display = "none";
iframe.src = src;
document.body.appendChild(iframe);
return iframe;
} | [
"function",
"gotoIFrame",
"(",
"src",
")",
"{",
"var",
"iframe",
"=",
"document",
".",
"createElement",
"(",
"\"iframe\"",
")",
";",
"iframe",
".",
"style",
".",
"display",
"=",
"\"none\"",
";",
"iframe",
".",
"src",
"=",
"src",
";",
"document",
".",
"... | Creates an invisible iframe and sets the src
@param {string} src the source for the iframe
@return {HTMLIFrameElement} The iframe | [
"Creates",
"an",
"invisible",
"iframe",
"and",
"sets",
"the",
"src"
] | 1c29e334ef9eca269980f5fc2b73894452688490 | https://github.com/greggman/HappyFunTimes/blob/1c29e334ef9eca269980f5fc2b73894452688490/src/hft/scripts/misc/misc.js#L214-L220 | train |
greggman/HappyFunTimes | src/hft/scripts/misc/misc.js | function(opt_randFunc) {
var randFunc = opt_randFunc || randInt;
var strong = randFunc(3);
var colors = [];
for (var ii = 0; ii < 3; ++ii) {
colors.push(randFunc(128) + (ii === strong ? 128 : 64));
}
return "rgb(" + colors.join(",") + ")";
} | javascript | function(opt_randFunc) {
var randFunc = opt_randFunc || randInt;
var strong = randFunc(3);
var colors = [];
for (var ii = 0; ii < 3; ++ii) {
colors.push(randFunc(128) + (ii === strong ? 128 : 64));
}
return "rgb(" + colors.join(",") + ")";
} | [
"function",
"(",
"opt_randFunc",
")",
"{",
"var",
"randFunc",
"=",
"opt_randFunc",
"||",
"randInt",
";",
"var",
"strong",
"=",
"randFunc",
"(",
"3",
")",
";",
"var",
"colors",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"ii",
"=",
"0",
";",
"ii",
"<",
... | get a random CSS color
@param {function(number): number?) opt_randFunc function to generate random numbers
@return {string} random css color
@memberOf module:Misc | [
"get",
"a",
"random",
"CSS",
"color"
] | 1c29e334ef9eca269980f5fc2b73894452688490 | https://github.com/greggman/HappyFunTimes/blob/1c29e334ef9eca269980f5fc2b73894452688490/src/hft/scripts/misc/misc.js#L238-L246 | train | |
greggman/HappyFunTimes | src/hft/scripts/misc/misc.js | function(opt_randFunc) {
var randFunc = opt_randFunc || randInt;
var strong = randFunc(3);
var color = 0xFF;
for (var ii = 0; ii < 3; ++ii) {
color = (color << 8) | (randFunc(128) + (ii === strong ? 128 : 64));
}
return color;
} | javascript | function(opt_randFunc) {
var randFunc = opt_randFunc || randInt;
var strong = randFunc(3);
var color = 0xFF;
for (var ii = 0; ii < 3; ++ii) {
color = (color << 8) | (randFunc(128) + (ii === strong ? 128 : 64));
}
return color;
} | [
"function",
"(",
"opt_randFunc",
")",
"{",
"var",
"randFunc",
"=",
"opt_randFunc",
"||",
"randInt",
";",
"var",
"strong",
"=",
"randFunc",
"(",
"3",
")",
";",
"var",
"color",
"=",
"0xFF",
";",
"for",
"(",
"var",
"ii",
"=",
"0",
";",
"ii",
"<",
"3",... | get a random 32bit color
@param {function(number): number?) opt_randFunc function to generate random numbers
@return {string} random 32bit color
@memberOf module:Misc | [
"get",
"a",
"random",
"32bit",
"color"
] | 1c29e334ef9eca269980f5fc2b73894452688490 | https://github.com/greggman/HappyFunTimes/blob/1c29e334ef9eca269980f5fc2b73894452688490/src/hft/scripts/misc/misc.js#L263-L271 | train | |
greggman/HappyFunTimes | src/hft/scripts/misc/misc.js | function(selector) {
for (var ii = 0; ii < document.styleSheets.length; ++ii) {
var styleSheet = document.styleSheets[ii];
var rules = styleSheet.cssRules || styleSheet.rules;
if (rules) {
for (var rr = 0; rr < rules.length; ++rr) {
var rule = rules[rr];
if (rule.select... | javascript | function(selector) {
for (var ii = 0; ii < document.styleSheets.length; ++ii) {
var styleSheet = document.styleSheets[ii];
var rules = styleSheet.cssRules || styleSheet.rules;
if (rules) {
for (var rr = 0; rr < rules.length; ++rr) {
var rule = rules[rr];
if (rule.select... | [
"function",
"(",
"selector",
")",
"{",
"for",
"(",
"var",
"ii",
"=",
"0",
";",
"ii",
"<",
"document",
".",
"styleSheets",
".",
"length",
";",
"++",
"ii",
")",
"{",
"var",
"styleSheet",
"=",
"document",
".",
"styleSheets",
"[",
"ii",
"]",
";",
"var"... | finds a CSS rule.
@param {string} selector
@return {Rule?} matching css rule
@memberOf module:Misc | [
"finds",
"a",
"CSS",
"rule",
"."
] | 1c29e334ef9eca269980f5fc2b73894452688490 | https://github.com/greggman/HappyFunTimes/blob/1c29e334ef9eca269980f5fc2b73894452688490/src/hft/scripts/misc/misc.js#L279-L292 | train | |
greggman/HappyFunTimes | src/hft/scripts/misc/misc.js | function(element) {
var r = { x: element.offsetLeft, y: element.offsetTop };
if (element.offsetParent) {
var tmp = getAbsolutePosition(element.offsetParent);
r.x += tmp.x;
r.y += tmp.y;
}
return r;
} | javascript | function(element) {
var r = { x: element.offsetLeft, y: element.offsetTop };
if (element.offsetParent) {
var tmp = getAbsolutePosition(element.offsetParent);
r.x += tmp.x;
r.y += tmp.y;
}
return r;
} | [
"function",
"(",
"element",
")",
"{",
"var",
"r",
"=",
"{",
"x",
":",
"element",
".",
"offsetLeft",
",",
"y",
":",
"element",
".",
"offsetTop",
"}",
";",
"if",
"(",
"element",
".",
"offsetParent",
")",
"{",
"var",
"tmp",
"=",
"getAbsolutePosition",
"... | Returns the absolute position of an element for certain browsers.
@param {HTMLElement} element The element to get a position
for.
@returns {Object} An object containing x and y as the
absolute position of the given element.
@memberOf module:Misc | [
"Returns",
"the",
"absolute",
"position",
"of",
"an",
"element",
"for",
"certain",
"browsers",
"."
] | 1c29e334ef9eca269980f5fc2b73894452688490 | https://github.com/greggman/HappyFunTimes/blob/1c29e334ef9eca269980f5fc2b73894452688490/src/hft/scripts/misc/misc.js#L314-L322 | train | |
greggman/HappyFunTimes | src/hft/scripts/misc/misc.js | function(canvas, useDevicePixelRatio) {
var mult = useDevicePixelRatio ? window.devicePixelRatio : 1;
mult = mult || 1;
var width = Math.floor(canvas.clientWidth * mult);
var height = Math.floor(canvas.clientHeight * mult);
if (canvas.width !== width ||
canvas.height !== height) {
ca... | javascript | function(canvas, useDevicePixelRatio) {
var mult = useDevicePixelRatio ? window.devicePixelRatio : 1;
mult = mult || 1;
var width = Math.floor(canvas.clientWidth * mult);
var height = Math.floor(canvas.clientHeight * mult);
if (canvas.width !== width ||
canvas.height !== height) {
ca... | [
"function",
"(",
"canvas",
",",
"useDevicePixelRatio",
")",
"{",
"var",
"mult",
"=",
"useDevicePixelRatio",
"?",
"window",
".",
"devicePixelRatio",
":",
"1",
";",
"mult",
"=",
"mult",
"||",
"1",
";",
"var",
"width",
"=",
"Math",
".",
"floor",
"(",
"canva... | Resizes a cavnas to match its CSS displayed size.
@param {Canvas} canvas canvas to resize.
@param {boolean?} useDevicePixelRatio if true canvas will be
created to match devicePixelRatio.
@memberOf module:Misc | [
"Resizes",
"a",
"cavnas",
"to",
"match",
"its",
"CSS",
"displayed",
"size",
"."
] | 1c29e334ef9eca269980f5fc2b73894452688490 | https://github.com/greggman/HappyFunTimes/blob/1c29e334ef9eca269980f5fc2b73894452688490/src/hft/scripts/misc/misc.js#L419-L430 | train | |
greggman/HappyFunTimes | src/hft/scripts/misc/misc.js | applyObject | function applyObject(src, dst) {
Object.keys(src).forEach(function(key) {
dst[key] = src[key];
});
return dst;
} | javascript | function applyObject(src, dst) {
Object.keys(src).forEach(function(key) {
dst[key] = src[key];
});
return dst;
} | [
"function",
"applyObject",
"(",
"src",
",",
"dst",
")",
"{",
"Object",
".",
"keys",
"(",
"src",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"dst",
"[",
"key",
"]",
"=",
"src",
"[",
"key",
"]",
";",
"}",
")",
";",
"return",
"dst"... | Copies all the src properties to the dst
@param {Object} src an object with some properties
@param {Object} dst an object to receive copes of the properties
@return returns the dst object. | [
"Copies",
"all",
"the",
"src",
"properties",
"to",
"the",
"dst"
] | 1c29e334ef9eca269980f5fc2b73894452688490 | https://github.com/greggman/HappyFunTimes/blob/1c29e334ef9eca269980f5fc2b73894452688490/src/hft/scripts/misc/misc.js#L438-L443 | train |
greggman/HappyFunTimes | src/hft/scripts/misc/misc.js | makeRandomId | function makeRandomId(digits) {
digits = digits || 16;
var id = "";
for (var ii = 0; ii < digits; ++ii) {
id = id + ((Math.random() * 16 | 0)).toString(16);
}
return id;
} | javascript | function makeRandomId(digits) {
digits = digits || 16;
var id = "";
for (var ii = 0; ii < digits; ++ii) {
id = id + ((Math.random() * 16 | 0)).toString(16);
}
return id;
} | [
"function",
"makeRandomId",
"(",
"digits",
")",
"{",
"digits",
"=",
"digits",
"||",
"16",
";",
"var",
"id",
"=",
"\"\"",
";",
"for",
"(",
"var",
"ii",
"=",
"0",
";",
"ii",
"<",
"digits",
";",
"++",
"ii",
")",
"{",
"id",
"=",
"id",
"+",
"(",
"... | Creates a random id
@param {number} [digits] number of digits. default 16 | [
"Creates",
"a",
"random",
"id"
] | 1c29e334ef9eca269980f5fc2b73894452688490 | https://github.com/greggman/HappyFunTimes/blob/1c29e334ef9eca269980f5fc2b73894452688490/src/hft/scripts/misc/misc.js#L481-L488 | train |
greggman/HappyFunTimes | src/hft/scripts/misc/misc.js | applyListeners | function applyListeners(emitter, listeners) {
Object.keys(listeners).forEach(function(name) {
emitter.addEventListener(name, listeners[name]);
});
} | javascript | function applyListeners(emitter, listeners) {
Object.keys(listeners).forEach(function(name) {
emitter.addEventListener(name, listeners[name]);
});
} | [
"function",
"applyListeners",
"(",
"emitter",
",",
"listeners",
")",
"{",
"Object",
".",
"keys",
"(",
"listeners",
")",
".",
"forEach",
"(",
"function",
"(",
"name",
")",
"{",
"emitter",
".",
"addEventListener",
"(",
"name",
",",
"listeners",
"[",
"name",
... | Applies an object of listeners to an emitter.
Example:
applyListeners(someDivElement, {
mousedown: someFunc1,
mousemove: someFunc2,
mouseup: someFunc3,
});
Which is the same as
someDivElement.addEventListener("mousedown", someFunc1);
someDivElement.addEventListener("mousemove", someFunc2);
someDivElement.addEventLi... | [
"Applies",
"an",
"object",
"of",
"listeners",
"to",
"an",
"emitter",
"."
] | 1c29e334ef9eca269980f5fc2b73894452688490 | https://github.com/greggman/HappyFunTimes/blob/1c29e334ef9eca269980f5fc2b73894452688490/src/hft/scripts/misc/misc.js#L510-L514 | train |
greggman/HappyFunTimes | src/hft/scripts/syncedclock.js | function(opt_syncRateSeconds, callback) {
var query = misc.parseUrlQuery();
var url = (query.hftUrl || window.location.href).replace("ws:", "http:");
var syncRateMS = (opt_syncRateSeconds || 10) * 1000;
var timeOffset = 0;
var syncToServer = function(queueNext) {
var sendTime = g... | javascript | function(opt_syncRateSeconds, callback) {
var query = misc.parseUrlQuery();
var url = (query.hftUrl || window.location.href).replace("ws:", "http:");
var syncRateMS = (opt_syncRateSeconds || 10) * 1000;
var timeOffset = 0;
var syncToServer = function(queueNext) {
var sendTime = g... | [
"function",
"(",
"opt_syncRateSeconds",
",",
"callback",
")",
"{",
"var",
"query",
"=",
"misc",
".",
"parseUrlQuery",
"(",
")",
";",
"var",
"url",
"=",
"(",
"query",
".",
"hftUrl",
"||",
"window",
".",
"location",
".",
"href",
")",
".",
"replace",
"(",... | A clock that gets the current time in seconds attempting to
keep the clock synced to the server.
@constructor | [
"A",
"clock",
"that",
"gets",
"the",
"current",
"time",
"in",
"seconds",
"attempting",
"to",
"keep",
"the",
"clock",
"synced",
"to",
"the",
"server",
"."
] | 1c29e334ef9eca269980f5fc2b73894452688490 | https://github.com/greggman/HappyFunTimes/blob/1c29e334ef9eca269980f5fc2b73894452688490/src/hft/scripts/syncedclock.js#L120-L167 | train | |
greggman/HappyFunTimes | docs/assets/js/io.js | function(url, jsonObject, callback, options) {
var options = JSON.parse(JSON.stringify(options || {}));
options.headers = options.headers || {};
options.headers["Content-type"] = "application/json";
return request(
url,
JSON.stringify(jsonObject),
function(err, content) {
if (e... | javascript | function(url, jsonObject, callback, options) {
var options = JSON.parse(JSON.stringify(options || {}));
options.headers = options.headers || {};
options.headers["Content-type"] = "application/json";
return request(
url,
JSON.stringify(jsonObject),
function(err, content) {
if (e... | [
"function",
"(",
"url",
",",
"jsonObject",
",",
"callback",
",",
"options",
")",
"{",
"var",
"options",
"=",
"JSON",
".",
"parse",
"(",
"JSON",
".",
"stringify",
"(",
"options",
"||",
"{",
"}",
")",
")",
";",
"options",
".",
"headers",
"=",
"options"... | sends a JSON 'POST' request, returns JSON repsonse
@memberOf module:IO
@param {string} url url to POST to.
@param {Object=} jsonObject JavaScript object on which to
call JSON.stringify.
@param {!function(error, object)} callback Function to call
on success or failure. If successful error will be
null, object will be js... | [
"sends",
"a",
"JSON",
"POST",
"request",
"returns",
"JSON",
"repsonse"
] | 1c29e334ef9eca269980f5fc2b73894452688490 | https://github.com/greggman/HappyFunTimes/blob/1c29e334ef9eca269980f5fc2b73894452688490/docs/assets/js/io.js#L141-L160 | train | |
alexindigo/asynckit | lib/readable_serial.js | ReadableSerial | function ReadableSerial(list, iterator, callback)
{
if (!(this instanceof ReadableSerial))
{
return new ReadableSerial(list, iterator, callback);
}
// turn on object mode
ReadableSerial.super_.call(this, {objectMode: true});
this._start(serial, list, iterator, callback);
} | javascript | function ReadableSerial(list, iterator, callback)
{
if (!(this instanceof ReadableSerial))
{
return new ReadableSerial(list, iterator, callback);
}
// turn on object mode
ReadableSerial.super_.call(this, {objectMode: true});
this._start(serial, list, iterator, callback);
} | [
"function",
"ReadableSerial",
"(",
"list",
",",
"iterator",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"ReadableSerial",
")",
")",
"{",
"return",
"new",
"ReadableSerial",
"(",
"list",
",",
"iterator",
",",
"callback",
")",
";",
... | Streaming wrapper to `asynckit.serial`
@param {array|object} list - array or object (named list) to iterate over
@param {function} iterator - iterator to run
@param {function} callback - invoked when all elements processed
@returns {stream.Readable#} | [
"Streaming",
"wrapper",
"to",
"asynckit",
".",
"serial"
] | 583a75ed4fe41761b66416bb6e703ebb1f8963bf | https://github.com/alexindigo/asynckit/blob/583a75ed4fe41761b66416bb6e703ebb1f8963bf/lib/readable_serial.js#L14-L25 | train |
alexindigo/asynckit | lib/streamify.js | wrapIterator | function wrapIterator(iterator)
{
var stream = this;
return function(item, key, cb)
{
var aborter
, wrappedCb = async(wrapIteratorCallback.call(stream, cb, key))
;
stream.jobs[key] = wrappedCb;
// it's either shortcut (item, cb)
if (iterator.length == 2)
{
aborter = iterat... | javascript | function wrapIterator(iterator)
{
var stream = this;
return function(item, key, cb)
{
var aborter
, wrappedCb = async(wrapIteratorCallback.call(stream, cb, key))
;
stream.jobs[key] = wrappedCb;
// it's either shortcut (item, cb)
if (iterator.length == 2)
{
aborter = iterat... | [
"function",
"wrapIterator",
"(",
"iterator",
")",
"{",
"var",
"stream",
"=",
"this",
";",
"return",
"function",
"(",
"item",
",",
"key",
",",
"cb",
")",
"{",
"var",
"aborter",
",",
"wrappedCb",
"=",
"async",
"(",
"wrapIteratorCallback",
".",
"call",
"(",... | Wraps iterators with long signature
@this ReadableAsyncKit#
@param {function} iterator - function to wrap
@returns {function} - wrapped function | [
"Wraps",
"iterators",
"with",
"long",
"signature"
] | 583a75ed4fe41761b66416bb6e703ebb1f8963bf | https://github.com/alexindigo/asynckit/blob/583a75ed4fe41761b66416bb6e703ebb1f8963bf/lib/streamify.js#L16-L41 | train |
alexindigo/asynckit | lib/streamify.js | wrapCallback | function wrapCallback(callback)
{
var stream = this;
var wrapped = function(error, result)
{
return finisher.call(stream, error, result, callback);
};
return wrapped;
} | javascript | function wrapCallback(callback)
{
var stream = this;
var wrapped = function(error, result)
{
return finisher.call(stream, error, result, callback);
};
return wrapped;
} | [
"function",
"wrapCallback",
"(",
"callback",
")",
"{",
"var",
"stream",
"=",
"this",
";",
"var",
"wrapped",
"=",
"function",
"(",
"error",
",",
"result",
")",
"{",
"return",
"finisher",
".",
"call",
"(",
"stream",
",",
"error",
",",
"result",
",",
"cal... | Wraps provided callback function
allowing to execute snitch function before
real callback
@this ReadableAsyncKit#
@param {function} callback - function to wrap
@returns {function} - wrapped function | [
"Wraps",
"provided",
"callback",
"function",
"allowing",
"to",
"execute",
"snitch",
"function",
"before",
"real",
"callback"
] | 583a75ed4fe41761b66416bb6e703ebb1f8963bf | https://github.com/alexindigo/asynckit/blob/583a75ed4fe41761b66416bb6e703ebb1f8963bf/lib/streamify.js#L52-L62 | train |
alexindigo/asynckit | lib/streamify.js | wrapIteratorCallback | function wrapIteratorCallback(callback, key)
{
var stream = this;
return function(error, output)
{
// don't repeat yourself
if (!(key in stream.jobs))
{
callback(error, output);
return;
}
// clean up jobs
delete stream.jobs[key];
return streamer.call(stream, error, {key:... | javascript | function wrapIteratorCallback(callback, key)
{
var stream = this;
return function(error, output)
{
// don't repeat yourself
if (!(key in stream.jobs))
{
callback(error, output);
return;
}
// clean up jobs
delete stream.jobs[key];
return streamer.call(stream, error, {key:... | [
"function",
"wrapIteratorCallback",
"(",
"callback",
",",
"key",
")",
"{",
"var",
"stream",
"=",
"this",
";",
"return",
"function",
"(",
"error",
",",
"output",
")",
"{",
"// don't repeat yourself",
"if",
"(",
"!",
"(",
"key",
"in",
"stream",
".",
"jobs",
... | Wraps provided iterator callback function
makes sure snitch only called once,
but passes secondary calls to the original callback
@this ReadableAsyncKit#
@param {function} callback - callback to wrap
@param {number|string} key - iteration key
@returns {function} wrapped callback | [
"Wraps",
"provided",
"iterator",
"callback",
"function",
"makes",
"sure",
"snitch",
"only",
"called",
"once",
"but",
"passes",
"secondary",
"calls",
"to",
"the",
"original",
"callback"
] | 583a75ed4fe41761b66416bb6e703ebb1f8963bf | https://github.com/alexindigo/asynckit/blob/583a75ed4fe41761b66416bb6e703ebb1f8963bf/lib/streamify.js#L74-L92 | train |
alexindigo/asynckit | lib/streamify.js | streamer | function streamer(error, output, callback)
{
if (error && !this.error)
{
this.error = error;
this.pause();
this.emit('error', error);
// send back value only, as expected
callback(error, output && output.value);
return;
}
// stream stuff
this.push(output);
// back to original track... | javascript | function streamer(error, output, callback)
{
if (error && !this.error)
{
this.error = error;
this.pause();
this.emit('error', error);
// send back value only, as expected
callback(error, output && output.value);
return;
}
// stream stuff
this.push(output);
// back to original track... | [
"function",
"streamer",
"(",
"error",
",",
"output",
",",
"callback",
")",
"{",
"if",
"(",
"error",
"&&",
"!",
"this",
".",
"error",
")",
"{",
"this",
".",
"error",
"=",
"error",
";",
"this",
".",
"pause",
"(",
")",
";",
"this",
".",
"emit",
"(",... | Stream wrapper for iterator callback
@this ReadableAsyncKit#
@param {mixed} error - error response
@param {mixed} output - iterator output
@param {function} callback - callback that expects iterator results | [
"Stream",
"wrapper",
"for",
"iterator",
"callback"
] | 583a75ed4fe41761b66416bb6e703ebb1f8963bf | https://github.com/alexindigo/asynckit/blob/583a75ed4fe41761b66416bb6e703ebb1f8963bf/lib/streamify.js#L102-L120 | train |
alexindigo/asynckit | lib/streamify.js | finisher | function finisher(error, output, callback)
{
// signal end of the stream
// only for successfully finished streams
if (!error)
{
this.push(null);
}
// back to original track
callback(error, output);
} | javascript | function finisher(error, output, callback)
{
// signal end of the stream
// only for successfully finished streams
if (!error)
{
this.push(null);
}
// back to original track
callback(error, output);
} | [
"function",
"finisher",
"(",
"error",
",",
"output",
",",
"callback",
")",
"{",
"// signal end of the stream",
"// only for successfully finished streams",
"if",
"(",
"!",
"error",
")",
"{",
"this",
".",
"push",
"(",
"null",
")",
";",
"}",
"// back to original tra... | Stream wrapper for finishing callback
@this ReadableAsyncKit#
@param {mixed} error - error response
@param {mixed} output - iterator output
@param {function} callback - callback that expects final results | [
"Stream",
"wrapper",
"for",
"finishing",
"callback"
] | 583a75ed4fe41761b66416bb6e703ebb1f8963bf | https://github.com/alexindigo/asynckit/blob/583a75ed4fe41761b66416bb6e703ebb1f8963bf/lib/streamify.js#L130-L141 | train |
alexindigo/asynckit | lib/iterate.js | iterate | function iterate(list, iterator, state, callback)
{
// store current index
var key = state['keyedList'] ? state['keyedList'][state.index] : state.index;
state.jobs[key] = runJob(iterator, key, list[key], function(error, output)
{
// don't repeat yourself
// skip secondary callbacks
if (!(key in sta... | javascript | function iterate(list, iterator, state, callback)
{
// store current index
var key = state['keyedList'] ? state['keyedList'][state.index] : state.index;
state.jobs[key] = runJob(iterator, key, list[key], function(error, output)
{
// don't repeat yourself
// skip secondary callbacks
if (!(key in sta... | [
"function",
"iterate",
"(",
"list",
",",
"iterator",
",",
"state",
",",
"callback",
")",
"{",
"// store current index",
"var",
"key",
"=",
"state",
"[",
"'keyedList'",
"]",
"?",
"state",
"[",
"'keyedList'",
"]",
"[",
"state",
".",
"index",
"]",
":",
"sta... | Iterates over each job object
@param {array|object} list - array or object (named list) to iterate over
@param {function} iterator - iterator to run
@param {object} state - current job status
@param {function} callback - invoked when all elements processed | [
"Iterates",
"over",
"each",
"job",
"object"
] | 583a75ed4fe41761b66416bb6e703ebb1f8963bf | https://github.com/alexindigo/asynckit/blob/583a75ed4fe41761b66416bb6e703ebb1f8963bf/lib/iterate.js#L16-L48 | train |
alexindigo/asynckit | lib/iterate.js | runJob | function runJob(iterator, key, item, callback)
{
var aborter;
// allow shortcut if iterator expects only two arguments
if (iterator.length == 2)
{
aborter = iterator(item, async(callback));
}
// otherwise go with full three arguments
else
{
aborter = iterator(item, key, async(callback));
}
... | javascript | function runJob(iterator, key, item, callback)
{
var aborter;
// allow shortcut if iterator expects only two arguments
if (iterator.length == 2)
{
aborter = iterator(item, async(callback));
}
// otherwise go with full three arguments
else
{
aborter = iterator(item, key, async(callback));
}
... | [
"function",
"runJob",
"(",
"iterator",
",",
"key",
",",
"item",
",",
"callback",
")",
"{",
"var",
"aborter",
";",
"// allow shortcut if iterator expects only two arguments",
"if",
"(",
"iterator",
".",
"length",
"==",
"2",
")",
"{",
"aborter",
"=",
"iterator",
... | Runs iterator over provided job element
@param {function} iterator - iterator to invoke
@param {string|number} key - key/index of the element in the list of jobs
@param {mixed} item - job description
@param {function} callback - invoked after iterator is done with the job
@returns {function|mixed} - job abort ... | [
"Runs",
"iterator",
"over",
"provided",
"job",
"element"
] | 583a75ed4fe41761b66416bb6e703ebb1f8963bf | https://github.com/alexindigo/asynckit/blob/583a75ed4fe41761b66416bb6e703ebb1f8963bf/lib/iterate.js#L59-L75 | train |
alexindigo/asynckit | serialOrdered.js | serialOrdered | function serialOrdered(list, iterator, sortMethod, callback)
{
var state = initState(list, sortMethod);
iterate(list, iterator, state, function iteratorHandler(error, result)
{
if (error)
{
callback(error, result);
return;
}
state.index++;
// are we there yet?
if (state.inde... | javascript | function serialOrdered(list, iterator, sortMethod, callback)
{
var state = initState(list, sortMethod);
iterate(list, iterator, state, function iteratorHandler(error, result)
{
if (error)
{
callback(error, result);
return;
}
state.index++;
// are we there yet?
if (state.inde... | [
"function",
"serialOrdered",
"(",
"list",
",",
"iterator",
",",
"sortMethod",
",",
"callback",
")",
"{",
"var",
"state",
"=",
"initState",
"(",
"list",
",",
"sortMethod",
")",
";",
"iterate",
"(",
"list",
",",
"iterator",
",",
"state",
",",
"function",
"... | Runs iterator over provided sorted array elements in series
@param {array|object} list - array or object (named list) to iterate over
@param {function} iterator - iterator to run
@param {function} sortMethod - custom sort function
@param {function} callback - invoked when all elements processed
@returns {funct... | [
"Runs",
"iterator",
"over",
"provided",
"sorted",
"array",
"elements",
"in",
"series"
] | 583a75ed4fe41761b66416bb6e703ebb1f8963bf | https://github.com/alexindigo/asynckit/blob/583a75ed4fe41761b66416bb6e703ebb1f8963bf/serialOrdered.js#L21-L47 | train |
alexindigo/asynckit | lib/readable_parallel.js | ReadableParallel | function ReadableParallel(list, iterator, callback)
{
if (!(this instanceof ReadableParallel))
{
return new ReadableParallel(list, iterator, callback);
}
// turn on object mode
ReadableParallel.super_.call(this, {objectMode: true});
this._start(parallel, list, iterator, callback);
} | javascript | function ReadableParallel(list, iterator, callback)
{
if (!(this instanceof ReadableParallel))
{
return new ReadableParallel(list, iterator, callback);
}
// turn on object mode
ReadableParallel.super_.call(this, {objectMode: true});
this._start(parallel, list, iterator, callback);
} | [
"function",
"ReadableParallel",
"(",
"list",
",",
"iterator",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"ReadableParallel",
")",
")",
"{",
"return",
"new",
"ReadableParallel",
"(",
"list",
",",
"iterator",
",",
"callback",
")",
... | Streaming wrapper to `asynckit.parallel`
@param {array|object} list - array or object (named list) to iterate over
@param {function} iterator - iterator to run
@param {function} callback - invoked when all elements processed
@returns {stream.Readable#} | [
"Streaming",
"wrapper",
"to",
"asynckit",
".",
"parallel"
] | 583a75ed4fe41761b66416bb6e703ebb1f8963bf | https://github.com/alexindigo/asynckit/blob/583a75ed4fe41761b66416bb6e703ebb1f8963bf/lib/readable_parallel.js#L14-L25 | train |
alexindigo/asynckit | lib/readable_serial_ordered.js | ReadableSerialOrdered | function ReadableSerialOrdered(list, iterator, sortMethod, callback)
{
if (!(this instanceof ReadableSerialOrdered))
{
return new ReadableSerialOrdered(list, iterator, sortMethod, callback);
}
// turn on object mode
ReadableSerialOrdered.super_.call(this, {objectMode: true});
this._start(serialOrdered... | javascript | function ReadableSerialOrdered(list, iterator, sortMethod, callback)
{
if (!(this instanceof ReadableSerialOrdered))
{
return new ReadableSerialOrdered(list, iterator, sortMethod, callback);
}
// turn on object mode
ReadableSerialOrdered.super_.call(this, {objectMode: true});
this._start(serialOrdered... | [
"function",
"ReadableSerialOrdered",
"(",
"list",
",",
"iterator",
",",
"sortMethod",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"ReadableSerialOrdered",
")",
")",
"{",
"return",
"new",
"ReadableSerialOrdered",
"(",
"list",
",",
"ite... | Streaming wrapper to `asynckit.serialOrdered`
@param {array|object} list - array or object (named list) to iterate over
@param {function} iterator - iterator to run
@param {function} sortMethod - custom sort function
@param {function} callback - invoked when all elements processed
@returns {stream.Readable#} | [
"Streaming",
"wrapper",
"to",
"asynckit",
".",
"serialOrdered"
] | 583a75ed4fe41761b66416bb6e703ebb1f8963bf | https://github.com/alexindigo/asynckit/blob/583a75ed4fe41761b66416bb6e703ebb1f8963bf/lib/readable_serial_ordered.js#L18-L29 | train |
alexindigo/asynckit | lib/readable_asynckit.js | _start | function _start()
{
// first argument – runner function
var runner = arguments[0]
// take away first argument
, args = Array.prototype.slice.call(arguments, 1)
// second argument - input data
, input = args[0]
// last argument - result callback
, endCb = streamify.callback.call(this,... | javascript | function _start()
{
// first argument – runner function
var runner = arguments[0]
// take away first argument
, args = Array.prototype.slice.call(arguments, 1)
// second argument - input data
, input = args[0]
// last argument - result callback
, endCb = streamify.callback.call(this,... | [
"function",
"_start",
"(",
")",
"{",
"// first argument – runner function",
"var",
"runner",
"=",
"arguments",
"[",
"0",
"]",
"// take away first argument",
",",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")"... | Starts provided jobs in async manner
@private | [
"Starts",
"provided",
"jobs",
"in",
"async",
"manner"
] | 583a75ed4fe41761b66416bb6e703ebb1f8963bf | https://github.com/alexindigo/asynckit/blob/583a75ed4fe41761b66416bb6e703ebb1f8963bf/lib/readable_asynckit.js#L51-L79 | train |
alexindigo/asynckit | lib/state.js | state | function state(list, sortMethod)
{
var isNamedList = !Array.isArray(list)
, initState =
{
index : 0,
keyedList: isNamedList || sortMethod ? Object.keys(list) : null,
jobs : {},
results : isNamedList ? {} : [],
size : isNamedList ? Object.keys(list).length : list.lengt... | javascript | function state(list, sortMethod)
{
var isNamedList = !Array.isArray(list)
, initState =
{
index : 0,
keyedList: isNamedList || sortMethod ? Object.keys(list) : null,
jobs : {},
results : isNamedList ? {} : [],
size : isNamedList ? Object.keys(list).length : list.lengt... | [
"function",
"state",
"(",
"list",
",",
"sortMethod",
")",
"{",
"var",
"isNamedList",
"=",
"!",
"Array",
".",
"isArray",
"(",
"list",
")",
",",
"initState",
"=",
"{",
"index",
":",
"0",
",",
"keyedList",
":",
"isNamedList",
"||",
"sortMethod",
"?",
"Obj... | Creates initial state object
for iteration over list
@param {array|object} list - list to iterate over
@param {function|null} sortMethod - function to use for keys sort,
or `null` to keep them as is
@returns {object} - initial state object | [
"Creates",
"initial",
"state",
"object",
"for",
"iteration",
"over",
"list"
] | 583a75ed4fe41761b66416bb6e703ebb1f8963bf | https://github.com/alexindigo/asynckit/blob/583a75ed4fe41761b66416bb6e703ebb1f8963bf/lib/state.js#L13-L37 | train |
alexindigo/asynckit | lib/abort.js | abort | function abort(state)
{
Object.keys(state.jobs).forEach(clean.bind(state));
// reset leftover jobs
state.jobs = {};
} | javascript | function abort(state)
{
Object.keys(state.jobs).forEach(clean.bind(state));
// reset leftover jobs
state.jobs = {};
} | [
"function",
"abort",
"(",
"state",
")",
"{",
"Object",
".",
"keys",
"(",
"state",
".",
"jobs",
")",
".",
"forEach",
"(",
"clean",
".",
"bind",
"(",
"state",
")",
")",
";",
"// reset leftover jobs",
"state",
".",
"jobs",
"=",
"{",
"}",
";",
"}"
] | Aborts leftover active jobs
@param {object} state - current state object | [
"Aborts",
"leftover",
"active",
"jobs"
] | 583a75ed4fe41761b66416bb6e703ebb1f8963bf | https://github.com/alexindigo/asynckit/blob/583a75ed4fe41761b66416bb6e703ebb1f8963bf/lib/abort.js#L9-L15 | train |
alexindigo/asynckit | lib/async.js | async | function async(callback)
{
var isAsync = false;
// check if async happened
defer(function() { isAsync = true; });
return function async_callback(err, result)
{
if (isAsync)
{
callback(err, result);
}
else
{
defer(function nextTick_callback()
{
callback(err, resu... | javascript | function async(callback)
{
var isAsync = false;
// check if async happened
defer(function() { isAsync = true; });
return function async_callback(err, result)
{
if (isAsync)
{
callback(err, result);
}
else
{
defer(function nextTick_callback()
{
callback(err, resu... | [
"function",
"async",
"(",
"callback",
")",
"{",
"var",
"isAsync",
"=",
"false",
";",
"// check if async happened",
"defer",
"(",
"function",
"(",
")",
"{",
"isAsync",
"=",
"true",
";",
"}",
")",
";",
"return",
"function",
"async_callback",
"(",
"err",
",",... | Runs provided callback asynchronously
even if callback itself is not
@param {function} callback - callback to invoke
@returns {function} - augmented callback | [
"Runs",
"provided",
"callback",
"asynchronously",
"even",
"if",
"callback",
"itself",
"is",
"not"
] | 583a75ed4fe41761b66416bb6e703ebb1f8963bf | https://github.com/alexindigo/asynckit/blob/583a75ed4fe41761b66416bb6e703ebb1f8963bf/lib/async.js#L13-L34 | train |
alexindigo/asynckit | parallel.js | parallel | function parallel(list, iterator, callback)
{
var state = initState(list);
while (state.index < (state['keyedList'] || list).length)
{
iterate(list, iterator, state, function(error, result)
{
if (error)
{
callback(error, result);
return;
}
// looks like it's the l... | javascript | function parallel(list, iterator, callback)
{
var state = initState(list);
while (state.index < (state['keyedList'] || list).length)
{
iterate(list, iterator, state, function(error, result)
{
if (error)
{
callback(error, result);
return;
}
// looks like it's the l... | [
"function",
"parallel",
"(",
"list",
",",
"iterator",
",",
"callback",
")",
"{",
"var",
"state",
"=",
"initState",
"(",
"list",
")",
";",
"while",
"(",
"state",
".",
"index",
"<",
"(",
"state",
"[",
"'keyedList'",
"]",
"||",
"list",
")",
".",
"length... | Runs iterator over provided array elements in parallel
@param {array|object} list - array or object (named list) to iterate over
@param {function} iterator - iterator to run
@param {function} callback - invoked when all elements processed
@returns {function} - jobs terminator | [
"Runs",
"iterator",
"over",
"provided",
"array",
"elements",
"in",
"parallel"
] | 583a75ed4fe41761b66416bb6e703ebb1f8963bf | https://github.com/alexindigo/asynckit/blob/583a75ed4fe41761b66416bb6e703ebb1f8963bf/parallel.js#L17-L43 | train |
alexindigo/asynckit | lib/terminator.js | terminator | function terminator(callback)
{
if (!Object.keys(this.jobs).length)
{
return;
}
// fast forward iteration index
this.index = this.size;
// abort jobs
abort(this);
// send back results we have so far
async(callback)(null, this.results);
} | javascript | function terminator(callback)
{
if (!Object.keys(this.jobs).length)
{
return;
}
// fast forward iteration index
this.index = this.size;
// abort jobs
abort(this);
// send back results we have so far
async(callback)(null, this.results);
} | [
"function",
"terminator",
"(",
"callback",
")",
"{",
"if",
"(",
"!",
"Object",
".",
"keys",
"(",
"this",
".",
"jobs",
")",
".",
"length",
")",
"{",
"return",
";",
"}",
"// fast forward iteration index",
"this",
".",
"index",
"=",
"this",
".",
"size",
"... | Terminates jobs in the attached state context
@this AsyncKitState#
@param {function} callback - final callback to invoke after termination | [
"Terminates",
"jobs",
"in",
"the",
"attached",
"state",
"context"
] | 583a75ed4fe41761b66416bb6e703ebb1f8963bf | https://github.com/alexindigo/asynckit/blob/583a75ed4fe41761b66416bb6e703ebb1f8963bf/lib/terminator.js#L14-L29 | train |
af83/oauth2_client_node | lib/oauth2_client.js | function(serverName, config, options) {
this.methods[serverName] = {};
this.config.servers[serverName] = config;
var self = this;
['valid_grant', 'treat_access_token', 'transform_token_response'].forEach(function(fctName) {
self.methods[serverName][fctName] = options[fctName] || self[fctName].bind... | javascript | function(serverName, config, options) {
this.methods[serverName] = {};
this.config.servers[serverName] = config;
var self = this;
['valid_grant', 'treat_access_token', 'transform_token_response'].forEach(function(fctName) {
self.methods[serverName][fctName] = options[fctName] || self[fctName].bind... | [
"function",
"(",
"serverName",
",",
"config",
",",
"options",
")",
"{",
"this",
".",
"methods",
"[",
"serverName",
"]",
"=",
"{",
"}",
";",
"this",
".",
"config",
".",
"servers",
"[",
"serverName",
"]",
"=",
"config",
";",
"var",
"self",
"=",
"this",... | Add oauth2 server | [
"Add",
"oauth2",
"server"
] | 40d5e56e717f88f6b2b9a725ca77a90b0a775535 | https://github.com/af83/oauth2_client_node/blob/40d5e56e717f88f6b2b9a725ca77a90b0a775535/lib/oauth2_client.js#L44-L51 | train | |
af83/oauth2_client_node | lib/oauth2_client.js | function(data, code, callback) {
var self = this;
var cconfig = this.config.client;
var sconfig = this.config.servers[data.oauth2_server_id];
request.post({uri: sconfig.server_token_endpoint,
headers: {'content-type': 'application/x-www-form-urlencoded'},
body: querys... | javascript | function(data, code, callback) {
var self = this;
var cconfig = this.config.client;
var sconfig = this.config.servers[data.oauth2_server_id];
request.post({uri: sconfig.server_token_endpoint,
headers: {'content-type': 'application/x-www-form-urlencoded'},
body: querys... | [
"function",
"(",
"data",
",",
"code",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"cconfig",
"=",
"this",
".",
"config",
".",
"client",
";",
"var",
"sconfig",
"=",
"this",
".",
"config",
".",
"servers",
"[",
"data",
".",
"oau... | Valid the grant given by user requesting the OAuth2 server
at OAuth2 token endpoint.
Arguments:
- data: hash containing:
- oauth2_server_id: string, the OAuth2 server is (ex: "facebook.com").
- next_url: string, the next_url associated with the OAuth2 request.
- state: hash, state associated with the OAuth2 request.
-... | [
"Valid",
"the",
"grant",
"given",
"by",
"user",
"requesting",
"the",
"OAuth2",
"server",
"at",
"OAuth2",
"token",
"endpoint",
"."
] | 40d5e56e717f88f6b2b9a725ca77a90b0a775535 | https://github.com/af83/oauth2_client_node/blob/40d5e56e717f88f6b2b9a725ca77a90b0a775535/lib/oauth2_client.js#L87-L116 | train | |
af83/oauth2_client_node | lib/oauth2_client.js | function(req, res) {
var params = URL.parse(req.url, true).query
, code = params.code
, state = params.state
;
if(!code) {
res.writeHead(400, {'Content-Type': 'text/plain'});
return res.end('The "code" parameter is missing.');
}
if(!state) {
res.writeHead(400, {'Conten... | javascript | function(req, res) {
var params = URL.parse(req.url, true).query
, code = params.code
, state = params.state
;
if(!code) {
res.writeHead(400, {'Content-Type': 'text/plain'});
return res.end('The "code" parameter is missing.');
}
if(!state) {
res.writeHead(400, {'Conten... | [
"function",
"(",
"req",
",",
"res",
")",
"{",
"var",
"params",
"=",
"URL",
".",
"parse",
"(",
"req",
".",
"url",
",",
"true",
")",
".",
"query",
",",
"code",
"=",
"params",
".",
"code",
",",
"state",
"=",
"params",
".",
"state",
";",
"if",
"(",... | Check the grant given by user to login in authserver is a good one.
Arguments:
- req
- res | [
"Check",
"the",
"grant",
"given",
"by",
"user",
"to",
"login",
"in",
"authserver",
"is",
"a",
"good",
"one",
"."
] | 40d5e56e717f88f6b2b9a725ca77a90b0a775535 | https://github.com/af83/oauth2_client_node/blob/40d5e56e717f88f6b2b9a725ca77a90b0a775535/lib/oauth2_client.js#L150-L188 | train | |
af83/oauth2_client_node | lib/oauth2_client.js | function(oauth2_server_id, res, next_url, state) {
var sconfig = this.config.servers[oauth2_server_id];
var cconfig = this.config.client;
var data = {
client_id: sconfig.client_id,
redirect_uri: cconfig.redirect_uri,
response_type: 'code',
state: this.serializer.stringify([oauth2_ser... | javascript | function(oauth2_server_id, res, next_url, state) {
var sconfig = this.config.servers[oauth2_server_id];
var cconfig = this.config.client;
var data = {
client_id: sconfig.client_id,
redirect_uri: cconfig.redirect_uri,
response_type: 'code',
state: this.serializer.stringify([oauth2_ser... | [
"function",
"(",
"oauth2_server_id",
",",
"res",
",",
"next_url",
",",
"state",
")",
"{",
"var",
"sconfig",
"=",
"this",
".",
"config",
".",
"servers",
"[",
"oauth2_server_id",
"]",
";",
"var",
"cconfig",
"=",
"this",
".",
"config",
".",
"client",
";",
... | Redirects the user to OAuth2 server for authentication.
Arguments:
- oauth2_server_id: OAuth2 server identification (ex: "facebook.com").
- res
- next_url: an url to redirect to once the process is complete.
- state: optional, a hash containing info you want to retrieve at the end
of the process. | [
"Redirects",
"the",
"user",
"to",
"OAuth2",
"server",
"for",
"authentication",
"."
] | 40d5e56e717f88f6b2b9a725ca77a90b0a775535 | https://github.com/af83/oauth2_client_node/blob/40d5e56e717f88f6b2b9a725ca77a90b0a775535/lib/oauth2_client.js#L200-L211 | train | |
af83/oauth2_client_node | lib/oauth2_client.js | function(req, params) {
if(!params) {
params = URL.parse(req.url, true).query;
}
var cconfig = this.config.client;
var next = params.next || cconfig.default_redirection_url;
var url = cconfig.base_url + next;
return url;
} | javascript | function(req, params) {
if(!params) {
params = URL.parse(req.url, true).query;
}
var cconfig = this.config.client;
var next = params.next || cconfig.default_redirection_url;
var url = cconfig.base_url + next;
return url;
} | [
"function",
"(",
"req",
",",
"params",
")",
"{",
"if",
"(",
"!",
"params",
")",
"{",
"params",
"=",
"URL",
".",
"parse",
"(",
"req",
".",
"url",
",",
"true",
")",
".",
"query",
";",
"}",
"var",
"cconfig",
"=",
"this",
".",
"config",
".",
"clien... | Returns value of next url query parameter if present, default otherwise.
The next query parameter should not contain the domain, the result will. | [
"Returns",
"value",
"of",
"next",
"url",
"query",
"parameter",
"if",
"present",
"default",
"otherwise",
".",
"The",
"next",
"query",
"parameter",
"should",
"not",
"contain",
"the",
"domain",
"the",
"result",
"will",
"."
] | 40d5e56e717f88f6b2b9a725ca77a90b0a775535 | https://github.com/af83/oauth2_client_node/blob/40d5e56e717f88f6b2b9a725ca77a90b0a775535/lib/oauth2_client.js#L217-L225 | train | |
af83/oauth2_client_node | lib/oauth2_client.js | function(req, res) {
var params = URL.parse(req.url, true).query;
var oauth2_server_id = params.provider || this.config.default_server;
var next_url = this.nexturl_query(req, params);
this.redirects_for_login(oauth2_server_id, res, next_url);
} | javascript | function(req, res) {
var params = URL.parse(req.url, true).query;
var oauth2_server_id = params.provider || this.config.default_server;
var next_url = this.nexturl_query(req, params);
this.redirects_for_login(oauth2_server_id, res, next_url);
} | [
"function",
"(",
"req",
",",
"res",
")",
"{",
"var",
"params",
"=",
"URL",
".",
"parse",
"(",
"req",
".",
"url",
",",
"true",
")",
".",
"query",
";",
"var",
"oauth2_server_id",
"=",
"params",
".",
"provider",
"||",
"this",
".",
"config",
".",
"defa... | Triggers redirects_for_login with next param if present in url query. | [
"Triggers",
"redirects_for_login",
"with",
"next",
"param",
"if",
"present",
"in",
"url",
"query",
"."
] | 40d5e56e717f88f6b2b9a725ca77a90b0a775535 | https://github.com/af83/oauth2_client_node/blob/40d5e56e717f88f6b2b9a725ca77a90b0a775535/lib/oauth2_client.js#L238-L243 | train | |
af83/oauth2_client_node | lib/oauth2_client.js | function() {
var client = this;
var cconf = this.config.client;
return router(function(app) {
app.get(cconf.process_login_url, client.auth_process_login.bind(client));
app.get(cconf.login_url, client.login.bind(client));
app.get(cconf.logout_url, client.logout.bind(client));
});
} | javascript | function() {
var client = this;
var cconf = this.config.client;
return router(function(app) {
app.get(cconf.process_login_url, client.auth_process_login.bind(client));
app.get(cconf.login_url, client.login.bind(client));
app.get(cconf.logout_url, client.logout.bind(client));
});
} | [
"function",
"(",
")",
"{",
"var",
"client",
"=",
"this",
";",
"var",
"cconf",
"=",
"this",
".",
"config",
".",
"client",
";",
"return",
"router",
"(",
"function",
"(",
"app",
")",
"{",
"app",
".",
"get",
"(",
"cconf",
".",
"process_login_url",
",",
... | Returns OAuth2 client connect middleware.
This middleware will intercep requests aiming at OAuth2 client
and treat them. | [
"Returns",
"OAuth2",
"client",
"connect",
"middleware",
"."
] | 40d5e56e717f88f6b2b9a725ca77a90b0a775535 | https://github.com/af83/oauth2_client_node/blob/40d5e56e717f88f6b2b9a725ca77a90b0a775535/lib/oauth2_client.js#L251-L260 | train | |
af83/oauth2_client_node | lib/oauth2_client.js | createClient | function createClient(conf, options) {
conf.default_redirection_url = conf.default_redirection_url || '/';
options = options || {};
return new OAuth2Client(conf, options);
} | javascript | function createClient(conf, options) {
conf.default_redirection_url = conf.default_redirection_url || '/';
options = options || {};
return new OAuth2Client(conf, options);
} | [
"function",
"createClient",
"(",
"conf",
",",
"options",
")",
"{",
"conf",
".",
"default_redirection_url",
"=",
"conf",
".",
"default_redirection_url",
"||",
"'/'",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"return",
"new",
"OAuth2Client",
"(",
"c... | Returns OAuth2 client
Arguments:
- config: hash containing:
- client, hash containing:
- base_url: The base URL of the OAuth2 client.
Ex: http://domain.com:8080
- process_login_url: the URL where to the OAuth2 server must redirect
the user when authenticated.
- login_url: the URL where the user must go to be redirect... | [
"Returns",
"OAuth2",
"client"
] | 40d5e56e717f88f6b2b9a725ca77a90b0a775535 | https://github.com/af83/oauth2_client_node/blob/40d5e56e717f88f6b2b9a725ca77a90b0a775535/lib/oauth2_client.js#L314-L318 | train |
bvalosek/tiny-ecs | lib/Loop.js | Loop | function Loop(messenger)
{
// Messenger we'll use for clock signals
this.messenger = messenger || new Messenger();
this.fixedDuration = 8;
this.started = false;
// Live stats
this.currentTime = 0;
this.fixedStepsPerFrame = 0;
this.fixedTimePerFrame = 0;
this.renderTimePerFrame = 0;
t... | javascript | function Loop(messenger)
{
// Messenger we'll use for clock signals
this.messenger = messenger || new Messenger();
this.fixedDuration = 8;
this.started = false;
// Live stats
this.currentTime = 0;
this.fixedStepsPerFrame = 0;
this.fixedTimePerFrame = 0;
this.renderTimePerFrame = 0;
t... | [
"function",
"Loop",
"(",
"messenger",
")",
"{",
"// Messenger we'll use for clock signals",
"this",
".",
"messenger",
"=",
"messenger",
"||",
"new",
"Messenger",
"(",
")",
";",
"this",
".",
"fixedDuration",
"=",
"8",
";",
"this",
".",
"started",
"=",
"false",
... | Game loop with independent clock events for fixed durations and variable
durations.
@param {Messenger} messenger
@constructor | [
"Game",
"loop",
"with",
"independent",
"clock",
"events",
"for",
"fixed",
"durations",
"and",
"variable",
"durations",
"."
] | c74f65660f622a9a32eca200f49fafc1728e6d4d | https://github.com/bvalosek/tiny-ecs/blob/c74f65660f622a9a32eca200f49fafc1728e6d4d/lib/Loop.js#L11-L25 | train |
ryanseys/lune | lib/lune.js | kepler | function kepler (m, ecc) {
const epsilon = 1e-6
m = torad(m)
let e = m
while (1) {
const delta = e - ecc * Math.sin(e) - m
e -= delta / (1.0 - ecc * Math.cos(e))
if (Math.abs(delta) <= epsilon) {
break
}
}
return e
} | javascript | function kepler (m, ecc) {
const epsilon = 1e-6
m = torad(m)
let e = m
while (1) {
const delta = e - ecc * Math.sin(e) - m
e -= delta / (1.0 - ecc * Math.cos(e))
if (Math.abs(delta) <= epsilon) {
break
}
}
return e
} | [
"function",
"kepler",
"(",
"m",
",",
"ecc",
")",
"{",
"const",
"epsilon",
"=",
"1e-6",
"m",
"=",
"torad",
"(",
"m",
")",
"let",
"e",
"=",
"m",
"while",
"(",
"1",
")",
"{",
"const",
"delta",
"=",
"e",
"-",
"ecc",
"*",
"Math",
".",
"sin",
"(",
... | Solve the equation of Kepler. | [
"Solve",
"the",
"equation",
"of",
"Kepler",
"."
] | 667d6ff778d0deb2cd09988e3d89eb8ca0428a23 | https://github.com/ryanseys/lune/blob/667d6ff778d0deb2cd09988e3d89eb8ca0428a23/lib/lune.js#L99-L114 | train |
ryanseys/lune | lib/lune.js | phase | function phase (phase_date) {
if (!phase_date) {
phase_date = new Date()
}
phase_date = julian.fromDate(phase_date)
const day = phase_date - EPOCH
// calculate sun position
const sun_mean_anomaly =
(360.0 / 365.2422) * day +
(ECLIPTIC_LONGITUDE_EPOCH - ECLIPTIC_LONGITUDE_PERIGEE)
const sun_t... | javascript | function phase (phase_date) {
if (!phase_date) {
phase_date = new Date()
}
phase_date = julian.fromDate(phase_date)
const day = phase_date - EPOCH
// calculate sun position
const sun_mean_anomaly =
(360.0 / 365.2422) * day +
(ECLIPTIC_LONGITUDE_EPOCH - ECLIPTIC_LONGITUDE_PERIGEE)
const sun_t... | [
"function",
"phase",
"(",
"phase_date",
")",
"{",
"if",
"(",
"!",
"phase_date",
")",
"{",
"phase_date",
"=",
"new",
"Date",
"(",
")",
"}",
"phase_date",
"=",
"julian",
".",
"fromDate",
"(",
"phase_date",
")",
"const",
"day",
"=",
"phase_date",
"-",
"EP... | Finds the phase information for specific date.
@param {Date} phase_date Date to get phase information of.
@return {Object} Phase data | [
"Finds",
"the",
"phase",
"information",
"for",
"specific",
"date",
"."
] | 667d6ff778d0deb2cd09988e3d89eb8ca0428a23 | https://github.com/ryanseys/lune/blob/667d6ff778d0deb2cd09988e3d89eb8ca0428a23/lib/lune.js#L121-L190 | train |
ryanseys/lune | lib/lune.js | phase_hunt | function phase_hunt (sdate) {
if (!sdate) {
sdate = new Date()
}
let adate = new Date(sdate.getTime() - (45 * 86400000)) // 45 days prior
let k1 = Math.floor(12.3685 * (adate.getFullYear() + (1.0 / 12.0) * adate.getMonth() - 1900))
let nt1 = meanphase(adate.getTime(), k1)
sdate = julian.fromDate(sdate... | javascript | function phase_hunt (sdate) {
if (!sdate) {
sdate = new Date()
}
let adate = new Date(sdate.getTime() - (45 * 86400000)) // 45 days prior
let k1 = Math.floor(12.3685 * (adate.getFullYear() + (1.0 / 12.0) * adate.getMonth() - 1900))
let nt1 = meanphase(adate.getTime(), k1)
sdate = julian.fromDate(sdate... | [
"function",
"phase_hunt",
"(",
"sdate",
")",
"{",
"if",
"(",
"!",
"sdate",
")",
"{",
"sdate",
"=",
"new",
"Date",
"(",
")",
"}",
"let",
"adate",
"=",
"new",
"Date",
"(",
"sdate",
".",
"getTime",
"(",
")",
"-",
"(",
"45",
"*",
"86400000",
")",
"... | Find time of phases of the moon which surround the current date.
Five phases are found, starting and ending with the new moons
which bound the current lunation.
@param {Date} sdate Date to start hunting from (defaults to current date)
@return {Object} Object containing recent past and future phases | [
"Find",
"time",
"of",
"phases",
"of",
"the",
"moon",
"which",
"surround",
"the",
"current",
"date",
".",
"Five",
"phases",
"are",
"found",
"starting",
"and",
"ending",
"with",
"the",
"new",
"moons",
"which",
"bound",
"the",
"current",
"lunation",
"."
] | 667d6ff778d0deb2cd09988e3d89eb8ca0428a23 | https://github.com/ryanseys/lune/blob/667d6ff778d0deb2cd09988e3d89eb8ca0428a23/lib/lune.js#L301-L329 | train |
dundalek/react-blessed-contrib | examples/dashboard.js | generateTable | function generateTable() {
var data = []
for (var i=0; i<30; i++) {
var row = []
row.push(commands[Math.round(Math.random()*(commands.length-1))])
row.push(Math.round(Math.random()*5))
row.push(Math.round(Math.random()*100))
data.push(row)
}
return {headers: ['Process', 'Cpu (%)',... | javascript | function generateTable() {
var data = []
for (var i=0; i<30; i++) {
var row = []
row.push(commands[Math.round(Math.random()*(commands.length-1))])
row.push(Math.round(Math.random()*5))
row.push(Math.round(Math.random()*100))
data.push(row)
}
return {headers: ['Process', 'Cpu (%)',... | [
"function",
"generateTable",
"(",
")",
"{",
"var",
"data",
"=",
"[",
"]",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"30",
";",
"i",
"++",
")",
"{",
"var",
"row",
"=",
"[",
"]",
"row",
".",
"push",
"(",
"commands",
"[",
"Math",
".",
"... | set dummy data for table | [
"set",
"dummy",
"data",
"for",
"table"
] | 2beb36f4416665aaca5dfb85a49dbcd625911e1d | https://github.com/dundalek/react-blessed-contrib/blob/2beb36f4416665aaca5dfb85a49dbcd625911e1d/examples/dashboard.js#L13-L25 | train |
dundalek/react-blessed-contrib | src/index.js | Grid | function Grid(props) {
const grid = new contrib.grid({...props, screen: { append: () => {} }});
const children = props.children instanceof Array ? props.children : [props.children];
return React.createElement(props.component || 'element', {}, children.map((child, key) => {
const props = child.props;
const... | javascript | function Grid(props) {
const grid = new contrib.grid({...props, screen: { append: () => {} }});
const children = props.children instanceof Array ? props.children : [props.children];
return React.createElement(props.component || 'element', {}, children.map((child, key) => {
const props = child.props;
const... | [
"function",
"Grid",
"(",
"props",
")",
"{",
"const",
"grid",
"=",
"new",
"contrib",
".",
"grid",
"(",
"{",
"...",
"props",
",",
"screen",
":",
"{",
"append",
":",
"(",
")",
"=>",
"{",
"}",
"}",
"}",
")",
";",
"const",
"children",
"=",
"props",
... | We stub methods for contrib.grid to let it compute params for us which we then render in the React way | [
"We",
"stub",
"methods",
"for",
"contrib",
".",
"grid",
"to",
"let",
"it",
"compute",
"params",
"for",
"us",
"which",
"we",
"then",
"render",
"in",
"the",
"React",
"way"
] | 2beb36f4416665aaca5dfb85a49dbcd625911e1d | https://github.com/dundalek/react-blessed-contrib/blob/2beb36f4416665aaca5dfb85a49dbcd625911e1d/src/index.js#L53-L62 | train |
grncdr/js-shell-parse | build.js | parse | function parse (input, opts) {
// Wrap parser.parse to allow specifying the start rule
// as a shorthand option
if (!opts) {
opts = {}
}
else if (typeof opts == 'string') {
opts = { startRule: opts }
}
return parser.parse(input, opts)
} | javascript | function parse (input, opts) {
// Wrap parser.parse to allow specifying the start rule
// as a shorthand option
if (!opts) {
opts = {}
}
else if (typeof opts == 'string') {
opts = { startRule: opts }
}
return parser.parse(input, opts)
} | [
"function",
"parse",
"(",
"input",
",",
"opts",
")",
"{",
"// Wrap parser.parse to allow specifying the start rule",
"// as a shorthand option",
"if",
"(",
"!",
"opts",
")",
"{",
"opts",
"=",
"{",
"}",
"}",
"else",
"if",
"(",
"typeof",
"opts",
"==",
"'string'",
... | This isn't called directly, but stringified into the resulting source | [
"This",
"isn",
"t",
"called",
"directly",
"but",
"stringified",
"into",
"the",
"resulting",
"source"
] | f5f65af37f42b120912bbad608e9da1cd909c27c | https://github.com/grncdr/js-shell-parse/blob/f5f65af37f42b120912bbad608e9da1cd909c27c/build.js#L58-L68 | train |
easylogic/codemirror-colorpicker | addon/codemirror-colorpicker.js | partial | function partial(area) {
var allFilter = null;
for (var _len2 = arguments.length, filters = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
filters[_key2 - 1] = arguments[_key2];
}
if (filters.length == 1 && typeof filters[0] === 'string') {
allFilter = filter$1(... | javascript | function partial(area) {
var allFilter = null;
for (var _len2 = arguments.length, filters = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
filters[_key2 - 1] = arguments[_key2];
}
if (filters.length == 1 && typeof filters[0] === 'string') {
allFilter = filter$1(... | [
"function",
"partial",
"(",
"area",
")",
"{",
"var",
"allFilter",
"=",
"null",
";",
"for",
"(",
"var",
"_len2",
"=",
"arguments",
".",
"length",
",",
"filters",
"=",
"Array",
"(",
"_len2",
">",
"1",
"?",
"_len2",
"-",
"1",
":",
"0",
")",
",",
"_k... | apply filter into special area
F.partial({x,y,width,height}, filter, filter, filter )
F.partial({x,y,width,height}, 'filter' )
@param {{x, y, width, height}} area
@param {*} filters | [
"apply",
"filter",
"into",
"special",
"area"
] | 5dc686d8394b89fefb1ff1ac968521575f41d1cd | https://github.com/easylogic/codemirror-colorpicker/blob/5dc686d8394b89fefb1ff1ac968521575f41d1cd/addon/codemirror-colorpicker.js#L4028-L4048 | train |
darach/eep-js | samples/custom.js | function(regex) {
var self = this; var re = new RegExp(regex);
var keys = {};
self.init = function() { keys = {}; };
self.accumulate = function(line) {
var m = re.exec(line);
if (m == null) return;
var k = m[1]; // use 1st group as key
var v = keys[k];
if (v) keys[k] = v+1; else keys[k] = 1;... | javascript | function(regex) {
var self = this; var re = new RegExp(regex);
var keys = {};
self.init = function() { keys = {}; };
self.accumulate = function(line) {
var m = re.exec(line);
if (m == null) return;
var k = m[1]; // use 1st group as key
var v = keys[k];
if (v) keys[k] = v+1; else keys[k] = 1;... | [
"function",
"(",
"regex",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"re",
"=",
"new",
"RegExp",
"(",
"regex",
")",
";",
"var",
"keys",
"=",
"{",
"}",
";",
"self",
".",
"init",
"=",
"function",
"(",
")",
"{",
"keys",
"=",
"{",
"}",
";"... | Widefinder aggregate function | [
"Widefinder",
"aggregate",
"function"
] | 1f5e1574c0dacfc73ca5de00daf4835f8d9d8dc6 | https://github.com/darach/eep-js/blob/1f5e1574c0dacfc73ca5de00daf4835f8d9d8dc6/samples/custom.js#L9-L31 | train | |
darach/eep-js | lib/eep.aggregate_function.js | AggregateFunction | function AggregateFunction() {
var self = this;
// function type can be one of
// - simple (default)
// - ordered - will require window to store elements in arrival and sorted order
//
self.type = "simple";
// invoked when a window opens - should 'reset' or 'zero' a windows internal state
self.init = fu... | javascript | function AggregateFunction() {
var self = this;
// function type can be one of
// - simple (default)
// - ordered - will require window to store elements in arrival and sorted order
//
self.type = "simple";
// invoked when a window opens - should 'reset' or 'zero' a windows internal state
self.init = fu... | [
"function",
"AggregateFunction",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// function type can be one of",
"// - simple (default)",
"// - ordered - will require window to store elements in arrival and sorted order",
"//",
"self",
".",
"type",
"=",
"\"simple\"",
";",
"... | Constraints computations on event streams to a simple functional contract | [
"Constraints",
"computations",
"on",
"event",
"streams",
"to",
"a",
"simple",
"functional",
"contract"
] | 1f5e1574c0dacfc73ca5de00daf4835f8d9d8dc6 | https://github.com/darach/eep-js/blob/1f5e1574c0dacfc73ca5de00daf4835f8d9d8dc6/lib/eep.aggregate_function.js#L25-L42 | train |
darach/eep-js | lib/eep.fn.stats.js | CountFunction | function CountFunction(win) {
var self = this, n;
self.name = "count";
self.type = "simple";
self.init = function() { n = 0; };
self.accumulate = function(ignored) { n += 1; };
self.compensate = function(ignored) { n -= 1; };
self.emit = function() { return n; };
self.make = function(win) { return new ... | javascript | function CountFunction(win) {
var self = this, n;
self.name = "count";
self.type = "simple";
self.init = function() { n = 0; };
self.accumulate = function(ignored) { n += 1; };
self.compensate = function(ignored) { n -= 1; };
self.emit = function() { return n; };
self.make = function(win) { return new ... | [
"function",
"CountFunction",
"(",
"win",
")",
"{",
"var",
"self",
"=",
"this",
",",
"n",
";",
"self",
".",
"name",
"=",
"\"count\"",
";",
"self",
".",
"type",
"=",
"\"simple\"",
";",
"self",
".",
"init",
"=",
"function",
"(",
")",
"{",
"n",
"=",
... | Count all the things | [
"Count",
"all",
"the",
"things"
] | 1f5e1574c0dacfc73ca5de00daf4835f8d9d8dc6 | https://github.com/darach/eep-js/blob/1f5e1574c0dacfc73ca5de00daf4835f8d9d8dc6/lib/eep.fn.stats.js#L26-L35 | train |
darach/eep-js | lib/eep.fn.stats.js | SumFunction | function SumFunction(win) {
var self = this, s;
self.name = "sum";
self.type = "simple";
self.init = function() { s = 0; };
self.accumulate = function(v) { s += v; };
self.compensate = function(v) { s -= v; };
self.emit = function() { return s; };
self.make = function(win) { return new SumFunction(win)... | javascript | function SumFunction(win) {
var self = this, s;
self.name = "sum";
self.type = "simple";
self.init = function() { s = 0; };
self.accumulate = function(v) { s += v; };
self.compensate = function(v) { s -= v; };
self.emit = function() { return s; };
self.make = function(win) { return new SumFunction(win)... | [
"function",
"SumFunction",
"(",
"win",
")",
"{",
"var",
"self",
"=",
"this",
",",
"s",
";",
"self",
".",
"name",
"=",
"\"sum\"",
";",
"self",
".",
"type",
"=",
"\"simple\"",
";",
"self",
".",
"init",
"=",
"function",
"(",
")",
"{",
"s",
"=",
"0",... | Sum all the things | [
"Sum",
"all",
"the",
"things"
] | 1f5e1574c0dacfc73ca5de00daf4835f8d9d8dc6 | https://github.com/darach/eep-js/blob/1f5e1574c0dacfc73ca5de00daf4835f8d9d8dc6/lib/eep.fn.stats.js#L39-L48 | train |
darach/eep-js | lib/eep.fn.stats.js | MinFunction | function MinFunction(win) {
var self = this, r;
self.win = win;
self.name = "min";
self.type = "ordered_reverse";
self.init = function() { r = null; };
self.accumulate = function(v) { if (v == null) { return; } if (r == null) { r = v; return; } r = (v < r) ? v : r; };
self.compensate = function(v) { r = ... | javascript | function MinFunction(win) {
var self = this, r;
self.win = win;
self.name = "min";
self.type = "ordered_reverse";
self.init = function() { r = null; };
self.accumulate = function(v) { if (v == null) { return; } if (r == null) { r = v; return; } r = (v < r) ? v : r; };
self.compensate = function(v) { r = ... | [
"function",
"MinFunction",
"(",
"win",
")",
"{",
"var",
"self",
"=",
"this",
",",
"r",
";",
"self",
".",
"win",
"=",
"win",
";",
"self",
".",
"name",
"=",
"\"min\"",
";",
"self",
".",
"type",
"=",
"\"ordered_reverse\"",
";",
"self",
".",
"init",
"=... | Get the smallest of all the things | [
"Get",
"the",
"smallest",
"of",
"all",
"the",
"things"
] | 1f5e1574c0dacfc73ca5de00daf4835f8d9d8dc6 | https://github.com/darach/eep-js/blob/1f5e1574c0dacfc73ca5de00daf4835f8d9d8dc6/lib/eep.fn.stats.js#L52-L62 | train |
darach/eep-js | lib/eep.fn.stats.js | MaxFunction | function MaxFunction(win) {
var self = this, r;
self.win = win;
self.name = "max";
self.type = "ordered_reverse";
self.init = function() { r = null; };
self.accumulate = function(v) { if (v == null) { return; } if (r == null) { r = v; return; } r = (v > r) ? v : r; };
self.compensate = function(v) { r = ... | javascript | function MaxFunction(win) {
var self = this, r;
self.win = win;
self.name = "max";
self.type = "ordered_reverse";
self.init = function() { r = null; };
self.accumulate = function(v) { if (v == null) { return; } if (r == null) { r = v; return; } r = (v > r) ? v : r; };
self.compensate = function(v) { r = ... | [
"function",
"MaxFunction",
"(",
"win",
")",
"{",
"var",
"self",
"=",
"this",
",",
"r",
";",
"self",
".",
"win",
"=",
"win",
";",
"self",
".",
"name",
"=",
"\"max\"",
";",
"self",
".",
"type",
"=",
"\"ordered_reverse\"",
";",
"self",
".",
"init",
"=... | Get the biggest of all the things | [
"Get",
"the",
"biggest",
"of",
"all",
"the",
"things"
] | 1f5e1574c0dacfc73ca5de00daf4835f8d9d8dc6 | https://github.com/darach/eep-js/blob/1f5e1574c0dacfc73ca5de00daf4835f8d9d8dc6/lib/eep.fn.stats.js#L66-L76 | train |
darach/eep-js | lib/eep.fn.stats.js | VarianceFunction | function VarianceFunction(win) {
var self = this, m, m2, d, n;
self.name = "vars";
self.type = "simple";
self.init = function() { m = 0; m2 = 0; d = 0; n = 0; };
self.accumulate = function(v) { n+=1; d = v - m; m = d/n + m; m2 = m2 + d*(v - m); };
self.compensate = function(v) { n-=1; d = m - v; m = m + d/n... | javascript | function VarianceFunction(win) {
var self = this, m, m2, d, n;
self.name = "vars";
self.type = "simple";
self.init = function() { m = 0; m2 = 0; d = 0; n = 0; };
self.accumulate = function(v) { n+=1; d = v - m; m = d/n + m; m2 = m2 + d*(v - m); };
self.compensate = function(v) { n-=1; d = m - v; m = m + d/n... | [
"function",
"VarianceFunction",
"(",
"win",
")",
"{",
"var",
"self",
"=",
"this",
",",
"m",
",",
"m2",
",",
"d",
",",
"n",
";",
"self",
".",
"name",
"=",
"\"vars\"",
";",
"self",
".",
"type",
"=",
"\"simple\"",
";",
"self",
".",
"init",
"=",
"fun... | Get the sample variance of all the things | [
"Get",
"the",
"sample",
"variance",
"of",
"all",
"the",
"things"
] | 1f5e1574c0dacfc73ca5de00daf4835f8d9d8dc6 | https://github.com/darach/eep-js/blob/1f5e1574c0dacfc73ca5de00daf4835f8d9d8dc6/lib/eep.fn.stats.js#L93-L102 | train |
darach/eep-js | lib/eep.fn.stats.js | StdevFunction | function StdevFunction(win) {
var self = this, m, m2, d, n;
self.name = "stdevs";
self.type = "simple";
self.init = function() { m = 0, m2 = 0, d = 0, n = 0; };
self.accumulate = function(v) {
n+=1;
d = v - m;
m = m + d/n;
m2 = m2 + d*(v-m);
};
self.compensate = function(v) {
n-=1;
... | javascript | function StdevFunction(win) {
var self = this, m, m2, d, n;
self.name = "stdevs";
self.type = "simple";
self.init = function() { m = 0, m2 = 0, d = 0, n = 0; };
self.accumulate = function(v) {
n+=1;
d = v - m;
m = m + d/n;
m2 = m2 + d*(v-m);
};
self.compensate = function(v) {
n-=1;
... | [
"function",
"StdevFunction",
"(",
"win",
")",
"{",
"var",
"self",
"=",
"this",
",",
"m",
",",
"m2",
",",
"d",
",",
"n",
";",
"self",
".",
"name",
"=",
"\"stdevs\"",
";",
"self",
".",
"type",
"=",
"\"simple\"",
";",
"self",
".",
"init",
"=",
"func... | Get the standard deviation of all the things | [
"Get",
"the",
"standard",
"deviation",
"of",
"all",
"the",
"things"
] | 1f5e1574c0dacfc73ca5de00daf4835f8d9d8dc6 | https://github.com/darach/eep-js/blob/1f5e1574c0dacfc73ca5de00daf4835f8d9d8dc6/lib/eep.fn.stats.js#L106-L125 | train |
darach/eep-js | lib/eep.clock_counting.js | CountingClock | function CountingClock() {
var self = this, at, mark = null;
self.at = function() {
return at;
};
self.init = function() {
at = mark = 0;
return at;
};
self.inc = function() {
at += 1;
};
self.tick = function() {
if (mark === null) {
mark = at + 1;
}
return ((at - ... | javascript | function CountingClock() {
var self = this, at, mark = null;
self.at = function() {
return at;
};
self.init = function() {
at = mark = 0;
return at;
};
self.inc = function() {
at += 1;
};
self.tick = function() {
if (mark === null) {
mark = at + 1;
}
return ((at - ... | [
"function",
"CountingClock",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"at",
",",
"mark",
"=",
"null",
";",
"self",
".",
"at",
"=",
"function",
"(",
")",
"{",
"return",
"at",
";",
"}",
";",
"self",
".",
"init",
"=",
"function",
"(",
")",
... | Simple monotonic clock. Ticks and tocks like the count on Sesame St. Mwa ha ha. Monotonic, basically. | [
"Simple",
"monotonic",
"clock",
".",
"Ticks",
"and",
"tocks",
"like",
"the",
"count",
"on",
"Sesame",
"St",
".",
"Mwa",
"ha",
"ha",
".",
"Monotonic",
"basically",
"."
] | 1f5e1574c0dacfc73ca5de00daf4835f8d9d8dc6 | https://github.com/darach/eep-js/blob/1f5e1574c0dacfc73ca5de00daf4835f8d9d8dc6/lib/eep.clock_counting.js#L26-L58 | train |
nymag/nymag-fs | index.js | getFolders | function getFolders(dir) {
try {
return fs.readdirSync(dir)
.filter(function (file) {
return exports.isDirectory(path.join(dir, file));
});
} catch (ex) {
return [];
}
} | javascript | function getFolders(dir) {
try {
return fs.readdirSync(dir)
.filter(function (file) {
return exports.isDirectory(path.join(dir, file));
});
} catch (ex) {
return [];
}
} | [
"function",
"getFolders",
"(",
"dir",
")",
"{",
"try",
"{",
"return",
"fs",
".",
"readdirSync",
"(",
"dir",
")",
".",
"filter",
"(",
"function",
"(",
"file",
")",
"{",
"return",
"exports",
".",
"isDirectory",
"(",
"path",
".",
"join",
"(",
"dir",
","... | Get folder names.
Should only occur once per directory.
@param {string} dir enclosing folder
@return {[]} array of folder names | [
"Get",
"folder",
"names",
"."
] | 94dcd3be2c0593b676131a9760c2318c75255a71 | https://github.com/nymag/nymag-fs/blob/94dcd3be2c0593b676131a9760c2318c75255a71/index.js#L80-L89 | train |
nymag/nymag-fs | index.js | tryRequire | function tryRequire(filePath) {
let resolvedPath = req.resolve(filePath);
if (resolvedPath) {
return req(resolvedPath);
}
return undefined;
} | javascript | function tryRequire(filePath) {
let resolvedPath = req.resolve(filePath);
if (resolvedPath) {
return req(resolvedPath);
}
return undefined;
} | [
"function",
"tryRequire",
"(",
"filePath",
")",
"{",
"let",
"resolvedPath",
"=",
"req",
".",
"resolve",
"(",
"filePath",
")",
";",
"if",
"(",
"resolvedPath",
")",
"{",
"return",
"req",
"(",
"resolvedPath",
")",
";",
"}",
"return",
"undefined",
";",
"}"
] | Try to require a module, do not fail if module is missing
@param {string} filePath
@returns {module}
@throw if fails for reason other than missing module | [
"Try",
"to",
"require",
"a",
"module",
"do",
"not",
"fail",
"if",
"module",
"is",
"missing"
] | 94dcd3be2c0593b676131a9760c2318c75255a71 | https://github.com/nymag/nymag-fs/blob/94dcd3be2c0593b676131a9760c2318c75255a71/index.js#L97-L105 | train |
nymag/nymag-fs | index.js | tryRequireEach | function tryRequireEach(paths) {
let result;
while (!result && paths.length) {
result = tryRequire(paths.shift());
}
return result;
} | javascript | function tryRequireEach(paths) {
let result;
while (!result && paths.length) {
result = tryRequire(paths.shift());
}
return result;
} | [
"function",
"tryRequireEach",
"(",
"paths",
")",
"{",
"let",
"result",
";",
"while",
"(",
"!",
"result",
"&&",
"paths",
".",
"length",
")",
"{",
"result",
"=",
"tryRequire",
"(",
"paths",
".",
"shift",
"(",
")",
")",
";",
"}",
"return",
"result",
";"... | Try to get a module, or return false.
@param {[string]} paths Possible paths to find their module.
@returns {object|false} | [
"Try",
"to",
"get",
"a",
"module",
"or",
"return",
"false",
"."
] | 94dcd3be2c0593b676131a9760c2318c75255a71 | https://github.com/nymag/nymag-fs/blob/94dcd3be2c0593b676131a9760c2318c75255a71/index.js#L113-L121 | train |
nymag/nymag-fs | control.js | memoize | function memoize(fn) {
const dataProp = '__data__.string.__data__',
memFn = _.memoize.apply(_, _.slice(arguments)),
report = _.throttle(reportMemoryLeak, minute),
controlFn = function () {
const result = memFn.apply(null, _.slice(arguments));
if (_.size(_.get(memFn, `cache.${dataProp}`)) >= m... | javascript | function memoize(fn) {
const dataProp = '__data__.string.__data__',
memFn = _.memoize.apply(_, _.slice(arguments)),
report = _.throttle(reportMemoryLeak, minute),
controlFn = function () {
const result = memFn.apply(null, _.slice(arguments));
if (_.size(_.get(memFn, `cache.${dataProp}`)) >= m... | [
"function",
"memoize",
"(",
"fn",
")",
"{",
"const",
"dataProp",
"=",
"'__data__.string.__data__'",
",",
"memFn",
"=",
"_",
".",
"memoize",
".",
"apply",
"(",
"_",
",",
"_",
".",
"slice",
"(",
"arguments",
")",
")",
",",
"report",
"=",
"_",
".",
"thr... | Memoize, but warn if the target is not suitable for memoization
@param {function} fn
@returns {function} | [
"Memoize",
"but",
"warn",
"if",
"the",
"target",
"is",
"not",
"suitable",
"for",
"memoization"
] | 94dcd3be2c0593b676131a9760c2318c75255a71 | https://github.com/nymag/nymag-fs/blob/94dcd3be2c0593b676131a9760c2318c75255a71/control.js#L42-L62 | train |
IonicaBizau/iterate-object | lib/index.js | iterateObject | function iterateObject(obj, fn) {
var i = 0
, keys = []
;
if (Array.isArray(obj)) {
for (; i < obj.length; ++i) {
if (fn(obj[i], i, obj) === false) {
break;
}
}
} else if (typeof obj === "object" && obj !== null) {
keys = Object.ke... | javascript | function iterateObject(obj, fn) {
var i = 0
, keys = []
;
if (Array.isArray(obj)) {
for (; i < obj.length; ++i) {
if (fn(obj[i], i, obj) === false) {
break;
}
}
} else if (typeof obj === "object" && obj !== null) {
keys = Object.ke... | [
"function",
"iterateObject",
"(",
"obj",
",",
"fn",
")",
"{",
"var",
"i",
"=",
"0",
",",
"keys",
"=",
"[",
"]",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",
"obj",
")",
")",
"{",
"for",
"(",
";",
"i",
"<",
"obj",
".",
"length",
";",
"++",
... | iterateObject
Iterates an object. Note the object field order may differ.
@name iterateObject
@function
@param {Object} obj The input object.
@param {Function} fn A function that will be called with the current value, field name and provided object.
@return {Function} The `iterateObject` function. | [
"iterateObject",
"Iterates",
"an",
"object",
".",
"Note",
"the",
"object",
"field",
"order",
"may",
"differ",
"."
] | 8c96db262c95c62524cc4c5ab7374439a5ff8971 | https://github.com/IonicaBizau/iterate-object/blob/8c96db262c95c62524cc4c5ab7374439a5ff8971/lib/index.js#L11-L30 | train |
gbv/jskos-tools | lib/tools.js | compareMappingsDeep | function compareMappingsDeep(mapping1, mapping2) {
return _.isEqualWith(mapping1, mapping2, (object1, object2, prop) => {
let mapping1 = { [prop]: object1 }
let mapping2 = { [prop]: object2 }
if (prop == "from" || prop == "to") {
if (!_.isEqual(Object.getOwnPropertyNames(_.get(object1, prop, {})), O... | javascript | function compareMappingsDeep(mapping1, mapping2) {
return _.isEqualWith(mapping1, mapping2, (object1, object2, prop) => {
let mapping1 = { [prop]: object1 }
let mapping2 = { [prop]: object2 }
if (prop == "from" || prop == "to") {
if (!_.isEqual(Object.getOwnPropertyNames(_.get(object1, prop, {})), O... | [
"function",
"compareMappingsDeep",
"(",
"mapping1",
",",
"mapping2",
")",
"{",
"return",
"_",
".",
"isEqualWith",
"(",
"mapping1",
",",
"mapping2",
",",
"(",
"object1",
",",
"object2",
",",
"prop",
")",
"=>",
"{",
"let",
"mapping1",
"=",
"{",
"[",
"prop"... | Compare two mappings based on their properties. Concept sets and schemes are compared by URI.
@memberof module:jskos-tools | [
"Compare",
"two",
"mappings",
"based",
"on",
"their",
"properties",
".",
"Concept",
"sets",
"and",
"schemes",
"are",
"compared",
"by",
"URI",
"."
] | da8672203362ea874f4ab9cdd34b990369987075 | https://github.com/gbv/jskos-tools/blob/da8672203362ea874f4ab9cdd34b990369987075/lib/tools.js#L419-L440 | train |
bem-contrib/md-to-bemjson | packages/mdast-util-to-bemjson/lib/index.js | toBemjson | function toBemjson(tree, options) {
const transform = transformFactory(tree, options);
return traverse(transform, tree);
} | javascript | function toBemjson(tree, options) {
const transform = transformFactory(tree, options);
return traverse(transform, tree);
} | [
"function",
"toBemjson",
"(",
"tree",
",",
"options",
")",
"{",
"const",
"transform",
"=",
"transformFactory",
"(",
"tree",
",",
"options",
")",
";",
"return",
"traverse",
"(",
"transform",
",",
"tree",
")",
";",
"}"
] | Augments bemNode with custom logic
@callback BjsonConverter~augmentCallback
@param {Object} bemNode - representation of bem entity
@returns {Object} - must return bemNode
Transform `tree`, which is an MDAST node, to a Bemjson node.
@param {Node} tree - MDAST tree
@param {Object} options - transform options
@return ... | [
"Augments",
"bemNode",
"with",
"custom",
"logic"
] | 047ab80c681073c7c92aecee754bcf46956507a9 | https://github.com/bem-contrib/md-to-bemjson/blob/047ab80c681073c7c92aecee754bcf46956507a9/packages/mdast-util-to-bemjson/lib/index.js#L21-L25 | train |
rangle/koast | lib/authentication/oauth.js | makeLoginHandler | function makeLoginHandler(provider, providerAccounts) {
return function (accessToken, refreshToken, profile, done) {
log.debug('Authentiated for ' + provider);
log.debug(profile);
profile.provider = provider;
profile.idWithProvider = profile.id;
exports.getUserFromProfile(providerAccounts, profil... | javascript | function makeLoginHandler(provider, providerAccounts) {
return function (accessToken, refreshToken, profile, done) {
log.debug('Authentiated for ' + provider);
log.debug(profile);
profile.provider = provider;
profile.idWithProvider = profile.id;
exports.getUserFromProfile(providerAccounts, profil... | [
"function",
"makeLoginHandler",
"(",
"provider",
",",
"providerAccounts",
")",
"{",
"return",
"function",
"(",
"accessToken",
",",
"refreshToken",
",",
"profile",
",",
"done",
")",
"{",
"log",
".",
"debug",
"(",
"'Authentiated for '",
"+",
"provider",
")",
";"... | Makes a handler to be called after the user was authenticated with an OAuth provider. | [
"Makes",
"a",
"handler",
"to",
"be",
"called",
"after",
"the",
"user",
"was",
"authenticated",
"with",
"an",
"OAuth",
"provider",
"."
] | 446dfaba7f80c03ae17d86b34dfafd6328be1ba6 | https://github.com/rangle/koast/blob/446dfaba7f80c03ae17d86b34dfafd6328be1ba6/lib/authentication/oauth.js#L73-L117 | train |
rangle/koast | lib/authentication/oauth.js | redirectToNext | function redirectToNext(req, res) {
var redirectTo = req.session.next || '';
req.session.next = null; // Null it so that we do not use it again.
res.redirect(redirectTo);
} | javascript | function redirectToNext(req, res) {
var redirectTo = req.session.next || '';
req.session.next = null; // Null it so that we do not use it again.
res.redirect(redirectTo);
} | [
"function",
"redirectToNext",
"(",
"req",
",",
"res",
")",
"{",
"var",
"redirectTo",
"=",
"req",
".",
"session",
".",
"next",
"||",
"''",
";",
"req",
".",
"session",
".",
"next",
"=",
"null",
";",
"// Null it so that we do not use it again.",
"res",
".",
"... | Redirects the user to the new url. | [
"Redirects",
"the",
"user",
"to",
"the",
"new",
"url",
"."
] | 446dfaba7f80c03ae17d86b34dfafd6328be1ba6 | https://github.com/rangle/koast/blob/446dfaba7f80c03ae17d86b34dfafd6328be1ba6/lib/authentication/oauth.js#L120-L124 | train |
rangle/koast | lib/authentication/oauth.js | setupStrategies | function setupStrategies(auth) {
var result = {};
if (auth.maintenance === 'token') {
result = {
facebook: require('passport-facebook').Strategy,
twitter: require('passport-twitter').Strategy
};
} else {
result = {
google: require('passport-google-oauth').OAuth2Str... | javascript | function setupStrategies(auth) {
var result = {};
if (auth.maintenance === 'token') {
result = {
facebook: require('passport-facebook').Strategy,
twitter: require('passport-twitter').Strategy
};
} else {
result = {
google: require('passport-google-oauth').OAuth2Str... | [
"function",
"setupStrategies",
"(",
"auth",
")",
"{",
"var",
"result",
"=",
"{",
"}",
";",
"if",
"(",
"auth",
".",
"maintenance",
"===",
"'token'",
")",
"{",
"result",
"=",
"{",
"facebook",
":",
"require",
"(",
"'passport-facebook'",
")",
".",
"Strategy"... | setup strategies that we can use google OAuth2Strategy requires session, which we do not setup if using token | [
"setup",
"strategies",
"that",
"we",
"can",
"use",
"google",
"OAuth2Strategy",
"requires",
"session",
"which",
"we",
"do",
"not",
"setup",
"if",
"using",
"token"
] | 446dfaba7f80c03ae17d86b34dfafd6328be1ba6 | https://github.com/rangle/koast/blob/446dfaba7f80c03ae17d86b34dfafd6328be1ba6/lib/authentication/oauth.js#L238-L254 | train |
RavelLaw/e3 | addon/utils/shadow/line-interpolation/monotone.js | d3_svg_lineHermite | function d3_svg_lineHermite(points, tangents) {
if (tangents.length < 1 || (points.length !== tangents.length && points.length !== tangents.length + 2)) {
return points;
}
var quad = points.length !== tangents.length,
commands = [],
p0 = points[0],
p = points[1],
t0 = tangents[0],
... | javascript | function d3_svg_lineHermite(points, tangents) {
if (tangents.length < 1 || (points.length !== tangents.length && points.length !== tangents.length + 2)) {
return points;
}
var quad = points.length !== tangents.length,
commands = [],
p0 = points[0],
p = points[1],
t0 = tangents[0],
... | [
"function",
"d3_svg_lineHermite",
"(",
"points",
",",
"tangents",
")",
"{",
"if",
"(",
"tangents",
".",
"length",
"<",
"1",
"||",
"(",
"points",
".",
"length",
"!==",
"tangents",
".",
"length",
"&&",
"points",
".",
"length",
"!==",
"tangents",
".",
"leng... | Hermite spline construction; generates "C" commands. | [
"Hermite",
"spline",
"construction",
";",
"generates",
"C",
"commands",
"."
] | 7149b2a9ebddd5c512132a41f7ae7c3a2235ac0d | https://github.com/RavelLaw/e3/blob/7149b2a9ebddd5c512132a41f7ae7c3a2235ac0d/addon/utils/shadow/line-interpolation/monotone.js#L79-L144 | train |
Incroud/cassanova | lib/model.js | Model | function Model(name, table) {
this.model = this;
if(!name || typeof name !== "string"){
throw new Error("Attempting to instantiate a model without a valid name. Create models using the Cassanova.model API.");
}
if(!table){
throw new Error("Attempting to instantiate a model, " + name + ... | javascript | function Model(name, table) {
this.model = this;
if(!name || typeof name !== "string"){
throw new Error("Attempting to instantiate a model without a valid name. Create models using the Cassanova.model API.");
}
if(!table){
throw new Error("Attempting to instantiate a model, " + name + ... | [
"function",
"Model",
"(",
"name",
",",
"table",
")",
"{",
"this",
".",
"model",
"=",
"this",
";",
"if",
"(",
"!",
"name",
"||",
"typeof",
"name",
"!==",
"\"string\"",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Attempting to instantiate a model without a vali... | Cassanova.Model
@param {String} name The name of the model. Used to creation and retrieve.
@param {Table} table The table associated with the model. | [
"Cassanova",
".",
"Model"
] | 49c5ce2e1bc6b19d25e8223e88df45c113c36b68 | https://github.com/Incroud/cassanova/blob/49c5ce2e1bc6b19d25e8223e88df45c113c36b68/lib/model.js#L9-L22 | train |
hoodiehq/pouchdb-hoodie-sync | lib/off.js | off | function off (state, eventName, handler) {
if (arguments.length === 2) {
state.emitter.removeAllListeners(eventName)
} else {
state.emitter.removeListener(eventName, handler)
}
return state.api
} | javascript | function off (state, eventName, handler) {
if (arguments.length === 2) {
state.emitter.removeAllListeners(eventName)
} else {
state.emitter.removeListener(eventName, handler)
}
return state.api
} | [
"function",
"off",
"(",
"state",
",",
"eventName",
",",
"handler",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"===",
"2",
")",
"{",
"state",
".",
"emitter",
".",
"removeAllListeners",
"(",
"eventName",
")",
"}",
"else",
"{",
"state",
".",
"emitte... | unbinds event from handler
@param {String} eventName push, pull, connect, disconnect
@param {Function} handler function unbound from event
@return {Promise} | [
"unbinds",
"event",
"from",
"handler"
] | c489baf813020c7f0cbd111224432cb6718c90de | https://github.com/hoodiehq/pouchdb-hoodie-sync/blob/c489baf813020c7f0cbd111224432cb6718c90de/lib/off.js#L10-L18 | train |
bem-contrib/md-to-bemjson | packages/md-to-bemjson/lib/augment.js | augmentFactory | function augmentFactory(options) {
/**
* Apply custom augmentation
*
* @param {Object} bemNode - representation of bem entity
* @returns {Object} bemNode
*/
function augment(bemNode) {
if (bemNode.block === 'md-root') {
bemNode.isRoot = true;
}
if (... | javascript | function augmentFactory(options) {
/**
* Apply custom augmentation
*
* @param {Object} bemNode - representation of bem entity
* @returns {Object} bemNode
*/
function augment(bemNode) {
if (bemNode.block === 'md-root') {
bemNode.isRoot = true;
}
if (... | [
"function",
"augmentFactory",
"(",
"options",
")",
"{",
"/**\n * Apply custom augmentation\n *\n * @param {Object} bemNode - representation of bem entity\n * @returns {Object} bemNode\n */",
"function",
"augment",
"(",
"bemNode",
")",
"{",
"if",
"(",
"bemNode",
".... | create augment function with options
@param {MDConverter~AugmentOptions} options - augmentation options
@returns {Function} | [
"create",
"augment",
"function",
"with",
"options"
] | 047ab80c681073c7c92aecee754bcf46956507a9 | https://github.com/bem-contrib/md-to-bemjson/blob/047ab80c681073c7c92aecee754bcf46956507a9/packages/md-to-bemjson/lib/augment.js#L13-L48 | train |
bem-contrib/md-to-bemjson | packages/md-to-bemjson/lib/augment.js | augmentScope | function augmentScope(bemNode, scope) {
assert(typeof scope === 'string', 'options.scope must be string');
if (bemNode.isRoot) {
bemNode.block = scope;
} else {
bemNode.elem = bemNode.block;
bemNode.elemMods = bemNode.mods;
delete bemNode.block;
delete bemNode.mods... | javascript | function augmentScope(bemNode, scope) {
assert(typeof scope === 'string', 'options.scope must be string');
if (bemNode.isRoot) {
bemNode.block = scope;
} else {
bemNode.elem = bemNode.block;
bemNode.elemMods = bemNode.mods;
delete bemNode.block;
delete bemNode.mods... | [
"function",
"augmentScope",
"(",
"bemNode",
",",
"scope",
")",
"{",
"assert",
"(",
"typeof",
"scope",
"===",
"'string'",
",",
"'options.scope must be string'",
")",
";",
"if",
"(",
"bemNode",
".",
"isRoot",
")",
"{",
"bemNode",
".",
"block",
"=",
"scope",
... | Replace root with scope and blocks with elems.
@param {Object} bemNode - representation of bem entity
@param {string} scope - new root block name
@returns {Object} bemNode | [
"Replace",
"root",
"with",
"scope",
"and",
"blocks",
"with",
"elems",
"."
] | 047ab80c681073c7c92aecee754bcf46956507a9 | https://github.com/bem-contrib/md-to-bemjson/blob/047ab80c681073c7c92aecee754bcf46956507a9/packages/md-to-bemjson/lib/augment.js#L80-L95 | train |
bem-contrib/md-to-bemjson | packages/md-to-bemjson/lib/augment.js | augmentMap | function augmentMap(bemNode, map) {
const name = bemNode.block;
if (map[name]) {
assert(typeof map[name] === 'string', `options.map: new name of ${name} must be string`);
bemNode.block = map[name];
}
return bemNode;
} | javascript | function augmentMap(bemNode, map) {
const name = bemNode.block;
if (map[name]) {
assert(typeof map[name] === 'string', `options.map: new name of ${name} must be string`);
bemNode.block = map[name];
}
return bemNode;
} | [
"function",
"augmentMap",
"(",
"bemNode",
",",
"map",
")",
"{",
"const",
"name",
"=",
"bemNode",
".",
"block",
";",
"if",
"(",
"map",
"[",
"name",
"]",
")",
"{",
"assert",
"(",
"typeof",
"map",
"[",
"name",
"]",
"===",
"'string'",
",",
"`",
"${",
... | Replace block names with new one
@param {Object} bemNode - representation of bem entity
@param {Object} map - key:blockName, value:newBlockName
@returns {Object} bemNode | [
"Replace",
"block",
"names",
"with",
"new",
"one"
] | 047ab80c681073c7c92aecee754bcf46956507a9 | https://github.com/bem-contrib/md-to-bemjson/blob/047ab80c681073c7c92aecee754bcf46956507a9/packages/md-to-bemjson/lib/augment.js#L104-L113 | train |
tamaina/mfmf | dist/script/prelude/array.js | intersperse | function intersperse(sep, xs) {
return concat(xs.map(x => [sep, x])).slice(1);
} | javascript | function intersperse(sep, xs) {
return concat(xs.map(x => [sep, x])).slice(1);
} | [
"function",
"intersperse",
"(",
"sep",
",",
"xs",
")",
"{",
"return",
"concat",
"(",
"xs",
".",
"map",
"(",
"x",
"=>",
"[",
"sep",
",",
"x",
"]",
")",
")",
".",
"slice",
"(",
"1",
")",
";",
"}"
] | Intersperse the element between the elements of the array
@param sep The element to be interspersed | [
"Intersperse",
"the",
"element",
"between",
"the",
"elements",
"of",
"the",
"array"
] | 31208f7265a37438ee0e7527969db91ded001f7c | https://github.com/tamaina/mfmf/blob/31208f7265a37438ee0e7527969db91ded001f7c/dist/script/prelude/array.js#L28-L30 | train |
tamaina/mfmf | dist/script/prelude/array.js | groupBy | function groupBy(f, xs) {
const groups = [];
for (const x of xs) {
if (groups.length !== 0 && f(groups[groups.length - 1][0], x)) {
groups[groups.length - 1].push(x);
}
else {
groups.push([x]);
}
}
return groups;
} | javascript | function groupBy(f, xs) {
const groups = [];
for (const x of xs) {
if (groups.length !== 0 && f(groups[groups.length - 1][0], x)) {
groups[groups.length - 1].push(x);
}
else {
groups.push([x]);
}
}
return groups;
} | [
"function",
"groupBy",
"(",
"f",
",",
"xs",
")",
"{",
"const",
"groups",
"=",
"[",
"]",
";",
"for",
"(",
"const",
"x",
"of",
"xs",
")",
"{",
"if",
"(",
"groups",
".",
"length",
"!==",
"0",
"&&",
"f",
"(",
"groups",
"[",
"groups",
".",
"length",... | Splits an array based on the equivalence relation.
The concatenation of the result is equal to the argument. | [
"Splits",
"an",
"array",
"based",
"on",
"the",
"equivalence",
"relation",
".",
"The",
"concatenation",
"of",
"the",
"result",
"is",
"equal",
"to",
"the",
"argument",
"."
] | 31208f7265a37438ee0e7527969db91ded001f7c | https://github.com/tamaina/mfmf/blob/31208f7265a37438ee0e7527969db91ded001f7c/dist/script/prelude/array.js#L66-L77 | train |
tamaina/mfmf | dist/script/prelude/array.js | groupOn | function groupOn(f, xs) {
return groupBy((a, b) => f(a) === f(b), xs);
} | javascript | function groupOn(f, xs) {
return groupBy((a, b) => f(a) === f(b), xs);
} | [
"function",
"groupOn",
"(",
"f",
",",
"xs",
")",
"{",
"return",
"groupBy",
"(",
"(",
"a",
",",
"b",
")",
"=>",
"f",
"(",
"a",
")",
"===",
"f",
"(",
"b",
")",
",",
"xs",
")",
";",
"}"
] | Splits an array based on the equivalence relation induced by the function.
The concatenation of the result is equal to the argument. | [
"Splits",
"an",
"array",
"based",
"on",
"the",
"equivalence",
"relation",
"induced",
"by",
"the",
"function",
".",
"The",
"concatenation",
"of",
"the",
"result",
"is",
"equal",
"to",
"the",
"argument",
"."
] | 31208f7265a37438ee0e7527969db91ded001f7c | https://github.com/tamaina/mfmf/blob/31208f7265a37438ee0e7527969db91ded001f7c/dist/script/prelude/array.js#L83-L85 | train |
tamaina/mfmf | dist/script/prelude/array.js | lessThan | function lessThan(xs, ys) {
for (let i = 0; i < Math.min(xs.length, ys.length); i++) {
if (xs[i] < ys[i])
return true;
if (xs[i] > ys[i])
return false;
}
return xs.length < ys.length;
} | javascript | function lessThan(xs, ys) {
for (let i = 0; i < Math.min(xs.length, ys.length); i++) {
if (xs[i] < ys[i])
return true;
if (xs[i] > ys[i])
return false;
}
return xs.length < ys.length;
} | [
"function",
"lessThan",
"(",
"xs",
",",
"ys",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"Math",
".",
"min",
"(",
"xs",
".",
"length",
",",
"ys",
".",
"length",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"xs",
"[",
"i",
"]"... | Compare two arrays by lexicographical order | [
"Compare",
"two",
"arrays",
"by",
"lexicographical",
"order"
] | 31208f7265a37438ee0e7527969db91ded001f7c | https://github.com/tamaina/mfmf/blob/31208f7265a37438ee0e7527969db91ded001f7c/dist/script/prelude/array.js#L90-L98 | train |
tamaina/mfmf | dist/script/prelude/array.js | takeWhile | function takeWhile(f, xs) {
const ys = [];
for (const x of xs) {
if (f(x)) {
ys.push(x);
}
else {
break;
}
}
return ys;
} | javascript | function takeWhile(f, xs) {
const ys = [];
for (const x of xs) {
if (f(x)) {
ys.push(x);
}
else {
break;
}
}
return ys;
} | [
"function",
"takeWhile",
"(",
"f",
",",
"xs",
")",
"{",
"const",
"ys",
"=",
"[",
"]",
";",
"for",
"(",
"const",
"x",
"of",
"xs",
")",
"{",
"if",
"(",
"f",
"(",
"x",
")",
")",
"{",
"ys",
".",
"push",
"(",
"x",
")",
";",
"}",
"else",
"{",
... | Returns the longest prefix of elements that satisfy the predicate | [
"Returns",
"the",
"longest",
"prefix",
"of",
"elements",
"that",
"satisfy",
"the",
"predicate"
] | 31208f7265a37438ee0e7527969db91ded001f7c | https://github.com/tamaina/mfmf/blob/31208f7265a37438ee0e7527969db91ded001f7c/dist/script/prelude/array.js#L103-L114 | train |
fissionjs/fission | lib/renderables/collectionView.js | function(){
return {
collection: configCollection,
data: config.data,
query: config.query,
offset: config.offset,
limit: config.limit,
where: config.where,
filter: config.filter,
filters: config.filters,
watch: config.watch,
sort: con... | javascript | function(){
return {
collection: configCollection,
data: config.data,
query: config.query,
offset: config.offset,
limit: config.limit,
where: config.where,
filter: config.filter,
filters: config.filters,
watch: config.watch,
sort: con... | [
"function",
"(",
")",
"{",
"return",
"{",
"collection",
":",
"configCollection",
",",
"data",
":",
"config",
".",
"data",
",",
"query",
":",
"config",
".",
"query",
",",
"offset",
":",
"config",
".",
"offset",
",",
"limit",
":",
"config",
".",
"limit",... | most options can be passed via config or props props takes precedence | [
"most",
"options",
"can",
"be",
"passed",
"via",
"config",
"or",
"props",
"props",
"takes",
"precedence"
] | e34eed78ed2386bb7934a69214e13f17fcd311c3 | https://github.com/fissionjs/fission/blob/e34eed78ed2386bb7934a69214e13f17fcd311c3/lib/renderables/collectionView.js#L53-L66 | train | |
fissionjs/fission | lib/renderables/collectionView.js | function(props) {
if (typeof props !== 'object') {
throw new Error('_configureItems called with invalid props');
}
// not initialized yet
if (!this._items) {
return;
}
this._items.configure({
where: bindIfFn(props.where, this),
filter: bindIfFn(props.f... | javascript | function(props) {
if (typeof props !== 'object') {
throw new Error('_configureItems called with invalid props');
}
// not initialized yet
if (!this._items) {
return;
}
this._items.configure({
where: bindIfFn(props.where, this),
filter: bindIfFn(props.f... | [
"function",
"(",
"props",
")",
"{",
"if",
"(",
"typeof",
"props",
"!==",
"'object'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'_configureItems called with invalid props'",
")",
";",
"}",
"// not initialized yet",
"if",
"(",
"!",
"this",
".",
"_items",
")",
"... | internal fn to sync props to shadow collection | [
"internal",
"fn",
"to",
"sync",
"props",
"to",
"shadow",
"collection"
] | e34eed78ed2386bb7934a69214e13f17fcd311c3 | https://github.com/fissionjs/fission/blob/e34eed78ed2386bb7934a69214e13f17fcd311c3/lib/renderables/collectionView.js#L136-L151 | train | |
cutting-room-floor/markers.js | dist/markers.js | reposition | function reposition(marker) {
// remember the tile coordinate so we don't have to reproject every time
if (!marker.coord) marker.coord = m.map.locationCoordinate(marker.location);
var pos = m.map.coordinatePoint(marker.coord);
var pos_loc, new_pos;
// If this point has wound aro... | javascript | function reposition(marker) {
// remember the tile coordinate so we don't have to reproject every time
if (!marker.coord) marker.coord = m.map.locationCoordinate(marker.location);
var pos = m.map.coordinatePoint(marker.coord);
var pos_loc, new_pos;
// If this point has wound aro... | [
"function",
"reposition",
"(",
"marker",
")",
"{",
"// remember the tile coordinate so we don't have to reproject every time",
"if",
"(",
"!",
"marker",
".",
"coord",
")",
"marker",
".",
"coord",
"=",
"m",
".",
"map",
".",
"locationCoordinate",
"(",
"marker",
".",
... | reposition a single marker element | [
"reposition",
"a",
"single",
"marker",
"element"
] | 3feae089a43b4c10835bb0f147e8166333fc7b6a | https://github.com/cutting-room-floor/markers.js/blob/3feae089a43b4c10835bb0f147e8166333fc7b6a/dist/markers.js#L46-L75 | train |
cutting-room-floor/markers.js | dist/markers.js | stopPropagation | function stopPropagation(e) {
e.cancelBubble = true;
if (e.stopPropagation) { e.stopPropagation(); }
return false;
} | javascript | function stopPropagation(e) {
e.cancelBubble = true;
if (e.stopPropagation) { e.stopPropagation(); }
return false;
} | [
"function",
"stopPropagation",
"(",
"e",
")",
"{",
"e",
".",
"cancelBubble",
"=",
"true",
";",
"if",
"(",
"e",
".",
"stopPropagation",
")",
"{",
"e",
".",
"stopPropagation",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Block mouse and touch events | [
"Block",
"mouse",
"and",
"touch",
"events"
] | 3feae089a43b4c10835bb0f147e8166333fc7b6a | https://github.com/cutting-room-floor/markers.js/blob/3feae089a43b4c10835bb0f147e8166333fc7b6a/dist/markers.js#L430-L434 | train |
cutting-room-floor/markers.js | dist/markers.js | csv_parse | function csv_parse(text) {
var header;
return csv_parseRows(text, function(row, i) {
if (i) {
var o = {}, j = -1, m = header.length;
while (++j < m) o[header[j]] = row[j];
return o;
} else {
header = row;
... | javascript | function csv_parse(text) {
var header;
return csv_parseRows(text, function(row, i) {
if (i) {
var o = {}, j = -1, m = header.length;
while (++j < m) o[header[j]] = row[j];
return o;
} else {
header = row;
... | [
"function",
"csv_parse",
"(",
"text",
")",
"{",
"var",
"header",
";",
"return",
"csv_parseRows",
"(",
"text",
",",
"function",
"(",
"row",
",",
"i",
")",
"{",
"if",
"(",
"i",
")",
"{",
"var",
"o",
"=",
"{",
"}",
",",
"j",
"=",
"-",
"1",
",",
... | Extracted from d3 | [
"Extracted",
"from",
"d3"
] | 3feae089a43b4c10835bb0f147e8166333fc7b6a | https://github.com/cutting-room-floor/markers.js/blob/3feae089a43b4c10835bb0f147e8166333fc7b6a/dist/markers.js#L506-L518 | train |
Icinetic/baucis-swagger2 | Controller.js | swagger20TypeFor | function swagger20TypeFor(type) {
if (!type) { return null; }
if (type === Number) { return 'number'; }
if (type === Boolean) { return 'boolean'; }
if (type === String ||
type === Date ||
type === mongoose.Schema.Types.ObjectId ||
type === mongoose.Schema.Types.Oid) {
return 'string';
}
... | javascript | function swagger20TypeFor(type) {
if (!type) { return null; }
if (type === Number) { return 'number'; }
if (type === Boolean) { return 'boolean'; }
if (type === String ||
type === Date ||
type === mongoose.Schema.Types.ObjectId ||
type === mongoose.Schema.Types.Oid) {
return 'string';
}
... | [
"function",
"swagger20TypeFor",
"(",
"type",
")",
"{",
"if",
"(",
"!",
"type",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"type",
"===",
"Number",
")",
"{",
"return",
"'number'",
";",
"}",
"if",
"(",
"type",
"===",
"Boolean",
")",
"{",
"retur... | Convert a Mongoose type into a Swagger type | [
"Convert",
"a",
"Mongoose",
"type",
"into",
"a",
"Swagger",
"type"
] | 502200ae8ac131849fe20d95636bf3170561e81e | https://github.com/Icinetic/baucis-swagger2/blob/502200ae8ac131849fe20d95636bf3170561e81e/Controller.js#L161-L183 | train |
Icinetic/baucis-swagger2 | Controller.js | generatePropertyDefinition | function generatePropertyDefinition(name, path, definitionName) {
var property = {};
var type = path.options.type ? swagger20TypeFor(path.options.type) : 'string'; // virtuals don't have type
if (skipProperty(name, path, controller)) {
return;
}
// Configure the property
if (path.options.... | javascript | function generatePropertyDefinition(name, path, definitionName) {
var property = {};
var type = path.options.type ? swagger20TypeFor(path.options.type) : 'string'; // virtuals don't have type
if (skipProperty(name, path, controller)) {
return;
}
// Configure the property
if (path.options.... | [
"function",
"generatePropertyDefinition",
"(",
"name",
",",
"path",
",",
"definitionName",
")",
"{",
"var",
"property",
"=",
"{",
"}",
";",
"var",
"type",
"=",
"path",
".",
"options",
".",
"type",
"?",
"swagger20TypeFor",
"(",
"path",
".",
"options",
".",
... | A method used to generated a Swagger property for a model | [
"A",
"method",
"used",
"to",
"generated",
"a",
"Swagger",
"property",
"for",
"a",
"model"
] | 502200ae8ac131849fe20d95636bf3170561e81e | https://github.com/Icinetic/baucis-swagger2/blob/502200ae8ac131849fe20d95636bf3170561e81e/Controller.js#L225-L301 | train |
Incroud/cassanova | lib/query.js | processPartitionKeys | function processPartitionKeys(keys){
var result = "(",
j,
len,
keyGroup;
if(typeof keys === 'string'){
return result += keys + ")";
}
len = keys.length;
for(j = 0; j< keys.length; j++){
keyGroup = keys[j];
if(keyGroup instanceof Array){
r... | javascript | function processPartitionKeys(keys){
var result = "(",
j,
len,
keyGroup;
if(typeof keys === 'string'){
return result += keys + ")";
}
len = keys.length;
for(j = 0; j< keys.length; j++){
keyGroup = keys[j];
if(keyGroup instanceof Array){
r... | [
"function",
"processPartitionKeys",
"(",
"keys",
")",
"{",
"var",
"result",
"=",
"\"(\"",
",",
"j",
",",
"len",
",",
"keyGroup",
";",
"if",
"(",
"typeof",
"keys",
"===",
"'string'",
")",
"{",
"return",
"result",
"+=",
"keys",
"+",
"\")\"",
";",
"}",
... | An internal method, it processes primary partition keys into a CQL statement.
@param {Object} keys A string, Array or multi-dimensional Array
@return {String} A CQL formatted string of the partition key | [
"An",
"internal",
"method",
"it",
"processes",
"primary",
"partition",
"keys",
"into",
"a",
"CQL",
"statement",
"."
] | 49c5ce2e1bc6b19d25e8223e88df45c113c36b68 | https://github.com/Incroud/cassanova/blob/49c5ce2e1bc6b19d25e8223e88df45c113c36b68/lib/query.js#L22-L47 | train |
Incroud/cassanova | lib/query.js | function(collection, blacklist){
var obj,
result = [],
prop,
i,
j,
collLen,
listLen;
blacklist = blacklist || ["__columns"];
if(!collection || !collection.length){
return result;
}
collLen = co... | javascript | function(collection, blacklist){
var obj,
result = [],
prop,
i,
j,
collLen,
listLen;
blacklist = blacklist || ["__columns"];
if(!collection || !collection.length){
return result;
}
collLen = co... | [
"function",
"(",
"collection",
",",
"blacklist",
")",
"{",
"var",
"obj",
",",
"result",
"=",
"[",
"]",
",",
"prop",
",",
"i",
",",
"j",
",",
"collLen",
",",
"listLen",
";",
"blacklist",
"=",
"blacklist",
"||",
"[",
"\"__columns\"",
"]",
";",
"if",
... | Removes black-listed properties from the data | [
"Removes",
"black",
"-",
"listed",
"properties",
"from",
"the",
"data"
] | 49c5ce2e1bc6b19d25e8223e88df45c113c36b68 | https://github.com/Incroud/cassanova/blob/49c5ce2e1bc6b19d25e8223e88df45c113c36b68/lib/query.js#L664-L700 | train | |
hoodiehq/pouchdb-hoodie-sync | lib/one.js | one | function one (state, eventName, handler) {
state.emitter.once(eventName, handler)
return state.api
} | javascript | function one (state, eventName, handler) {
state.emitter.once(eventName, handler)
return state.api
} | [
"function",
"one",
"(",
"state",
",",
"eventName",
",",
"handler",
")",
"{",
"state",
".",
"emitter",
".",
"once",
"(",
"eventName",
",",
"handler",
")",
"return",
"state",
".",
"api",
"}"
] | binds event only once to handler
@param {String} eventName push, pull, connect, disconnect
@param {Function} handler function once bound to event
@return {Promise} | [
"binds",
"event",
"only",
"once",
"to",
"handler"
] | c489baf813020c7f0cbd111224432cb6718c90de | https://github.com/hoodiehq/pouchdb-hoodie-sync/blob/c489baf813020c7f0cbd111224432cb6718c90de/lib/one.js#L10-L14 | train |
jugglingdb/connect-jugglingdb | index.js | JugglingStore | function JugglingStore(schema, options) {
options = options || {};
Store.call(this, options);
this.maxAge = options.maxAge || defaults.maxAge;
var coll = this.collection = schema.define('Session', {
sid: {
type: String,
index: true
},
expires: {
type: Date,
index: true
},
session:... | javascript | function JugglingStore(schema, options) {
options = options || {};
Store.call(this, options);
this.maxAge = options.maxAge || defaults.maxAge;
var coll = this.collection = schema.define('Session', {
sid: {
type: String,
index: true
},
expires: {
type: Date,
index: true
},
session:... | [
"function",
"JugglingStore",
"(",
"schema",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"Store",
".",
"call",
"(",
"this",
",",
"options",
")",
";",
"this",
".",
"maxAge",
"=",
"options",
".",
"maxAge",
"||",
"defaults",
... | Initialize JugglingStore with the given `options`.
@param {JugglingDB.Schema} schema
@param {Object} options
@api public | [
"Initialize",
"JugglingStore",
"with",
"the",
"given",
"options",
"."
] | b088660f6d69bd52dfd79c8523034cd0d2673694 | https://github.com/jugglingdb/connect-jugglingdb/blob/b088660f6d69bd52dfd79c8523034cd0d2673694/index.js#L30-L58 | train |
rangle/koast | lib/app/app-maker.js | validateRouteDefinition | function validateRouteDefinition(routeDef) {
var expectedKeys = ['route', 'type', 'module', 'path'];
var expectedTypes = ['static', 'module'];
var expectedTypeMap = {
'static': 'path',
'module': 'module'
};
var keys = Object.keys(routeDef);
var EXPECTED_NUMBER_OF_PROPERTIES = 3;
//Handle warnings... | javascript | function validateRouteDefinition(routeDef) {
var expectedKeys = ['route', 'type', 'module', 'path'];
var expectedTypes = ['static', 'module'];
var expectedTypeMap = {
'static': 'path',
'module': 'module'
};
var keys = Object.keys(routeDef);
var EXPECTED_NUMBER_OF_PROPERTIES = 3;
//Handle warnings... | [
"function",
"validateRouteDefinition",
"(",
"routeDef",
")",
"{",
"var",
"expectedKeys",
"=",
"[",
"'route'",
",",
"'type'",
",",
"'module'",
",",
"'path'",
"]",
";",
"var",
"expectedTypes",
"=",
"[",
"'static'",
",",
"'module'",
"]",
";",
"var",
"expectedTy... | Validate the incoming route configurations are valie.
@param routeDef
@example
{
'route': '/alwaysStartWithSlash',
'type': 'static' || 'module',
'module' || 'path': 'filePath'
}
@return true if valid otherwise throw an error. | [
"Validate",
"the",
"incoming",
"route",
"configurations",
"are",
"valie",
"."
] | 446dfaba7f80c03ae17d86b34dfafd6328be1ba6 | https://github.com/rangle/koast/blob/446dfaba7f80c03ae17d86b34dfafd6328be1ba6/lib/app/app-maker.js#L73-L107 | train |
entrinsik-org/utils | lib/constant-aggregate-expression.js | ConstantAggregateExpression | function ConstantAggregateExpression(number) {
if(!Number.isFinite(number))
this.number = parseFloat(number);
else
this.number = number;
} | javascript | function ConstantAggregateExpression(number) {
if(!Number.isFinite(number))
this.number = parseFloat(number);
else
this.number = number;
} | [
"function",
"ConstantAggregateExpression",
"(",
"number",
")",
"{",
"if",
"(",
"!",
"Number",
".",
"isFinite",
"(",
"number",
")",
")",
"this",
".",
"number",
"=",
"parseFloat",
"(",
"number",
")",
";",
"else",
"this",
".",
"number",
"=",
"number",
";",
... | Represent a constant number for use an an argument to a aggregation calculation
@param number {number}
@constructor | [
"Represent",
"a",
"constant",
"number",
"for",
"use",
"an",
"an",
"argument",
"to",
"a",
"aggregation",
"calculation"
] | da2bff77afd0c3316148d7b79b2416d021a9b53a | https://github.com/entrinsik-org/utils/blob/da2bff77afd0c3316148d7b79b2416d021a9b53a/lib/constant-aggregate-expression.js#L11-L16 | train |
gbv/jskos-tools | lib/identifiers.js | reduceSet | function reduceSet(set) {
return set.map(member => member && member.uri).filter(Boolean)
} | javascript | function reduceSet(set) {
return set.map(member => member && member.uri).filter(Boolean)
} | [
"function",
"reduceSet",
"(",
"set",
")",
"{",
"return",
"set",
".",
"map",
"(",
"member",
"=>",
"member",
"&&",
"member",
".",
"uri",
")",
".",
"filter",
"(",
"Boolean",
")",
"}"
] | Reduce JSKOS set to members with URI. | [
"Reduce",
"JSKOS",
"set",
"to",
"members",
"with",
"URI",
"."
] | da8672203362ea874f4ab9cdd34b990369987075 | https://github.com/gbv/jskos-tools/blob/da8672203362ea874f4ab9cdd34b990369987075/lib/identifiers.js#L10-L12 | train |
gbv/jskos-tools | lib/identifiers.js | mappingContent | function mappingContent(mapping) {
const { from, to, type } = mapping
let result = {
from: reduceBundle(from || {}),
to: reduceBundle(to || {}),
type: [
type && type[0] || "http://www.w3.org/2004/02/skos/core#mappingRelation"
]
}
for (let side of ["from", "to"]) {
if ((result[side][mem... | javascript | function mappingContent(mapping) {
const { from, to, type } = mapping
let result = {
from: reduceBundle(from || {}),
to: reduceBundle(to || {}),
type: [
type && type[0] || "http://www.w3.org/2004/02/skos/core#mappingRelation"
]
}
for (let side of ["from", "to"]) {
if ((result[side][mem... | [
"function",
"mappingContent",
"(",
"mapping",
")",
"{",
"const",
"{",
"from",
",",
"to",
",",
"type",
"}",
"=",
"mapping",
"let",
"result",
"=",
"{",
"from",
":",
"reduceBundle",
"(",
"from",
"||",
"{",
"}",
")",
",",
"to",
":",
"reduceBundle",
"(",
... | Reduce mapping to reduced fields from, to, and type. | [
"Reduce",
"mapping",
"to",
"reduced",
"fields",
"from",
"to",
"and",
"type",
"."
] | da8672203362ea874f4ab9cdd34b990369987075 | https://github.com/gbv/jskos-tools/blob/da8672203362ea874f4ab9cdd34b990369987075/lib/identifiers.js#L29-L48 | train |
gbv/jskos-tools | lib/identifiers.js | mappingMembers | function mappingMembers(mapping) {
const { from, to } = mapping
const memberUris = [ from, to ].filter(Boolean)
.map(bundle => reduceSet(bundle[memberField(bundle)] || []))
return [].concat(...memberUris).sort()
} | javascript | function mappingMembers(mapping) {
const { from, to } = mapping
const memberUris = [ from, to ].filter(Boolean)
.map(bundle => reduceSet(bundle[memberField(bundle)] || []))
return [].concat(...memberUris).sort()
} | [
"function",
"mappingMembers",
"(",
"mapping",
")",
"{",
"const",
"{",
"from",
",",
"to",
"}",
"=",
"mapping",
"const",
"memberUris",
"=",
"[",
"from",
",",
"to",
"]",
".",
"filter",
"(",
"Boolean",
")",
".",
"map",
"(",
"bundle",
"=>",
"reduceSet",
"... | Get a sorted list of member URIs. | [
"Get",
"a",
"sorted",
"list",
"of",
"member",
"URIs",
"."
] | da8672203362ea874f4ab9cdd34b990369987075 | https://github.com/gbv/jskos-tools/blob/da8672203362ea874f4ab9cdd34b990369987075/lib/identifiers.js#L51-L56 | train |
hoodiehq/pouchdb-hoodie-sync | lib/on.js | on | function on (state, eventName, handler) {
state.emitter.on(eventName, handler)
return state.api
} | javascript | function on (state, eventName, handler) {
state.emitter.on(eventName, handler)
return state.api
} | [
"function",
"on",
"(",
"state",
",",
"eventName",
",",
"handler",
")",
"{",
"state",
".",
"emitter",
".",
"on",
"(",
"eventName",
",",
"handler",
")",
"return",
"state",
".",
"api",
"}"
] | binds event to handler
@param {String} eventName push, pull, connect, disconnect
@param {Function} handler function bound to event
@return {Promise} | [
"binds",
"event",
"to",
"handler"
] | c489baf813020c7f0cbd111224432cb6718c90de | https://github.com/hoodiehq/pouchdb-hoodie-sync/blob/c489baf813020c7f0cbd111224432cb6718c90de/lib/on.js#L10-L14 | train |
Pinoccio/client-node-pinoccio | lib/commands/bridge/index.js | bridgeCommand | function bridgeCommand(command,cb){
if(!connected) return setImmediate(function(){
cb('killed');
});
if(!connected.pings) connected.pings = {};
var id = ++pingid;
var timer;
connected.pings[id] = function(err,data){
clearTimeout(timer);
delete connected.pings[id]
cb(err,... | javascript | function bridgeCommand(command,cb){
if(!connected) return setImmediate(function(){
cb('killed');
});
if(!connected.pings) connected.pings = {};
var id = ++pingid;
var timer;
connected.pings[id] = function(err,data){
clearTimeout(timer);
delete connected.pings[id]
cb(err,... | [
"function",
"bridgeCommand",
"(",
"command",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"connected",
")",
"return",
"setImmediate",
"(",
"function",
"(",
")",
"{",
"cb",
"(",
"'killed'",
")",
";",
"}",
")",
";",
"if",
"(",
"!",
"connected",
".",
"pings",
... | rpc to worker process for commands. | [
"rpc",
"to",
"worker",
"process",
"for",
"commands",
"."
] | 9ee7b254639190a228dce6a4db9680f2c1bf1ca5 | https://github.com/Pinoccio/client-node-pinoccio/blob/9ee7b254639190a228dce6a4db9680f2c1bf1ca5/lib/commands/bridge/index.js#L200-L218 | train |
Pinoccio/client-node-pinoccio | lib/commands/bridge/index.js | deviceScan | function deviceScan(){
shuffle(Object.keys(watchs.boards)).forEach(function(id){
plugHandler({event:'plug',device:watchs.boards[id]});
});
} | javascript | function deviceScan(){
shuffle(Object.keys(watchs.boards)).forEach(function(id){
plugHandler({event:'plug',device:watchs.boards[id]});
});
} | [
"function",
"deviceScan",
"(",
")",
"{",
"shuffle",
"(",
"Object",
".",
"keys",
"(",
"watchs",
".",
"boards",
")",
")",
".",
"forEach",
"(",
"function",
"(",
"id",
")",
"{",
"plugHandler",
"(",
"{",
"event",
":",
"'plug'",
",",
"device",
":",
"watchs... | find the next eligble bridge scout. | [
"find",
"the",
"next",
"eligble",
"bridge",
"scout",
"."
] | 9ee7b254639190a228dce6a4db9680f2c1bf1ca5 | https://github.com/Pinoccio/client-node-pinoccio/blob/9ee7b254639190a228dce6a4db9680f2c1bf1ca5/lib/commands/bridge/index.js#L497-L501 | train |
hoodiehq/pouchdb-hoodie-sync | lib/sync.js | sync | function sync (state, docsOrIds) {
var syncedObjects = []
var errors = state.db.constructor.Errors
return Promise.resolve(state.remote)
.then(function (remote) {
return new Promise(function (resolve, reject) {
if (Array.isArray(docsOrIds)) {
docsOrIds = docsOrIds.map(toId)
} else {
... | javascript | function sync (state, docsOrIds) {
var syncedObjects = []
var errors = state.db.constructor.Errors
return Promise.resolve(state.remote)
.then(function (remote) {
return new Promise(function (resolve, reject) {
if (Array.isArray(docsOrIds)) {
docsOrIds = docsOrIds.map(toId)
} else {
... | [
"function",
"sync",
"(",
"state",
",",
"docsOrIds",
")",
"{",
"var",
"syncedObjects",
"=",
"[",
"]",
"var",
"errors",
"=",
"state",
".",
"db",
".",
"constructor",
".",
"Errors",
"return",
"Promise",
".",
"resolve",
"(",
"state",
".",
"remote",
")",
"."... | syncs one or multiple objects between local and remote database
@param {StringOrObject} docsOrIds object or ID of object or array of objects/ids (all optional)
@return {Promise} | [
"syncs",
"one",
"or",
"multiple",
"objects",
"between",
"local",
"and",
"remote",
"database"
] | c489baf813020c7f0cbd111224432cb6718c90de | https://github.com/hoodiehq/pouchdb-hoodie-sync/blob/c489baf813020c7f0cbd111224432cb6718c90de/lib/sync.js#L13-L55 | train |
bem-contrib/md-to-bemjson | packages/remark-bemjson/lib/exports.js | createExport | function createExport(exportOptions, content) {
if (!content) return content;
const type = exportOptions.type;
const name = exportOptions.name;
const exportFunction = exportFabric(type);
return exportFunction(name, content);
} | javascript | function createExport(exportOptions, content) {
if (!content) return content;
const type = exportOptions.type;
const name = exportOptions.name;
const exportFunction = exportFabric(type);
return exportFunction(name, content);
} | [
"function",
"createExport",
"(",
"exportOptions",
",",
"content",
")",
"{",
"if",
"(",
"!",
"content",
")",
"return",
"content",
";",
"const",
"type",
"=",
"exportOptions",
".",
"type",
";",
"const",
"name",
"=",
"exportOptions",
".",
"name",
";",
"const",... | Create export for one of provided modules
@param {Object} exportOptions - export type and name
@param {ExportType} exportOptions.type - export type
@param {String} [exportOptions.name] - export name, required for browser modules
@param {String} content - bemjson content
@returns {String} | [
"Create",
"export",
"for",
"one",
"of",
"provided",
"modules"
] | 047ab80c681073c7c92aecee754bcf46956507a9 | https://github.com/bem-contrib/md-to-bemjson/blob/047ab80c681073c7c92aecee754bcf46956507a9/packages/remark-bemjson/lib/exports.js#L33-L41 | train |
soajs/soajs.core.drivers | infra/google/kubernetes/index.js | createVpcNetwork | function createVpcNetwork(mCb) {
let networksOptions = Object.assign({}, options);
networksOptions.params = {
name,
returnGlobalOperation: true
};
networks.add(networksOptions, (error, globalOperationResponse) => {
if (error) return cb(error);
//assign network name to deployment entry
... | javascript | function createVpcNetwork(mCb) {
let networksOptions = Object.assign({}, options);
networksOptions.params = {
name,
returnGlobalOperation: true
};
networks.add(networksOptions, (error, globalOperationResponse) => {
if (error) return cb(error);
//assign network name to deployment entry
... | [
"function",
"createVpcNetwork",
"(",
"mCb",
")",
"{",
"let",
"networksOptions",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"options",
")",
";",
"networksOptions",
".",
"params",
"=",
"{",
"name",
",",
"returnGlobalOperation",
":",
"true",
"}",
";",
... | method used to create a google vpc network
@returns {*} | [
"method",
"used",
"to",
"create",
"a",
"google",
"vpc",
"network"
] | 545891509a47e16d9d2f40515e81bb1f4f3d8165 | https://github.com/soajs/soajs.core.drivers/blob/545891509a47e16d9d2f40515e81bb1f4f3d8165/infra/google/kubernetes/index.js#L95-L150 | train |
soajs/soajs.core.drivers | infra/google/kubernetes/index.js | useVpcNetwork | function useVpcNetwork(mCb) {
//assign network name to deployment entry
oneDeployment.options.network = name;
function patchFirewall() {
let firewallRules = getFirewallRules(oneDeployment.options.network);
let request = getConnector(options.infra.api);
request.filter = `network eq .*${oneD... | javascript | function useVpcNetwork(mCb) {
//assign network name to deployment entry
oneDeployment.options.network = name;
function patchFirewall() {
let firewallRules = getFirewallRules(oneDeployment.options.network);
let request = getConnector(options.infra.api);
request.filter = `network eq .*${oneD... | [
"function",
"useVpcNetwork",
"(",
"mCb",
")",
"{",
"//assign network name to deployment entry",
"oneDeployment",
".",
"options",
".",
"network",
"=",
"name",
";",
"function",
"patchFirewall",
"(",
")",
"{",
"let",
"firewallRules",
"=",
"getFirewallRules",
"(",
"oneD... | method used to use an existing google vpc network
@returns {*} | [
"method",
"used",
"to",
"use",
"an",
"existing",
"google",
"vpc",
"network"
] | 545891509a47e16d9d2f40515e81bb1f4f3d8165 | https://github.com/soajs/soajs.core.drivers/blob/545891509a47e16d9d2f40515e81bb1f4f3d8165/infra/google/kubernetes/index.js#L156-L192 | 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.