id
int32 0
58k
| 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
sequence | docstring
stringlengths 4
11.8k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 86
226
|
---|---|---|---|---|---|---|---|---|---|---|---|
51,500 | wunderbyte/grunt-spiritual-dox | src/js/libs/spiritual-edb.js | function() {
var count = 0,
elm = this.element();
if (this._map) {
if ((count = edbml.FunctionUpdate._remap(elm, this._map))) {
this._report("remapped " + count + " keys");
}
} else {
if ((count = edbml.FunctionUpdate._revoke(elm))) {
this._report("revoked " + count + " keys");
}
}
} | javascript | function() {
var count = 0,
elm = this.element();
if (this._map) {
if ((count = edbml.FunctionUpdate._remap(elm, this._map))) {
this._report("remapped " + count + " keys");
}
} else {
if ((count = edbml.FunctionUpdate._revoke(elm))) {
this._report("revoked " + count + " keys");
}
}
} | [
"function",
"(",
")",
"{",
"var",
"count",
"=",
"0",
",",
"elm",
"=",
"this",
".",
"element",
"(",
")",
";",
"if",
"(",
"this",
".",
"_map",
")",
"{",
"if",
"(",
"(",
"count",
"=",
"edbml",
".",
"FunctionUpdate",
".",
"_remap",
"(",
"elm",
",",
"this",
".",
"_map",
")",
")",
")",
"{",
"this",
".",
"_report",
"(",
"\"remapped \"",
"+",
"count",
"+",
"\" keys\"",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"(",
"count",
"=",
"edbml",
".",
"FunctionUpdate",
".",
"_revoke",
"(",
"elm",
")",
")",
")",
"{",
"this",
".",
"_report",
"(",
"\"revoked \"",
"+",
"count",
"+",
"\" keys\"",
")",
";",
"}",
"}",
"}"
] | Do the update. | [
"Do",
"the",
"update",
"."
] | 5afcfe31ddbf7d654166aa15b938553b61de5811 | https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L4130-L4142 |
|
51,501 | wunderbyte/grunt-spiritual-dox | src/js/libs/spiritual-edb.js | function(element) {
var atts = [];
new gui.Crawler('functionupdate').descend(element, {
handleElement: function(elm) {
if (elm !== element) {
Array.forEach(elm.attributes, function(att) {
if (att.value.contains("edbml.$run")) {
atts.push([elm, att]);
}
});
if (elm.spirit && elm.spirit.script.loaded) { // ... not our DOM tree
return gui.Crawler.SKIP_CHILDREN;
}
}
}
});
return atts;
} | javascript | function(element) {
var atts = [];
new gui.Crawler('functionupdate').descend(element, {
handleElement: function(elm) {
if (elm !== element) {
Array.forEach(elm.attributes, function(att) {
if (att.value.contains("edbml.$run")) {
atts.push([elm, att]);
}
});
if (elm.spirit && elm.spirit.script.loaded) { // ... not our DOM tree
return gui.Crawler.SKIP_CHILDREN;
}
}
}
});
return atts;
} | [
"function",
"(",
"element",
")",
"{",
"var",
"atts",
"=",
"[",
"]",
";",
"new",
"gui",
".",
"Crawler",
"(",
"'functionupdate'",
")",
".",
"descend",
"(",
"element",
",",
"{",
"handleElement",
":",
"function",
"(",
"elm",
")",
"{",
"if",
"(",
"elm",
"!==",
"element",
")",
"{",
"Array",
".",
"forEach",
"(",
"elm",
".",
"attributes",
",",
"function",
"(",
"att",
")",
"{",
"if",
"(",
"att",
".",
"value",
".",
"contains",
"(",
"\"edbml.$run\"",
")",
")",
"{",
"atts",
".",
"push",
"(",
"[",
"elm",
",",
"att",
"]",
")",
";",
"}",
"}",
")",
";",
"if",
"(",
"elm",
".",
"spirit",
"&&",
"elm",
".",
"spirit",
".",
"script",
".",
"loaded",
")",
"{",
"// ... not our DOM tree",
"return",
"gui",
".",
"Crawler",
".",
"SKIP_CHILDREN",
";",
"}",
"}",
"}",
"}",
")",
";",
"return",
"atts",
";",
"}"
] | Collect attributes from DOM subtree that
somewhat resemble EDBML poke statements.
@returns {Array<Array<Node>>} | [
"Collect",
"attributes",
"from",
"DOM",
"subtree",
"that",
"somewhat",
"resemble",
"EDBML",
"poke",
"statements",
"."
] | 5afcfe31ddbf7d654166aa15b938553b61de5811 | https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L4210-L4227 |
|
51,502 | wunderbyte/grunt-spiritual-dox | src/js/libs/spiritual-edb.js | function() {
gui.Plugin.prototype.ondestruct.call(this);
if (this.loaded) {
gui.Tick.cancelFrame(this._frameindex);
this.spirit.life.remove(gui.LIFE_ENTER, this);
gui.Broadcast.remove(edb.BROADCAST_ACCESS, this);
if (this.$input) { // TODO: interface for this (dispose)
this.$input.ondestruct();
this.$input.$ondestruct();
}
}
} | javascript | function() {
gui.Plugin.prototype.ondestruct.call(this);
if (this.loaded) {
gui.Tick.cancelFrame(this._frameindex);
this.spirit.life.remove(gui.LIFE_ENTER, this);
gui.Broadcast.remove(edb.BROADCAST_ACCESS, this);
if (this.$input) { // TODO: interface for this (dispose)
this.$input.ondestruct();
this.$input.$ondestruct();
}
}
} | [
"function",
"(",
")",
"{",
"gui",
".",
"Plugin",
".",
"prototype",
".",
"ondestruct",
".",
"call",
"(",
"this",
")",
";",
"if",
"(",
"this",
".",
"loaded",
")",
"{",
"gui",
".",
"Tick",
".",
"cancelFrame",
"(",
"this",
".",
"_frameindex",
")",
";",
"this",
".",
"spirit",
".",
"life",
".",
"remove",
"(",
"gui",
".",
"LIFE_ENTER",
",",
"this",
")",
";",
"gui",
".",
"Broadcast",
".",
"remove",
"(",
"edb",
".",
"BROADCAST_ACCESS",
",",
"this",
")",
";",
"if",
"(",
"this",
".",
"$input",
")",
"{",
"// TODO: interface for this (dispose)",
"this",
".",
"$input",
".",
"ondestruct",
"(",
")",
";",
"this",
".",
"$input",
".",
"$ondestruct",
"(",
")",
";",
"}",
"}",
"}"
] | Destruction time. | [
"Destruction",
"time",
"."
] | 5afcfe31ddbf7d654166aa15b938553b61de5811 | https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L4274-L4285 |
|
51,503 | wunderbyte/grunt-spiritual-dox | src/js/libs/spiritual-edb.js | function(html) {
var changed = this._html !== html;
var focused = this._focusedfield();
if (changed) {
this._html = html;
this._updater.update(html);
if(focused) {
this._restorefocus(focused);
}
}
this._status(this.spirit);
this.ran = true; // TODO: deprecate and use 'spirit.life.rendered'
} | javascript | function(html) {
var changed = this._html !== html;
var focused = this._focusedfield();
if (changed) {
this._html = html;
this._updater.update(html);
if(focused) {
this._restorefocus(focused);
}
}
this._status(this.spirit);
this.ran = true; // TODO: deprecate and use 'spirit.life.rendered'
} | [
"function",
"(",
"html",
")",
"{",
"var",
"changed",
"=",
"this",
".",
"_html",
"!==",
"html",
";",
"var",
"focused",
"=",
"this",
".",
"_focusedfield",
"(",
")",
";",
"if",
"(",
"changed",
")",
"{",
"this",
".",
"_html",
"=",
"html",
";",
"this",
".",
"_updater",
".",
"update",
"(",
"html",
")",
";",
"if",
"(",
"focused",
")",
"{",
"this",
".",
"_restorefocus",
"(",
"focused",
")",
";",
"}",
"}",
"this",
".",
"_status",
"(",
"this",
".",
"spirit",
")",
";",
"this",
".",
"ran",
"=",
"true",
";",
"// TODO: deprecate and use 'spirit.life.rendered'",
"}"
] | Write the actual HTML to screen. You should probably only
call this method if you are producing your own markup
somehow, ie. not using EDBML templates out of the box.
@param {String} html | [
"Write",
"the",
"actual",
"HTML",
"to",
"screen",
".",
"You",
"should",
"probably",
"only",
"call",
"this",
"method",
"if",
"you",
"are",
"producing",
"your",
"own",
"markup",
"somehow",
"ie",
".",
"not",
"using",
"EDBML",
"templates",
"out",
"of",
"the",
"box",
"."
] | 5afcfe31ddbf7d654166aa15b938553b61de5811 | https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L4350-L4362 |
|
51,504 | wunderbyte/grunt-spiritual-dox | src/js/libs/spiritual-edb.js | function(changes) {
if (changes.some(function(c) {
var id = c.object.$instanceid,
clas = c.object.$classname,
name = c.name;
if(edbml.$rendering && edbml.$rendering[id]) {
console.error(
'Don\'t update "' + name + '" of the ' + clas + ' while ' +
'rendering, it will cause the rendering to run in an endless loop. '
);
} else {
var props = this._oldfokkers[id].properties;
try {
if (!name || props[name]) {
return true;
}
} catch (todoexception) {
//console.error(this._oldfokkers[id].toString(), name);
// TODO: fix sceario with selectedIndex................
}
return false;
}
}, this)) {
this._schedule();
}
} | javascript | function(changes) {
if (changes.some(function(c) {
var id = c.object.$instanceid,
clas = c.object.$classname,
name = c.name;
if(edbml.$rendering && edbml.$rendering[id]) {
console.error(
'Don\'t update "' + name + '" of the ' + clas + ' while ' +
'rendering, it will cause the rendering to run in an endless loop. '
);
} else {
var props = this._oldfokkers[id].properties;
try {
if (!name || props[name]) {
return true;
}
} catch (todoexception) {
//console.error(this._oldfokkers[id].toString(), name);
// TODO: fix sceario with selectedIndex................
}
return false;
}
}, this)) {
this._schedule();
}
} | [
"function",
"(",
"changes",
")",
"{",
"if",
"(",
"changes",
".",
"some",
"(",
"function",
"(",
"c",
")",
"{",
"var",
"id",
"=",
"c",
".",
"object",
".",
"$instanceid",
",",
"clas",
"=",
"c",
".",
"object",
".",
"$classname",
",",
"name",
"=",
"c",
".",
"name",
";",
"if",
"(",
"edbml",
".",
"$rendering",
"&&",
"edbml",
".",
"$rendering",
"[",
"id",
"]",
")",
"{",
"console",
".",
"error",
"(",
"'Don\\'t update \"'",
"+",
"name",
"+",
"'\" of the '",
"+",
"clas",
"+",
"' while '",
"+",
"'rendering, it will cause the rendering to run in an endless loop. '",
")",
";",
"}",
"else",
"{",
"var",
"props",
"=",
"this",
".",
"_oldfokkers",
"[",
"id",
"]",
".",
"properties",
";",
"try",
"{",
"if",
"(",
"!",
"name",
"||",
"props",
"[",
"name",
"]",
")",
"{",
"return",
"true",
";",
"}",
"}",
"catch",
"(",
"todoexception",
")",
"{",
"//console.error(this._oldfokkers[id].toString(), name);",
"// TODO: fix sceario with selectedIndex................",
"}",
"return",
"false",
";",
"}",
"}",
",",
"this",
")",
")",
"{",
"this",
".",
"_schedule",
"(",
")",
";",
"}",
"}"
] | Handle change.
@param {Array<edb.Change>} changes | [
"Handle",
"change",
"."
] | 5afcfe31ddbf7d654166aa15b938553b61de5811 | https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L4426-L4451 |
|
51,505 | wunderbyte/grunt-spiritual-dox | src/js/libs/spiritual-edb.js | function(l) {
if (l.type === gui.LIFE_ENTER) {
if (!this.spirit.life.rendered) { // spirit did a manual run?
this.run.apply(this, this._arguments || []);
}
this.spirit.life.remove(l.type, this);
this._arguments = null;
}
} | javascript | function(l) {
if (l.type === gui.LIFE_ENTER) {
if (!this.spirit.life.rendered) { // spirit did a manual run?
this.run.apply(this, this._arguments || []);
}
this.spirit.life.remove(l.type, this);
this._arguments = null;
}
} | [
"function",
"(",
"l",
")",
"{",
"if",
"(",
"l",
".",
"type",
"===",
"gui",
".",
"LIFE_ENTER",
")",
"{",
"if",
"(",
"!",
"this",
".",
"spirit",
".",
"life",
".",
"rendered",
")",
"{",
"// spirit did a manual run?",
"this",
".",
"run",
".",
"apply",
"(",
"this",
",",
"this",
".",
"_arguments",
"||",
"[",
"]",
")",
";",
"}",
"this",
".",
"spirit",
".",
"life",
".",
"remove",
"(",
"l",
".",
"type",
",",
"this",
")",
";",
"this",
".",
"_arguments",
"=",
"null",
";",
"}",
"}"
] | Handle life.
@param {gui.Life} life | [
"Handle",
"life",
"."
] | 5afcfe31ddbf7d654166aa15b938553b61de5811 | https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L4457-L4465 |
|
51,506 | wunderbyte/grunt-spiritual-dox | src/js/libs/spiritual-edb.js | function() {
edbml.$rendering = this._oldfokkers || {};
gui.Broadcast.add(edb.BROADCAST_ACCESS, this);
edb.$accessaware = true;
this._newfokkers = {};
} | javascript | function() {
edbml.$rendering = this._oldfokkers || {};
gui.Broadcast.add(edb.BROADCAST_ACCESS, this);
edb.$accessaware = true;
this._newfokkers = {};
} | [
"function",
"(",
")",
"{",
"edbml",
".",
"$rendering",
"=",
"this",
".",
"_oldfokkers",
"||",
"{",
"}",
";",
"gui",
".",
"Broadcast",
".",
"add",
"(",
"edb",
".",
"BROADCAST_ACCESS",
",",
"this",
")",
";",
"edb",
".",
"$accessaware",
"=",
"true",
";",
"this",
".",
"_newfokkers",
"=",
"{",
"}",
";",
"}"
] | Start it. | [
"Start",
"it",
"."
] | 5afcfe31ddbf7d654166aa15b938553b61de5811 | https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L4553-L4558 |
|
51,507 | wunderbyte/grunt-spiritual-dox | src/js/libs/spiritual-edb.js | function() {
var oldfokkers = this._oldfokkers,
newfokkers = this._newfokkers;
edbml.$rendering = null;
gui.Broadcast.remove(edb.BROADCAST_ACCESS, this);
edb.$accessaware = false;
Object.keys(oldfokkers).forEach(function(id) {
if (!newfokkers[id]) {
oldfokkers[id].object.removeObserver(this);
delete oldfokkers[id];
}
}, this);
Object.keys(newfokkers).forEach(function(id) {
var oldx = oldfokkers[id];
var newx = newfokkers[id];
if (oldx) {
if (newx.properties) {
oldx.properties = newx.properties;
}
} else {
oldfokkers[id] = newfokkers[id];
oldfokkers[id].object.addObserver(this);
delete newfokkers[id];
}
}, this);
this._newfokkers = null;
} | javascript | function() {
var oldfokkers = this._oldfokkers,
newfokkers = this._newfokkers;
edbml.$rendering = null;
gui.Broadcast.remove(edb.BROADCAST_ACCESS, this);
edb.$accessaware = false;
Object.keys(oldfokkers).forEach(function(id) {
if (!newfokkers[id]) {
oldfokkers[id].object.removeObserver(this);
delete oldfokkers[id];
}
}, this);
Object.keys(newfokkers).forEach(function(id) {
var oldx = oldfokkers[id];
var newx = newfokkers[id];
if (oldx) {
if (newx.properties) {
oldx.properties = newx.properties;
}
} else {
oldfokkers[id] = newfokkers[id];
oldfokkers[id].object.addObserver(this);
delete newfokkers[id];
}
}, this);
this._newfokkers = null;
} | [
"function",
"(",
")",
"{",
"var",
"oldfokkers",
"=",
"this",
".",
"_oldfokkers",
",",
"newfokkers",
"=",
"this",
".",
"_newfokkers",
";",
"edbml",
".",
"$rendering",
"=",
"null",
";",
"gui",
".",
"Broadcast",
".",
"remove",
"(",
"edb",
".",
"BROADCAST_ACCESS",
",",
"this",
")",
";",
"edb",
".",
"$accessaware",
"=",
"false",
";",
"Object",
".",
"keys",
"(",
"oldfokkers",
")",
".",
"forEach",
"(",
"function",
"(",
"id",
")",
"{",
"if",
"(",
"!",
"newfokkers",
"[",
"id",
"]",
")",
"{",
"oldfokkers",
"[",
"id",
"]",
".",
"object",
".",
"removeObserver",
"(",
"this",
")",
";",
"delete",
"oldfokkers",
"[",
"id",
"]",
";",
"}",
"}",
",",
"this",
")",
";",
"Object",
".",
"keys",
"(",
"newfokkers",
")",
".",
"forEach",
"(",
"function",
"(",
"id",
")",
"{",
"var",
"oldx",
"=",
"oldfokkers",
"[",
"id",
"]",
";",
"var",
"newx",
"=",
"newfokkers",
"[",
"id",
"]",
";",
"if",
"(",
"oldx",
")",
"{",
"if",
"(",
"newx",
".",
"properties",
")",
"{",
"oldx",
".",
"properties",
"=",
"newx",
".",
"properties",
";",
"}",
"}",
"else",
"{",
"oldfokkers",
"[",
"id",
"]",
"=",
"newfokkers",
"[",
"id",
"]",
";",
"oldfokkers",
"[",
"id",
"]",
".",
"object",
".",
"addObserver",
"(",
"this",
")",
";",
"delete",
"newfokkers",
"[",
"id",
"]",
";",
"}",
"}",
",",
"this",
")",
";",
"this",
".",
"_newfokkers",
"=",
"null",
";",
"}"
] | Stop it. | [
"Stop",
"it",
"."
] | 5afcfe31ddbf7d654166aa15b938553b61de5811 | https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L4563-L4589 |
|
51,508 | wunderbyte/grunt-spiritual-dox | src/js/libs/spiritual-edb.js | function() {
gui.Tick.cancelFrame(this._frameindex);
var spirit = this.spirit;
var input = this.$input;
var runnow = function() {
if (!spirit.life.destructed && (!input || input.done)) {
this.run();
}
}.bind(this);
if (spirit.life.entered) {
if (spirit.life.rendered) {
this._frameindex = gui.Tick.nextFrame(runnow);
} else {
runnow();
}
} else {
spirit.life.add(gui.LIFE_ENTER, this);
}
} | javascript | function() {
gui.Tick.cancelFrame(this._frameindex);
var spirit = this.spirit;
var input = this.$input;
var runnow = function() {
if (!spirit.life.destructed && (!input || input.done)) {
this.run();
}
}.bind(this);
if (spirit.life.entered) {
if (spirit.life.rendered) {
this._frameindex = gui.Tick.nextFrame(runnow);
} else {
runnow();
}
} else {
spirit.life.add(gui.LIFE_ENTER, this);
}
} | [
"function",
"(",
")",
"{",
"gui",
".",
"Tick",
".",
"cancelFrame",
"(",
"this",
".",
"_frameindex",
")",
";",
"var",
"spirit",
"=",
"this",
".",
"spirit",
";",
"var",
"input",
"=",
"this",
".",
"$input",
";",
"var",
"runnow",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"!",
"spirit",
".",
"life",
".",
"destructed",
"&&",
"(",
"!",
"input",
"||",
"input",
".",
"done",
")",
")",
"{",
"this",
".",
"run",
"(",
")",
";",
"}",
"}",
".",
"bind",
"(",
"this",
")",
";",
"if",
"(",
"spirit",
".",
"life",
".",
"entered",
")",
"{",
"if",
"(",
"spirit",
".",
"life",
".",
"rendered",
")",
"{",
"this",
".",
"_frameindex",
"=",
"gui",
".",
"Tick",
".",
"nextFrame",
"(",
"runnow",
")",
";",
"}",
"else",
"{",
"runnow",
"(",
")",
";",
"}",
"}",
"else",
"{",
"spirit",
".",
"life",
".",
"add",
"(",
"gui",
".",
"LIFE_ENTER",
",",
"this",
")",
";",
"}",
"}"
] | Schedule rendering. | [
"Schedule",
"rendering",
"."
] | 5afcfe31ddbf7d654166aa15b938553b61de5811 | https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L4594-L4612 |
|
51,509 | wunderbyte/grunt-spiritual-dox | src/js/libs/spiritual-edb.js | function(elm) {
var index = -1;
var parts = [];
function hasid(elm) {
if (elm.id) {
try {
gui.DOMPlugin.q(elm.parentNode, elm.id);
return true;
} catch (malformedexception) {}
}
return false;
}
while (elm && elm.nodeType === Node.ELEMENT_NODE) {
if (hasid(elm)) {
parts.push("#" + elm.id);
elm = null;
} else {
if (elm.localName === "body") {
parts.push("body");
elm = null;
} else {
index = gui.DOMPlugin.ordinal(elm) + 1;
parts.push(">" + elm.localName + ":nth-child(" + index + ")");
elm = elm.parentNode;
}
}
}
return parts.reverse().join("");
} | javascript | function(elm) {
var index = -1;
var parts = [];
function hasid(elm) {
if (elm.id) {
try {
gui.DOMPlugin.q(elm.parentNode, elm.id);
return true;
} catch (malformedexception) {}
}
return false;
}
while (elm && elm.nodeType === Node.ELEMENT_NODE) {
if (hasid(elm)) {
parts.push("#" + elm.id);
elm = null;
} else {
if (elm.localName === "body") {
parts.push("body");
elm = null;
} else {
index = gui.DOMPlugin.ordinal(elm) + 1;
parts.push(">" + elm.localName + ":nth-child(" + index + ")");
elm = elm.parentNode;
}
}
}
return parts.reverse().join("");
} | [
"function",
"(",
"elm",
")",
"{",
"var",
"index",
"=",
"-",
"1",
";",
"var",
"parts",
"=",
"[",
"]",
";",
"function",
"hasid",
"(",
"elm",
")",
"{",
"if",
"(",
"elm",
".",
"id",
")",
"{",
"try",
"{",
"gui",
".",
"DOMPlugin",
".",
"q",
"(",
"elm",
".",
"parentNode",
",",
"elm",
".",
"id",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"malformedexception",
")",
"{",
"}",
"}",
"return",
"false",
";",
"}",
"while",
"(",
"elm",
"&&",
"elm",
".",
"nodeType",
"===",
"Node",
".",
"ELEMENT_NODE",
")",
"{",
"if",
"(",
"hasid",
"(",
"elm",
")",
")",
"{",
"parts",
".",
"push",
"(",
"\"#\"",
"+",
"elm",
".",
"id",
")",
";",
"elm",
"=",
"null",
";",
"}",
"else",
"{",
"if",
"(",
"elm",
".",
"localName",
"===",
"\"body\"",
")",
"{",
"parts",
".",
"push",
"(",
"\"body\"",
")",
";",
"elm",
"=",
"null",
";",
"}",
"else",
"{",
"index",
"=",
"gui",
".",
"DOMPlugin",
".",
"ordinal",
"(",
"elm",
")",
"+",
"1",
";",
"parts",
".",
"push",
"(",
"\">\"",
"+",
"elm",
".",
"localName",
"+",
"\":nth-child(\"",
"+",
"index",
"+",
"\")\"",
")",
";",
"elm",
"=",
"elm",
".",
"parentNode",
";",
"}",
"}",
"}",
"return",
"parts",
".",
"reverse",
"(",
")",
".",
"join",
"(",
"\"\"",
")",
";",
"}"
] | Compute selector for form field. We scope it to
nearest element ID or fallback to document body.
@param {Element} element
@returns {string} | [
"Compute",
"selector",
"for",
"form",
"field",
".",
"We",
"scope",
"it",
"to",
"nearest",
"element",
"ID",
"or",
"fallback",
"to",
"document",
"body",
"."
] | 5afcfe31ddbf7d654166aa15b938553b61de5811 | https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L4691-L4719 |
|
51,510 | wunderbyte/grunt-spiritual-dox | src/js/libs/spiritual-edb.js | function(selector) {
var texts = 'textarea, input:not([type=checkbox]):not([type=radio])';
var field = gui.DOMPlugin.qdoc(selector);
if(field && field !== document.activeElement) {
field.focus();
if (gui.CSSPlugin.matches(field, texts)) {
field.setSelectionRange(
field.value.length,
field.value.length
);
}
}
} | javascript | function(selector) {
var texts = 'textarea, input:not([type=checkbox]):not([type=radio])';
var field = gui.DOMPlugin.qdoc(selector);
if(field && field !== document.activeElement) {
field.focus();
if (gui.CSSPlugin.matches(field, texts)) {
field.setSelectionRange(
field.value.length,
field.value.length
);
}
}
} | [
"function",
"(",
"selector",
")",
"{",
"var",
"texts",
"=",
"'textarea, input:not([type=checkbox]):not([type=radio])'",
";",
"var",
"field",
"=",
"gui",
".",
"DOMPlugin",
".",
"qdoc",
"(",
"selector",
")",
";",
"if",
"(",
"field",
"&&",
"field",
"!==",
"document",
".",
"activeElement",
")",
"{",
"field",
".",
"focus",
"(",
")",
";",
"if",
"(",
"gui",
".",
"CSSPlugin",
".",
"matches",
"(",
"field",
",",
"texts",
")",
")",
"{",
"field",
".",
"setSelectionRange",
"(",
"field",
".",
"value",
".",
"length",
",",
"field",
".",
"value",
".",
"length",
")",
";",
"}",
"}",
"}"
] | Refocus that form field.
@param {string} selector | [
"Refocus",
"that",
"form",
"field",
"."
] | 5afcfe31ddbf7d654166aa15b938553b61de5811 | https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L4725-L4737 |
|
51,511 | wunderbyte/grunt-spiritual-dox | src/js/libs/spiritual-edb.js | function() {
gui.Spirit.prototype.onconfigure.call(this);
if (this.dom.embedded()) {
var id, parent = this.dom.parent(gui.Spirit);
if (parent && (id = this.scriptid)) {
parent.script.load(gui.Object.lookup(id));
}
}
} | javascript | function() {
gui.Spirit.prototype.onconfigure.call(this);
if (this.dom.embedded()) {
var id, parent = this.dom.parent(gui.Spirit);
if (parent && (id = this.scriptid)) {
parent.script.load(gui.Object.lookup(id));
}
}
} | [
"function",
"(",
")",
"{",
"gui",
".",
"Spirit",
".",
"prototype",
".",
"onconfigure",
".",
"call",
"(",
"this",
")",
";",
"if",
"(",
"this",
".",
"dom",
".",
"embedded",
"(",
")",
")",
"{",
"var",
"id",
",",
"parent",
"=",
"this",
".",
"dom",
".",
"parent",
"(",
"gui",
".",
"Spirit",
")",
";",
"if",
"(",
"parent",
"&&",
"(",
"id",
"=",
"this",
".",
"scriptid",
")",
")",
"{",
"parent",
".",
"script",
".",
"load",
"(",
"gui",
".",
"Object",
".",
"lookup",
"(",
"id",
")",
")",
";",
"}",
"}",
"}"
] | Load script into parent spirit. This spirit will
automatically destruct when the script executes. | [
"Load",
"script",
"into",
"parent",
"spirit",
".",
"This",
"spirit",
"will",
"automatically",
"destruct",
"when",
"the",
"script",
"executes",
"."
] | 5afcfe31ddbf7d654166aa15b938553b61de5811 | https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L4761-L4769 |
|
51,512 | wunderbyte/grunt-spiritual-dox | src/js/libs/spiritual-edb.js | function() {
/*
* Automatically load spirit scripts by naming convention?
* ns.MySpirit would automatically load ns.MySpirit.edbml
*/
var edbmlscript, basespirit = gui.Spirit.prototype;
gui.Function.decorateAfter(basespirit, 'onconfigure', function() {
if (edbml.bootload && !this.script.loaded) {
edbmlscript = gui.Object.lookup(this.$classname + '.edbml');
if (gui.Type.isFunction(edbmlscript)) {
this.script.load(edbmlscript);
}
}
});
/*
* Nasty hack to circumvent that we hardcode "event" into inline poke
* events, this creates an undesired global variable, but fixes an
* exception in the console, at least I think this was the problem.
*/
if (!window.event) {
try {
window.event = null;
} catch (ieexception) {}
}
} | javascript | function() {
/*
* Automatically load spirit scripts by naming convention?
* ns.MySpirit would automatically load ns.MySpirit.edbml
*/
var edbmlscript, basespirit = gui.Spirit.prototype;
gui.Function.decorateAfter(basespirit, 'onconfigure', function() {
if (edbml.bootload && !this.script.loaded) {
edbmlscript = gui.Object.lookup(this.$classname + '.edbml');
if (gui.Type.isFunction(edbmlscript)) {
this.script.load(edbmlscript);
}
}
});
/*
* Nasty hack to circumvent that we hardcode "event" into inline poke
* events, this creates an undesired global variable, but fixes an
* exception in the console, at least I think this was the problem.
*/
if (!window.event) {
try {
window.event = null;
} catch (ieexception) {}
}
} | [
"function",
"(",
")",
"{",
"/*\n\t\t * Automatically load spirit scripts by naming convention?\n\t\t * ns.MySpirit would automatically load ns.MySpirit.edbml\n\t\t */",
"var",
"edbmlscript",
",",
"basespirit",
"=",
"gui",
".",
"Spirit",
".",
"prototype",
";",
"gui",
".",
"Function",
".",
"decorateAfter",
"(",
"basespirit",
",",
"'onconfigure'",
",",
"function",
"(",
")",
"{",
"if",
"(",
"edbml",
".",
"bootload",
"&&",
"!",
"this",
".",
"script",
".",
"loaded",
")",
"{",
"edbmlscript",
"=",
"gui",
".",
"Object",
".",
"lookup",
"(",
"this",
".",
"$classname",
"+",
"'.edbml'",
")",
";",
"if",
"(",
"gui",
".",
"Type",
".",
"isFunction",
"(",
"edbmlscript",
")",
")",
"{",
"this",
".",
"script",
".",
"load",
"(",
"edbmlscript",
")",
";",
"}",
"}",
"}",
")",
";",
"/*\n\t\t * Nasty hack to circumvent that we hardcode \"event\" into inline poke \n\t\t * events, this creates an undesired global variable, but fixes an \n\t\t * exception in the console, at least I think this was the problem.\n\t\t */",
"if",
"(",
"!",
"window",
".",
"event",
")",
"{",
"try",
"{",
"window",
".",
"event",
"=",
"null",
";",
"}",
"catch",
"(",
"ieexception",
")",
"{",
"}",
"}",
"}"
] | Setup environment. | [
"Setup",
"environment",
"."
] | 5afcfe31ddbf7d654166aa15b938553b61de5811 | https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L4851-L4877 |
|
51,513 | cafjs/caf_conduit | lib/conduit.js | function(node) {
var newNode = function(data, next) {
var that = {};
that.getData = function() {
return data;
};
that.getNext = function() {
return next;
};
return that;
};
var top = node || null;
var that = {};
that.__push_internal__ = function(data) {
return newStack(newNode(data, top));
};
that.__peek__ = function() {
return top && top.getData();
};
that.__pop_internal__ = function() {
return top && newStack(top.getNext());
};
that.__forEach__ = function(f) {
var i = top;
var s = 0;
while (i !== null) {
f(i.getData(), s);
s = s +1;
i = i.getNext();
}
};
that.__map__ = function(f) {
var i = top;
var result = [];
while (i !== null) {
result.push(f(i.getData()));
i = i.getNext();
}
return result;
};
that.__length__ = function() {
var count = 0;
that.__forEach__(function() { count = count + 1;});
return count;
};
return that;
} | javascript | function(node) {
var newNode = function(data, next) {
var that = {};
that.getData = function() {
return data;
};
that.getNext = function() {
return next;
};
return that;
};
var top = node || null;
var that = {};
that.__push_internal__ = function(data) {
return newStack(newNode(data, top));
};
that.__peek__ = function() {
return top && top.getData();
};
that.__pop_internal__ = function() {
return top && newStack(top.getNext());
};
that.__forEach__ = function(f) {
var i = top;
var s = 0;
while (i !== null) {
f(i.getData(), s);
s = s +1;
i = i.getNext();
}
};
that.__map__ = function(f) {
var i = top;
var result = [];
while (i !== null) {
result.push(f(i.getData()));
i = i.getNext();
}
return result;
};
that.__length__ = function() {
var count = 0;
that.__forEach__(function() { count = count + 1;});
return count;
};
return that;
} | [
"function",
"(",
"node",
")",
"{",
"var",
"newNode",
"=",
"function",
"(",
"data",
",",
"next",
")",
"{",
"var",
"that",
"=",
"{",
"}",
";",
"that",
".",
"getData",
"=",
"function",
"(",
")",
"{",
"return",
"data",
";",
"}",
";",
"that",
".",
"getNext",
"=",
"function",
"(",
")",
"{",
"return",
"next",
";",
"}",
";",
"return",
"that",
";",
"}",
";",
"var",
"top",
"=",
"node",
"||",
"null",
";",
"var",
"that",
"=",
"{",
"}",
";",
"that",
".",
"__push_internal__",
"=",
"function",
"(",
"data",
")",
"{",
"return",
"newStack",
"(",
"newNode",
"(",
"data",
",",
"top",
")",
")",
";",
"}",
";",
"that",
".",
"__peek__",
"=",
"function",
"(",
")",
"{",
"return",
"top",
"&&",
"top",
".",
"getData",
"(",
")",
";",
"}",
";",
"that",
".",
"__pop_internal__",
"=",
"function",
"(",
")",
"{",
"return",
"top",
"&&",
"newStack",
"(",
"top",
".",
"getNext",
"(",
")",
")",
";",
"}",
";",
"that",
".",
"__forEach__",
"=",
"function",
"(",
"f",
")",
"{",
"var",
"i",
"=",
"top",
";",
"var",
"s",
"=",
"0",
";",
"while",
"(",
"i",
"!==",
"null",
")",
"{",
"f",
"(",
"i",
".",
"getData",
"(",
")",
",",
"s",
")",
";",
"s",
"=",
"s",
"+",
"1",
";",
"i",
"=",
"i",
".",
"getNext",
"(",
")",
";",
"}",
"}",
";",
"that",
".",
"__map__",
"=",
"function",
"(",
"f",
")",
"{",
"var",
"i",
"=",
"top",
";",
"var",
"result",
"=",
"[",
"]",
";",
"while",
"(",
"i",
"!==",
"null",
")",
"{",
"result",
".",
"push",
"(",
"f",
"(",
"i",
".",
"getData",
"(",
")",
")",
")",
";",
"i",
"=",
"i",
".",
"getNext",
"(",
")",
";",
"}",
"return",
"result",
";",
"}",
";",
"that",
".",
"__length__",
"=",
"function",
"(",
")",
"{",
"var",
"count",
"=",
"0",
";",
"that",
".",
"__forEach__",
"(",
"function",
"(",
")",
"{",
"count",
"=",
"count",
"+",
"1",
";",
"}",
")",
";",
"return",
"count",
";",
"}",
";",
"return",
"that",
";",
"}"
] | An immutable stack as base class. | [
"An",
"immutable",
"stack",
"as",
"base",
"class",
"."
] | 72b4856dddfca76be7de605c1c60bcd1b8315996 | https://github.com/cafjs/caf_conduit/blob/72b4856dddfca76be7de605c1c60bcd1b8315996/lib/conduit.js#L134-L186 |
|
51,514 | redisjs/jsr-server | lib/command/database/hash/hscan.js | execute | function execute(req, res) {
//console.dir(req.args);
var hmap = req.db.getKey(req.args[0], req);
if(hmap === undefined) {
return res.send(null, [0, []]);
}
//console.dir(hmap.getKeys())
var scanner = new Scanner(
hmap.getKeys(),
req.info.cursor,
req.info.pattern,
req.info.count,
hmap.data);
scanner.scan(req, res);
} | javascript | function execute(req, res) {
//console.dir(req.args);
var hmap = req.db.getKey(req.args[0], req);
if(hmap === undefined) {
return res.send(null, [0, []]);
}
//console.dir(hmap.getKeys())
var scanner = new Scanner(
hmap.getKeys(),
req.info.cursor,
req.info.pattern,
req.info.count,
hmap.data);
scanner.scan(req, res);
} | [
"function",
"execute",
"(",
"req",
",",
"res",
")",
"{",
"//console.dir(req.args);",
"var",
"hmap",
"=",
"req",
".",
"db",
".",
"getKey",
"(",
"req",
".",
"args",
"[",
"0",
"]",
",",
"req",
")",
";",
"if",
"(",
"hmap",
"===",
"undefined",
")",
"{",
"return",
"res",
".",
"send",
"(",
"null",
",",
"[",
"0",
",",
"[",
"]",
"]",
")",
";",
"}",
"//console.dir(hmap.getKeys())",
"var",
"scanner",
"=",
"new",
"Scanner",
"(",
"hmap",
".",
"getKeys",
"(",
")",
",",
"req",
".",
"info",
".",
"cursor",
",",
"req",
".",
"info",
".",
"pattern",
",",
"req",
".",
"info",
".",
"count",
",",
"hmap",
".",
"data",
")",
";",
"scanner",
".",
"scan",
"(",
"req",
",",
"res",
")",
";",
"}"
] | Respond to the HSCAN command. | [
"Respond",
"to",
"the",
"HSCAN",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/database/hash/hscan.js#L19-L34 |
51,515 | hbouvier/node-tagger | lib/util/rest.js | lexPhrase | function lexPhrase(req, res) {
var now = elapse.start();
var body = req ? req.body : null;
var phrase = typeof(body) === 'object' ? body.phrase : null;
if (!phrase) {
return res.jsonp(412, {"code":412, "message": meta.module + '|lex|EXCEPTION|invalid request body: ' + (body === null ? 'body is null' : 'phrase is null')});
}
body.words = api.lex(phrase);
body.elapsedMs = elapse.stop(now).elapsed;
res.jsonp(body);
} | javascript | function lexPhrase(req, res) {
var now = elapse.start();
var body = req ? req.body : null;
var phrase = typeof(body) === 'object' ? body.phrase : null;
if (!phrase) {
return res.jsonp(412, {"code":412, "message": meta.module + '|lex|EXCEPTION|invalid request body: ' + (body === null ? 'body is null' : 'phrase is null')});
}
body.words = api.lex(phrase);
body.elapsedMs = elapse.stop(now).elapsed;
res.jsonp(body);
} | [
"function",
"lexPhrase",
"(",
"req",
",",
"res",
")",
"{",
"var",
"now",
"=",
"elapse",
".",
"start",
"(",
")",
";",
"var",
"body",
"=",
"req",
"?",
"req",
".",
"body",
":",
"null",
";",
"var",
"phrase",
"=",
"typeof",
"(",
"body",
")",
"===",
"'object'",
"?",
"body",
".",
"phrase",
":",
"null",
";",
"if",
"(",
"!",
"phrase",
")",
"{",
"return",
"res",
".",
"jsonp",
"(",
"412",
",",
"{",
"\"code\"",
":",
"412",
",",
"\"message\"",
":",
"meta",
".",
"module",
"+",
"'|lex|EXCEPTION|invalid request body: '",
"+",
"(",
"body",
"===",
"null",
"?",
"'body is null'",
":",
"'phrase is null'",
")",
"}",
")",
";",
"}",
"body",
".",
"words",
"=",
"api",
".",
"lex",
"(",
"phrase",
")",
";",
"body",
".",
"elapsedMs",
"=",
"elapse",
".",
"stop",
"(",
"now",
")",
".",
"elapsed",
";",
"res",
".",
"jsonp",
"(",
"body",
")",
";",
"}"
] | HTTP Request to lex a phrase
@param req: an HTTP request
@param res: an HTTP response
curl -X POST -H "Content-Type: application/json" -d '{"phrase":"bye there"}' http://tagger.beeker.c9.io/ws/lex/phrase | [
"HTTP",
"Request",
"to",
"lex",
"a",
"phrase"
] | 51a6a9b6158e83cbbc4d3d4f10fde19ac796510b | https://github.com/hbouvier/node-tagger/blob/51a6a9b6158e83cbbc4d3d4f10fde19ac796510b/lib/util/rest.js#L27-L37 |
51,516 | eliascodes/modload | lib/tree.js | walk | function walk (dir, mapper, exclude, include, stopfile) {
let files = fs.readdirSync(dir).map((file) => path.join(dir, file))
if (exclude)
files = files.filter((file) => !exclude.test(file))
let directories = files.filter(utils.is.dir)
files = files.filter(utils.is.file)
if (include)
files = files.filter((file) => include.test(file))
if (stopfile) {
for (let ii = 0; ii < files.length; ii++) {
if (stopfile.test(files[ii]))
return mapper ? mapper(files[ii]) : [files[ii]]
}
}
if (mapper)
files = files.map(mapper)
for (let jj = 0; jj < directories.length; jj++) {
let result = walk(directories[jj], mapper, exclude, include, stopfile)
files = files.concat(result)
}
return files
} | javascript | function walk (dir, mapper, exclude, include, stopfile) {
let files = fs.readdirSync(dir).map((file) => path.join(dir, file))
if (exclude)
files = files.filter((file) => !exclude.test(file))
let directories = files.filter(utils.is.dir)
files = files.filter(utils.is.file)
if (include)
files = files.filter((file) => include.test(file))
if (stopfile) {
for (let ii = 0; ii < files.length; ii++) {
if (stopfile.test(files[ii]))
return mapper ? mapper(files[ii]) : [files[ii]]
}
}
if (mapper)
files = files.map(mapper)
for (let jj = 0; jj < directories.length; jj++) {
let result = walk(directories[jj], mapper, exclude, include, stopfile)
files = files.concat(result)
}
return files
} | [
"function",
"walk",
"(",
"dir",
",",
"mapper",
",",
"exclude",
",",
"include",
",",
"stopfile",
")",
"{",
"let",
"files",
"=",
"fs",
".",
"readdirSync",
"(",
"dir",
")",
".",
"map",
"(",
"(",
"file",
")",
"=>",
"path",
".",
"join",
"(",
"dir",
",",
"file",
")",
")",
"if",
"(",
"exclude",
")",
"files",
"=",
"files",
".",
"filter",
"(",
"(",
"file",
")",
"=>",
"!",
"exclude",
".",
"test",
"(",
"file",
")",
")",
"let",
"directories",
"=",
"files",
".",
"filter",
"(",
"utils",
".",
"is",
".",
"dir",
")",
"files",
"=",
"files",
".",
"filter",
"(",
"utils",
".",
"is",
".",
"file",
")",
"if",
"(",
"include",
")",
"files",
"=",
"files",
".",
"filter",
"(",
"(",
"file",
")",
"=>",
"include",
".",
"test",
"(",
"file",
")",
")",
"if",
"(",
"stopfile",
")",
"{",
"for",
"(",
"let",
"ii",
"=",
"0",
";",
"ii",
"<",
"files",
".",
"length",
";",
"ii",
"++",
")",
"{",
"if",
"(",
"stopfile",
".",
"test",
"(",
"files",
"[",
"ii",
"]",
")",
")",
"return",
"mapper",
"?",
"mapper",
"(",
"files",
"[",
"ii",
"]",
")",
":",
"[",
"files",
"[",
"ii",
"]",
"]",
"}",
"}",
"if",
"(",
"mapper",
")",
"files",
"=",
"files",
".",
"map",
"(",
"mapper",
")",
"for",
"(",
"let",
"jj",
"=",
"0",
";",
"jj",
"<",
"directories",
".",
"length",
";",
"jj",
"++",
")",
"{",
"let",
"result",
"=",
"walk",
"(",
"directories",
"[",
"jj",
"]",
",",
"mapper",
",",
"exclude",
",",
"include",
",",
"stopfile",
")",
"files",
"=",
"files",
".",
"concat",
"(",
"result",
")",
"}",
"return",
"files",
"}"
] | Recursively walk a directory and return array of files
@returns {array} of files found in the directory
@param {string} dir - Root directory to traverse
@param {function} mapper - (Optional) Transforms each filepath
@param {RegExp} exclude - (Optional) Pattern for files to exclude from results
@param {RegExp} include - (Optional) Pattern for files to include in results
@param {RegExp} stopfile - (Optional) Pattern for file at which to terminate recursion | [
"Recursively",
"walk",
"a",
"directory",
"and",
"return",
"array",
"of",
"files"
] | bc3bad88c8b677970bb9154764db7bbf72401d3a | https://github.com/eliascodes/modload/blob/bc3bad88c8b677970bb9154764db7bbf72401d3a/lib/tree.js#L19-L47 |
51,517 | jmarthernandez/chat-parser | src/emoticons.js | getEmoticons | function getEmoticons(arr) {
var nested = arr.map(function (str) {
return str.match(between);
});
return flatten(nested)
.filter(function (el) {
return el;
})
.filter(emoticonsPredicate)
.map(function (str) {
return str.slice(1, str.length - 1);
});
} | javascript | function getEmoticons(arr) {
var nested = arr.map(function (str) {
return str.match(between);
});
return flatten(nested)
.filter(function (el) {
return el;
})
.filter(emoticonsPredicate)
.map(function (str) {
return str.slice(1, str.length - 1);
});
} | [
"function",
"getEmoticons",
"(",
"arr",
")",
"{",
"var",
"nested",
"=",
"arr",
".",
"map",
"(",
"function",
"(",
"str",
")",
"{",
"return",
"str",
".",
"match",
"(",
"between",
")",
";",
"}",
")",
";",
"return",
"flatten",
"(",
"nested",
")",
".",
"filter",
"(",
"function",
"(",
"el",
")",
"{",
"return",
"el",
";",
"}",
")",
".",
"filter",
"(",
"emoticonsPredicate",
")",
".",
"map",
"(",
"function",
"(",
"str",
")",
"{",
"return",
"str",
".",
"slice",
"(",
"1",
",",
"str",
".",
"length",
"-",
"1",
")",
";",
"}",
")",
";",
"}"
] | Parses tokenized array into emoticon strings
@func
@param {array} arr - a chat input string split on whitespace | [
"Parses",
"tokenized",
"array",
"into",
"emoticon",
"strings"
] | 62e7e28cca35318158e4a807b30dd8d5d88718ac | https://github.com/jmarthernandez/chat-parser/blob/62e7e28cca35318158e4a807b30dd8d5d88718ac/src/emoticons.js#L31-L44 |
51,518 | kevoree/kevoree-js-node-javascript | lib/AdaptationEngine.js | function (diffSeq, targetModel) {
var self = this;
this.targetModel = targetModel;
// know if a trace has already been added to cmdList for {path <-> AdaptationPrimitive}
var traceAlreadyProcessed = function (cmd) {
return self.alreadyProcessedTraces[cmd.modelElement.path()] && self.alreadyProcessedTraces[cmd.modelElement.path()][cmd.toString()];
};
// add a trace to the processed trace map
var addProcessedTrace = function (cmd) {
self.alreadyProcessedTraces[cmd.modelElement.path()] = self.alreadyProcessedTraces[cmd.modelElement.path()] || {};
self.alreadyProcessedTraces[cmd.modelElement.path()][cmd.toString()] = cmd;
};
// fill adaptation primitives list
var cmdList = [];
diffSeq.traces.array.forEach(function (trace) {
self.processTrace(trace).forEach(function (cmd) {
if (!traceAlreadyProcessed(cmd)) {
cmdList.push(cmd);
addProcessedTrace(cmd);
}
});
});
// clean primitives:
// - don't call UpdateInstance when (Start|Stop)Instance will be executed
for (var path in this.alreadyProcessedTraces) {
if (this.alreadyProcessedTraces[path][UpdateInstance.prototype.toString()]) {
for (var type in this.alreadyProcessedTraces[path]) {
if (type === StopInstance.prototype.toString() || type === StartInstance.prototype.toString()) {
var index = cmdList.indexOf(this.alreadyProcessedTraces[path][UpdateInstance.prototype.toString()]);
if (index > -1) {
cmdList.splice(index, 1);
}
}
}
}
}
// free-up some mem
this.targetModel = null;
this.alreadyProcessedTraces = {};
//return sorted command list (sort by COMMAND_RANK in order to process adaptations properly)
// this.sortCommands(cmdList).forEach(function (cmd) {
// var tag = cmd.toString();
// while (tag.length < 20) {
// tag += ' ';
// }
// console.log(tag, cmd.modelElement.path());
// });
return this.sortCommands(cmdList);
} | javascript | function (diffSeq, targetModel) {
var self = this;
this.targetModel = targetModel;
// know if a trace has already been added to cmdList for {path <-> AdaptationPrimitive}
var traceAlreadyProcessed = function (cmd) {
return self.alreadyProcessedTraces[cmd.modelElement.path()] && self.alreadyProcessedTraces[cmd.modelElement.path()][cmd.toString()];
};
// add a trace to the processed trace map
var addProcessedTrace = function (cmd) {
self.alreadyProcessedTraces[cmd.modelElement.path()] = self.alreadyProcessedTraces[cmd.modelElement.path()] || {};
self.alreadyProcessedTraces[cmd.modelElement.path()][cmd.toString()] = cmd;
};
// fill adaptation primitives list
var cmdList = [];
diffSeq.traces.array.forEach(function (trace) {
self.processTrace(trace).forEach(function (cmd) {
if (!traceAlreadyProcessed(cmd)) {
cmdList.push(cmd);
addProcessedTrace(cmd);
}
});
});
// clean primitives:
// - don't call UpdateInstance when (Start|Stop)Instance will be executed
for (var path in this.alreadyProcessedTraces) {
if (this.alreadyProcessedTraces[path][UpdateInstance.prototype.toString()]) {
for (var type in this.alreadyProcessedTraces[path]) {
if (type === StopInstance.prototype.toString() || type === StartInstance.prototype.toString()) {
var index = cmdList.indexOf(this.alreadyProcessedTraces[path][UpdateInstance.prototype.toString()]);
if (index > -1) {
cmdList.splice(index, 1);
}
}
}
}
}
// free-up some mem
this.targetModel = null;
this.alreadyProcessedTraces = {};
//return sorted command list (sort by COMMAND_RANK in order to process adaptations properly)
// this.sortCommands(cmdList).forEach(function (cmd) {
// var tag = cmd.toString();
// while (tag.length < 20) {
// tag += ' ';
// }
// console.log(tag, cmd.modelElement.path());
// });
return this.sortCommands(cmdList);
} | [
"function",
"(",
"diffSeq",
",",
"targetModel",
")",
"{",
"var",
"self",
"=",
"this",
";",
"this",
".",
"targetModel",
"=",
"targetModel",
";",
"// know if a trace has already been added to cmdList for {path <-> AdaptationPrimitive}",
"var",
"traceAlreadyProcessed",
"=",
"function",
"(",
"cmd",
")",
"{",
"return",
"self",
".",
"alreadyProcessedTraces",
"[",
"cmd",
".",
"modelElement",
".",
"path",
"(",
")",
"]",
"&&",
"self",
".",
"alreadyProcessedTraces",
"[",
"cmd",
".",
"modelElement",
".",
"path",
"(",
")",
"]",
"[",
"cmd",
".",
"toString",
"(",
")",
"]",
";",
"}",
";",
"// add a trace to the processed trace map",
"var",
"addProcessedTrace",
"=",
"function",
"(",
"cmd",
")",
"{",
"self",
".",
"alreadyProcessedTraces",
"[",
"cmd",
".",
"modelElement",
".",
"path",
"(",
")",
"]",
"=",
"self",
".",
"alreadyProcessedTraces",
"[",
"cmd",
".",
"modelElement",
".",
"path",
"(",
")",
"]",
"||",
"{",
"}",
";",
"self",
".",
"alreadyProcessedTraces",
"[",
"cmd",
".",
"modelElement",
".",
"path",
"(",
")",
"]",
"[",
"cmd",
".",
"toString",
"(",
")",
"]",
"=",
"cmd",
";",
"}",
";",
"// fill adaptation primitives list",
"var",
"cmdList",
"=",
"[",
"]",
";",
"diffSeq",
".",
"traces",
".",
"array",
".",
"forEach",
"(",
"function",
"(",
"trace",
")",
"{",
"self",
".",
"processTrace",
"(",
"trace",
")",
".",
"forEach",
"(",
"function",
"(",
"cmd",
")",
"{",
"if",
"(",
"!",
"traceAlreadyProcessed",
"(",
"cmd",
")",
")",
"{",
"cmdList",
".",
"push",
"(",
"cmd",
")",
";",
"addProcessedTrace",
"(",
"cmd",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"// clean primitives:",
"// - don't call UpdateInstance when (Start|Stop)Instance will be executed",
"for",
"(",
"var",
"path",
"in",
"this",
".",
"alreadyProcessedTraces",
")",
"{",
"if",
"(",
"this",
".",
"alreadyProcessedTraces",
"[",
"path",
"]",
"[",
"UpdateInstance",
".",
"prototype",
".",
"toString",
"(",
")",
"]",
")",
"{",
"for",
"(",
"var",
"type",
"in",
"this",
".",
"alreadyProcessedTraces",
"[",
"path",
"]",
")",
"{",
"if",
"(",
"type",
"===",
"StopInstance",
".",
"prototype",
".",
"toString",
"(",
")",
"||",
"type",
"===",
"StartInstance",
".",
"prototype",
".",
"toString",
"(",
")",
")",
"{",
"var",
"index",
"=",
"cmdList",
".",
"indexOf",
"(",
"this",
".",
"alreadyProcessedTraces",
"[",
"path",
"]",
"[",
"UpdateInstance",
".",
"prototype",
".",
"toString",
"(",
")",
"]",
")",
";",
"if",
"(",
"index",
">",
"-",
"1",
")",
"{",
"cmdList",
".",
"splice",
"(",
"index",
",",
"1",
")",
";",
"}",
"}",
"}",
"}",
"}",
"// free-up some mem",
"this",
".",
"targetModel",
"=",
"null",
";",
"this",
".",
"alreadyProcessedTraces",
"=",
"{",
"}",
";",
"//return sorted command list (sort by COMMAND_RANK in order to process adaptations properly)",
"// this.sortCommands(cmdList).forEach(function (cmd) {",
"// var tag = cmd.toString();",
"// while (tag.length < 20) {",
"// tag += ' ';",
"// }",
"// console.log(tag, cmd.modelElement.path());",
"// });",
"return",
"this",
".",
"sortCommands",
"(",
"cmdList",
")",
";",
"}"
] | Process traces to find the right adaptation primitive command
Returns a command to execute in order to do the adaptation logic
@param diffSeq
@param targetModel
@returns {Array} | [
"Process",
"traces",
"to",
"find",
"the",
"right",
"adaptation",
"primitive",
"command",
"Returns",
"a",
"command",
"to",
"execute",
"in",
"order",
"to",
"do",
"the",
"adaptation",
"logic"
] | a1bcce1b76317bc90eb2d0c1c0c70525eaa1d70d | https://github.com/kevoree/kevoree-js-node-javascript/blob/a1bcce1b76317bc90eb2d0c1c0c70525eaa1d70d/lib/AdaptationEngine.js#L78-L132 |
|
51,519 | kevoree/kevoree-js-node-javascript | lib/AdaptationEngine.js | function (cmd) {
self.alreadyProcessedTraces[cmd.modelElement.path()] = self.alreadyProcessedTraces[cmd.modelElement.path()] || {};
self.alreadyProcessedTraces[cmd.modelElement.path()][cmd.toString()] = cmd;
} | javascript | function (cmd) {
self.alreadyProcessedTraces[cmd.modelElement.path()] = self.alreadyProcessedTraces[cmd.modelElement.path()] || {};
self.alreadyProcessedTraces[cmd.modelElement.path()][cmd.toString()] = cmd;
} | [
"function",
"(",
"cmd",
")",
"{",
"self",
".",
"alreadyProcessedTraces",
"[",
"cmd",
".",
"modelElement",
".",
"path",
"(",
")",
"]",
"=",
"self",
".",
"alreadyProcessedTraces",
"[",
"cmd",
".",
"modelElement",
".",
"path",
"(",
")",
"]",
"||",
"{",
"}",
";",
"self",
".",
"alreadyProcessedTraces",
"[",
"cmd",
".",
"modelElement",
".",
"path",
"(",
")",
"]",
"[",
"cmd",
".",
"toString",
"(",
")",
"]",
"=",
"cmd",
";",
"}"
] | add a trace to the processed trace map | [
"add",
"a",
"trace",
"to",
"the",
"processed",
"trace",
"map"
] | a1bcce1b76317bc90eb2d0c1c0c70525eaa1d70d | https://github.com/kevoree/kevoree-js-node-javascript/blob/a1bcce1b76317bc90eb2d0c1c0c70525eaa1d70d/lib/AdaptationEngine.js#L88-L91 |
|
51,520 | kevoree/kevoree-js-node-javascript | lib/AdaptationEngine.js | function (element) {
if (element) {
if (element.metaClassName() === 'org.kevoree.ComponentInstance') {
// if parent is this node platform: it's ok
return (element.eContainer().name === this.node.getName());
} else if (element.metaClassName() === 'org.kevoree.Channel') {
// if this channel has bindings with components hosted in this node platform: it's ok
var bindings = element.bindings.iterator();
while (bindings.hasNext()) {
var binding = bindings.next();
if (binding.port && binding.port.eContainer()) {
if (this.isRelatedToPlatform(binding.port.eContainer())) {
return true;
}
}
}
} else if (element.metaClassName() === 'org.kevoree.Group') {
return element.subNodes.array.some(function (node) {
return this.isRelatedToPlatform(node);
}.bind(this));
} else if (element.metaClassName() === 'org.kevoree.ContainerNode') {
return ((element.name === this.node.getName()) || (element.host && element.host.name === this.node.getName()));
} else if (element.metaClassName() === 'org.kevoree.MBinding') {
if (element.port && element.port.eContainer()) {
if (this.isRelatedToPlatform(element.port.eContainer())) {
return true;
}
}
if (element.hub) {
return this.isRelatedToPlatform(element.hub);
}
} else if (element.metaClassName() === 'org.kevoree.Value') {
if (element.eContainer().metaClassName() === 'org.kevoree.FragmentDictionary') {
return (element.eContainer().name === this.node.getName());
} else {
return this.isRelatedToPlatform(element.eContainer().eContainer());
}
} else if (element.metaClassName() === 'org.kevoree.Port') {
return this.isRelatedToPlatform(element.eContainer());
}
}
return false;
} | javascript | function (element) {
if (element) {
if (element.metaClassName() === 'org.kevoree.ComponentInstance') {
// if parent is this node platform: it's ok
return (element.eContainer().name === this.node.getName());
} else if (element.metaClassName() === 'org.kevoree.Channel') {
// if this channel has bindings with components hosted in this node platform: it's ok
var bindings = element.bindings.iterator();
while (bindings.hasNext()) {
var binding = bindings.next();
if (binding.port && binding.port.eContainer()) {
if (this.isRelatedToPlatform(binding.port.eContainer())) {
return true;
}
}
}
} else if (element.metaClassName() === 'org.kevoree.Group') {
return element.subNodes.array.some(function (node) {
return this.isRelatedToPlatform(node);
}.bind(this));
} else if (element.metaClassName() === 'org.kevoree.ContainerNode') {
return ((element.name === this.node.getName()) || (element.host && element.host.name === this.node.getName()));
} else if (element.metaClassName() === 'org.kevoree.MBinding') {
if (element.port && element.port.eContainer()) {
if (this.isRelatedToPlatform(element.port.eContainer())) {
return true;
}
}
if (element.hub) {
return this.isRelatedToPlatform(element.hub);
}
} else if (element.metaClassName() === 'org.kevoree.Value') {
if (element.eContainer().metaClassName() === 'org.kevoree.FragmentDictionary') {
return (element.eContainer().name === this.node.getName());
} else {
return this.isRelatedToPlatform(element.eContainer().eContainer());
}
} else if (element.metaClassName() === 'org.kevoree.Port') {
return this.isRelatedToPlatform(element.eContainer());
}
}
return false;
} | [
"function",
"(",
"element",
")",
"{",
"if",
"(",
"element",
")",
"{",
"if",
"(",
"element",
".",
"metaClassName",
"(",
")",
"===",
"'org.kevoree.ComponentInstance'",
")",
"{",
"// if parent is this node platform: it's ok",
"return",
"(",
"element",
".",
"eContainer",
"(",
")",
".",
"name",
"===",
"this",
".",
"node",
".",
"getName",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"element",
".",
"metaClassName",
"(",
")",
"===",
"'org.kevoree.Channel'",
")",
"{",
"// if this channel has bindings with components hosted in this node platform: it's ok",
"var",
"bindings",
"=",
"element",
".",
"bindings",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"bindings",
".",
"hasNext",
"(",
")",
")",
"{",
"var",
"binding",
"=",
"bindings",
".",
"next",
"(",
")",
";",
"if",
"(",
"binding",
".",
"port",
"&&",
"binding",
".",
"port",
".",
"eContainer",
"(",
")",
")",
"{",
"if",
"(",
"this",
".",
"isRelatedToPlatform",
"(",
"binding",
".",
"port",
".",
"eContainer",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"}",
"else",
"if",
"(",
"element",
".",
"metaClassName",
"(",
")",
"===",
"'org.kevoree.Group'",
")",
"{",
"return",
"element",
".",
"subNodes",
".",
"array",
".",
"some",
"(",
"function",
"(",
"node",
")",
"{",
"return",
"this",
".",
"isRelatedToPlatform",
"(",
"node",
")",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"}",
"else",
"if",
"(",
"element",
".",
"metaClassName",
"(",
")",
"===",
"'org.kevoree.ContainerNode'",
")",
"{",
"return",
"(",
"(",
"element",
".",
"name",
"===",
"this",
".",
"node",
".",
"getName",
"(",
")",
")",
"||",
"(",
"element",
".",
"host",
"&&",
"element",
".",
"host",
".",
"name",
"===",
"this",
".",
"node",
".",
"getName",
"(",
")",
")",
")",
";",
"}",
"else",
"if",
"(",
"element",
".",
"metaClassName",
"(",
")",
"===",
"'org.kevoree.MBinding'",
")",
"{",
"if",
"(",
"element",
".",
"port",
"&&",
"element",
".",
"port",
".",
"eContainer",
"(",
")",
")",
"{",
"if",
"(",
"this",
".",
"isRelatedToPlatform",
"(",
"element",
".",
"port",
".",
"eContainer",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"if",
"(",
"element",
".",
"hub",
")",
"{",
"return",
"this",
".",
"isRelatedToPlatform",
"(",
"element",
".",
"hub",
")",
";",
"}",
"}",
"else",
"if",
"(",
"element",
".",
"metaClassName",
"(",
")",
"===",
"'org.kevoree.Value'",
")",
"{",
"if",
"(",
"element",
".",
"eContainer",
"(",
")",
".",
"metaClassName",
"(",
")",
"===",
"'org.kevoree.FragmentDictionary'",
")",
"{",
"return",
"(",
"element",
".",
"eContainer",
"(",
")",
".",
"name",
"===",
"this",
".",
"node",
".",
"getName",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"this",
".",
"isRelatedToPlatform",
"(",
"element",
".",
"eContainer",
"(",
")",
".",
"eContainer",
"(",
")",
")",
";",
"}",
"}",
"else",
"if",
"(",
"element",
".",
"metaClassName",
"(",
")",
"===",
"'org.kevoree.Port'",
")",
"{",
"return",
"this",
".",
"isRelatedToPlatform",
"(",
"element",
".",
"eContainer",
"(",
")",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | know if an modelElement is related to the current plarform node
@param element
@returns {boolean} | [
"know",
"if",
"an",
"modelElement",
"is",
"related",
"to",
"the",
"current",
"plarform",
"node"
] | a1bcce1b76317bc90eb2d0c1c0c70525eaa1d70d | https://github.com/kevoree/kevoree-js-node-javascript/blob/a1bcce1b76317bc90eb2d0c1c0c70525eaa1d70d/lib/AdaptationEngine.js#L476-L524 |
|
51,521 | kevoree/kevoree-js-node-javascript | lib/AdaptationEngine.js | function (list) {
list.sort(function (a, b) {
if (COMMAND_RANK[a.toString()] > COMMAND_RANK[b.toString()]) {
return 1;
} else if (COMMAND_RANK[a.toString()] < COMMAND_RANK[b.toString()]) {
return -1;
} else {
return 0;
}
});
return list;
} | javascript | function (list) {
list.sort(function (a, b) {
if (COMMAND_RANK[a.toString()] > COMMAND_RANK[b.toString()]) {
return 1;
} else if (COMMAND_RANK[a.toString()] < COMMAND_RANK[b.toString()]) {
return -1;
} else {
return 0;
}
});
return list;
} | [
"function",
"(",
"list",
")",
"{",
"list",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"COMMAND_RANK",
"[",
"a",
".",
"toString",
"(",
")",
"]",
">",
"COMMAND_RANK",
"[",
"b",
".",
"toString",
"(",
")",
"]",
")",
"{",
"return",
"1",
";",
"}",
"else",
"if",
"(",
"COMMAND_RANK",
"[",
"a",
".",
"toString",
"(",
")",
"]",
"<",
"COMMAND_RANK",
"[",
"b",
".",
"toString",
"(",
")",
"]",
")",
"{",
"return",
"-",
"1",
";",
"}",
"else",
"{",
"return",
"0",
";",
"}",
"}",
")",
";",
"return",
"list",
";",
"}"
] | Sorts primitives array according to COMMAND_RANK
@param list
@returns {*} | [
"Sorts",
"primitives",
"array",
"according",
"to",
"COMMAND_RANK"
] | a1bcce1b76317bc90eb2d0c1c0c70525eaa1d70d | https://github.com/kevoree/kevoree-js-node-javascript/blob/a1bcce1b76317bc90eb2d0c1c0c70525eaa1d70d/lib/AdaptationEngine.js#L599-L611 |
|
51,522 | redisjs/jsr-store | lib/command/keys.js | del | function del(/* key-1, key-N, req */) {
var args = slice.call(arguments, 0)
, req = typeof args[args.length-1] === 'object' ? args.pop() : null;
var deleted = 0;
for(var i = 0;i < args.length;i++) {
if(this.keyExists(args[i])) {
this.delKey(args[i], req);
deleted++;
}
}
return deleted;
} | javascript | function del(/* key-1, key-N, req */) {
var args = slice.call(arguments, 0)
, req = typeof args[args.length-1] === 'object' ? args.pop() : null;
var deleted = 0;
for(var i = 0;i < args.length;i++) {
if(this.keyExists(args[i])) {
this.delKey(args[i], req);
deleted++;
}
}
return deleted;
} | [
"function",
"del",
"(",
"/* key-1, key-N, req */",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"0",
")",
",",
"req",
"=",
"typeof",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
"===",
"'object'",
"?",
"args",
".",
"pop",
"(",
")",
":",
"null",
";",
"var",
"deleted",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"args",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"this",
".",
"keyExists",
"(",
"args",
"[",
"i",
"]",
")",
")",
"{",
"this",
".",
"delKey",
"(",
"args",
"[",
"i",
"]",
",",
"req",
")",
";",
"deleted",
"++",
";",
"}",
"}",
"return",
"deleted",
";",
"}"
] | Removes the specified keys. A key is ignored if it does not exist. | [
"Removes",
"the",
"specified",
"keys",
".",
"A",
"key",
"is",
"ignored",
"if",
"it",
"does",
"not",
"exist",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/keys.js#L9-L20 |
51,523 | redisjs/jsr-store | lib/command/keys.js | rename | function rename(key, newkey, req) {
var val = this.getKey(key);
this.delKey(key);
this.setKey(newkey, val);
return OK;
} | javascript | function rename(key, newkey, req) {
var val = this.getKey(key);
this.delKey(key);
this.setKey(newkey, val);
return OK;
} | [
"function",
"rename",
"(",
"key",
",",
"newkey",
",",
"req",
")",
"{",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
")",
";",
"this",
".",
"delKey",
"(",
"key",
")",
";",
"this",
".",
"setKey",
"(",
"newkey",
",",
"val",
")",
";",
"return",
"OK",
";",
"}"
] | Rename a key.
Expected that command validation has already check that the key names
do not match and that the target key does exist. | [
"Rename",
"a",
"key",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/keys.js#L28-L33 |
51,524 | redisjs/jsr-store | lib/command/keys.js | renamenx | function renamenx(key, newkey, req) {
var exists = this.keyExists(newkey);
if(!exists) {
this.rename(key, newkey, req);
}
return exists ? 0 : 1;
} | javascript | function renamenx(key, newkey, req) {
var exists = this.keyExists(newkey);
if(!exists) {
this.rename(key, newkey, req);
}
return exists ? 0 : 1;
} | [
"function",
"renamenx",
"(",
"key",
",",
"newkey",
",",
"req",
")",
"{",
"var",
"exists",
"=",
"this",
".",
"keyExists",
"(",
"newkey",
")",
";",
"if",
"(",
"!",
"exists",
")",
"{",
"this",
".",
"rename",
"(",
"key",
",",
"newkey",
",",
"req",
")",
";",
"}",
"return",
"exists",
"?",
"0",
":",
"1",
";",
"}"
] | Rename a key, only if the new key does not exist.
Expected that the command has validated according the rules for
RENAME. | [
"Rename",
"a",
"key",
"only",
"if",
"the",
"new",
"key",
"does",
"not",
"exist",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/keys.js#L41-L47 |
51,525 | redisjs/jsr-store | lib/command/keys.js | move | function move(key, index, req) {
var val = this.getKey(key)
, db = this.store.getDatabase(index, this.options);
//console.dir(val);
if(!val || db.keyExists(key)) return 0;
db.setKey(key, val);
this.delKey(key);
return 1;
} | javascript | function move(key, index, req) {
var val = this.getKey(key)
, db = this.store.getDatabase(index, this.options);
//console.dir(val);
if(!val || db.keyExists(key)) return 0;
db.setKey(key, val);
this.delKey(key);
return 1;
} | [
"function",
"move",
"(",
"key",
",",
"index",
",",
"req",
")",
"{",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
")",
",",
"db",
"=",
"this",
".",
"store",
".",
"getDatabase",
"(",
"index",
",",
"this",
".",
"options",
")",
";",
"//console.dir(val);",
"if",
"(",
"!",
"val",
"||",
"db",
".",
"keyExists",
"(",
"key",
")",
")",
"return",
"0",
";",
"db",
".",
"setKey",
"(",
"key",
",",
"val",
")",
";",
"this",
".",
"delKey",
"(",
"key",
")",
";",
"return",
"1",
";",
"}"
] | Move a key from this database to another database. | [
"Move",
"a",
"key",
"from",
"this",
"database",
"to",
"another",
"database",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/keys.js#L66-L74 |
51,526 | gethuman/pancakes-angular | lib/transformers/ng.app.transformer.js | transform | function transform(flapjack, options) {
var filePath = options.filePath;
var appName = this.getAppName(filePath, options.appName);
var appInfo = this.pancakes.cook(flapjack, null);
var validations = this.getSchemaValidations(appInfo, null);
var schema = this.stringify(validations);
var deps = (options.isMobile && appInfo.clientMobileDeps) ?
appInfo.clientMobileDeps :
appInfo.clientDependencies;
return this.template({
appName: this.getAppModuleName(options.prefix, appName),
deps: deps || [],
initLoad: appInfo.clientLoadOnInit,
isMobile: options.isMobile,
schema: schema,
isCommon: appName === 'common'
});
} | javascript | function transform(flapjack, options) {
var filePath = options.filePath;
var appName = this.getAppName(filePath, options.appName);
var appInfo = this.pancakes.cook(flapjack, null);
var validations = this.getSchemaValidations(appInfo, null);
var schema = this.stringify(validations);
var deps = (options.isMobile && appInfo.clientMobileDeps) ?
appInfo.clientMobileDeps :
appInfo.clientDependencies;
return this.template({
appName: this.getAppModuleName(options.prefix, appName),
deps: deps || [],
initLoad: appInfo.clientLoadOnInit,
isMobile: options.isMobile,
schema: schema,
isCommon: appName === 'common'
});
} | [
"function",
"transform",
"(",
"flapjack",
",",
"options",
")",
"{",
"var",
"filePath",
"=",
"options",
".",
"filePath",
";",
"var",
"appName",
"=",
"this",
".",
"getAppName",
"(",
"filePath",
",",
"options",
".",
"appName",
")",
";",
"var",
"appInfo",
"=",
"this",
".",
"pancakes",
".",
"cook",
"(",
"flapjack",
",",
"null",
")",
";",
"var",
"validations",
"=",
"this",
".",
"getSchemaValidations",
"(",
"appInfo",
",",
"null",
")",
";",
"var",
"schema",
"=",
"this",
".",
"stringify",
"(",
"validations",
")",
";",
"var",
"deps",
"=",
"(",
"options",
".",
"isMobile",
"&&",
"appInfo",
".",
"clientMobileDeps",
")",
"?",
"appInfo",
".",
"clientMobileDeps",
":",
"appInfo",
".",
"clientDependencies",
";",
"return",
"this",
".",
"template",
"(",
"{",
"appName",
":",
"this",
".",
"getAppModuleName",
"(",
"options",
".",
"prefix",
",",
"appName",
")",
",",
"deps",
":",
"deps",
"||",
"[",
"]",
",",
"initLoad",
":",
"appInfo",
".",
"clientLoadOnInit",
",",
"isMobile",
":",
"options",
".",
"isMobile",
",",
"schema",
":",
"schema",
",",
"isCommon",
":",
"appName",
"===",
"'common'",
"}",
")",
";",
"}"
] | Pull together the template model and generate the template
@param flapjack
@param options
@returns {Q} | [
"Pull",
"together",
"the",
"template",
"model",
"and",
"generate",
"the",
"template"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/transformers/ng.app.transformer.js#L15-L33 |
51,527 | gethuman/pancakes-angular | lib/transformers/ng.app.transformer.js | getSchemaValidations | function getSchemaValidations(appInfo, resources) {
if (!appInfo.includeSchemas) { return null; }
// if resources not passed in, then get from pancakes
resources = resources || this.pancakes.cook('resources', null);
var validations = {};
_.each(resources, function (resource) {
_.each(resource.fields, function (fieldDef, fieldName) {
if (fieldDef.ui) {
validations[resource.name] = validations[resource.name] || {};
validations[resource.name][fieldName] = fieldDef;
}
});
});
return validations;
} | javascript | function getSchemaValidations(appInfo, resources) {
if (!appInfo.includeSchemas) { return null; }
// if resources not passed in, then get from pancakes
resources = resources || this.pancakes.cook('resources', null);
var validations = {};
_.each(resources, function (resource) {
_.each(resource.fields, function (fieldDef, fieldName) {
if (fieldDef.ui) {
validations[resource.name] = validations[resource.name] || {};
validations[resource.name][fieldName] = fieldDef;
}
});
});
return validations;
} | [
"function",
"getSchemaValidations",
"(",
"appInfo",
",",
"resources",
")",
"{",
"if",
"(",
"!",
"appInfo",
".",
"includeSchemas",
")",
"{",
"return",
"null",
";",
"}",
"// if resources not passed in, then get from pancakes",
"resources",
"=",
"resources",
"||",
"this",
".",
"pancakes",
".",
"cook",
"(",
"'resources'",
",",
"null",
")",
";",
"var",
"validations",
"=",
"{",
"}",
";",
"_",
".",
"each",
"(",
"resources",
",",
"function",
"(",
"resource",
")",
"{",
"_",
".",
"each",
"(",
"resource",
".",
"fields",
",",
"function",
"(",
"fieldDef",
",",
"fieldName",
")",
"{",
"if",
"(",
"fieldDef",
".",
"ui",
")",
"{",
"validations",
"[",
"resource",
".",
"name",
"]",
"=",
"validations",
"[",
"resource",
".",
"name",
"]",
"||",
"{",
"}",
";",
"validations",
"[",
"resource",
".",
"name",
"]",
"[",
"fieldName",
"]",
"=",
"fieldDef",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"return",
"validations",
";",
"}"
] | Get the stringified version of the schem
@param appInfo
@param resources
@returns {*} | [
"Get",
"the",
"stringified",
"version",
"of",
"the",
"schem"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/transformers/ng.app.transformer.js#L41-L60 |
51,528 | gethuman/pancakes-angular | lib/transformers/ng.app.transformer.js | stringify | function stringify(validations) {
if (!validations) { return ''; }
return JSON.stringify(validations, function (key, value) {
if (_.isRegExp(value)) { return value.toString(); }
switch (value) {
case String: return 'String';
case Boolean: return 'Boolean';
case Date: return 'Date';
case Number: return 'Number';
default: return value;
}
});
} | javascript | function stringify(validations) {
if (!validations) { return ''; }
return JSON.stringify(validations, function (key, value) {
if (_.isRegExp(value)) { return value.toString(); }
switch (value) {
case String: return 'String';
case Boolean: return 'Boolean';
case Date: return 'Date';
case Number: return 'Number';
default: return value;
}
});
} | [
"function",
"stringify",
"(",
"validations",
")",
"{",
"if",
"(",
"!",
"validations",
")",
"{",
"return",
"''",
";",
"}",
"return",
"JSON",
".",
"stringify",
"(",
"validations",
",",
"function",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"_",
".",
"isRegExp",
"(",
"value",
")",
")",
"{",
"return",
"value",
".",
"toString",
"(",
")",
";",
"}",
"switch",
"(",
"value",
")",
"{",
"case",
"String",
":",
"return",
"'String'",
";",
"case",
"Boolean",
":",
"return",
"'Boolean'",
";",
"case",
"Date",
":",
"return",
"'Date'",
";",
"case",
"Number",
":",
"return",
"'Number'",
";",
"default",
":",
"return",
"value",
";",
"}",
"}",
")",
";",
"}"
] | Stringify the validations object
@param validations
@returns {*} | [
"Stringify",
"the",
"validations",
"object"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/transformers/ng.app.transformer.js#L67-L81 |
51,529 | hypergroup/hyper-client-superagent | index.js | Client | function Client(API_URL, token, opts) {
if (!(this instanceof Client)) return new Client(API_URL, token, opts);
if (typeof token == 'object') {
opts = token;
token = null;
}
Emitter.call(this);
var self = this;
opts = opts || {};
self.cache = new LRU(opts.maxSize || 500);
self.pending = {};
self.root = get.bind(self, API_URL);
self.get = get.bind(self);
var context = self.context = superagent();
if (token) self.header('authorization', 'Bearer ' + token);
// TODO only set the parser for the context
var parsers = context.request.parse;
parsers['application/json'] = parsers['application/hyper+json'] = parseHyperJson;
patchCrappySuperagent(context.request.Response, context.request.parse);
} | javascript | function Client(API_URL, token, opts) {
if (!(this instanceof Client)) return new Client(API_URL, token, opts);
if (typeof token == 'object') {
opts = token;
token = null;
}
Emitter.call(this);
var self = this;
opts = opts || {};
self.cache = new LRU(opts.maxSize || 500);
self.pending = {};
self.root = get.bind(self, API_URL);
self.get = get.bind(self);
var context = self.context = superagent();
if (token) self.header('authorization', 'Bearer ' + token);
// TODO only set the parser for the context
var parsers = context.request.parse;
parsers['application/json'] = parsers['application/hyper+json'] = parseHyperJson;
patchCrappySuperagent(context.request.Response, context.request.parse);
} | [
"function",
"Client",
"(",
"API_URL",
",",
"token",
",",
"opts",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Client",
")",
")",
"return",
"new",
"Client",
"(",
"API_URL",
",",
"token",
",",
"opts",
")",
";",
"if",
"(",
"typeof",
"token",
"==",
"'object'",
")",
"{",
"opts",
"=",
"token",
";",
"token",
"=",
"null",
";",
"}",
"Emitter",
".",
"call",
"(",
"this",
")",
";",
"var",
"self",
"=",
"this",
";",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"self",
".",
"cache",
"=",
"new",
"LRU",
"(",
"opts",
".",
"maxSize",
"||",
"500",
")",
";",
"self",
".",
"pending",
"=",
"{",
"}",
";",
"self",
".",
"root",
"=",
"get",
".",
"bind",
"(",
"self",
",",
"API_URL",
")",
";",
"self",
".",
"get",
"=",
"get",
".",
"bind",
"(",
"self",
")",
";",
"var",
"context",
"=",
"self",
".",
"context",
"=",
"superagent",
"(",
")",
";",
"if",
"(",
"token",
")",
"self",
".",
"header",
"(",
"'authorization'",
",",
"'Bearer '",
"+",
"token",
")",
";",
"// TODO only set the parser for the context",
"var",
"parsers",
"=",
"context",
".",
"request",
".",
"parse",
";",
"parsers",
"[",
"'application/json'",
"]",
"=",
"parsers",
"[",
"'application/hyper+json'",
"]",
"=",
"parseHyperJson",
";",
"patchCrappySuperagent",
"(",
"context",
".",
"request",
".",
"Response",
",",
"context",
".",
"request",
".",
"parse",
")",
";",
"}"
] | Create a client | [
"Create",
"a",
"client"
] | 4c1c7c2014386ac93b4804b50eabfe1c3b5a23f6 | https://github.com/hypergroup/hyper-client-superagent/blob/4c1c7c2014386ac93b4804b50eabfe1c3b5a23f6/index.js#L24-L50 |
51,530 | hypergroup/hyper-client-superagent | index.js | HyperError | function HyperError(res) {
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.name = 'HyperError';
this.status = res.status;
if (res.body && res.body.error) this.message = res.body.error.message;
else this.message = res.text;
} | javascript | function HyperError(res) {
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.name = 'HyperError';
this.status = res.status;
if (res.body && res.body.error) this.message = res.body.error.message;
else this.message = res.text;
} | [
"function",
"HyperError",
"(",
"res",
")",
"{",
"Error",
".",
"call",
"(",
"this",
")",
";",
"Error",
".",
"captureStackTrace",
"(",
"this",
",",
"arguments",
".",
"callee",
")",
";",
"this",
".",
"name",
"=",
"'HyperError'",
";",
"this",
".",
"status",
"=",
"res",
".",
"status",
";",
"if",
"(",
"res",
".",
"body",
"&&",
"res",
".",
"body",
".",
"error",
")",
"this",
".",
"message",
"=",
"res",
".",
"body",
".",
"error",
".",
"message",
";",
"else",
"this",
".",
"message",
"=",
"res",
".",
"text",
";",
"}"
] | Create a hyper error given a superagent response
@param {Response} res | [
"Create",
"a",
"hyper",
"error",
"given",
"a",
"superagent",
"response"
] | 4c1c7c2014386ac93b4804b50eabfe1c3b5a23f6 | https://github.com/hypergroup/hyper-client-superagent/blob/4c1c7c2014386ac93b4804b50eabfe1c3b5a23f6/index.js#L270-L277 |
51,531 | akaspin/tav | index.js | function(spec, banner, strict) {
spec = spec || {};
banner = banner || "Usage:";
var self = this;
var incoming = process.argv.slice(2); // incoming params
/**
* Returns extra items frob b
* @param a
* @param b
* @returns {Array}
*/
var arrayDiff = function(a, b) {
return b.filter(function(i) {
return a.indexOf(i) == -1;
});
};
/**
* Check conditions. If help setted - always exit.
* @param parsed Parsed specs
*/
var check = function(parsed) {
var end = false, message = "", code = 0, outer = console.log;
var setted = Object.keys(self);
var specced = Object.keys(parsed);
var required = arrayDiff(setted, specced);
var unexpected = arrayDiff(specced, setted);
// If any required options is not provided - crash it!
if (required.length) {
end = true;
code = 1;
outer = console.error;
message += "Required but not provided:\n --"
+ required.join("\n --") + "\n";
}
// + unexpected
if (unexpected.length) {
message += "Unexpected options:\n --"
+ unexpected.join("\n --") + "\n";
}
message += (message.length ?
"\nRun with --help for more info" : "");
if (strict && message.length) {
end = true;
code = 1;
outer = console.error;
}
// If --help, exit without error
if (incoming.indexOf("--help") != -1) {
end = true;
code = 0;
outer = console.log;
message = Object.keys(parsed).reduce(function(msg, k) {
return msg + parsed[k].note + "\n --" + k
+ (parsed[k].req ? " *required\n" : "\n");
}, "") + "Help. This message.\n --help\n";
}
if (end) {
// exiting
outer(banner + "\n");
outer(message);
process.exit(code);
}
};
// Fill spec and default values
var parsed = {};
Object.keys(spec).forEach(function(name) {
var req = spec[name].value === undefined ? true : false;
var note = spec[name].note || "Note not provided";
parsed[name] = {
req : req,
note : note
};
// If value not required - set it
if (!req) {
self[name] = spec[name].value;
}
});
// Evaluate process.argv
var numRe = /^[0-9.]+$/;
incoming.filter(function(chunk) {
return chunk != "--help" && chunk != "--";
})
.forEach(function(chunk) {
if (chunk.substring(0,2) == "--") {
var tokens = chunk.substring(2).split("=");
var name = tokens[0];
// Expected option - evaluate value
if (tokens.length == 1) {
// Boolean
var value = true;
} else {
var value = tokens.length > 2 ?
tokens.slice(1).join('=') : tokens[1];
if (numRe.test(value)) {
value = parseFloat(value);
}
}
if (self[name] instanceof Array) {
self[name].push(value);
} else {
self[name] = value;
}
} else {
// Just argument
self.args.push(chunk);
}
});
check(parsed);
return this;
} | javascript | function(spec, banner, strict) {
spec = spec || {};
banner = banner || "Usage:";
var self = this;
var incoming = process.argv.slice(2); // incoming params
/**
* Returns extra items frob b
* @param a
* @param b
* @returns {Array}
*/
var arrayDiff = function(a, b) {
return b.filter(function(i) {
return a.indexOf(i) == -1;
});
};
/**
* Check conditions. If help setted - always exit.
* @param parsed Parsed specs
*/
var check = function(parsed) {
var end = false, message = "", code = 0, outer = console.log;
var setted = Object.keys(self);
var specced = Object.keys(parsed);
var required = arrayDiff(setted, specced);
var unexpected = arrayDiff(specced, setted);
// If any required options is not provided - crash it!
if (required.length) {
end = true;
code = 1;
outer = console.error;
message += "Required but not provided:\n --"
+ required.join("\n --") + "\n";
}
// + unexpected
if (unexpected.length) {
message += "Unexpected options:\n --"
+ unexpected.join("\n --") + "\n";
}
message += (message.length ?
"\nRun with --help for more info" : "");
if (strict && message.length) {
end = true;
code = 1;
outer = console.error;
}
// If --help, exit without error
if (incoming.indexOf("--help") != -1) {
end = true;
code = 0;
outer = console.log;
message = Object.keys(parsed).reduce(function(msg, k) {
return msg + parsed[k].note + "\n --" + k
+ (parsed[k].req ? " *required\n" : "\n");
}, "") + "Help. This message.\n --help\n";
}
if (end) {
// exiting
outer(banner + "\n");
outer(message);
process.exit(code);
}
};
// Fill spec and default values
var parsed = {};
Object.keys(spec).forEach(function(name) {
var req = spec[name].value === undefined ? true : false;
var note = spec[name].note || "Note not provided";
parsed[name] = {
req : req,
note : note
};
// If value not required - set it
if (!req) {
self[name] = spec[name].value;
}
});
// Evaluate process.argv
var numRe = /^[0-9.]+$/;
incoming.filter(function(chunk) {
return chunk != "--help" && chunk != "--";
})
.forEach(function(chunk) {
if (chunk.substring(0,2) == "--") {
var tokens = chunk.substring(2).split("=");
var name = tokens[0];
// Expected option - evaluate value
if (tokens.length == 1) {
// Boolean
var value = true;
} else {
var value = tokens.length > 2 ?
tokens.slice(1).join('=') : tokens[1];
if (numRe.test(value)) {
value = parseFloat(value);
}
}
if (self[name] instanceof Array) {
self[name].push(value);
} else {
self[name] = value;
}
} else {
// Just argument
self.args.push(chunk);
}
});
check(parsed);
return this;
} | [
"function",
"(",
"spec",
",",
"banner",
",",
"strict",
")",
"{",
"spec",
"=",
"spec",
"||",
"{",
"}",
";",
"banner",
"=",
"banner",
"||",
"\"Usage:\"",
";",
"var",
"self",
"=",
"this",
";",
"var",
"incoming",
"=",
"process",
".",
"argv",
".",
"slice",
"(",
"2",
")",
";",
"// incoming params\r",
"/**\r\n * Returns extra items frob b\r\n * @param a\r\n * @param b\r\n * @returns {Array}\r\n */",
"var",
"arrayDiff",
"=",
"function",
"(",
"a",
",",
"b",
")",
"{",
"return",
"b",
".",
"filter",
"(",
"function",
"(",
"i",
")",
"{",
"return",
"a",
".",
"indexOf",
"(",
"i",
")",
"==",
"-",
"1",
";",
"}",
")",
";",
"}",
";",
"/**\r\n * Check conditions. If help setted - always exit.\r\n * @param parsed Parsed specs\r\n */",
"var",
"check",
"=",
"function",
"(",
"parsed",
")",
"{",
"var",
"end",
"=",
"false",
",",
"message",
"=",
"\"\"",
",",
"code",
"=",
"0",
",",
"outer",
"=",
"console",
".",
"log",
";",
"var",
"setted",
"=",
"Object",
".",
"keys",
"(",
"self",
")",
";",
"var",
"specced",
"=",
"Object",
".",
"keys",
"(",
"parsed",
")",
";",
"var",
"required",
"=",
"arrayDiff",
"(",
"setted",
",",
"specced",
")",
";",
"var",
"unexpected",
"=",
"arrayDiff",
"(",
"specced",
",",
"setted",
")",
";",
"// If any required options is not provided - crash it!\r",
"if",
"(",
"required",
".",
"length",
")",
"{",
"end",
"=",
"true",
";",
"code",
"=",
"1",
";",
"outer",
"=",
"console",
".",
"error",
";",
"message",
"+=",
"\"Required but not provided:\\n --\"",
"+",
"required",
".",
"join",
"(",
"\"\\n --\"",
")",
"+",
"\"\\n\"",
";",
"}",
"// + unexpected\r",
"if",
"(",
"unexpected",
".",
"length",
")",
"{",
"message",
"+=",
"\"Unexpected options:\\n --\"",
"+",
"unexpected",
".",
"join",
"(",
"\"\\n --\"",
")",
"+",
"\"\\n\"",
";",
"}",
"message",
"+=",
"(",
"message",
".",
"length",
"?",
"\"\\nRun with --help for more info\"",
":",
"\"\"",
")",
";",
"if",
"(",
"strict",
"&&",
"message",
".",
"length",
")",
"{",
"end",
"=",
"true",
";",
"code",
"=",
"1",
";",
"outer",
"=",
"console",
".",
"error",
";",
"}",
"// If --help, exit without error\r",
"if",
"(",
"incoming",
".",
"indexOf",
"(",
"\"--help\"",
")",
"!=",
"-",
"1",
")",
"{",
"end",
"=",
"true",
";",
"code",
"=",
"0",
";",
"outer",
"=",
"console",
".",
"log",
";",
"message",
"=",
"Object",
".",
"keys",
"(",
"parsed",
")",
".",
"reduce",
"(",
"function",
"(",
"msg",
",",
"k",
")",
"{",
"return",
"msg",
"+",
"parsed",
"[",
"k",
"]",
".",
"note",
"+",
"\"\\n --\"",
"+",
"k",
"+",
"(",
"parsed",
"[",
"k",
"]",
".",
"req",
"?",
"\" *required\\n\"",
":",
"\"\\n\"",
")",
";",
"}",
",",
"\"\"",
")",
"+",
"\"Help. This message.\\n --help\\n\"",
";",
"}",
"if",
"(",
"end",
")",
"{",
"// exiting\r",
"outer",
"(",
"banner",
"+",
"\"\\n\"",
")",
";",
"outer",
"(",
"message",
")",
";",
"process",
".",
"exit",
"(",
"code",
")",
";",
"}",
"}",
";",
"// Fill spec and default values\r",
"var",
"parsed",
"=",
"{",
"}",
";",
"Object",
".",
"keys",
"(",
"spec",
")",
".",
"forEach",
"(",
"function",
"(",
"name",
")",
"{",
"var",
"req",
"=",
"spec",
"[",
"name",
"]",
".",
"value",
"===",
"undefined",
"?",
"true",
":",
"false",
";",
"var",
"note",
"=",
"spec",
"[",
"name",
"]",
".",
"note",
"||",
"\"Note not provided\"",
";",
"parsed",
"[",
"name",
"]",
"=",
"{",
"req",
":",
"req",
",",
"note",
":",
"note",
"}",
";",
"// If value not required - set it\r",
"if",
"(",
"!",
"req",
")",
"{",
"self",
"[",
"name",
"]",
"=",
"spec",
"[",
"name",
"]",
".",
"value",
";",
"}",
"}",
")",
";",
"// Evaluate process.argv\r",
"var",
"numRe",
"=",
"/",
"^[0-9.]+$",
"/",
";",
"incoming",
".",
"filter",
"(",
"function",
"(",
"chunk",
")",
"{",
"return",
"chunk",
"!=",
"\"--help\"",
"&&",
"chunk",
"!=",
"\"--\"",
";",
"}",
")",
".",
"forEach",
"(",
"function",
"(",
"chunk",
")",
"{",
"if",
"(",
"chunk",
".",
"substring",
"(",
"0",
",",
"2",
")",
"==",
"\"--\"",
")",
"{",
"var",
"tokens",
"=",
"chunk",
".",
"substring",
"(",
"2",
")",
".",
"split",
"(",
"\"=\"",
")",
";",
"var",
"name",
"=",
"tokens",
"[",
"0",
"]",
";",
"// Expected option - evaluate value\r",
"if",
"(",
"tokens",
".",
"length",
"==",
"1",
")",
"{",
"// Boolean\r",
"var",
"value",
"=",
"true",
";",
"}",
"else",
"{",
"var",
"value",
"=",
"tokens",
".",
"length",
">",
"2",
"?",
"tokens",
".",
"slice",
"(",
"1",
")",
".",
"join",
"(",
"'='",
")",
":",
"tokens",
"[",
"1",
"]",
";",
"if",
"(",
"numRe",
".",
"test",
"(",
"value",
")",
")",
"{",
"value",
"=",
"parseFloat",
"(",
"value",
")",
";",
"}",
"}",
"if",
"(",
"self",
"[",
"name",
"]",
"instanceof",
"Array",
")",
"{",
"self",
"[",
"name",
"]",
".",
"push",
"(",
"value",
")",
";",
"}",
"else",
"{",
"self",
"[",
"name",
"]",
"=",
"value",
";",
"}",
"}",
"else",
"{",
"// Just argument\r",
"self",
".",
"args",
".",
"push",
"(",
"chunk",
")",
";",
"}",
"}",
")",
";",
"check",
"(",
"parsed",
")",
";",
"return",
"this",
";",
"}"
] | Sets options.
@param spec Specification
@param banner Banner
@param strict Assume unexpected params as error. | [
"Sets",
"options",
"."
] | 1a7402ba5cd59cacecabad80e4a51f4a3ca66f1e | https://github.com/akaspin/tav/blob/1a7402ba5cd59cacecabad80e4a51f4a3ca66f1e/index.js#L16-L134 |
|
51,532 | akaspin/tav | index.js | function(parsed) {
var end = false, message = "", code = 0, outer = console.log;
var setted = Object.keys(self);
var specced = Object.keys(parsed);
var required = arrayDiff(setted, specced);
var unexpected = arrayDiff(specced, setted);
// If any required options is not provided - crash it!
if (required.length) {
end = true;
code = 1;
outer = console.error;
message += "Required but not provided:\n --"
+ required.join("\n --") + "\n";
}
// + unexpected
if (unexpected.length) {
message += "Unexpected options:\n --"
+ unexpected.join("\n --") + "\n";
}
message += (message.length ?
"\nRun with --help for more info" : "");
if (strict && message.length) {
end = true;
code = 1;
outer = console.error;
}
// If --help, exit without error
if (incoming.indexOf("--help") != -1) {
end = true;
code = 0;
outer = console.log;
message = Object.keys(parsed).reduce(function(msg, k) {
return msg + parsed[k].note + "\n --" + k
+ (parsed[k].req ? " *required\n" : "\n");
}, "") + "Help. This message.\n --help\n";
}
if (end) {
// exiting
outer(banner + "\n");
outer(message);
process.exit(code);
}
} | javascript | function(parsed) {
var end = false, message = "", code = 0, outer = console.log;
var setted = Object.keys(self);
var specced = Object.keys(parsed);
var required = arrayDiff(setted, specced);
var unexpected = arrayDiff(specced, setted);
// If any required options is not provided - crash it!
if (required.length) {
end = true;
code = 1;
outer = console.error;
message += "Required but not provided:\n --"
+ required.join("\n --") + "\n";
}
// + unexpected
if (unexpected.length) {
message += "Unexpected options:\n --"
+ unexpected.join("\n --") + "\n";
}
message += (message.length ?
"\nRun with --help for more info" : "");
if (strict && message.length) {
end = true;
code = 1;
outer = console.error;
}
// If --help, exit without error
if (incoming.indexOf("--help") != -1) {
end = true;
code = 0;
outer = console.log;
message = Object.keys(parsed).reduce(function(msg, k) {
return msg + parsed[k].note + "\n --" + k
+ (parsed[k].req ? " *required\n" : "\n");
}, "") + "Help. This message.\n --help\n";
}
if (end) {
// exiting
outer(banner + "\n");
outer(message);
process.exit(code);
}
} | [
"function",
"(",
"parsed",
")",
"{",
"var",
"end",
"=",
"false",
",",
"message",
"=",
"\"\"",
",",
"code",
"=",
"0",
",",
"outer",
"=",
"console",
".",
"log",
";",
"var",
"setted",
"=",
"Object",
".",
"keys",
"(",
"self",
")",
";",
"var",
"specced",
"=",
"Object",
".",
"keys",
"(",
"parsed",
")",
";",
"var",
"required",
"=",
"arrayDiff",
"(",
"setted",
",",
"specced",
")",
";",
"var",
"unexpected",
"=",
"arrayDiff",
"(",
"specced",
",",
"setted",
")",
";",
"// If any required options is not provided - crash it!\r",
"if",
"(",
"required",
".",
"length",
")",
"{",
"end",
"=",
"true",
";",
"code",
"=",
"1",
";",
"outer",
"=",
"console",
".",
"error",
";",
"message",
"+=",
"\"Required but not provided:\\n --\"",
"+",
"required",
".",
"join",
"(",
"\"\\n --\"",
")",
"+",
"\"\\n\"",
";",
"}",
"// + unexpected\r",
"if",
"(",
"unexpected",
".",
"length",
")",
"{",
"message",
"+=",
"\"Unexpected options:\\n --\"",
"+",
"unexpected",
".",
"join",
"(",
"\"\\n --\"",
")",
"+",
"\"\\n\"",
";",
"}",
"message",
"+=",
"(",
"message",
".",
"length",
"?",
"\"\\nRun with --help for more info\"",
":",
"\"\"",
")",
";",
"if",
"(",
"strict",
"&&",
"message",
".",
"length",
")",
"{",
"end",
"=",
"true",
";",
"code",
"=",
"1",
";",
"outer",
"=",
"console",
".",
"error",
";",
"}",
"// If --help, exit without error\r",
"if",
"(",
"incoming",
".",
"indexOf",
"(",
"\"--help\"",
")",
"!=",
"-",
"1",
")",
"{",
"end",
"=",
"true",
";",
"code",
"=",
"0",
";",
"outer",
"=",
"console",
".",
"log",
";",
"message",
"=",
"Object",
".",
"keys",
"(",
"parsed",
")",
".",
"reduce",
"(",
"function",
"(",
"msg",
",",
"k",
")",
"{",
"return",
"msg",
"+",
"parsed",
"[",
"k",
"]",
".",
"note",
"+",
"\"\\n --\"",
"+",
"k",
"+",
"(",
"parsed",
"[",
"k",
"]",
".",
"req",
"?",
"\" *required\\n\"",
":",
"\"\\n\"",
")",
";",
"}",
",",
"\"\"",
")",
"+",
"\"Help. This message.\\n --help\\n\"",
";",
"}",
"if",
"(",
"end",
")",
"{",
"// exiting\r",
"outer",
"(",
"banner",
"+",
"\"\\n\"",
")",
";",
"outer",
"(",
"message",
")",
";",
"process",
".",
"exit",
"(",
"code",
")",
";",
"}",
"}"
] | Check conditions. If help setted - always exit.
@param parsed Parsed specs | [
"Check",
"conditions",
".",
"If",
"help",
"setted",
"-",
"always",
"exit",
"."
] | 1a7402ba5cd59cacecabad80e4a51f4a3ca66f1e | https://github.com/akaspin/tav/blob/1a7402ba5cd59cacecabad80e4a51f4a3ca66f1e/index.js#L37-L83 |
|
51,533 | redisjs/jsr-server | lib/command/database/string/bitop.js | validate | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var op = ('' + args[0]).toLowerCase();
if(op !== BITOP.AND && op !== BITOP.OR
&& op !== BITOP.XOR && op !== BITOP.NOT) {
throw CommandSyntax;
}
if(op === BITOP.NOT && args.length !== 3) {
throw BitopNot;
}
args[0] = op;
} | javascript | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var op = ('' + args[0]).toLowerCase();
if(op !== BITOP.AND && op !== BITOP.OR
&& op !== BITOP.XOR && op !== BITOP.NOT) {
throw CommandSyntax;
}
if(op === BITOP.NOT && args.length !== 3) {
throw BitopNot;
}
args[0] = op;
} | [
"function",
"validate",
"(",
"cmd",
",",
"args",
",",
"info",
")",
"{",
"AbstractCommand",
".",
"prototype",
".",
"validate",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"var",
"op",
"=",
"(",
"''",
"+",
"args",
"[",
"0",
"]",
")",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"op",
"!==",
"BITOP",
".",
"AND",
"&&",
"op",
"!==",
"BITOP",
".",
"OR",
"&&",
"op",
"!==",
"BITOP",
".",
"XOR",
"&&",
"op",
"!==",
"BITOP",
".",
"NOT",
")",
"{",
"throw",
"CommandSyntax",
";",
"}",
"if",
"(",
"op",
"===",
"BITOP",
".",
"NOT",
"&&",
"args",
".",
"length",
"!==",
"3",
")",
"{",
"throw",
"BitopNot",
";",
"}",
"args",
"[",
"0",
"]",
"=",
"op",
";",
"}"
] | Validate the BITOP command. | [
"Validate",
"the",
"BITOP",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/database/string/bitop.js#L21-L32 |
51,534 | redisjs/jsr-server | lib/state.js | ServerState | function ServerState() {
// server configuration
this._conf = new Configuration();
this._conf.once('load', this.onConfigLoad.bind(this));
// the server bind address information
// if listen() is never called this is null
this._addr = null;
// timestamp for the last save of the rdb file
this._lastsave = Date.now();
// server logger
this._logger = logger();
// periodic scheduler
this._scheduler = new Scheduler();
// collection of connections
this._conn = [];
// master pattern matcher
this._pattern = new Pattern();
// the store - this is where the data lives
this._store = new Store(this._conf);
// ensure we have a database at index 0
// the SELECT command will lazily create databases
// on demand
if(this._store.databases[0] === undefined) {
this._store.getDatabase(0, {pattern: this._pattern});
}
// server statistics
this._stats = new Stats(this);
// server information
this._info = new Info(this);
// global pubsub state
this._pubsub = new PubSub(this._stats);
// slow log storage
this._slowlog = new SlowLog(this._conf);
function onSave(time, diff, version, file) {
this._lastsave = Date.now();
this.log.notice('db saved to disk: %s seconds (%s)', time, file)
}
Persistence.on('save', onSave.bind(this));
process.on('debug', debug.bind(this));
process.on('tick', expire.bind(this));
} | javascript | function ServerState() {
// server configuration
this._conf = new Configuration();
this._conf.once('load', this.onConfigLoad.bind(this));
// the server bind address information
// if listen() is never called this is null
this._addr = null;
// timestamp for the last save of the rdb file
this._lastsave = Date.now();
// server logger
this._logger = logger();
// periodic scheduler
this._scheduler = new Scheduler();
// collection of connections
this._conn = [];
// master pattern matcher
this._pattern = new Pattern();
// the store - this is where the data lives
this._store = new Store(this._conf);
// ensure we have a database at index 0
// the SELECT command will lazily create databases
// on demand
if(this._store.databases[0] === undefined) {
this._store.getDatabase(0, {pattern: this._pattern});
}
// server statistics
this._stats = new Stats(this);
// server information
this._info = new Info(this);
// global pubsub state
this._pubsub = new PubSub(this._stats);
// slow log storage
this._slowlog = new SlowLog(this._conf);
function onSave(time, diff, version, file) {
this._lastsave = Date.now();
this.log.notice('db saved to disk: %s seconds (%s)', time, file)
}
Persistence.on('save', onSave.bind(this));
process.on('debug', debug.bind(this));
process.on('tick', expire.bind(this));
} | [
"function",
"ServerState",
"(",
")",
"{",
"// server configuration",
"this",
".",
"_conf",
"=",
"new",
"Configuration",
"(",
")",
";",
"this",
".",
"_conf",
".",
"once",
"(",
"'load'",
",",
"this",
".",
"onConfigLoad",
".",
"bind",
"(",
"this",
")",
")",
";",
"// the server bind address information",
"// if listen() is never called this is null",
"this",
".",
"_addr",
"=",
"null",
";",
"// timestamp for the last save of the rdb file",
"this",
".",
"_lastsave",
"=",
"Date",
".",
"now",
"(",
")",
";",
"// server logger",
"this",
".",
"_logger",
"=",
"logger",
"(",
")",
";",
"// periodic scheduler",
"this",
".",
"_scheduler",
"=",
"new",
"Scheduler",
"(",
")",
";",
"// collection of connections",
"this",
".",
"_conn",
"=",
"[",
"]",
";",
"// master pattern matcher",
"this",
".",
"_pattern",
"=",
"new",
"Pattern",
"(",
")",
";",
"// the store - this is where the data lives",
"this",
".",
"_store",
"=",
"new",
"Store",
"(",
"this",
".",
"_conf",
")",
";",
"// ensure we have a database at index 0",
"// the SELECT command will lazily create databases",
"// on demand",
"if",
"(",
"this",
".",
"_store",
".",
"databases",
"[",
"0",
"]",
"===",
"undefined",
")",
"{",
"this",
".",
"_store",
".",
"getDatabase",
"(",
"0",
",",
"{",
"pattern",
":",
"this",
".",
"_pattern",
"}",
")",
";",
"}",
"// server statistics",
"this",
".",
"_stats",
"=",
"new",
"Stats",
"(",
"this",
")",
";",
"// server information",
"this",
".",
"_info",
"=",
"new",
"Info",
"(",
"this",
")",
";",
"// global pubsub state",
"this",
".",
"_pubsub",
"=",
"new",
"PubSub",
"(",
"this",
".",
"_stats",
")",
";",
"// slow log storage",
"this",
".",
"_slowlog",
"=",
"new",
"SlowLog",
"(",
"this",
".",
"_conf",
")",
";",
"function",
"onSave",
"(",
"time",
",",
"diff",
",",
"version",
",",
"file",
")",
"{",
"this",
".",
"_lastsave",
"=",
"Date",
".",
"now",
"(",
")",
";",
"this",
".",
"log",
".",
"notice",
"(",
"'db saved to disk: %s seconds (%s)'",
",",
"time",
",",
"file",
")",
"}",
"Persistence",
".",
"on",
"(",
"'save'",
",",
"onSave",
".",
"bind",
"(",
"this",
")",
")",
";",
"process",
".",
"on",
"(",
"'debug'",
",",
"debug",
".",
"bind",
"(",
"this",
")",
")",
";",
"process",
".",
"on",
"(",
"'tick'",
",",
"expire",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] | Encapsulates the state of the server. | [
"Encapsulates",
"the",
"state",
"of",
"the",
"server",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/state.js#L19-L74 |
51,535 | redisjs/jsr-server | lib/state.js | pause | function pause(timeout) {
var log = this._logger;
// keep list of matching clients
var clients = [];
this._conn.forEach(function(conn) {
if(!conn.client.isSlave()) {
clients.push(conn);
conn.pause();
}
})
function resume() {
log.notice('resume %s connections', clients.length);
clients.forEach(function(conn) {
conn.resume();
})
}
log.notice('pause %s connections for %sms', clients.length, timeout);
setTimeout(resume, timeout);
} | javascript | function pause(timeout) {
var log = this._logger;
// keep list of matching clients
var clients = [];
this._conn.forEach(function(conn) {
if(!conn.client.isSlave()) {
clients.push(conn);
conn.pause();
}
})
function resume() {
log.notice('resume %s connections', clients.length);
clients.forEach(function(conn) {
conn.resume();
})
}
log.notice('pause %s connections for %sms', clients.length, timeout);
setTimeout(resume, timeout);
} | [
"function",
"pause",
"(",
"timeout",
")",
"{",
"var",
"log",
"=",
"this",
".",
"_logger",
";",
"// keep list of matching clients",
"var",
"clients",
"=",
"[",
"]",
";",
"this",
".",
"_conn",
".",
"forEach",
"(",
"function",
"(",
"conn",
")",
"{",
"if",
"(",
"!",
"conn",
".",
"client",
".",
"isSlave",
"(",
")",
")",
"{",
"clients",
".",
"push",
"(",
"conn",
")",
";",
"conn",
".",
"pause",
"(",
")",
";",
"}",
"}",
")",
"function",
"resume",
"(",
")",
"{",
"log",
".",
"notice",
"(",
"'resume %s connections'",
",",
"clients",
".",
"length",
")",
";",
"clients",
".",
"forEach",
"(",
"function",
"(",
"conn",
")",
"{",
"conn",
".",
"resume",
"(",
")",
";",
"}",
")",
"}",
"log",
".",
"notice",
"(",
"'pause %s connections for %sms'",
",",
"clients",
".",
"length",
",",
"timeout",
")",
";",
"setTimeout",
"(",
"resume",
",",
"timeout",
")",
";",
"}"
] | Pause normal and pubsub clients. | [
"Pause",
"normal",
"and",
"pubsub",
"clients",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/state.js#L81-L99 |
51,536 | redisjs/jsr-server | lib/state.js | expire | function expire() {
var dbs = this._store.databases, i;
for(i in dbs) {
dbs[i].delExpiredKeys();
}
} | javascript | function expire() {
var dbs = this._store.databases, i;
for(i in dbs) {
dbs[i].delExpiredKeys();
}
} | [
"function",
"expire",
"(",
")",
"{",
"var",
"dbs",
"=",
"this",
".",
"_store",
".",
"databases",
",",
"i",
";",
"for",
"(",
"i",
"in",
"dbs",
")",
"{",
"dbs",
"[",
"i",
"]",
".",
"delExpiredKeys",
"(",
")",
";",
"}",
"}"
] | Scheduler tick event that handles expiring keys.
Passive expiry. | [
"Scheduler",
"tick",
"event",
"that",
"handles",
"expiring",
"keys",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/state.js#L106-L111 |
51,537 | redisjs/jsr-server | lib/state.js | debug | function debug(rusage, memory) {
var dbs = this._store.databases
, i
, db
, size;
for(i in dbs) {
db = dbs[i];
size = db.dbsize();
if(size) {
this._logger.debug('DB %s: %s keys (%s volatile)', i, size, db.expiring);
}
}
this._logger.debug('%s clients connected, %s heap, %s rss bytes',
this.getLength(), memory.heapUsed, rusage.maxrss);
} | javascript | function debug(rusage, memory) {
var dbs = this._store.databases
, i
, db
, size;
for(i in dbs) {
db = dbs[i];
size = db.dbsize();
if(size) {
this._logger.debug('DB %s: %s keys (%s volatile)', i, size, db.expiring);
}
}
this._logger.debug('%s clients connected, %s heap, %s rss bytes',
this.getLength(), memory.heapUsed, rusage.maxrss);
} | [
"function",
"debug",
"(",
"rusage",
",",
"memory",
")",
"{",
"var",
"dbs",
"=",
"this",
".",
"_store",
".",
"databases",
",",
"i",
",",
"db",
",",
"size",
";",
"for",
"(",
"i",
"in",
"dbs",
")",
"{",
"db",
"=",
"dbs",
"[",
"i",
"]",
";",
"size",
"=",
"db",
".",
"dbsize",
"(",
")",
";",
"if",
"(",
"size",
")",
"{",
"this",
".",
"_logger",
".",
"debug",
"(",
"'DB %s: %s keys (%s volatile)'",
",",
"i",
",",
"size",
",",
"db",
".",
"expiring",
")",
";",
"}",
"}",
"this",
".",
"_logger",
".",
"debug",
"(",
"'%s clients connected, %s heap, %s rss bytes'",
",",
"this",
".",
"getLength",
"(",
")",
",",
"memory",
".",
"heapUsed",
",",
"rusage",
".",
"maxrss",
")",
";",
"}"
] | Listener for the debug log event. | [
"Listener",
"for",
"the",
"debug",
"log",
"event",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/state.js#L116-L130 |
51,538 | redisjs/jsr-server | lib/state.js | onConfigLoad | function onConfigLoad() {
var file = this._conf.get(ConfigName.LOGFILE);
this._logger.level(this._conf.get(ConfigName.LOGLEVEL));
//console.dir('config loaded.');
if(file && !this._conf.get(ConfigName.DAEMONIZE)) {
this._logger.stream(file);
}
if(this._conf.isDefault()) {
this._logger.warning('no config file specified, using the default config');
}
// TODO: listen for log change events and toggle this
this._scheduler.startDebugLog();
this._scheduler.start(this._conf.get(ConfigName.HZ));
} | javascript | function onConfigLoad() {
var file = this._conf.get(ConfigName.LOGFILE);
this._logger.level(this._conf.get(ConfigName.LOGLEVEL));
//console.dir('config loaded.');
if(file && !this._conf.get(ConfigName.DAEMONIZE)) {
this._logger.stream(file);
}
if(this._conf.isDefault()) {
this._logger.warning('no config file specified, using the default config');
}
// TODO: listen for log change events and toggle this
this._scheduler.startDebugLog();
this._scheduler.start(this._conf.get(ConfigName.HZ));
} | [
"function",
"onConfigLoad",
"(",
")",
"{",
"var",
"file",
"=",
"this",
".",
"_conf",
".",
"get",
"(",
"ConfigName",
".",
"LOGFILE",
")",
";",
"this",
".",
"_logger",
".",
"level",
"(",
"this",
".",
"_conf",
".",
"get",
"(",
"ConfigName",
".",
"LOGLEVEL",
")",
")",
";",
"//console.dir('config loaded.');",
"if",
"(",
"file",
"&&",
"!",
"this",
".",
"_conf",
".",
"get",
"(",
"ConfigName",
".",
"DAEMONIZE",
")",
")",
"{",
"this",
".",
"_logger",
".",
"stream",
"(",
"file",
")",
";",
"}",
"if",
"(",
"this",
".",
"_conf",
".",
"isDefault",
"(",
")",
")",
"{",
"this",
".",
"_logger",
".",
"warning",
"(",
"'no config file specified, using the default config'",
")",
";",
"}",
"// TODO: listen for log change events and toggle this",
"this",
".",
"_scheduler",
".",
"startDebugLog",
"(",
")",
";",
"this",
".",
"_scheduler",
".",
"start",
"(",
"this",
".",
"_conf",
".",
"get",
"(",
"ConfigName",
".",
"HZ",
")",
")",
";",
"}"
] | Listener for the config load event. | [
"Listener",
"for",
"the",
"config",
"load",
"event",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/state.js#L135-L150 |
51,539 | Wizcorp/panopticon | index.js | Panopticon | function Panopticon(options) {
var isInstance = this instanceof Panopticon;
if (!isInstance) {
return new Panopticon(options);
}
EventEmitter.call(this);
this.id = instanceCount;
instanceCount += 1;
// First we sort out the methods and data which handle are local to this process.
genericSetup(this, options);
// If the process is a worker, we only need to send the master results then return. If the
// process is not a worker, it is either the master or stand alone. The master also handles
// the delivery of aggregated data.
if (cluster.isWorker) {
workerSetup(this);
} else {
masterSetup(this);
setupDelivery(this);
}
} | javascript | function Panopticon(options) {
var isInstance = this instanceof Panopticon;
if (!isInstance) {
return new Panopticon(options);
}
EventEmitter.call(this);
this.id = instanceCount;
instanceCount += 1;
// First we sort out the methods and data which handle are local to this process.
genericSetup(this, options);
// If the process is a worker, we only need to send the master results then return. If the
// process is not a worker, it is either the master or stand alone. The master also handles
// the delivery of aggregated data.
if (cluster.isWorker) {
workerSetup(this);
} else {
masterSetup(this);
setupDelivery(this);
}
} | [
"function",
"Panopticon",
"(",
"options",
")",
"{",
"var",
"isInstance",
"=",
"this",
"instanceof",
"Panopticon",
";",
"if",
"(",
"!",
"isInstance",
")",
"{",
"return",
"new",
"Panopticon",
"(",
"options",
")",
";",
"}",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"id",
"=",
"instanceCount",
";",
"instanceCount",
"+=",
"1",
";",
"// First we sort out the methods and data which handle are local to this process.",
"genericSetup",
"(",
"this",
",",
"options",
")",
";",
"// If the process is a worker, we only need to send the master results then return. If the",
"// process is not a worker, it is either the master or stand alone. The master also handles",
"// the delivery of aggregated data.",
"if",
"(",
"cluster",
".",
"isWorker",
")",
"{",
"workerSetup",
"(",
"this",
")",
";",
"}",
"else",
"{",
"masterSetup",
"(",
"this",
")",
";",
"setupDelivery",
"(",
"this",
")",
";",
"}",
"}"
] | The constructor for Panopticon. Handles the differences between master and worker processes.
Please refer to the README for more information.
@param {Object} options The configuration object.
@param {Number} options.startTime Time in ms elapsed since 1 January 1970 00:00:00 UTC.
@param {String} options.name The name of the panopticon being constructed.
@param {Number} options.interval Interval time in milliseconds.
@param {Number} [options.scaleFactor] 1 -> kHz, 1000 -> Hz. If no positive finite number is
given, defaults to 1.
@param {Boolean} [options.persist] Keep a logger once initialized. Each interval reset it.
@param {Function} [options.transformer] A custom function to transform data before merging with
the aggregate.
@constructor
@extends EventEmitter
@alias module:Panopticon | [
"The",
"constructor",
"for",
"Panopticon",
".",
"Handles",
"the",
"differences",
"between",
"master",
"and",
"worker",
"processes",
".",
"Please",
"refer",
"to",
"the",
"README",
"for",
"more",
"information",
"."
] | e0d660cd5287b45aafdb5a91e54affa7364b14e0 | https://github.com/Wizcorp/panopticon/blob/e0d660cd5287b45aafdb5a91e54affa7364b14e0/index.js#L48-L71 |
51,540 | killmenot/jasmine-spy-matchers | lib/mixins/CallTracker.js | function(index) {
var calls = this.all();
var call = calls[index];
return call ? call.object : null;
} | javascript | function(index) {
var calls = this.all();
var call = calls[index];
return call ? call.object : null;
} | [
"function",
"(",
"index",
")",
"{",
"var",
"calls",
"=",
"this",
".",
"all",
"(",
")",
";",
"var",
"call",
"=",
"calls",
"[",
"index",
"]",
";",
"return",
"call",
"?",
"call",
".",
"object",
":",
"null",
";",
"}"
] | Get the this that were passed to a specific invocation of this spy.
@name Spy#calls#thisArgFor
@function
@param {Integer} index The 0-based invocation index.
@return {Object} | [
"Get",
"the",
"this",
"that",
"were",
"passed",
"to",
"a",
"specific",
"invocation",
"of",
"this",
"spy",
"."
] | dc1ad0988220bbc2cfb44eaabc3473a00145c2a2 | https://github.com/killmenot/jasmine-spy-matchers/blob/dc1ad0988220bbc2cfb44eaabc3473a00145c2a2/lib/mixins/CallTracker.js#L13-L18 |
|
51,541 | viatsyshyn/emp.ria | syntax/tokenizer.js | isBuildInType | function isBuildInType(type) {
return type === Function
|| type === String
|| type === Boolean
|| type === Number
|| type === RegExp
|| type === Object
|| type === Array
|| type === Date
} | javascript | function isBuildInType(type) {
return type === Function
|| type === String
|| type === Boolean
|| type === Number
|| type === RegExp
|| type === Object
|| type === Array
|| type === Date
} | [
"function",
"isBuildInType",
"(",
"type",
")",
"{",
"return",
"type",
"===",
"Function",
"||",
"type",
"===",
"String",
"||",
"type",
"===",
"Boolean",
"||",
"type",
"===",
"Number",
"||",
"type",
"===",
"RegExp",
"||",
"type",
"===",
"Object",
"||",
"type",
"===",
"Array",
"||",
"type",
"===",
"Date",
"}"
] | Checks if type is native js constructor
@param {*} type
@return {Boolean} | [
"Checks",
"if",
"type",
"is",
"native",
"js",
"constructor"
] | 59286e792748a69fc463597e082daf7873529fae | https://github.com/viatsyshyn/emp.ria/blob/59286e792748a69fc463597e082daf7873529fae/syntax/tokenizer.js#L12-L21 |
51,542 | viatsyshyn/emp.ria | syntax/tokenizer.js | isCustomType | function isCustomType(type) {
return ria.__API.isClassConstructor(type)
|| ria.__API.isInterface(type)
|| ria.__API.isEnum(type)
|| ria.__API.isIdentifier(type)
|| ria.__API.isDelegate(type)
|| ria.__API.isSpecification(type);
//|| ArrayOfDescriptor.isArrayOfDescriptor(type)
;
} | javascript | function isCustomType(type) {
return ria.__API.isClassConstructor(type)
|| ria.__API.isInterface(type)
|| ria.__API.isEnum(type)
|| ria.__API.isIdentifier(type)
|| ria.__API.isDelegate(type)
|| ria.__API.isSpecification(type);
//|| ArrayOfDescriptor.isArrayOfDescriptor(type)
;
} | [
"function",
"isCustomType",
"(",
"type",
")",
"{",
"return",
"ria",
".",
"__API",
".",
"isClassConstructor",
"(",
"type",
")",
"||",
"ria",
".",
"__API",
".",
"isInterface",
"(",
"type",
")",
"||",
"ria",
".",
"__API",
".",
"isEnum",
"(",
"type",
")",
"||",
"ria",
".",
"__API",
".",
"isIdentifier",
"(",
"type",
")",
"||",
"ria",
".",
"__API",
".",
"isDelegate",
"(",
"type",
")",
"||",
"ria",
".",
"__API",
".",
"isSpecification",
"(",
"type",
")",
";",
"//|| ArrayOfDescriptor.isArrayOfDescriptor(type)",
";",
"}"
] | Checks if type is ria enabled custom constructor
@param {*} type
@return {Boolean} | [
"Checks",
"if",
"type",
"is",
"ria",
"enabled",
"custom",
"constructor"
] | 59286e792748a69fc463597e082daf7873529fae | https://github.com/viatsyshyn/emp.ria/blob/59286e792748a69fc463597e082daf7873529fae/syntax/tokenizer.js#L28-L37 |
51,543 | aaronmccall/ampersand-model-patch-mixin | lib/utils.js | smartIndexOf | function smartIndexOf(array, test) {
var index = -1;
if (!array || !test) return index;
var length = array.length;
if (!length) return index;
while (++index < length) {
if (test(array[index], index, array)) return index;
}
return -1;
} | javascript | function smartIndexOf(array, test) {
var index = -1;
if (!array || !test) return index;
var length = array.length;
if (!length) return index;
while (++index < length) {
if (test(array[index], index, array)) return index;
}
return -1;
} | [
"function",
"smartIndexOf",
"(",
"array",
",",
"test",
")",
"{",
"var",
"index",
"=",
"-",
"1",
";",
"if",
"(",
"!",
"array",
"||",
"!",
"test",
")",
"return",
"index",
";",
"var",
"length",
"=",
"array",
".",
"length",
";",
"if",
"(",
"!",
"length",
")",
"return",
"index",
";",
"while",
"(",
"++",
"index",
"<",
"length",
")",
"{",
"if",
"(",
"test",
"(",
"array",
"[",
"index",
"]",
",",
"index",
",",
"array",
")",
")",
"return",
"index",
";",
"}",
"return",
"-",
"1",
";",
"}"
] | Find index of array member that passes test | [
"Find",
"index",
"of",
"array",
"member",
"that",
"passes",
"test"
] | 28dd7797a306dcaa79d2eefdf904a4bb4fbdebbc | https://github.com/aaronmccall/ampersand-model-patch-mixin/blob/28dd7797a306dcaa79d2eefdf904a4bb4fbdebbc/lib/utils.js#L2-L11 |
51,544 | aaronmccall/ampersand-model-patch-mixin | lib/utils.js | indexById | function indexById(array, id) {
if (!array) return -1;
return smartIndexOf(array, function (obj) {
return obj.id === id;
});
} | javascript | function indexById(array, id) {
if (!array) return -1;
return smartIndexOf(array, function (obj) {
return obj.id === id;
});
} | [
"function",
"indexById",
"(",
"array",
",",
"id",
")",
"{",
"if",
"(",
"!",
"array",
")",
"return",
"-",
"1",
";",
"return",
"smartIndexOf",
"(",
"array",
",",
"function",
"(",
"obj",
")",
"{",
"return",
"obj",
".",
"id",
"===",
"id",
";",
"}",
")",
";",
"}"
] | Returns index of object with matching id property | [
"Returns",
"index",
"of",
"object",
"with",
"matching",
"id",
"property"
] | 28dd7797a306dcaa79d2eefdf904a4bb4fbdebbc | https://github.com/aaronmccall/ampersand-model-patch-mixin/blob/28dd7797a306dcaa79d2eefdf904a4bb4fbdebbc/lib/utils.js#L15-L20 |
51,545 | gtuk/tvmaze-api | tvmaze.js | querySearch | function querySearch( query, single, embed, callback ) {
var embd = '';
if ( single ) {
for ( var key in embed ) {
if ( embed.hasOwnProperty(key) ) {
embd += '&embed[]=' + embed[key];
}
}
}
var url = apiBaseUrl + ( single ? endpoints['query']['single'] : endpoints['query']['multi'] ) + query + embd;
fetch(url, function(result) {
callback(result);
});
} | javascript | function querySearch( query, single, embed, callback ) {
var embd = '';
if ( single ) {
for ( var key in embed ) {
if ( embed.hasOwnProperty(key) ) {
embd += '&embed[]=' + embed[key];
}
}
}
var url = apiBaseUrl + ( single ? endpoints['query']['single'] : endpoints['query']['multi'] ) + query + embd;
fetch(url, function(result) {
callback(result);
});
} | [
"function",
"querySearch",
"(",
"query",
",",
"single",
",",
"embed",
",",
"callback",
")",
"{",
"var",
"embd",
"=",
"''",
";",
"if",
"(",
"single",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"embed",
")",
"{",
"if",
"(",
"embed",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"embd",
"+=",
"'&embed[]='",
"+",
"embed",
"[",
"key",
"]",
";",
"}",
"}",
"}",
"var",
"url",
"=",
"apiBaseUrl",
"+",
"(",
"single",
"?",
"endpoints",
"[",
"'query'",
"]",
"[",
"'single'",
"]",
":",
"endpoints",
"[",
"'query'",
"]",
"[",
"'multi'",
"]",
")",
"+",
"query",
"+",
"embd",
";",
"fetch",
"(",
"url",
",",
"function",
"(",
"result",
")",
"{",
"callback",
"(",
"result",
")",
";",
"}",
")",
";",
"}"
] | Search by query string
@param query
@param single
@param embed
@param callback | [
"Search",
"by",
"query",
"string"
] | 94597b17ac5ce84846e3348e0c557f7be106d8c4 | https://github.com/gtuk/tvmaze-api/blob/94597b17ac5ce84846e3348e0c557f7be106d8c4/tvmaze.js#L29-L44 |
51,546 | gtuk/tvmaze-api | tvmaze.js | idSearch | function idSearch( id, type, callback ) {
if ( ! endpoints['id'].hasOwnProperty(type) ) {
return callback(new Error('No valid type'));
}
var url = apiBaseUrl+endpoints['id'][type] + id;
fetch(url, function(result) {
callback(result);
});
} | javascript | function idSearch( id, type, callback ) {
if ( ! endpoints['id'].hasOwnProperty(type) ) {
return callback(new Error('No valid type'));
}
var url = apiBaseUrl+endpoints['id'][type] + id;
fetch(url, function(result) {
callback(result);
});
} | [
"function",
"idSearch",
"(",
"id",
",",
"type",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"endpoints",
"[",
"'id'",
"]",
".",
"hasOwnProperty",
"(",
"type",
")",
")",
"{",
"return",
"callback",
"(",
"new",
"Error",
"(",
"'No valid type'",
")",
")",
";",
"}",
"var",
"url",
"=",
"apiBaseUrl",
"+",
"endpoints",
"[",
"'id'",
"]",
"[",
"type",
"]",
"+",
"id",
";",
"fetch",
"(",
"url",
",",
"function",
"(",
"result",
")",
"{",
"callback",
"(",
"result",
")",
";",
"}",
")",
";",
"}"
] | Search by imdb, tvrage or tvdb id
@param id
@param type
@param callback | [
"Search",
"by",
"imdb",
"tvrage",
"or",
"tvdb",
"id"
] | 94597b17ac5ce84846e3348e0c557f7be106d8c4 | https://github.com/gtuk/tvmaze-api/blob/94597b17ac5ce84846e3348e0c557f7be106d8c4/tvmaze.js#L53-L63 |
51,547 | gtuk/tvmaze-api | tvmaze.js | showSearch | function showSearch( id, embed, callback ) {
var embd = '';
for ( var key in embed ) {
if ( embed.hasOwnProperty(key) ) {
embd += ( 0 == key ? '?' : '&' ) + 'embed[]=' + embed[key];
}
}
var url = apiBaseUrl+endpoints['show'] + id + embd;
fetch(url, function(result) {
callback(result);
});
} | javascript | function showSearch( id, embed, callback ) {
var embd = '';
for ( var key in embed ) {
if ( embed.hasOwnProperty(key) ) {
embd += ( 0 == key ? '?' : '&' ) + 'embed[]=' + embed[key];
}
}
var url = apiBaseUrl+endpoints['show'] + id + embd;
fetch(url, function(result) {
callback(result);
});
} | [
"function",
"showSearch",
"(",
"id",
",",
"embed",
",",
"callback",
")",
"{",
"var",
"embd",
"=",
"''",
";",
"for",
"(",
"var",
"key",
"in",
"embed",
")",
"{",
"if",
"(",
"embed",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"embd",
"+=",
"(",
"0",
"==",
"key",
"?",
"'?'",
":",
"'&'",
")",
"+",
"'embed[]='",
"+",
"embed",
"[",
"key",
"]",
";",
"}",
"}",
"var",
"url",
"=",
"apiBaseUrl",
"+",
"endpoints",
"[",
"'show'",
"]",
"+",
"id",
"+",
"embd",
";",
"fetch",
"(",
"url",
",",
"function",
"(",
"result",
")",
"{",
"callback",
"(",
"result",
")",
";",
"}",
")",
";",
"}"
] | Get show infos by id
@param id
@param embed
@param callback | [
"Get",
"show",
"infos",
"by",
"id"
] | 94597b17ac5ce84846e3348e0c557f7be106d8c4 | https://github.com/gtuk/tvmaze-api/blob/94597b17ac5ce84846e3348e0c557f7be106d8c4/tvmaze.js#L72-L85 |
51,548 | gtuk/tvmaze-api | tvmaze.js | showPeople | function showPeople( id, callback ) {
var url = apiBaseUrl+endpoints['people'] + id;
fetch(url, function(result) {
callback(result);
});
} | javascript | function showPeople( id, callback ) {
var url = apiBaseUrl+endpoints['people'] + id;
fetch(url, function(result) {
callback(result);
});
} | [
"function",
"showPeople",
"(",
"id",
",",
"callback",
")",
"{",
"var",
"url",
"=",
"apiBaseUrl",
"+",
"endpoints",
"[",
"'people'",
"]",
"+",
"id",
";",
"fetch",
"(",
"url",
",",
"function",
"(",
"result",
")",
"{",
"callback",
"(",
"result",
")",
";",
"}",
")",
";",
"}"
] | Get people main information by id
@param id
@param callback | [
"Get",
"people",
"main",
"information",
"by",
"id"
] | 94597b17ac5ce84846e3348e0c557f7be106d8c4 | https://github.com/gtuk/tvmaze-api/blob/94597b17ac5ce84846e3348e0c557f7be106d8c4/tvmaze.js#L93-L99 |
51,549 | gtuk/tvmaze-api | tvmaze.js | scheduleSearch | function scheduleSearch( country, date, callback ) {
var url = apiBaseUrl+endpoints['schedule'].replace('$1', country).replace('$2', date);
fetch(url, function(result) {
callback(result);
});
} | javascript | function scheduleSearch( country, date, callback ) {
var url = apiBaseUrl+endpoints['schedule'].replace('$1', country).replace('$2', date);
fetch(url, function(result) {
callback(result);
});
} | [
"function",
"scheduleSearch",
"(",
"country",
",",
"date",
",",
"callback",
")",
"{",
"var",
"url",
"=",
"apiBaseUrl",
"+",
"endpoints",
"[",
"'schedule'",
"]",
".",
"replace",
"(",
"'$1'",
",",
"country",
")",
".",
"replace",
"(",
"'$2'",
",",
"date",
")",
";",
"fetch",
"(",
"url",
",",
"function",
"(",
"result",
")",
"{",
"callback",
"(",
"result",
")",
";",
"}",
")",
";",
"}"
] | Search schedule for specific country and date
@param country
@param date
@param callback | [
"Search",
"schedule",
"for",
"specific",
"country",
"and",
"date"
] | 94597b17ac5ce84846e3348e0c557f7be106d8c4 | https://github.com/gtuk/tvmaze-api/blob/94597b17ac5ce84846e3348e0c557f7be106d8c4/tvmaze.js#L108-L114 |
51,550 | gtuk/tvmaze-api | tvmaze.js | fetch | function fetch( url, callback ) {
request({ url: url, json: true }, function( err, resp, data ) {
if (err) {
return callback(err);
}
if ( 200 != resp.statusCode ) {
return callback(new Error(resp.statusMessage));
}
callback(data);
});
} | javascript | function fetch( url, callback ) {
request({ url: url, json: true }, function( err, resp, data ) {
if (err) {
return callback(err);
}
if ( 200 != resp.statusCode ) {
return callback(new Error(resp.statusMessage));
}
callback(data);
});
} | [
"function",
"fetch",
"(",
"url",
",",
"callback",
")",
"{",
"request",
"(",
"{",
"url",
":",
"url",
",",
"json",
":",
"true",
"}",
",",
"function",
"(",
"err",
",",
"resp",
",",
"data",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"callback",
"(",
"err",
")",
";",
"}",
"if",
"(",
"200",
"!=",
"resp",
".",
"statusCode",
")",
"{",
"return",
"callback",
"(",
"new",
"Error",
"(",
"resp",
".",
"statusMessage",
")",
")",
";",
"}",
"callback",
"(",
"data",
")",
";",
"}",
")",
";",
"}"
] | Actual request against the tvmaze api
@param url
@param callback | [
"Actual",
"request",
"against",
"the",
"tvmaze",
"api"
] | 94597b17ac5ce84846e3348e0c557f7be106d8c4 | https://github.com/gtuk/tvmaze-api/blob/94597b17ac5ce84846e3348e0c557f7be106d8c4/tvmaze.js#L122-L134 |
51,551 | tolokoban/ToloFrameWork | lib/context.js | function( packageFilename, options ) {
if( typeof options === 'undefined' ) options = {};
packageFilename = Path.resolve( packageFilename );
if( false == FS.existsSync() )
this.fatal( "Package file not found: \"" + packageFilename + "\"" );
var prjDir = Path.dirname( packageFilename );
this._prjDir = Path.resolve( prjDir );
this._libDir = Path.resolve( Path.join(__dirname, "../ker") );
this._tplDir = Path.resolve( Path.join(__dirname, "../tpl") );
this._srcDir = mkdir.call( this, prjDir, "src" );
this._docDir = mkdir.call( this, prjDir, "doc" );
this._tmpDir = mkdir.call( this, prjDir, "tmp" );
this._wwwDir = mkdir.call( this, prjDir, "www" );
} | javascript | function( packageFilename, options ) {
if( typeof options === 'undefined' ) options = {};
packageFilename = Path.resolve( packageFilename );
if( false == FS.existsSync() )
this.fatal( "Package file not found: \"" + packageFilename + "\"" );
var prjDir = Path.dirname( packageFilename );
this._prjDir = Path.resolve( prjDir );
this._libDir = Path.resolve( Path.join(__dirname, "../ker") );
this._tplDir = Path.resolve( Path.join(__dirname, "../tpl") );
this._srcDir = mkdir.call( this, prjDir, "src" );
this._docDir = mkdir.call( this, prjDir, "doc" );
this._tmpDir = mkdir.call( this, prjDir, "tmp" );
this._wwwDir = mkdir.call( this, prjDir, "www" );
} | [
"function",
"(",
"packageFilename",
",",
"options",
")",
"{",
"if",
"(",
"typeof",
"options",
"===",
"'undefined'",
")",
"options",
"=",
"{",
"}",
";",
"packageFilename",
"=",
"Path",
".",
"resolve",
"(",
"packageFilename",
")",
";",
"if",
"(",
"false",
"==",
"FS",
".",
"existsSync",
"(",
")",
")",
"this",
".",
"fatal",
"(",
"\"Package file not found: \\\"\"",
"+",
"packageFilename",
"+",
"\"\\\"\"",
")",
";",
"var",
"prjDir",
"=",
"Path",
".",
"dirname",
"(",
"packageFilename",
")",
";",
"this",
".",
"_prjDir",
"=",
"Path",
".",
"resolve",
"(",
"prjDir",
")",
";",
"this",
".",
"_libDir",
"=",
"Path",
".",
"resolve",
"(",
"Path",
".",
"join",
"(",
"__dirname",
",",
"\"../ker\"",
")",
")",
";",
"this",
".",
"_tplDir",
"=",
"Path",
".",
"resolve",
"(",
"Path",
".",
"join",
"(",
"__dirname",
",",
"\"../tpl\"",
")",
")",
";",
"this",
".",
"_srcDir",
"=",
"mkdir",
".",
"call",
"(",
"this",
",",
"prjDir",
",",
"\"src\"",
")",
";",
"this",
".",
"_docDir",
"=",
"mkdir",
".",
"call",
"(",
"this",
",",
"prjDir",
",",
"\"doc\"",
")",
";",
"this",
".",
"_tmpDir",
"=",
"mkdir",
".",
"call",
"(",
"this",
",",
"prjDir",
",",
"\"tmp\"",
")",
";",
"this",
".",
"_wwwDir",
"=",
"mkdir",
".",
"call",
"(",
"this",
",",
"prjDir",
",",
"\"www\"",
")",
";",
"}"
] | This is the context of a project. A project is definied by its `package.json` file. | [
"This",
"is",
"the",
"context",
"of",
"a",
"project",
".",
"A",
"project",
"is",
"definied",
"by",
"its",
"package",
".",
"json",
"file",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/context.js#L10-L26 |
|
51,552 | beemo-js/beemo | lib/components/validation/annotations/constraints.js | addAnnotation | function addAnnotation(target, key, index, data) {
const classAnnotationsStore = container.get(AnnotationsServiceName.ClassAnnotationsStore);
if (index === undefined) {
// property
classAnnotationsStore.addPropertyAnnotation(target.constructor, key, Constraints, data);
}
else {
// method parameter
classAnnotationsStore.addMethodParameterAnnotation(target.constructor, key, index, Constraints, data);
}
} | javascript | function addAnnotation(target, key, index, data) {
const classAnnotationsStore = container.get(AnnotationsServiceName.ClassAnnotationsStore);
if (index === undefined) {
// property
classAnnotationsStore.addPropertyAnnotation(target.constructor, key, Constraints, data);
}
else {
// method parameter
classAnnotationsStore.addMethodParameterAnnotation(target.constructor, key, index, Constraints, data);
}
} | [
"function",
"addAnnotation",
"(",
"target",
",",
"key",
",",
"index",
",",
"data",
")",
"{",
"const",
"classAnnotationsStore",
"=",
"container",
".",
"get",
"(",
"AnnotationsServiceName",
".",
"ClassAnnotationsStore",
")",
";",
"if",
"(",
"index",
"===",
"undefined",
")",
"{",
"// property",
"classAnnotationsStore",
".",
"addPropertyAnnotation",
"(",
"target",
".",
"constructor",
",",
"key",
",",
"Constraints",
",",
"data",
")",
";",
"}",
"else",
"{",
"// method parameter",
"classAnnotationsStore",
".",
"addMethodParameterAnnotation",
"(",
"target",
".",
"constructor",
",",
"key",
",",
"index",
",",
"Constraints",
",",
"data",
")",
";",
"}",
"}"
] | Annotation to property or method | [
"Annotation",
"to",
"property",
"or",
"method"
] | b3fb926c03f55803ae49bf730c09ecbbdd78b8b8 | https://github.com/beemo-js/beemo/blob/b3fb926c03f55803ae49bf730c09ecbbdd78b8b8/lib/components/validation/annotations/constraints.js#L5-L15 |
51,553 | derdesign/protos | middleware/static_server/static_server.js | createStaticFileRegex | function createStaticFileRegex() {
var regex = '^\\/(',
staticViews = this.views.static;
// Get directories in public/
var files = getStaticDirs.call(this);
// Iterate over files and append to regex
for (var path, dir, re, i=0; i < files.length; i++) {
dir = files[i];
path = dir.replace(this.regex.startOrEndSlash, '').replace(this.regex.regExpChars, '\\$1');
if (i > 0) path = "|" + path;
regex += path;
}
// Finalize & create regex
regex += ')\\/?';
if (regex == '^\\/()\\/?') {
// No directories found in public/. Invalidate regex
this.staticFileRegex = /^$/;
} else {
// Directories found in public/
this.staticFileRegex = new RegExp(regex);
}
} | javascript | function createStaticFileRegex() {
var regex = '^\\/(',
staticViews = this.views.static;
// Get directories in public/
var files = getStaticDirs.call(this);
// Iterate over files and append to regex
for (var path, dir, re, i=0; i < files.length; i++) {
dir = files[i];
path = dir.replace(this.regex.startOrEndSlash, '').replace(this.regex.regExpChars, '\\$1');
if (i > 0) path = "|" + path;
regex += path;
}
// Finalize & create regex
regex += ')\\/?';
if (regex == '^\\/()\\/?') {
// No directories found in public/. Invalidate regex
this.staticFileRegex = /^$/;
} else {
// Directories found in public/
this.staticFileRegex = new RegExp(regex);
}
} | [
"function",
"createStaticFileRegex",
"(",
")",
"{",
"var",
"regex",
"=",
"'^\\\\/('",
",",
"staticViews",
"=",
"this",
".",
"views",
".",
"static",
";",
"// Get directories in public/",
"var",
"files",
"=",
"getStaticDirs",
".",
"call",
"(",
"this",
")",
";",
"// Iterate over files and append to regex",
"for",
"(",
"var",
"path",
",",
"dir",
",",
"re",
",",
"i",
"=",
"0",
";",
"i",
"<",
"files",
".",
"length",
";",
"i",
"++",
")",
"{",
"dir",
"=",
"files",
"[",
"i",
"]",
";",
"path",
"=",
"dir",
".",
"replace",
"(",
"this",
".",
"regex",
".",
"startOrEndSlash",
",",
"''",
")",
".",
"replace",
"(",
"this",
".",
"regex",
".",
"regExpChars",
",",
"'\\\\$1'",
")",
";",
"if",
"(",
"i",
">",
"0",
")",
"path",
"=",
"\"|\"",
"+",
"path",
";",
"regex",
"+=",
"path",
";",
"}",
"// Finalize & create regex",
"regex",
"+=",
"')\\\\/?'",
";",
"if",
"(",
"regex",
"==",
"'^\\\\/()\\\\/?'",
")",
"{",
"// No directories found in public/. Invalidate regex",
"this",
".",
"staticFileRegex",
"=",
"/",
"^$",
"/",
";",
"}",
"else",
"{",
"// Directories found in public/",
"this",
".",
"staticFileRegex",
"=",
"new",
"RegExp",
"(",
"regex",
")",
";",
"}",
"}"
] | Creates the static file regex
@private | [
"Creates",
"the",
"static",
"file",
"regex"
] | 0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9 | https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/middleware/static_server/static_server.js#L45-L72 |
51,554 | derdesign/protos | middleware/static_server/static_server.js | getStaticDirs | function getStaticDirs() {
var files = fs.readdirSync(this.path + '/' + this.paths.public),
dirs = [];
for (var file, stat, i=0; i < files.length; i++) {
file = files[i];
stat = fs.lstatSync(this.path + '/' + this.paths.public + file);
if ( stat.isDirectory() ) dirs.push(file);
}
return dirs;
} | javascript | function getStaticDirs() {
var files = fs.readdirSync(this.path + '/' + this.paths.public),
dirs = [];
for (var file, stat, i=0; i < files.length; i++) {
file = files[i];
stat = fs.lstatSync(this.path + '/' + this.paths.public + file);
if ( stat.isDirectory() ) dirs.push(file);
}
return dirs;
} | [
"function",
"getStaticDirs",
"(",
")",
"{",
"var",
"files",
"=",
"fs",
".",
"readdirSync",
"(",
"this",
".",
"path",
"+",
"'/'",
"+",
"this",
".",
"paths",
".",
"public",
")",
",",
"dirs",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"file",
",",
"stat",
",",
"i",
"=",
"0",
";",
"i",
"<",
"files",
".",
"length",
";",
"i",
"++",
")",
"{",
"file",
"=",
"files",
"[",
"i",
"]",
";",
"stat",
"=",
"fs",
".",
"lstatSync",
"(",
"this",
".",
"path",
"+",
"'/'",
"+",
"this",
".",
"paths",
".",
"public",
"+",
"file",
")",
";",
"if",
"(",
"stat",
".",
"isDirectory",
"(",
")",
")",
"dirs",
".",
"push",
"(",
"file",
")",
";",
"}",
"return",
"dirs",
";",
"}"
] | Gets the static directories available in the application's public
@returns {array}
@private | [
"Gets",
"the",
"static",
"directories",
"available",
"in",
"the",
"application",
"s",
"public"
] | 0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9 | https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/middleware/static_server/static_server.js#L81-L90 |
51,555 | byron-dupreez/aws-stream-consumer-core | sequencing.js | sequenceMessages | function sequenceMessages(batch, context) {
const states = batch.states;
const messages = batch.messages;
if (messages.length < 2 || !context.streamProcessing.sequencingRequired) {
return messages;
}
// First prepare the messages for sequencing by normalizing all of the messages' sequence numbers
prepareMessagesForSequencing(messages, states, context);
const firstMessagesToProcess = [];
const sequencingPerKey = context.streamProcessing.sequencingPerKey;
const comparator = sequencingPerKey ?
(m1, m2) => compareSameKeyMessages(m1, m2, states, context):
(m1, m2) => compareAnyKeyMessages(m1, m2, states, context);
// Group all of the messages by the stringified versions of their keys (to avoid strict equal failures)
const messagesByKeyString = sequencingPerKey ?
groupBy(messages, msg => {
const msgState = states.get(msg);
const keys = msgState.keys;
return keys && keys.length > 0 ? msgState.key : '?';
}) : {'*': messages};
// Sort all of the messages that share the same keys by their sequence numbers and then link them to each other via
// their prevMessage and nextMessage state properties
const keyStrings = Object.getOwnPropertyNames(messagesByKeyString);
for (let i = 0; i < keyStrings.length; ++i) {
const keyString = keyStrings[i];
const msgs = messagesByKeyString[keyString];
if (context.traceEnabled && msgs.length > 1) context.trace(`BEFORE sorting (${keyString}): ${stringify(msgs.map(m => states.get(m).seqNo))}`);
msgs.sort(comparator);
if (context.traceEnabled) context.trace(` AFTER sorting (${keyString}): ${stringify(msgs.map(m => states.get(m).seqNo))}`);
let prevMessage = undefined;
let prevMessageState = undefined;
firstMessagesToProcess.push(msgs[0]);
for (let m = 0; m < msgs.length; ++m) {
const nextMessage = msgs[m];
const nextMessageState = states.get(nextMessage);
setPrevMessage(nextMessageState, prevMessage);
if (prevMessageState) {
setNextMessage(prevMessageState, nextMessage);
}
prevMessage = nextMessage;
prevMessageState = nextMessageState;
}
if (prevMessageState) {
setNextMessage(prevMessageState, undefined);
}
}
if (context.debugEnabled) {
const firstMessagesDetails = firstMessagesToProcess.map(m => `(${getMessageStateKeySeqNoId(states.get(m))})`).join(", ");
context.debug(`Finished sequencing messages - found ${firstMessagesToProcess.length} first message${firstMessagesToProcess.length !== 1 ? 's' : ''} to process out of ${messages.length} message${messages.length !== 1 ? 's' : ''} - first [${firstMessagesDetails}]`);
}
return firstMessagesToProcess;
} | javascript | function sequenceMessages(batch, context) {
const states = batch.states;
const messages = batch.messages;
if (messages.length < 2 || !context.streamProcessing.sequencingRequired) {
return messages;
}
// First prepare the messages for sequencing by normalizing all of the messages' sequence numbers
prepareMessagesForSequencing(messages, states, context);
const firstMessagesToProcess = [];
const sequencingPerKey = context.streamProcessing.sequencingPerKey;
const comparator = sequencingPerKey ?
(m1, m2) => compareSameKeyMessages(m1, m2, states, context):
(m1, m2) => compareAnyKeyMessages(m1, m2, states, context);
// Group all of the messages by the stringified versions of their keys (to avoid strict equal failures)
const messagesByKeyString = sequencingPerKey ?
groupBy(messages, msg => {
const msgState = states.get(msg);
const keys = msgState.keys;
return keys && keys.length > 0 ? msgState.key : '?';
}) : {'*': messages};
// Sort all of the messages that share the same keys by their sequence numbers and then link them to each other via
// their prevMessage and nextMessage state properties
const keyStrings = Object.getOwnPropertyNames(messagesByKeyString);
for (let i = 0; i < keyStrings.length; ++i) {
const keyString = keyStrings[i];
const msgs = messagesByKeyString[keyString];
if (context.traceEnabled && msgs.length > 1) context.trace(`BEFORE sorting (${keyString}): ${stringify(msgs.map(m => states.get(m).seqNo))}`);
msgs.sort(comparator);
if (context.traceEnabled) context.trace(` AFTER sorting (${keyString}): ${stringify(msgs.map(m => states.get(m).seqNo))}`);
let prevMessage = undefined;
let prevMessageState = undefined;
firstMessagesToProcess.push(msgs[0]);
for (let m = 0; m < msgs.length; ++m) {
const nextMessage = msgs[m];
const nextMessageState = states.get(nextMessage);
setPrevMessage(nextMessageState, prevMessage);
if (prevMessageState) {
setNextMessage(prevMessageState, nextMessage);
}
prevMessage = nextMessage;
prevMessageState = nextMessageState;
}
if (prevMessageState) {
setNextMessage(prevMessageState, undefined);
}
}
if (context.debugEnabled) {
const firstMessagesDetails = firstMessagesToProcess.map(m => `(${getMessageStateKeySeqNoId(states.get(m))})`).join(", ");
context.debug(`Finished sequencing messages - found ${firstMessagesToProcess.length} first message${firstMessagesToProcess.length !== 1 ? 's' : ''} to process out of ${messages.length} message${messages.length !== 1 ? 's' : ''} - first [${firstMessagesDetails}]`);
}
return firstMessagesToProcess;
} | [
"function",
"sequenceMessages",
"(",
"batch",
",",
"context",
")",
"{",
"const",
"states",
"=",
"batch",
".",
"states",
";",
"const",
"messages",
"=",
"batch",
".",
"messages",
";",
"if",
"(",
"messages",
".",
"length",
"<",
"2",
"||",
"!",
"context",
".",
"streamProcessing",
".",
"sequencingRequired",
")",
"{",
"return",
"messages",
";",
"}",
"// First prepare the messages for sequencing by normalizing all of the messages' sequence numbers",
"prepareMessagesForSequencing",
"(",
"messages",
",",
"states",
",",
"context",
")",
";",
"const",
"firstMessagesToProcess",
"=",
"[",
"]",
";",
"const",
"sequencingPerKey",
"=",
"context",
".",
"streamProcessing",
".",
"sequencingPerKey",
";",
"const",
"comparator",
"=",
"sequencingPerKey",
"?",
"(",
"m1",
",",
"m2",
")",
"=>",
"compareSameKeyMessages",
"(",
"m1",
",",
"m2",
",",
"states",
",",
"context",
")",
":",
"(",
"m1",
",",
"m2",
")",
"=>",
"compareAnyKeyMessages",
"(",
"m1",
",",
"m2",
",",
"states",
",",
"context",
")",
";",
"// Group all of the messages by the stringified versions of their keys (to avoid strict equal failures)",
"const",
"messagesByKeyString",
"=",
"sequencingPerKey",
"?",
"groupBy",
"(",
"messages",
",",
"msg",
"=>",
"{",
"const",
"msgState",
"=",
"states",
".",
"get",
"(",
"msg",
")",
";",
"const",
"keys",
"=",
"msgState",
".",
"keys",
";",
"return",
"keys",
"&&",
"keys",
".",
"length",
">",
"0",
"?",
"msgState",
".",
"key",
":",
"'?'",
";",
"}",
")",
":",
"{",
"'*'",
":",
"messages",
"}",
";",
"// Sort all of the messages that share the same keys by their sequence numbers and then link them to each other via",
"// their prevMessage and nextMessage state properties",
"const",
"keyStrings",
"=",
"Object",
".",
"getOwnPropertyNames",
"(",
"messagesByKeyString",
")",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"keyStrings",
".",
"length",
";",
"++",
"i",
")",
"{",
"const",
"keyString",
"=",
"keyStrings",
"[",
"i",
"]",
";",
"const",
"msgs",
"=",
"messagesByKeyString",
"[",
"keyString",
"]",
";",
"if",
"(",
"context",
".",
"traceEnabled",
"&&",
"msgs",
".",
"length",
">",
"1",
")",
"context",
".",
"trace",
"(",
"`",
"${",
"keyString",
"}",
"${",
"stringify",
"(",
"msgs",
".",
"map",
"(",
"m",
"=>",
"states",
".",
"get",
"(",
"m",
")",
".",
"seqNo",
")",
")",
"}",
"`",
")",
";",
"msgs",
".",
"sort",
"(",
"comparator",
")",
";",
"if",
"(",
"context",
".",
"traceEnabled",
")",
"context",
".",
"trace",
"(",
"`",
"${",
"keyString",
"}",
"${",
"stringify",
"(",
"msgs",
".",
"map",
"(",
"m",
"=>",
"states",
".",
"get",
"(",
"m",
")",
".",
"seqNo",
")",
")",
"}",
"`",
")",
";",
"let",
"prevMessage",
"=",
"undefined",
";",
"let",
"prevMessageState",
"=",
"undefined",
";",
"firstMessagesToProcess",
".",
"push",
"(",
"msgs",
"[",
"0",
"]",
")",
";",
"for",
"(",
"let",
"m",
"=",
"0",
";",
"m",
"<",
"msgs",
".",
"length",
";",
"++",
"m",
")",
"{",
"const",
"nextMessage",
"=",
"msgs",
"[",
"m",
"]",
";",
"const",
"nextMessageState",
"=",
"states",
".",
"get",
"(",
"nextMessage",
")",
";",
"setPrevMessage",
"(",
"nextMessageState",
",",
"prevMessage",
")",
";",
"if",
"(",
"prevMessageState",
")",
"{",
"setNextMessage",
"(",
"prevMessageState",
",",
"nextMessage",
")",
";",
"}",
"prevMessage",
"=",
"nextMessage",
";",
"prevMessageState",
"=",
"nextMessageState",
";",
"}",
"if",
"(",
"prevMessageState",
")",
"{",
"setNextMessage",
"(",
"prevMessageState",
",",
"undefined",
")",
";",
"}",
"}",
"if",
"(",
"context",
".",
"debugEnabled",
")",
"{",
"const",
"firstMessagesDetails",
"=",
"firstMessagesToProcess",
".",
"map",
"(",
"m",
"=>",
"`",
"${",
"getMessageStateKeySeqNoId",
"(",
"states",
".",
"get",
"(",
"m",
")",
")",
"}",
"`",
")",
".",
"join",
"(",
"\", \"",
")",
";",
"context",
".",
"debug",
"(",
"`",
"${",
"firstMessagesToProcess",
".",
"length",
"}",
"${",
"firstMessagesToProcess",
".",
"length",
"!==",
"1",
"?",
"'s'",
":",
"''",
"}",
"${",
"messages",
".",
"length",
"}",
"${",
"messages",
".",
"length",
"!==",
"1",
"?",
"'s'",
":",
"''",
"}",
"${",
"firstMessagesDetails",
"}",
"`",
")",
";",
"}",
"return",
"firstMessagesToProcess",
";",
"}"
] | Sequences the given entire batch of messages by linking messages with the same keys to each other via their
nextMessage and prevMessage properties in sequences determined by their sequence numbers.
@param {Batch} batch - the batch containing the messages to be sequenced
@param {StreamConsumerContext} context - the context to use
@returns {Message[]} the first messages to be processed (i.e. all of the messages that do NOT have a defined prevMessage | [
"Sequences",
"the",
"given",
"entire",
"batch",
"of",
"messages",
"by",
"linking",
"messages",
"with",
"the",
"same",
"keys",
"to",
"each",
"other",
"via",
"their",
"nextMessage",
"and",
"prevMessage",
"properties",
"in",
"sequences",
"determined",
"by",
"their",
"sequence",
"numbers",
"."
] | 9b256084297f80d373bcf483aaf68a9da176b3d7 | https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/sequencing.js#L283-L351 |
51,556 | Frederikbh/tickspotv2-api | lib/service.js | getAuthorization | function getAuthorization(user, auth) {
if (auth === AUTH_BASIC) {
return 'Basic ' + btoa(user.username + ':' + user.password);
} else if (auth === AUTH_TOKEN) {
return 'Token token=' + user.token;
}
} | javascript | function getAuthorization(user, auth) {
if (auth === AUTH_BASIC) {
return 'Basic ' + btoa(user.username + ':' + user.password);
} else if (auth === AUTH_TOKEN) {
return 'Token token=' + user.token;
}
} | [
"function",
"getAuthorization",
"(",
"user",
",",
"auth",
")",
"{",
"if",
"(",
"auth",
"===",
"AUTH_BASIC",
")",
"{",
"return",
"'Basic '",
"+",
"btoa",
"(",
"user",
".",
"username",
"+",
"':'",
"+",
"user",
".",
"password",
")",
";",
"}",
"else",
"if",
"(",
"auth",
"===",
"AUTH_TOKEN",
")",
"{",
"return",
"'Token token='",
"+",
"user",
".",
"token",
";",
"}",
"}"
] | Gets the correctly formatted authorization header | [
"Gets",
"the",
"correctly",
"formatted",
"authorization",
"header"
] | 07fb0cdf62e9eb9cb05f74be07130c7472b2bf84 | https://github.com/Frederikbh/tickspotv2-api/blob/07fb0cdf62e9eb9cb05f74be07130c7472b2bf84/lib/service.js#L10-L16 |
51,557 | Frederikbh/tickspotv2-api | lib/service.js | getParams | function getParams(user, auth, url, options, headers) {
return _.extend({
url: url,
headers: _.extend({
'User-Agent': user.userAgent,
'Authorization': getAuthorization(user, auth)
}, headers)
}, options);
} | javascript | function getParams(user, auth, url, options, headers) {
return _.extend({
url: url,
headers: _.extend({
'User-Agent': user.userAgent,
'Authorization': getAuthorization(user, auth)
}, headers)
}, options);
} | [
"function",
"getParams",
"(",
"user",
",",
"auth",
",",
"url",
",",
"options",
",",
"headers",
")",
"{",
"return",
"_",
".",
"extend",
"(",
"{",
"url",
":",
"url",
",",
"headers",
":",
"_",
".",
"extend",
"(",
"{",
"'User-Agent'",
":",
"user",
".",
"userAgent",
",",
"'Authorization'",
":",
"getAuthorization",
"(",
"user",
",",
"auth",
")",
"}",
",",
"headers",
")",
"}",
",",
"options",
")",
";",
"}"
] | Creates the params object for the request | [
"Creates",
"the",
"params",
"object",
"for",
"the",
"request"
] | 07fb0cdf62e9eb9cb05f74be07130c7472b2bf84 | https://github.com/Frederikbh/tickspotv2-api/blob/07fb0cdf62e9eb9cb05f74be07130c7472b2bf84/lib/service.js#L19-L27 |
51,558 | Frederikbh/tickspotv2-api | lib/service.js | makeRequest | function makeRequest(user, auth, url, cb, options = {}, headers = {}) {
const params = getParams(user, auth, url, options, headers);
const promise = new Promise((resolve, reject) => {
request(params, (err, response, body) => {
if (!err && [200, 201, 204, 301].indexOf(response.statusCode) > -1) {
const result = _.isString(body) ? JSON.parse(body) : body;
return resolve([undefined, result]);
} else {
if (cb) {
return resolve([err || body]);
}
return reject([err || body]);
}
});
});
return handleCallback(promise, cb);
} | javascript | function makeRequest(user, auth, url, cb, options = {}, headers = {}) {
const params = getParams(user, auth, url, options, headers);
const promise = new Promise((resolve, reject) => {
request(params, (err, response, body) => {
if (!err && [200, 201, 204, 301].indexOf(response.statusCode) > -1) {
const result = _.isString(body) ? JSON.parse(body) : body;
return resolve([undefined, result]);
} else {
if (cb) {
return resolve([err || body]);
}
return reject([err || body]);
}
});
});
return handleCallback(promise, cb);
} | [
"function",
"makeRequest",
"(",
"user",
",",
"auth",
",",
"url",
",",
"cb",
",",
"options",
"=",
"{",
"}",
",",
"headers",
"=",
"{",
"}",
")",
"{",
"const",
"params",
"=",
"getParams",
"(",
"user",
",",
"auth",
",",
"url",
",",
"options",
",",
"headers",
")",
";",
"const",
"promise",
"=",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"request",
"(",
"params",
",",
"(",
"err",
",",
"response",
",",
"body",
")",
"=>",
"{",
"if",
"(",
"!",
"err",
"&&",
"[",
"200",
",",
"201",
",",
"204",
",",
"301",
"]",
".",
"indexOf",
"(",
"response",
".",
"statusCode",
")",
">",
"-",
"1",
")",
"{",
"const",
"result",
"=",
"_",
".",
"isString",
"(",
"body",
")",
"?",
"JSON",
".",
"parse",
"(",
"body",
")",
":",
"body",
";",
"return",
"resolve",
"(",
"[",
"undefined",
",",
"result",
"]",
")",
";",
"}",
"else",
"{",
"if",
"(",
"cb",
")",
"{",
"return",
"resolve",
"(",
"[",
"err",
"||",
"body",
"]",
")",
";",
"}",
"return",
"reject",
"(",
"[",
"err",
"||",
"body",
"]",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"return",
"handleCallback",
"(",
"promise",
",",
"cb",
")",
";",
"}"
] | Makes the http request | [
"Makes",
"the",
"http",
"request"
] | 07fb0cdf62e9eb9cb05f74be07130c7472b2bf84 | https://github.com/Frederikbh/tickspotv2-api/blob/07fb0cdf62e9eb9cb05f74be07130c7472b2bf84/lib/service.js#L30-L47 |
51,559 | Frederikbh/tickspotv2-api | lib/service.js | extractHeaders | function extractHeaders(options) {
let headers = {};
if (options && options.headers) {
headers = options.headers;
delete options.headers;
}
return headers;
} | javascript | function extractHeaders(options) {
let headers = {};
if (options && options.headers) {
headers = options.headers;
delete options.headers;
}
return headers;
} | [
"function",
"extractHeaders",
"(",
"options",
")",
"{",
"let",
"headers",
"=",
"{",
"}",
";",
"if",
"(",
"options",
"&&",
"options",
".",
"headers",
")",
"{",
"headers",
"=",
"options",
".",
"headers",
";",
"delete",
"options",
".",
"headers",
";",
"}",
"return",
"headers",
";",
"}"
] | Extract headers from options object | [
"Extract",
"headers",
"from",
"options",
"object"
] | 07fb0cdf62e9eb9cb05f74be07130c7472b2bf84 | https://github.com/Frederikbh/tickspotv2-api/blob/07fb0cdf62e9eb9cb05f74be07130c7472b2bf84/lib/service.js#L64-L71 |
51,560 | Frederikbh/tickspotv2-api | lib/service.js | parseArguments | function parseArguments(options, callback) {
if (_.isUndefined(options) && _.isUndefined(callback)) { // No params
return [{}, undefined];
}
if (!_.isUndefined(options) && _.isFunction(options)) { // Only callback param
callback = options;
options = {};
}
return [options, callback]; // Both params
} | javascript | function parseArguments(options, callback) {
if (_.isUndefined(options) && _.isUndefined(callback)) { // No params
return [{}, undefined];
}
if (!_.isUndefined(options) && _.isFunction(options)) { // Only callback param
callback = options;
options = {};
}
return [options, callback]; // Both params
} | [
"function",
"parseArguments",
"(",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"_",
".",
"isUndefined",
"(",
"options",
")",
"&&",
"_",
".",
"isUndefined",
"(",
"callback",
")",
")",
"{",
"// No params",
"return",
"[",
"{",
"}",
",",
"undefined",
"]",
";",
"}",
"if",
"(",
"!",
"_",
".",
"isUndefined",
"(",
"options",
")",
"&&",
"_",
".",
"isFunction",
"(",
"options",
")",
")",
"{",
"// Only callback param",
"callback",
"=",
"options",
";",
"options",
"=",
"{",
"}",
";",
"}",
"return",
"[",
"options",
",",
"callback",
"]",
";",
"// Both params",
"}"
] | Parses arguments provided, makes it possible to only apply a callback function | [
"Parses",
"arguments",
"provided",
"makes",
"it",
"possible",
"to",
"only",
"apply",
"a",
"callback",
"function"
] | 07fb0cdf62e9eb9cb05f74be07130c7472b2bf84 | https://github.com/Frederikbh/tickspotv2-api/blob/07fb0cdf62e9eb9cb05f74be07130c7472b2bf84/lib/service.js#L74-L83 |
51,561 | Frederikbh/tickspotv2-api | lib/service.js | http | function http(tick, args) {
let url = 'https://www.tickspot.com/' + tick.subscriptionID + '/api/v2/';
url += args.paths.join('/') + '.json';
if (args.query) {
url += '?';
url += _.pairs(args.query).map(p => p.join('=')).join('&');
}
return url;
} | javascript | function http(tick, args) {
let url = 'https://www.tickspot.com/' + tick.subscriptionID + '/api/v2/';
url += args.paths.join('/') + '.json';
if (args.query) {
url += '?';
url += _.pairs(args.query).map(p => p.join('=')).join('&');
}
return url;
} | [
"function",
"http",
"(",
"tick",
",",
"args",
")",
"{",
"let",
"url",
"=",
"'https://www.tickspot.com/'",
"+",
"tick",
".",
"subscriptionID",
"+",
"'/api/v2/'",
";",
"url",
"+=",
"args",
".",
"paths",
".",
"join",
"(",
"'/'",
")",
"+",
"'.json'",
";",
"if",
"(",
"args",
".",
"query",
")",
"{",
"url",
"+=",
"'?'",
";",
"url",
"+=",
"_",
".",
"pairs",
"(",
"args",
".",
"query",
")",
".",
"map",
"(",
"p",
"=>",
"p",
".",
"join",
"(",
"'='",
")",
")",
".",
"join",
"(",
"'&'",
")",
";",
"}",
"return",
"url",
";",
"}"
] | Formats the url | [
"Formats",
"the",
"url"
] | 07fb0cdf62e9eb9cb05f74be07130c7472b2bf84 | https://github.com/Frederikbh/tickspotv2-api/blob/07fb0cdf62e9eb9cb05f74be07130c7472b2bf84/lib/service.js#L86-L95 |
51,562 | Frederikbh/tickspotv2-api | lib/service.js | extractPage | function extractPage(options) {
let page = 1;
if (options && options.page) {
page = options.page;
delete options.page;
}
return page;
} | javascript | function extractPage(options) {
let page = 1;
if (options && options.page) {
page = options.page;
delete options.page;
}
return page;
} | [
"function",
"extractPage",
"(",
"options",
")",
"{",
"let",
"page",
"=",
"1",
";",
"if",
"(",
"options",
"&&",
"options",
".",
"page",
")",
"{",
"page",
"=",
"options",
".",
"page",
";",
"delete",
"options",
".",
"page",
";",
"}",
"return",
"page",
";",
"}"
] | Extracts page from options | [
"Extracts",
"page",
"from",
"options"
] | 07fb0cdf62e9eb9cb05f74be07130c7472b2bf84 | https://github.com/Frederikbh/tickspotv2-api/blob/07fb0cdf62e9eb9cb05f74be07130c7472b2bf84/lib/service.js#L98-L105 |
51,563 | derdesign/protos | middleware/cookie_parser/application.js | parseCookie | function parseCookie(str) {
var obj = {},
pairs = str.split(/[;,] */);
for (var pair,eqlIndex,key,val,i=0; i < pairs.length; i++) {
pair = pairs[i];
eqlIndex = pair.indexOf('=');
key = pair.substr(0, eqlIndex).trim().toLowerCase();
val = pair.substr(++eqlIndex, pair.length).trim();
if ('"' === val[0]) val = val.slice(1, -1);
if (obj[key] === undefined) {
val = val.replace(/\+/g, ' ');
try {
obj[key] = decodeURIComponent(val);
} catch (err) {
if (err instanceof URIError) {
obj[key] = val;
} else {
throw err;
}
}
}
}
return obj;
} | javascript | function parseCookie(str) {
var obj = {},
pairs = str.split(/[;,] */);
for (var pair,eqlIndex,key,val,i=0; i < pairs.length; i++) {
pair = pairs[i];
eqlIndex = pair.indexOf('=');
key = pair.substr(0, eqlIndex).trim().toLowerCase();
val = pair.substr(++eqlIndex, pair.length).trim();
if ('"' === val[0]) val = val.slice(1, -1);
if (obj[key] === undefined) {
val = val.replace(/\+/g, ' ');
try {
obj[key] = decodeURIComponent(val);
} catch (err) {
if (err instanceof URIError) {
obj[key] = val;
} else {
throw err;
}
}
}
}
return obj;
} | [
"function",
"parseCookie",
"(",
"str",
")",
"{",
"var",
"obj",
"=",
"{",
"}",
",",
"pairs",
"=",
"str",
".",
"split",
"(",
"/",
"[;,] *",
"/",
")",
";",
"for",
"(",
"var",
"pair",
",",
"eqlIndex",
",",
"key",
",",
"val",
",",
"i",
"=",
"0",
";",
"i",
"<",
"pairs",
".",
"length",
";",
"i",
"++",
")",
"{",
"pair",
"=",
"pairs",
"[",
"i",
"]",
";",
"eqlIndex",
"=",
"pair",
".",
"indexOf",
"(",
"'='",
")",
";",
"key",
"=",
"pair",
".",
"substr",
"(",
"0",
",",
"eqlIndex",
")",
".",
"trim",
"(",
")",
".",
"toLowerCase",
"(",
")",
";",
"val",
"=",
"pair",
".",
"substr",
"(",
"++",
"eqlIndex",
",",
"pair",
".",
"length",
")",
".",
"trim",
"(",
")",
";",
"if",
"(",
"'\"'",
"===",
"val",
"[",
"0",
"]",
")",
"val",
"=",
"val",
".",
"slice",
"(",
"1",
",",
"-",
"1",
")",
";",
"if",
"(",
"obj",
"[",
"key",
"]",
"===",
"undefined",
")",
"{",
"val",
"=",
"val",
".",
"replace",
"(",
"/",
"\\+",
"/",
"g",
",",
"' '",
")",
";",
"try",
"{",
"obj",
"[",
"key",
"]",
"=",
"decodeURIComponent",
"(",
"val",
")",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"if",
"(",
"err",
"instanceof",
"URIError",
")",
"{",
"obj",
"[",
"key",
"]",
"=",
"val",
";",
"}",
"else",
"{",
"throw",
"err",
";",
"}",
"}",
"}",
"}",
"return",
"obj",
";",
"}"
] | Parses the cookie header
@param {string} str
@returns {object}
@private | [
"Parses",
"the",
"cookie",
"header"
] | 0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9 | https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/middleware/cookie_parser/application.js#L32-L56 |
51,564 | derdesign/protos | middleware/cookie_parser/application.js | getRequestCookies | function getRequestCookies(req) {
if (req.headers.cookie != null) {
try {
return parseCookie(req.headers.cookie);
} catch (e) {
this.log(req.urlData.pathname, "Error parsing cookie header: " + e.toString());
return {};
}
} else {
return {};
}
} | javascript | function getRequestCookies(req) {
if (req.headers.cookie != null) {
try {
return parseCookie(req.headers.cookie);
} catch (e) {
this.log(req.urlData.pathname, "Error parsing cookie header: " + e.toString());
return {};
}
} else {
return {};
}
} | [
"function",
"getRequestCookies",
"(",
"req",
")",
"{",
"if",
"(",
"req",
".",
"headers",
".",
"cookie",
"!=",
"null",
")",
"{",
"try",
"{",
"return",
"parseCookie",
"(",
"req",
".",
"headers",
".",
"cookie",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"this",
".",
"log",
"(",
"req",
".",
"urlData",
".",
"pathname",
",",
"\"Error parsing cookie header: \"",
"+",
"e",
".",
"toString",
"(",
")",
")",
";",
"return",
"{",
"}",
";",
"}",
"}",
"else",
"{",
"return",
"{",
"}",
";",
"}",
"}"
] | Parses the request cookies
@param {object} req
@returns {object}
@private | [
"Parses",
"the",
"request",
"cookies"
] | 0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9 | https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/middleware/cookie_parser/application.js#L66-L77 |
51,565 | shadybones/fakery | examples/use_features.js | function(a,b){
if(b[0]=="my-id") {
var fakeResult = [];
return fakeResult;
}else return document.getElementById.apply(document,b);
} | javascript | function(a,b){
if(b[0]=="my-id") {
var fakeResult = [];
return fakeResult;
}else return document.getElementById.apply(document,b);
} | [
"function",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"b",
"[",
"0",
"]",
"==",
"\"my-id\"",
")",
"{",
"var",
"fakeResult",
"=",
"[",
"]",
";",
"return",
"fakeResult",
";",
"}",
"else",
"return",
"document",
".",
"getElementById",
".",
"apply",
"(",
"document",
",",
"b",
")",
";",
"}"
] | a = fake object, b = args | [
"a",
"=",
"fake",
"object",
"b",
"=",
"args"
] | 0ca9adec545595f4cdeaadbf9a3c33d0514b5061 | https://github.com/shadybones/fakery/blob/0ca9adec545595f4cdeaadbf9a3c33d0514b5061/examples/use_features.js#L23-L28 |
|
51,566 | Digznav/bilberry | git-porcelain-status.js | gitPorcelainStatus | function gitPorcelainStatus() {
return git('status --porcelain -b', stdout => {
const status = gitUtil.extractStatus(stdout);
let parsedStatus = Object.values(status.index).concat(Object.values(status.workingTree));
// Flattened
parsedStatus = parsedStatus.reduce((a, b) => a.concat(b), []);
return {
status,
currentBranch: status.branch.split('...')[0],
clean: parsedStatus.length === 0
};
});
} | javascript | function gitPorcelainStatus() {
return git('status --porcelain -b', stdout => {
const status = gitUtil.extractStatus(stdout);
let parsedStatus = Object.values(status.index).concat(Object.values(status.workingTree));
// Flattened
parsedStatus = parsedStatus.reduce((a, b) => a.concat(b), []);
return {
status,
currentBranch: status.branch.split('...')[0],
clean: parsedStatus.length === 0
};
});
} | [
"function",
"gitPorcelainStatus",
"(",
")",
"{",
"return",
"git",
"(",
"'status --porcelain -b'",
",",
"stdout",
"=>",
"{",
"const",
"status",
"=",
"gitUtil",
".",
"extractStatus",
"(",
"stdout",
")",
";",
"let",
"parsedStatus",
"=",
"Object",
".",
"values",
"(",
"status",
".",
"index",
")",
".",
"concat",
"(",
"Object",
".",
"values",
"(",
"status",
".",
"workingTree",
")",
")",
";",
"// Flattened",
"parsedStatus",
"=",
"parsedStatus",
".",
"reduce",
"(",
"(",
"a",
",",
"b",
")",
"=>",
"a",
".",
"concat",
"(",
"b",
")",
",",
"[",
"]",
")",
";",
"return",
"{",
"status",
",",
"currentBranch",
":",
"status",
".",
"branch",
".",
"split",
"(",
"'...'",
")",
"[",
"0",
"]",
",",
"clean",
":",
"parsedStatus",
".",
"length",
"===",
"0",
"}",
";",
"}",
")",
";",
"}"
] | Verify the status of the repository.
@return {object} Current branch and the status of hte repository. | [
"Verify",
"the",
"status",
"of",
"the",
"repository",
"."
] | ef6db49de6c8b0d2f4f9d3e10e8a8153e39ffcc4 | https://github.com/Digznav/bilberry/blob/ef6db49de6c8b0d2f4f9d3e10e8a8153e39ffcc4/git-porcelain-status.js#L8-L22 |
51,567 | LoveKino/ast-transfer | src/lazy/lazyCode.js | function(args, fn, type) {
this.args = args;
this.fn = fn;
this.type = type;
this.id = prefix + _code_node_id_count++;
} | javascript | function(args, fn, type) {
this.args = args;
this.fn = fn;
this.type = type;
this.id = prefix + _code_node_id_count++;
} | [
"function",
"(",
"args",
",",
"fn",
",",
"type",
")",
"{",
"this",
".",
"args",
"=",
"args",
";",
"this",
".",
"fn",
"=",
"fn",
";",
"this",
".",
"type",
"=",
"type",
";",
"this",
".",
"id",
"=",
"prefix",
"+",
"_code_node_id_count",
"++",
";",
"}"
] | Normally, when reduce a production, will new a LazyCode object
TODO fast way to indicate ancestor-descendant relationship | [
"Normally",
"when",
"reduce",
"a",
"production",
"will",
"new",
"a",
"LazyCode",
"object"
] | d0592343589e55ddee5ed9816632c7160a09d205 | https://github.com/LoveKino/ast-transfer/blob/d0592343589e55ddee5ed9816632c7160a09d205/src/lazy/lazyCode.js#L12-L18 |
|
51,568 | cli-kit/cli-help | lib/doc/gnu.js | function() {
HelpDocument.apply(this, arguments);
this.useCustom = false;
this.sections = [
HelpDocument.SYNOPSIS,
HelpDocument.DESCRIPTION,
HelpDocument.COMMANDS,
HelpDocument.OPTIONS,
HelpDocument.BUGS
]
} | javascript | function() {
HelpDocument.apply(this, arguments);
this.useCustom = false;
this.sections = [
HelpDocument.SYNOPSIS,
HelpDocument.DESCRIPTION,
HelpDocument.COMMANDS,
HelpDocument.OPTIONS,
HelpDocument.BUGS
]
} | [
"function",
"(",
")",
"{",
"HelpDocument",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"this",
".",
"useCustom",
"=",
"false",
";",
"this",
".",
"sections",
"=",
"[",
"HelpDocument",
".",
"SYNOPSIS",
",",
"HelpDocument",
".",
"DESCRIPTION",
",",
"HelpDocument",
".",
"COMMANDS",
",",
"HelpDocument",
".",
"OPTIONS",
",",
"HelpDocument",
".",
"BUGS",
"]",
"}"
] | Write help as a plain text document as if it were
being sent to a tty. | [
"Write",
"help",
"as",
"a",
"plain",
"text",
"document",
"as",
"if",
"it",
"were",
"being",
"sent",
"to",
"a",
"tty",
"."
] | 09613efdd753452b466d4deb7c5391c4926e3f04 | https://github.com/cli-kit/cli-help/blob/09613efdd753452b466d4deb7c5391c4926e3f04/lib/doc/gnu.js#L12-L22 |
|
51,569 | pimbrouwers/ditto | src/index.js | clean | function clean (callback) {
if (this._clobber) {
rimraf(path.join(destination, this._clobberGlob), callback);
}
else {
callback(null);
}
} | javascript | function clean (callback) {
if (this._clobber) {
rimraf(path.join(destination, this._clobberGlob), callback);
}
else {
callback(null);
}
} | [
"function",
"clean",
"(",
"callback",
")",
"{",
"if",
"(",
"this",
".",
"_clobber",
")",
"{",
"rimraf",
"(",
"path",
".",
"join",
"(",
"destination",
",",
"this",
".",
"_clobberGlob",
")",
",",
"callback",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"null",
")",
";",
"}",
"}"
] | Clean destination if clobber
@param {Function} callback | [
"Clean",
"destination",
"if",
"clobber"
] | 0217cecdec04606e896d3339f40e75b47dea8b77 | https://github.com/pimbrouwers/ditto/blob/0217cecdec04606e896d3339f40e75b47dea8b77/src/index.js#L124-L131 |
51,570 | pimbrouwers/ditto | src/index.js | discover | function discover (callback) {
glob(path.join(this._source, '/**/*.*'), function (err, filepaths) {
if (err) callback(err);
callback(null, filepaths);
});
} | javascript | function discover (callback) {
glob(path.join(this._source, '/**/*.*'), function (err, filepaths) {
if (err) callback(err);
callback(null, filepaths);
});
} | [
"function",
"discover",
"(",
"callback",
")",
"{",
"glob",
"(",
"path",
".",
"join",
"(",
"this",
".",
"_source",
",",
"'/**/*.*'",
")",
",",
"function",
"(",
"err",
",",
"filepaths",
")",
"{",
"if",
"(",
"err",
")",
"callback",
"(",
"err",
")",
";",
"callback",
"(",
"null",
",",
"filepaths",
")",
";",
"}",
")",
";",
"}"
] | Discover & parse files in source directory
@param {Function.<Error, Array.<string>>} callback | [
"Discover",
"&",
"parse",
"files",
"in",
"source",
"directory"
] | 0217cecdec04606e896d3339f40e75b47dea8b77 | https://github.com/pimbrouwers/ditto/blob/0217cecdec04606e896d3339f40e75b47dea8b77/src/index.js#L137-L142 |
51,571 | pimbrouwers/ditto | src/index.js | run | function run (files, callback) {
let self = this,
i = 0;
function next(err, files) {
let mw = self.middleware[i++];
if (mw) {
mw(files, self, next);
}
else {
callback(null, files);
}
};
next(null, files);
} | javascript | function run (files, callback) {
let self = this,
i = 0;
function next(err, files) {
let mw = self.middleware[i++];
if (mw) {
mw(files, self, next);
}
else {
callback(null, files);
}
};
next(null, files);
} | [
"function",
"run",
"(",
"files",
",",
"callback",
")",
"{",
"let",
"self",
"=",
"this",
",",
"i",
"=",
"0",
";",
"function",
"next",
"(",
"err",
",",
"files",
")",
"{",
"let",
"mw",
"=",
"self",
".",
"middleware",
"[",
"i",
"++",
"]",
";",
"if",
"(",
"mw",
")",
"{",
"mw",
"(",
"files",
",",
"self",
",",
"next",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"null",
",",
"files",
")",
";",
"}",
"}",
";",
"next",
"(",
"null",
",",
"files",
")",
";",
"}"
] | Run middleware pipeline
@param {Function} callback | [
"Run",
"middleware",
"pipeline"
] | 0217cecdec04606e896d3339f40e75b47dea8b77 | https://github.com/pimbrouwers/ditto/blob/0217cecdec04606e896d3339f40e75b47dea8b77/src/index.js#L182-L199 |
51,572 | pimbrouwers/ditto | src/index.js | writeFile | function writeFile (file, callback) {
fs.outputFile(path.resolve(this._destination, path.join(file.path.dir, file.path.name + file.path.ext)), file.content, function (err) {
if (err) callback(err);
callback(null);
});
} | javascript | function writeFile (file, callback) {
fs.outputFile(path.resolve(this._destination, path.join(file.path.dir, file.path.name + file.path.ext)), file.content, function (err) {
if (err) callback(err);
callback(null);
});
} | [
"function",
"writeFile",
"(",
"file",
",",
"callback",
")",
"{",
"fs",
".",
"outputFile",
"(",
"path",
".",
"resolve",
"(",
"this",
".",
"_destination",
",",
"path",
".",
"join",
"(",
"file",
".",
"path",
".",
"dir",
",",
"file",
".",
"path",
".",
"name",
"+",
"file",
".",
"path",
".",
"ext",
")",
")",
",",
"file",
".",
"content",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"callback",
"(",
"err",
")",
";",
"callback",
"(",
"null",
")",
";",
"}",
")",
";",
"}"
] | Write file to disk
@param {Object.<DittoFile>} file DittoFile
@param {Function.<Error>} callback | [
"Write",
"file",
"to",
"disk"
] | 0217cecdec04606e896d3339f40e75b47dea8b77 | https://github.com/pimbrouwers/ditto/blob/0217cecdec04606e896d3339f40e75b47dea8b77/src/index.js#L218-L223 |
51,573 | tolokoban/ToloFrameWork | ker/com/x-widget/x-widget.com.js | getRootChildren | function getRootChildren( root, libs, com ) {
var src = ( root.attribs.src || "" ).trim( );
if ( src.length > 0 ) {
if (!libs.fileExists( src )) {
libs.fatal( "File not found: \"" + src + "\"!" );
}
// Add a compilation dependency on the include file.
libs.addInclude( src );
var content = libs.readFileContent( src );
root.children = libs.parseHTML( content );
}
} | javascript | function getRootChildren( root, libs, com ) {
var src = ( root.attribs.src || "" ).trim( );
if ( src.length > 0 ) {
if (!libs.fileExists( src )) {
libs.fatal( "File not found: \"" + src + "\"!" );
}
// Add a compilation dependency on the include file.
libs.addInclude( src );
var content = libs.readFileContent( src );
root.children = libs.parseHTML( content );
}
} | [
"function",
"getRootChildren",
"(",
"root",
",",
"libs",
",",
"com",
")",
"{",
"var",
"src",
"=",
"(",
"root",
".",
"attribs",
".",
"src",
"||",
"\"\"",
")",
".",
"trim",
"(",
")",
";",
"if",
"(",
"src",
".",
"length",
">",
"0",
")",
"{",
"if",
"(",
"!",
"libs",
".",
"fileExists",
"(",
"src",
")",
")",
"{",
"libs",
".",
"fatal",
"(",
"\"File not found: \\\"\"",
"+",
"src",
"+",
"\"\\\"!\"",
")",
";",
"}",
"// Add a compilation dependency on the include file.",
"libs",
".",
"addInclude",
"(",
"src",
")",
";",
"var",
"content",
"=",
"libs",
".",
"readFileContent",
"(",
"src",
")",
";",
"root",
".",
"children",
"=",
"libs",
".",
"parseHTML",
"(",
"content",
")",
";",
"}",
"}"
] | If root has got a `src` attribute, we load a file and put its content as children of `root`. | [
"If",
"root",
"has",
"got",
"a",
"src",
"attribute",
"we",
"load",
"a",
"file",
"and",
"put",
"its",
"content",
"as",
"children",
"of",
"root",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/com/x-widget/x-widget.com.js#L227-L238 |
51,574 | tolokoban/ToloFrameWork | ker/com/x-widget/x-widget.com.js | getPropertiesAndBindings | function getPropertiesAndBindings( root, libs, com, indent ) {
// Attributes can have post initialization, especially for data bindings.
var postInit = {};
var hasPostInit = false;
var key,
val,
values;
var bindings;
var slots;
for ( key in root.attribs ) {
if ( key.charAt( 0 ) == '$' ) {
// All the attributes that start with a '$' are used as args attributes.
val = root.attribs[key];
com.prop[key.substr( 1 )] = JSON.stringify( val );
}
else if ( key.substr( 0, 5 ) == 'intl:' ) {
// Internationalization.
val = root.attribs[key];
com.prop[key.substr( 5 )] = "APP._(" + JSON.stringify( val ) + ")";
}
else if ( key.substr( 0, 5 ) == 'bind:' ) {
// Syntaxe :
// <bind> := <bind-item> <bind-next>*
// <bind-next> := "," <bind-item>
// <bind-item> := <widget-name> <attribute>? <value>?
// <widget-name> := /[$a-zA-Z_-][$0-9a-zA-Z_-]+/
// <attribute> := ":" <attrib-name>
// <attrib-name> := /[$a-zA-Z_-][$0-9a-zA-Z_-]+/
// <value> := "=" <data>
// <data> := "true" | "false" | "null" | <number> | <string>
//
// @example
// <wdg:checkbox bind:value="btn1:action" />
// <wdg:checkbox bind:value="btn1:action, btn2, action=false" />
if ( typeof postInit[key.substr( 5 )] === 'undefined' ) {
postInit[key.substr( 5 )] = {};
}
postInit[key.substr( 5 )].B = parseBinding(root.attribs[key]);
hasPostInit = true;
}
else if ( key.substr( 0, 5 ) == 'slot:' ) {
// @example
// <wdg:button slot:action="removeOrder" />
// <wdg:button slot:action="removeOrder, changePage" />
// <wdg:button slot:action="my-module:my-function" />
values = root.attribs[key].split( "," );
key = key.substr( 5 );
if ( typeof postInit[key] === 'undefined' ) {
postInit[key] = {};
}
slots = [ ];
values.forEach( function( val ) {
// Before the colon (:) there is the module name. After, there
// is the function name. If there is no colon, `APP` is used
// as module.
val = val.split( ':' );
if ( val.length < 2 ) {
slots.push(val[0].trim( ));
} else {
slots.push(val.map( String.trim ));
libs.require(val[0]);
}
});
postInit[key].S = slots;
hasPostInit = true;
}
else {
com.attr[key] = root.attribs[key];
}
}
if ( hasPostInit ) {
libs.addPostInitJS( " W.bind('" + com.attr.id + "'," + JSON.stringify( postInit ) + ");" );
}
} | javascript | function getPropertiesAndBindings( root, libs, com, indent ) {
// Attributes can have post initialization, especially for data bindings.
var postInit = {};
var hasPostInit = false;
var key,
val,
values;
var bindings;
var slots;
for ( key in root.attribs ) {
if ( key.charAt( 0 ) == '$' ) {
// All the attributes that start with a '$' are used as args attributes.
val = root.attribs[key];
com.prop[key.substr( 1 )] = JSON.stringify( val );
}
else if ( key.substr( 0, 5 ) == 'intl:' ) {
// Internationalization.
val = root.attribs[key];
com.prop[key.substr( 5 )] = "APP._(" + JSON.stringify( val ) + ")";
}
else if ( key.substr( 0, 5 ) == 'bind:' ) {
// Syntaxe :
// <bind> := <bind-item> <bind-next>*
// <bind-next> := "," <bind-item>
// <bind-item> := <widget-name> <attribute>? <value>?
// <widget-name> := /[$a-zA-Z_-][$0-9a-zA-Z_-]+/
// <attribute> := ":" <attrib-name>
// <attrib-name> := /[$a-zA-Z_-][$0-9a-zA-Z_-]+/
// <value> := "=" <data>
// <data> := "true" | "false" | "null" | <number> | <string>
//
// @example
// <wdg:checkbox bind:value="btn1:action" />
// <wdg:checkbox bind:value="btn1:action, btn2, action=false" />
if ( typeof postInit[key.substr( 5 )] === 'undefined' ) {
postInit[key.substr( 5 )] = {};
}
postInit[key.substr( 5 )].B = parseBinding(root.attribs[key]);
hasPostInit = true;
}
else if ( key.substr( 0, 5 ) == 'slot:' ) {
// @example
// <wdg:button slot:action="removeOrder" />
// <wdg:button slot:action="removeOrder, changePage" />
// <wdg:button slot:action="my-module:my-function" />
values = root.attribs[key].split( "," );
key = key.substr( 5 );
if ( typeof postInit[key] === 'undefined' ) {
postInit[key] = {};
}
slots = [ ];
values.forEach( function( val ) {
// Before the colon (:) there is the module name. After, there
// is the function name. If there is no colon, `APP` is used
// as module.
val = val.split( ':' );
if ( val.length < 2 ) {
slots.push(val[0].trim( ));
} else {
slots.push(val.map( String.trim ));
libs.require(val[0]);
}
});
postInit[key].S = slots;
hasPostInit = true;
}
else {
com.attr[key] = root.attribs[key];
}
}
if ( hasPostInit ) {
libs.addPostInitJS( " W.bind('" + com.attr.id + "'," + JSON.stringify( postInit ) + ");" );
}
} | [
"function",
"getPropertiesAndBindings",
"(",
"root",
",",
"libs",
",",
"com",
",",
"indent",
")",
"{",
"// Attributes can have post initialization, especially for data bindings.",
"var",
"postInit",
"=",
"{",
"}",
";",
"var",
"hasPostInit",
"=",
"false",
";",
"var",
"key",
",",
"val",
",",
"values",
";",
"var",
"bindings",
";",
"var",
"slots",
";",
"for",
"(",
"key",
"in",
"root",
".",
"attribs",
")",
"{",
"if",
"(",
"key",
".",
"charAt",
"(",
"0",
")",
"==",
"'$'",
")",
"{",
"// All the attributes that start with a '$' are used as args attributes.",
"val",
"=",
"root",
".",
"attribs",
"[",
"key",
"]",
";",
"com",
".",
"prop",
"[",
"key",
".",
"substr",
"(",
"1",
")",
"]",
"=",
"JSON",
".",
"stringify",
"(",
"val",
")",
";",
"}",
"else",
"if",
"(",
"key",
".",
"substr",
"(",
"0",
",",
"5",
")",
"==",
"'intl:'",
")",
"{",
"// Internationalization.",
"val",
"=",
"root",
".",
"attribs",
"[",
"key",
"]",
";",
"com",
".",
"prop",
"[",
"key",
".",
"substr",
"(",
"5",
")",
"]",
"=",
"\"APP._(\"",
"+",
"JSON",
".",
"stringify",
"(",
"val",
")",
"+",
"\")\"",
";",
"}",
"else",
"if",
"(",
"key",
".",
"substr",
"(",
"0",
",",
"5",
")",
"==",
"'bind:'",
")",
"{",
"// Syntaxe :",
"// <bind> := <bind-item> <bind-next>*",
"// <bind-next> := \",\" <bind-item>",
"// <bind-item> := <widget-name> <attribute>? <value>?",
"// <widget-name> := /[$a-zA-Z_-][$0-9a-zA-Z_-]+/",
"// <attribute> := \":\" <attrib-name>",
"// <attrib-name> := /[$a-zA-Z_-][$0-9a-zA-Z_-]+/",
"// <value> := \"=\" <data>",
"// <data> := \"true\" | \"false\" | \"null\" | <number> | <string>",
"//",
"// @example",
"// <wdg:checkbox bind:value=\"btn1:action\" />",
"// <wdg:checkbox bind:value=\"btn1:action, btn2, action=false\" />",
"if",
"(",
"typeof",
"postInit",
"[",
"key",
".",
"substr",
"(",
"5",
")",
"]",
"===",
"'undefined'",
")",
"{",
"postInit",
"[",
"key",
".",
"substr",
"(",
"5",
")",
"]",
"=",
"{",
"}",
";",
"}",
"postInit",
"[",
"key",
".",
"substr",
"(",
"5",
")",
"]",
".",
"B",
"=",
"parseBinding",
"(",
"root",
".",
"attribs",
"[",
"key",
"]",
")",
";",
"hasPostInit",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"key",
".",
"substr",
"(",
"0",
",",
"5",
")",
"==",
"'slot:'",
")",
"{",
"// @example",
"// <wdg:button slot:action=\"removeOrder\" />",
"// <wdg:button slot:action=\"removeOrder, changePage\" />",
"// <wdg:button slot:action=\"my-module:my-function\" />",
"values",
"=",
"root",
".",
"attribs",
"[",
"key",
"]",
".",
"split",
"(",
"\",\"",
")",
";",
"key",
"=",
"key",
".",
"substr",
"(",
"5",
")",
";",
"if",
"(",
"typeof",
"postInit",
"[",
"key",
"]",
"===",
"'undefined'",
")",
"{",
"postInit",
"[",
"key",
"]",
"=",
"{",
"}",
";",
"}",
"slots",
"=",
"[",
"]",
";",
"values",
".",
"forEach",
"(",
"function",
"(",
"val",
")",
"{",
"// Before the colon (:) there is the module name. After, there",
"// is the function name. If there is no colon, `APP` is used",
"// as module.",
"val",
"=",
"val",
".",
"split",
"(",
"':'",
")",
";",
"if",
"(",
"val",
".",
"length",
"<",
"2",
")",
"{",
"slots",
".",
"push",
"(",
"val",
"[",
"0",
"]",
".",
"trim",
"(",
")",
")",
";",
"}",
"else",
"{",
"slots",
".",
"push",
"(",
"val",
".",
"map",
"(",
"String",
".",
"trim",
")",
")",
";",
"libs",
".",
"require",
"(",
"val",
"[",
"0",
"]",
")",
";",
"}",
"}",
")",
";",
"postInit",
"[",
"key",
"]",
".",
"S",
"=",
"slots",
";",
"hasPostInit",
"=",
"true",
";",
"}",
"else",
"{",
"com",
".",
"attr",
"[",
"key",
"]",
"=",
"root",
".",
"attribs",
"[",
"key",
"]",
";",
"}",
"}",
"if",
"(",
"hasPostInit",
")",
"{",
"libs",
".",
"addPostInitJS",
"(",
"\" W.bind('\"",
"+",
"com",
".",
"attr",
".",
"id",
"+",
"\"',\"",
"+",
"JSON",
".",
"stringify",
"(",
"postInit",
")",
"+",
"\");\"",
")",
";",
"}",
"}"
] | Properties and bindings. | [
"Properties",
"and",
"bindings",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/com/x-widget/x-widget.com.js#L243-L317 |
51,575 | vesln/sourcery | lib/resource.js | Resource | function Resource(attributes) {
this.engine = engine;
this.name = !this.name ? this.name : this.name.toLowerCase();
this.queryParams = {};
this.attributes = {};
this.load(attributes || {});
} | javascript | function Resource(attributes) {
this.engine = engine;
this.name = !this.name ? this.name : this.name.toLowerCase();
this.queryParams = {};
this.attributes = {};
this.load(attributes || {});
} | [
"function",
"Resource",
"(",
"attributes",
")",
"{",
"this",
".",
"engine",
"=",
"engine",
";",
"this",
".",
"name",
"=",
"!",
"this",
".",
"name",
"?",
"this",
".",
"name",
":",
"this",
".",
"name",
".",
"toLowerCase",
"(",
")",
";",
"this",
".",
"queryParams",
"=",
"{",
"}",
";",
"this",
".",
"attributes",
"=",
"{",
"}",
";",
"this",
".",
"load",
"(",
"attributes",
"||",
"{",
"}",
")",
";",
"}"
] | Base resource. All resources inherit from it.
@param {Object} attributes to be set
@constructor | [
"Base",
"resource",
".",
"All",
"resources",
"inherit",
"from",
"it",
"."
] | e3e7c3de6bbb2d0e1ef0a546fb9af00d10653ce5 | https://github.com/vesln/sourcery/blob/e3e7c3de6bbb2d0e1ef0a546fb9af00d10653ce5/lib/resource.js#L29-L35 |
51,576 | redisjs/jsr-server | lib/daemon.js | daemonize | function daemonize(file, conf, args) {
/* istanbul ignore next: never parse argv in test env */
args = args || process.argv.slice(2);
args.unshift(file);
var logfile = conf.get(ConfigKey.LOGFILE) || '/dev/null'
//var logfile = conf.get(ConfigKey.LOGFILE) || 'daemon.log'
, out = fs.openSync(logfile, 'a')
, err = fs.openSync(logfile, 'a')
, opts = {
detached: true,
stdio: ['ignore', out, err],
cwd: process.cwd(),
env: process.env
};
//console.dir(logfile);
//console.dir(args);
var ps = spawn(cmd, args, opts);
/* istanbul ignore next: always in test env */
if(process.env.NODE_ENV !== Constants.TEST) {
process.exit(0);
}
return ps.pid;
} | javascript | function daemonize(file, conf, args) {
/* istanbul ignore next: never parse argv in test env */
args = args || process.argv.slice(2);
args.unshift(file);
var logfile = conf.get(ConfigKey.LOGFILE) || '/dev/null'
//var logfile = conf.get(ConfigKey.LOGFILE) || 'daemon.log'
, out = fs.openSync(logfile, 'a')
, err = fs.openSync(logfile, 'a')
, opts = {
detached: true,
stdio: ['ignore', out, err],
cwd: process.cwd(),
env: process.env
};
//console.dir(logfile);
//console.dir(args);
var ps = spawn(cmd, args, opts);
/* istanbul ignore next: always in test env */
if(process.env.NODE_ENV !== Constants.TEST) {
process.exit(0);
}
return ps.pid;
} | [
"function",
"daemonize",
"(",
"file",
",",
"conf",
",",
"args",
")",
"{",
"/* istanbul ignore next: never parse argv in test env */",
"args",
"=",
"args",
"||",
"process",
".",
"argv",
".",
"slice",
"(",
"2",
")",
";",
"args",
".",
"unshift",
"(",
"file",
")",
";",
"var",
"logfile",
"=",
"conf",
".",
"get",
"(",
"ConfigKey",
".",
"LOGFILE",
")",
"||",
"'/dev/null'",
"//var logfile = conf.get(ConfigKey.LOGFILE) || 'daemon.log'",
",",
"out",
"=",
"fs",
".",
"openSync",
"(",
"logfile",
",",
"'a'",
")",
",",
"err",
"=",
"fs",
".",
"openSync",
"(",
"logfile",
",",
"'a'",
")",
",",
"opts",
"=",
"{",
"detached",
":",
"true",
",",
"stdio",
":",
"[",
"'ignore'",
",",
"out",
",",
"err",
"]",
",",
"cwd",
":",
"process",
".",
"cwd",
"(",
")",
",",
"env",
":",
"process",
".",
"env",
"}",
";",
"//console.dir(logfile);",
"//console.dir(args);",
"var",
"ps",
"=",
"spawn",
"(",
"cmd",
",",
"args",
",",
"opts",
")",
";",
"/* istanbul ignore next: always in test env */",
"if",
"(",
"process",
".",
"env",
".",
"NODE_ENV",
"!==",
"Constants",
".",
"TEST",
")",
"{",
"process",
".",
"exit",
"(",
"0",
")",
";",
"}",
"return",
"ps",
".",
"pid",
";",
"}"
] | Create the daemon process. | [
"Create",
"the",
"daemon",
"process",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/daemon.js#L14-L38 |
51,577 | redisjs/jsr-server | lib/daemon.js | write | function write(conf) {
var contents = process.pid + EOL
, file = conf.get(ConfigKey.PIDFILE);
// can be the empty string
if(file) {
try {
fs.writeFileSync(file, contents);
log.notice('wrote pid %s to %s', process.pid, file);
}catch(e) {
log.warning('failed to write pid file (%s): %s', file, e.message);
}
}
} | javascript | function write(conf) {
var contents = process.pid + EOL
, file = conf.get(ConfigKey.PIDFILE);
// can be the empty string
if(file) {
try {
fs.writeFileSync(file, contents);
log.notice('wrote pid %s to %s', process.pid, file);
}catch(e) {
log.warning('failed to write pid file (%s): %s', file, e.message);
}
}
} | [
"function",
"write",
"(",
"conf",
")",
"{",
"var",
"contents",
"=",
"process",
".",
"pid",
"+",
"EOL",
",",
"file",
"=",
"conf",
".",
"get",
"(",
"ConfigKey",
".",
"PIDFILE",
")",
";",
"// can be the empty string",
"if",
"(",
"file",
")",
"{",
"try",
"{",
"fs",
".",
"writeFileSync",
"(",
"file",
",",
"contents",
")",
";",
"log",
".",
"notice",
"(",
"'wrote pid %s to %s'",
",",
"process",
".",
"pid",
",",
"file",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"log",
".",
"warning",
"(",
"'failed to write pid file (%s): %s'",
",",
"file",
",",
"e",
".",
"message",
")",
";",
"}",
"}",
"}"
] | Write the pid file. | [
"Write",
"the",
"pid",
"file",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/daemon.js#L43-L55 |
51,578 | redisjs/jsr-server | lib/daemon.js | remove | function remove(conf) {
var file = conf.get(ConfigKey.PIDFILE);
// can be the empty string
if(file) {
log.notice('removing pid file %s', file);
try {
fs.unlinkSync(file);
}catch(e) {
log.warning('failed to remove pid file (%s): %s', file, e.message);
}
}
} | javascript | function remove(conf) {
var file = conf.get(ConfigKey.PIDFILE);
// can be the empty string
if(file) {
log.notice('removing pid file %s', file);
try {
fs.unlinkSync(file);
}catch(e) {
log.warning('failed to remove pid file (%s): %s', file, e.message);
}
}
} | [
"function",
"remove",
"(",
"conf",
")",
"{",
"var",
"file",
"=",
"conf",
".",
"get",
"(",
"ConfigKey",
".",
"PIDFILE",
")",
";",
"// can be the empty string",
"if",
"(",
"file",
")",
"{",
"log",
".",
"notice",
"(",
"'removing pid file %s'",
",",
"file",
")",
";",
"try",
"{",
"fs",
".",
"unlinkSync",
"(",
"file",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"log",
".",
"warning",
"(",
"'failed to remove pid file (%s): %s'",
",",
"file",
",",
"e",
".",
"message",
")",
";",
"}",
"}",
"}"
] | Remove the pid file. | [
"Remove",
"the",
"pid",
"file",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/daemon.js#L60-L71 |
51,579 | Lindurion/closure-pro-build | 3p/closure-library-20130212/third_party/closure/goog/dojo/dom/query.js | function(node, root) {
var pn = node.parentNode;
while (pn) {
if (pn == root) {
break;
}
pn = pn.parentNode;
}
return !!pn;
} | javascript | function(node, root) {
var pn = node.parentNode;
while (pn) {
if (pn == root) {
break;
}
pn = pn.parentNode;
}
return !!pn;
} | [
"function",
"(",
"node",
",",
"root",
")",
"{",
"var",
"pn",
"=",
"node",
".",
"parentNode",
";",
"while",
"(",
"pn",
")",
"{",
"if",
"(",
"pn",
"==",
"root",
")",
"{",
"break",
";",
"}",
"pn",
"=",
"pn",
".",
"parentNode",
";",
"}",
"return",
"!",
"!",
"pn",
";",
"}"
] | test to see if node is below root | [
"test",
"to",
"see",
"if",
"node",
"is",
"below",
"root"
] | c279d0fcc3a65969d2fe965f55e627b074792f1a | https://github.com/Lindurion/closure-pro-build/blob/c279d0fcc3a65969d2fe965f55e627b074792f1a/3p/closure-library-20130212/third_party/closure/goog/dojo/dom/query.js#L988-L997 |
|
51,580 | Lindurion/closure-pro-build | 3p/closure-library-20130212/third_party/closure/goog/dojo/dom/query.js | function(node, bag) {
if (!bag) {
return 1;
}
var id = _nodeUID(node);
if (!bag[id]) {
return bag[id] = 1;
}
return 0;
} | javascript | function(node, bag) {
if (!bag) {
return 1;
}
var id = _nodeUID(node);
if (!bag[id]) {
return bag[id] = 1;
}
return 0;
} | [
"function",
"(",
"node",
",",
"bag",
")",
"{",
"if",
"(",
"!",
"bag",
")",
"{",
"return",
"1",
";",
"}",
"var",
"id",
"=",
"_nodeUID",
"(",
"node",
")",
";",
"if",
"(",
"!",
"bag",
"[",
"id",
"]",
")",
"{",
"return",
"bag",
"[",
"id",
"]",
"=",
"1",
";",
"}",
"return",
"0",
";",
"}"
] | determine if a node in is unique in a 'bag'. In this case we don't want to flatten a list of unique items, but rather just tell if the item in question is already in the bag. Normally we'd just use hash lookup to do this for us but IE's DOM is busted so we can't really count on that. On the upside, it gives us a built in unique ID function. | [
"determine",
"if",
"a",
"node",
"in",
"is",
"unique",
"in",
"a",
"bag",
".",
"In",
"this",
"case",
"we",
"don",
"t",
"want",
"to",
"flatten",
"a",
"list",
"of",
"unique",
"items",
"but",
"rather",
"just",
"tell",
"if",
"the",
"item",
"in",
"question",
"is",
"already",
"in",
"the",
"bag",
".",
"Normally",
"we",
"d",
"just",
"use",
"hash",
"lookup",
"to",
"do",
"this",
"for",
"us",
"but",
"IE",
"s",
"DOM",
"is",
"busted",
"so",
"we",
"can",
"t",
"really",
"count",
"on",
"that",
".",
"On",
"the",
"upside",
"it",
"gives",
"us",
"a",
"built",
"in",
"unique",
"ID",
"function",
"."
] | c279d0fcc3a65969d2fe965f55e627b074792f1a | https://github.com/Lindurion/closure-pro-build/blob/c279d0fcc3a65969d2fe965f55e627b074792f1a/3p/closure-library-20130212/third_party/closure/goog/dojo/dom/query.js#L1402-L1411 |
|
51,581 | Lindurion/closure-pro-build | 3p/closure-library-20130212/third_party/closure/goog/dojo/dom/query.js | function(query, root) {
// NOTE: elementsById is not currently supported
// NOTE: ignores xpath-ish queries for now
//Set list constructor to desired value. This can change
//between calls, so always re-assign here.
if (!query) {
return [];
}
if (query.constructor == Array) {
return /** @type {!Array} */ (query);
}
if (!goog.isString(query)) {
return [query];
}
if (goog.isString(root)) {
root = goog.dom.getElement(root);
if (!root) {
return [];
}
}
root = root || goog.dom.getDocument();
var od = root.ownerDocument || root.documentElement;
// throw the big case sensitivity switch
// NOTE:
// Opera in XHTML mode doesn't detect case-sensitivity correctly
// and it's not clear that there's any way to test for it
caseSensitive =
root.contentType && root.contentType == 'application/xml' ||
goog.userAgent.OPERA &&
(root.doctype || od.toString() == '[object XMLDocument]') ||
!!od &&
(goog.userAgent.IE ? od.xml : (root.xmlVersion || od.xmlVersion));
// NOTE:
// adding 'true' as the 2nd argument to getQueryFunc is useful for
// testing the DOM branch without worrying about the
// behavior/performance of the QSA branch.
var r = getQueryFunc(query)(root);
// FIXME(slightlyoff):
// need to investigate this branch WRT dojo:#8074 and dojo:#8075
if (r && r.nozip) {
return r;
}
return _zip(r);
} | javascript | function(query, root) {
// NOTE: elementsById is not currently supported
// NOTE: ignores xpath-ish queries for now
//Set list constructor to desired value. This can change
//between calls, so always re-assign here.
if (!query) {
return [];
}
if (query.constructor == Array) {
return /** @type {!Array} */ (query);
}
if (!goog.isString(query)) {
return [query];
}
if (goog.isString(root)) {
root = goog.dom.getElement(root);
if (!root) {
return [];
}
}
root = root || goog.dom.getDocument();
var od = root.ownerDocument || root.documentElement;
// throw the big case sensitivity switch
// NOTE:
// Opera in XHTML mode doesn't detect case-sensitivity correctly
// and it's not clear that there's any way to test for it
caseSensitive =
root.contentType && root.contentType == 'application/xml' ||
goog.userAgent.OPERA &&
(root.doctype || od.toString() == '[object XMLDocument]') ||
!!od &&
(goog.userAgent.IE ? od.xml : (root.xmlVersion || od.xmlVersion));
// NOTE:
// adding 'true' as the 2nd argument to getQueryFunc is useful for
// testing the DOM branch without worrying about the
// behavior/performance of the QSA branch.
var r = getQueryFunc(query)(root);
// FIXME(slightlyoff):
// need to investigate this branch WRT dojo:#8074 and dojo:#8075
if (r && r.nozip) {
return r;
}
return _zip(r);
} | [
"function",
"(",
"query",
",",
"root",
")",
"{",
"// NOTE: elementsById is not currently supported",
"// NOTE: ignores xpath-ish queries for now",
"//Set list constructor to desired value. This can change",
"//between calls, so always re-assign here.",
"if",
"(",
"!",
"query",
")",
"{",
"return",
"[",
"]",
";",
"}",
"if",
"(",
"query",
".",
"constructor",
"==",
"Array",
")",
"{",
"return",
"/** @type {!Array} */",
"(",
"query",
")",
";",
"}",
"if",
"(",
"!",
"goog",
".",
"isString",
"(",
"query",
")",
")",
"{",
"return",
"[",
"query",
"]",
";",
"}",
"if",
"(",
"goog",
".",
"isString",
"(",
"root",
")",
")",
"{",
"root",
"=",
"goog",
".",
"dom",
".",
"getElement",
"(",
"root",
")",
";",
"if",
"(",
"!",
"root",
")",
"{",
"return",
"[",
"]",
";",
"}",
"}",
"root",
"=",
"root",
"||",
"goog",
".",
"dom",
".",
"getDocument",
"(",
")",
";",
"var",
"od",
"=",
"root",
".",
"ownerDocument",
"||",
"root",
".",
"documentElement",
";",
"// throw the big case sensitivity switch",
"// NOTE:",
"// Opera in XHTML mode doesn't detect case-sensitivity correctly",
"// and it's not clear that there's any way to test for it",
"caseSensitive",
"=",
"root",
".",
"contentType",
"&&",
"root",
".",
"contentType",
"==",
"'application/xml'",
"||",
"goog",
".",
"userAgent",
".",
"OPERA",
"&&",
"(",
"root",
".",
"doctype",
"||",
"od",
".",
"toString",
"(",
")",
"==",
"'[object XMLDocument]'",
")",
"||",
"!",
"!",
"od",
"&&",
"(",
"goog",
".",
"userAgent",
".",
"IE",
"?",
"od",
".",
"xml",
":",
"(",
"root",
".",
"xmlVersion",
"||",
"od",
".",
"xmlVersion",
")",
")",
";",
"// NOTE:",
"// adding 'true' as the 2nd argument to getQueryFunc is useful for",
"// testing the DOM branch without worrying about the",
"// behavior/performance of the QSA branch.",
"var",
"r",
"=",
"getQueryFunc",
"(",
"query",
")",
"(",
"root",
")",
";",
"// FIXME(slightlyoff):",
"// need to investigate this branch WRT dojo:#8074 and dojo:#8075",
"if",
"(",
"r",
"&&",
"r",
".",
"nozip",
")",
"{",
"return",
"r",
";",
"}",
"return",
"_zip",
"(",
"r",
")",
";",
"}"
] | The main executor. Type specification from above.
@param {string|Array} query The query.
@param {(string|Node)=} root The root.
@return {!Array} The elements that matched the query. | [
"The",
"main",
"executor",
".",
"Type",
"specification",
"from",
"above",
"."
] | c279d0fcc3a65969d2fe965f55e627b074792f1a | https://github.com/Lindurion/closure-pro-build/blob/c279d0fcc3a65969d2fe965f55e627b074792f1a/3p/closure-library-20130212/third_party/closure/goog/dojo/dom/query.js#L1472-L1525 |
|
51,582 | novemberborn/legendary | lib/private/resolution.js | Propagator | function Propagator(
constructor, transforms,
cancellable, signalCancelled) {
this._constructor = constructor || promise.Promise;
this._transforms = transforms;
this._cancellable = cancellable === true;
this._signalCancelled = signalCancelled;
this._state = INITIALIZED;
this._resolved = false;
this._cancelled = false;
this._delegatedResolve = null;
this._delegatedReject = null;
this._result = null;
this._resultThen = null;
this._handledRejection = null;
this._promise = null;
} | javascript | function Propagator(
constructor, transforms,
cancellable, signalCancelled) {
this._constructor = constructor || promise.Promise;
this._transforms = transforms;
this._cancellable = cancellable === true;
this._signalCancelled = signalCancelled;
this._state = INITIALIZED;
this._resolved = false;
this._cancelled = false;
this._delegatedResolve = null;
this._delegatedReject = null;
this._result = null;
this._resultThen = null;
this._handledRejection = null;
this._promise = null;
} | [
"function",
"Propagator",
"(",
"constructor",
",",
"transforms",
",",
"cancellable",
",",
"signalCancelled",
")",
"{",
"this",
".",
"_constructor",
"=",
"constructor",
"||",
"promise",
".",
"Promise",
";",
"this",
".",
"_transforms",
"=",
"transforms",
";",
"this",
".",
"_cancellable",
"=",
"cancellable",
"===",
"true",
";",
"this",
".",
"_signalCancelled",
"=",
"signalCancelled",
";",
"this",
".",
"_state",
"=",
"INITIALIZED",
";",
"this",
".",
"_resolved",
"=",
"false",
";",
"this",
".",
"_cancelled",
"=",
"false",
";",
"this",
".",
"_delegatedResolve",
"=",
"null",
";",
"this",
".",
"_delegatedReject",
"=",
"null",
";",
"this",
".",
"_result",
"=",
"null",
";",
"this",
".",
"_resultThen",
"=",
"null",
";",
"this",
".",
"_handledRejection",
"=",
"null",
";",
"this",
".",
"_promise",
"=",
"null",
";",
"}"
] | Propagators propagate the state of a promise to added callbacks, optionally transforming it first. The transformation may result in a thenable. The propagator will only attempt to resolve the state of the thenable when callbacks are added. | [
"Propagators",
"propagate",
"the",
"state",
"of",
"a",
"promise",
"to",
"added",
"callbacks",
"optionally",
"transforming",
"it",
"first",
".",
"The",
"transformation",
"may",
"result",
"in",
"a",
"thenable",
".",
"The",
"propagator",
"will",
"only",
"attempt",
"to",
"resolve",
"the",
"state",
"of",
"the",
"thenable",
"when",
"callbacks",
"are",
"added",
"."
] | 8420f2dd20e2e3eaced51385fb6b0dc65b81a9fc | https://github.com/novemberborn/legendary/blob/8420f2dd20e2e3eaced51385fb6b0dc65b81a9fc/lib/private/resolution.js#L62-L81 |
51,583 | wscn-FED/wscn-react-vendor | dist/wscn-react-vendor.js | nodeIsRenderedByOtherInstance | function nodeIsRenderedByOtherInstance(container) {
var rootEl = getReactRootElementInContainer(container);
return !!(rootEl && isReactNode(rootEl) && !ReactDOMComponentTree.getInstanceFromNode(rootEl));
} | javascript | function nodeIsRenderedByOtherInstance(container) {
var rootEl = getReactRootElementInContainer(container);
return !!(rootEl && isReactNode(rootEl) && !ReactDOMComponentTree.getInstanceFromNode(rootEl));
} | [
"function",
"nodeIsRenderedByOtherInstance",
"(",
"container",
")",
"{",
"var",
"rootEl",
"=",
"getReactRootElementInContainer",
"(",
"container",
")",
";",
"return",
"!",
"!",
"(",
"rootEl",
"&&",
"isReactNode",
"(",
"rootEl",
")",
"&&",
"!",
"ReactDOMComponentTree",
".",
"getInstanceFromNode",
"(",
"rootEl",
")",
")",
";",
"}"
] | True if the supplied DOM node is a React DOM element and
it has been rendered by another copy of React.
@param {?DOMElement} node The candidate DOM node.
@return {boolean} True if the DOM has been rendered by another copy of React
@internal | [
"True",
"if",
"the",
"supplied",
"DOM",
"node",
"is",
"a",
"React",
"DOM",
"element",
"and",
"it",
"has",
"been",
"rendered",
"by",
"another",
"copy",
"of",
"React",
"."
] | 4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2 | https://github.com/wscn-FED/wscn-react-vendor/blob/4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2/dist/wscn-react-vendor.js#L12418-L12421 |
51,584 | wscn-FED/wscn-react-vendor | dist/wscn-react-vendor.js | isReactNode | function isReactNode(node) {
return isValidContainer(node) && (node.hasAttribute(ROOT_ATTR_NAME) || node.hasAttribute(ATTR_NAME));
} | javascript | function isReactNode(node) {
return isValidContainer(node) && (node.hasAttribute(ROOT_ATTR_NAME) || node.hasAttribute(ATTR_NAME));
} | [
"function",
"isReactNode",
"(",
"node",
")",
"{",
"return",
"isValidContainer",
"(",
"node",
")",
"&&",
"(",
"node",
".",
"hasAttribute",
"(",
"ROOT_ATTR_NAME",
")",
"||",
"node",
".",
"hasAttribute",
"(",
"ATTR_NAME",
")",
")",
";",
"}"
] | True if the supplied DOM node is a valid React node element.
@param {?DOMElement} node The candidate DOM node.
@return {boolean} True if the DOM is a valid React DOM node.
@internal | [
"True",
"if",
"the",
"supplied",
"DOM",
"node",
"is",
"a",
"valid",
"React",
"node",
"element",
"."
] | 4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2 | https://github.com/wscn-FED/wscn-react-vendor/blob/4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2/dist/wscn-react-vendor.js#L12441-L12443 |
51,585 | wscn-FED/wscn-react-vendor | dist/wscn-react-vendor.js | function (root, className) {
var all = ReactTestUtils.scryRenderedDOMComponentsWithClass(root, className);
if (all.length !== 1) {
throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for class:' + className);
}
return all[0];
} | javascript | function (root, className) {
var all = ReactTestUtils.scryRenderedDOMComponentsWithClass(root, className);
if (all.length !== 1) {
throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for class:' + className);
}
return all[0];
} | [
"function",
"(",
"root",
",",
"className",
")",
"{",
"var",
"all",
"=",
"ReactTestUtils",
".",
"scryRenderedDOMComponentsWithClass",
"(",
"root",
",",
"className",
")",
";",
"if",
"(",
"all",
".",
"length",
"!==",
"1",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Did not find exactly one match (found: '",
"+",
"all",
".",
"length",
"+",
"') '",
"+",
"'for class:'",
"+",
"className",
")",
";",
"}",
"return",
"all",
"[",
"0",
"]",
";",
"}"
] | Like scryRenderedDOMComponentsWithClass but expects there to be one result,
and returns that one result, or throws exception if there is any other
number of matches besides one.
@return {!ReactDOMComponent} The one match. | [
"Like",
"scryRenderedDOMComponentsWithClass",
"but",
"expects",
"there",
"to",
"be",
"one",
"result",
"and",
"returns",
"that",
"one",
"result",
"or",
"throws",
"exception",
"if",
"there",
"is",
"any",
"other",
"number",
"of",
"matches",
"besides",
"one",
"."
] | 4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2 | https://github.com/wscn-FED/wscn-react-vendor/blob/4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2/dist/wscn-react-vendor.js#L15590-L15596 |
|
51,586 | wscn-FED/wscn-react-vendor | dist/wscn-react-vendor.js | function (root, tagName) {
return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
return ReactTestUtils.isDOMComponent(inst) && inst.tagName.toUpperCase() === tagName.toUpperCase();
});
} | javascript | function (root, tagName) {
return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
return ReactTestUtils.isDOMComponent(inst) && inst.tagName.toUpperCase() === tagName.toUpperCase();
});
} | [
"function",
"(",
"root",
",",
"tagName",
")",
"{",
"return",
"ReactTestUtils",
".",
"findAllInRenderedTree",
"(",
"root",
",",
"function",
"(",
"inst",
")",
"{",
"return",
"ReactTestUtils",
".",
"isDOMComponent",
"(",
"inst",
")",
"&&",
"inst",
".",
"tagName",
".",
"toUpperCase",
"(",
")",
"===",
"tagName",
".",
"toUpperCase",
"(",
")",
";",
"}",
")",
";",
"}"
] | Finds all instance of components in the rendered tree that are DOM
components with the tag name matching `tagName`.
@return {array} an array of all the matches. | [
"Finds",
"all",
"instance",
"of",
"components",
"in",
"the",
"rendered",
"tree",
"that",
"are",
"DOM",
"components",
"with",
"the",
"tag",
"name",
"matching",
"tagName",
"."
] | 4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2 | https://github.com/wscn-FED/wscn-react-vendor/blob/4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2/dist/wscn-react-vendor.js#L15603-L15607 |
|
51,587 | wscn-FED/wscn-react-vendor | dist/wscn-react-vendor.js | function (root, tagName) {
var all = ReactTestUtils.scryRenderedDOMComponentsWithTag(root, tagName);
if (all.length !== 1) {
throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for tag:' + tagName);
}
return all[0];
} | javascript | function (root, tagName) {
var all = ReactTestUtils.scryRenderedDOMComponentsWithTag(root, tagName);
if (all.length !== 1) {
throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for tag:' + tagName);
}
return all[0];
} | [
"function",
"(",
"root",
",",
"tagName",
")",
"{",
"var",
"all",
"=",
"ReactTestUtils",
".",
"scryRenderedDOMComponentsWithTag",
"(",
"root",
",",
"tagName",
")",
";",
"if",
"(",
"all",
".",
"length",
"!==",
"1",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Did not find exactly one match (found: '",
"+",
"all",
".",
"length",
"+",
"') '",
"+",
"'for tag:'",
"+",
"tagName",
")",
";",
"}",
"return",
"all",
"[",
"0",
"]",
";",
"}"
] | Like scryRenderedDOMComponentsWithTag but expects there to be one result,
and returns that one result, or throws exception if there is any other
number of matches besides one.
@return {!ReactDOMComponent} The one match. | [
"Like",
"scryRenderedDOMComponentsWithTag",
"but",
"expects",
"there",
"to",
"be",
"one",
"result",
"and",
"returns",
"that",
"one",
"result",
"or",
"throws",
"exception",
"if",
"there",
"is",
"any",
"other",
"number",
"of",
"matches",
"besides",
"one",
"."
] | 4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2 | https://github.com/wscn-FED/wscn-react-vendor/blob/4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2/dist/wscn-react-vendor.js#L15615-L15621 |
|
51,588 | wscn-FED/wscn-react-vendor | dist/wscn-react-vendor.js | function (root, componentType) {
return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
return ReactTestUtils.isCompositeComponentWithType(inst, componentType);
});
} | javascript | function (root, componentType) {
return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
return ReactTestUtils.isCompositeComponentWithType(inst, componentType);
});
} | [
"function",
"(",
"root",
",",
"componentType",
")",
"{",
"return",
"ReactTestUtils",
".",
"findAllInRenderedTree",
"(",
"root",
",",
"function",
"(",
"inst",
")",
"{",
"return",
"ReactTestUtils",
".",
"isCompositeComponentWithType",
"(",
"inst",
",",
"componentType",
")",
";",
"}",
")",
";",
"}"
] | Finds all instances of components with type equal to `componentType`.
@return {array} an array of all the matches. | [
"Finds",
"all",
"instances",
"of",
"components",
"with",
"type",
"equal",
"to",
"componentType",
"."
] | 4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2 | https://github.com/wscn-FED/wscn-react-vendor/blob/4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2/dist/wscn-react-vendor.js#L15627-L15631 |
|
51,589 | wscn-FED/wscn-react-vendor | dist/wscn-react-vendor.js | function (root, componentType) {
var all = ReactTestUtils.scryRenderedComponentsWithType(root, componentType);
if (all.length !== 1) {
throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for componentType:' + componentType);
}
return all[0];
} | javascript | function (root, componentType) {
var all = ReactTestUtils.scryRenderedComponentsWithType(root, componentType);
if (all.length !== 1) {
throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for componentType:' + componentType);
}
return all[0];
} | [
"function",
"(",
"root",
",",
"componentType",
")",
"{",
"var",
"all",
"=",
"ReactTestUtils",
".",
"scryRenderedComponentsWithType",
"(",
"root",
",",
"componentType",
")",
";",
"if",
"(",
"all",
".",
"length",
"!==",
"1",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Did not find exactly one match (found: '",
"+",
"all",
".",
"length",
"+",
"') '",
"+",
"'for componentType:'",
"+",
"componentType",
")",
";",
"}",
"return",
"all",
"[",
"0",
"]",
";",
"}"
] | Same as `scryRenderedComponentsWithType` but expects there to be one result
and returns that one result, or throws exception if there is any other
number of matches besides one.
@return {!ReactComponent} The one match. | [
"Same",
"as",
"scryRenderedComponentsWithType",
"but",
"expects",
"there",
"to",
"be",
"one",
"result",
"and",
"returns",
"that",
"one",
"result",
"or",
"throws",
"exception",
"if",
"there",
"is",
"any",
"other",
"number",
"of",
"matches",
"besides",
"one",
"."
] | 4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2 | https://github.com/wscn-FED/wscn-react-vendor/blob/4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2/dist/wscn-react-vendor.js#L15639-L15645 |
|
51,590 | wscn-FED/wscn-react-vendor | dist/wscn-react-vendor.js | function (topLevelType, node, fakeNativeEvent) {
fakeNativeEvent.target = node;
ReactBrowserEventEmitter.ReactEventListener.dispatchEvent(topLevelType, fakeNativeEvent);
} | javascript | function (topLevelType, node, fakeNativeEvent) {
fakeNativeEvent.target = node;
ReactBrowserEventEmitter.ReactEventListener.dispatchEvent(topLevelType, fakeNativeEvent);
} | [
"function",
"(",
"topLevelType",
",",
"node",
",",
"fakeNativeEvent",
")",
"{",
"fakeNativeEvent",
".",
"target",
"=",
"node",
";",
"ReactBrowserEventEmitter",
".",
"ReactEventListener",
".",
"dispatchEvent",
"(",
"topLevelType",
",",
"fakeNativeEvent",
")",
";",
"}"
] | Simulates a top level event being dispatched from a raw event that occurred
on an `Element` node.
@param {Object} topLevelType A type from `EventConstants.topLevelTypes`
@param {!Element} node The dom to simulate an event occurring on.
@param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent. | [
"Simulates",
"a",
"top",
"level",
"event",
"being",
"dispatched",
"from",
"a",
"raw",
"event",
"that",
"occurred",
"on",
"an",
"Element",
"node",
"."
] | 4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2 | https://github.com/wscn-FED/wscn-react-vendor/blob/4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2/dist/wscn-react-vendor.js#L15677-L15680 |
|
51,591 | wscn-FED/wscn-react-vendor | dist/wscn-react-vendor.js | matchesSelector | function matchesSelector(element, selector) {
var matchesImpl = element.matches || element.webkitMatchesSelector || element.mozMatchesSelector || element.msMatchesSelector || function (s) {
return matchesSelector_SLOW(element, s);
};
return matchesImpl.call(element, selector);
} | javascript | function matchesSelector(element, selector) {
var matchesImpl = element.matches || element.webkitMatchesSelector || element.mozMatchesSelector || element.msMatchesSelector || function (s) {
return matchesSelector_SLOW(element, s);
};
return matchesImpl.call(element, selector);
} | [
"function",
"matchesSelector",
"(",
"element",
",",
"selector",
")",
"{",
"var",
"matchesImpl",
"=",
"element",
".",
"matches",
"||",
"element",
".",
"webkitMatchesSelector",
"||",
"element",
".",
"mozMatchesSelector",
"||",
"element",
".",
"msMatchesSelector",
"||",
"function",
"(",
"s",
")",
"{",
"return",
"matchesSelector_SLOW",
"(",
"element",
",",
"s",
")",
";",
"}",
";",
"return",
"matchesImpl",
".",
"call",
"(",
"element",
",",
"selector",
")",
";",
"}"
] | Tests whether the element matches the selector specified
@param {DOMNode|DOMWindow} element the element that we are querying
@param {string} selector the CSS selector
@return {boolean} true if the element matches the selector, false if not | [
"Tests",
"whether",
"the",
"element",
"matches",
"the",
"selector",
"specified"
] | 4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2 | https://github.com/wscn-FED/wscn-react-vendor/blob/4a7fb1020c20ba3ffe71a2ad959f24ed0bacbdb2/dist/wscn-react-vendor.js#L21658-L21663 |
51,592 | radixdlt/radixdlt-js-lite | src/connection-handler.js | registerApp | function registerApp(name, description, permissions) {
const CONNECTION = new Connection();
return new Promise((resolve, reject) => {
CONNECTION.register(name, description, permissions)
.then(() => resolve(new ConnectionHandler(CONNECTION)))
.catch((error) => reject(error));
});
} | javascript | function registerApp(name, description, permissions) {
const CONNECTION = new Connection();
return new Promise((resolve, reject) => {
CONNECTION.register(name, description, permissions)
.then(() => resolve(new ConnectionHandler(CONNECTION)))
.catch((error) => reject(error));
});
} | [
"function",
"registerApp",
"(",
"name",
",",
"description",
",",
"permissions",
")",
"{",
"const",
"CONNECTION",
"=",
"new",
"Connection",
"(",
")",
";",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"CONNECTION",
".",
"register",
"(",
"name",
",",
"description",
",",
"permissions",
")",
".",
"then",
"(",
"(",
")",
"=>",
"resolve",
"(",
"new",
"ConnectionHandler",
"(",
"CONNECTION",
")",
")",
")",
".",
"catch",
"(",
"(",
"error",
")",
"=>",
"reject",
"(",
"error",
")",
")",
";",
"}",
")",
";",
"}"
] | Register an App.
@param {string} name - App's name.
@param {string} description - App's description.
@param {string[]} permissions - Permissions requested by this App.
@returns {Promise} | [
"Register",
"an",
"App",
"."
] | 8ee699d9eed3c7f843ea45c81f2924dfb419d903 | https://github.com/radixdlt/radixdlt-js-lite/blob/8ee699d9eed3c7f843ea45c81f2924dfb419d903/src/connection-handler.js#L65-L73 |
51,593 | radixdlt/radixdlt-js-lite | src/connection-handler.js | connectApp | function connectApp(token) {
const CONNECTION = new Connection();
return new Promise((resolve, reject) => {
CONNECTION.connect(token)
.then(() => resolve(new ConnectionHandler(CONNECTION)))
.catch((error) => reject(error));
});
} | javascript | function connectApp(token) {
const CONNECTION = new Connection();
return new Promise((resolve, reject) => {
CONNECTION.connect(token)
.then(() => resolve(new ConnectionHandler(CONNECTION)))
.catch((error) => reject(error));
});
} | [
"function",
"connectApp",
"(",
"token",
")",
"{",
"const",
"CONNECTION",
"=",
"new",
"Connection",
"(",
")",
";",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"CONNECTION",
".",
"connect",
"(",
"token",
")",
".",
"then",
"(",
"(",
")",
"=>",
"resolve",
"(",
"new",
"ConnectionHandler",
"(",
"CONNECTION",
")",
")",
")",
".",
"catch",
"(",
"(",
"error",
")",
"=>",
"reject",
"(",
"error",
")",
")",
";",
"}",
")",
";",
"}"
] | Re-connects an App with a valid token.
@param {string} token - Auth token.
@returns {Promise} | [
"Re",
"-",
"connects",
"an",
"App",
"with",
"a",
"valid",
"token",
"."
] | 8ee699d9eed3c7f843ea45c81f2924dfb419d903 | https://github.com/radixdlt/radixdlt-js-lite/blob/8ee699d9eed3c7f843ea45c81f2924dfb419d903/src/connection-handler.js#L80-L88 |
51,594 | darrylwest/node-messaging-commons | browser/browser-messaging-commons.js | function(options) {
'use strict';
var client = this,
log = options.log,
socketHost = options.socketHost,
hubName = options.hubName,
hub;
/**
* open the public/private channels to begin exchanges
*/
this.subscribe = function(channelName, handler, callback) {
client.createHub();
if (typeof handler !== 'function') {
throw new Error('must subscribe with a handler, using default...');
}
log.info('open the access channel: ', channelName);
hub.subscribe( channelName, handler ).then(function() {
log.info('channel ', channelName, ' now alive...');
if (callback) {
callback( channelName );
}
});
};
/**
* wrap the request message and publish to the specified channel
*
* @param channel - the channel name
* @param id - the ssid
* @param request - the message body
*/
this.publish = function(channel, id, request) {
var message = client.wrapMessage(id, request);
if (log.isDebug()) {
log.debug('publish to ', channel, ', message: ', JSON.stringify( message ));
}
hub.publish( channel, message );
};
/**
* create the message hub from socket host
*
* @returns the message hub
*/
this.createHub = function() {
if (!hub) {
hub = new Faye.Client( socketHost + hubName, { timeout:45 });
}
return hub;
};
/**
* create the standard wrapper
*
* @param request a request object
* @returns the wrapped message request
*/
this.wrapMessage = function(id, request) {
var message = {
ts:Date.now(),
message:request
};
if (id) {
message.id = id;
}
return message;
};
// constructor validations
if (!log) throw new Error('access client must be constructed with a log');
} | javascript | function(options) {
'use strict';
var client = this,
log = options.log,
socketHost = options.socketHost,
hubName = options.hubName,
hub;
/**
* open the public/private channels to begin exchanges
*/
this.subscribe = function(channelName, handler, callback) {
client.createHub();
if (typeof handler !== 'function') {
throw new Error('must subscribe with a handler, using default...');
}
log.info('open the access channel: ', channelName);
hub.subscribe( channelName, handler ).then(function() {
log.info('channel ', channelName, ' now alive...');
if (callback) {
callback( channelName );
}
});
};
/**
* wrap the request message and publish to the specified channel
*
* @param channel - the channel name
* @param id - the ssid
* @param request - the message body
*/
this.publish = function(channel, id, request) {
var message = client.wrapMessage(id, request);
if (log.isDebug()) {
log.debug('publish to ', channel, ', message: ', JSON.stringify( message ));
}
hub.publish( channel, message );
};
/**
* create the message hub from socket host
*
* @returns the message hub
*/
this.createHub = function() {
if (!hub) {
hub = new Faye.Client( socketHost + hubName, { timeout:45 });
}
return hub;
};
/**
* create the standard wrapper
*
* @param request a request object
* @returns the wrapped message request
*/
this.wrapMessage = function(id, request) {
var message = {
ts:Date.now(),
message:request
};
if (id) {
message.id = id;
}
return message;
};
// constructor validations
if (!log) throw new Error('access client must be constructed with a log');
} | [
"function",
"(",
"options",
")",
"{",
"'use strict'",
";",
"var",
"client",
"=",
"this",
",",
"log",
"=",
"options",
".",
"log",
",",
"socketHost",
"=",
"options",
".",
"socketHost",
",",
"hubName",
"=",
"options",
".",
"hubName",
",",
"hub",
";",
"/**\n * open the public/private channels to begin exchanges\n */",
"this",
".",
"subscribe",
"=",
"function",
"(",
"channelName",
",",
"handler",
",",
"callback",
")",
"{",
"client",
".",
"createHub",
"(",
")",
";",
"if",
"(",
"typeof",
"handler",
"!==",
"'function'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'must subscribe with a handler, using default...'",
")",
";",
"}",
"log",
".",
"info",
"(",
"'open the access channel: '",
",",
"channelName",
")",
";",
"hub",
".",
"subscribe",
"(",
"channelName",
",",
"handler",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"log",
".",
"info",
"(",
"'channel '",
",",
"channelName",
",",
"' now alive...'",
")",
";",
"if",
"(",
"callback",
")",
"{",
"callback",
"(",
"channelName",
")",
";",
"}",
"}",
")",
";",
"}",
";",
"/**\n * wrap the request message and publish to the specified channel\n *\n * @param channel - the channel name\n * @param id - the ssid\n * @param request - the message body\n */",
"this",
".",
"publish",
"=",
"function",
"(",
"channel",
",",
"id",
",",
"request",
")",
"{",
"var",
"message",
"=",
"client",
".",
"wrapMessage",
"(",
"id",
",",
"request",
")",
";",
"if",
"(",
"log",
".",
"isDebug",
"(",
")",
")",
"{",
"log",
".",
"debug",
"(",
"'publish to '",
",",
"channel",
",",
"', message: '",
",",
"JSON",
".",
"stringify",
"(",
"message",
")",
")",
";",
"}",
"hub",
".",
"publish",
"(",
"channel",
",",
"message",
")",
";",
"}",
";",
"/**\n * create the message hub from socket host\n *\n * @returns the message hub\n */",
"this",
".",
"createHub",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"!",
"hub",
")",
"{",
"hub",
"=",
"new",
"Faye",
".",
"Client",
"(",
"socketHost",
"+",
"hubName",
",",
"{",
"timeout",
":",
"45",
"}",
")",
";",
"}",
"return",
"hub",
";",
"}",
";",
"/**\n * create the standard wrapper\n *\n * @param request a request object\n * @returns the wrapped message request\n */",
"this",
".",
"wrapMessage",
"=",
"function",
"(",
"id",
",",
"request",
")",
"{",
"var",
"message",
"=",
"{",
"ts",
":",
"Date",
".",
"now",
"(",
")",
",",
"message",
":",
"request",
"}",
";",
"if",
"(",
"id",
")",
"{",
"message",
".",
"id",
"=",
"id",
";",
"}",
"return",
"message",
";",
"}",
";",
"// constructor validations",
"if",
"(",
"!",
"log",
")",
"throw",
"new",
"Error",
"(",
"'access client must be constructed with a log'",
")",
";",
"}"
] | AbstractMessageClient - browser side base class
@author: [email protected]
@created: 8/31/14 | [
"AbstractMessageClient",
"-",
"browser",
"side",
"base",
"class"
] | 31907d87ced947075013a79f879e71a310eb52e1 | https://github.com/darrylwest/node-messaging-commons/blob/31907d87ced947075013a79f879e71a310eb52e1/browser/browser-messaging-commons.js#L7-L88 |
|
51,595 | pzlr/build-core | lib/block.js | validateCache | function validateCache(path, cache) {
const
{mtime} = fs.statSync(path);
return {
mtime,
fromCache: Boolean(cache[path] && Sugar.Date.is(mtime, cache[path].mtime))
};
} | javascript | function validateCache(path, cache) {
const
{mtime} = fs.statSync(path);
return {
mtime,
fromCache: Boolean(cache[path] && Sugar.Date.is(mtime, cache[path].mtime))
};
} | [
"function",
"validateCache",
"(",
"path",
",",
"cache",
")",
"{",
"const",
"{",
"mtime",
"}",
"=",
"fs",
".",
"statSync",
"(",
"path",
")",
";",
"return",
"{",
"mtime",
",",
"fromCache",
":",
"Boolean",
"(",
"cache",
"[",
"path",
"]",
"&&",
"Sugar",
".",
"Date",
".",
"is",
"(",
"mtime",
",",
"cache",
"[",
"path",
"]",
".",
"mtime",
")",
")",
"}",
";",
"}"
] | Validates a file by the specified path and return meta information
@param {string} path
@param {!Object} cache - cache object
@returns {{mtime: !Object, fromCache: boolean}} | [
"Validates",
"a",
"file",
"by",
"the",
"specified",
"path",
"and",
"return",
"meta",
"information"
] | 11e20eda500682b9fa62c7804c66be1714df0df4 | https://github.com/pzlr/build-core/blob/11e20eda500682b9fa62c7804c66be1714df0df4/lib/block.js#L30-L38 |
51,596 | pzlr/build-core | lib/block.js | getFile | function getFile(path) {
const
cache = validateCache(path, filesCache);
if (!cache.fromCache) {
filesCache[path] = {
mtime: cache.mtime,
content: fs.readFileSync(path, 'utf-8')
};
}
return filesCache[path].content;
} | javascript | function getFile(path) {
const
cache = validateCache(path, filesCache);
if (!cache.fromCache) {
filesCache[path] = {
mtime: cache.mtime,
content: fs.readFileSync(path, 'utf-8')
};
}
return filesCache[path].content;
} | [
"function",
"getFile",
"(",
"path",
")",
"{",
"const",
"cache",
"=",
"validateCache",
"(",
"path",
",",
"filesCache",
")",
";",
"if",
"(",
"!",
"cache",
".",
"fromCache",
")",
"{",
"filesCache",
"[",
"path",
"]",
"=",
"{",
"mtime",
":",
"cache",
".",
"mtime",
",",
"content",
":",
"fs",
".",
"readFileSync",
"(",
"path",
",",
"'utf-8'",
")",
"}",
";",
"}",
"return",
"filesCache",
"[",
"path",
"]",
".",
"content",
";",
"}"
] | Returns a file content by the specified path
@param {string} path
@returns {string} | [
"Returns",
"a",
"file",
"content",
"by",
"the",
"specified",
"path"
] | 11e20eda500682b9fa62c7804c66be1714df0df4 | https://github.com/pzlr/build-core/blob/11e20eda500682b9fa62c7804c66be1714df0df4/lib/block.js#L46-L58 |
51,597 | gethuman/pancakes-recipe | utils/bulk.change.js | BulkChange | function BulkChange(model) {
this.model = model;
this.bulk = model.collection.initializeUnorderedBulkOp();
this.isChange = false;
} | javascript | function BulkChange(model) {
this.model = model;
this.bulk = model.collection.initializeUnorderedBulkOp();
this.isChange = false;
} | [
"function",
"BulkChange",
"(",
"model",
")",
"{",
"this",
".",
"model",
"=",
"model",
";",
"this",
".",
"bulk",
"=",
"model",
".",
"collection",
".",
"initializeUnorderedBulkOp",
"(",
")",
";",
"this",
".",
"isChange",
"=",
"false",
";",
"}"
] | Constructor used to start the undordered bulk operation
@param model
@constructor | [
"Constructor",
"used",
"to",
"start",
"the",
"undordered",
"bulk",
"operation"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/utils/bulk.change.js#L14-L18 |
51,598 | quantumpayments/media | bin/view.js | getMediaByBuffer | function getMediaByBuffer (uri, cert, mode, user, safe, bufferURI) {
var bufferPath = root
if (bufferURI) {
bufferPath += '/../' + url.parse(bufferURI).path
}
return new Promise(function (resolve, reject) {
// var bufferPath = __dirname + '/../data/buffer/image/'
debug('bufferPath', bufferPath)
var files = fs.readdirSync(bufferPath)
files.sort(function (a, b) {
return fs.statSync(bufferPath + b).mtime.getTime() -
fs.statSync(bufferPath + a).mtime.getTime()
})
var file = getNextFile(files)
debug('nextFile', file)
if (file) {
var nextFile = bufferPath + file
var ret = { 'uri': nextFile, 'cacheURI': urlencode.decode(file) }
// var lastFile = bufferPath + files[files.length - 1]
resolve(ret)
} else {
reject(new Error('nothing in buffer'))
}
balance(user).then((ret) => {
return ret
}).then(function (ret) {
if (ret >= algos.getRandomUnseenImage.cost) {
addMediaToBuffer(uri, cert, mode, user, safe, bufferURI)
} else {
reject(new Error('not enough funds'))
}
})
})
} | javascript | function getMediaByBuffer (uri, cert, mode, user, safe, bufferURI) {
var bufferPath = root
if (bufferURI) {
bufferPath += '/../' + url.parse(bufferURI).path
}
return new Promise(function (resolve, reject) {
// var bufferPath = __dirname + '/../data/buffer/image/'
debug('bufferPath', bufferPath)
var files = fs.readdirSync(bufferPath)
files.sort(function (a, b) {
return fs.statSync(bufferPath + b).mtime.getTime() -
fs.statSync(bufferPath + a).mtime.getTime()
})
var file = getNextFile(files)
debug('nextFile', file)
if (file) {
var nextFile = bufferPath + file
var ret = { 'uri': nextFile, 'cacheURI': urlencode.decode(file) }
// var lastFile = bufferPath + files[files.length - 1]
resolve(ret)
} else {
reject(new Error('nothing in buffer'))
}
balance(user).then((ret) => {
return ret
}).then(function (ret) {
if (ret >= algos.getRandomUnseenImage.cost) {
addMediaToBuffer(uri, cert, mode, user, safe, bufferURI)
} else {
reject(new Error('not enough funds'))
}
})
})
} | [
"function",
"getMediaByBuffer",
"(",
"uri",
",",
"cert",
",",
"mode",
",",
"user",
",",
"safe",
",",
"bufferURI",
")",
"{",
"var",
"bufferPath",
"=",
"root",
"if",
"(",
"bufferURI",
")",
"{",
"bufferPath",
"+=",
"'/../'",
"+",
"url",
".",
"parse",
"(",
"bufferURI",
")",
".",
"path",
"}",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"// var bufferPath = __dirname + '/../data/buffer/image/'",
"debug",
"(",
"'bufferPath'",
",",
"bufferPath",
")",
"var",
"files",
"=",
"fs",
".",
"readdirSync",
"(",
"bufferPath",
")",
"files",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"return",
"fs",
".",
"statSync",
"(",
"bufferPath",
"+",
"b",
")",
".",
"mtime",
".",
"getTime",
"(",
")",
"-",
"fs",
".",
"statSync",
"(",
"bufferPath",
"+",
"a",
")",
".",
"mtime",
".",
"getTime",
"(",
")",
"}",
")",
"var",
"file",
"=",
"getNextFile",
"(",
"files",
")",
"debug",
"(",
"'nextFile'",
",",
"file",
")",
"if",
"(",
"file",
")",
"{",
"var",
"nextFile",
"=",
"bufferPath",
"+",
"file",
"var",
"ret",
"=",
"{",
"'uri'",
":",
"nextFile",
",",
"'cacheURI'",
":",
"urlencode",
".",
"decode",
"(",
"file",
")",
"}",
"// var lastFile = bufferPath + files[files.length - 1]",
"resolve",
"(",
"ret",
")",
"}",
"else",
"{",
"reject",
"(",
"new",
"Error",
"(",
"'nothing in buffer'",
")",
")",
"}",
"balance",
"(",
"user",
")",
".",
"then",
"(",
"(",
"ret",
")",
"=>",
"{",
"return",
"ret",
"}",
")",
".",
"then",
"(",
"function",
"(",
"ret",
")",
"{",
"if",
"(",
"ret",
">=",
"algos",
".",
"getRandomUnseenImage",
".",
"cost",
")",
"{",
"addMediaToBuffer",
"(",
"uri",
",",
"cert",
",",
"mode",
",",
"user",
",",
"safe",
",",
"bufferURI",
")",
"}",
"else",
"{",
"reject",
"(",
"new",
"Error",
"(",
"'not enough funds'",
")",
")",
"}",
"}",
")",
"}",
")",
"}"
] | Get Media item from buffer
@param {string} uri The uri to get it from.
@param {string} cert Location of an X.509 cert.
@param {string} mode Mode api | http | buffer.
@param {string} user The WebID of the user.
@param {number} safe Whether safe search is on.
@param {string} bufferURI The URI of the buffer.
@return {object} Promise with the row. | [
"Get",
"Media",
"item",
"from",
"buffer"
] | b53034e6dd2a94dca950e60a49e403aceaa1cdf1 | https://github.com/quantumpayments/media/blob/b53034e6dd2a94dca950e60a49e403aceaa1cdf1/bin/view.js#L104-L140 |
51,599 | quantumpayments/media | bin/view.js | addMediaToBuffer | function addMediaToBuffer (uri, cert, mode, user, safe, bufferURI) {
// var bufferPath = root
// if (bufferURI) {
// bufferPath += '/../' + url.parse(bufferURI).path
// }
setTimeout(() => {
try {
// fs.unlinkSync(lastFile)
} catch (e) {
console.error(e)
}
var params = {}
params.reviewer = user
if (safe && safe === 'off') {
params.safe = 0
} else {
params.safe = 1
}
algos.getRandomUnseenImage.function(params).then(function (row) {
debug('unseen', row.ret)
var cacheURI = row.ret[0][0].cacheURI
var filePath = cacheURI.substr('file://'.length)
debug('copying', filePath)
// copyMedia(filePath, bufferPath + urlencode(cacheURI), function (err) {
copyMedia(filePath, bufferURI + urlencode(cacheURI), cert, function (err) {
if (err) {
debug(err)
} else {
console.log('success!')
// pay
var credit = {}
credit['https://w3id.org/cc#source'] = user
credit['https://w3id.org/cc#amount'] = algos.getRandomUnseenImage.cost
credit['https://w3id.org/cc#currency'] = 'https://w3id.org/cc#bit'
credit['https://w3id.org/cc#destination'] = algos.getRandomUnseenImage.counterparty
debug(credit)
pay(credit)
if (row && row.conn) {
row.conn.close()
}
}
})
})
}, 500)
} | javascript | function addMediaToBuffer (uri, cert, mode, user, safe, bufferURI) {
// var bufferPath = root
// if (bufferURI) {
// bufferPath += '/../' + url.parse(bufferURI).path
// }
setTimeout(() => {
try {
// fs.unlinkSync(lastFile)
} catch (e) {
console.error(e)
}
var params = {}
params.reviewer = user
if (safe && safe === 'off') {
params.safe = 0
} else {
params.safe = 1
}
algos.getRandomUnseenImage.function(params).then(function (row) {
debug('unseen', row.ret)
var cacheURI = row.ret[0][0].cacheURI
var filePath = cacheURI.substr('file://'.length)
debug('copying', filePath)
// copyMedia(filePath, bufferPath + urlencode(cacheURI), function (err) {
copyMedia(filePath, bufferURI + urlencode(cacheURI), cert, function (err) {
if (err) {
debug(err)
} else {
console.log('success!')
// pay
var credit = {}
credit['https://w3id.org/cc#source'] = user
credit['https://w3id.org/cc#amount'] = algos.getRandomUnseenImage.cost
credit['https://w3id.org/cc#currency'] = 'https://w3id.org/cc#bit'
credit['https://w3id.org/cc#destination'] = algos.getRandomUnseenImage.counterparty
debug(credit)
pay(credit)
if (row && row.conn) {
row.conn.close()
}
}
})
})
}, 500)
} | [
"function",
"addMediaToBuffer",
"(",
"uri",
",",
"cert",
",",
"mode",
",",
"user",
",",
"safe",
",",
"bufferURI",
")",
"{",
"// var bufferPath = root",
"// if (bufferURI) {",
"// bufferPath += '/../' + url.parse(bufferURI).path",
"// }",
"setTimeout",
"(",
"(",
")",
"=>",
"{",
"try",
"{",
"// fs.unlinkSync(lastFile)",
"}",
"catch",
"(",
"e",
")",
"{",
"console",
".",
"error",
"(",
"e",
")",
"}",
"var",
"params",
"=",
"{",
"}",
"params",
".",
"reviewer",
"=",
"user",
"if",
"(",
"safe",
"&&",
"safe",
"===",
"'off'",
")",
"{",
"params",
".",
"safe",
"=",
"0",
"}",
"else",
"{",
"params",
".",
"safe",
"=",
"1",
"}",
"algos",
".",
"getRandomUnseenImage",
".",
"function",
"(",
"params",
")",
".",
"then",
"(",
"function",
"(",
"row",
")",
"{",
"debug",
"(",
"'unseen'",
",",
"row",
".",
"ret",
")",
"var",
"cacheURI",
"=",
"row",
".",
"ret",
"[",
"0",
"]",
"[",
"0",
"]",
".",
"cacheURI",
"var",
"filePath",
"=",
"cacheURI",
".",
"substr",
"(",
"'file://'",
".",
"length",
")",
"debug",
"(",
"'copying'",
",",
"filePath",
")",
"// copyMedia(filePath, bufferPath + urlencode(cacheURI), function (err) {",
"copyMedia",
"(",
"filePath",
",",
"bufferURI",
"+",
"urlencode",
"(",
"cacheURI",
")",
",",
"cert",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"debug",
"(",
"err",
")",
"}",
"else",
"{",
"console",
".",
"log",
"(",
"'success!'",
")",
"// pay",
"var",
"credit",
"=",
"{",
"}",
"credit",
"[",
"'https://w3id.org/cc#source'",
"]",
"=",
"user",
"credit",
"[",
"'https://w3id.org/cc#amount'",
"]",
"=",
"algos",
".",
"getRandomUnseenImage",
".",
"cost",
"credit",
"[",
"'https://w3id.org/cc#currency'",
"]",
"=",
"'https://w3id.org/cc#bit'",
"credit",
"[",
"'https://w3id.org/cc#destination'",
"]",
"=",
"algos",
".",
"getRandomUnseenImage",
".",
"counterparty",
"debug",
"(",
"credit",
")",
"pay",
"(",
"credit",
")",
"if",
"(",
"row",
"&&",
"row",
".",
"conn",
")",
"{",
"row",
".",
"conn",
".",
"close",
"(",
")",
"}",
"}",
"}",
")",
"}",
")",
"}",
",",
"500",
")",
"}"
] | Adds media to buffer
@param {string} uri The uri to get it from.
@param {string} cert Location of an X.509 cert.
@param {string} mode Mode api | http | buffer.
@param {string} user The WebID of the user.
@param {number} safe Whether safe search is on.
@param {string} bufferURI The URI of the buffer.
@return {object} Promise with the row. | [
"Adds",
"media",
"to",
"buffer"
] | b53034e6dd2a94dca950e60a49e403aceaa1cdf1 | https://github.com/quantumpayments/media/blob/b53034e6dd2a94dca950e60a49e403aceaa1cdf1/bin/view.js#L152-L199 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.