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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
fronteerio/node-embdr | lib/api/resources.js | function(id, callback) {
var url = '/resources/' + ProcessrUtil.encodeURIComponent(id);
return processr._request('GET', url, null, callback);
} | javascript | function(id, callback) {
var url = '/resources/' + ProcessrUtil.encodeURIComponent(id);
return processr._request('GET', url, null, callback);
} | [
"function",
"(",
"id",
",",
"callback",
")",
"{",
"var",
"url",
"=",
"'/resources/'",
"+",
"ProcessrUtil",
".",
"encodeURIComponent",
"(",
"id",
")",
";",
"return",
"processr",
".",
"_request",
"(",
"'GET'",
",",
"url",
",",
"null",
",",
"callback",
")",... | Get a resource
@param {string} id The id of the resource that should be retrieved
@param {Function} callback Standard callback function
@param {Error} callback.err The error object as returned by the REST API. If no error occurred, this value will be `null`
@param {Obj... | [
"Get",
"a",
"resource"
] | 050916baa37b069d894fdd4db3b80f110ad8c51e | https://github.com/fronteerio/node-embdr/blob/050916baa37b069d894fdd4db3b80f110ad8c51e/lib/api/resources.js#L73-L76 | train | |
skerit/hawkejs | lib/client/scene.js | onReadystatechange | function onReadystatechange(e) {
if (!(e instanceof Event)) {
throw new TypeError('Invalid event was given');
}
if (document.readyState == 'interactive') {
makeReady.call(this);
}
if (document.readyState == 'complete') {
makeLoaded.call(this);
}
} | javascript | function onReadystatechange(e) {
if (!(e instanceof Event)) {
throw new TypeError('Invalid event was given');
}
if (document.readyState == 'interactive') {
makeReady.call(this);
}
if (document.readyState == 'complete') {
makeLoaded.call(this);
}
} | [
"function",
"onReadystatechange",
"(",
"e",
")",
"{",
"if",
"(",
"!",
"(",
"e",
"instanceof",
"Event",
")",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'Invalid event was given'",
")",
";",
"}",
"if",
"(",
"document",
".",
"readyState",
"==",
"'interactiv... | Listen to the readystate changes of the `document`
@author Jelle De Loecker <jelle@develry.be>
@since 1.0.0
@version 1.0.0 | [
"Listen",
"to",
"the",
"readystate",
"changes",
"of",
"the",
"document"
] | 15ed7205183ac2c425362deb8c0796c0d16b898a | https://github.com/skerit/hawkejs/blob/15ed7205183ac2c425362deb8c0796c0d16b898a/lib/client/scene.js#L208-L221 | train |
skerit/hawkejs | lib/client/scene.js | check | function check() {
var el,
i;
// Return early if no elements need to be checked
if (!elements.length) {
return;
}
for (i = 0; i < elements.length; i++) {
el = elements[i];
if (el.isVisible(options.padding)) {
if (live) {
el.classList.remove(query);
} else {
elements.splice... | javascript | function check() {
var el,
i;
// Return early if no elements need to be checked
if (!elements.length) {
return;
}
for (i = 0; i < elements.length; i++) {
el = elements[i];
if (el.isVisible(options.padding)) {
if (live) {
el.classList.remove(query);
} else {
elements.splice... | [
"function",
"check",
"(",
")",
"{",
"var",
"el",
",",
"i",
";",
"// Return early if no elements need to be checked",
"if",
"(",
"!",
"elements",
".",
"length",
")",
"{",
"return",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"elements",
".",
"le... | The actual check | [
"The",
"actual",
"check"
] | 15ed7205183ac2c425362deb8c0796c0d16b898a | https://github.com/skerit/hawkejs/blob/15ed7205183ac2c425362deb8c0796c0d16b898a/lib/client/scene.js#L3004-L3045 | train |
alexpods/ClazzJS | src/components/meta/Events.js | function(clazz, metaData) {
this.applyEvents(clazz, metaData.clazz_events || {});
this.applyEvents(clazz.prototype, metaData.events || {});
} | javascript | function(clazz, metaData) {
this.applyEvents(clazz, metaData.clazz_events || {});
this.applyEvents(clazz.prototype, metaData.events || {});
} | [
"function",
"(",
"clazz",
",",
"metaData",
")",
"{",
"this",
".",
"applyEvents",
"(",
"clazz",
",",
"metaData",
".",
"clazz_events",
"||",
"{",
"}",
")",
";",
"this",
".",
"applyEvents",
"(",
"clazz",
".",
"prototype",
",",
"metaData",
".",
"events",
"... | Applies events to clazz and its prototype
@param {clazz} clazz Clazz
@param {object} metaData Meta data with 'clazz_event' and 'event' properties
@this {metaProcessor} | [
"Applies",
"events",
"to",
"clazz",
"and",
"its",
"prototype"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Events.js#L15-L18 | train | |
alexpods/ClazzJS | src/components/meta/Events.js | function(object, events) {
if (!object.__isInterfaceImplemented('events')) {
object.__implementInterface('events', this.interface);
}
object.__initEvents();
_.each(events, function(eventListeners, eventName) {
_.each(eventListeners, function(listener, listenerNa... | javascript | function(object, events) {
if (!object.__isInterfaceImplemented('events')) {
object.__implementInterface('events', this.interface);
}
object.__initEvents();
_.each(events, function(eventListeners, eventName) {
_.each(eventListeners, function(listener, listenerNa... | [
"function",
"(",
"object",
",",
"events",
")",
"{",
"if",
"(",
"!",
"object",
".",
"__isInterfaceImplemented",
"(",
"'events'",
")",
")",
"{",
"object",
".",
"__implementInterface",
"(",
"'events'",
",",
"this",
".",
"interface",
")",
";",
"}",
"object",
... | Implements events prototype and applies events to object
@param {clazz|object} object Clazz of its prototype
@param {object} events Events
@this {metaProcessor} | [
"Implements",
"events",
"prototype",
"and",
"applies",
"events",
"to",
"object"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Events.js#L28-L40 | train | |
alexpods/ClazzJS | src/components/meta/Events.js | function(event /* params */) {
var listeners;
var that = this;
var params = _.toArray(arguments).slice(1);
listeners = this.__getEventListeners(event);
_.each(listeners, function(listener) {
listener.apply(that, params);
});
... | javascript | function(event /* params */) {
var listeners;
var that = this;
var params = _.toArray(arguments).slice(1);
listeners = this.__getEventListeners(event);
_.each(listeners, function(listener) {
listener.apply(that, params);
});
... | [
"function",
"(",
"event",
"/* params */",
")",
"{",
"var",
"listeners",
";",
"var",
"that",
"=",
"this",
";",
"var",
"params",
"=",
"_",
".",
"toArray",
"(",
"arguments",
")",
".",
"slice",
"(",
"1",
")",
";",
"listeners",
"=",
"this",
".",
"__getEve... | Emits specified event
@param {string} event Event name
@returns {clazz|object} this
@this {clazz|object} | [
"Emits",
"specified",
"event"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Events.js#L64-L83 | train | |
alexpods/ClazzJS | src/components/meta/Events.js | function(event, name, callback) {
if (this.__hasEventListener(event, name)) {
throw new Error('Event listener for event "' + event + '" with name "' + name + '" already exist!');
}
if (!(event in this.__events)) {
this.__events[event] = {};
... | javascript | function(event, name, callback) {
if (this.__hasEventListener(event, name)) {
throw new Error('Event listener for event "' + event + '" with name "' + name + '" already exist!');
}
if (!(event in this.__events)) {
this.__events[event] = {};
... | [
"function",
"(",
"event",
",",
"name",
",",
"callback",
")",
"{",
"if",
"(",
"this",
".",
"__hasEventListener",
"(",
"event",
",",
"name",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Event listener for event \"'",
"+",
"event",
"+",
"'\" with name \"'",
... | Adds event listener for specified event
@param {string} event Event name
@param {string} name Listener name
@param {function} callback Listener handler
@returns {clazz|object} this
@throws {Error} if event listener for specified event already exist
@this {clazz|object} | [
"Adds",
"event",
"listener",
"for",
"specified",
"event"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Events.js#L97-L109 | train | |
alexpods/ClazzJS | src/components/meta/Events.js | function(event, name) {
var that = this;
if (!(event in that.__events)) {
that.__events[event] = {};
}
if (!_.isUndefined(name)) {
if (!that.__hasEventListener(event, name)) {
throw new Error('There is no "' + event + ... | javascript | function(event, name) {
var that = this;
if (!(event in that.__events)) {
that.__events[event] = {};
}
if (!_.isUndefined(name)) {
if (!that.__hasEventListener(event, name)) {
throw new Error('There is no "' + event + ... | [
"function",
"(",
"event",
",",
"name",
")",
"{",
"var",
"that",
"=",
"this",
";",
"if",
"(",
"!",
"(",
"event",
"in",
"that",
".",
"__events",
")",
")",
"{",
"that",
".",
"__events",
"[",
"event",
"]",
"=",
"{",
"}",
";",
"}",
"if",
"(",
"!",... | Removes event listener for specified event
@param {string} event Event name
@param {string} name Listener name
@returns {clazz|object} this
@throws {Error} if event listener for specified event does not exists
@this {clazz|object} | [
"Removes",
"event",
"listener",
"for",
"specified",
"event"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Events.js#L122-L144 | train | |
alexpods/ClazzJS | src/components/meta/Events.js | function(event, name) {
var eventListeners = this.__getEventListeners(event);
if (!(name in eventListeners)) {
throw new Error('Event listener for event "' + event + '" with name "' + name + '" does not exist!');
}
return eventListeners[event][name];
... | javascript | function(event, name) {
var eventListeners = this.__getEventListeners(event);
if (!(name in eventListeners)) {
throw new Error('Event listener for event "' + event + '" with name "' + name + '" does not exist!');
}
return eventListeners[event][name];
... | [
"function",
"(",
"event",
",",
"name",
")",
"{",
"var",
"eventListeners",
"=",
"this",
".",
"__getEventListeners",
"(",
"event",
")",
";",
"if",
"(",
"!",
"(",
"name",
"in",
"eventListeners",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Event listener ... | Gets event listener
@param {string} event Event name
@param {string} name Listener name
@returns {function} Event listener handler
@throws {Error} if event listener does not exist
@this {clazz|object} | [
"Gets",
"event",
"listener"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Events.js#L170-L179 | train | |
alexpods/ClazzJS | src/components/meta/Events.js | function(event) {
var events = this.__collectAllPropertyValues.apply(this, ['__events', 2].concat(event || []));
_.each(events, function(eventsListeners) {
_.each(eventsListeners, function(listener, listenerName) {
if (_.isUndefined(listener)) {
... | javascript | function(event) {
var events = this.__collectAllPropertyValues.apply(this, ['__events', 2].concat(event || []));
_.each(events, function(eventsListeners) {
_.each(eventsListeners, function(listener, listenerName) {
if (_.isUndefined(listener)) {
... | [
"function",
"(",
"event",
")",
"{",
"var",
"events",
"=",
"this",
".",
"__collectAllPropertyValues",
".",
"apply",
"(",
"this",
",",
"[",
"'__events'",
",",
"2",
"]",
".",
"concat",
"(",
"event",
"||",
"[",
"]",
")",
")",
";",
"_",
".",
"each",
"("... | Gets all event listeners for specified event
@param {string} event Event name
@returns {object} Hash of event listener
@this {clazz|object} | [
"Gets",
"all",
"event",
"listeners",
"for",
"specified",
"event"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Events.js#L191-L203 | train | |
redisjs/jsr-script | lib/manager.js | ScriptManager | function ScriptManager() {
// child process
this.ps = null;
// script execution limit in milliseconds
this._limit = 5000;
// flag determining if a script is busy executing
this._busy = false;
// flag determining if script execution issued
// any write commands
this._written = false;
// currentl... | javascript | function ScriptManager() {
// child process
this.ps = null;
// script execution limit in milliseconds
this._limit = 5000;
// flag determining if a script is busy executing
this._busy = false;
// flag determining if script execution issued
// any write commands
this._written = false;
// currentl... | [
"function",
"ScriptManager",
"(",
")",
"{",
"// child process",
"this",
".",
"ps",
"=",
"null",
";",
"// script execution limit in milliseconds",
"this",
".",
"_limit",
"=",
"5000",
";",
"// flag determining if a script is busy executing",
"this",
".",
"_busy",
"=",
"... | Manages script evaluation, compilation and command execution.
Scripts are executed in a child process so that a script that contains
an infinite loop or other bad code will not prevent this process
from serving client requests. | [
"Manages",
"script",
"evaluation",
"compilation",
"and",
"command",
"execution",
"."
] | eab3df935372724a82a9ad9ba3bca7e6e165e9d1 | https://github.com/redisjs/jsr-script/blob/eab3df935372724a82a9ad9ba3bca7e6e165e9d1/lib/manager.js#L19-L42 | train |
redisjs/jsr-script | lib/manager.js | load | function load(req, res, source) {
this.spawn();
this.reply(req, res);
this.ps.send({event: 'load', source: source});
} | javascript | function load(req, res, source) {
this.spawn();
this.reply(req, res);
this.ps.send({event: 'load', source: source});
} | [
"function",
"load",
"(",
"req",
",",
"res",
",",
"source",
")",
"{",
"this",
".",
"spawn",
"(",
")",
";",
"this",
".",
"reply",
"(",
"req",
",",
"res",
")",
";",
"this",
".",
"ps",
".",
"send",
"(",
"{",
"event",
":",
"'load'",
",",
"source",
... | Load a script in to the script cache. | [
"Load",
"a",
"script",
"in",
"to",
"the",
"script",
"cache",
"."
] | eab3df935372724a82a9ad9ba3bca7e6e165e9d1 | https://github.com/redisjs/jsr-script/blob/eab3df935372724a82a9ad9ba3bca7e6e165e9d1/lib/manager.js#L60-L64 | train |
redisjs/jsr-script | lib/manager.js | eval | function eval(req, res, source, args) {
this.spawn();
this.reply(req, res, this._limit);
// need to coerce buffers for the moment
args = args.map(function(a) {
if(a instanceof Buffer) return a.toString();
return a;
})
this.ps.send({event: 'eval', source: source, args: args});
} | javascript | function eval(req, res, source, args) {
this.spawn();
this.reply(req, res, this._limit);
// need to coerce buffers for the moment
args = args.map(function(a) {
if(a instanceof Buffer) return a.toString();
return a;
})
this.ps.send({event: 'eval', source: source, args: args});
} | [
"function",
"eval",
"(",
"req",
",",
"res",
",",
"source",
",",
"args",
")",
"{",
"this",
".",
"spawn",
"(",
")",
";",
"this",
".",
"reply",
"(",
"req",
",",
"res",
",",
"this",
".",
"_limit",
")",
";",
"// need to coerce buffers for the moment",
"args... | Evaluate a script. | [
"Evaluate",
"a",
"script",
"."
] | eab3df935372724a82a9ad9ba3bca7e6e165e9d1 | https://github.com/redisjs/jsr-script/blob/eab3df935372724a82a9ad9ba3bca7e6e165e9d1/lib/manager.js#L69-L78 | train |
redisjs/jsr-script | lib/manager.js | evalsha | function evalsha(req, res, sha, args) {
this.spawn();
this.reply(req, res, this._limit);
// need to coerce buffers for the moment
args = args.map(function(a) {
if(a instanceof Buffer) return a.toString();
return a;
})
this.ps.send({event: 'evalsha', sha: sha, args: args});
} | javascript | function evalsha(req, res, sha, args) {
this.spawn();
this.reply(req, res, this._limit);
// need to coerce buffers for the moment
args = args.map(function(a) {
if(a instanceof Buffer) return a.toString();
return a;
})
this.ps.send({event: 'evalsha', sha: sha, args: args});
} | [
"function",
"evalsha",
"(",
"req",
",",
"res",
",",
"sha",
",",
"args",
")",
"{",
"this",
".",
"spawn",
"(",
")",
";",
"this",
".",
"reply",
"(",
"req",
",",
"res",
",",
"this",
".",
"_limit",
")",
";",
"// need to coerce buffers for the moment",
"args... | Evaluate a script by sha checksum. | [
"Evaluate",
"a",
"script",
"by",
"sha",
"checksum",
"."
] | eab3df935372724a82a9ad9ba3bca7e6e165e9d1 | https://github.com/redisjs/jsr-script/blob/eab3df935372724a82a9ad9ba3bca7e6e165e9d1/lib/manager.js#L83-L92 | train |
redisjs/jsr-script | lib/manager.js | flush | function flush(req, res) {
this.spawn();
this.reply(req, res);
this.ps.send({event: 'flush'});
} | javascript | function flush(req, res) {
this.spawn();
this.reply(req, res);
this.ps.send({event: 'flush'});
} | [
"function",
"flush",
"(",
"req",
",",
"res",
")",
"{",
"this",
".",
"spawn",
"(",
")",
";",
"this",
".",
"reply",
"(",
"req",
",",
"res",
")",
";",
"this",
".",
"ps",
".",
"send",
"(",
"{",
"event",
":",
"'flush'",
"}",
")",
";",
"}"
] | Flush the script cache. | [
"Flush",
"the",
"script",
"cache",
"."
] | eab3df935372724a82a9ad9ba3bca7e6e165e9d1 | https://github.com/redisjs/jsr-script/blob/eab3df935372724a82a9ad9ba3bca7e6e165e9d1/lib/manager.js#L111-L115 | train |
redisjs/jsr-script | lib/manager.js | kill | function kill(req, res) {
if(!this._busy || !this.ps) return res.send(NotBusy);
if(this._busy && this._written) return res.send(Unkillable);
this.ps.removeAllListeners();
this._busy = false;
this._written = false;
function onClose() {
res.send(null, Constants.OK);
// re-spawn for next execution
... | javascript | function kill(req, res) {
if(!this._busy || !this.ps) return res.send(NotBusy);
if(this._busy && this._written) return res.send(Unkillable);
this.ps.removeAllListeners();
this._busy = false;
this._written = false;
function onClose() {
res.send(null, Constants.OK);
// re-spawn for next execution
... | [
"function",
"kill",
"(",
"req",
",",
"res",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_busy",
"||",
"!",
"this",
".",
"ps",
")",
"return",
"res",
".",
"send",
"(",
"NotBusy",
")",
";",
"if",
"(",
"this",
".",
"_busy",
"&&",
"this",
".",
"_written... | Kill a running script. | [
"Kill",
"a",
"running",
"script",
"."
] | eab3df935372724a82a9ad9ba3bca7e6e165e9d1 | https://github.com/redisjs/jsr-script/blob/eab3df935372724a82a9ad9ba3bca7e6e165e9d1/lib/manager.js#L120-L134 | train |
fin-hypergrid/hyper-analytics | example/generateSampleData.js | function() {
var firstName = Math.round((firstNames.length - 1) * randomFunc());
var lastName = Math.round((lastNames.length - 1) * randomFunc());
var pets = Math.round(10 * randomFunc());
var birthyear = 1900 + Math.round(randomFunc() * 114);
var birthmonth = Math.round(randomFu... | javascript | function() {
var firstName = Math.round((firstNames.length - 1) * randomFunc());
var lastName = Math.round((lastNames.length - 1) * randomFunc());
var pets = Math.round(10 * randomFunc());
var birthyear = 1900 + Math.round(randomFunc() * 114);
var birthmonth = Math.round(randomFu... | [
"function",
"(",
")",
"{",
"var",
"firstName",
"=",
"Math",
".",
"round",
"(",
"(",
"firstNames",
".",
"length",
"-",
"1",
")",
"*",
"randomFunc",
"(",
")",
")",
";",
"var",
"lastName",
"=",
"Math",
".",
"round",
"(",
"(",
"lastNames",
".",
"length... | var randomFunc = rnd; | [
"var",
"randomFunc",
"=",
"rnd",
";"
] | 70257bf0d0388d29177ce86192d0d08508b2a22e | https://github.com/fin-hypergrid/hyper-analytics/blob/70257bf0d0388d29177ce86192d0d08508b2a22e/example/generateSampleData.js#L13-L39 | train | |
iopa-io/iopa-http | src/common/incomingParser.js | HTTPParser | function HTTPParser(channelContext, context) {
_classCallCheck(this, HTTPParser);
if (channelContext) {
this._channelContext = channelContext;
channelContext[SERVER.Capabilities][HTTP.CAPABILITY].incoming = [];
channelContext[SERVER.Capabilities][HTTP.CAPABILITY].currentIncoming = null;
}
this.cont... | javascript | function HTTPParser(channelContext, context) {
_classCallCheck(this, HTTPParser);
if (channelContext) {
this._channelContext = channelContext;
channelContext[SERVER.Capabilities][HTTP.CAPABILITY].incoming = [];
channelContext[SERVER.Capabilities][HTTP.CAPABILITY].currentIncoming = null;
}
this.cont... | [
"function",
"HTTPParser",
"(",
"channelContext",
",",
"context",
")",
"{",
"_classCallCheck",
"(",
"this",
",",
"HTTPParser",
")",
";",
"if",
"(",
"channelContext",
")",
"{",
"this",
".",
"_channelContext",
"=",
"channelContext",
";",
"channelContext",
"[",
"S... | IOPA HTTPParser converts inbound HTTP requests and inbound HTTP responses into IOPA Request and Response contexts
@class HTTPParser
@param channelContext (required) the transport context on which to parse the SERVER.RawStream message stream for one or more requests/responses; typically TCP or UDP
@param context (opti... | [
"IOPA",
"HTTPParser",
"converts",
"inbound",
"HTTP",
"requests",
"and",
"inbound",
"HTTP",
"responses",
"into",
"IOPA",
"Request",
"and",
"Response",
"contexts"
] | 7fc01ecdeddbb3fa55e23b9918e176f16f630844 | https://github.com/iopa-io/iopa-http/blob/7fc01ecdeddbb3fa55e23b9918e176f16f630844/src/common/incomingParser.js#L66-L90 | train |
wrote/write | build/index.js | write | async function write(path, data) {
if (!path) throw new Error('No path is given.')
const er = erotic(true)
const ws = createWriteStream(path)
await new Promise((r, j) => {
ws
.on('error', (e) => {
const err = er(e)
j(err)
})
.on('close', r)
.end(data)
})
} | javascript | async function write(path, data) {
if (!path) throw new Error('No path is given.')
const er = erotic(true)
const ws = createWriteStream(path)
await new Promise((r, j) => {
ws
.on('error', (e) => {
const err = er(e)
j(err)
})
.on('close', r)
.end(data)
})
} | [
"async",
"function",
"write",
"(",
"path",
",",
"data",
")",
"{",
"if",
"(",
"!",
"path",
")",
"throw",
"new",
"Error",
"(",
"'No path is given.'",
")",
"const",
"er",
"=",
"erotic",
"(",
"true",
")",
"const",
"ws",
"=",
"createWriteStream",
"(",
"path... | Write a file to the filesystem.
@param {string} path The path of the file to write.
@param {string|Buffer} data The data to write. | [
"Write",
"a",
"file",
"to",
"the",
"filesystem",
"."
] | b665396d791ac48ec57d3485fa2302926c3a9502 | https://github.com/wrote/write/blob/b665396d791ac48ec57d3485fa2302926c3a9502/build/index.js#L9-L22 | train |
redisjs/jsr-server | lib/command/database/zset/zadd.js | validate | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var i
, num;
if((args.length - 1) % 2 !== 0) {
throw new CommandArgLength(cmd);
}
for(i = 1;i < args.length;i += 2) {
num = parseFloat('' + args[i]);
if(isNaN(num)) {
throw InvalidFloat;
... | javascript | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var i
, num;
if((args.length - 1) % 2 !== 0) {
throw new CommandArgLength(cmd);
}
for(i = 1;i < args.length;i += 2) {
num = parseFloat('' + args[i]);
if(isNaN(num)) {
throw InvalidFloat;
... | [
"function",
"validate",
"(",
"cmd",
",",
"args",
",",
"info",
")",
"{",
"AbstractCommand",
".",
"prototype",
".",
"validate",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"var",
"i",
",",
"num",
";",
"if",
"(",
"(",
"args",
".",
"length",
... | Validate the ZADD command. | [
"Validate",
"the",
"ZADD",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/database/zset/zadd.js#L20-L35 | train |
allex-servercore-libs/servicepack | user/creator.js | distinctElements | function distinctElements(a1,a2){
var ret = a1.slice();
a2.forEach(function(a2item){
if(ret.indexOf(a2item)<0){
ret.push(a2item);
}
});
return ret;
} | javascript | function distinctElements(a1,a2){
var ret = a1.slice();
a2.forEach(function(a2item){
if(ret.indexOf(a2item)<0){
ret.push(a2item);
}
});
return ret;
} | [
"function",
"distinctElements",
"(",
"a1",
",",
"a2",
")",
"{",
"var",
"ret",
"=",
"a1",
".",
"slice",
"(",
")",
";",
"a2",
".",
"forEach",
"(",
"function",
"(",
"a2item",
")",
"{",
"if",
"(",
"ret",
".",
"indexOf",
"(",
"a2item",
")",
"<",
"0",
... | User.inherit = UserEntity.inherit; | [
"User",
".",
"inherit",
"=",
"UserEntity",
".",
"inherit",
";"
] | 1b0ce2fe7b9208ab6c8d60d862ceeaf970797d23 | https://github.com/allex-servercore-libs/servicepack/blob/1b0ce2fe7b9208ab6c8d60d862ceeaf970797d23/user/creator.js#L27-L35 | train |
zorojs/zoro-kit-vue | dist/js/router/index.js | stringToRegexp | function stringToRegexp (path, keys, options) {
var tokens = parse(path)
var re = tokensToRegExp(tokens, options)
// Attach keys back to the regexp.
for (var i = 0; i < tokens.length; i++) {
if (typeof tokens[i] !== 'string') {
keys.push(tokens[i])
}
}
return attachKeys(re, keys)
... | javascript | function stringToRegexp (path, keys, options) {
var tokens = parse(path)
var re = tokensToRegExp(tokens, options)
// Attach keys back to the regexp.
for (var i = 0; i < tokens.length; i++) {
if (typeof tokens[i] !== 'string') {
keys.push(tokens[i])
}
}
return attachKeys(re, keys)
... | [
"function",
"stringToRegexp",
"(",
"path",
",",
"keys",
",",
"options",
")",
"{",
"var",
"tokens",
"=",
"parse",
"(",
"path",
")",
"var",
"re",
"=",
"tokensToRegExp",
"(",
"tokens",
",",
"options",
")",
"// Attach keys back to the regexp.",
"for",
"(",
"var"... | Create a path regexp from string input.
@param {string} path
@param {!Array} keys
@param {!Object} options
@return {!RegExp} | [
"Create",
"a",
"path",
"regexp",
"from",
"string",
"input",
"."
] | fe65e25bbdcc7f9c47961112c8709b105528d595 | https://github.com/zorojs/zoro-kit-vue/blob/fe65e25bbdcc7f9c47961112c8709b105528d595/dist/js/router/index.js#L943-L955 | train |
zorojs/zoro-kit-vue | dist/js/router/index.js | looseEqual | function looseEqual (a, b) {
/* eslint-disable eqeqeq */
return a == b || (
isObject(a) && isObject(b)
? JSON.stringify(a) === JSON.stringify(b)
: false
)
/* eslint-enable eqeqeq */
} | javascript | function looseEqual (a, b) {
/* eslint-disable eqeqeq */
return a == b || (
isObject(a) && isObject(b)
? JSON.stringify(a) === JSON.stringify(b)
: false
)
/* eslint-enable eqeqeq */
} | [
"function",
"looseEqual",
"(",
"a",
",",
"b",
")",
"{",
"/* eslint-disable eqeqeq */",
"return",
"a",
"==",
"b",
"||",
"(",
"isObject",
"(",
"a",
")",
"&&",
"isObject",
"(",
"b",
")",
"?",
"JSON",
".",
"stringify",
"(",
"a",
")",
"===",
"JSON",
".",
... | Check if two values are loosely equal - that is,
if they are plain objects, do they have the same shape? | [
"Check",
"if",
"two",
"values",
"are",
"loosely",
"equal",
"-",
"that",
"is",
"if",
"they",
"are",
"plain",
"objects",
"do",
"they",
"have",
"the",
"same",
"shape?"
] | fe65e25bbdcc7f9c47961112c8709b105528d595 | https://github.com/zorojs/zoro-kit-vue/blob/fe65e25bbdcc7f9c47961112c8709b105528d595/dist/js/router/index.js#L2227-L2235 | train |
zorojs/zoro-kit-vue | dist/js/router/index.js | mergeData | function mergeData (to, from) {
var key, toVal, fromVal;
for (key in from) {
toVal = to[key];
fromVal = from[key];
if (!hasOwn(to, key)) {
set(to, key, fromVal);
} else if (isObject(toVal) && isObject(fromVal)) {
mergeData(toVal, fromVal);
}
}
return to
} | javascript | function mergeData (to, from) {
var key, toVal, fromVal;
for (key in from) {
toVal = to[key];
fromVal = from[key];
if (!hasOwn(to, key)) {
set(to, key, fromVal);
} else if (isObject(toVal) && isObject(fromVal)) {
mergeData(toVal, fromVal);
}
}
return to
} | [
"function",
"mergeData",
"(",
"to",
",",
"from",
")",
"{",
"var",
"key",
",",
"toVal",
",",
"fromVal",
";",
"for",
"(",
"key",
"in",
"from",
")",
"{",
"toVal",
"=",
"to",
"[",
"key",
"]",
";",
"fromVal",
"=",
"from",
"[",
"key",
"]",
";",
"if",... | Helper that recursively merges two data objects together. | [
"Helper",
"that",
"recursively",
"merges",
"two",
"data",
"objects",
"together",
"."
] | fe65e25bbdcc7f9c47961112c8709b105528d595 | https://github.com/zorojs/zoro-kit-vue/blob/fe65e25bbdcc7f9c47961112c8709b105528d595/dist/js/router/index.js#L4676-L4688 | train |
zorojs/zoro-kit-vue | dist/js/router/index.js | normalizeComponents | function normalizeComponents (options) {
if (options.components) {
var components = options.components;
var def;
for (var key in components) {
var lower = key.toLowerCase();
if (isBuiltInTag(lower) || config.isReservedTag(lower)) {
"development" !== 'production' && warn(
... | javascript | function normalizeComponents (options) {
if (options.components) {
var components = options.components;
var def;
for (var key in components) {
var lower = key.toLowerCase();
if (isBuiltInTag(lower) || config.isReservedTag(lower)) {
"development" !== 'production' && warn(
... | [
"function",
"normalizeComponents",
"(",
"options",
")",
"{",
"if",
"(",
"options",
".",
"components",
")",
"{",
"var",
"components",
"=",
"options",
".",
"components",
";",
"var",
"def",
";",
"for",
"(",
"var",
"key",
"in",
"components",
")",
"{",
"var",... | Make sure component options get converted to actual
constructors. | [
"Make",
"sure",
"component",
"options",
"get",
"converted",
"to",
"actual",
"constructors",
"."
] | fe65e25bbdcc7f9c47961112c8709b105528d595 | https://github.com/zorojs/zoro-kit-vue/blob/fe65e25bbdcc7f9c47961112c8709b105528d595/dist/js/router/index.js#L4834-L4853 | train |
zorojs/zoro-kit-vue | dist/js/router/index.js | updateDOMListeners | function updateDOMListeners (oldVnode, vnode) {
if (!oldVnode.data.on && !vnode.data.on) {
return
}
var on = vnode.data.on || {};
var oldOn = oldVnode.data.on || {};
var add = vnode.elm._v_add || (vnode.elm._v_add = function (event, handler, capture) {
vnode.elm.addEventListener(event, handler,... | javascript | function updateDOMListeners (oldVnode, vnode) {
if (!oldVnode.data.on && !vnode.data.on) {
return
}
var on = vnode.data.on || {};
var oldOn = oldVnode.data.on || {};
var add = vnode.elm._v_add || (vnode.elm._v_add = function (event, handler, capture) {
vnode.elm.addEventListener(event, handler,... | [
"function",
"updateDOMListeners",
"(",
"oldVnode",
",",
"vnode",
")",
"{",
"if",
"(",
"!",
"oldVnode",
".",
"data",
".",
"on",
"&&",
"!",
"vnode",
".",
"data",
".",
"on",
")",
"{",
"return",
"}",
"var",
"on",
"=",
"vnode",
".",
"data",
".",
"on",
... | skip type checking this file because we need to attach private properties to elements | [
"skip",
"type",
"checking",
"this",
"file",
"because",
"we",
"need",
"to",
"attach",
"private",
"properties",
"to",
"elements"
] | fe65e25bbdcc7f9c47961112c8709b105528d595 | https://github.com/zorojs/zoro-kit-vue/blob/fe65e25bbdcc7f9c47961112c8709b105528d595/dist/js/router/index.js#L6488-L6501 | train |
zorojs/zoro-kit-vue | dist/js/router/index.js | removeClass | function removeClass (el, cls) {
/* istanbul ignore else */
if (el.classList) {
if (cls.indexOf(' ') > -1) {
cls.split(/\s+/).forEach(function (c) { return el.classList.remove(c); });
} else {
el.classList.remove(cls);
}
} else {
var cur = ' ' + el.getAttribute('class') + ' ';... | javascript | function removeClass (el, cls) {
/* istanbul ignore else */
if (el.classList) {
if (cls.indexOf(' ') > -1) {
cls.split(/\s+/).forEach(function (c) { return el.classList.remove(c); });
} else {
el.classList.remove(cls);
}
} else {
var cur = ' ' + el.getAttribute('class') + ' ';... | [
"function",
"removeClass",
"(",
"el",
",",
"cls",
")",
"{",
"/* istanbul ignore else */",
"if",
"(",
"el",
".",
"classList",
")",
"{",
"if",
"(",
"cls",
".",
"indexOf",
"(",
"' '",
")",
">",
"-",
"1",
")",
"{",
"cls",
".",
"split",
"(",
"/",
"\\s+"... | Remove class with compatibility for SVG since classList is not supported on
SVG elements in IE | [
"Remove",
"class",
"with",
"compatibility",
"for",
"SVG",
"since",
"classList",
"is",
"not",
"supported",
"on",
"SVG",
"elements",
"in",
"IE"
] | fe65e25bbdcc7f9c47961112c8709b105528d595 | https://github.com/zorojs/zoro-kit-vue/blob/fe65e25bbdcc7f9c47961112c8709b105528d595/dist/js/router/index.js#L6649-L6665 | train |
vesln/printr | lib/printr.js | Printr | function Printr(options) {
options = options || {};
options.out = options.out || process.stdout;
options.err = options.err || process.stderr;
options.prefix = options.prefix || '';
this.options = options;
} | javascript | function Printr(options) {
options = options || {};
options.out = options.out || process.stdout;
options.err = options.err || process.stderr;
options.prefix = options.prefix || '';
this.options = options;
} | [
"function",
"Printr",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"options",
".",
"out",
"=",
"options",
".",
"out",
"||",
"process",
".",
"stdout",
";",
"options",
".",
"err",
"=",
"options",
".",
"err",
"||",
"process"... | Printr - tiny print util.
Options:
- `out` out stream, default: process.stdout
- `err` err stream, default: process.stderr
- `prefix` prefix to append for `Message#print`, default: ''
@param {Object} options
@constructor | [
"Printr",
"-",
"tiny",
"print",
"util",
"."
] | 09f7e61b313bbb5991071d54f7a5fd38a9c4f81f | https://github.com/vesln/printr/blob/09f7e61b313bbb5991071d54f7a5fd38a9c4f81f/lib/printr.js#L19-L25 | train |
chrisenytc/livi18n | lib/client/livi18n.js | function (key, obj) {
//Split key
var p = key.split('.');
//Loop and save object state
for (var i = 0, len = p.length; i < len - 1; i++) {
obj = obj[p[i]];
}
//Return object value
return obj[p[len - 1]];
} | javascript | function (key, obj) {
//Split key
var p = key.split('.');
//Loop and save object state
for (var i = 0, len = p.length; i < len - 1; i++) {
obj = obj[p[i]];
}
//Return object value
return obj[p[len - 1]];
} | [
"function",
"(",
"key",
",",
"obj",
")",
"{",
"//Split key",
"var",
"p",
"=",
"key",
".",
"split",
"(",
"'.'",
")",
";",
"//Loop and save object state",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"p",
".",
"length",
";",
"i",
"<",
"len",
... | Get Data Property | [
"Get",
"Data",
"Property"
] | cff846d533f2db9162013dd572d18ffd8fa38340 | https://github.com/chrisenytc/livi18n/blob/cff846d533f2db9162013dd572d18ffd8fa38340/lib/client/livi18n.js#L217-L226 | train | |
chrisenytc/livi18n | lib/client/livi18n.js | function () {
//Init Var
var length = 0;
//Loop filenames
$.each(config.data, function () {
length++;
});
//If value of length is equal to filenames length,
// return true, if not, return false
if (length === config.filenames.length) {
return true;
} else {
return f... | javascript | function () {
//Init Var
var length = 0;
//Loop filenames
$.each(config.data, function () {
length++;
});
//If value of length is equal to filenames length,
// return true, if not, return false
if (length === config.filenames.length) {
return true;
} else {
return f... | [
"function",
"(",
")",
"{",
"//Init Var",
"var",
"length",
"=",
"0",
";",
"//Loop filenames",
"$",
".",
"each",
"(",
"config",
".",
"data",
",",
"function",
"(",
")",
"{",
"length",
"++",
";",
"}",
")",
";",
"//If value of length is equal to filenames length,... | Check if dataStorage is loaded | [
"Check",
"if",
"dataStorage",
"is",
"loaded"
] | cff846d533f2db9162013dd572d18ffd8fa38340 | https://github.com/chrisenytc/livi18n/blob/cff846d533f2db9162013dd572d18ffd8fa38340/lib/client/livi18n.js#L287-L301 | train | |
chrisenytc/livi18n | lib/client/livi18n.js | function (key) {
var string = key.split('.');
string.shift(0);
var value = string.join('.');
return value;
} | javascript | function (key) {
var string = key.split('.');
string.shift(0);
var value = string.join('.');
return value;
} | [
"function",
"(",
"key",
")",
"{",
"var",
"string",
"=",
"key",
".",
"split",
"(",
"'.'",
")",
";",
"string",
".",
"shift",
"(",
"0",
")",
";",
"var",
"value",
"=",
"string",
".",
"join",
"(",
"'.'",
")",
";",
"return",
"value",
";",
"}"
] | Get Keyname in Key | [
"Get",
"Keyname",
"in",
"Key"
] | cff846d533f2db9162013dd572d18ffd8fa38340 | https://github.com/chrisenytc/livi18n/blob/cff846d533f2db9162013dd572d18ffd8fa38340/lib/client/livi18n.js#L308-L313 | train | |
the-terribles/evergreen | lib/errors.js | DependenciesNotResolvedError | function DependenciesNotResolvedError(dependencies){
superError.call(
this,
'DependenciesNotResolvedError',
util.format('Dependencies cannot be resolved: %s', dependencies.join(','))
);
this.dependencies = dependencies;
} | javascript | function DependenciesNotResolvedError(dependencies){
superError.call(
this,
'DependenciesNotResolvedError',
util.format('Dependencies cannot be resolved: %s', dependencies.join(','))
);
this.dependencies = dependencies;
} | [
"function",
"DependenciesNotResolvedError",
"(",
"dependencies",
")",
"{",
"superError",
".",
"call",
"(",
"this",
",",
"'DependenciesNotResolvedError'",
",",
"util",
".",
"format",
"(",
"'Dependencies cannot be resolved: %s'",
",",
"dependencies",
".",
"join",
"(",
"... | Dependencies in the Graph could not be resolved.
@param dependencies {Array} Dependencies that could not be resolved.
@constructor | [
"Dependencies",
"in",
"the",
"Graph",
"could",
"not",
"be",
"resolved",
"."
] | c1adaea1ce825727c5c5ed75d858e2f0d22657e2 | https://github.com/the-terribles/evergreen/blob/c1adaea1ce825727c5c5ed75d858e2f0d22657e2/lib/errors.js#L22-L30 | train |
the-terribles/evergreen | lib/errors.js | PathNotFoundError | function PathNotFoundError(path, sympath){
superError.call(
this,
'PathNotFoundError',
util.format('Path was not found in the tree: %s', sympath)
);
this.arrayPath = path;
this.sympath = sympath;
} | javascript | function PathNotFoundError(path, sympath){
superError.call(
this,
'PathNotFoundError',
util.format('Path was not found in the tree: %s', sympath)
);
this.arrayPath = path;
this.sympath = sympath;
} | [
"function",
"PathNotFoundError",
"(",
"path",
",",
"sympath",
")",
"{",
"superError",
".",
"call",
"(",
"this",
",",
"'PathNotFoundError'",
",",
"util",
".",
"format",
"(",
"'Path was not found in the tree: %s'",
",",
"sympath",
")",
")",
";",
"this",
".",
"ar... | The Path does not exist in the tree.
@param path {Array} Path that was not found
@param sympath {String} Symbolic path representation.
@constructor | [
"The",
"Path",
"does",
"not",
"exist",
"in",
"the",
"tree",
"."
] | c1adaea1ce825727c5c5ed75d858e2f0d22657e2 | https://github.com/the-terribles/evergreen/blob/c1adaea1ce825727c5c5ed75d858e2f0d22657e2/lib/errors.js#L61-L70 | train |
the-terribles/evergreen | lib/errors.js | CannotBuildDependencyGraphError | function CannotBuildDependencyGraphError(nestedError){
this.name = 'CannotBuildDependencyGraphError';
this.message = nestedError.message;
this.stack = nestedError.stack;
this.nestedError = nestedError;
} | javascript | function CannotBuildDependencyGraphError(nestedError){
this.name = 'CannotBuildDependencyGraphError';
this.message = nestedError.message;
this.stack = nestedError.stack;
this.nestedError = nestedError;
} | [
"function",
"CannotBuildDependencyGraphError",
"(",
"nestedError",
")",
"{",
"this",
".",
"name",
"=",
"'CannotBuildDependencyGraphError'",
";",
"this",
".",
"message",
"=",
"nestedError",
".",
"message",
";",
"this",
".",
"stack",
"=",
"nestedError",
".",
"stack"... | Wraps errors returned from Topo representing a failure to build the dependency graph.
@param nestedError {Error} error encountered topo sorting the dependency graph.
@constructor | [
"Wraps",
"errors",
"returned",
"from",
"Topo",
"representing",
"a",
"failure",
"to",
"build",
"the",
"dependency",
"graph",
"."
] | c1adaea1ce825727c5c5ed75d858e2f0d22657e2 | https://github.com/the-terribles/evergreen/blob/c1adaea1ce825727c5c5ed75d858e2f0d22657e2/lib/errors.js#L138-L144 | train |
the-terribles/evergreen | lib/errors.js | JavaScriptFileLoadError | function JavaScriptFileLoadError(file, nestedError){
nestedError = nestedError || null;
var message = (nestedError)?
util.format('"%s" failed to load as JavaScript; VM error: %s', file, nestedError.toString()) :
util.format('"%s" failed to load as JavaScript.', file);
superError.call(this, 'Java... | javascript | function JavaScriptFileLoadError(file, nestedError){
nestedError = nestedError || null;
var message = (nestedError)?
util.format('"%s" failed to load as JavaScript; VM error: %s', file, nestedError.toString()) :
util.format('"%s" failed to load as JavaScript.', file);
superError.call(this, 'Java... | [
"function",
"JavaScriptFileLoadError",
"(",
"file",
",",
"nestedError",
")",
"{",
"nestedError",
"=",
"nestedError",
"||",
"null",
";",
"var",
"message",
"=",
"(",
"nestedError",
")",
"?",
"util",
".",
"format",
"(",
"'\"%s\" failed to load as JavaScript; VM error: ... | Failed to load the JavaScript file.
@param file {String} path to file
@param nestedError {Error} nested error from VM.
@constructor | [
"Failed",
"to",
"load",
"the",
"JavaScript",
"file",
"."
] | c1adaea1ce825727c5c5ed75d858e2f0d22657e2 | https://github.com/the-terribles/evergreen/blob/c1adaea1ce825727c5c5ed75d858e2f0d22657e2/lib/errors.js#L225-L236 | train |
the-terribles/evergreen | lib/errors.js | HttpRequestError | function HttpRequestError(nestedError, status, body){
nestedError = nestedError || null;
status = status || -1;
body = body || null;
superError.call(
this,
'HttpRequestError',
util.format('An error [%s] occurred requesting content from an HTTP source: %s', status, nestedError || body)
);
this... | javascript | function HttpRequestError(nestedError, status, body){
nestedError = nestedError || null;
status = status || -1;
body = body || null;
superError.call(
this,
'HttpRequestError',
util.format('An error [%s] occurred requesting content from an HTTP source: %s', status, nestedError || body)
);
this... | [
"function",
"HttpRequestError",
"(",
"nestedError",
",",
"status",
",",
"body",
")",
"{",
"nestedError",
"=",
"nestedError",
"||",
"null",
";",
"status",
"=",
"status",
"||",
"-",
"1",
";",
"body",
"=",
"body",
"||",
"null",
";",
"superError",
".",
"call... | Wraps an HTTP Request Error coming from an HTTP client library.
@param status {int} status code
@param body {String|Object} body of the response
@param nestedError {Error} error thrown by the client library.
@constructor | [
"Wraps",
"an",
"HTTP",
"Request",
"Error",
"coming",
"from",
"an",
"HTTP",
"client",
"library",
"."
] | c1adaea1ce825727c5c5ed75d858e2f0d22657e2 | https://github.com/the-terribles/evergreen/blob/c1adaea1ce825727c5c5ed75d858e2f0d22657e2/lib/errors.js#L249-L264 | train |
the-terribles/evergreen | lib/errors.js | CannotParseTreeError | function CannotParseTreeError(errors){
superError.call(
this,
'CannotParseTreeError',
util.format('Could not parse the tree for metadata; errors: %s', JSON.stringify(errors))
);
this.errors = errors;
} | javascript | function CannotParseTreeError(errors){
superError.call(
this,
'CannotParseTreeError',
util.format('Could not parse the tree for metadata; errors: %s', JSON.stringify(errors))
);
this.errors = errors;
} | [
"function",
"CannotParseTreeError",
"(",
"errors",
")",
"{",
"superError",
".",
"call",
"(",
"this",
",",
"'CannotParseTreeError'",
",",
"util",
".",
"format",
"(",
"'Could not parse the tree for metadata; errors: %s'",
",",
"JSON",
".",
"stringify",
"(",
"errors",
... | Thrown if errors occurred in parsing the tree.
@param errors {Array}
@constructor | [
"Thrown",
"if",
"errors",
"occurred",
"in",
"parsing",
"the",
"tree",
"."
] | c1adaea1ce825727c5c5ed75d858e2f0d22657e2 | https://github.com/the-terribles/evergreen/blob/c1adaea1ce825727c5c5ed75d858e2f0d22657e2/lib/errors.js#L275-L284 | train |
integreat-io/great-uri-template | lib/filters/prepend.js | prepend | function prepend (value, string) {
if (
value === null || value === undefined || value === '' ||
string === null || string === undefined
) {
return value
}
return string + value
} | javascript | function prepend (value, string) {
if (
value === null || value === undefined || value === '' ||
string === null || string === undefined
) {
return value
}
return string + value
} | [
"function",
"prepend",
"(",
"value",
",",
"string",
")",
"{",
"if",
"(",
"value",
"===",
"null",
"||",
"value",
"===",
"undefined",
"||",
"value",
"===",
"''",
"||",
"string",
"===",
"null",
"||",
"string",
"===",
"undefined",
")",
"{",
"return",
"valu... | Prepend the given string to the value, unless the value is empty.
@param {string} value - The value to prepend to
@returns {string} The prepended result | [
"Prepend",
"the",
"given",
"string",
"to",
"the",
"value",
"unless",
"the",
"value",
"is",
"empty",
"."
] | 0e896ead0567737cf31a4a8b76a26cfa6ce60759 | https://github.com/integreat-io/great-uri-template/blob/0e896ead0567737cf31a4a8b76a26cfa6ce60759/lib/filters/prepend.js#L6-L14 | train |
jonschlinkert/enable-travis | index.js | enable | function enable(options, cb) {
options = options || {};
var travis = new Travis({
version: '2.0.0',
// user-agent needs to start with "Travis"
// https://github.com/travis-ci/travis-ci/issues/5649
headers: {'user-agent': 'Travis: jonschlinkert/enable-travis'}
});
travis.auth.github.post({
g... | javascript | function enable(options, cb) {
options = options || {};
var travis = new Travis({
version: '2.0.0',
// user-agent needs to start with "Travis"
// https://github.com/travis-ci/travis-ci/issues/5649
headers: {'user-agent': 'Travis: jonschlinkert/enable-travis'}
});
travis.auth.github.post({
g... | [
"function",
"enable",
"(",
"options",
",",
"cb",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"travis",
"=",
"new",
"Travis",
"(",
"{",
"version",
":",
"'2.0.0'",
",",
"// user-agent needs to start with \"Travis\"",
"// https://github.com/tra... | Enable a travis project | [
"Enable",
"a",
"travis",
"project"
] | 9f35e788e294dfc6879781ef8e62f74ea355500d | https://github.com/jonschlinkert/enable-travis/blob/9f35e788e294dfc6879781ef8e62f74ea355500d/index.js#L22-L56 | train |
Nazariglez/perenquen | lib/pixi/src/filters/color/ColorStepFilter.js | ColorStepFilter | function ColorStepFilter()
{
core.AbstractFilter.call(this,
// vertex shader
null,
// fragment shader
fs.readFileSync(__dirname + '/colorStep.frag', 'utf8'),
// custom uniforms
{
step: { type: '1f', value: 5 }
}
);
} | javascript | function ColorStepFilter()
{
core.AbstractFilter.call(this,
// vertex shader
null,
// fragment shader
fs.readFileSync(__dirname + '/colorStep.frag', 'utf8'),
// custom uniforms
{
step: { type: '1f', value: 5 }
}
);
} | [
"function",
"ColorStepFilter",
"(",
")",
"{",
"core",
".",
"AbstractFilter",
".",
"call",
"(",
"this",
",",
"// vertex shader",
"null",
",",
"// fragment shader",
"fs",
".",
"readFileSync",
"(",
"__dirname",
"+",
"'/colorStep.frag'",
",",
"'utf8'",
")",
",",
"... | This lowers the color depth of your image by the given amount, producing an image with a smaller palette.
@class
@extends AbstractFilter
@memberof PIXI.filters | [
"This",
"lowers",
"the",
"color",
"depth",
"of",
"your",
"image",
"by",
"the",
"given",
"amount",
"producing",
"an",
"image",
"with",
"a",
"smaller",
"palette",
"."
] | e023964d05afeefebdcac4e2044819fdfa3899ae | https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/filters/color/ColorStepFilter.js#L12-L24 | train |
wavesoft/jbb-profile-three | lib/helpers/MD2CharacterLoader.js | function(config, onload, onprogress, onerror) {
var character = new THREE.MD2Character();
character.onLoadComplete = function() {
if (onload) onload( character );
};
character.loadParts( config );
} | javascript | function(config, onload, onprogress, onerror) {
var character = new THREE.MD2Character();
character.onLoadComplete = function() {
if (onload) onload( character );
};
character.loadParts( config );
} | [
"function",
"(",
"config",
",",
"onload",
",",
"onprogress",
",",
"onerror",
")",
"{",
"var",
"character",
"=",
"new",
"THREE",
".",
"MD2Character",
"(",
")",
";",
"character",
".",
"onLoadComplete",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"onload",
... | Load an MD2 Character with the config provided | [
"Load",
"an",
"MD2",
"Character",
"with",
"the",
"config",
"provided"
] | 8539cfbb2d04b67999eee6e530fcaf03083e0e04 | https://github.com/wavesoft/jbb-profile-three/blob/8539cfbb2d04b67999eee6e530fcaf03083e0e04/lib/helpers/MD2CharacterLoader.js#L16-L26 | train | |
derdesign/protos | drivers/postgres.js | PostgreSQL | function PostgreSQL(config) {
var self = this;
config = protos.extend({
host: 'localhost',
port: 5432
}, config);
this.className = this.constructor.name;
this.config = config;
// Set client
this.client = new Client(config);
// Connect client
this.client.connect();
// Assign stor... | javascript | function PostgreSQL(config) {
var self = this;
config = protos.extend({
host: 'localhost',
port: 5432
}, config);
this.className = this.constructor.name;
this.config = config;
// Set client
this.client = new Client(config);
// Connect client
this.client.connect();
// Assign stor... | [
"function",
"PostgreSQL",
"(",
"config",
")",
"{",
"var",
"self",
"=",
"this",
";",
"config",
"=",
"protos",
".",
"extend",
"(",
"{",
"host",
":",
"'localhost'",
",",
"port",
":",
"5432",
"}",
",",
"config",
")",
";",
"this",
".",
"className",
"=",
... | PostgreSQL Driver class
Driver configuration
config: {
host: 'localhost',
port: 5432,
user: 'db_user',
password: 'db_password',
database: 'db_name',
storage: 'redis'
}
@class PostgreSQL
@extends Driver
@constructor
@param {object} app Application instance
@param {object} config Driver configuration | [
"PostgreSQL",
"Driver",
"class"
] | 0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9 | https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/drivers/postgres.js#L31-L63 | train |
Jomint/jostack | lib/index.js | init | function init(options) {
var fs = require('fs');
var path = require('path');
var rootdir = path.dirname(require.main);
var options = options || {
config: require(path.join(rootdir, 'config.json')),
root: rootdir,
callback: function (noop) {}
};
var def = {};
function... | javascript | function init(options) {
var fs = require('fs');
var path = require('path');
var rootdir = path.dirname(require.main);
var options = options || {
config: require(path.join(rootdir, 'config.json')),
root: rootdir,
callback: function (noop) {}
};
var def = {};
function... | [
"function",
"init",
"(",
"options",
")",
"{",
"var",
"fs",
"=",
"require",
"(",
"'fs'",
")",
";",
"var",
"path",
"=",
"require",
"(",
"'path'",
")",
";",
"var",
"rootdir",
"=",
"path",
".",
"dirname",
"(",
"require",
".",
"main",
")",
";",
"var",
... | Node process entry
@author - Mark Williams
Entry point for node process. All bootstrapping activity is handled
by bootstrapping process in the loader created by factory | [
"Node",
"process",
"entry"
] | 6ab3bb8f44cf275a142b7a07d9bfba67f25f5af7 | https://github.com/Jomint/jostack/blob/6ab3bb8f44cf275a142b7a07d9bfba67f25f5af7/lib/index.js#L9-L63 | train |
Frijol/tessel-button | index.js | Button | function Button (hardware, callback) {
var self = this;
// Set hardware connection of the object
self.hardware = hardware;
// Object properties
self.delay = 100;
self.pressed = false;
// Begin listening for events
self.hardware.on('fall', function () {
self._press();
});
self.hardware.on('ri... | javascript | function Button (hardware, callback) {
var self = this;
// Set hardware connection of the object
self.hardware = hardware;
// Object properties
self.delay = 100;
self.pressed = false;
// Begin listening for events
self.hardware.on('fall', function () {
self._press();
});
self.hardware.on('ri... | [
"function",
"Button",
"(",
"hardware",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// Set hardware connection of the object",
"self",
".",
"hardware",
"=",
"hardware",
";",
"// Object properties",
"self",
".",
"delay",
"=",
"100",
";",
"self",
... | Constructor function to instantiate the hardware object | [
"Constructor",
"function",
"to",
"instantiate",
"the",
"hardware",
"object"
] | 084f1d81a3ffde2a243edc1e5159cedb531f28a4 | https://github.com/Frijol/tessel-button/blob/084f1d81a3ffde2a243edc1e5159cedb531f28a4/index.js#L6-L42 | train |
Wizcorp/component-hint | lib/cli.js | formatOptionStrings | function formatOptionStrings(options, width) {
var totalWidth = (width < process.stdout.columns) ? width : process.stdout.columns;
var paddingWidth = cliOptions.largestOptionLength() + 6;
var stringWidth = totalWidth - paddingWidth;
if (stringWidth <= 0) {
return;
}
var paddingString = '\n' + (new Array(paddin... | javascript | function formatOptionStrings(options, width) {
var totalWidth = (width < process.stdout.columns) ? width : process.stdout.columns;
var paddingWidth = cliOptions.largestOptionLength() + 6;
var stringWidth = totalWidth - paddingWidth;
if (stringWidth <= 0) {
return;
}
var paddingString = '\n' + (new Array(paddin... | [
"function",
"formatOptionStrings",
"(",
"options",
",",
"width",
")",
"{",
"var",
"totalWidth",
"=",
"(",
"width",
"<",
"process",
".",
"stdout",
".",
"columns",
")",
"?",
"width",
":",
"process",
".",
"stdout",
".",
"columns",
";",
"var",
"paddingWidth",
... | Function which re-formats commander option descriptions to have correct new lines and padding.
This makes the output a whole lot cleaner with long description strings, and takes terminal
window width into consideration.
@param {Array} options - options array from commander object
@param {Integer} width - maximum width... | [
"Function",
"which",
"re",
"-",
"formats",
"commander",
"option",
"descriptions",
"to",
"have",
"correct",
"new",
"lines",
"and",
"padding",
".",
"This",
"makes",
"the",
"output",
"a",
"whole",
"lot",
"cleaner",
"with",
"long",
"description",
"strings",
"and",... | ccd314a9af5dc5b7cb24dc06227c4b95f2034b19 | https://github.com/Wizcorp/component-hint/blob/ccd314a9af5dc5b7cb24dc06227c4b95f2034b19/lib/cli.js#L19-L57 | train |
Wizcorp/component-hint | lib/cli.js | setupCliObject | function setupCliObject(argv) {
// Set cli options
cliOptions
.version(packageJson.version)
.usage('[options] <component_path ...>')
.option('-v, --verbose',
'Be verbose during tests. (cannot be used with --quiet or --silent)')
.option('-q, --quiet',
'Display only the final outcome.')
.option('-s, --s... | javascript | function setupCliObject(argv) {
// Set cli options
cliOptions
.version(packageJson.version)
.usage('[options] <component_path ...>')
.option('-v, --verbose',
'Be verbose during tests. (cannot be used with --quiet or --silent)')
.option('-q, --quiet',
'Display only the final outcome.')
.option('-s, --s... | [
"function",
"setupCliObject",
"(",
"argv",
")",
"{",
"// Set cli options",
"cliOptions",
".",
"version",
"(",
"packageJson",
".",
"version",
")",
".",
"usage",
"(",
"'[options] <component_path ...>'",
")",
".",
"option",
"(",
"'-v, --verbose'",
",",
"'Be verbose dur... | Function which sets up the commander object with all of our options and customisations.
@param {Array} argv
@returns {undefined} | [
"Function",
"which",
"sets",
"up",
"the",
"commander",
"object",
"with",
"all",
"of",
"our",
"options",
"and",
"customisations",
"."
] | ccd314a9af5dc5b7cb24dc06227c4b95f2034b19 | https://github.com/Wizcorp/component-hint/blob/ccd314a9af5dc5b7cb24dc06227c4b95f2034b19/lib/cli.js#L66-L111 | train |
Wizcorp/component-hint | lib/cli.js | ensurePathsExist | function ensurePathsExist(pathsList, cb) {
async.eachLimit(pathsList, 10, function (pathItem, callback) {
var absolutePath = path.resolve(pathItem);
fs.stat(absolutePath, function (error, stats) {
if (error) {
return callback(new Error('Path does not exist: ' + absolutePath));
}
if (!stats.isDirector... | javascript | function ensurePathsExist(pathsList, cb) {
async.eachLimit(pathsList, 10, function (pathItem, callback) {
var absolutePath = path.resolve(pathItem);
fs.stat(absolutePath, function (error, stats) {
if (error) {
return callback(new Error('Path does not exist: ' + absolutePath));
}
if (!stats.isDirector... | [
"function",
"ensurePathsExist",
"(",
"pathsList",
",",
"cb",
")",
"{",
"async",
".",
"eachLimit",
"(",
"pathsList",
",",
"10",
",",
"function",
"(",
"pathItem",
",",
"callback",
")",
"{",
"var",
"absolutePath",
"=",
"path",
".",
"resolve",
"(",
"pathItem",... | Function which esures all given paths exist. If not it will return an error via the callback
provided.
@param {Array} pathsList
@param {Function} cb
@returns {undefined} | [
"Function",
"which",
"esures",
"all",
"given",
"paths",
"exist",
".",
"If",
"not",
"it",
"will",
"return",
"an",
"error",
"via",
"the",
"callback",
"provided",
"."
] | ccd314a9af5dc5b7cb24dc06227c4b95f2034b19 | https://github.com/Wizcorp/component-hint/blob/ccd314a9af5dc5b7cb24dc06227c4b95f2034b19/lib/cli.js#L122-L137 | train |
quartzjer/telehash-udp4 | index.js | createSocket | function createSocket(type, receive)
{
try{ // newer
var sock = dgram.createSocket({ type: type, reuseAddr: true }, receive);
}catch(E){ // older
var sock = dgram.createSocket(type, receive);
}
return sock;
} | javascript | function createSocket(type, receive)
{
try{ // newer
var sock = dgram.createSocket({ type: type, reuseAddr: true }, receive);
}catch(E){ // older
var sock = dgram.createSocket(type, receive);
}
return sock;
} | [
"function",
"createSocket",
"(",
"type",
",",
"receive",
")",
"{",
"try",
"{",
"// newer",
"var",
"sock",
"=",
"dgram",
".",
"createSocket",
"(",
"{",
"type",
":",
"type",
",",
"reuseAddr",
":",
"true",
"}",
",",
"receive",
")",
";",
"}",
"catch",
"(... | compatibility wrapper between node v0.10 v0.12 and iojs | [
"compatibility",
"wrapper",
"between",
"node",
"v0",
".",
"10",
"v0",
".",
"12",
"and",
"iojs"
] | d68277335c698e65db3bdd5191d7d3e6dc64076b | https://github.com/quartzjer/telehash-udp4/blob/d68277335c698e65db3bdd5191d7d3e6dc64076b/index.js#L11-L19 | train |
quartzjer/telehash-udp4 | index.js | receive | function receive(msg, rinfo){
var packet = lob.decloak(msg);
if(!packet) packet = lob.decode(msg); // accept un-encrypted discovery broadcast hints
if(!packet) return mesh.log.info('dropping invalid packet from',rinfo,msg.toString('hex'));
tp.pipe(false, {type:'udp4',ip:rinfo.address,port:rinfo.port}, f... | javascript | function receive(msg, rinfo){
var packet = lob.decloak(msg);
if(!packet) packet = lob.decode(msg); // accept un-encrypted discovery broadcast hints
if(!packet) return mesh.log.info('dropping invalid packet from',rinfo,msg.toString('hex'));
tp.pipe(false, {type:'udp4',ip:rinfo.address,port:rinfo.port}, f... | [
"function",
"receive",
"(",
"msg",
",",
"rinfo",
")",
"{",
"var",
"packet",
"=",
"lob",
".",
"decloak",
"(",
"msg",
")",
";",
"if",
"(",
"!",
"packet",
")",
"packet",
"=",
"lob",
".",
"decode",
"(",
"msg",
")",
";",
"// accept un-encrypted discovery br... | generic handler to receive udp datagrams | [
"generic",
"handler",
"to",
"receive",
"udp",
"datagrams"
] | d68277335c698e65db3bdd5191d7d3e6dc64076b | https://github.com/quartzjer/telehash-udp4/blob/d68277335c698e65db3bdd5191d7d3e6dc64076b/index.js#L30-L37 | train |
Knorcedger/apier-authenticator | index.js | findById | function findById(schemaName, id) {
return new Promise(function(resolve, reject) {
var Model = db.mongoose.model(schemaName);
Model
.findById(id)
.exec(function(error, result) {
if (error) {
reqlog.error('internal server error', error);
reject(error);
} else {
resolve(result || 'notFound');
... | javascript | function findById(schemaName, id) {
return new Promise(function(resolve, reject) {
var Model = db.mongoose.model(schemaName);
Model
.findById(id)
.exec(function(error, result) {
if (error) {
reqlog.error('internal server error', error);
reject(error);
} else {
resolve(result || 'notFound');
... | [
"function",
"findById",
"(",
"schemaName",
",",
"id",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"var",
"Model",
"=",
"db",
".",
"mongoose",
".",
"model",
"(",
"schemaName",
")",
";",
"Model",
".",
... | custom findById that has no limitations on the data it can load
@method findById
@param {string} schemaName The schema to load
@param {string} id The Object id to search with
@return {Promise} Just a promise :p | [
"custom",
"findById",
"that",
"has",
"no",
"limitations",
"on",
"the",
"data",
"it",
"can",
"load"
] | 852a1070067274af6b6c4a3c11c49992c5caf5a9 | https://github.com/Knorcedger/apier-authenticator/blob/852a1070067274af6b6c4a3c11c49992c5caf5a9/index.js#L47-L62 | train |
andrewscwei/requiem | src/helpers/getInstanceNameFromElement.js | getInstanceNameFromElement | function getInstanceNameFromElement(element) {
let nameFromName = getAttribute(element, 'name');
if (nameFromName !== null && nameFromName !== undefined && nameFromName !== '')
return nameFromName;
else
return null;
} | javascript | function getInstanceNameFromElement(element) {
let nameFromName = getAttribute(element, 'name');
if (nameFromName !== null && nameFromName !== undefined && nameFromName !== '')
return nameFromName;
else
return null;
} | [
"function",
"getInstanceNameFromElement",
"(",
"element",
")",
"{",
"let",
"nameFromName",
"=",
"getAttribute",
"(",
"element",
",",
"'name'",
")",
";",
"if",
"(",
"nameFromName",
"!==",
"null",
"&&",
"nameFromName",
"!==",
"undefined",
"&&",
"nameFromName",
"!=... | Gets the instance name from a DOM element.
@param {Node} element - The DOM element.
@return {string} The instance name.
@alias module:requiem~helpers.getInstanceNameFromElement | [
"Gets",
"the",
"instance",
"name",
"from",
"a",
"DOM",
"element",
"."
] | c4182bfffc9841c6de5718f689ad3c2060511777 | https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/helpers/getInstanceNameFromElement.js#L16-L23 | train |
materliu/grunt-localhosts | tasks/localhosts.js | function (lines, cb) {
fs.stat(HOSTS, function (err, stat) {
if (err) {
cb(err);
} else {
var s = fs.createWriteStream(HOSTS, { mode: stat.mode });
s.on('close', cb);
s.on('error', cb);
lines.forEach(function (line, lineNum) {
if (Array.isArray(line)) {... | javascript | function (lines, cb) {
fs.stat(HOSTS, function (err, stat) {
if (err) {
cb(err);
} else {
var s = fs.createWriteStream(HOSTS, { mode: stat.mode });
s.on('close', cb);
s.on('error', cb);
lines.forEach(function (line, lineNum) {
if (Array.isArray(line)) {... | [
"function",
"(",
"lines",
",",
"cb",
")",
"{",
"fs",
".",
"stat",
"(",
"HOSTS",
",",
"function",
"(",
"err",
",",
"stat",
")",
"{",
"if",
"(",
"err",
")",
"{",
"cb",
"(",
"err",
")",
";",
"}",
"else",
"{",
"var",
"s",
"=",
"fs",
".",
"creat... | Write out an array of lines to the host file. Assumes that they're in the
format that `get` returns.
@param {Array.<string|Array.<string>>} lines
@param {function(Error)} cb | [
"Write",
"out",
"an",
"array",
"of",
"lines",
"to",
"the",
"host",
"file",
".",
"Assumes",
"that",
"they",
"re",
"in",
"the",
"format",
"that",
"get",
"returns",
"."
] | 65115f9f876509eeda302c9f4b76e12168cd382d | https://github.com/materliu/grunt-localhosts/blob/65115f9f876509eeda302c9f4b76e12168cd382d/tasks/localhosts.js#L112-L130 | train | |
haraldrudell/apprunner | lib/anomaly.js | getBody | function getBody(id, arr) {
var result = []
// heading and location: 'Anomaly 2012-08-11T03:23:49.725Z'
var now = new Date
result.push('Anomaly ' + now.toISOString() + ' ' + haraldutil.getISOPacific(now))
if (id) result.push()
result.push('host:' + os.hostname() +
' app:' + (opts.app || 'unknown') +
' api: '... | javascript | function getBody(id, arr) {
var result = []
// heading and location: 'Anomaly 2012-08-11T03:23:49.725Z'
var now = new Date
result.push('Anomaly ' + now.toISOString() + ' ' + haraldutil.getISOPacific(now))
if (id) result.push()
result.push('host:' + os.hostname() +
' app:' + (opts.app || 'unknown') +
' api: '... | [
"function",
"getBody",
"(",
"id",
",",
"arr",
")",
"{",
"var",
"result",
"=",
"[",
"]",
"// heading and location: 'Anomaly 2012-08-11T03:23:49.725Z'",
"var",
"now",
"=",
"new",
"Date",
"result",
".",
"push",
"(",
"'Anomaly '",
"+",
"now",
".",
"toISOString",
"... | assemble the text body of one anomaly | [
"assemble",
"the",
"text",
"body",
"of",
"one",
"anomaly"
] | 8d7dead166c919d160b429e00c49a62027994c33 | https://github.com/haraldrudell/apprunner/blob/8d7dead166c919d160b429e00c49a62027994c33/lib/anomaly.js#L93-L127 | train |
haraldrudell/apprunner | lib/anomaly.js | sendQueue | function sendQueue() {
var subject = ['Anomaly Report']
if (!opts.noSubjectApp && opts.app) subject.push(opts.app)
if (!opts.noSubjectHost) subject.push(os.hostname())
subject = subject.join(' ')
var body
if (skipCounter > 0) { // notify of skipped emails
enqueuedEmails.push('Skipped:' + skipCounter)
skipCo... | javascript | function sendQueue() {
var subject = ['Anomaly Report']
if (!opts.noSubjectApp && opts.app) subject.push(opts.app)
if (!opts.noSubjectHost) subject.push(os.hostname())
subject = subject.join(' ')
var body
if (skipCounter > 0) { // notify of skipped emails
enqueuedEmails.push('Skipped:' + skipCounter)
skipCo... | [
"function",
"sendQueue",
"(",
")",
"{",
"var",
"subject",
"=",
"[",
"'Anomaly Report'",
"]",
"if",
"(",
"!",
"opts",
".",
"noSubjectApp",
"&&",
"opts",
".",
"app",
")",
"subject",
".",
"push",
"(",
"opts",
".",
"app",
")",
"if",
"(",
"!",
"opts",
"... | flush the send queue to an email | [
"flush",
"the",
"send",
"queue",
"to",
"an",
"email"
] | 8d7dead166c919d160b429e00c49a62027994c33 | https://github.com/haraldrudell/apprunner/blob/8d7dead166c919d160b429e00c49a62027994c33/lib/anomaly.js#L137-L155 | train |
jm-root/core | packages/jm-event/dist/index.esm.js | EventEmitter | function EventEmitter() {
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
_classCallCheck(this, EventEmitter);
this._events = {};
if (opts.async) this.emit = emitAsync;
} | javascript | function EventEmitter() {
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
_classCallCheck(this, EventEmitter);
this._events = {};
if (opts.async) this.emit = emitAsync;
} | [
"function",
"EventEmitter",
"(",
")",
"{",
"var",
"opts",
"=",
"arguments",
".",
"length",
">",
"0",
"&&",
"arguments",
"[",
"0",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"0",
"]",
":",
"{",
"}",
";",
"_classCallCheck",
"(",
"this",
",",
"Even... | Create an eventEmitter. | [
"Create",
"an",
"eventEmitter",
"."
] | d05c7356a2991edf861e5c1aac2d0bc971cfdff3 | https://github.com/jm-root/core/blob/d05c7356a2991edf861e5c1aac2d0bc971cfdff3/packages/jm-event/dist/index.esm.js#L346-L353 | train |
Everyplay/backbone-db | lib/db.js | function(method, model, options) {
options = options || {};
var self = this;
var db;
if (!(self instanceof Db)) {
db = model.db || options.db;
debug('using db from model');
} else {
debug('using self as database');
db = self;
}
debug('sync %s %s %s %s',
method,... | javascript | function(method, model, options) {
options = options || {};
var self = this;
var db;
if (!(self instanceof Db)) {
db = model.db || options.db;
debug('using db from model');
} else {
debug('using self as database');
db = self;
}
debug('sync %s %s %s %s',
method,... | [
"function",
"(",
"method",
",",
"model",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"self",
"=",
"this",
";",
"var",
"db",
";",
"if",
"(",
"!",
"(",
"self",
"instanceof",
"Db",
")",
")",
"{",
"db",
"=",
"mo... | Default backbone sync which call the correct
database adapter function based on method.
@param {String} method (create, read, update, delete)
@param {Model} model instance of Backbone.Model
@param {Object} options options fon sync
@returns{Any} None | [
"Default",
"backbone",
"sync",
"which",
"call",
"the",
"correct",
"database",
"adapter",
"function",
"based",
"on",
"method",
"."
] | d68dd412f34a92fdfd91bb85668aceaf10d4fba4 | https://github.com/Everyplay/backbone-db/blob/d68dd412f34a92fdfd91bb85668aceaf10d4fba4/lib/db.js#L24-L89 | train | |
briancsparks/run-anywhere | lib/v2/express-host.js | hook | function hook(req, res, next) {
var _end = res.end;
var _write = res.write;
//var _on = res.on;
res.write = function(chunk, encoding) {
// ... other things
// Call the original
_write.call(this, chunk, encoding);
// Note: in some cases, you have to restore the function:
// res.wri... | javascript | function hook(req, res, next) {
var _end = res.end;
var _write = res.write;
//var _on = res.on;
res.write = function(chunk, encoding) {
// ... other things
// Call the original
_write.call(this, chunk, encoding);
// Note: in some cases, you have to restore the function:
// res.wri... | [
"function",
"hook",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"var",
"_end",
"=",
"res",
".",
"end",
";",
"var",
"_write",
"=",
"res",
".",
"write",
";",
"//var _on = res.on;",
"res",
".",
"write",
"=",
"function",
"(",
"chunk",
",",
"encodi... | Example of how to do Express.js middleware when you need to do something at the end
of the request.
@param {ServerRequest} req
@param {ServerResponse} res
@param {function} next | [
"Example",
"of",
"how",
"to",
"do",
"Express",
".",
"js",
"middleware",
"when",
"you",
"need",
"to",
"do",
"something",
"at",
"the",
"end",
"of",
"the",
"request",
"."
] | b73d170dc86cc00e6562ca8544fceb3478d51e20 | https://github.com/briancsparks/run-anywhere/blob/b73d170dc86cc00e6562ca8544fceb3478d51e20/lib/v2/express-host.js#L197-L223 | train |
PanthR/panthrMath | panthrMath/utils.js | inferEndpoint | function inferEndpoint(f, y, lower, e) {
var comp; // comparison of f(e) and f(2*e)
if (e != null) { return e; }
e = lower ? -1 : 1;
comp = f(e) < f(2 * e);
while (f(e) > y !== comp) {
e *= 2;
if (-e > 1e200) {
throw new Error('Binary search: Cannot find ' ... | javascript | function inferEndpoint(f, y, lower, e) {
var comp; // comparison of f(e) and f(2*e)
if (e != null) { return e; }
e = lower ? -1 : 1;
comp = f(e) < f(2 * e);
while (f(e) > y !== comp) {
e *= 2;
if (-e > 1e200) {
throw new Error('Binary search: Cannot find ' ... | [
"function",
"inferEndpoint",
"(",
"f",
",",
"y",
",",
"lower",
",",
"e",
")",
"{",
"var",
"comp",
";",
"// comparison of f(e) and f(2*e)",
"if",
"(",
"e",
"!=",
"null",
")",
"{",
"return",
"e",
";",
"}",
"e",
"=",
"lower",
"?",
"-",
"1",
":",
"1",
... | lower = true means looking for lower endpoint = false means looking for upper endpoint if "e" is provided it is just returned | [
"lower",
"=",
"true",
"means",
"looking",
"for",
"lower",
"endpoint",
"=",
"false",
"means",
"looking",
"for",
"upper",
"endpoint",
"if",
"e",
"is",
"provided",
"it",
"is",
"just",
"returned"
] | 54d249ca9903a9535f963da711bd3a87fb229c0b | https://github.com/PanthR/panthrMath/blob/54d249ca9903a9535f963da711bd3a87fb229c0b/panthrMath/utils.js#L433-L448 | train |
pattern-library/pattern-library-utilities | lib/logger.js | getLoggerOptions | function getLoggerOptions() {
'use strict';
var defaultOptions = {
logger: {
level: 'info',
silent: false,
exitOnError: true,
logFile: ''
}
};
var loggerOptions = {};
// get the project's options
var projectOptions = getOptions.getProjectOptions();
// merge project opti... | javascript | function getLoggerOptions() {
'use strict';
var defaultOptions = {
logger: {
level: 'info',
silent: false,
exitOnError: true,
logFile: ''
}
};
var loggerOptions = {};
// get the project's options
var projectOptions = getOptions.getProjectOptions();
// merge project opti... | [
"function",
"getLoggerOptions",
"(",
")",
"{",
"'use strict'",
";",
"var",
"defaultOptions",
"=",
"{",
"logger",
":",
"{",
"level",
":",
"'info'",
",",
"silent",
":",
"false",
",",
"exitOnError",
":",
"true",
",",
"logFile",
":",
"''",
"}",
"}",
";",
"... | Get options for logging system. Checks project's options against defaults, and sets up Winston's transport requirements
@return {Object} Contains Winston-specific options for transports and exiting on errors. | [
"Get",
"options",
"for",
"logging",
"system",
".",
"Checks",
"project",
"s",
"options",
"against",
"defaults",
"and",
"sets",
"up",
"Winston",
"s",
"transport",
"requirements"
] | a0198f7bb698eb5b859576b11afa3d0ebd3e5911 | https://github.com/pattern-library/pattern-library-utilities/blob/a0198f7bb698eb5b859576b11afa3d0ebd3e5911/lib/logger.js#L16-L64 | train |
Nazariglez/perenquen | lib/pixi/src/mesh/Rope.js | Rope | function Rope(texture, points)
{
Mesh.call(this, texture);
/*
* @member {Array} An array of points that determine the rope
*/
this.points = points;
/*
* @member {Float32Array} An array of vertices used to construct this rope.
*/
this.vertices = new Float32Array(points.length * ... | javascript | function Rope(texture, points)
{
Mesh.call(this, texture);
/*
* @member {Array} An array of points that determine the rope
*/
this.points = points;
/*
* @member {Float32Array} An array of vertices used to construct this rope.
*/
this.vertices = new Float32Array(points.length * ... | [
"function",
"Rope",
"(",
"texture",
",",
"points",
")",
"{",
"Mesh",
".",
"call",
"(",
"this",
",",
"texture",
")",
";",
"/*\n * @member {Array} An array of points that determine the rope\n */",
"this",
".",
"points",
"=",
"points",
";",
"/*\n * @member {F... | The rope allows you to draw a texture across several points and them manipulate these points
```js
for (var i = 0; i < 20; i++) {
points.push(new PIXI.Point(i * 50, 0));
};
var rope = new PIXI.Rope(PIXI.Texture.fromImage("snake.png"), points);
```
@class
@extends Mesh
@memberof PIXI.mesh
@param {Texture} texture - Th... | [
"The",
"rope",
"allows",
"you",
"to",
"draw",
"a",
"texture",
"across",
"several",
"points",
"and",
"them",
"manipulate",
"these",
"points"
] | e023964d05afeefebdcac4e2044819fdfa3899ae | https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/mesh/Rope.js#L20-L50 | train |
erraroo/ember-cli-erraroo | vendor/timing.js | function(opts) {
var performance = window.performance || window.webkitPerformance || window.msPerformance || window.mozPerformance;
if (performance === undefined) {
//console.log('Unfortunately, your browser does not support the Navigation Timing API');
return;
... | javascript | function(opts) {
var performance = window.performance || window.webkitPerformance || window.msPerformance || window.mozPerformance;
if (performance === undefined) {
//console.log('Unfortunately, your browser does not support the Navigation Timing API');
return;
... | [
"function",
"(",
"opts",
")",
"{",
"var",
"performance",
"=",
"window",
".",
"performance",
"||",
"window",
".",
"webkitPerformance",
"||",
"window",
".",
"msPerformance",
"||",
"window",
".",
"mozPerformance",
";",
"if",
"(",
"performance",
"===",
"undefined"... | Outputs extended measurements using Navigation Timing API
@param Object opts Options (simple (bool) - opts out of full data view)
@return Object measurements | [
"Outputs",
"extended",
"measurements",
"using",
"Navigation",
"Timing",
"API"
] | 1bd7d09f13e4c8f4394dc658314ed21f239741c7 | https://github.com/erraroo/ember-cli-erraroo/blob/1bd7d09f13e4c8f4394dc658314ed21f239741c7/vendor/timing.js#L18-L93 | train | |
xiamidaxia/xiami | xiami/webapp/Xiami.js | function(cb) {
var self = this
//set mainHtml
mainHtmlCache = fs.readFileSync(config.get('main_path'))
self.emit("STARTUP")
self.httpServer.listen(this.getConfig("port"), Meteor.bindEnvironment(function() {
Log.info('xiami server listeing at ' + self.getConfig('port')... | javascript | function(cb) {
var self = this
//set mainHtml
mainHtmlCache = fs.readFileSync(config.get('main_path'))
self.emit("STARTUP")
self.httpServer.listen(this.getConfig("port"), Meteor.bindEnvironment(function() {
Log.info('xiami server listeing at ' + self.getConfig('port')... | [
"function",
"(",
"cb",
")",
"{",
"var",
"self",
"=",
"this",
"//set mainHtml",
"mainHtmlCache",
"=",
"fs",
".",
"readFileSync",
"(",
"config",
".",
"get",
"(",
"'main_path'",
")",
")",
"self",
".",
"emit",
"(",
"\"STARTUP\"",
")",
"self",
".",
"httpServe... | start the server | [
"start",
"the",
"server"
] | 6fcee92c493c12bf8fd67c7068e67fa6a72a306b | https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/xiami/webapp/Xiami.js#L42-L53 | train | |
PeerioTechnologies/peerio-updater | hash.js | verifyHash | function verifyHash(correctHash, filepath) {
return calculateHash(filepath).then(hash => {
if (hash !== correctHash) {
throw new Error(`Incorrect checksum: expected ${correctHash}, got ${hash}`);
}
return true;
});
} | javascript | function verifyHash(correctHash, filepath) {
return calculateHash(filepath).then(hash => {
if (hash !== correctHash) {
throw new Error(`Incorrect checksum: expected ${correctHash}, got ${hash}`);
}
return true;
});
} | [
"function",
"verifyHash",
"(",
"correctHash",
",",
"filepath",
")",
"{",
"return",
"calculateHash",
"(",
"filepath",
")",
".",
"then",
"(",
"hash",
"=>",
"{",
"if",
"(",
"hash",
"!==",
"correctHash",
")",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"... | Calculates SHA512 hash of filepath and compares
it to the provided correctHash.
Returns a promise which rejects if the hash is
incorrect, otherwise resolves to true.
@param {string} correctHash expected hex-encoded SHA-512 hash
@param {string} filepath file path
@returns {Promise<boolean>} | [
"Calculates",
"SHA512",
"hash",
"of",
"filepath",
"and",
"compares",
"it",
"to",
"the",
"provided",
"correctHash",
"."
] | 9d6fedeec727f16a31653e4bbd4efe164e0957cb | https://github.com/PeerioTechnologies/peerio-updater/blob/9d6fedeec727f16a31653e4bbd4efe164e0957cb/hash.js#L16-L23 | train |
PeerioTechnologies/peerio-updater | hash.js | calculateHash | function calculateHash(filepath) {
return new Promise((fulfill, reject) => {
const file = fs.createReadStream(filepath);
const hash = crypto.createHash('sha512');
hash.setEncoding('hex');
file.on('error', err => {
reject(err);
});
file.on('end', () => {
... | javascript | function calculateHash(filepath) {
return new Promise((fulfill, reject) => {
const file = fs.createReadStream(filepath);
const hash = crypto.createHash('sha512');
hash.setEncoding('hex');
file.on('error', err => {
reject(err);
});
file.on('end', () => {
... | [
"function",
"calculateHash",
"(",
"filepath",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"fulfill",
",",
"reject",
")",
"=>",
"{",
"const",
"file",
"=",
"fs",
".",
"createReadStream",
"(",
"filepath",
")",
";",
"const",
"hash",
"=",
"crypto",
".",
... | Calculates hash of the file at the given path.
@param {string} filepath
@returns Promise<string> hex encoded hash | [
"Calculates",
"hash",
"of",
"the",
"file",
"at",
"the",
"given",
"path",
"."
] | 9d6fedeec727f16a31653e4bbd4efe164e0957cb | https://github.com/PeerioTechnologies/peerio-updater/blob/9d6fedeec727f16a31653e4bbd4efe164e0957cb/hash.js#L31-L45 | train |
wshager/js-rrb-vector | lib/util.js | getRoot | function getRoot(i, list) {
for (var x = list.height; x > 0; x--) {
var slot = i >> x * _const.B;
while (list.sizes[slot] <= i) {
slot++;
}
if (slot > 0) {
i -= list.sizes[slot - 1];
}
list = list[slot];
}
return list[i];
} | javascript | function getRoot(i, list) {
for (var x = list.height; x > 0; x--) {
var slot = i >> x * _const.B;
while (list.sizes[slot] <= i) {
slot++;
}
if (slot > 0) {
i -= list.sizes[slot - 1];
}
list = list[slot];
}
return list[i];
} | [
"function",
"getRoot",
"(",
"i",
",",
"list",
")",
"{",
"for",
"(",
"var",
"x",
"=",
"list",
".",
"height",
";",
"x",
">",
"0",
";",
"x",
"--",
")",
"{",
"var",
"slot",
"=",
"i",
">>",
"x",
"*",
"_const",
".",
"B",
";",
"while",
"(",
"list"... | Calculates in which slot the item probably is, then find the exact slot in the sizes. Returns the index. | [
"Calculates",
"in",
"which",
"slot",
"the",
"item",
"probably",
"is",
"then",
"find",
"the",
"exact",
"slot",
"in",
"the",
"sizes",
".",
"Returns",
"the",
"index",
"."
] | 766c3c12f658cc251dce028460c4eca4e33d5254 | https://github.com/wshager/js-rrb-vector/blob/766c3c12f658cc251dce028460c4eca4e33d5254/lib/util.js#L96-L108 | train |
r-park/images-ready | vendor/promise/core.js | Promise | function Promise(fn) {
if (typeof this !== 'object') {
throw new TypeError('Promises must be constructed via new');
}
if (typeof fn !== 'function') {
throw new TypeError('not a function');
}
this._37 = 0;
this._12 = null;
this._59 = [];
if (fn === noop) return;
doResolve(fn, this);
} | javascript | function Promise(fn) {
if (typeof this !== 'object') {
throw new TypeError('Promises must be constructed via new');
}
if (typeof fn !== 'function') {
throw new TypeError('not a function');
}
this._37 = 0;
this._12 = null;
this._59 = [];
if (fn === noop) return;
doResolve(fn, this);
} | [
"function",
"Promise",
"(",
"fn",
")",
"{",
"if",
"(",
"typeof",
"this",
"!==",
"'object'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'Promises must be constructed via new'",
")",
";",
"}",
"if",
"(",
"typeof",
"fn",
"!==",
"'function'",
")",
"{",
"thro... | module.exports = Promise; | [
"module",
".",
"exports",
"=",
"Promise",
";"
] | 5167989c2af31f28f306cb683a522ab07c785dc8 | https://github.com/r-park/images-ready/blob/5167989c2af31f28f306cb683a522ab07c785dc8/vendor/promise/core.js#L55-L67 | train |
AckerApple/ack-host | modules/webapp.js | host | function host(){
var app = leachApp(connect())
for(var x in host.prototype)app[x] = host.prototype[x]
return app
} | javascript | function host(){
var app = leachApp(connect())
for(var x in host.prototype)app[x] = host.prototype[x]
return app
} | [
"function",
"host",
"(",
")",
"{",
"var",
"app",
"=",
"leachApp",
"(",
"connect",
"(",
")",
")",
"for",
"(",
"var",
"x",
"in",
"host",
".",
"prototype",
")",
"app",
"[",
"x",
"]",
"=",
"host",
".",
"prototype",
"[",
"x",
"]",
"return",
"app",
"... | one step above using http.createServer | [
"one",
"step",
"above",
"using",
"http",
".",
"createServer"
] | b8ff0563e236499a2b9add5bf1d3849b9137a520 | https://github.com/AckerApple/ack-host/blob/b8ff0563e236499a2b9add5bf1d3849b9137a520/modules/webapp.js#L29-L33 | train |
iceroad/baresoil-server | lib/sandbox/SandboxDriver/main.js | relay | function relay(evtName) {
sbDriver.on(evtName, (...evtArgs) => {
evtArgs.splice(0, 0, evtName);
console.log(json(evtArgs));
});
} | javascript | function relay(evtName) {
sbDriver.on(evtName, (...evtArgs) => {
evtArgs.splice(0, 0, evtName);
console.log(json(evtArgs));
});
} | [
"function",
"relay",
"(",
"evtName",
")",
"{",
"sbDriver",
".",
"on",
"(",
"evtName",
",",
"(",
"...",
"evtArgs",
")",
"=>",
"{",
"evtArgs",
".",
"splice",
"(",
"0",
",",
"0",
",",
"evtName",
")",
";",
"console",
".",
"log",
"(",
"json",
"(",
"ev... | Emit sandbox driver's emitted events messages to stdout as JSON. | [
"Emit",
"sandbox",
"driver",
"s",
"emitted",
"events",
"messages",
"to",
"stdout",
"as",
"JSON",
"."
] | 8285f1647a81eb935331ea24491b38002b51278d | https://github.com/iceroad/baresoil-server/blob/8285f1647a81eb935331ea24491b38002b51278d/lib/sandbox/SandboxDriver/main.js#L16-L21 | train |
Nazariglez/perenquen | lib/pixi/src/core/text/Text.js | Text | function Text(text, style, resolution)
{
/**
* The canvas element that everything is drawn to
*
* @member {HTMLCanvasElement}
*/
this.canvas = document.createElement('canvas');
/**
* The canvas 2d context that everything is drawn with
* @member {HTMLCanvasElement}
*/
... | javascript | function Text(text, style, resolution)
{
/**
* The canvas element that everything is drawn to
*
* @member {HTMLCanvasElement}
*/
this.canvas = document.createElement('canvas');
/**
* The canvas 2d context that everything is drawn with
* @member {HTMLCanvasElement}
*/
... | [
"function",
"Text",
"(",
"text",
",",
"style",
",",
"resolution",
")",
"{",
"/**\n * The canvas element that everything is drawn to\n *\n * @member {HTMLCanvasElement}\n */",
"this",
".",
"canvas",
"=",
"document",
".",
"createElement",
"(",
"'canvas'",
")",
... | A Text Object will create a line or multiple lines of text. To split a line you can use '\n' in your text string,
or add a wordWrap property set to true and and wordWrapWidth property with a value in the style object.
A Text can be created directly from a string and a style object
```js
var text = new PIXI.Text('This... | [
"A",
"Text",
"Object",
"will",
"create",
"a",
"line",
"or",
"multiple",
"lines",
"of",
"text",
".",
"To",
"split",
"a",
"line",
"you",
"can",
"use",
"\\",
"n",
"in",
"your",
"text",
"string",
"or",
"add",
"a",
"wordWrap",
"property",
"set",
"to",
"tr... | e023964d05afeefebdcac4e2044819fdfa3899ae | https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/core/text/Text.js#L40-L84 | train |
andrewscwei/requiem | src/dom/getDataRegistry.js | getDataRegistry | function getDataRegistry(identifier) {
assert(!identifier || (typeof identifier === 'string'), `Invalid identifier specified: ${identifier}`);
if (!window.__private__) window.__private__ = {};
if (window.__private__.dataRegistry === undefined) window.__private__.dataRegistry = {};
if (identifier)
return n... | javascript | function getDataRegistry(identifier) {
assert(!identifier || (typeof identifier === 'string'), `Invalid identifier specified: ${identifier}`);
if (!window.__private__) window.__private__ = {};
if (window.__private__.dataRegistry === undefined) window.__private__.dataRegistry = {};
if (identifier)
return n... | [
"function",
"getDataRegistry",
"(",
"identifier",
")",
"{",
"assert",
"(",
"!",
"identifier",
"||",
"(",
"typeof",
"identifier",
"===",
"'string'",
")",
",",
"`",
"${",
"identifier",
"}",
"`",
")",
";",
"if",
"(",
"!",
"window",
".",
"__private__",
")",
... | Gets the data registry or a specific entry inside the data registry.
@param {string} [identifier] - The dot notated identifier.
@return {Object} The data registry.
@alias module:requiem~dom.getDataRegistry | [
"Gets",
"the",
"data",
"registry",
"or",
"a",
"specific",
"entry",
"inside",
"the",
"data",
"registry",
"."
] | c4182bfffc9841c6de5718f689ad3c2060511777 | https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/dom/getDataRegistry.js#L17-L29 | train |
haztivity/hz-soupletter | src/lib/wordfindgame.js | function (el, puzzle) {
var output = '';
// for each row in the puzzle
for (var i = 0, height = puzzle.length; i < height; i++) {
// append a div to represent a row in the puzzle
var row = puzzle[i];
output += '<div class="wordsRow">';
... | javascript | function (el, puzzle) {
var output = '';
// for each row in the puzzle
for (var i = 0, height = puzzle.length; i < height; i++) {
// append a div to represent a row in the puzzle
var row = puzzle[i];
output += '<div class="wordsRow">';
... | [
"function",
"(",
"el",
",",
"puzzle",
")",
"{",
"var",
"output",
"=",
"''",
";",
"// for each row in the puzzle",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"height",
"=",
"puzzle",
".",
"length",
";",
"i",
"<",
"height",
";",
"i",
"++",
")",
"{",
"// ... | Draws the puzzle by inserting rows of buttons into el.
@param {String} el: The jQuery element to write the puzzle to
@param {[[String]]} puzzle: The puzzle to draw | [
"Draws",
"the",
"puzzle",
"by",
"inserting",
"rows",
"of",
"buttons",
"into",
"el",
"."
] | 38cbcd0c6e9ad029b7e74ce9e9e75f8775870956 | https://github.com/haztivity/hz-soupletter/blob/38cbcd0c6e9ad029b7e74ce9e9e75f8775870956/src/lib/wordfindgame.js#L32-L50 | train | |
haztivity/hz-soupletter | src/lib/wordfindgame.js | function (target) {
// if the user hasn't started a word yet, just return
if (!startSquare) {
return;
}
// if the new square is actually the previous square, just return
var lastSquare = selectedSquares[selectedSquares.length - 1];
... | javascript | function (target) {
// if the user hasn't started a word yet, just return
if (!startSquare) {
return;
}
// if the new square is actually the previous square, just return
var lastSquare = selectedSquares[selectedSquares.length - 1];
... | [
"function",
"(",
"target",
")",
"{",
"// if the user hasn't started a word yet, just return",
"if",
"(",
"!",
"startSquare",
")",
"{",
"return",
";",
"}",
"// if the new square is actually the previous square, just return",
"var",
"lastSquare",
"=",
"selectedSquares",
"[",
... | Event that handles mouse over on a new square. Ensures that the new square
is adjacent to the previous square and the new square is along the path
of an actual word. | [
"Event",
"that",
"handles",
"mouse",
"over",
"on",
"a",
"new",
"square",
".",
"Ensures",
"that",
"the",
"new",
"square",
"is",
"adjacent",
"to",
"the",
"previous",
"square",
"and",
"the",
"new",
"square",
"is",
"along",
"the",
"path",
"of",
"an",
"actual... | 38cbcd0c6e9ad029b7e74ce9e9e75f8775870956 | https://github.com/haztivity/hz-soupletter/blob/38cbcd0c6e9ad029b7e74ce9e9e75f8775870956/src/lib/wordfindgame.js#L88-L137 | train | |
haztivity/hz-soupletter | src/lib/wordfindgame.js | function (square) {
// make sure we are still forming a valid word
for (var i = 0, len = wordList.length; i < len; i++) {
if (wordList[i].indexOf(curWord + $(square).text()) === 0) {
$(square).addClass('selected');
selectedSquares.push(squa... | javascript | function (square) {
// make sure we are still forming a valid word
for (var i = 0, len = wordList.length; i < len; i++) {
if (wordList[i].indexOf(curWord + $(square).text()) === 0) {
$(square).addClass('selected');
selectedSquares.push(squa... | [
"function",
"(",
"square",
")",
"{",
"// make sure we are still forming a valid word",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"wordList",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"wordList",
"[",
"i",
"]",
... | Updates the game state when the previous selection was valid.
@param {el} square: The jQuery element that was played | [
"Updates",
"the",
"game",
"state",
"when",
"the",
"previous",
"selection",
"was",
"valid",
"."
] | 38cbcd0c6e9ad029b7e74ce9e9e75f8775870956 | https://github.com/haztivity/hz-soupletter/blob/38cbcd0c6e9ad029b7e74ce9e9e75f8775870956/src/lib/wordfindgame.js#L152-L162 | train | |
haztivity/hz-soupletter | src/lib/wordfindgame.js | function (e) {
// see if we formed a valid word
for (var i = 0, len = wordList.length; i < len; i++) {
if (wordList[i] === curWord) {
var selected = $('.selected');
selected.addClass('found');
wordList.splice(i, 1);
... | javascript | function (e) {
// see if we formed a valid word
for (var i = 0, len = wordList.length; i < len; i++) {
if (wordList[i] === curWord) {
var selected = $('.selected');
selected.addClass('found');
wordList.splice(i, 1);
... | [
"function",
"(",
"e",
")",
"{",
"// see if we formed a valid word",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"wordList",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"wordList",
"[",
"i",
"]",
"===",
"curWord"... | Event that handles mouse up on a square. Checks to see if a valid word
was created and updates the class of the letters and word if it was. Then
resets the game state to start a new word. | [
"Event",
"that",
"handles",
"mouse",
"up",
"on",
"a",
"square",
".",
"Checks",
"to",
"see",
"if",
"a",
"valid",
"word",
"was",
"created",
"and",
"updates",
"the",
"class",
"of",
"the",
"letters",
"and",
"word",
"if",
"it",
"was",
".",
"Then",
"resets",... | 38cbcd0c6e9ad029b7e74ce9e9e75f8775870956 | https://github.com/haztivity/hz-soupletter/blob/38cbcd0c6e9ad029b7e74ce9e9e75f8775870956/src/lib/wordfindgame.js#L169-L201 | train | |
haztivity/hz-soupletter | src/lib/wordfindgame.js | function (x1, y1, x2, y2) {
for (var orientation in wordfind.orientations) {
var nextFn = wordfind.orientations[orientation];
var nextPos = nextFn(x1, y1, 1);
if (nextPos.x === x2 && nextPos.y === y2) {
return orientation;
}... | javascript | function (x1, y1, x2, y2) {
for (var orientation in wordfind.orientations) {
var nextFn = wordfind.orientations[orientation];
var nextPos = nextFn(x1, y1, 1);
if (nextPos.x === x2 && nextPos.y === y2) {
return orientation;
}... | [
"function",
"(",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
")",
"{",
"for",
"(",
"var",
"orientation",
"in",
"wordfind",
".",
"orientations",
")",
"{",
"var",
"nextFn",
"=",
"wordfind",
".",
"orientations",
"[",
"orientation",
"]",
";",
"var",
"nextPos",
... | Given two points, ensure that they are adjacent and determine what
orientation the second point is relative to the first
@param {int} x1: The x coordinate of the first point
@param {int} y1: The y coordinate of the first point
@param {int} x2: The x coordinate of the second point
@param {int} y2: The y coordinate of t... | [
"Given",
"two",
"points",
"ensure",
"that",
"they",
"are",
"adjacent",
"and",
"determine",
"what",
"orientation",
"the",
"second",
"point",
"is",
"relative",
"to",
"the",
"first"
] | 38cbcd0c6e9ad029b7e74ce9e9e75f8775870956 | https://github.com/haztivity/hz-soupletter/blob/38cbcd0c6e9ad029b7e74ce9e9e75f8775870956/src/lib/wordfindgame.js#L211-L220 | train | |
haztivity/hz-soupletter | src/lib/wordfindgame.js | function (words, puzzleEl, wordsEl, options, colorHash) {
wordList = words.slice(0).sort();
var puzzle = wordfind.newPuzzle(words, options);
// draw out all of the words
drawPuzzle(puzzleEl, puzzle);
var list = drawWords(wordsEl, wordList);... | javascript | function (words, puzzleEl, wordsEl, options, colorHash) {
wordList = words.slice(0).sort();
var puzzle = wordfind.newPuzzle(words, options);
// draw out all of the words
drawPuzzle(puzzleEl, puzzle);
var list = drawWords(wordsEl, wordList);... | [
"function",
"(",
"words",
",",
"puzzleEl",
",",
"wordsEl",
",",
"options",
",",
"colorHash",
")",
"{",
"wordList",
"=",
"words",
".",
"slice",
"(",
"0",
")",
".",
"sort",
"(",
")",
";",
"var",
"puzzle",
"=",
"wordfind",
".",
"newPuzzle",
"(",
"words"... | Creates a new word find game and draws the board and words.
Returns the puzzle that was created.
@param {[String]} words: The words to add to the puzzle
@param {String} puzzleEl: Selector to use when inserting the puzzle
@param {String} wordsEl: Selector to use when inserting the word list
@param {Options} options: W... | [
"Creates",
"a",
"new",
"word",
"find",
"game",
"and",
"draws",
"the",
"board",
"and",
"words",
"."
] | 38cbcd0c6e9ad029b7e74ce9e9e75f8775870956 | https://github.com/haztivity/hz-soupletter/blob/38cbcd0c6e9ad029b7e74ce9e9e75f8775870956/src/lib/wordfindgame.js#L232-L243 | train | |
haztivity/hz-soupletter | src/lib/wordfindgame.js | function (puzzle, words, list, colorHash) {
var solution = wordfind.solve(puzzle, words).found;
for (var i = 0, len = solution.length; i < len; i++) {
var word = solution[i].word, orientation = solution[i].orientation, x = solution[i].x, y = solution[i].y, next = word... | javascript | function (puzzle, words, list, colorHash) {
var solution = wordfind.solve(puzzle, words).found;
for (var i = 0, len = solution.length; i < len; i++) {
var word = solution[i].word, orientation = solution[i].orientation, x = solution[i].x, y = solution[i].y, next = word... | [
"function",
"(",
"puzzle",
",",
"words",
",",
"list",
",",
"colorHash",
")",
"{",
"var",
"solution",
"=",
"wordfind",
".",
"solve",
"(",
"puzzle",
",",
"words",
")",
".",
"found",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"solution",
... | Solves an existing puzzle.
@param {[[String]]} puzzle: The puzzle to solve
@param {[String]} words: The words to solve for | [
"Solves",
"an",
"existing",
"puzzle",
"."
] | 38cbcd0c6e9ad029b7e74ce9e9e75f8775870956 | https://github.com/haztivity/hz-soupletter/blob/38cbcd0c6e9ad029b7e74ce9e9e75f8775870956/src/lib/wordfindgame.js#L250-L284 | train | |
derdesign/protos | middleware/logger/transport-mongodb.js | initMongo | function initMongo(config, callback) {
var self = this;
// Set db
self.db = new Db(config.database, new Server(config.host, config.port, {}), {safe: true});
// Get client
self.db.open(function(err, client) {
if (err) throw err;
else {
self.client = client;
client.collectionNames(f... | javascript | function initMongo(config, callback) {
var self = this;
// Set db
self.db = new Db(config.database, new Server(config.host, config.port, {}), {safe: true});
// Get client
self.db.open(function(err, client) {
if (err) throw err;
else {
self.client = client;
client.collectionNames(f... | [
"function",
"initMongo",
"(",
"config",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// Set db",
"self",
".",
"db",
"=",
"new",
"Db",
"(",
"config",
".",
"database",
",",
"new",
"Server",
"(",
"config",
".",
"host",
",",
"config",
"."... | Initializes the MongoDB Client & Collection
@param {object} config
@param {function} callback
@private | [
"Initializes",
"the",
"MongoDB",
"Client",
"&",
"Collection"
] | 0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9 | https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/middleware/logger/transport-mongodb.js#L128-L196 | train |
nomic/api-driver | lib/expector.js | checkJSONExpression | function checkJSONExpression(expression, json) {
if (! (expression && json)) {
return false;
}
// array expressions never match non-arrays or arrays of a different length.
if (_.isArray(expression) && !(_.isArray(json) && expression.length === json.length)) {
return false;
}
return _.all(expressio... | javascript | function checkJSONExpression(expression, json) {
if (! (expression && json)) {
return false;
}
// array expressions never match non-arrays or arrays of a different length.
if (_.isArray(expression) && !(_.isArray(json) && expression.length === json.length)) {
return false;
}
return _.all(expressio... | [
"function",
"checkJSONExpression",
"(",
"expression",
",",
"json",
")",
"{",
"if",
"(",
"!",
"(",
"expression",
"&&",
"json",
")",
")",
"{",
"return",
"false",
";",
"}",
"// array expressions never match non-arrays or arrays of a different length.",
"if",
"(",
"_",
... | Check the body expression matches matches the body. | [
"Check",
"the",
"body",
"expression",
"matches",
"matches",
"the",
"body",
"."
] | 9e1401d14113c0e7ba9fe7582f1beac315394a5b | https://github.com/nomic/api-driver/blob/9e1401d14113c0e7ba9fe7582f1beac315394a5b/lib/expector.js#L13-L63 | train |
RekkyRek/RantScript | src/utilities/http.js | POST_FILE | function POST_FILE(uri, params, filepath) {
var form = new FormData();
for (var i in params) {
form.append(i, params[i]);
}
let contenttype = 'INVALID';
if(filepath.split('.').pop().toLowerCase() == 'jpg') { contenttype = 'image/jpg' }
if(filepath.split('.').pop().toLowerCase() == 'png') { contentt... | javascript | function POST_FILE(uri, params, filepath) {
var form = new FormData();
for (var i in params) {
form.append(i, params[i]);
}
let contenttype = 'INVALID';
if(filepath.split('.').pop().toLowerCase() == 'jpg') { contenttype = 'image/jpg' }
if(filepath.split('.').pop().toLowerCase() == 'png') { contentt... | [
"function",
"POST_FILE",
"(",
"uri",
",",
"params",
",",
"filepath",
")",
"{",
"var",
"form",
"=",
"new",
"FormData",
"(",
")",
";",
"for",
"(",
"var",
"i",
"in",
"params",
")",
"{",
"form",
".",
"append",
"(",
"i",
",",
"params",
"[",
"i",
"]",
... | For posting a file using multipart formdata
@param {any} uri - request URL
@param {any} params - request parameters
@param {any} filepath - path to the file
@returns | [
"For",
"posting",
"a",
"file",
"using",
"multipart",
"formdata"
] | 58b6178e9e0b7e6b44c7c9657936dde1166e593f | https://github.com/RekkyRek/RantScript/blob/58b6178e9e0b7e6b44c7c9657936dde1166e593f/src/utilities/http.js#L59-L100 | train |
RekkyRek/RantScript | src/utilities/http.js | POST | function POST(uri, params) {
var form = new FormData();
for (var i in params) {
form.append(i, params[i]);
}
const requestURL = `${uri}`;
log(`request URL: ${requestURL}`);
return fetch(requestURL, { method: 'POST', compress: compress, body: form, headers: { 'Content-Type': 'multipart/form-data; bo... | javascript | function POST(uri, params) {
var form = new FormData();
for (var i in params) {
form.append(i, params[i]);
}
const requestURL = `${uri}`;
log(`request URL: ${requestURL}`);
return fetch(requestURL, { method: 'POST', compress: compress, body: form, headers: { 'Content-Type': 'multipart/form-data; bo... | [
"function",
"POST",
"(",
"uri",
",",
"params",
")",
"{",
"var",
"form",
"=",
"new",
"FormData",
"(",
")",
";",
"for",
"(",
"var",
"i",
"in",
"params",
")",
"{",
"form",
".",
"append",
"(",
"i",
",",
"params",
"[",
"i",
"]",
")",
";",
"}",
"co... | Use this functions for HTTP POST request
@param {String} uri - request URL
@param {Object} params - request parameters
@return {Promise} HTTP response | [
"Use",
"this",
"functions",
"for",
"HTTP",
"POST",
"request"
] | 58b6178e9e0b7e6b44c7c9657936dde1166e593f | https://github.com/RekkyRek/RantScript/blob/58b6178e9e0b7e6b44c7c9657936dde1166e593f/src/utilities/http.js#L110-L134 | train |
RekkyRek/RantScript | src/utilities/http.js | DELETE | function DELETE(uri, params) {
const requestURL = `${uri}${url.format({ query: params })}`;
log(`request URL: ${requestURL}`);
return fetch(requestURL, { method: 'DELETE', compress: compress })
.then(function handleRequest(res) {
const statusText = res.statusText;
const status = res.status;
... | javascript | function DELETE(uri, params) {
const requestURL = `${uri}${url.format({ query: params })}`;
log(`request URL: ${requestURL}`);
return fetch(requestURL, { method: 'DELETE', compress: compress })
.then(function handleRequest(res) {
const statusText = res.statusText;
const status = res.status;
... | [
"function",
"DELETE",
"(",
"uri",
",",
"params",
")",
"{",
"const",
"requestURL",
"=",
"`",
"${",
"uri",
"}",
"${",
"url",
".",
"format",
"(",
"{",
"query",
":",
"params",
"}",
")",
"}",
"`",
";",
"log",
"(",
"`",
"${",
"requestURL",
"}",
"`",
... | Use this functions for HTTP DELETE requst
@param {String} uri - request URL
@param {Object} params - request parameters
@return {Promise} HTTP response | [
"Use",
"this",
"functions",
"for",
"HTTP",
"DELETE",
"requst"
] | 58b6178e9e0b7e6b44c7c9657936dde1166e593f | https://github.com/RekkyRek/RantScript/blob/58b6178e9e0b7e6b44c7c9657936dde1166e593f/src/utilities/http.js#L144-L163 | train |
jonschlinkert/inject-snippet | index.js | memoize | function memoize(key, val) {
if (cache.hasOwnProperty(key)) {
return cache[key];
}
return (cache[key] = val);
} | javascript | function memoize(key, val) {
if (cache.hasOwnProperty(key)) {
return cache[key];
}
return (cache[key] = val);
} | [
"function",
"memoize",
"(",
"key",
",",
"val",
")",
"{",
"if",
"(",
"cache",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"return",
"cache",
"[",
"key",
"]",
";",
"}",
"return",
"(",
"cache",
"[",
"key",
"]",
"=",
"val",
")",
";",
"}"
] | Delimiter-related utils | [
"Delimiter",
"-",
"related",
"utils"
] | 8272f3eb32dc31c145e5874fd9ee1ad5004f4d06 | https://github.com/jonschlinkert/inject-snippet/blob/8272f3eb32dc31c145e5874fd9ee1ad5004f4d06/index.js#L108-L113 | train |
tjmehta/cast-buffer | index.js | castBuffer | function castBuffer (val) {
if (Buffer.isBuffer(val)) {
return val
}
val = toJSON(val)
var args = assertArgs([val], {
val: ['string', 'array', 'object', 'number', 'boolean']
})
val = args.val
var str
if (Array.isArray(val)) {
val = val.map(toJSON)
str = JSON.stringify(val)
} else if... | javascript | function castBuffer (val) {
if (Buffer.isBuffer(val)) {
return val
}
val = toJSON(val)
var args = assertArgs([val], {
val: ['string', 'array', 'object', 'number', 'boolean']
})
val = args.val
var str
if (Array.isArray(val)) {
val = val.map(toJSON)
str = JSON.stringify(val)
} else if... | [
"function",
"castBuffer",
"(",
"val",
")",
"{",
"if",
"(",
"Buffer",
".",
"isBuffer",
"(",
"val",
")",
")",
"{",
"return",
"val",
"}",
"val",
"=",
"toJSON",
"(",
"val",
")",
"var",
"args",
"=",
"assertArgs",
"(",
"[",
"val",
"]",
",",
"{",
"val",... | cast value to buffer
@param {Buffer|Object|Array|String|Boolean} val value to be casted
@return {Buffer} value as a Buffer | [
"cast",
"value",
"to",
"buffer"
] | 4abb132fc84d5ce15d83990ecc69232b7024cbec | https://github.com/tjmehta/cast-buffer/blob/4abb132fc84d5ce15d83990ecc69232b7024cbec/index.js#L15-L39 | train |
le17i/ParseJS | parse.js | function (value) {
if(value === undefined) return null;
if(value instanceof Date) {
return value;
}
var date = null, replace, regex, a = 0, length = helpers.date.regex.length;
value = value.toString();
for(a; a < length; a++) {
regex = helpers.date.regex[a];
... | javascript | function (value) {
if(value === undefined) return null;
if(value instanceof Date) {
return value;
}
var date = null, replace, regex, a = 0, length = helpers.date.regex.length;
value = value.toString();
for(a; a < length; a++) {
regex = helpers.date.regex[a];
... | [
"function",
"(",
"value",
")",
"{",
"if",
"(",
"value",
"===",
"undefined",
")",
"return",
"null",
";",
"if",
"(",
"value",
"instanceof",
"Date",
")",
"{",
"return",
"value",
";",
"}",
"var",
"date",
"=",
"null",
",",
"replace",
",",
"regex",
",",
... | Try convert the value on date object. If failed, return false | [
"Try",
"convert",
"the",
"value",
"on",
"date",
"object",
".",
"If",
"failed",
"return",
"false"
] | fcd17a78b1a9433a768e0f4fc9650f0df8a8404b | https://github.com/le17i/ParseJS/blob/fcd17a78b1a9433a768e0f4fc9650f0df8a8404b/parse.js#L128-L159 | train | |
le17i/ParseJS | parse.js | function(format, value) {
var date = helpers.date.parse(value);
if(date === false || date === undefined) return false;
var day = date.getDate().toString().replace(/(?=(^\d{1}$))/g, "0");
var month = (date.getMonth() + 1).toString().replace(/(?=(^\d{1}$))/g, "0");
var formatDate = format... | javascript | function(format, value) {
var date = helpers.date.parse(value);
if(date === false || date === undefined) return false;
var day = date.getDate().toString().replace(/(?=(^\d{1}$))/g, "0");
var month = (date.getMonth() + 1).toString().replace(/(?=(^\d{1}$))/g, "0");
var formatDate = format... | [
"function",
"(",
"format",
",",
"value",
")",
"{",
"var",
"date",
"=",
"helpers",
".",
"date",
".",
"parse",
"(",
"value",
")",
";",
"if",
"(",
"date",
"===",
"false",
"||",
"date",
"===",
"undefined",
")",
"return",
"false",
";",
"var",
"day",
"="... | Transform the date object to format string | [
"Transform",
"the",
"date",
"object",
"to",
"format",
"string"
] | fcd17a78b1a9433a768e0f4fc9650f0df8a8404b | https://github.com/le17i/ParseJS/blob/fcd17a78b1a9433a768e0f4fc9650f0df8a8404b/parse.js#L162-L176 | train | |
appcelerator-archive/appc-connector-utils | lib/utils/fs.js | saveModelSync | function saveModelSync (modelName, modelMetadata, modelDir) {
const buffer = `const Arrow = require('arrow')
var Model = Arrow.Model.extend('${modelName}', ${JSON.stringify(modelMetadata, null, '\t')})
module.exports = Model`
fs.writeFileSync(path.join(modelDir, modelMetadata.name.toLowerCase() + '.js'), buffer)
} | javascript | function saveModelSync (modelName, modelMetadata, modelDir) {
const buffer = `const Arrow = require('arrow')
var Model = Arrow.Model.extend('${modelName}', ${JSON.stringify(modelMetadata, null, '\t')})
module.exports = Model`
fs.writeFileSync(path.join(modelDir, modelMetadata.name.toLowerCase() + '.js'), buffer)
} | [
"function",
"saveModelSync",
"(",
"modelName",
",",
"modelMetadata",
",",
"modelDir",
")",
"{",
"const",
"buffer",
"=",
"`",
"${",
"modelName",
"}",
"${",
"JSON",
".",
"stringify",
"(",
"modelMetadata",
",",
"null",
",",
"'\\t'",
")",
"}",
"`",
"fs",
"."... | Saves model to disk
@param {string} modelName the name model
@param {object} modelMetadata metadata that describes the model
@param {string} modelDir the directory where to save the model | [
"Saves",
"model",
"to",
"disk"
] | 4af3bb7d24c5780270d7ba0ec98017b1f58f1aa8 | https://github.com/appcelerator-archive/appc-connector-utils/blob/4af3bb7d24c5780270d7ba0ec98017b1f58f1aa8/lib/utils/fs.js#L37-L42 | train |
appcelerator-archive/appc-connector-utils | lib/utils/fs.js | ensureExistsAndClean | function ensureExistsAndClean (dir) {
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir)
} else {
cleanDir(dir)
}
} | javascript | function ensureExistsAndClean (dir) {
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir)
} else {
cleanDir(dir)
}
} | [
"function",
"ensureExistsAndClean",
"(",
"dir",
")",
"{",
"if",
"(",
"!",
"fs",
".",
"existsSync",
"(",
"dir",
")",
")",
"{",
"fs",
".",
"mkdirSync",
"(",
"dir",
")",
"}",
"else",
"{",
"cleanDir",
"(",
"dir",
")",
"}",
"}"
] | Makes sure that the specified directory exists.
@param dir | [
"Makes",
"sure",
"that",
"the",
"specified",
"directory",
"exists",
"."
] | 4af3bb7d24c5780270d7ba0ec98017b1f58f1aa8 | https://github.com/appcelerator-archive/appc-connector-utils/blob/4af3bb7d24c5780270d7ba0ec98017b1f58f1aa8/lib/utils/fs.js#L48-L54 | train |
kawanet/promisen | promisen.js | executable | function executable(value) {
var result;
try {
result = resolve(task.apply(this, arguments));
} catch (e) {
result = reject(e);
}
return result;
} | javascript | function executable(value) {
var result;
try {
result = resolve(task.apply(this, arguments));
} catch (e) {
result = reject(e);
}
return result;
} | [
"function",
"executable",
"(",
"value",
")",
"{",
"var",
"result",
";",
"try",
"{",
"result",
"=",
"resolve",
"(",
"task",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"result",
"=",
"reject",
"(",
... | return a result from the function | [
"return",
"a",
"result",
"from",
"the",
"function"
] | 71093972cf8d3cfb8e316f48498f1aa9999f169c | https://github.com/kawanet/promisen/blob/71093972cf8d3cfb8e316f48498f1aa9999f169c/promisen.js#L132-L140 | train |
kawanet/promisen | promisen.js | parallel | function parallel(tasks) {
if (tasks == null) return promisen([]);
tasks = Array.prototype.map.call(tasks, wrap);
return all;
function all(value) {
var boundTasks = Array.prototype.map.call(tasks, run.bind(this, value));
return promisen.Promise.all(boundTasks);
}
// apply the first... | javascript | function parallel(tasks) {
if (tasks == null) return promisen([]);
tasks = Array.prototype.map.call(tasks, wrap);
return all;
function all(value) {
var boundTasks = Array.prototype.map.call(tasks, run.bind(this, value));
return promisen.Promise.all(boundTasks);
}
// apply the first... | [
"function",
"parallel",
"(",
"tasks",
")",
"{",
"if",
"(",
"tasks",
"==",
"null",
")",
"return",
"promisen",
"(",
"[",
"]",
")",
";",
"tasks",
"=",
"Array",
".",
"prototype",
".",
"map",
".",
"call",
"(",
"tasks",
",",
"wrap",
")",
";",
"return",
... | creates a promise-returning function which runs multiple tasks in parallel.
@class promisen
@static
@function parallel
@param tasks {Array|Array-like} list of tasks
@returns {Function} promise-returning function
@example
var promisen = require("promisen");
// generate a promise-returning function
var task = promisen.... | [
"creates",
"a",
"promise",
"-",
"returning",
"function",
"which",
"runs",
"multiple",
"tasks",
"in",
"parallel",
"."
] | 71093972cf8d3cfb8e316f48498f1aa9999f169c | https://github.com/kawanet/promisen/blob/71093972cf8d3cfb8e316f48498f1aa9999f169c/promisen.js#L268-L286 | train |
kawanet/promisen | promisen.js | IF | function IF(condTask, trueTask, falseTask) {
condTask = (condTask != null) ? promisen(condTask) : promisen();
trueTask = (trueTask != null) ? promisen(trueTask) : promisen();
falseTask = (falseTask != null) ? promisen(falseTask) : promisen();
return conditional;
function conditional(value) {
... | javascript | function IF(condTask, trueTask, falseTask) {
condTask = (condTask != null) ? promisen(condTask) : promisen();
trueTask = (trueTask != null) ? promisen(trueTask) : promisen();
falseTask = (falseTask != null) ? promisen(falseTask) : promisen();
return conditional;
function conditional(value) {
... | [
"function",
"IF",
"(",
"condTask",
",",
"trueTask",
",",
"falseTask",
")",
"{",
"condTask",
"=",
"(",
"condTask",
"!=",
"null",
")",
"?",
"promisen",
"(",
"condTask",
")",
":",
"promisen",
"(",
")",
";",
"trueTask",
"=",
"(",
"trueTask",
"!=",
"null",
... | creates a promise-returning function which runs a task assigned by a conditional task.
When null or undefined is given as a task, it will do nothing for value and just passes it.
@class promisen
@static
@function if
@param [condTask] {Boolean|Function|Promise|thenable|*|null} boolean or function returns boolean
@para... | [
"creates",
"a",
"promise",
"-",
"returning",
"function",
"which",
"runs",
"a",
"task",
"assigned",
"by",
"a",
"conditional",
"task",
"."
] | 71093972cf8d3cfb8e316f48498f1aa9999f169c | https://github.com/kawanet/promisen/blob/71093972cf8d3cfb8e316f48498f1aa9999f169c/promisen.js#L325-L341 | train |
kawanet/promisen | promisen.js | WHILE | function WHILE(condTask, runTask) {
var runTasks = Array.prototype.slice.call(arguments, 1);
runTasks.push(nextTask);
runTask = waterfall(runTasks);
var whileTask = IF(condTask, runTask);
return whileTask;
function nextTask(value) {
return whileTask.call(this, value);
}
} | javascript | function WHILE(condTask, runTask) {
var runTasks = Array.prototype.slice.call(arguments, 1);
runTasks.push(nextTask);
runTask = waterfall(runTasks);
var whileTask = IF(condTask, runTask);
return whileTask;
function nextTask(value) {
return whileTask.call(this, value);
}
} | [
"function",
"WHILE",
"(",
"condTask",
",",
"runTask",
")",
"{",
"var",
"runTasks",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
";",
"runTasks",
".",
"push",
"(",
"nextTask",
")",
";",
"runTask",
"=",
"w... | creates a promise-returning function which runs a task repeatedly while the condition is true.
When null or undefined is given as condTask, it will do nothing for value and just passes it.
@class promisen
@static
@function while
@param condTask {Boolean|Function|Promise|thenable|*|null} boolean or function returns bo... | [
"creates",
"a",
"promise",
"-",
"returning",
"function",
"which",
"runs",
"a",
"task",
"repeatedly",
"while",
"the",
"condition",
"is",
"true",
"."
] | 71093972cf8d3cfb8e316f48498f1aa9999f169c | https://github.com/kawanet/promisen/blob/71093972cf8d3cfb8e316f48498f1aa9999f169c/promisen.js#L368-L378 | train |
kawanet/promisen | promisen.js | eachSeries | function eachSeries(arrayTask, iteratorTask) {
if (arrayTask == null) arrayTask = promisen();
iteratorTask = promisen(iteratorTask);
return waterfall([arrayTask, loopTask]);
// composite multiple tasks
function loopTask(arrayResults) {
arrayResults = Array.prototype.map.call(arrayResults, wra... | javascript | function eachSeries(arrayTask, iteratorTask) {
if (arrayTask == null) arrayTask = promisen();
iteratorTask = promisen(iteratorTask);
return waterfall([arrayTask, loopTask]);
// composite multiple tasks
function loopTask(arrayResults) {
arrayResults = Array.prototype.map.call(arrayResults, wra... | [
"function",
"eachSeries",
"(",
"arrayTask",
",",
"iteratorTask",
")",
"{",
"if",
"(",
"arrayTask",
"==",
"null",
")",
"arrayTask",
"=",
"promisen",
"(",
")",
";",
"iteratorTask",
"=",
"promisen",
"(",
"iteratorTask",
")",
";",
"return",
"waterfall",
"(",
"... | creates a promise-returning function which runs task repeatedly for each value of array in order.
@class promisen
@static
@function eachSeries
@param arrayTask {Array|Function|Promise|thenable} array or task returns array for iteration
@param iteratorTask {Function} task runs repeatedly for each of array values
@retur... | [
"creates",
"a",
"promise",
"-",
"returning",
"function",
"which",
"runs",
"task",
"repeatedly",
"for",
"each",
"value",
"of",
"array",
"in",
"order",
"."
] | 71093972cf8d3cfb8e316f48498f1aa9999f169c | https://github.com/kawanet/promisen/blob/71093972cf8d3cfb8e316f48498f1aa9999f169c/promisen.js#L401-L418 | train |
kawanet/promisen | promisen.js | each | function each(arrayTask, iteratorTask) {
if (arrayTask == null) arrayTask = promisen();
iteratorTask = promisen(iteratorTask);
return waterfall([arrayTask, loopTask]);
// composite multiple tasks
function loopTask(arrayResults) {
arrayResults = Array.prototype.map.call(arrayResults, wrap);
... | javascript | function each(arrayTask, iteratorTask) {
if (arrayTask == null) arrayTask = promisen();
iteratorTask = promisen(iteratorTask);
return waterfall([arrayTask, loopTask]);
// composite multiple tasks
function loopTask(arrayResults) {
arrayResults = Array.prototype.map.call(arrayResults, wrap);
... | [
"function",
"each",
"(",
"arrayTask",
",",
"iteratorTask",
")",
"{",
"if",
"(",
"arrayTask",
"==",
"null",
")",
"arrayTask",
"=",
"promisen",
"(",
")",
";",
"iteratorTask",
"=",
"promisen",
"(",
"iteratorTask",
")",
";",
"return",
"waterfall",
"(",
"[",
... | creates a promise-returning function which runs task repeatedly for each value of array in parallel.
@class promisen
@static
@function each
@param arrayTask {Array|Function|Promise|thenable} array or task returns array for iteration
@param iteratorTask {Function} task runs repeatedly for each of array values
@returns ... | [
"creates",
"a",
"promise",
"-",
"returning",
"function",
"which",
"runs",
"task",
"repeatedly",
"for",
"each",
"value",
"of",
"array",
"in",
"parallel",
"."
] | 71093972cf8d3cfb8e316f48498f1aa9999f169c | https://github.com/kawanet/promisen/blob/71093972cf8d3cfb8e316f48498f1aa9999f169c/promisen.js#L441-L459 | train |
kawanet/promisen | promisen.js | incr | function incr(array) {
return incrTask;
function incrTask() {
if (!array.length) {
Array.prototype.push.call(array, 0 | 0);
}
return resolve(++array[array.length - 1]);
}
} | javascript | function incr(array) {
return incrTask;
function incrTask() {
if (!array.length) {
Array.prototype.push.call(array, 0 | 0);
}
return resolve(++array[array.length - 1]);
}
} | [
"function",
"incr",
"(",
"array",
")",
"{",
"return",
"incrTask",
";",
"function",
"incrTask",
"(",
")",
"{",
"if",
"(",
"!",
"array",
".",
"length",
")",
"{",
"Array",
".",
"prototype",
".",
"push",
".",
"call",
"(",
"array",
",",
"0",
"|",
"0",
... | creates a promise-returning function which increments a counter on top of stack.
@class promisen
@static
@function incr
@param array {Array|Array-like} counter holder
@returns {Function} promise-returning function
@example
var promisen = require("promisen");
var counter = [123];
console.log("count: " + counter); // =... | [
"creates",
"a",
"promise",
"-",
"returning",
"function",
"which",
"increments",
"a",
"counter",
"on",
"top",
"of",
"stack",
"."
] | 71093972cf8d3cfb8e316f48498f1aa9999f169c | https://github.com/kawanet/promisen/blob/71093972cf8d3cfb8e316f48498f1aa9999f169c/promisen.js#L482-L491 | train |
kawanet/promisen | promisen.js | push | function push(array) {
return pushTask;
function pushTask(value) {
Array.prototype.push.call(array, value); // copy
return resolve(value); // through
}
} | javascript | function push(array) {
return pushTask;
function pushTask(value) {
Array.prototype.push.call(array, value); // copy
return resolve(value); // through
}
} | [
"function",
"push",
"(",
"array",
")",
"{",
"return",
"pushTask",
";",
"function",
"pushTask",
"(",
"value",
")",
"{",
"Array",
".",
"prototype",
".",
"push",
".",
"call",
"(",
"array",
",",
"value",
")",
";",
"// copy",
"return",
"resolve",
"(",
"valu... | creates a promise-returning function which stores a value into the array.
@class promisen
@static
@function push
@param array {Array|Array-like}
@returns {Function} promise-returning function
@example
var promisen = require("promisen");
var stack = []; // stack is an array
var task2 = promisen(task1, promisen.push(s... | [
"creates",
"a",
"promise",
"-",
"returning",
"function",
"which",
"stores",
"a",
"value",
"into",
"the",
"array",
"."
] | 71093972cf8d3cfb8e316f48498f1aa9999f169c | https://github.com/kawanet/promisen/blob/71093972cf8d3cfb8e316f48498f1aa9999f169c/promisen.js#L543-L550 | train |
kawanet/promisen | promisen.js | pop | function pop(array) {
return popTask;
function popTask() {
var value = Array.prototype.pop.call(array);
return resolve(value);
}
} | javascript | function pop(array) {
return popTask;
function popTask() {
var value = Array.prototype.pop.call(array);
return resolve(value);
}
} | [
"function",
"pop",
"(",
"array",
")",
"{",
"return",
"popTask",
";",
"function",
"popTask",
"(",
")",
"{",
"var",
"value",
"=",
"Array",
".",
"prototype",
".",
"pop",
".",
"call",
"(",
"array",
")",
";",
"return",
"resolve",
"(",
"value",
")",
";",
... | creates a promise-returning function which fetches the last value on the array.
@class promisen
@static
@function pop
@param array {Array|Array-like}
@returns {Function} promise-returning function
@example
var promisen = require("promisen");
var stack = ["foo", "bar"]; // stack is an array
var task2 = promisen(promi... | [
"creates",
"a",
"promise",
"-",
"returning",
"function",
"which",
"fetches",
"the",
"last",
"value",
"on",
"the",
"array",
"."
] | 71093972cf8d3cfb8e316f48498f1aa9999f169c | https://github.com/kawanet/promisen/blob/71093972cf8d3cfb8e316f48498f1aa9999f169c/promisen.js#L570-L577 | train |
kawanet/promisen | promisen.js | top | function top(array) {
return topTask;
function topTask() {
var value = array[array.length - 1];
return resolve(value);
}
} | javascript | function top(array) {
return topTask;
function topTask() {
var value = array[array.length - 1];
return resolve(value);
}
} | [
"function",
"top",
"(",
"array",
")",
"{",
"return",
"topTask",
";",
"function",
"topTask",
"(",
")",
"{",
"var",
"value",
"=",
"array",
"[",
"array",
".",
"length",
"-",
"1",
"]",
";",
"return",
"resolve",
"(",
"value",
")",
";",
"}",
"}"
] | creates a promise-returning function which inspects the last value on the array.
@class promisen
@static
@function push
@param array {Array|Array-like}
@returns {Function} promise-returning function
@example
var promisen = require("promisen");
var stack = ["foo", "bar"]; // stack is an array
var task2 = promisen(pro... | [
"creates",
"a",
"promise",
"-",
"returning",
"function",
"which",
"inspects",
"the",
"last",
"value",
"on",
"the",
"array",
"."
] | 71093972cf8d3cfb8e316f48498f1aa9999f169c | https://github.com/kawanet/promisen/blob/71093972cf8d3cfb8e316f48498f1aa9999f169c/promisen.js#L597-L604 | train |
kawanet/promisen | promisen.js | wait | function wait(msec) {
return waitTask;
function waitTask(value) {
var that = this;
return new promisen.Promise(function(resolve) {
setTimeout(function() {
resolve.call(that, value);
}, msec);
});
}
} | javascript | function wait(msec) {
return waitTask;
function waitTask(value) {
var that = this;
return new promisen.Promise(function(resolve) {
setTimeout(function() {
resolve.call(that, value);
}, msec);
});
}
} | [
"function",
"wait",
"(",
"msec",
")",
"{",
"return",
"waitTask",
";",
"function",
"waitTask",
"(",
"value",
")",
"{",
"var",
"that",
"=",
"this",
";",
"return",
"new",
"promisen",
".",
"Promise",
"(",
"function",
"(",
"resolve",
")",
"{",
"setTimeout",
... | creates a promise-returning function which does just sleep for given milliseconds.
@class promisen
@static
@function wait
@param msec {Number}
@returns {Function} promise-returning function
@example
var promisen = require("promisen");
var sleep = promisen.wait(1000); // 1 sec
sleep(value).then(function(value) {...});... | [
"creates",
"a",
"promise",
"-",
"returning",
"function",
"which",
"does",
"just",
"sleep",
"for",
"given",
"milliseconds",
"."
] | 71093972cf8d3cfb8e316f48498f1aa9999f169c | https://github.com/kawanet/promisen/blob/71093972cf8d3cfb8e316f48498f1aa9999f169c/promisen.js#L686-L697 | train |
kawanet/promisen | promisen.js | throttle | function throttle(task, concurrency, timeout) {
if (!concurrency) concurrency = 1;
task = promisen(task);
var queue = singleTask.queue = [];
var running = singleTask.running = {};
var serial = 0;
return singleTask;
function singleTask(value) {
var that = this;
var args = argumen... | javascript | function throttle(task, concurrency, timeout) {
if (!concurrency) concurrency = 1;
task = promisen(task);
var queue = singleTask.queue = [];
var running = singleTask.running = {};
var serial = 0;
return singleTask;
function singleTask(value) {
var that = this;
var args = argumen... | [
"function",
"throttle",
"(",
"task",
",",
"concurrency",
",",
"timeout",
")",
"{",
"if",
"(",
"!",
"concurrency",
")",
"concurrency",
"=",
"1",
";",
"task",
"=",
"promisen",
"(",
"task",
")",
";",
"var",
"queue",
"=",
"singleTask",
".",
"queue",
"=",
... | creates a promise-returning function which limits number of concurrent job workers run in parallel.
@class promisen
@static
@function throttle
@param task {Function} the job
@param concurrency {Number} number of job workers run in parallel (default: 1)
@param timeout {Number} timeout in millisecond until job started (... | [
"creates",
"a",
"promise",
"-",
"returning",
"function",
"which",
"limits",
"number",
"of",
"concurrent",
"job",
"workers",
"run",
"in",
"parallel",
"."
] | 71093972cf8d3cfb8e316f48498f1aa9999f169c | https://github.com/kawanet/promisen/blob/71093972cf8d3cfb8e316f48498f1aa9999f169c/promisen.js#L717-L765 | 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.