repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
1stdibs/backbone-base-and-form-view | backbone-baseview.js | function (key, preserveElems) {
var subViews = (key && (typeof key === "string" || key.cid)) ? this.get(key) : key;
var len;
if (!subViews) { return this; }
if (!isArray(subViews)) {
subViews = [subViews];
}
len = subViews ? subView... | javascript | function (key, preserveElems) {
var subViews = (key && (typeof key === "string" || key.cid)) ? this.get(key) : key;
var len;
if (!subViews) { return this; }
if (!isArray(subViews)) {
subViews = [subViews];
}
len = subViews ? subView... | [
"function",
"(",
"key",
",",
"preserveElems",
")",
"{",
"var",
"subViews",
"=",
"(",
"key",
"&&",
"(",
"typeof",
"key",
"===",
"\"string\"",
"||",
"key",
".",
"cid",
")",
")",
"?",
"this",
".",
"get",
"(",
"key",
")",
":",
"key",
";",
"var",
"len... | Remove a subView
@memberOf SubViewManager#
@type {SubViewManager}
@param {String|Backbone.View|Backbone.Model} key
@param {Boolean} [preserveElems] If true, the View's element will not be removed from the DOM
@return {SubViewManager} | [
"Remove",
"a",
"subView"
] | 9c49f9ac059ba3177b61f7395151de78b506e8f7 | https://github.com/1stdibs/backbone-base-and-form-view/blob/9c49f9ac059ba3177b61f7395151de78b506e8f7/backbone-baseview.js#L602-L620 | train | |
1stdibs/backbone-base-and-form-view | backbone-baseview.js | function (keys, preserveElems) {
var i = 0;
var len = keys ? keys.length : 0;
for (i; i < len; i++) {
this.remove(keys[i], preserveElems);
}
return this;
} | javascript | function (keys, preserveElems) {
var i = 0;
var len = keys ? keys.length : 0;
for (i; i < len; i++) {
this.remove(keys[i], preserveElems);
}
return this;
} | [
"function",
"(",
"keys",
",",
"preserveElems",
")",
"{",
"var",
"i",
"=",
"0",
";",
"var",
"len",
"=",
"keys",
"?",
"keys",
".",
"length",
":",
"0",
";",
"for",
"(",
"i",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"this",
".",
"remove",
... | Remove's all subviews matching any
key in a list of keys
@memberOf SubViewManager#
@param {String[]} keys
@param {Boolean} [preserveElems=false]
If true, the views' elements will not
be removed from the DOM
@return {SubViewManager} | [
"Remove",
"s",
"all",
"subviews",
"matching",
"any",
"key",
"in",
"a",
"list",
"of",
"keys"
] | 9c49f9ac059ba3177b61f7395151de78b506e8f7 | https://github.com/1stdibs/backbone-base-and-form-view/blob/9c49f9ac059ba3177b61f7395151de78b506e8f7/backbone-baseview.js#L631-L638 | train | |
1stdibs/backbone-base-and-form-view | backbone-baseview.js | function (subViews) {
subViews = subViews || this.subViews;
var i = -1;
var len = subViews.length;
while (++i < len) {
subViews[i].remove();
}
return this;
} | javascript | function (subViews) {
subViews = subViews || this.subViews;
var i = -1;
var len = subViews.length;
while (++i < len) {
subViews[i].remove();
}
return this;
} | [
"function",
"(",
"subViews",
")",
"{",
"subViews",
"=",
"subViews",
"||",
"this",
".",
"subViews",
";",
"var",
"i",
"=",
"-",
"1",
";",
"var",
"len",
"=",
"subViews",
".",
"length",
";",
"while",
"(",
"++",
"i",
"<",
"len",
")",
"{",
"subViews",
... | Removes all subView '.el' element from the dom, or if passed a
list of subViews, removes only the elements in those.
@memberOf SubViewManager#
@type {SubViewManager}
@param {Backbone.View[]} subViews
@return {SubViewManager} | [
"Removes",
"all",
"subView",
".",
"el",
"element",
"from",
"the",
"dom",
"or",
"if",
"passed",
"a",
"list",
"of",
"subViews",
"removes",
"only",
"the",
"elements",
"in",
"those",
"."
] | 9c49f9ac059ba3177b61f7395151de78b506e8f7 | https://github.com/1stdibs/backbone-base-and-form-view/blob/9c49f9ac059ba3177b61f7395151de78b506e8f7/backbone-baseview.js#L647-L656 | train | |
1stdibs/backbone-base-and-form-view | backbone-baseview.js | function (key) {
if (key.cid) {
return this._subViewsByCid[key.cid] || this._subViewsByModelCid[key.cid];
}
if (key.indexOf('.') > -1 && this.dotNotation) {
var segs = key.split('.');
var view = this.parent;
while (segs.... | javascript | function (key) {
if (key.cid) {
return this._subViewsByCid[key.cid] || this._subViewsByModelCid[key.cid];
}
if (key.indexOf('.') > -1 && this.dotNotation) {
var segs = key.split('.');
var view = this.parent;
while (segs.... | [
"function",
"(",
"key",
")",
"{",
"if",
"(",
"key",
".",
"cid",
")",
"{",
"return",
"this",
".",
"_subViewsByCid",
"[",
"key",
".",
"cid",
"]",
"||",
"this",
".",
"_subViewsByModelCid",
"[",
"key",
".",
"cid",
"]",
";",
"}",
"if",
"(",
"key",
"."... | Get a subView instance or an array if multiple instances
match your key.
@memberOf SubViewManager#
@type {SubViewManager}
@param {Object|String} [key]
The key to a subView singleton, the view's cid
the associated model cid, the associated model itself,
or the associated view itself. If your key is a
string, you can use... | [
"Get",
"a",
"subView",
"instance",
"or",
"an",
"array",
"if",
"multiple",
"instances",
"match",
"your",
"key",
"."
] | 9c49f9ac059ba3177b61f7395151de78b506e8f7 | https://github.com/1stdibs/backbone-base-and-form-view/blob/9c49f9ac059ba3177b61f7395151de78b506e8f7/backbone-baseview.js#L692-L705 | train | |
1stdibs/backbone-base-and-form-view | backbone-baseview.js | function (subview) {
subview = (subview instanceof View === true) ? subview : this.get(subview);
return subview._subviewtype;
} | javascript | function (subview) {
subview = (subview instanceof View === true) ? subview : this.get(subview);
return subview._subviewtype;
} | [
"function",
"(",
"subview",
")",
"{",
"subview",
"=",
"(",
"subview",
"instanceof",
"View",
"===",
"true",
")",
"?",
"subview",
":",
"this",
".",
"get",
"(",
"subview",
")",
";",
"return",
"subview",
".",
"_subviewtype",
";",
"}"
] | Get the subviews type or key
@memberOf SubViewManager#
@type {SubViewManager}
@param subview
@return {String|Number} | [
"Get",
"the",
"subviews",
"type",
"or",
"key"
] | 9c49f9ac059ba3177b61f7395151de78b506e8f7 | https://github.com/1stdibs/backbone-base-and-form-view/blob/9c49f9ac059ba3177b61f7395151de78b506e8f7/backbone-baseview.js#L726-L729 | train | |
1stdibs/backbone-base-and-form-view | backbone-baseview.js | function (type) {
var confs = type ? _.pick(this.config, type) : this.config;
each(confs, function (config) {
this.parent.$(config.location).html('');
}, this);
return this;
} | javascript | function (type) {
var confs = type ? _.pick(this.config, type) : this.config;
each(confs, function (config) {
this.parent.$(config.location).html('');
}, this);
return this;
} | [
"function",
"(",
"type",
")",
"{",
"var",
"confs",
"=",
"type",
"?",
"_",
".",
"pick",
"(",
"this",
".",
"config",
",",
"type",
")",
":",
"this",
".",
"config",
";",
"each",
"(",
"confs",
",",
"function",
"(",
"config",
")",
"{",
"this",
".",
"... | Clears the html in all locations specified in the subview configs
@memberOf SubViewManager#
@type {SubViewManager}
@return {SubViewManager} | [
"Clears",
"the",
"html",
"in",
"all",
"locations",
"specified",
"in",
"the",
"subview",
"configs"
] | 9c49f9ac059ba3177b61f7395151de78b506e8f7 | https://github.com/1stdibs/backbone-base-and-form-view/blob/9c49f9ac059ba3177b61f7395151de78b506e8f7/backbone-baseview.js#L747-L753 | train | |
1stdibs/backbone-base-and-form-view | backbone-baseview.js | function () {
var html = '';
var template = this.template;
if (isFunction(template)) {
html = template(result(this, 'templateVars')) || '';
}
this.$el.html(html);
this.subs.renderAppend();
return this;
} | javascript | function () {
var html = '';
var template = this.template;
if (isFunction(template)) {
html = template(result(this, 'templateVars')) || '';
}
this.$el.html(html);
this.subs.renderAppend();
return this;
} | [
"function",
"(",
")",
"{",
"var",
"html",
"=",
"''",
";",
"var",
"template",
"=",
"this",
".",
"template",
";",
"if",
"(",
"isFunction",
"(",
"template",
")",
")",
"{",
"html",
"=",
"template",
"(",
"result",
"(",
"this",
",",
"'templateVars'",
")",
... | A basic render function that looks for a template
function, calls the template with the result of
the 'templateVars' property, and then set the html
to the result. Then, subviews are rendered and then
appended to their locations.
@memberOf Backbone.BaseView#
@return {Backbone.BaseView} | [
"A",
"basic",
"render",
"function",
"that",
"looks",
"for",
"a",
"template",
"function",
"calls",
"the",
"template",
"with",
"the",
"result",
"of",
"the",
"templateVars",
"property",
"and",
"then",
"set",
"the",
"html",
"to",
"the",
"result",
".",
"Then",
... | 9c49f9ac059ba3177b61f7395151de78b506e8f7 | https://github.com/1stdibs/backbone-base-and-form-view/blob/9c49f9ac059ba3177b61f7395151de78b506e8f7/backbone-baseview.js#L1105-L1114 | train | |
1stdibs/backbone-base-and-form-view | backbone-baseview.js | function (event) {
var args = slice.call(arguments, 1);
var stopPropogation;
var anscestor;
args.unshift(event);
args.push(this);
anscestor = this;
while (anscestor) {
anscestor.trigger.apply(anscestor, args);
... | javascript | function (event) {
var args = slice.call(arguments, 1);
var stopPropogation;
var anscestor;
args.unshift(event);
args.push(this);
anscestor = this;
while (anscestor) {
anscestor.trigger.apply(anscestor, args);
... | [
"function",
"(",
"event",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
";",
"var",
"stopPropogation",
";",
"var",
"anscestor",
";",
"args",
".",
"unshift",
"(",
"event",
")",
";",
"args",
".",
"push",
"(",
"t... | Like Backbone.trigger, except that this will not only use trigger
on the instance this method is invoked on, but also the instance's
'parentView', and the parentView's parentView, and so on.
Additional arguments beyond the event name will be passed
as arguments to the event handler functions. The view that
originated t... | [
"Like",
"Backbone",
".",
"trigger",
"except",
"that",
"this",
"will",
"not",
"only",
"use",
"trigger",
"on",
"the",
"instance",
"this",
"method",
"is",
"invoked",
"on",
"but",
"also",
"the",
"instance",
"s",
"parentView",
"and",
"the",
"parentView",
"s",
"... | 9c49f9ac059ba3177b61f7395151de78b506e8f7 | https://github.com/1stdibs/backbone-base-and-form-view/blob/9c49f9ac059ba3177b61f7395151de78b506e8f7/backbone-baseview.js#L1177-L1194 | train | |
1stdibs/backbone-base-and-form-view | backbone-baseview.js | function (event) {
var args = slice.call(arguments, 1);
var _trigger = function (subViews) {
var i = -1;
var len = subViews.length;
var subSubs;
var stopPropogation;
var descend;
while (++i < len) {
... | javascript | function (event) {
var args = slice.call(arguments, 1);
var _trigger = function (subViews) {
var i = -1;
var len = subViews.length;
var subSubs;
var stopPropogation;
var descend;
while (++i < len) {
... | [
"function",
"(",
"event",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
";",
"var",
"_trigger",
"=",
"function",
"(",
"subViews",
")",
"{",
"var",
"i",
"=",
"-",
"1",
";",
"var",
"len",
"=",
"subViews",
".",... | Triggers an event that will trigger on each of the instances
subViews, and then if a subView has subViews, will trigger the
event on that subViews' subViews, and so on. If a subView
calls stopEvent and passes the event name, then the event
will not trigger on that subViews' subViews. Arguments
work in the same manner a... | [
"Triggers",
"an",
"event",
"that",
"will",
"trigger",
"on",
"each",
"of",
"the",
"instances",
"subViews",
"and",
"then",
"if",
"a",
"subView",
"has",
"subViews",
"will",
"trigger",
"the",
"event",
"on",
"that",
"subViews",
"subViews",
"and",
"so",
"on",
".... | 9c49f9ac059ba3177b61f7395151de78b506e8f7 | https://github.com/1stdibs/backbone-base-and-form-view/blob/9c49f9ac059ba3177b61f7395151de78b506e8f7/backbone-baseview.js#L1207-L1233 | train | |
1stdibs/backbone-base-and-form-view | backbone-baseview.js | function (fnName, args) {
var func;
var ancestor = this;
var isFunc = isFunction(fnName);
while (ancestor.parentView) {
ancestor = ancestor.parentView;
if (ancestor) {
func = isFunc ? fnName : ancestor[fnName];
... | javascript | function (fnName, args) {
var func;
var ancestor = this;
var isFunc = isFunction(fnName);
while (ancestor.parentView) {
ancestor = ancestor.parentView;
if (ancestor) {
func = isFunc ? fnName : ancestor[fnName];
... | [
"function",
"(",
"fnName",
",",
"args",
")",
"{",
"var",
"func",
";",
"var",
"ancestor",
"=",
"this",
";",
"var",
"isFunc",
"=",
"isFunction",
"(",
"fnName",
")",
";",
"while",
"(",
"ancestor",
".",
"parentView",
")",
"{",
"ancestor",
"=",
"ancestor",
... | Invoke a function or method on ancestors
@memberOf Backbone.BaseView#
@param {Function|String} fnName
@param {mixed[]} [args]
An array of arguments to pass to
the invocation
@return {Backbone.BaseView} | [
"Invoke",
"a",
"function",
"or",
"method",
"on",
"ancestors"
] | 9c49f9ac059ba3177b61f7395151de78b506e8f7 | https://github.com/1stdibs/backbone-base-and-form-view/blob/9c49f9ac059ba3177b61f7395151de78b506e8f7/backbone-baseview.js#L1243-L1255 | train | |
1stdibs/backbone-base-and-form-view | backbone-baseview.js | function (testFn) {
var ancestor = this;
while (ancestor.parentView) {
ancestor = ancestor.parentView;
if (ancestor && testFn(ancestor)) {
return ancestor;
}
}
return null;
} | javascript | function (testFn) {
var ancestor = this;
while (ancestor.parentView) {
ancestor = ancestor.parentView;
if (ancestor && testFn(ancestor)) {
return ancestor;
}
}
return null;
} | [
"function",
"(",
"testFn",
")",
"{",
"var",
"ancestor",
"=",
"this",
";",
"while",
"(",
"ancestor",
".",
"parentView",
")",
"{",
"ancestor",
"=",
"ancestor",
".",
"parentView",
";",
"if",
"(",
"ancestor",
"&&",
"testFn",
"(",
"ancestor",
")",
")",
"{",... | Ascends up the ancestor line until an
a test function returns true
@param {Function} testFn
A function that returns a truthy
value if the current ancestor should be
returned
@return {Backbone.BaseView|null} | [
"Ascends",
"up",
"the",
"ancestor",
"line",
"until",
"an",
"a",
"test",
"function",
"returns",
"true"
] | 9c49f9ac059ba3177b61f7395151de78b506e8f7 | https://github.com/1stdibs/backbone-base-and-form-view/blob/9c49f9ac059ba3177b61f7395151de78b506e8f7/backbone-baseview.js#L1265-L1274 | train | |
1stdibs/backbone-base-and-form-view | backbone-baseview.js | function (events) {
events = events || result(this, 'viewEvents');
each(events, function (func, event) {
var segs = event.split(' ');
var listenTo = (segs.length > 1) ? this[segs[1]] : this;
func = isFunction(func) ? func : this[func];
... | javascript | function (events) {
events = events || result(this, 'viewEvents');
each(events, function (func, event) {
var segs = event.split(' ');
var listenTo = (segs.length > 1) ? this[segs[1]] : this;
func = isFunction(func) ? func : this[func];
... | [
"function",
"(",
"events",
")",
"{",
"events",
"=",
"events",
"||",
"result",
"(",
"this",
",",
"'viewEvents'",
")",
";",
"each",
"(",
"events",
",",
"function",
"(",
"func",
",",
"event",
")",
"{",
"var",
"segs",
"=",
"event",
".",
"split",
"(",
"... | Like delegateEvents, except that instead of events being bound to el, the
events are backbone events bound to the view object itself. You can create
a 'viewEvents' object literal property on a View's prototype, and when it's
instantiated, the view will listen for events on a Backone object based on
the key.
For exampl... | [
"Like",
"delegateEvents",
"except",
"that",
"instead",
"of",
"events",
"being",
"bound",
"to",
"el",
"the",
"events",
"are",
"backbone",
"events",
"bound",
"to",
"the",
"view",
"object",
"itself",
".",
"You",
"can",
"create",
"a",
"viewEvents",
"object",
"li... | 9c49f9ac059ba3177b61f7395151de78b506e8f7 | https://github.com/1stdibs/backbone-base-and-form-view/blob/9c49f9ac059ba3177b61f7395151de78b506e8f7/backbone-baseview.js#L1345-L1357 | train | |
1stdibs/backbone-base-and-form-view | backbone-baseview.js | function (viewInstance) {
console.assert(viewInstance instanceof Backbone.BaseView, 'viewInstance must be an instance of Backbone.BaseView');
var mixins = slice.call(arguments, 1);
_marinate(viewInstance, mixins);
} | javascript | function (viewInstance) {
console.assert(viewInstance instanceof Backbone.BaseView, 'viewInstance must be an instance of Backbone.BaseView');
var mixins = slice.call(arguments, 1);
_marinate(viewInstance, mixins);
} | [
"function",
"(",
"viewInstance",
")",
"{",
"console",
".",
"assert",
"(",
"viewInstance",
"instanceof",
"Backbone",
".",
"BaseView",
",",
"'viewInstance must be an instance of Backbone.BaseView'",
")",
";",
"var",
"mixins",
"=",
"slice",
".",
"call",
"(",
"arguments... | Marinate only an instance of a view
@memberOf module:marinate
@param {Backbone.BaseView} viewInstance
@param {...object} mixins | [
"Marinate",
"only",
"an",
"instance",
"of",
"a",
"view"
] | 9c49f9ac059ba3177b61f7395151de78b506e8f7 | https://github.com/1stdibs/backbone-base-and-form-view/blob/9c49f9ac059ba3177b61f7395151de78b506e8f7/backbone-baseview.js#L1460-L1464 | train | |
1stdibs/backbone-base-and-form-view | backbone-baseview.js | function (View, name, eventsObj) { //eslint-disable-line no-shadow
console.assert(View.prototype instanceof Backbone.BaseView, 'View must a Backbone.BaseView constructor');
_addEvents(View.prototype, name, eventsObj);
} | javascript | function (View, name, eventsObj) { //eslint-disable-line no-shadow
console.assert(View.prototype instanceof Backbone.BaseView, 'View must a Backbone.BaseView constructor');
_addEvents(View.prototype, name, eventsObj);
} | [
"function",
"(",
"View",
",",
"name",
",",
"eventsObj",
")",
"{",
"//eslint-disable-line no-shadow",
"console",
".",
"assert",
"(",
"View",
".",
"prototype",
"instanceof",
"Backbone",
".",
"BaseView",
",",
"'View must a Backbone.BaseView constructor'",
")",
";",
"_a... | Add DOM events to a BaseView pseudoclass
@memberOf module:marinate
@param {function} View Constructor for Backbone.BaseView
@param {string} name Namespace for your added events
@param {object} eventsObj Backbone DOM events hash | [
"Add",
"DOM",
"events",
"to",
"a",
"BaseView",
"pseudoclass"
] | 9c49f9ac059ba3177b61f7395151de78b506e8f7 | https://github.com/1stdibs/backbone-base-and-form-view/blob/9c49f9ac059ba3177b61f7395151de78b506e8f7/backbone-baseview.js#L1472-L1475 | train | |
1stdibs/backbone-base-and-form-view | backbone-baseview.js | function (viewInstance, name, eventsObj) {
console.assert(viewInstance instanceof Backbone.BaseView, 'viewInstance must be an instance of Backbone.BaseView');
_addEvents(viewInstance, name, eventsObj);
} | javascript | function (viewInstance, name, eventsObj) {
console.assert(viewInstance instanceof Backbone.BaseView, 'viewInstance must be an instance of Backbone.BaseView');
_addEvents(viewInstance, name, eventsObj);
} | [
"function",
"(",
"viewInstance",
",",
"name",
",",
"eventsObj",
")",
"{",
"console",
".",
"assert",
"(",
"viewInstance",
"instanceof",
"Backbone",
".",
"BaseView",
",",
"'viewInstance must be an instance of Backbone.BaseView'",
")",
";",
"_addEvents",
"(",
"viewInstan... | Add DOM events to a BaseView instance
@memberOf module:marinate
@param {Backbone.BaseView} viewInstance
@param {string} name Namespace for your added events
@param {object} eventsObj Backbone DOM events hash | [
"Add",
"DOM",
"events",
"to",
"a",
"BaseView",
"instance"
] | 9c49f9ac059ba3177b61f7395151de78b506e8f7 | https://github.com/1stdibs/backbone-base-and-form-view/blob/9c49f9ac059ba3177b61f7395151de78b506e8f7/backbone-baseview.js#L1483-L1486 | train | |
chip-js/observations-js | src/observations.js | function(context, expression, onChange, callbackContext) {
var observer = this.createObserver(expression, onChange, callbackContext || context);
observer.bind(context);
return observer;
} | javascript | function(context, expression, onChange, callbackContext) {
var observer = this.createObserver(expression, onChange, callbackContext || context);
observer.bind(context);
return observer;
} | [
"function",
"(",
"context",
",",
"expression",
",",
"onChange",
",",
"callbackContext",
")",
"{",
"var",
"observer",
"=",
"this",
".",
"createObserver",
"(",
"expression",
",",
"onChange",
",",
"callbackContext",
"||",
"context",
")",
";",
"observer",
".",
"... | Observes any changes to the result of the expression on the context object and calls the callback.
@param {Object} context The context to bind the expression against
@param {String} expression The expression to observe
@param {Function} onChange The function which will be called when the expression value changes
@retur... | [
"Observes",
"any",
"changes",
"to",
"the",
"result",
"of",
"the",
"expression",
"on",
"the",
"context",
"object",
"and",
"calls",
"the",
"callback",
"."
] | a48b32a648089bc86b502712d78cd0b3f8317d50 | https://github.com/chip-js/observations-js/blob/a48b32a648089bc86b502712d78cd0b3f8317d50/src/observations.js#L56-L60 | train | |
chip-js/observations-js | src/observations.js | function(expression, options) {
if (options && options.isSetter) {
return expressions.parseSetter(expression, this.globals, this.formatters, options.extraArgs);
} else if (options && options.extraArgs) {
var allArgs = [expression, this.globals, this.formatters].concat(options.extraArgs);
retur... | javascript | function(expression, options) {
if (options && options.isSetter) {
return expressions.parseSetter(expression, this.globals, this.formatters, options.extraArgs);
} else if (options && options.extraArgs) {
var allArgs = [expression, this.globals, this.formatters].concat(options.extraArgs);
retur... | [
"function",
"(",
"expression",
",",
"options",
")",
"{",
"if",
"(",
"options",
"&&",
"options",
".",
"isSetter",
")",
"{",
"return",
"expressions",
".",
"parseSetter",
"(",
"expression",
",",
"this",
".",
"globals",
",",
"this",
".",
"formatters",
",",
"... | Parses an expression into a function using the globals and formatters objects associated with this instance of
observations.
@param {String} expression The expression string to parse into a function
@param {Object} options Additional options to pass to the parser.
`{ isSetter: true }` will make this expression a setter... | [
"Parses",
"an",
"expression",
"into",
"a",
"function",
"using",
"the",
"globals",
"and",
"formatters",
"objects",
"associated",
"with",
"this",
"instance",
"of",
"observations",
"."
] | a48b32a648089bc86b502712d78cd0b3f8317d50 | https://github.com/chip-js/observations-js/blob/a48b32a648089bc86b502712d78cd0b3f8317d50/src/observations.js#L181-L190 | train | |
chip-js/observations-js | src/observations.js | function(source, expression, value) {
return this.getExpression(expression, { isSetter: true }).call(source, value);
} | javascript | function(source, expression, value) {
return this.getExpression(expression, { isSetter: true }).call(source, value);
} | [
"function",
"(",
"source",
",",
"expression",
",",
"value",
")",
"{",
"return",
"this",
".",
"getExpression",
"(",
"expression",
",",
"{",
"isSetter",
":",
"true",
"}",
")",
".",
"call",
"(",
"source",
",",
"value",
")",
";",
"}"
] | Sets the value on the expression in the given context object
@param {Object} context The context object the expression will be evaluated against
@param {String} expression The expression to set a value with
@param {mixed} value The value to set on the expression
@return {mixed} The result of the expression against the ... | [
"Sets",
"the",
"value",
"on",
"the",
"expression",
"in",
"the",
"given",
"context",
"object"
] | a48b32a648089bc86b502712d78cd0b3f8317d50 | https://github.com/chip-js/observations-js/blob/a48b32a648089bc86b502712d78cd0b3f8317d50/src/observations.js#L211-L213 | train | |
chip-js/observations-js | src/observations.js | function(callback) {
if (typeof callback === 'function') {
this.afterSync(callback);
}
if (this.pendingSync) {
return false;
}
var fallback = setTimeout(this.syncNow, 500);
this.windows = this.windows.filter(this.removeClosed);
this.pendingSync = this.windows.map(this.queueSync... | javascript | function(callback) {
if (typeof callback === 'function') {
this.afterSync(callback);
}
if (this.pendingSync) {
return false;
}
var fallback = setTimeout(this.syncNow, 500);
this.windows = this.windows.filter(this.removeClosed);
this.pendingSync = this.windows.map(this.queueSync... | [
"function",
"(",
"callback",
")",
"{",
"if",
"(",
"typeof",
"callback",
"===",
"'function'",
")",
"{",
"this",
".",
"afterSync",
"(",
"callback",
")",
";",
"}",
"if",
"(",
"this",
".",
"pendingSync",
")",
"{",
"return",
"false",
";",
"}",
"var",
"fal... | Schedules an observer sync cycle which checks all the observers to see if they've changed. | [
"Schedules",
"an",
"observer",
"sync",
"cycle",
"which",
"checks",
"all",
"the",
"observers",
"to",
"see",
"if",
"they",
"ve",
"changed",
"."
] | a48b32a648089bc86b502712d78cd0b3f8317d50 | https://github.com/chip-js/observations-js/blob/a48b32a648089bc86b502712d78cd0b3f8317d50/src/observations.js#L217-L230 | train | |
chip-js/observations-js | src/observations.js | function(callback) {
if (typeof callback === 'function') {
this.afterSync(callback);
}
if (this.pendingSync) {
clearTimeout(this.pendingSync.pop());
this.pendingSync.forEach(this.cancelQueue);
this.pendingSync = null;
}
if (this.syncing) {
this.rerun = true;
ret... | javascript | function(callback) {
if (typeof callback === 'function') {
this.afterSync(callback);
}
if (this.pendingSync) {
clearTimeout(this.pendingSync.pop());
this.pendingSync.forEach(this.cancelQueue);
this.pendingSync = null;
}
if (this.syncing) {
this.rerun = true;
ret... | [
"function",
"(",
"callback",
")",
"{",
"if",
"(",
"typeof",
"callback",
"===",
"'function'",
")",
"{",
"this",
".",
"afterSync",
"(",
"callback",
")",
";",
"}",
"if",
"(",
"this",
".",
"pendingSync",
")",
"{",
"clearTimeout",
"(",
"this",
".",
"pending... | Runs the observer sync cycle which checks all the observers to see if they've changed. | [
"Runs",
"the",
"observer",
"sync",
"cycle",
"which",
"checks",
"all",
"the",
"observers",
"to",
"see",
"if",
"they",
"ve",
"changed",
"."
] | a48b32a648089bc86b502712d78cd0b3f8317d50 | https://github.com/chip-js/observations-js/blob/a48b32a648089bc86b502712d78cd0b3f8317d50/src/observations.js#L234-L252 | train | |
chip-js/observations-js | src/observations.js | function(observer, skipUpdate) {
this.observers.add(observer);
if (!skipUpdate) {
observer.forceUpdateNextSync = true;
observer.sync();
}
} | javascript | function(observer, skipUpdate) {
this.observers.add(observer);
if (!skipUpdate) {
observer.forceUpdateNextSync = true;
observer.sync();
}
} | [
"function",
"(",
"observer",
",",
"skipUpdate",
")",
"{",
"this",
".",
"observers",
".",
"add",
"(",
"observer",
")",
";",
"if",
"(",
"!",
"skipUpdate",
")",
"{",
"observer",
".",
"forceUpdateNextSync",
"=",
"true",
";",
"observer",
".",
"sync",
"(",
"... | Adds a new observer to be synced with changes. If `skipUpdate` is true then the callback will only be called when a change is made, not initially. | [
"Adds",
"a",
"new",
"observer",
"to",
"be",
"synced",
"with",
"changes",
".",
"If",
"skipUpdate",
"is",
"true",
"then",
"the",
"callback",
"will",
"only",
"be",
"called",
"when",
"a",
"change",
"is",
"made",
"not",
"initially",
"."
] | a48b32a648089bc86b502712d78cd0b3f8317d50 | https://github.com/chip-js/observations-js/blob/a48b32a648089bc86b502712d78cd0b3f8317d50/src/observations.js#L329-L335 | train | |
inadarei/nodebootstrap-server | app.js | configure_logging | function configure_logging() {
if ('log' in CONF) {
if ('plugin' in CONF.log) { process.env.NODE_LOGGER_PLUGIN = CONF.log.plugin; }
if ('level' in CONF.log) { process.env.NODE_LOGGER_LEVEL = CONF.log.level; }
if ('customlevels' in CONF.log) {
for (var key in CONF.log.customlevels) {
proc... | javascript | function configure_logging() {
if ('log' in CONF) {
if ('plugin' in CONF.log) { process.env.NODE_LOGGER_PLUGIN = CONF.log.plugin; }
if ('level' in CONF.log) { process.env.NODE_LOGGER_LEVEL = CONF.log.level; }
if ('customlevels' in CONF.log) {
for (var key in CONF.log.customlevels) {
proc... | [
"function",
"configure_logging",
"(",
")",
"{",
"if",
"(",
"'log'",
"in",
"CONF",
")",
"{",
"if",
"(",
"'plugin'",
"in",
"CONF",
".",
"log",
")",
"{",
"process",
".",
"env",
".",
"NODE_LOGGER_PLUGIN",
"=",
"CONF",
".",
"log",
".",
"plugin",
";",
"}",... | Default configuration of logging | [
"Default",
"configuration",
"of",
"logging"
] | 250b5affd440b6030e7fb7eb435c5d952abf91af | https://github.com/inadarei/nodebootstrap-server/blob/250b5affd440b6030e7fb7eb435c5d952abf91af/app.js#L117-L129 | train |
ofidj/fidj | .todo/miapp.tools.storage.js | errorMessage | function errorMessage(fileError) {
var msg = '';
switch (fileError.code) {
case FileError.NOT_FOUND_ERR:
msg = 'File not found';
break;
case FileError.SECURITY_ERR:
// You may need the --allow-file-access-from-files flag
... | javascript | function errorMessage(fileError) {
var msg = '';
switch (fileError.code) {
case FileError.NOT_FOUND_ERR:
msg = 'File not found';
break;
case FileError.SECURITY_ERR:
// You may need the --allow-file-access-from-files flag
... | [
"function",
"errorMessage",
"(",
"fileError",
")",
"{",
"var",
"msg",
"=",
"''",
";",
"switch",
"(",
"fileError",
".",
"code",
")",
"{",
"case",
"FileError",
".",
"NOT_FOUND_ERR",
":",
"msg",
"=",
"'File not found'",
";",
"break",
";",
"case",
"FileError",... | Private API helper functions and variables hidden within this function scope | [
"Private",
"API",
"helper",
"functions",
"and",
"variables",
"hidden",
"within",
"this",
"function",
"scope"
] | e57ebece54ee68211d43802a8e0feeef098d3e36 | https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.storage.js#L1356-L1404 | train |
cafjs/caf_components | lib/templateUtils.js | function(template, delta) {
assert.ok(Array.isArray(template), "'template' is not an array");
assert.ok(Array.isArray(delta), "'delta' is not an array");
/*
* This merge step is inefficient O(n*m) but we are assuming small arrays
* and 'delta' typically smaller than 'template'.
*
* ... | javascript | function(template, delta) {
assert.ok(Array.isArray(template), "'template' is not an array");
assert.ok(Array.isArray(delta), "'delta' is not an array");
/*
* This merge step is inefficient O(n*m) but we are assuming small arrays
* and 'delta' typically smaller than 'template'.
*
* ... | [
"function",
"(",
"template",
",",
"delta",
")",
"{",
"assert",
".",
"ok",
"(",
"Array",
".",
"isArray",
"(",
"template",
")",
",",
"\"'template' is not an array\"",
")",
";",
"assert",
".",
"ok",
"(",
"Array",
".",
"isArray",
"(",
"delta",
")",
",",
"\... | Merge two component arrays of matching components.
@param {Array.<specType>} template
@param {Array.<specDeltaType>} delta
@return {Array.<specType>} result | [
"Merge",
"two",
"component",
"arrays",
"of",
"matching",
"components",
"."
] | dca28007d6618066df8ed058362f0d4a0745c2cf | https://github.com/cafjs/caf_components/blob/dca28007d6618066df8ed058362f0d4a0745c2cf/lib/templateUtils.js#L63-L126 | train | |
cafjs/caf_components | lib/templateUtils.js | function(template, delta) {
assert.equal(typeof(template), 'object', "'template' is not an object");
assert.equal(typeof(delta), 'object', "'delta' is not an object");
var result = myUtils.deepClone(template);
Object.keys(delta).forEach(function(x) {
result[x] = myUtils.deepClone(delta[x]);
... | javascript | function(template, delta) {
assert.equal(typeof(template), 'object', "'template' is not an object");
assert.equal(typeof(delta), 'object', "'delta' is not an object");
var result = myUtils.deepClone(template);
Object.keys(delta).forEach(function(x) {
result[x] = myUtils.deepClone(delta[x]);
... | [
"function",
"(",
"template",
",",
"delta",
")",
"{",
"assert",
".",
"equal",
"(",
"typeof",
"(",
"template",
")",
",",
"'object'",
",",
"\"'template' is not an object\"",
")",
";",
"assert",
".",
"equal",
"(",
"typeof",
"(",
"delta",
")",
",",
"'object'",
... | Merge two environments of matching components.
@param {Object} template
@param {Object} delta
@return {Object} result | [
"Merge",
"two",
"environments",
"of",
"matching",
"components",
"."
] | dca28007d6618066df8ed058362f0d4a0745c2cf | https://github.com/cafjs/caf_components/blob/dca28007d6618066df8ed058362f0d4a0745c2cf/lib/templateUtils.js#L135-L144 | train | |
cafjs/caf_components | lib/templateUtils.js | function(template, delta, overrideName) {
if (template.name !== delta.name) {
if (!overrideName) {
var err = new Error('mergeObj: description names do not match');
err['template'] = template;
err['delta'] = delta;
throw err;
}
}
/** @type spec... | javascript | function(template, delta, overrideName) {
if (template.name !== delta.name) {
if (!overrideName) {
var err = new Error('mergeObj: description names do not match');
err['template'] = template;
err['delta'] = delta;
throw err;
}
}
/** @type spec... | [
"function",
"(",
"template",
",",
"delta",
",",
"overrideName",
")",
"{",
"if",
"(",
"template",
".",
"name",
"!==",
"delta",
".",
"name",
")",
"{",
"if",
"(",
"!",
"overrideName",
")",
"{",
"var",
"err",
"=",
"new",
"Error",
"(",
"'mergeObj: descripti... | Merge two descriptions with the same name.
@param {specType} template
@param {specDeltaType} delta
@param {boolean} overrideName
@return {specType} result | [
"Merge",
"two",
"descriptions",
"with",
"the",
"same",
"name",
"."
] | dca28007d6618066df8ed058362f0d4a0745c2cf | https://github.com/cafjs/caf_components/blob/dca28007d6618066df8ed058362f0d4a0745c2cf/lib/templateUtils.js#L156-L180 | train | |
cafjs/caf_components | lib/templateUtils.js | function(desc, f) {
if (typeof desc === 'object') {
f(desc.env);
if (Array.isArray(desc.components)) {
desc.components.forEach(function(x) { patchEnv(x, f);});
}
} else {
var err = new Error('patchEnv: not an object');
err['desc'] = desc;
throw err;
... | javascript | function(desc, f) {
if (typeof desc === 'object') {
f(desc.env);
if (Array.isArray(desc.components)) {
desc.components.forEach(function(x) { patchEnv(x, f);});
}
} else {
var err = new Error('patchEnv: not an object');
err['desc'] = desc;
throw err;
... | [
"function",
"(",
"desc",
",",
"f",
")",
"{",
"if",
"(",
"typeof",
"desc",
"===",
"'object'",
")",
"{",
"f",
"(",
"desc",
".",
"env",
")",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",
"desc",
".",
"components",
")",
")",
"{",
"desc",
".",
"comp... | Patches every environment in a description.
@param {specType} desc A description to patch.
@param {function(Object)} f A function to patch an environment. | [
"Patches",
"every",
"environment",
"in",
"a",
"description",
"."
] | dca28007d6618066df8ed058362f0d4a0745c2cf | https://github.com/cafjs/caf_components/blob/dca28007d6618066df8ed058362f0d4a0745c2cf/lib/templateUtils.js#L215-L226 | train | |
cafjs/caf_components | lib/templateUtils.js | function(prefix, f) {
var retF = function(env) {
Object.keys(env)
.forEach(function(x) {
var val = env[x];
if ((typeof val === 'string') &&
(val.indexOf(prefix) === 0)) {
var propName = val.substring(prefix.length,
... | javascript | function(prefix, f) {
var retF = function(env) {
Object.keys(env)
.forEach(function(x) {
var val = env[x];
if ((typeof val === 'string') &&
(val.indexOf(prefix) === 0)) {
var propName = val.substring(prefix.length,
... | [
"function",
"(",
"prefix",
",",
"f",
")",
"{",
"var",
"retF",
"=",
"function",
"(",
"env",
")",
"{",
"Object",
".",
"keys",
"(",
"env",
")",
".",
"forEach",
"(",
"function",
"(",
"x",
")",
"{",
"var",
"val",
"=",
"env",
"[",
"x",
"]",
";",
"i... | Returns a function that filters relevant values in an environment and
applies a transform to them.
@param {string} prefix A matching prefix for selected values.
@param {function(string): Object} f A function that transforms matching
values. | [
"Returns",
"a",
"function",
"that",
"filters",
"relevant",
"values",
"in",
"an",
"environment",
"and",
"applies",
"a",
"transform",
"to",
"them",
"."
] | dca28007d6618066df8ed058362f0d4a0745c2cf | https://github.com/cafjs/caf_components/blob/dca28007d6618066df8ed058362f0d4a0745c2cf/lib/templateUtils.js#L237-L255 | train | |
repetere/periodicjs.core.mailer | lib/getTransport.js | getTransport | function getTransport(options = {}) {
return new Promise((resolve, reject) => {
try {
const defaultTransport = {
type: 'direct',
transportOptions: { debug: true }
};
const { transportObject = defaultTransport, } = options;
const nodemailerTransporter = nodemailer.createTran... | javascript | function getTransport(options = {}) {
return new Promise((resolve, reject) => {
try {
const defaultTransport = {
type: 'direct',
transportOptions: { debug: true }
};
const { transportObject = defaultTransport, } = options;
const nodemailerTransporter = nodemailer.createTran... | [
"function",
"getTransport",
"(",
"options",
"=",
"{",
"}",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"try",
"{",
"const",
"defaultTransport",
"=",
"{",
"type",
":",
"'direct'",
",",
"transportOptions",
":",... | returns a node mailer transport based off of a json configuration
@param {any} [options={}]
@param {object} options.transportObject the json configuration for a node mailer transport
@param {string} options.transportObject.transportType [ses|direct|sendmail|smtp-pool|sendgrid|sendgridapi|mailgun|stub]
@param {object} ... | [
"returns",
"a",
"node",
"mailer",
"transport",
"based",
"off",
"of",
"a",
"json",
"configuration"
] | f544584cb1520015adac0326f8b02c38fbbd3417 | https://github.com/repetere/periodicjs.core.mailer/blob/f544584cb1520015adac0326f8b02c38fbbd3417/lib/getTransport.js#L38-L64 | train |
typhonjs-node-escomplex/escomplex-plugin-syntax-babylon | src/PluginSyntaxBabylon.js | s_SAFE_COMPUTED_OPERANDS | function s_SAFE_COMPUTED_OPERANDS(node)
{
const operands = [];
if (typeof node.computed === 'boolean' && node.computed)
{
// The following will pick up a single literal computed value (string).
if (node.key.type === 'StringLiteral')
{
operands.push(TraitUtil.safeValue(node.key));
... | javascript | function s_SAFE_COMPUTED_OPERANDS(node)
{
const operands = [];
if (typeof node.computed === 'boolean' && node.computed)
{
// The following will pick up a single literal computed value (string).
if (node.key.type === 'StringLiteral')
{
operands.push(TraitUtil.safeValue(node.key));
... | [
"function",
"s_SAFE_COMPUTED_OPERANDS",
"(",
"node",
")",
"{",
"const",
"operands",
"=",
"[",
"]",
";",
"if",
"(",
"typeof",
"node",
".",
"computed",
"===",
"'boolean'",
"&&",
"node",
".",
"computed",
")",
"{",
"// The following will pick up a single literal compu... | Provides a utility method that determines the operands of a method for Babylon AST nodes. If the name is a computed
value and not a string literal then `ASTGenerator` is invoked to determine the computed operands.
@param {object} node - The current AST node.
@returns {Array<*>} | [
"Provides",
"a",
"utility",
"method",
"that",
"determines",
"the",
"operands",
"of",
"a",
"method",
"for",
"Babylon",
"AST",
"nodes",
".",
"If",
"the",
"name",
"is",
"a",
"computed",
"value",
"and",
"not",
"a",
"string",
"literal",
"then",
"ASTGenerator",
... | d0ce535ccebb2f8afc4bc991db6611fcd7e01ce5 | https://github.com/typhonjs-node-escomplex/escomplex-plugin-syntax-babylon/blob/d0ce535ccebb2f8afc4bc991db6611fcd7e01ce5/src/PluginSyntaxBabylon.js#L269-L291 | train |
Mammut-FE/nejm | src/base/element.js | function(_list){
var _result = 0;
_u._$forEach(
_list,function(_size){
if (!_size) return;
if (!_result){
_result = _size;
}else{
_result = Math.min(_result,_size);
... | javascript | function(_list){
var _result = 0;
_u._$forEach(
_list,function(_size){
if (!_size) return;
if (!_result){
_result = _size;
}else{
_result = Math.min(_result,_size);
... | [
"function",
"(",
"_list",
")",
"{",
"var",
"_result",
"=",
"0",
";",
"_u",
".",
"_$forEach",
"(",
"_list",
",",
"function",
"(",
"_size",
")",
"{",
"if",
"(",
"!",
"_size",
")",
"return",
";",
"if",
"(",
"!",
"_result",
")",
"{",
"_result",
"=",
... | get min value but not zero | [
"get",
"min",
"value",
"but",
"not",
"zero"
] | dfc09ac66a8d67620a7aea65e34d8a179976b3fb | https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/base/element.js#L463-L476 | train | |
jldec/pub-resolve-opts | resolve-opts.js | injectPaths | function injectPaths(paths) {
u.each(paths, function(path) {
if (path.inject) {
// injected css and js sources are always rooted paths
var src = mkSrc(path);
if (/\.css$/i.test(src.path)) return opts.injectCss.push(src);
if (/\.js$|\.es6$|\.jsx$/i.test(src.path)) return opts.in... | javascript | function injectPaths(paths) {
u.each(paths, function(path) {
if (path.inject) {
// injected css and js sources are always rooted paths
var src = mkSrc(path);
if (/\.css$/i.test(src.path)) return opts.injectCss.push(src);
if (/\.js$|\.es6$|\.jsx$/i.test(src.path)) return opts.in... | [
"function",
"injectPaths",
"(",
"paths",
")",
"{",
"u",
".",
"each",
"(",
"paths",
",",
"function",
"(",
"path",
")",
"{",
"if",
"(",
"path",
".",
"inject",
")",
"{",
"// injected css and js sources are always rooted paths",
"var",
"src",
"=",
"mkSrc",
"(",
... | add injectable staticPaths to opts.injectCss or opts.injectJs | [
"add",
"injectable",
"staticPaths",
"to",
"opts",
".",
"injectCss",
"or",
"opts",
".",
"injectJs"
] | 432dce8a638e1a909256179957a4ec25ac9542b7 | https://github.com/jldec/pub-resolve-opts/blob/432dce8a638e1a909256179957a4ec25ac9542b7/resolve-opts.js#L214-L224 | train |
jldec/pub-resolve-opts | resolve-opts.js | watchOpts | function watchOpts(src) {
if ((src._pkg && !opts.watchPkgs) || ('watch' in src && !src.watch)) return false;
return (typeof src.watch === 'object') ? src.watch : {};
} | javascript | function watchOpts(src) {
if ((src._pkg && !opts.watchPkgs) || ('watch' in src && !src.watch)) return false;
return (typeof src.watch === 'object') ? src.watch : {};
} | [
"function",
"watchOpts",
"(",
"src",
")",
"{",
"if",
"(",
"(",
"src",
".",
"_pkg",
"&&",
"!",
"opts",
".",
"watchPkgs",
")",
"||",
"(",
"'watch'",
"in",
"src",
"&&",
"!",
"src",
".",
"watch",
")",
")",
"return",
"false",
";",
"return",
"(",
"type... | don't watch inside packages unless opts.watchPkgs don't watch if src.watch = falsy | [
"don",
"t",
"watch",
"inside",
"packages",
"unless",
"opts",
".",
"watchPkgs",
"don",
"t",
"watch",
"if",
"src",
".",
"watch",
"=",
"falsy"
] | 432dce8a638e1a909256179957a4ec25ac9542b7 | https://github.com/jldec/pub-resolve-opts/blob/432dce8a638e1a909256179957a4ec25ac9542b7/resolve-opts.js#L334-L337 | train |
jldec/pub-resolve-opts | resolve-opts.js | normalizeOptsKey | function normalizeOptsKey(aval, basedir, pkg) {
aval = aval || [];
if (!u.isArray(aval)) {
aval = [ aval ];
}
return u.map(u.compact(aval), function(val) {
return normalize(val, basedir, pkg);
});
} | javascript | function normalizeOptsKey(aval, basedir, pkg) {
aval = aval || [];
if (!u.isArray(aval)) {
aval = [ aval ];
}
return u.map(u.compact(aval), function(val) {
return normalize(val, basedir, pkg);
});
} | [
"function",
"normalizeOptsKey",
"(",
"aval",
",",
"basedir",
",",
"pkg",
")",
"{",
"aval",
"=",
"aval",
"||",
"[",
"]",
";",
"if",
"(",
"!",
"u",
".",
"isArray",
"(",
"aval",
")",
")",
"{",
"aval",
"=",
"[",
"aval",
"]",
";",
"}",
"return",
"u"... | normalize a single opts key | [
"normalize",
"a",
"single",
"opts",
"key"
] | 432dce8a638e1a909256179957a4ec25ac9542b7 | https://github.com/jldec/pub-resolve-opts/blob/432dce8a638e1a909256179957a4ec25ac9542b7/resolve-opts.js#L362-L374 | train |
jldec/pub-resolve-opts | resolve-opts.js | normalize | function normalize(val, basedir, pkg) {
if (typeof val === 'string') {
val = { path: val };
}
var originalPath = val.path;
// npm3 treatment of sub-package paths starting with ./node_modules/
var subPkgName = val.path.replace(/^\.\/node_modules\/([^/]+).*/,'$1');
if (subPkgName != origi... | javascript | function normalize(val, basedir, pkg) {
if (typeof val === 'string') {
val = { path: val };
}
var originalPath = val.path;
// npm3 treatment of sub-package paths starting with ./node_modules/
var subPkgName = val.path.replace(/^\.\/node_modules\/([^/]+).*/,'$1');
if (subPkgName != origi... | [
"function",
"normalize",
"(",
"val",
",",
"basedir",
",",
"pkg",
")",
"{",
"if",
"(",
"typeof",
"val",
"===",
"'string'",
")",
"{",
"val",
"=",
"{",
"path",
":",
"val",
"}",
";",
"}",
"var",
"originalPath",
"=",
"val",
".",
"path",
";",
"// npm3 tr... | normalize a single opts key value | [
"normalize",
"a",
"single",
"opts",
"key",
"value"
] | 432dce8a638e1a909256179957a4ec25ac9542b7 | https://github.com/jldec/pub-resolve-opts/blob/432dce8a638e1a909256179957a4ec25ac9542b7/resolve-opts.js#L377-L408 | train |
vesln/hydro | lib/timeout-error.js | TimeoutError | function TimeoutError(message) {
this.message = message;
this.timeout = true;
Error.captureStackTrace(this, arguments.callee);
} | javascript | function TimeoutError(message) {
this.message = message;
this.timeout = true;
Error.captureStackTrace(this, arguments.callee);
} | [
"function",
"TimeoutError",
"(",
"message",
")",
"{",
"this",
".",
"message",
"=",
"message",
";",
"this",
".",
"timeout",
"=",
"true",
";",
"Error",
".",
"captureStackTrace",
"(",
"this",
",",
"arguments",
".",
"callee",
")",
";",
"}"
] | Timeout Error.
@param {String} message
@constructor | [
"Timeout",
"Error",
"."
] | 3f4d2e4926f913976187376e82f1496514c39890 | https://github.com/vesln/hydro/blob/3f4d2e4926f913976187376e82f1496514c39890/lib/timeout-error.js#L8-L13 | train |
arokor/pararr.js | lib/paworker.js | onFunction | function onFunction(data, op, iterStr, context) {
var iter,
data;
// Check task
if(!op || !data || !iterStr || !context) {
throw Error('Worker received invalid task');
}
// parse the serialized function
// eval() may be evil but here we don't have much choice
eval('var iter = ' + iterStr);
switch(op) ... | javascript | function onFunction(data, op, iterStr, context) {
var iter,
data;
// Check task
if(!op || !data || !iterStr || !context) {
throw Error('Worker received invalid task');
}
// parse the serialized function
// eval() may be evil but here we don't have much choice
eval('var iter = ' + iterStr);
switch(op) ... | [
"function",
"onFunction",
"(",
"data",
",",
"op",
",",
"iterStr",
",",
"context",
")",
"{",
"var",
"iter",
",",
"data",
";",
"// Check task",
"if",
"(",
"!",
"op",
"||",
"!",
"data",
"||",
"!",
"iterStr",
"||",
"!",
"context",
")",
"{",
"throw",
"E... | Handle functional requests | [
"Handle",
"functional",
"requests"
] | 215ddc452e24fd239b42de3997738510d1888135 | https://github.com/arokor/pararr.js/blob/215ddc452e24fd239b42de3997738510d1888135/lib/paworker.js#L2-L31 | train |
arokor/pararr.js | lib/paworker.js | onExec | function onExec(funcStr, parStr, context) {
var func,
par,
data,
err = null;
try {
// Check task
if(!funcStr || !context) {
throw Error('Worker received invalid task');
}
par = parStr ? JSON.parse(parStr) : null;
// parse the serialized function
// eval() may be evil but here we don't have mu... | javascript | function onExec(funcStr, parStr, context) {
var func,
par,
data,
err = null;
try {
// Check task
if(!funcStr || !context) {
throw Error('Worker received invalid task');
}
par = parStr ? JSON.parse(parStr) : null;
// parse the serialized function
// eval() may be evil but here we don't have mu... | [
"function",
"onExec",
"(",
"funcStr",
",",
"parStr",
",",
"context",
")",
"{",
"var",
"func",
",",
"par",
",",
"data",
",",
"err",
"=",
"null",
";",
"try",
"{",
"// Check task",
"if",
"(",
"!",
"funcStr",
"||",
"!",
"context",
")",
"{",
"throw",
"E... | Handle exec requests | [
"Handle",
"exec",
"requests"
] | 215ddc452e24fd239b42de3997738510d1888135 | https://github.com/arokor/pararr.js/blob/215ddc452e24fd239b42de3997738510d1888135/lib/paworker.js#L34-L62 | train |
veo-labs/openveo-api | lib/controllers/ContentController.js | getUserGroups | function getUserGroups(user) {
var groups = {};
if (user && user.permissions) {
user.permissions.forEach(function(permission) {
var reg = new RegExp('^(get|update|delete)-group-(.+)$');
var permissionChunks = reg.exec(permission);
if (permissionChunks) {
var operation = permissionChun... | javascript | function getUserGroups(user) {
var groups = {};
if (user && user.permissions) {
user.permissions.forEach(function(permission) {
var reg = new RegExp('^(get|update|delete)-group-(.+)$');
var permissionChunks = reg.exec(permission);
if (permissionChunks) {
var operation = permissionChun... | [
"function",
"getUserGroups",
"(",
"user",
")",
"{",
"var",
"groups",
"=",
"{",
"}",
";",
"if",
"(",
"user",
"&&",
"user",
".",
"permissions",
")",
"{",
"user",
".",
"permissions",
".",
"forEach",
"(",
"function",
"(",
"permission",
")",
"{",
"var",
"... | Gets user permissions by groups.
@example
// Example of user permissions
['get-group-Jekrn20Rl', 'update-group-Jekrn20Rl', 'delete-group-YldO3Jie3']
// Example of returned groups
{
'Jekrn20Rl': ['get', 'update'], // User only has get / update permissions on group 'Jekrn20Rl'
'YldO3Jie3': ['delete'], // User only has... | [
"Gets",
"user",
"permissions",
"by",
"groups",
"."
] | 493a811e9a5ba4d3e14910facaa7452caba1ab38 | https://github.com/veo-labs/openveo-api/blob/493a811e9a5ba4d3e14910facaa7452caba1ab38/lib/controllers/ContentController.js#L80-L100 | train |
veo-labs/openveo-api | lib/controllers/ContentController.js | getUserAuthorizedGroups | function getUserAuthorizedGroups(user, operation) {
var userGroups = getUserGroups(user);
var groups = [];
for (var groupId in userGroups) {
if (userGroups[groupId].indexOf(operation) >= 0)
groups.push(groupId);
}
return groups;
} | javascript | function getUserAuthorizedGroups(user, operation) {
var userGroups = getUserGroups(user);
var groups = [];
for (var groupId in userGroups) {
if (userGroups[groupId].indexOf(operation) >= 0)
groups.push(groupId);
}
return groups;
} | [
"function",
"getUserAuthorizedGroups",
"(",
"user",
",",
"operation",
")",
"{",
"var",
"userGroups",
"=",
"getUserGroups",
"(",
"user",
")",
";",
"var",
"groups",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"groupId",
"in",
"userGroups",
")",
"{",
"if",
"(",
... | Gets the list of groups of a user, with authorization on a certain operation.
All user groups with authorization on the operation are returned.
@method getUserAuthorizedGroups
@private
@param {Object} user The user
@param {String} operation The operation (get, update or delete)
@return {Array} The list of user groups... | [
"Gets",
"the",
"list",
"of",
"groups",
"of",
"a",
"user",
"with",
"authorization",
"on",
"a",
"certain",
"operation",
"."
] | 493a811e9a5ba4d3e14910facaa7452caba1ab38 | https://github.com/veo-labs/openveo-api/blob/493a811e9a5ba4d3e14910facaa7452caba1ab38/lib/controllers/ContentController.js#L113-L123 | train |
chip-js/observations-js | src/observable-hash.js | ObservableHash | function ObservableHash(observations) {
var enabled = true;
var _observers = [];
_observers.enabled = true;
Object.defineProperties(this, {
_context: { writable: true, value: this },
_observations: { value: observations },
_namespaces: { value: [] },
_observers: { value: _observers },
compu... | javascript | function ObservableHash(observations) {
var enabled = true;
var _observers = [];
_observers.enabled = true;
Object.defineProperties(this, {
_context: { writable: true, value: this },
_observations: { value: observations },
_namespaces: { value: [] },
_observers: { value: _observers },
compu... | [
"function",
"ObservableHash",
"(",
"observations",
")",
"{",
"var",
"enabled",
"=",
"true",
";",
"var",
"_observers",
"=",
"[",
"]",
";",
"_observers",
".",
"enabled",
"=",
"true",
";",
"Object",
".",
"defineProperties",
"(",
"this",
",",
"{",
"_context",
... | An object for storing data to be accessed by an application. Has methods for easily computing and watching data
changes.
@param {Observations} observations An instance of the Observations class this has is bound to | [
"An",
"object",
"for",
"storing",
"data",
"to",
"be",
"accessed",
"by",
"an",
"application",
".",
"Has",
"methods",
"for",
"easily",
"computing",
"and",
"watching",
"data",
"changes",
"."
] | a48b32a648089bc86b502712d78cd0b3f8317d50 | https://github.com/chip-js/observations-js/blob/a48b32a648089bc86b502712d78cd0b3f8317d50/src/observable-hash.js#L10-L22 | train |
chip-js/observations-js | src/observable-hash.js | function() {
this._observers.enabled = true;
this._observers.forEach(this.observersBindHelper.bind(this), this);
// Set namespaced hashes to the same value
this._namespaces.forEach(this.observersStartHelper.bind(this), this);
} | javascript | function() {
this._observers.enabled = true;
this._observers.forEach(this.observersBindHelper.bind(this), this);
// Set namespaced hashes to the same value
this._namespaces.forEach(this.observersStartHelper.bind(this), this);
} | [
"function",
"(",
")",
"{",
"this",
".",
"_observers",
".",
"enabled",
"=",
"true",
";",
"this",
".",
"_observers",
".",
"forEach",
"(",
"this",
".",
"observersBindHelper",
".",
"bind",
"(",
"this",
")",
",",
"this",
")",
";",
"// Set namespaced hashes to t... | Starts the observers watching their values | [
"Starts",
"the",
"observers",
"watching",
"their",
"values"
] | a48b32a648089bc86b502712d78cd0b3f8317d50 | https://github.com/chip-js/observations-js/blob/a48b32a648089bc86b502712d78cd0b3f8317d50/src/observable-hash.js#L43-L49 | train | |
chip-js/observations-js | src/observable-hash.js | function(clearValues) {
this._observers.enabled = false;
this._observers.forEach(this.observersUnbindHelper.bind(this, clearValues));
// Set namespaced hashes to the same value
this._namespaces.forEach(this.observersStopHelper.bind(this, clearValues), this);
} | javascript | function(clearValues) {
this._observers.enabled = false;
this._observers.forEach(this.observersUnbindHelper.bind(this, clearValues));
// Set namespaced hashes to the same value
this._namespaces.forEach(this.observersStopHelper.bind(this, clearValues), this);
} | [
"function",
"(",
"clearValues",
")",
"{",
"this",
".",
"_observers",
".",
"enabled",
"=",
"false",
";",
"this",
".",
"_observers",
".",
"forEach",
"(",
"this",
".",
"observersUnbindHelper",
".",
"bind",
"(",
"this",
",",
"clearValues",
")",
")",
";",
"//... | Stops the observers watching and responding to changes, optionally clearing out the values
@param {Boolean} clearValues Whether to clear the values out to `undefined` or leave them as-is | [
"Stops",
"the",
"observers",
"watching",
"and",
"responding",
"to",
"changes",
"optionally",
"clearing",
"out",
"the",
"values"
] | a48b32a648089bc86b502712d78cd0b3f8317d50 | https://github.com/chip-js/observations-js/blob/a48b32a648089bc86b502712d78cd0b3f8317d50/src/observable-hash.js#L63-L69 | train | |
chip-js/observations-js | src/observable-hash.js | function(namespace, map) {
if (typeof namespace === 'string' && typeof map === 'object') {
if (!this[namespace]) {
this[namespace] = new ObservableHash(this._observations);
this[namespace].observersEnabled = this.observersEnabled;
this._namespaces.push(namespace);
}
this._o... | javascript | function(namespace, map) {
if (typeof namespace === 'string' && typeof map === 'object') {
if (!this[namespace]) {
this[namespace] = new ObservableHash(this._observations);
this[namespace].observersEnabled = this.observersEnabled;
this._namespaces.push(namespace);
}
this._o... | [
"function",
"(",
"namespace",
",",
"map",
")",
"{",
"if",
"(",
"typeof",
"namespace",
"===",
"'string'",
"&&",
"typeof",
"map",
"===",
"'object'",
")",
"{",
"if",
"(",
"!",
"this",
"[",
"namespace",
"]",
")",
"{",
"this",
"[",
"namespace",
"]",
"=",
... | Add computed properties to this hash. If `name` is provided it will add the computed properties to that namespace
on the hash. Otherwise they will be added directly to the hash.
@param {String} name [OPTIONAL] The namespace to add the computed properties under
@param {Object} map The map of computed properties that wil... | [
"Add",
"computed",
"properties",
"to",
"this",
"hash",
".",
"If",
"name",
"is",
"provided",
"it",
"will",
"add",
"the",
"computed",
"properties",
"to",
"that",
"namespace",
"on",
"the",
"hash",
".",
"Otherwise",
"they",
"will",
"be",
"added",
"directly",
"... | a48b32a648089bc86b502712d78cd0b3f8317d50 | https://github.com/chip-js/observations-js/blob/a48b32a648089bc86b502712d78cd0b3f8317d50/src/observable-hash.js#L104-L119 | train | |
chip-js/observations-js | src/observable-hash.js | function(expression, onChange, callbackContext) {
var observer = this._observations.createObserver(expression, onChange, callbackContext || this);
this._observers.push(observer);
if (this.observersEnabled) observer.bind(this._context);
return observer;
} | javascript | function(expression, onChange, callbackContext) {
var observer = this._observations.createObserver(expression, onChange, callbackContext || this);
this._observers.push(observer);
if (this.observersEnabled) observer.bind(this._context);
return observer;
} | [
"function",
"(",
"expression",
",",
"onChange",
",",
"callbackContext",
")",
"{",
"var",
"observer",
"=",
"this",
".",
"_observations",
".",
"createObserver",
"(",
"expression",
",",
"onChange",
",",
"callbackContext",
"||",
"this",
")",
";",
"this",
".",
"_... | Watch this object for changes in the value of the expression
@param {String} expression The expression to observe
@param {Function} onChange The function which will be called when the expression value changes
@return {Observer} The observer created | [
"Watch",
"this",
"object",
"for",
"changes",
"in",
"the",
"value",
"of",
"the",
"expression"
] | a48b32a648089bc86b502712d78cd0b3f8317d50 | https://github.com/chip-js/observations-js/blob/a48b32a648089bc86b502712d78cd0b3f8317d50/src/observable-hash.js#L127-L132 | train | |
derdesign/multi | lib/multi.js | resultsCallback | function resultsCallback() {
var args = slice.call(arguments, 0);
var err = args.shift();
if (err) {
if (config.interrupt === true) {
errors.push(err);
results.push(null);
callback.call(self, errors, results);
return;
} else {
errored = true... | javascript | function resultsCallback() {
var args = slice.call(arguments, 0);
var err = args.shift();
if (err) {
if (config.interrupt === true) {
errors.push(err);
results.push(null);
callback.call(self, errors, results);
return;
} else {
errored = true... | [
"function",
"resultsCallback",
"(",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"0",
")",
";",
"var",
"err",
"=",
"args",
".",
"shift",
"(",
")",
";",
"if",
"(",
"err",
")",
"{",
"if",
"(",
"config",
".",
"interrupt... | Handles the internal async execution loop in order | [
"Handles",
"the",
"internal",
"async",
"execution",
"loop",
"in",
"order"
] | ea8e3b4c07eae5a65354c09a3850e60461ce4bc4 | https://github.com/derdesign/multi/blob/ea8e3b4c07eae5a65354c09a3850e60461ce4bc4/lib/multi.js#L84-L133 | train |
derdesign/multi | lib/multi.js | queue | function queue(args) {
args.push(resultsCallback);
stack.push({caller: this.caller, args: args});
} | javascript | function queue(args) {
args.push(resultsCallback);
stack.push({caller: this.caller, args: args});
} | [
"function",
"queue",
"(",
"args",
")",
"{",
"args",
".",
"push",
"(",
"resultsCallback",
")",
";",
"stack",
".",
"push",
"(",
"{",
"caller",
":",
"this",
".",
"caller",
",",
"args",
":",
"args",
"}",
")",
";",
"}"
] | Queues the callback | [
"Queues",
"the",
"callback"
] | ea8e3b4c07eae5a65354c09a3850e60461ce4bc4 | https://github.com/derdesign/multi/blob/ea8e3b4c07eae5a65354c09a3850e60461ce4bc4/lib/multi.js#L137-L140 | train |
derdesign/multi | lib/multi.js | dummy | function dummy(caller) {
return function() {
queue.call({caller: caller}, slice.call(arguments, 0));
return self;
}
} | javascript | function dummy(caller) {
return function() {
queue.call({caller: caller}, slice.call(arguments, 0));
return self;
}
} | [
"function",
"dummy",
"(",
"caller",
")",
"{",
"return",
"function",
"(",
")",
"{",
"queue",
".",
"call",
"(",
"{",
"caller",
":",
"caller",
"}",
",",
"slice",
".",
"call",
"(",
"arguments",
",",
"0",
")",
")",
";",
"return",
"self",
";",
"}",
"}"... | Generates the queuing function | [
"Generates",
"the",
"queuing",
"function"
] | ea8e3b4c07eae5a65354c09a3850e60461ce4bc4 | https://github.com/derdesign/multi/blob/ea8e3b4c07eae5a65354c09a3850e60461ce4bc4/lib/multi.js#L144-L149 | train |
derdesign/multi | lib/multi.js | setInitialState | function setInitialState(ret) {
var e, r;
// Before resetting, keep a copy of args
if (ret) {
e = (errored ? errors : null);
r = results;
}
// Reset runtime vars to their default state
counter = 0;
errored = false;
errors = [];
results = [];
// Flu... | javascript | function setInitialState(ret) {
var e, r;
// Before resetting, keep a copy of args
if (ret) {
e = (errored ? errors : null);
r = results;
}
// Reset runtime vars to their default state
counter = 0;
errored = false;
errors = [];
results = [];
// Flu... | [
"function",
"setInitialState",
"(",
"ret",
")",
"{",
"var",
"e",
",",
"r",
";",
"// Before resetting, keep a copy of args",
"if",
"(",
"ret",
")",
"{",
"e",
"=",
"(",
"errored",
"?",
"errors",
":",
"null",
")",
";",
"r",
"=",
"results",
";",
"}",
"// R... | Sets the initial state of multi | [
"Sets",
"the",
"initial",
"state",
"of",
"multi"
] | ea8e3b4c07eae5a65354c09a3850e60461ce4bc4 | https://github.com/derdesign/multi/blob/ea8e3b4c07eae5a65354c09a3850e60461ce4bc4/lib/multi.js#L153-L175 | train |
Mammut-FE/nejm | src/util/history/history.js | function(_href){
// locked from history back
if (!!_locked){
_locked = !1;
return;
}
var _event = {
oldValue:_location,
newValue:_getLocation()
};
// check ignore beforeurlchange event... | javascript | function(_href){
// locked from history back
if (!!_locked){
_locked = !1;
return;
}
var _event = {
oldValue:_location,
newValue:_getLocation()
};
// check ignore beforeurlchange event... | [
"function",
"(",
"_href",
")",
"{",
"// locked from history back",
"if",
"(",
"!",
"!",
"_locked",
")",
"{",
"_locked",
"=",
"!",
"1",
";",
"return",
";",
"}",
"var",
"_event",
"=",
"{",
"oldValue",
":",
"_location",
",",
"newValue",
":",
"_getLocation",... | parse location change | [
"parse",
"location",
"change"
] | dfc09ac66a8d67620a7aea65e34d8a179976b3fb | https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/history/history.js#L83-L115 | train | |
Mammut-FE/nejm | src/util/history/history.js | function(){
var _knl = _m._$KERNEL;
_ie7 = _knl.engine=='trident'&&_knl.release<='3.0';
return _isHack()&&('onhashchange' in window)&&!_ie7;
} | javascript | function(){
var _knl = _m._$KERNEL;
_ie7 = _knl.engine=='trident'&&_knl.release<='3.0';
return _isHack()&&('onhashchange' in window)&&!_ie7;
} | [
"function",
"(",
")",
"{",
"var",
"_knl",
"=",
"_m",
".",
"_$KERNEL",
";",
"_ie7",
"=",
"_knl",
".",
"engine",
"==",
"'trident'",
"&&",
"_knl",
".",
"release",
"<=",
"'3.0'",
";",
"return",
"_isHack",
"(",
")",
"&&",
"(",
"'onhashchange'",
"in",
"win... | check use hashchange event on window | [
"check",
"use",
"hashchange",
"event",
"on",
"window"
] | dfc09ac66a8d67620a7aea65e34d8a179976b3fb | https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/history/history.js#L122-L126 | train | |
DavidSouther/JEFRi | modeler/angular/app/scripts/lib/codemirror/mode/xquery/xquery.js | tokenString | function tokenString(quote, f) {
return function(stream, state) {
var ch;
if(isInString(state) && stream.current() == quote) {
popStateStack(state);
if(f) state.tokenize = f;
return ret("string", "string");
}
pushStateStack(state, { type: "string", name: quote, toke... | javascript | function tokenString(quote, f) {
return function(stream, state) {
var ch;
if(isInString(state) && stream.current() == quote) {
popStateStack(state);
if(f) state.tokenize = f;
return ret("string", "string");
}
pushStateStack(state, { type: "string", name: quote, toke... | [
"function",
"tokenString",
"(",
"quote",
",",
"f",
")",
"{",
"return",
"function",
"(",
"stream",
",",
"state",
")",
"{",
"var",
"ch",
";",
"if",
"(",
"isInString",
"(",
"state",
")",
"&&",
"stream",
".",
"current",
"(",
")",
"==",
"quote",
")",
"{... | tokenizer for string literals optionally pass a tokenizer function to set state.tokenize back to when finished | [
"tokenizer",
"for",
"string",
"literals",
"optionally",
"pass",
"a",
"tokenizer",
"function",
"to",
"set",
"state",
".",
"tokenize",
"back",
"to",
"when",
"finished"
] | 161f24e242e05b9b2114cc1123a257141a60eaf2 | https://github.com/DavidSouther/JEFRi/blob/161f24e242e05b9b2114cc1123a257141a60eaf2/modeler/angular/app/scripts/lib/codemirror/mode/xquery/xquery.js#L252-L289 | train |
DavidSouther/JEFRi | modeler/angular/app/scripts/lib/codemirror/mode/xquery/xquery.js | tokenVariable | function tokenVariable(stream, state) {
var isVariableChar = /[\w\$_-]/;
// a variable may start with a quoted EQName so if the next character is quote, consume to the next quote
if(stream.eat("\"")) {
while(stream.next() !== '\"'){};
stream.eat(":");
} else {
stream.eatWhile(isVariab... | javascript | function tokenVariable(stream, state) {
var isVariableChar = /[\w\$_-]/;
// a variable may start with a quoted EQName so if the next character is quote, consume to the next quote
if(stream.eat("\"")) {
while(stream.next() !== '\"'){};
stream.eat(":");
} else {
stream.eatWhile(isVariab... | [
"function",
"tokenVariable",
"(",
"stream",
",",
"state",
")",
"{",
"var",
"isVariableChar",
"=",
"/",
"[\\w\\$_-]",
"/",
";",
"// a variable may start with a quoted EQName so if the next character is quote, consume to the next quote",
"if",
"(",
"stream",
".",
"eat",
"(",
... | tokenizer for variables | [
"tokenizer",
"for",
"variables"
] | 161f24e242e05b9b2114cc1123a257141a60eaf2 | https://github.com/DavidSouther/JEFRi/blob/161f24e242e05b9b2114cc1123a257141a60eaf2/modeler/angular/app/scripts/lib/codemirror/mode/xquery/xquery.js#L292-L306 | train |
DavidSouther/JEFRi | modeler/angular/app/scripts/lib/codemirror/mode/xquery/xquery.js | tokenAttribute | function tokenAttribute(stream, state) {
var ch = stream.next();
if(ch == "/" && stream.eat(">")) {
if(isInXmlAttributeBlock(state)) popStateStack(state);
if(isInXmlBlock(state)) popStateStack(state);
return ret("tag", "tag");
}
if(ch == ">") {
if(isInXmlAttributeBlock(state... | javascript | function tokenAttribute(stream, state) {
var ch = stream.next();
if(ch == "/" && stream.eat(">")) {
if(isInXmlAttributeBlock(state)) popStateStack(state);
if(isInXmlBlock(state)) popStateStack(state);
return ret("tag", "tag");
}
if(ch == ">") {
if(isInXmlAttributeBlock(state... | [
"function",
"tokenAttribute",
"(",
"stream",
",",
"state",
")",
"{",
"var",
"ch",
"=",
"stream",
".",
"next",
"(",
")",
";",
"if",
"(",
"ch",
"==",
"\"/\"",
"&&",
"stream",
".",
"eat",
"(",
"\">\"",
")",
")",
"{",
"if",
"(",
"isInXmlAttributeBlock",
... | tokenizer for XML attributes | [
"tokenizer",
"for",
"XML",
"attributes"
] | 161f24e242e05b9b2114cc1123a257141a60eaf2 | https://github.com/DavidSouther/JEFRi/blob/161f24e242e05b9b2114cc1123a257141a60eaf2/modeler/angular/app/scripts/lib/codemirror/mode/xquery/xquery.js#L332-L364 | train |
AnyFetch/anyfetch-hydrater.js | lib/helpers/Childs.js | function(tasksPerProcess) {
this.ttl = tasksPerProcess;
this.available = true;
this.process = fork(__dirname + '/child-process.js', {silent: true});
this.reset = function() {
this.process.kill('SIGKILL');
this.process = fork(__dirname + '/child-process.js', {silent: true});
this.ttl = tasksPerProc... | javascript | function(tasksPerProcess) {
this.ttl = tasksPerProcess;
this.available = true;
this.process = fork(__dirname + '/child-process.js', {silent: true});
this.reset = function() {
this.process.kill('SIGKILL');
this.process = fork(__dirname + '/child-process.js', {silent: true});
this.ttl = tasksPerProc... | [
"function",
"(",
"tasksPerProcess",
")",
"{",
"this",
".",
"ttl",
"=",
"tasksPerProcess",
";",
"this",
".",
"available",
"=",
"true",
";",
"this",
".",
"process",
"=",
"fork",
"(",
"__dirname",
"+",
"'/child-process.js'",
",",
"{",
"silent",
":",
"true",
... | Manage a child process | [
"Manage",
"a",
"child",
"process"
] | 1e70fdb5d8dcd26382e2a16de747b91a5b3ef3ae | https://github.com/AnyFetch/anyfetch-hydrater.js/blob/1e70fdb5d8dcd26382e2a16de747b91a5b3ef3ae/lib/helpers/Childs.js#L9-L31 | train | |
AnyFetch/anyfetch-hydrater.js | lib/helpers/Childs.js | function(concurrency, tasksPerProcess) {
this.childs = [];
for(var i = 0; i < concurrency; i += 1) {
this.childs[i] = new Child(tasksPerProcess);
}
} | javascript | function(concurrency, tasksPerProcess) {
this.childs = [];
for(var i = 0; i < concurrency; i += 1) {
this.childs[i] = new Child(tasksPerProcess);
}
} | [
"function",
"(",
"concurrency",
",",
"tasksPerProcess",
")",
"{",
"this",
".",
"childs",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"concurrency",
";",
"i",
"+=",
"1",
")",
"{",
"this",
".",
"childs",
"[",
"i",
"]",
"=... | Manage a pool of childs process | [
"Manage",
"a",
"pool",
"of",
"childs",
"process"
] | 1e70fdb5d8dcd26382e2a16de747b91a5b3ef3ae | https://github.com/AnyFetch/anyfetch-hydrater.js/blob/1e70fdb5d8dcd26382e2a16de747b91a5b3ef3ae/lib/helpers/Childs.js#L37-L42 | train | |
unfoldingWord-dev/node-door43-client | lib/sqlite-helper.js | SQLiteHelper | function SQLiteHelper (schemaPath, dbPath) {
let dbFilePath = dbPath,
dbDirPath = path.dirname(dbFilePath),
sql;
/**
* Saves a sql database to the disk.
*
* @param sql {Database}
*/
function saveDB (sql) {
let data = sql.export();
let buffer = new Buffer... | javascript | function SQLiteHelper (schemaPath, dbPath) {
let dbFilePath = dbPath,
dbDirPath = path.dirname(dbFilePath),
sql;
/**
* Saves a sql database to the disk.
*
* @param sql {Database}
*/
function saveDB (sql) {
let data = sql.export();
let buffer = new Buffer... | [
"function",
"SQLiteHelper",
"(",
"schemaPath",
",",
"dbPath",
")",
"{",
"let",
"dbFilePath",
"=",
"dbPath",
",",
"dbDirPath",
"=",
"path",
".",
"dirname",
"(",
"dbFilePath",
")",
",",
"sql",
";",
"/**\n * Saves a sql database to the disk.\n *\n * @param sq... | A SQLite database helper.
@param schemaPath {string}
@param dbPath {string}
@constructor | [
"A",
"SQLite",
"database",
"helper",
"."
] | 18f518368ee89f4baf8943500a1c53ef5efcfb3e | https://github.com/unfoldingWord-dev/node-door43-client/blob/18f518368ee89f4baf8943500a1c53ef5efcfb3e/lib/sqlite-helper.js#L16-L97 | train |
unfoldingWord-dev/node-door43-client | lib/sqlite-helper.js | saveDB | function saveDB (sql) {
let data = sql.export();
let buffer = new Buffer(data);
mkdirp.sync(dbDirPath, '0755');
fs.writeFileSync(dbFilePath, buffer);
} | javascript | function saveDB (sql) {
let data = sql.export();
let buffer = new Buffer(data);
mkdirp.sync(dbDirPath, '0755');
fs.writeFileSync(dbFilePath, buffer);
} | [
"function",
"saveDB",
"(",
"sql",
")",
"{",
"let",
"data",
"=",
"sql",
".",
"export",
"(",
")",
";",
"let",
"buffer",
"=",
"new",
"Buffer",
"(",
"data",
")",
";",
"mkdirp",
".",
"sync",
"(",
"dbDirPath",
",",
"'0755'",
")",
";",
"fs",
".",
"write... | Saves a sql database to the disk.
@param sql {Database} | [
"Saves",
"a",
"sql",
"database",
"to",
"the",
"disk",
"."
] | 18f518368ee89f4baf8943500a1c53ef5efcfb3e | https://github.com/unfoldingWord-dev/node-door43-client/blob/18f518368ee89f4baf8943500a1c53ef5efcfb3e/lib/sqlite-helper.js#L27-L33 | train |
unfoldingWord-dev/node-door43-client | lib/sqlite-helper.js | query | function query (query, params) {
let rows = [];
let stmt = sql.prepare(query);
params = normalizeParams(params);
stmt.bind(params);
while(stmt.step()) {
rows.push(stmt.getAsObject());
}
stmt.free();
return rows;
} | javascript | function query (query, params) {
let rows = [];
let stmt = sql.prepare(query);
params = normalizeParams(params);
stmt.bind(params);
while(stmt.step()) {
rows.push(stmt.getAsObject());
}
stmt.free();
return rows;
} | [
"function",
"query",
"(",
"query",
",",
"params",
")",
"{",
"let",
"rows",
"=",
"[",
"]",
";",
"let",
"stmt",
"=",
"sql",
".",
"prepare",
"(",
"query",
")",
";",
"params",
"=",
"normalizeParams",
"(",
"params",
")",
";",
"stmt",
".",
"bind",
"(",
... | Executes a command returning the results.
@param query {string} the query string
@param params {[]|{}} the parameters to be bound to the query
@returns {[]} an array of rows | [
"Executes",
"a",
"command",
"returning",
"the",
"results",
"."
] | 18f518368ee89f4baf8943500a1c53ef5efcfb3e | https://github.com/unfoldingWord-dev/node-door43-client/blob/18f518368ee89f4baf8943500a1c53ef5efcfb3e/lib/sqlite-helper.js#L58-L68 | train |
unfoldingWord-dev/node-door43-client | lib/sqlite-helper.js | run | function run(query, params) {
let stmt = sql.prepare(query);
params = normalizeParams(params);
stmt.run(params);
stmt.free();
} | javascript | function run(query, params) {
let stmt = sql.prepare(query);
params = normalizeParams(params);
stmt.run(params);
stmt.free();
} | [
"function",
"run",
"(",
"query",
",",
"params",
")",
"{",
"let",
"stmt",
"=",
"sql",
".",
"prepare",
"(",
"query",
")",
";",
"params",
"=",
"normalizeParams",
"(",
"params",
")",
";",
"stmt",
".",
"run",
"(",
"params",
")",
";",
"stmt",
".",
"free"... | Executes a command ignoring the results.
@param query {string} the run string
@param params {[]|{}} the parameters to be bound to the query | [
"Executes",
"a",
"command",
"ignoring",
"the",
"results",
"."
] | 18f518368ee89f4baf8943500a1c53ef5efcfb3e | https://github.com/unfoldingWord-dev/node-door43-client/blob/18f518368ee89f4baf8943500a1c53ef5efcfb3e/lib/sqlite-helper.js#L76-L81 | train |
Runnable/api-client | lib/models/user.js | validateAndCbBackend | function validateAndCbBackend (instance, urlPort, cb) {
var backendUrl = instance.dockerUrlForPort(urlPort);
var err = validateContainer(instance.attrs.container);
if (err) {
return cb(err); }
if (!backendUrl) {
err = Boom.create(400, 'port not exposed', urlPort);
return cb(err);
}
cb(null, bac... | javascript | function validateAndCbBackend (instance, urlPort, cb) {
var backendUrl = instance.dockerUrlForPort(urlPort);
var err = validateContainer(instance.attrs.container);
if (err) {
return cb(err); }
if (!backendUrl) {
err = Boom.create(400, 'port not exposed', urlPort);
return cb(err);
}
cb(null, bac... | [
"function",
"validateAndCbBackend",
"(",
"instance",
",",
"urlPort",
",",
"cb",
")",
"{",
"var",
"backendUrl",
"=",
"instance",
".",
"dockerUrlForPort",
"(",
"urlPort",
")",
";",
"var",
"err",
"=",
"validateContainer",
"(",
"instance",
".",
"attrs",
".",
"co... | private function that gets the backend url of an instance and verifies the port is exposed
@param {Object} instance instance model
@param {Function} cb callback | [
"private",
"function",
"that",
"gets",
"the",
"backend",
"url",
"of",
"an",
"instance",
"and",
"verifies",
"the",
"port",
"is",
"exposed"
] | e6089c4ed0b8c6ed383a82cbd50514e1e720f154 | https://github.com/Runnable/api-client/blob/e6089c4ed0b8c6ed383a82cbd50514e1e720f154/lib/models/user.js#L327-L338 | train |
studybreak/casio | lib/connection-pool.js | function () {
if (!self.connections.length) {
self.removeListener('remove', remove);
self.closing = false;
return callback();
}
} | javascript | function () {
if (!self.connections.length) {
self.removeListener('remove', remove);
self.closing = false;
return callback();
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"self",
".",
"connections",
".",
"length",
")",
"{",
"self",
".",
"removeListener",
"(",
"'remove'",
",",
"remove",
")",
";",
"self",
".",
"closing",
"=",
"false",
";",
"return",
"callback",
"(",
")",
";",
... | When all of the connections have been removed, call the callback. | [
"When",
"all",
"of",
"the",
"connections",
"have",
"been",
"removed",
"call",
"the",
"callback",
"."
] | 814546bdd4c861cc363d5398762035598f6dbc09 | https://github.com/studybreak/casio/blob/814546bdd4c861cc363d5398762035598f6dbc09/lib/connection-pool.js#L353-L359 | train | |
cogswell-io/cogs-pubsub-dialect | index.js | identifySchema | function identifySchema(obj) {
if (obj) {
const code = obj.code;
const action = obj.action;
const category = Dialect[action];
if (category) {
if (action === 'msg' || action == 'invalid-request') {
// First handle the schemas which are a category unto themselves.
return category;... | javascript | function identifySchema(obj) {
if (obj) {
const code = obj.code;
const action = obj.action;
const category = Dialect[action];
if (category) {
if (action === 'msg' || action == 'invalid-request') {
// First handle the schemas which are a category unto themselves.
return category;... | [
"function",
"identifySchema",
"(",
"obj",
")",
"{",
"if",
"(",
"obj",
")",
"{",
"const",
"code",
"=",
"obj",
".",
"code",
";",
"const",
"action",
"=",
"obj",
".",
"action",
";",
"const",
"category",
"=",
"Dialect",
"[",
"action",
"]",
";",
"if",
"(... | Identifies the schema to use in order to validate the supplied object. | [
"Identifies",
"the",
"schema",
"to",
"use",
"in",
"order",
"to",
"validate",
"the",
"supplied",
"object",
"."
] | f265434b5af17a45fc4f84b202bd7cf73c7da655 | https://github.com/cogswell-io/cogs-pubsub-dialect/blob/f265434b5af17a45fc4f84b202bd7cf73c7da655/index.js#L214-L248 | train |
cogswell-io/cogs-pubsub-dialect | index.js | validate | function validate(object, validator, callback) {
if (typeof callback === 'function') {
return Joi.validate(object, validator, callback);
} else {
return Joi.validate(object, validator);
}
} | javascript | function validate(object, validator, callback) {
if (typeof callback === 'function') {
return Joi.validate(object, validator, callback);
} else {
return Joi.validate(object, validator);
}
} | [
"function",
"validate",
"(",
"object",
",",
"validator",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"callback",
"===",
"'function'",
")",
"{",
"return",
"Joi",
".",
"validate",
"(",
"object",
",",
"validator",
",",
"callback",
")",
";",
"}",
"else",... | The Joi validator function. | [
"The",
"Joi",
"validator",
"function",
"."
] | f265434b5af17a45fc4f84b202bd7cf73c7da655 | https://github.com/cogswell-io/cogs-pubsub-dialect/blob/f265434b5af17a45fc4f84b202bd7cf73c7da655/index.js#L251-L257 | train |
cogswell-io/cogs-pubsub-dialect | index.js | autoValidate | function autoValidate(object) {
const seq = (object) ? object.seq : undefined;
const action = (object) ? object.action : undefined;
const schema = identifySchema(object)
if (schema) {
const {error, value} = validate(object, schema);
if (error) {
return { isValid: false, seq, action, error };
... | javascript | function autoValidate(object) {
const seq = (object) ? object.seq : undefined;
const action = (object) ? object.action : undefined;
const schema = identifySchema(object)
if (schema) {
const {error, value} = validate(object, schema);
if (error) {
return { isValid: false, seq, action, error };
... | [
"function",
"autoValidate",
"(",
"object",
")",
"{",
"const",
"seq",
"=",
"(",
"object",
")",
"?",
"object",
".",
"seq",
":",
"undefined",
";",
"const",
"action",
"=",
"(",
"object",
")",
"?",
"object",
".",
"action",
":",
"undefined",
";",
"const",
... | Validate the object, auto-detecting its schema. | [
"Validate",
"the",
"object",
"auto",
"-",
"detecting",
"its",
"schema",
"."
] | f265434b5af17a45fc4f84b202bd7cf73c7da655 | https://github.com/cogswell-io/cogs-pubsub-dialect/blob/f265434b5af17a45fc4f84b202bd7cf73c7da655/index.js#L260-L278 | train |
cogswell-io/cogs-pubsub-dialect | index.js | parseAndAutoValidate | function parseAndAutoValidate(json) {
try {
const obj = JSON.parse(json);
return autoValidate(obj);
} catch (error) {
return { isValid: false, error: error };
}
} | javascript | function parseAndAutoValidate(json) {
try {
const obj = JSON.parse(json);
return autoValidate(obj);
} catch (error) {
return { isValid: false, error: error };
}
} | [
"function",
"parseAndAutoValidate",
"(",
"json",
")",
"{",
"try",
"{",
"const",
"obj",
"=",
"JSON",
".",
"parse",
"(",
"json",
")",
";",
"return",
"autoValidate",
"(",
"obj",
")",
";",
"}",
"catch",
"(",
"error",
")",
"{",
"return",
"{",
"isValid",
"... | Parse and validate JSON, auto-detecting its schema. | [
"Parse",
"and",
"validate",
"JSON",
"auto",
"-",
"detecting",
"its",
"schema",
"."
] | f265434b5af17a45fc4f84b202bd7cf73c7da655 | https://github.com/cogswell-io/cogs-pubsub-dialect/blob/f265434b5af17a45fc4f84b202bd7cf73c7da655/index.js#L281-L288 | train |
WaiChungWong/jw-mouse | lib/index.js | getDirection | function getDirection(position1, position2) {
var _getDistanceVector2 = getDistanceVector(position1, position2),
x = _getDistanceVector2.x,
y = _getDistanceVector2.y;
return atan2(y, x);
} | javascript | function getDirection(position1, position2) {
var _getDistanceVector2 = getDistanceVector(position1, position2),
x = _getDistanceVector2.x,
y = _getDistanceVector2.y;
return atan2(y, x);
} | [
"function",
"getDirection",
"(",
"position1",
",",
"position2",
")",
"{",
"var",
"_getDistanceVector2",
"=",
"getDistanceVector",
"(",
"position1",
",",
"position2",
")",
",",
"x",
"=",
"_getDistanceVector2",
".",
"x",
",",
"y",
"=",
"_getDistanceVector2",
".",
... | Calculate the directional angle to the destination position
in terms of the angle oriented to the East. | [
"Calculate",
"the",
"directional",
"angle",
"to",
"the",
"destination",
"position",
"in",
"terms",
"of",
"the",
"angle",
"oriented",
"to",
"the",
"East",
"."
] | 7c17e333405206065c657ef9bba6d5dfbc3ee7f8 | https://github.com/WaiChungWong/jw-mouse/blob/7c17e333405206065c657ef9bba6d5dfbc3ee7f8/lib/index.js#L43-L49 | train |
DavidSouther/JEFRi | modeler/angular/app/scripts/lib/codemirror/keymap/vim.js | findWord | function findWord(cm, lineNum, pos, dir, regexps) {
var line = cm.getLine(lineNum);
while (true) {
var stop = (dir > 0) ? line.length : -1;
var wordStart = stop, wordEnd = stop;
// Find bounds of next word.
for (; pos != stop; pos += dir) {
for (var i = 0; i < regexps.length; ++i... | javascript | function findWord(cm, lineNum, pos, dir, regexps) {
var line = cm.getLine(lineNum);
while (true) {
var stop = (dir > 0) ? line.length : -1;
var wordStart = stop, wordEnd = stop;
// Find bounds of next word.
for (; pos != stop; pos += dir) {
for (var i = 0; i < regexps.length; ++i... | [
"function",
"findWord",
"(",
"cm",
",",
"lineNum",
",",
"pos",
",",
"dir",
",",
"regexps",
")",
"{",
"var",
"line",
"=",
"cm",
".",
"getLine",
"(",
"lineNum",
")",
";",
"while",
"(",
"true",
")",
"{",
"var",
"stop",
"=",
"(",
"dir",
">",
"0",
"... | Finds a word on the given line, and continue searching the next line if it can't find one. | [
"Finds",
"a",
"word",
"on",
"the",
"given",
"line",
"and",
"continue",
"searching",
"the",
"next",
"line",
"if",
"it",
"can",
"t",
"find",
"one",
"."
] | 161f24e242e05b9b2114cc1123a257141a60eaf2 | https://github.com/DavidSouther/JEFRi/blob/161f24e242e05b9b2114cc1123a257141a60eaf2/modeler/angular/app/scripts/lib/codemirror/keymap/vim.js#L103-L129 | train |
DavidSouther/JEFRi | modeler/angular/app/scripts/lib/codemirror/keymap/vim.js | textObjectManipulation | function textObjectManipulation(cm, object, remove, insert, inclusive) {
// Object is the text object, delete object if remove is true, enter insert
// mode if insert is true, inclusive is the difference between a and i
var tmp = textObjects[object](cm, inclusive);
var start = tmp.start;
var end = t... | javascript | function textObjectManipulation(cm, object, remove, insert, inclusive) {
// Object is the text object, delete object if remove is true, enter insert
// mode if insert is true, inclusive is the difference between a and i
var tmp = textObjects[object](cm, inclusive);
var start = tmp.start;
var end = t... | [
"function",
"textObjectManipulation",
"(",
"cm",
",",
"object",
",",
"remove",
",",
"insert",
",",
"inclusive",
")",
"{",
"// Object is the text object, delete object if remove is true, enter insert",
"// mode if insert is true, inclusive is the difference between a and i",
"var",
... | One function to handle all operation upon text objects. Kinda funky but it works better than rewriting this code six times | [
"One",
"function",
"to",
"handle",
"all",
"operation",
"upon",
"text",
"objects",
".",
"Kinda",
"funky",
"but",
"it",
"works",
"better",
"than",
"rewriting",
"this",
"code",
"six",
"times"
] | 161f24e242e05b9b2114cc1123a257141a60eaf2 | https://github.com/DavidSouther/JEFRi/blob/161f24e242e05b9b2114cc1123a257141a60eaf2/modeler/angular/app/scripts/lib/codemirror/keymap/vim.js#L871-L883 | train |
Mammut-FE/nejm | src/util/audio/audio.js | function(_key,_event){
if (_event.state==0){
_doClearAction(_key);
}
_doStateChangeCallback(_key,_event.state);
} | javascript | function(_key,_event){
if (_event.state==0){
_doClearAction(_key);
}
_doStateChangeCallback(_key,_event.state);
} | [
"function",
"(",
"_key",
",",
"_event",
")",
"{",
"if",
"(",
"_event",
".",
"state",
"==",
"0",
")",
"{",
"_doClearAction",
"(",
"_key",
")",
";",
"}",
"_doStateChangeCallback",
"(",
"_key",
",",
"_event",
".",
"state",
")",
";",
"}"
] | state change action | [
"state",
"change",
"action"
] | dfc09ac66a8d67620a7aea65e34d8a179976b3fb | https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/audio/audio.js#L139-L144 | train | |
LeisureLink/magicbus | lib/exchange-machine.js | function() {
this.handlers.push(topology.on('bindings-completed', () => {
this.handle('bindings-completed');
}));
this.handlers.push(connection.on('reconnected', () => {
this.transition('reconnecting');
}));
this.handlers.push(this.on('failed', (err) => {
_.each(thi... | javascript | function() {
this.handlers.push(topology.on('bindings-completed', () => {
this.handle('bindings-completed');
}));
this.handlers.push(connection.on('reconnected', () => {
this.transition('reconnecting');
}));
this.handlers.push(this.on('failed', (err) => {
_.each(thi... | [
"function",
"(",
")",
"{",
"this",
".",
"handlers",
".",
"push",
"(",
"topology",
".",
"on",
"(",
"'bindings-completed'",
",",
"(",
")",
"=>",
"{",
"this",
".",
"handle",
"(",
"'bindings-completed'",
")",
";",
"}",
")",
")",
";",
"this",
".",
"handle... | Listens for events around bindings and reconnecting
@private
@memberOf ExchangeMachine.prototype | [
"Listens",
"for",
"events",
"around",
"bindings",
"and",
"reconnecting"
] | 0370c38ebb8c7917cfd3894263d734aefc2d3d29 | https://github.com/LeisureLink/magicbus/blob/0370c38ebb8c7917cfd3894263d734aefc2d3d29/lib/exchange-machine.js#L69-L82 | train | |
LeisureLink/magicbus | lib/exchange-machine.js | function(reject) {
let index = _.indexOf(this.deferred, reject);
if (index >= 0) {
this.deferred.splice(index, 1);
}
} | javascript | function(reject) {
let index = _.indexOf(this.deferred, reject);
if (index >= 0) {
this.deferred.splice(index, 1);
}
} | [
"function",
"(",
"reject",
")",
"{",
"let",
"index",
"=",
"_",
".",
"indexOf",
"(",
"this",
".",
"deferred",
",",
"reject",
")",
";",
"if",
"(",
"index",
">=",
"0",
")",
"{",
"this",
".",
"deferred",
".",
"splice",
"(",
"index",
",",
"1",
")",
... | Removes DeferredPromise from the tracked list
@private
@memberOf ExchangeMachine.prototype | [
"Removes",
"DeferredPromise",
"from",
"the",
"tracked",
"list"
] | 0370c38ebb8c7917cfd3894263d734aefc2d3d29 | https://github.com/LeisureLink/magicbus/blob/0370c38ebb8c7917cfd3894263d734aefc2d3d29/lib/exchange-machine.js#L90-L95 | train | |
LeisureLink/magicbus | lib/exchange-machine.js | function() {
let deferred = DeferredPromise();
logger.debug(`Destroy called on exchange ${this.name} - ${connection.name} (${this.published.count()} messages pending)`);
this.handle('destroy', deferred);
return deferred.promise;
} | javascript | function() {
let deferred = DeferredPromise();
logger.debug(`Destroy called on exchange ${this.name} - ${connection.name} (${this.published.count()} messages pending)`);
this.handle('destroy', deferred);
return deferred.promise;
} | [
"function",
"(",
")",
"{",
"let",
"deferred",
"=",
"DeferredPromise",
"(",
")",
";",
"logger",
".",
"debug",
"(",
"`",
"${",
"this",
".",
"name",
"}",
"${",
"connection",
".",
"name",
"}",
"${",
"this",
".",
"published",
".",
"count",
"(",
")",
"}"... | Destroy the exchange
@public
@memberOf ExchangeMachine.prototype
@returns {Promise} a promise that is fulfilled when destruction is complete | [
"Destroy",
"the",
"exchange"
] | 0370c38ebb8c7917cfd3894263d734aefc2d3d29 | https://github.com/LeisureLink/magicbus/blob/0370c38ebb8c7917cfd3894263d734aefc2d3d29/lib/exchange-machine.js#L117-L122 | train | |
LeisureLink/magicbus | lib/exchange-machine.js | function(message) {
let publishTimeout = message.timeout || options.publishTimeout || message.connectionPublishTimeout || 0;
logger.silly(`Publish called in state ${this.state}`);
return new Promise((resolve, reject) => {
let timeout;
let timedOut;
if(publishTimeout > 0) {
... | javascript | function(message) {
let publishTimeout = message.timeout || options.publishTimeout || message.connectionPublishTimeout || 0;
logger.silly(`Publish called in state ${this.state}`);
return new Promise((resolve, reject) => {
let timeout;
let timedOut;
if(publishTimeout > 0) {
... | [
"function",
"(",
"message",
")",
"{",
"let",
"publishTimeout",
"=",
"message",
".",
"timeout",
"||",
"options",
".",
"publishTimeout",
"||",
"message",
".",
"connectionPublishTimeout",
"||",
"0",
";",
"logger",
".",
"silly",
"(",
"`",
"${",
"this",
".",
"s... | Publish a message to the exchange
@public
@memberOf ExchangeMachine.prototype
@param {Object} message - the message to publish, passed to Exchange.publish
@param {Number} message.timeout - the time to wait before abandoning the publish
@returns {Promise} a promise that is fulfilled when publication is complete | [
"Publish",
"a",
"message",
"to",
"the",
"exchange"
] | 0370c38ebb8c7917cfd3894263d734aefc2d3d29 | https://github.com/LeisureLink/magicbus/blob/0370c38ebb8c7917cfd3894263d734aefc2d3d29/lib/exchange-machine.js#L133-L168 | train | |
unfoldingWord-dev/node-door43-client | bin/util.js | writeProgress | function writeProgress(id, total, completed) {
var percent = Math.round(10 * (100 * completed) / total) / 10;
if(id == lastProgressId) {
readline.cursorTo(process.stdout, 0);
readline.clearLine(process.stdout, 0);
} else {
lastProgressId = id;
process.stdout.write('\n');
... | javascript | function writeProgress(id, total, completed) {
var percent = Math.round(10 * (100 * completed) / total) / 10;
if(id == lastProgressId) {
readline.cursorTo(process.stdout, 0);
readline.clearLine(process.stdout, 0);
} else {
lastProgressId = id;
process.stdout.write('\n');
... | [
"function",
"writeProgress",
"(",
"id",
",",
"total",
",",
"completed",
")",
"{",
"var",
"percent",
"=",
"Math",
".",
"round",
"(",
"10",
"*",
"(",
"100",
"*",
"completed",
")",
"/",
"total",
")",
"/",
"10",
";",
"if",
"(",
"id",
"==",
"lastProgres... | Displays a progress indicator in the console.
@param id
@param total
@param completed | [
"Displays",
"a",
"progress",
"indicator",
"in",
"the",
"console",
"."
] | 18f518368ee89f4baf8943500a1c53ef5efcfb3e | https://github.com/unfoldingWord-dev/node-door43-client/blob/18f518368ee89f4baf8943500a1c53ef5efcfb3e/bin/util.js#L11-L33 | train |
backand/backand-hosting-s3 | backand_sync_s3.js | condition | function condition(file){
var suffix = file.path.substr(file.base.length);
var re = new RegExp(specialChars);
var flag = service === "hosting" && re.test(suffix);
var warning = "Warning: Cannot sync files with characters: " + specialChars + " in the file name: ";
if (flag){
var message = warni... | javascript | function condition(file){
var suffix = file.path.substr(file.base.length);
var re = new RegExp(specialChars);
var flag = service === "hosting" && re.test(suffix);
var warning = "Warning: Cannot sync files with characters: " + specialChars + " in the file name: ";
if (flag){
var message = warni... | [
"function",
"condition",
"(",
"file",
")",
"{",
"var",
"suffix",
"=",
"file",
".",
"path",
".",
"substr",
"(",
"file",
".",
"base",
".",
"length",
")",
";",
"var",
"re",
"=",
"new",
"RegExp",
"(",
"specialChars",
")",
";",
"var",
"flag",
"=",
"serv... | exclude files with special characters in name | [
"exclude",
"files",
"with",
"special",
"characters",
"in",
"name"
] | 25f802b969fcda285f83c53da8f83a2e17925bc3 | https://github.com/backand/backand-hosting-s3/blob/25f802b969fcda285f83c53da8f83a2e17925bc3/backand_sync_s3.js#L81-L91 | train |
hairyhenderson/node-fellowshipone | lib/person_communications.js | PersonCommunications | function PersonCommunications (f1, personID) {
if (!personID) {
throw new Error('PersonCommunications requires a person ID!')
}
Communications.call(this, f1, {
path: '/People/' + personID + '/Communications'
})
} | javascript | function PersonCommunications (f1, personID) {
if (!personID) {
throw new Error('PersonCommunications requires a person ID!')
}
Communications.call(this, f1, {
path: '/People/' + personID + '/Communications'
})
} | [
"function",
"PersonCommunications",
"(",
"f1",
",",
"personID",
")",
"{",
"if",
"(",
"!",
"personID",
")",
"{",
"throw",
"new",
"Error",
"(",
"'PersonCommunications requires a person ID!'",
")",
"}",
"Communications",
".",
"call",
"(",
"this",
",",
"f1",
",",
... | The Communications object, in a Person context.
@param {Object} f1 - the F1 object
@param {Number} personID - the Person ID, for context | [
"The",
"Communications",
"object",
"in",
"a",
"Person",
"context",
"."
] | 5e80eb9ec31fb6dceee1e8c211e7b6e0e373b08b | https://github.com/hairyhenderson/node-fellowshipone/blob/5e80eb9ec31fb6dceee1e8c211e7b6e0e373b08b/lib/person_communications.js#L10-L17 | train |
zazuko/trifid-core | plugins/error-handler.js | init | function init (router) {
router.use((err, req, res, next) => {
console.error(err.stack || err.message)
res.statusCode = err.statusCode || 500
res.end()
})
} | javascript | function init (router) {
router.use((err, req, res, next) => {
console.error(err.stack || err.message)
res.statusCode = err.statusCode || 500
res.end()
})
} | [
"function",
"init",
"(",
"router",
")",
"{",
"router",
".",
"use",
"(",
"(",
"err",
",",
"req",
",",
"res",
",",
"next",
")",
"=>",
"{",
"console",
".",
"error",
"(",
"err",
".",
"stack",
"||",
"err",
".",
"message",
")",
"res",
".",
"statusCode"... | default error handler -> send no content
@param router | [
"default",
"error",
"handler",
"-",
">",
"send",
"no",
"content"
] | 47068ef508971f562e35768d829e15699ce3e19c | https://github.com/zazuko/trifid-core/blob/47068ef508971f562e35768d829e15699ce3e19c/plugins/error-handler.js#L5-L12 | train |
unfoldingWord-dev/node-door43-client | lib/library.js | function(table, params, unique) {
unique = unique || [];
let columns = _.keys(params);
let whereStatements = _.map(unique, function(c) { return c + '=:' + c});
let updatedColumns = _.map(_.filter(columns, function(c) { return unique.indexOf(c) }), function(c) { return c + '=:' + c });
... | javascript | function(table, params, unique) {
unique = unique || [];
let columns = _.keys(params);
let whereStatements = _.map(unique, function(c) { return c + '=:' + c});
let updatedColumns = _.map(_.filter(columns, function(c) { return unique.indexOf(c) }), function(c) { return c + '=:' + c });
... | [
"function",
"(",
"table",
",",
"params",
",",
"unique",
")",
"{",
"unique",
"=",
"unique",
"||",
"[",
"]",
";",
"let",
"columns",
"=",
"_",
".",
"keys",
"(",
"params",
")",
";",
"let",
"whereStatements",
"=",
"_",
".",
"map",
"(",
"unique",
",",
... | A utility to perform insert+update operations.
Insert failures are ignored.
Update failures are thrown.
@param table {string}
@param params {{}} keys must be valid column names
@param unique {[]} a list of unique columns on this table. This should be a subset of params
@returns {int} the id of the inserted/updated row... | [
"A",
"utility",
"to",
"perform",
"insert",
"+",
"update",
"operations",
".",
"Insert",
"failures",
"are",
"ignored",
".",
"Update",
"failures",
"are",
"thrown",
"."
] | 18f518368ee89f4baf8943500a1c53ef5efcfb3e | https://github.com/unfoldingWord-dev/node-door43-client/blob/18f518368ee89f4baf8943500a1c53ef5efcfb3e/lib/library.js#L65-L82 | train | |
unfoldingWord-dev/node-door43-client | lib/library.js | function(obj, required_props) {
if(typeof obj === 'object') {
required_props = required_props || Object.keys(obj);
for (let prop of required_props) {
if (obj[prop] === undefined || obj[prop] === null || obj[prop] === '') {
throw new Error('Missing requ... | javascript | function(obj, required_props) {
if(typeof obj === 'object') {
required_props = required_props || Object.keys(obj);
for (let prop of required_props) {
if (obj[prop] === undefined || obj[prop] === null || obj[prop] === '') {
throw new Error('Missing requ... | [
"function",
"(",
"obj",
",",
"required_props",
")",
"{",
"if",
"(",
"typeof",
"obj",
"===",
"'object'",
")",
"{",
"required_props",
"=",
"required_props",
"||",
"Object",
".",
"keys",
"(",
"obj",
")",
";",
"for",
"(",
"let",
"prop",
"of",
"required_props... | Performs an empty validation check on an object or scalar.
This should only be used to validate string properties
since invalid integers values are handled by the db schema.
@param obj {{}|string} the object or string to be validated
@param required_props {[string]} an array of required properties. default is all prop... | [
"Performs",
"an",
"empty",
"validation",
"check",
"on",
"an",
"object",
"or",
"scalar",
".",
"This",
"should",
"only",
"be",
"used",
"to",
"validate",
"string",
"properties",
"since",
"invalid",
"integers",
"values",
"are",
"handled",
"by",
"the",
"db",
"sch... | 18f518368ee89f4baf8943500a1c53ef5efcfb3e | https://github.com/unfoldingWord-dev/node-door43-client/blob/18f518368ee89f4baf8943500a1c53ef5efcfb3e/lib/library.js#L92-L105 | train | |
unfoldingWord-dev/node-door43-client | lib/library.js | function() {
let resultLangCount = query('select count(*) as count from target_language');
let resultResLvl3Count = query('select count(*) as count from resource where checking_level >= 3');
let resultResCount = query('select count(*) as count from resource');
let result... | javascript | function() {
let resultLangCount = query('select count(*) as count from target_language');
let resultResLvl3Count = query('select count(*) as count from resource where checking_level >= 3');
let resultResCount = query('select count(*) as count from resource');
let result... | [
"function",
"(",
")",
"{",
"let",
"resultLangCount",
"=",
"query",
"(",
"'select count(*) as count from target_language'",
")",
";",
"let",
"resultResLvl3Count",
"=",
"query",
"(",
"'select count(*) as count from resource where checking_level >= 3'",
")",
";",
"let",
"resul... | Returns a map of metrics about content in the index | [
"Returns",
"a",
"map",
"of",
"metrics",
"about",
"content",
"in",
"the",
"index"
] | 18f518368ee89f4baf8943500a1c53ef5efcfb3e | https://github.com/unfoldingWord-dev/node-door43-client/blob/18f518368ee89f4baf8943500a1c53ef5efcfb3e/lib/library.js#L525-L536 | train | |
unfoldingWord-dev/node-door43-client | lib/library.js | function(temp_target_language_slug) {
let result = query('select tl.* from target_language as tl' +
' left join temp_target_language as ttl on ttl.approved_target_language_slug=tl.slug' +
' where ttl.slug=?', [temp_target_language_slug]);
if(result.length > 0) {
... | javascript | function(temp_target_language_slug) {
let result = query('select tl.* from target_language as tl' +
' left join temp_target_language as ttl on ttl.approved_target_language_slug=tl.slug' +
' where ttl.slug=?', [temp_target_language_slug]);
if(result.length > 0) {
... | [
"function",
"(",
"temp_target_language_slug",
")",
"{",
"let",
"result",
"=",
"query",
"(",
"'select tl.* from target_language as tl'",
"+",
"' left join temp_target_language as ttl on ttl.approved_target_language_slug=tl.slug'",
"+",
"' where ttl.slug=?'",
",",
"[",
"temp_target_l... | Returns the target language that has been assigned to a temporary target language.
Note: does not include the row id. You don't need it
@param temp_target_language_slug {string} the temporary target language with the assignment
@returns {{}|null} the language object or null if it does not exist | [
"Returns",
"the",
"target",
"language",
"that",
"has",
"been",
"assigned",
"to",
"a",
"temporary",
"target",
"language",
"."
] | 18f518368ee89f4baf8943500a1c53ef5efcfb3e | https://github.com/unfoldingWord-dev/node-door43-client/blob/18f518368ee89f4baf8943500a1c53ef5efcfb3e/lib/library.js#L608-L617 | train | |
unfoldingWord-dev/node-door43-client | lib/library.js | function(languageSlug, projectSlug) {
// support passing args as an object
if(languageSlug != null && typeof languageSlug == 'object') {
projectSlug = languageSlug.projectSlug;
languageSlug = languageSlug.languageSlug;
}
let result = query... | javascript | function(languageSlug, projectSlug) {
// support passing args as an object
if(languageSlug != null && typeof languageSlug == 'object') {
projectSlug = languageSlug.projectSlug;
languageSlug = languageSlug.languageSlug;
}
let result = query... | [
"function",
"(",
"languageSlug",
",",
"projectSlug",
")",
"{",
"// support passing args as an object",
"if",
"(",
"languageSlug",
"!=",
"null",
"&&",
"typeof",
"languageSlug",
"==",
"'object'",
")",
"{",
"projectSlug",
"=",
"languageSlug",
".",
"projectSlug",
";",
... | Returns a project.
@param languageSlug {string|{languageSlug, projectSlug}}
@param projectSlug {string}
@returns {{}|null} the project object or null if it does not exist | [
"Returns",
"a",
"project",
"."
] | 18f518368ee89f4baf8943500a1c53ef5efcfb3e | https://github.com/unfoldingWord-dev/node-door43-client/blob/18f518368ee89f4baf8943500a1c53ef5efcfb3e/lib/library.js#L626-L643 | train | |
unfoldingWord-dev/node-door43-client | lib/library.js | function(languageSlug) {
let result;
if(languageSlug) {
result = query('select p.*, c.slug as category_slug from project as p' +
' left join category as c on c.id=p.category_id' +
' where p.source_language_id in (select id from source_langu... | javascript | function(languageSlug) {
let result;
if(languageSlug) {
result = query('select p.*, c.slug as category_slug from project as p' +
' left join category as c on c.id=p.category_id' +
' where p.source_language_id in (select id from source_langu... | [
"function",
"(",
"languageSlug",
")",
"{",
"let",
"result",
";",
"if",
"(",
"languageSlug",
")",
"{",
"result",
"=",
"query",
"(",
"'select p.*, c.slug as category_slug from project as p'",
"+",
"' left join category as c on c.id=p.category_id'",
"+",
"' where p.source_lang... | Returns a list of projects available in the given language.
@param languageSlug {string} if left null an array of all unique projects will be returned
@returns {[{}]} an array of projects | [
"Returns",
"a",
"list",
"of",
"projects",
"available",
"in",
"the",
"given",
"language",
"."
] | 18f518368ee89f4baf8943500a1c53ef5efcfb3e | https://github.com/unfoldingWord-dev/node-door43-client/blob/18f518368ee89f4baf8943500a1c53ef5efcfb3e/lib/library.js#L651-L667 | train | |
unfoldingWord-dev/node-door43-client | lib/library.js | function(parentCategoryId, languageSlug, translateMode) {
let preferredSlug = [languageSlug, 'en', '%'];
let categories = [];
if(translateMode) {
categories = query('select \'category\' as type, c.slug as name, \'\' as source_language_slug,' +
' c.... | javascript | function(parentCategoryId, languageSlug, translateMode) {
let preferredSlug = [languageSlug, 'en', '%'];
let categories = [];
if(translateMode) {
categories = query('select \'category\' as type, c.slug as name, \'\' as source_language_slug,' +
' c.... | [
"function",
"(",
"parentCategoryId",
",",
"languageSlug",
",",
"translateMode",
")",
"{",
"let",
"preferredSlug",
"=",
"[",
"languageSlug",
",",
"'en'",
",",
"'%'",
"]",
";",
"let",
"categories",
"=",
"[",
"]",
";",
"if",
"(",
"translateMode",
")",
"{",
... | Returns an array of categories that exist underneath the parent category.
The results of this method are a combination of categories and projects.
@param parentCategoryId {int} the category who's children will be returned. If 0 then all top level categories will be returned.
@param languageSlug {string} the language i... | [
"Returns",
"an",
"array",
"of",
"categories",
"that",
"exist",
"underneath",
"the",
"parent",
"category",
".",
"The",
"results",
"of",
"this",
"method",
"are",
"a",
"combination",
"of",
"categories",
"and",
"projects",
"."
] | 18f518368ee89f4baf8943500a1c53ef5efcfb3e | https://github.com/unfoldingWord-dev/node-door43-client/blob/18f518368ee89f4baf8943500a1c53ef5efcfb3e/lib/library.js#L678-L732 | train | |
unfoldingWord-dev/node-door43-client | lib/library.js | function(languageSlug, projectSlug, resourceSlug) {
let result = query('select r.*, lri.translation_words_assignments_url from resource as r' +
' left join legacy_resource_info as lri on lri.resource_id=r.id' +
' where r.slug=? and r.project_id in (' +
' sel... | javascript | function(languageSlug, projectSlug, resourceSlug) {
let result = query('select r.*, lri.translation_words_assignments_url from resource as r' +
' left join legacy_resource_info as lri on lri.resource_id=r.id' +
' where r.slug=? and r.project_id in (' +
' sel... | [
"function",
"(",
"languageSlug",
",",
"projectSlug",
",",
"resourceSlug",
")",
"{",
"let",
"result",
"=",
"query",
"(",
"'select r.*, lri.translation_words_assignments_url from resource as r'",
"+",
"' left join legacy_resource_info as lri on lri.resource_id=r.id'",
"+",
"' where... | Returns a resource.
@param languageSlug {string}
@param projectSlug {string}
@param resourceSlug {string}
@returns {{}|null} the resource object or null if it does not exist | [
"Returns",
"a",
"resource",
"."
] | 18f518368ee89f4baf8943500a1c53ef5efcfb3e | https://github.com/unfoldingWord-dev/node-door43-client/blob/18f518368ee89f4baf8943500a1c53ef5efcfb3e/lib/library.js#L742-L789 | train | |
unfoldingWord-dev/node-door43-client | lib/library.js | function(languageSlug, versificationSlug) {
let result = query('' +
'select vn.name, v.slug, v.id from versification_name as vn' +
' left join versification as v on v.id=vn.versification_id' +
' left join source_language as sl on sl.id=vn.source_language_id' +... | javascript | function(languageSlug, versificationSlug) {
let result = query('' +
'select vn.name, v.slug, v.id from versification_name as vn' +
' left join versification as v on v.id=vn.versification_id' +
' left join source_language as sl on sl.id=vn.source_language_id' +... | [
"function",
"(",
"languageSlug",
",",
"versificationSlug",
")",
"{",
"let",
"result",
"=",
"query",
"(",
"''",
"+",
"'select vn.name, v.slug, v.id from versification_name as vn'",
"+",
"' left join versification as v on v.id=vn.versification_id'",
"+",
"' left join source_languag... | Returns a versification.
@param languageSlug {string}
@param versificationSlug {string}
@returns {{}|null} | [
"Returns",
"a",
"versification",
"."
] | 18f518368ee89f4baf8943500a1c53ef5efcfb3e | https://github.com/unfoldingWord-dev/node-door43-client/blob/18f518368ee89f4baf8943500a1c53ef5efcfb3e/lib/library.js#L946-L956 | train | |
unfoldingWord-dev/node-door43-client | lib/library.js | function(tdId) {
let result = query('select * from questionnaire where td_id=?', [tdId]);
if(result.length > 0) {
let questionnaire = result[0];
questionnaire.language_data = {};
// load data fields
let dataResults = query('select ... | javascript | function(tdId) {
let result = query('select * from questionnaire where td_id=?', [tdId]);
if(result.length > 0) {
let questionnaire = result[0];
questionnaire.language_data = {};
// load data fields
let dataResults = query('select ... | [
"function",
"(",
"tdId",
")",
"{",
"let",
"result",
"=",
"query",
"(",
"'select * from questionnaire where td_id=?'",
",",
"[",
"tdId",
"]",
")",
";",
"if",
"(",
"result",
".",
"length",
">",
"0",
")",
"{",
"let",
"questionnaire",
"=",
"result",
"[",
"0"... | Returns a single questionnaire
@param tdId {string} the translation database id of the questionnaire | [
"Returns",
"a",
"single",
"questionnaire"
] | 18f518368ee89f4baf8943500a1c53ef5efcfb3e | https://github.com/unfoldingWord-dev/node-door43-client/blob/18f518368ee89f4baf8943500a1c53ef5efcfb3e/lib/library.js#L990-L1005 | train | |
unfoldingWord-dev/node-door43-client | lib/library.js | function() {
let results = query('select * from questionnaire');
for(let questionnaire of results) {
// load data fields
questionnaire.language_data = {};
let dataResults = query('select field, question_td_id from questionnaire_data_field where qu... | javascript | function() {
let results = query('select * from questionnaire');
for(let questionnaire of results) {
// load data fields
questionnaire.language_data = {};
let dataResults = query('select field, question_td_id from questionnaire_data_field where qu... | [
"function",
"(",
")",
"{",
"let",
"results",
"=",
"query",
"(",
"'select * from questionnaire'",
")",
";",
"for",
"(",
"let",
"questionnaire",
"of",
"results",
")",
"{",
"// load data fields",
"questionnaire",
".",
"language_data",
"=",
"{",
"}",
";",
"let",
... | Returns a list of questionnaires.
@returns {[{}]} a list of questionnaires | [
"Returns",
"a",
"list",
"of",
"questionnaires",
"."
] | 18f518368ee89f4baf8943500a1c53ef5efcfb3e | https://github.com/unfoldingWord-dev/node-door43-client/blob/18f518368ee89f4baf8943500a1c53ef5efcfb3e/lib/library.js#L1012-L1025 | train | |
unfoldingWord-dev/node-door43-client | lib/library.js | function(language_slug, project_slug, resource_slug, resource_type, translate_mode, min_checking_level, max_checking_level) {
let condition_max_checking = '';
language_slug = language_slug || '%';
project_slug = project_slug || '%';
resource_slug = resource_slug || '%';
... | javascript | function(language_slug, project_slug, resource_slug, resource_type, translate_mode, min_checking_level, max_checking_level) {
let condition_max_checking = '';
language_slug = language_slug || '%';
project_slug = project_slug || '%';
resource_slug = resource_slug || '%';
... | [
"function",
"(",
"language_slug",
",",
"project_slug",
",",
"resource_slug",
",",
"resource_type",
",",
"translate_mode",
",",
"min_checking_level",
",",
"max_checking_level",
")",
"{",
"let",
"condition_max_checking",
"=",
"''",
";",
"language_slug",
"=",
"language_s... | Return sa list of translations.
@param language_slug string the language these translations are available in. Leave null for all.
@param project_slug string the project for whom these translations are available. Leave null for all.
@param resource_slug string the resource for whom these translations are available. Lea... | [
"Return",
"sa",
"list",
"of",
"translations",
"."
] | 18f518368ee89f4baf8943500a1c53ef5efcfb3e | https://github.com/unfoldingWord-dev/node-door43-client/blob/18f518368ee89f4baf8943500a1c53ef5efcfb3e/lib/library.js#L1048-L1131 | train | |
DavidSouther/JEFRi | modeler/angular/app/scripts/lib/$/select2/dev.js | equal | function equal(a, b) {
if (a === b) return true;
if (a === undefined || b === undefined) return false;
if (a === null || b === null) return false;
if (a.constructor === String) return a.localeCompare(b) === 0;
if (b.constructor === String) return b.localeCompare(a) === 0;
... | javascript | function equal(a, b) {
if (a === b) return true;
if (a === undefined || b === undefined) return false;
if (a === null || b === null) return false;
if (a.constructor === String) return a.localeCompare(b) === 0;
if (b.constructor === String) return b.localeCompare(a) === 0;
... | [
"function",
"equal",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"a",
"===",
"b",
")",
"return",
"true",
";",
"if",
"(",
"a",
"===",
"undefined",
"||",
"b",
"===",
"undefined",
")",
"return",
"false",
";",
"if",
"(",
"a",
"===",
"null",
"||",
"b",... | Compares equality of a and b taking into account that a and b may be strings, in which case localeCompare is used
@param a
@param b | [
"Compares",
"equality",
"of",
"a",
"and",
"b",
"taking",
"into",
"account",
"that",
"a",
"and",
"b",
"may",
"be",
"strings",
"in",
"which",
"case",
"localeCompare",
"is",
"used"
] | 161f24e242e05b9b2114cc1123a257141a60eaf2 | https://github.com/DavidSouther/JEFRi/blob/161f24e242e05b9b2114cc1123a257141a60eaf2/modeler/angular/app/scripts/lib/$/select2/dev.js#L122-L129 | train |
DavidSouther/JEFRi | modeler/angular/app/scripts/lib/$/select2/dev.js | installFilteredMouseMove | function installFilteredMouseMove(element) {
element.bind("mousemove", function (e) {
var lastpos = $.data(document, "select2-lastpos");
if (lastpos === undefined || lastpos.x !== e.pageX || lastpos.y !== e.pageY) {
$(e.target).trigger("mousemove-filtered", e);
}... | javascript | function installFilteredMouseMove(element) {
element.bind("mousemove", function (e) {
var lastpos = $.data(document, "select2-lastpos");
if (lastpos === undefined || lastpos.x !== e.pageX || lastpos.y !== e.pageY) {
$(e.target).trigger("mousemove-filtered", e);
}... | [
"function",
"installFilteredMouseMove",
"(",
"element",
")",
"{",
"element",
".",
"bind",
"(",
"\"mousemove\"",
",",
"function",
"(",
"e",
")",
"{",
"var",
"lastpos",
"=",
"$",
".",
"data",
"(",
"document",
",",
"\"select2-lastpos\"",
")",
";",
"if",
"(",
... | filters mouse events so an event is fired only if the mouse moved.
filters out mouse events that occur when mouse is stationary but
the elements under the pointer are scrolled. | [
"filters",
"mouse",
"events",
"so",
"an",
"event",
"is",
"fired",
"only",
"if",
"the",
"mouse",
"moved",
"."
] | 161f24e242e05b9b2114cc1123a257141a60eaf2 | https://github.com/DavidSouther/JEFRi/blob/161f24e242e05b9b2114cc1123a257141a60eaf2/modeler/angular/app/scripts/lib/$/select2/dev.js#L175-L182 | train |
DavidSouther/JEFRi | modeler/angular/app/scripts/lib/$/select2/dev.js | ajax | function ajax(options) {
var timeout, // current scheduled but not yet executed request
requestSequence = 0, // sequence used to drop out-of-order responses
handler = null,
quietMillis = options.quietMillis || 100;
return function (query) {
window.clearTi... | javascript | function ajax(options) {
var timeout, // current scheduled but not yet executed request
requestSequence = 0, // sequence used to drop out-of-order responses
handler = null,
quietMillis = options.quietMillis || 100;
return function (query) {
window.clearTi... | [
"function",
"ajax",
"(",
"options",
")",
"{",
"var",
"timeout",
",",
"// current scheduled but not yet executed request",
"requestSequence",
"=",
"0",
",",
"// sequence used to drop out-of-order responses",
"handler",
"=",
"null",
",",
"quietMillis",
"=",
"options",
".",
... | Produces an ajax-based query function
@param options object containing configuration paramters
@param options.transport function that will be used to execute the ajax request. must be compatible with parameters supported by $.ajax
@param options.url url for the data
@param options.data a function(searchTerm, pageNumbe... | [
"Produces",
"an",
"ajax",
"-",
"based",
"query",
"function"
] | 161f24e242e05b9b2114cc1123a257141a60eaf2 | https://github.com/DavidSouther/JEFRi/blob/161f24e242e05b9b2114cc1123a257141a60eaf2/modeler/angular/app/scripts/lib/$/select2/dev.js#L285-L322 | train |
DavidSouther/JEFRi | modeler/angular/app/scripts/lib/$/select2/dev.js | local | function local(options) {
var data = options, // data elements
dataText,
text = function (item) { return ""+item.text; }; // function used to retrieve the text portion of a data item that is matched against the search
if (!$.isArray(data)) {
text = data.text;
... | javascript | function local(options) {
var data = options, // data elements
dataText,
text = function (item) { return ""+item.text; }; // function used to retrieve the text portion of a data item that is matched against the search
if (!$.isArray(data)) {
text = data.text;
... | [
"function",
"local",
"(",
"options",
")",
"{",
"var",
"data",
"=",
"options",
",",
"// data elements",
"dataText",
",",
"text",
"=",
"function",
"(",
"item",
")",
"{",
"return",
"\"\"",
"+",
"item",
".",
"text",
";",
"}",
";",
"// function used to retrieve... | Produces a query function that works with a local array
@param options object containing configuration parameters. The options parameter can either be an array or an
object.
If the array form is used it is assumed that it contains objects with 'id' and 'text' keys.
If the object form is used ti is assumed that it co... | [
"Produces",
"a",
"query",
"function",
"that",
"works",
"with",
"a",
"local",
"array"
] | 161f24e242e05b9b2114cc1123a257141a60eaf2 | https://github.com/DavidSouther/JEFRi/blob/161f24e242e05b9b2114cc1123a257141a60eaf2/modeler/angular/app/scripts/lib/$/select2/dev.js#L338-L383 | train |
DavidSouther/JEFRi | modeler/angular/app/scripts/lib/$/select2/dev.js | function () {
function resolveContainerWidth() {
var style, attrs, matches, i, l;
if (this.opts.width === "off") {
return null;
} else if (this.opts.width === "element"){
return this.opts.element.outerWidth() === 0 ? 'a... | javascript | function () {
function resolveContainerWidth() {
var style, attrs, matches, i, l;
if (this.opts.width === "off") {
return null;
} else if (this.opts.width === "element"){
return this.opts.element.outerWidth() === 0 ? 'a... | [
"function",
"(",
")",
"{",
"function",
"resolveContainerWidth",
"(",
")",
"{",
"var",
"style",
",",
"attrs",
",",
"matches",
",",
"i",
",",
"l",
";",
"if",
"(",
"this",
".",
"opts",
".",
"width",
"===",
"\"off\"",
")",
"{",
"return",
"null",
";",
"... | Get the desired width for the container element. This is
derived first from option `width` passed to select2, then
the inline 'style' on the original element, and finally
falls back to the jQuery calculated element width.
abstract | [
"Get",
"the",
"desired",
"width",
"for",
"the",
"container",
"element",
".",
"This",
"is",
"derived",
"first",
"from",
"option",
"width",
"passed",
"to",
"select2",
"then",
"the",
"inline",
"style",
"on",
"the",
"original",
"element",
"and",
"finally",
"fall... | 161f24e242e05b9b2114cc1123a257141a60eaf2 | https://github.com/DavidSouther/JEFRi/blob/161f24e242e05b9b2114cc1123a257141a60eaf2/modeler/angular/app/scripts/lib/$/select2/dev.js#L1326-L1369 | train | |
Runnable/monitor-dog | lib/interval-monitor.js | IntervalMonitor | function IntervalMonitor(monitor, prefix, interval) {
this.monitor = monitor;
this.prefix = prefix || this.monitor.prefix;
this.interval = interval || this.monitor.interval;
} | javascript | function IntervalMonitor(monitor, prefix, interval) {
this.monitor = monitor;
this.prefix = prefix || this.monitor.prefix;
this.interval = interval || this.monitor.interval;
} | [
"function",
"IntervalMonitor",
"(",
"monitor",
",",
"prefix",
",",
"interval",
")",
"{",
"this",
".",
"monitor",
"=",
"monitor",
";",
"this",
".",
"prefix",
"=",
"prefix",
"||",
"this",
".",
"monitor",
".",
"prefix",
";",
"this",
".",
"interval",
"=",
... | Abstract base class for all types of specialized monitors that report
information periodically over a given interval.
@param {monitor-dog.Monitor} Base monitor class for the interval monitor.
@param {string} prefix Prefix to use for the interval monitor.
@param {number} interval Amount of time between reports, in milli... | [
"Abstract",
"base",
"class",
"for",
"all",
"types",
"of",
"specialized",
"monitors",
"that",
"report",
"information",
"periodically",
"over",
"a",
"given",
"interval",
"."
] | 040b259dfc8c6b5d934dc235f76028e5ab9094cc | https://github.com/Runnable/monitor-dog/blob/040b259dfc8c6b5d934dc235f76028e5ab9094cc/lib/interval-monitor.js#L18-L22 | train |
vesln/hydro | lib/interface.js | each | function each(key, interface, fn) {
var stack = interface.stack;
for (var i = 0, len = stack.length; i < len; i++) {
stack[i][key].forEach(fn);
}
} | javascript | function each(key, interface, fn) {
var stack = interface.stack;
for (var i = 0, len = stack.length; i < len; i++) {
stack[i][key].forEach(fn);
}
} | [
"function",
"each",
"(",
"key",
",",
"interface",
",",
"fn",
")",
"{",
"var",
"stack",
"=",
"interface",
".",
"stack",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"stack",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
... | Interate through all functions in the stack.
@param {String} key
@param {Interface} interface
@param {Function} fn
@api private | [
"Interate",
"through",
"all",
"functions",
"in",
"the",
"stack",
"."
] | 3f4d2e4926f913976187376e82f1496514c39890 | https://github.com/vesln/hydro/blob/3f4d2e4926f913976187376e82f1496514c39890/lib/interface.js#L203-L209 | train |
hrgdavor/babel-plugin-jsx-mi2 | index.js | buildOpeningElementAttributes | function buildOpeningElementAttributes (attribs, state) {
var _props = []
while (attribs.length) {
var prop = attribs.shift()
if (t.isJSXSpreadAttribute(prop)) {
prop.argument._isSpread = true
_props.push(t.spreadProperty(prop.argument))
} else {
_props.push(convertAtt... | javascript | function buildOpeningElementAttributes (attribs, state) {
var _props = []
while (attribs.length) {
var prop = attribs.shift()
if (t.isJSXSpreadAttribute(prop)) {
prop.argument._isSpread = true
_props.push(t.spreadProperty(prop.argument))
} else {
_props.push(convertAtt... | [
"function",
"buildOpeningElementAttributes",
"(",
"attribs",
",",
"state",
")",
"{",
"var",
"_props",
"=",
"[",
"]",
"while",
"(",
"attribs",
".",
"length",
")",
"{",
"var",
"prop",
"=",
"attribs",
".",
"shift",
"(",
")",
"if",
"(",
"t",
".",
"isJSXSpr... | Convert to object declaration by adding all
props and spreads as they are found. | [
"Convert",
"to",
"object",
"declaration",
"by",
"adding",
"all",
"props",
"and",
"spreads",
"as",
"they",
"are",
"found",
"."
] | a5f1be9d7994cf72b5c740c2970bab5dab57d207 | https://github.com/hrgdavor/babel-plugin-jsx-mi2/blob/a5f1be9d7994cf72b5c740c2970bab5dab57d207/index.js#L124-L140 | train |
Mammut-FE/nejm | src/util/ajax/proxy/xhr.js | function(_form){
var _result = [];
_u._$reverseEach(
_form.getElementsByTagName('input'),
function(_input){
if (_input.type!='file'){
return;
}
// remove file without name
... | javascript | function(_form){
var _result = [];
_u._$reverseEach(
_form.getElementsByTagName('input'),
function(_input){
if (_input.type!='file'){
return;
}
// remove file without name
... | [
"function",
"(",
"_form",
")",
"{",
"var",
"_result",
"=",
"[",
"]",
";",
"_u",
".",
"_$reverseEach",
"(",
"_form",
".",
"getElementsByTagName",
"(",
"'input'",
")",
",",
"function",
"(",
"_input",
")",
"{",
"if",
"(",
"_input",
".",
"type",
"!=",
"'... | split input.file for multiple files | [
"split",
"input",
".",
"file",
"for",
"multiple",
"files"
] | dfc09ac66a8d67620a7aea65e34d8a179976b3fb | https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/ajax/proxy/xhr.js#L62-L85 | train | |
Mammut-FE/nejm | src/base/platform/element.patch.js | function(_element){
var _id = _element.id;
if (!!_dataset[_id]) return;
var _map = {};
_u._$forEach(
_element.attributes,
function(_node){
var _key = _node.nodeName;
i... | javascript | function(_element){
var _id = _element.id;
if (!!_dataset[_id]) return;
var _map = {};
_u._$forEach(
_element.attributes,
function(_node){
var _key = _node.nodeName;
i... | [
"function",
"(",
"_element",
")",
"{",
"var",
"_id",
"=",
"_element",
".",
"id",
";",
"if",
"(",
"!",
"!",
"_dataset",
"[",
"_id",
"]",
")",
"return",
";",
"var",
"_map",
"=",
"{",
"}",
";",
"_u",
".",
"_$forEach",
"(",
"_element",
".",
"attribut... | init element dataset | [
"init",
"element",
"dataset"
] | dfc09ac66a8d67620a7aea65e34d8a179976b3fb | https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/base/platform/element.patch.js#L52-L69 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.