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
hitchyjs/odem
index.js
mergeHooks
function mergeHooks( target, source ) { const propNames = Object.keys( source ); for ( let i = 0, numNames = propNames.length; i < numNames; i++ ) { const name = propNames[i]; let hook = source[name]; if ( typeof hook === "function" ) { hook = [hook]; } if ( !Array.isArray( hook ) ) { throw new Typ...
javascript
function mergeHooks( target, source ) { const propNames = Object.keys( source ); for ( let i = 0, numNames = propNames.length; i < numNames; i++ ) { const name = propNames[i]; let hook = source[name]; if ( typeof hook === "function" ) { hook = [hook]; } if ( !Array.isArray( hook ) ) { throw new Typ...
[ "function", "mergeHooks", "(", "target", ",", "source", ")", "{", "const", "propNames", "=", "Object", ".", "keys", "(", "source", ")", ";", "for", "(", "let", "i", "=", "0", ",", "numNames", "=", "propNames", ".", "length", ";", "i", "<", "numNames"...
Merges separately defined map of lifecycle hooks into single schema matching expectations of hitchy-odem. @param {object} target resulting schema for use with hitchy-odem @param {object<string,(function|function[])>} source maps names of lifecycle hooks into the related callback or list of callbacks @returns {void}
[ "Merges", "separately", "defined", "map", "of", "lifecycle", "hooks", "into", "single", "schema", "matching", "expectations", "of", "hitchy", "-", "odem", "." ]
28f3dc31cc3314f9109d2cac1f5f7e20dad6521b
https://github.com/hitchyjs/odem/blob/28f3dc31cc3314f9109d2cac1f5f7e20dad6521b/index.js#L148-L171
train
limin/byteof
index.js
byteof
function byteof(object){ const objects = [object] let bytes = 0; for (let index = 0; index < objects.length; index ++){ const object=objects[index] switch (typeof object){ case 'boolean': bytes += BYTES.BOOLEAN break case 'number': bytes += BYTES.NUMBER ...
javascript
function byteof(object){ const objects = [object] let bytes = 0; for (let index = 0; index < objects.length; index ++){ const object=objects[index] switch (typeof object){ case 'boolean': bytes += BYTES.BOOLEAN break case 'number': bytes += BYTES.NUMBER ...
[ "function", "byteof", "(", "object", ")", "{", "const", "objects", "=", "[", "object", "]", "let", "bytes", "=", "0", ";", "for", "(", "let", "index", "=", "0", ";", "index", "<", "objects", ".", "length", ";", "index", "++", ")", "{", "const", "...
Calculate the approximate memory usage of javascript object in bytes. @param {*} object - The object to be calcuated memory usage in bytes @returns {number} The memory usage in bytes @example // returns 8 byteof(2) // returns 8 byteof(2.0) // return 4 byteof(false) // return 2*3=6 byteof("abc") // return 32 cons...
[ "Calculate", "the", "approximate", "memory", "usage", "of", "javascript", "object", "in", "bytes", "." ]
3a6416da9e970723799bf547da6132105a73fab0
https://github.com/limin/byteof/blob/3a6416da9e970723799bf547da6132105a73fab0/index.js#L42-L74
train
colthreepv/promesso
index.js
promesso
function promesso (handler) { const handleFn = isFunction(handler) ? [handler] : handler; const middlewares = []; let validations = 0; handleFn.forEach(h => { if (!isFunction(h)) throw new Error('Handler is expected to be a function or an Array of functions.'); if (isObject(handleFn['@validation'])) {...
javascript
function promesso (handler) { const handleFn = isFunction(handler) ? [handler] : handler; const middlewares = []; let validations = 0; handleFn.forEach(h => { if (!isFunction(h)) throw new Error('Handler is expected to be a function or an Array of functions.'); if (isObject(handleFn['@validation'])) {...
[ "function", "promesso", "(", "handler", ")", "{", "const", "handleFn", "=", "isFunction", "(", "handler", ")", "?", "[", "handler", "]", ":", "handler", ";", "const", "middlewares", "=", "[", "]", ";", "let", "validations", "=", "0", ";", "handleFn", "...
promesso takes a Promise-based middleware function and converts it to a classic array of middlewares @param {Function|Function[]} handler: Promise-based Express middleware @return {Function[]} Express-compliant Array of middlewares
[ "promesso", "takes", "a", "Promise", "-", "based", "middleware", "function", "and", "converts", "it", "to", "a", "classic", "array", "of", "middlewares" ]
4076df7df42778484b1d000d1c5d4d4c01873fa6
https://github.com/colthreepv/promesso/blob/4076df7df42778484b1d000d1c5d4d4c01873fa6/index.js#L33-L50
train
colthreepv/promesso
index.js
validationMiddleware
function validationMiddleware (err, req, res, next) { if (!err instanceof ValidationError) return next(err); return res.status(err.status).send({ errors: err.errors }); }
javascript
function validationMiddleware (err, req, res, next) { if (!err instanceof ValidationError) return next(err); return res.status(err.status).send({ errors: err.errors }); }
[ "function", "validationMiddleware", "(", "err", ",", "req", ",", "res", ",", "next", ")", "{", "if", "(", "!", "err", "instanceof", "ValidationError", ")", "return", "next", "(", "err", ")", ";", "return", "res", ".", "status", "(", "err", ".", "status...
Handles thrown errors from express-validation
[ "Handles", "thrown", "errors", "from", "express", "-", "validation" ]
4076df7df42778484b1d000d1c5d4d4c01873fa6
https://github.com/colthreepv/promesso/blob/4076df7df42778484b1d000d1c5d4d4c01873fa6/index.js#L115-L118
train
wilmoore/sum.js
index.js
sum
function sum(list, fun) { fun = toString.call(fun) == '[object String]' ? selectn(fun) : fun; end = list.length; sum = -0; idx = -1; while (++idx < end) { sum += typeof fun == 'function' ? fun(list[idx]) * 1000 : list[idx] * 1000; } return sum && (sum / 1000); }
javascript
function sum(list, fun) { fun = toString.call(fun) == '[object String]' ? selectn(fun) : fun; end = list.length; sum = -0; idx = -1; while (++idx < end) { sum += typeof fun == 'function' ? fun(list[idx]) * 1000 : list[idx] * 1000; } return sum && (sum / 1000); }
[ "function", "sum", "(", "list", ",", "fun", ")", "{", "fun", "=", "toString", ".", "call", "(", "fun", ")", "==", "'[object String]'", "?", "selectn", "(", "fun", ")", ":", "fun", ";", "end", "=", "list", ".", "length", ";", "sum", "=", "-", "0",...
Returns the sum of a list supporting number literals, nested objects, or transformation function. #### Number literals sum([1, 2, 3, 4]) //=> 10 #### Nested object properties var strings = [ 'literal', 'constructor' ]; sum(strings, 'length'); //=> 18 #### Custom function sum([1, 2, 3, 4], function (n) { n * 60 })...
[ "Returns", "the", "sum", "of", "a", "list", "supporting", "number", "literals", "nested", "objects", "or", "transformation", "function", "." ]
23630999bf8b2c4d33bb6acef6387f8597ad3a85
https://github.com/wilmoore/sum.js/blob/23630999bf8b2c4d33bb6acef6387f8597ad3a85/index.js#L37-L48
train
jrgns/node_stream_handler
node_stream_handler.js
StreamHandler
function StreamHandler(host, port, delimiter) { events.EventEmitter.call(this); var self = this; self.delimiter = delimiter || "\r\n"; self.host = host; self.port = port; self.buffer = ''; self.conn = net.createConnection(self.port, self.host); self.conn.setEncoding("utf8"); self.conn.on('erro...
javascript
function StreamHandler(host, port, delimiter) { events.EventEmitter.call(this); var self = this; self.delimiter = delimiter || "\r\n"; self.host = host; self.port = port; self.buffer = ''; self.conn = net.createConnection(self.port, self.host); self.conn.setEncoding("utf8"); self.conn.on('erro...
[ "function", "StreamHandler", "(", "host", ",", "port", ",", "delimiter", ")", "{", "events", ".", "EventEmitter", ".", "call", "(", "this", ")", ";", "var", "self", "=", "this", ";", "self", ".", "delimiter", "=", "delimiter", "||", "\"\\r\\n\"", ";", ...
Consume data until you get a new line, emit a line event, clean buffer, rinse, repeat
[ "Consume", "data", "until", "you", "get", "a", "new", "line", "emit", "a", "line", "event", "clean", "buffer", "rinse", "repeat" ]
3962e6ee1fcf46bc71231ab606627eccd06ebff5
https://github.com/jrgns/node_stream_handler/blob/3962e6ee1fcf46bc71231ab606627eccd06ebff5/node_stream_handler.js#L11-L51
train
tanepiper/nell
lib/generate/load_items.js
function(file, file_done) { var item = {}; item.file_path = path.join(nell_site[type_path_key], file); item.file_output = generateOutputDetails(nell_site, file, type); item.link = item.file_output.link_path; var processContent = concat(function(err, file_content_raw) { if (err) { retu...
javascript
function(file, file_done) { var item = {}; item.file_path = path.join(nell_site[type_path_key], file); item.file_output = generateOutputDetails(nell_site, file, type); item.link = item.file_output.link_path; var processContent = concat(function(err, file_content_raw) { if (err) { retu...
[ "function", "(", "file", ",", "file_done", ")", "{", "var", "item", "=", "{", "}", ";", "item", ".", "file_path", "=", "path", ".", "join", "(", "nell_site", "[", "type_path_key", "]", ",", "file", ")", ";", "item", ".", "file_output", "=", "generate...
Function to process each item
[ "Function", "to", "process", "each", "item" ]
ecceaf63e8d685e08081e2d5f5fb85e71b17a037
https://github.com/tanepiper/nell/blob/ecceaf63e8d685e08081e2d5f5fb85e71b17a037/lib/generate/load_items.js#L32-L60
train
AlphaReplica/Connecta
lib/client/source/connectaSocket.js
connect
function connect() { if(scope._conn) { if(scope._conn.readyState === 1) { return; } scope._conn.close(); } var url = (scope._redirectURL.length>0) ? scope._redirectURL : scope._url; scope._conn = new ...
javascript
function connect() { if(scope._conn) { if(scope._conn.readyState === 1) { return; } scope._conn.close(); } var url = (scope._redirectURL.length>0) ? scope._redirectURL : scope._url; scope._conn = new ...
[ "function", "connect", "(", ")", "{", "if", "(", "scope", ".", "_conn", ")", "{", "if", "(", "scope", ".", "_conn", ".", "readyState", "===", "1", ")", "{", "return", ";", "}", "scope", ".", "_conn", ".", "close", "(", ")", ";", "}", "var", "ur...
connects to server
[ "connects", "to", "server" ]
bc0ce3fa1ef5ef07526633da5668dcaff5ef29e0
https://github.com/AlphaReplica/Connecta/blob/bc0ce3fa1ef5ef07526633da5668dcaff5ef29e0/lib/client/source/connectaSocket.js#L31-L49
train
AlphaReplica/Connecta
lib/client/source/connectaSocket.js
onArrayBuffer
function onArrayBuffer(data) { var arr = bufferToArray(scope.byteType,data); if(arr) { if(arr[arr.length-1] == MessageType.RTC_FAIL && scope.rtcFallback == true && scope.useRTC == true) { if(scope.onRTCFallback) { ...
javascript
function onArrayBuffer(data) { var arr = bufferToArray(scope.byteType,data); if(arr) { if(arr[arr.length-1] == MessageType.RTC_FAIL && scope.rtcFallback == true && scope.useRTC == true) { if(scope.onRTCFallback) { ...
[ "function", "onArrayBuffer", "(", "data", ")", "{", "var", "arr", "=", "bufferToArray", "(", "scope", ".", "byteType", ",", "data", ")", ";", "if", "(", "arr", ")", "{", "if", "(", "arr", "[", "arr", ".", "length", "-", "1", "]", "==", "MessageType...
server message callback for bytebuffer message
[ "server", "message", "callback", "for", "bytebuffer", "message" ]
bc0ce3fa1ef5ef07526633da5668dcaff5ef29e0
https://github.com/AlphaReplica/Connecta/blob/bc0ce3fa1ef5ef07526633da5668dcaff5ef29e0/lib/client/source/connectaSocket.js#L95-L116
train
AlphaReplica/Connecta
lib/client/source/connectaSocket.js
changeServer
function changeServer(url) { scope._redirectURL = url; if(scope._conn) { scope._conn.onopen = null; scope._conn.onerror = null; scope._conn.onclose = null; scope._conn.onmessage = null; scope._conn.close(); } ...
javascript
function changeServer(url) { scope._redirectURL = url; if(scope._conn) { scope._conn.onopen = null; scope._conn.onerror = null; scope._conn.onclose = null; scope._conn.onmessage = null; scope._conn.close(); } ...
[ "function", "changeServer", "(", "url", ")", "{", "scope", ".", "_redirectURL", "=", "url", ";", "if", "(", "scope", ".", "_conn", ")", "{", "scope", ".", "_conn", ".", "onopen", "=", "null", ";", "scope", ".", "_conn", ".", "onerror", "=", "null", ...
switches server by given url
[ "switches", "server", "by", "given", "url" ]
bc0ce3fa1ef5ef07526633da5668dcaff5ef29e0
https://github.com/AlphaReplica/Connecta/blob/bc0ce3fa1ef5ef07526633da5668dcaff5ef29e0/lib/client/source/connectaSocket.js#L286-L298
train
airicyu/stateful-result
src/models/exception.js
Exception
function Exception(code, message) { Error.captureStackTrace(this, Exception); this.name = Exception.name; this.code = code; this.message = message; }
javascript
function Exception(code, message) { Error.captureStackTrace(this, Exception); this.name = Exception.name; this.code = code; this.message = message; }
[ "function", "Exception", "(", "code", ",", "message", ")", "{", "Error", ".", "captureStackTrace", "(", "this", ",", "Exception", ")", ";", "this", ".", "name", "=", "Exception", ".", "name", ";", "this", ".", "code", "=", "code", ";", "this", ".", "...
Exception object. Extended from Error to support having the error code attribute. @param {integer} code @param {string} message
[ "Exception", "object", ".", "Extended", "from", "Error", "to", "support", "having", "the", "error", "code", "attribute", "." ]
d0658294587792476bed618d7489868715f15fcb
https://github.com/airicyu/stateful-result/blob/d0658294587792476bed618d7489868715f15fcb/src/models/exception.js#L13-L18
train
intervolga/bem-utils
lib/bem-dirs.js
bemDirs
function bemDirs(bemdeps) { const dirFilter = {}; bemdeps.forEach((dep) => { const depPath = bemPath(dep); const depDir = path.dirname(depPath); dirFilter[depDir] = true; }); return Object.keys(dirFilter); }
javascript
function bemDirs(bemdeps) { const dirFilter = {}; bemdeps.forEach((dep) => { const depPath = bemPath(dep); const depDir = path.dirname(depPath); dirFilter[depDir] = true; }); return Object.keys(dirFilter); }
[ "function", "bemDirs", "(", "bemdeps", ")", "{", "const", "dirFilter", "=", "{", "}", ";", "bemdeps", ".", "forEach", "(", "(", "dep", ")", "=>", "{", "const", "depPath", "=", "bemPath", "(", "dep", ")", ";", "const", "depDir", "=", "path", ".", "d...
Convert BemDeps to directory names @param {Array} bemdeps @return {Array}
[ "Convert", "BemDeps", "to", "directory", "names" ]
3b81bb9bc408275486175326dc7f35c563a46563
https://github.com/intervolga/bem-utils/blob/3b81bb9bc408275486175326dc7f35c563a46563/lib/bem-dirs.js#L10-L19
train
skylarkutils/skylark-utils
dist/uncompressed/skylark-utils/models.js
function(options) { options = langx.mixin({parse: true}, options); var entity = this; var success = options.success; options.success = function(resp) { var serverAttrs = options.parse ? entity.parse(resp, options) : resp; if (!entity.set(serverAttrs, options)) return false; ...
javascript
function(options) { options = langx.mixin({parse: true}, options); var entity = this; var success = options.success; options.success = function(resp) { var serverAttrs = options.parse ? entity.parse(resp, options) : resp; if (!entity.set(serverAttrs, options)) return false; ...
[ "function", "(", "options", ")", "{", "options", "=", "langx", ".", "mixin", "(", "{", "parse", ":", "true", "}", ",", "options", ")", ";", "var", "entity", "=", "this", ";", "var", "success", "=", "options", ".", "success", ";", "options", ".", "s...
Fetch the entity from the server, merging the response with the entity's local attributes. Any changed attributes will trigger a "change" event.
[ "Fetch", "the", "entity", "from", "the", "server", "merging", "the", "response", "with", "the", "entity", "s", "local", "attributes", ".", "Any", "changed", "attributes", "will", "trigger", "a", "change", "event", "." ]
ef082bb53b162b4a2c6992ef07a3e32553f6aed5
https://github.com/skylarkutils/skylark-utils/blob/ef082bb53b162b4a2c6992ef07a3e32553f6aed5/dist/uncompressed/skylark-utils/models.js#L94-L106
train
skylarkutils/skylark-utils
dist/uncompressed/skylark-utils/models.js
function(entities, options) { return this.set(entities, langx.mixin({merge: false}, options, addOptions)); }
javascript
function(entities, options) { return this.set(entities, langx.mixin({merge: false}, options, addOptions)); }
[ "function", "(", "entities", ",", "options", ")", "{", "return", "this", ".", "set", "(", "entities", ",", "langx", ".", "mixin", "(", "{", "merge", ":", "false", "}", ",", "options", ",", "addOptions", ")", ")", ";", "}" ]
Add a entity, or list of entities to the set. `entities` may be Backbone Entitys or raw JavaScript objects to be converted to Entitys, or any combination of the two.
[ "Add", "a", "entity", "or", "list", "of", "entities", "to", "the", "set", ".", "entities", "may", "be", "Backbone", "Entitys", "or", "raw", "JavaScript", "objects", "to", "be", "converted", "to", "Entitys", "or", "any", "combination", "of", "the", "two", ...
ef082bb53b162b4a2c6992ef07a3e32553f6aed5
https://github.com/skylarkutils/skylark-utils/blob/ef082bb53b162b4a2c6992ef07a3e32553f6aed5/dist/uncompressed/skylark-utils/models.js#L263-L265
train
skylarkutils/skylark-utils
dist/uncompressed/skylark-utils/models.js
function(entities, options) { options = langx.mixin({}, options); var singular = !langx.isArray(entities); entities = singular ? [entities] : entities.slice(); var removed = this._removeEntitys(entities, options); if (!options.silent && removed.length) { options.changes = {added: [...
javascript
function(entities, options) { options = langx.mixin({}, options); var singular = !langx.isArray(entities); entities = singular ? [entities] : entities.slice(); var removed = this._removeEntitys(entities, options); if (!options.silent && removed.length) { options.changes = {added: [...
[ "function", "(", "entities", ",", "options", ")", "{", "options", "=", "langx", ".", "mixin", "(", "{", "}", ",", "options", ")", ";", "var", "singular", "=", "!", "langx", ".", "isArray", "(", "entities", ")", ";", "entities", "=", "singular", "?", ...
Remove a entity, or a list of entities from the set.
[ "Remove", "a", "entity", "or", "a", "list", "of", "entities", "from", "the", "set", "." ]
ef082bb53b162b4a2c6992ef07a3e32553f6aed5
https://github.com/skylarkutils/skylark-utils/blob/ef082bb53b162b4a2c6992ef07a3e32553f6aed5/dist/uncompressed/skylark-utils/models.js#L268-L278
train
skylarkutils/skylark-utils
dist/uncompressed/skylark-utils/models.js
function(entities, options) { options = options ? langx.clone(options) : {}; for (var i = 0; i < this.entities.length; i++) { this._removeReference(this.entities[i], options); } options.previousEntitys = this.entities; this._reset(); entities = this.add(entities, langx.mixin(...
javascript
function(entities, options) { options = options ? langx.clone(options) : {}; for (var i = 0; i < this.entities.length; i++) { this._removeReference(this.entities[i], options); } options.previousEntitys = this.entities; this._reset(); entities = this.add(entities, langx.mixin(...
[ "function", "(", "entities", ",", "options", ")", "{", "options", "=", "options", "?", "langx", ".", "clone", "(", "options", ")", ":", "{", "}", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "this", ".", "entities", ".", "length", ";", ...
When you have more items than you want to add or remove individually, you can reset the entire set with a new list of entities, without firing any granular `add` or `remove` events. Fires `reset` when finished. Useful for bulk operations and optimizations.
[ "When", "you", "have", "more", "items", "than", "you", "want", "to", "add", "or", "remove", "individually", "you", "can", "reset", "the", "entire", "set", "with", "a", "new", "list", "of", "entities", "without", "firing", "any", "granular", "add", "or", ...
ef082bb53b162b4a2c6992ef07a3e32553f6aed5
https://github.com/skylarkutils/skylark-utils/blob/ef082bb53b162b4a2c6992ef07a3e32553f6aed5/dist/uncompressed/skylark-utils/models.js#L403-L413
train
skylarkutils/skylark-utils
dist/uncompressed/skylark-utils/models.js
function(obj) { if (obj == null) return void 0; return this._byId[obj] || this._byId[this.entityId(obj.attributes || obj)] || obj.cid && this._byId[obj.cid]; }
javascript
function(obj) { if (obj == null) return void 0; return this._byId[obj] || this._byId[this.entityId(obj.attributes || obj)] || obj.cid && this._byId[obj.cid]; }
[ "function", "(", "obj", ")", "{", "if", "(", "obj", "==", "null", ")", "return", "void", "0", ";", "return", "this", ".", "_byId", "[", "obj", "]", "||", "this", ".", "_byId", "[", "this", ".", "entityId", "(", "obj", ".", "attributes", "||", "ob...
Get a entity from the set by id, cid, entity object with id or cid properties, or an attributes object that is transformed through entityId.
[ "Get", "a", "entity", "from", "the", "set", "by", "id", "cid", "entity", "object", "with", "id", "or", "cid", "properties", "or", "an", "attributes", "object", "that", "is", "transformed", "through", "entityId", "." ]
ef082bb53b162b4a2c6992ef07a3e32553f6aed5
https://github.com/skylarkutils/skylark-utils/blob/ef082bb53b162b4a2c6992ef07a3e32553f6aed5/dist/uncompressed/skylark-utils/models.js#L444-L449
train
skylarkutils/skylark-utils
dist/uncompressed/skylark-utils/models.js
function(entity, options) { this._byId[entity.cid] = entity; var id = this.entityId(entity.attributes); if (id != null) this._byId[id] = entity; entity.on('all', this._onEntityEvent, this); }
javascript
function(entity, options) { this._byId[entity.cid] = entity; var id = this.entityId(entity.attributes); if (id != null) this._byId[id] = entity; entity.on('all', this._onEntityEvent, this); }
[ "function", "(", "entity", ",", "options", ")", "{", "this", ".", "_byId", "[", "entity", ".", "cid", "]", "=", "entity", ";", "var", "id", "=", "this", ".", "entityId", "(", "entity", ".", "attributes", ")", ";", "if", "(", "id", "!=", "null", "...
Internal method to create a entity's ties to a collection.
[ "Internal", "method", "to", "create", "a", "entity", "s", "ties", "to", "a", "collection", "." ]
ef082bb53b162b4a2c6992ef07a3e32553f6aed5
https://github.com/skylarkutils/skylark-utils/blob/ef082bb53b162b4a2c6992ef07a3e32553f6aed5/dist/uncompressed/skylark-utils/models.js#L613-L618
train
skylarkutils/skylark-utils
dist/uncompressed/skylark-utils/models.js
function(entity, options) { delete this._byId[entity.cid]; var id = this.entityId(entity.attributes); if (id != null) delete this._byId[id]; if (this === entity.collection) delete entity.collection; entity.off('all', this._onEntityEvent, this); }
javascript
function(entity, options) { delete this._byId[entity.cid]; var id = this.entityId(entity.attributes); if (id != null) delete this._byId[id]; if (this === entity.collection) delete entity.collection; entity.off('all', this._onEntityEvent, this); }
[ "function", "(", "entity", ",", "options", ")", "{", "delete", "this", ".", "_byId", "[", "entity", ".", "cid", "]", ";", "var", "id", "=", "this", ".", "entityId", "(", "entity", ".", "attributes", ")", ";", "if", "(", "id", "!=", "null", ")", "...
Internal method to sever a entity's ties to a collection.
[ "Internal", "method", "to", "sever", "a", "entity", "s", "ties", "to", "a", "collection", "." ]
ef082bb53b162b4a2c6992ef07a3e32553f6aed5
https://github.com/skylarkutils/skylark-utils/blob/ef082bb53b162b4a2c6992ef07a3e32553f6aed5/dist/uncompressed/skylark-utils/models.js#L621-L627
train
skylarkutils/skylark-utils
dist/uncompressed/skylark-utils/models.js
function(event, entity, collection, options) { if (entity) { if ((event === 'add' || event === 'remove') && collection !== this) return; if (event === 'destroy') this.remove(entity, options); if (event === 'change') { var prevId = this.entityId(entity.previousAttributes()); ...
javascript
function(event, entity, collection, options) { if (entity) { if ((event === 'add' || event === 'remove') && collection !== this) return; if (event === 'destroy') this.remove(entity, options); if (event === 'change') { var prevId = this.entityId(entity.previousAttributes()); ...
[ "function", "(", "event", ",", "entity", ",", "collection", ",", "options", ")", "{", "if", "(", "entity", ")", "{", "if", "(", "(", "event", "===", "'add'", "||", "event", "===", "'remove'", ")", "&&", "collection", "!==", "this", ")", "return", ";"...
Internal method called every time a entity in the set fires an event. Sets need to update their indexes when entities change ids. All other events simply proxy through. "add" and "remove" events that originate in other collections are ignored.
[ "Internal", "method", "called", "every", "time", "a", "entity", "in", "the", "set", "fires", "an", "event", ".", "Sets", "need", "to", "update", "their", "indexes", "when", "entities", "change", "ids", ".", "All", "other", "events", "simply", "proxy", "thr...
ef082bb53b162b4a2c6992ef07a3e32553f6aed5
https://github.com/skylarkutils/skylark-utils/blob/ef082bb53b162b4a2c6992ef07a3e32553f6aed5/dist/uncompressed/skylark-utils/models.js#L633-L647
train
tgi-io/tgi-store-remote
lib/tgi-store-host.source.js
function (args) { //console.log('PutModel messageContents: json ' + JSON.stringify(messageContents)); Model.call(this, args); this.modelType = messageContents.modelType; this.attributes = []; var a, attrib, v; for (a in messageContents.attributes) { //console.log('PutModel Attribute: json...
javascript
function (args) { //console.log('PutModel messageContents: json ' + JSON.stringify(messageContents)); Model.call(this, args); this.modelType = messageContents.modelType; this.attributes = []; var a, attrib, v; for (a in messageContents.attributes) { //console.log('PutModel Attribute: json...
[ "function", "(", "args", ")", "{", "//console.log('PutModel messageContents: json ' + JSON.stringify(messageContents));", "Model", ".", "call", "(", "this", ",", "args", ")", ";", "this", ".", "modelType", "=", "messageContents", ".", "modelType", ";", "this", ".", ...
create proxy for client model
[ "create", "proxy", "for", "client", "model" ]
8c143c0bbd97c29fe7b12ce2501f6a2602eb71ad
https://github.com/tgi-io/tgi-store-remote/blob/8c143c0bbd97c29fe7b12ce2501f6a2602eb71ad/lib/tgi-store-host.source.js#L7-L39
train
jpommerening/node-markdown-bdd
index.js
containedInOrder
function containedInOrder(needle, haystack) { var i, j = 0; for (i = 0; i < needle.length; i++) { while (j < haystack.length && needle[i] !== haystack[j]) j++; } return i === needle.length && j < haystack.length; }
javascript
function containedInOrder(needle, haystack) { var i, j = 0; for (i = 0; i < needle.length; i++) { while (j < haystack.length && needle[i] !== haystack[j]) j++; } return i === needle.length && j < haystack.length; }
[ "function", "containedInOrder", "(", "needle", ",", "haystack", ")", "{", "var", "i", ",", "j", "=", "0", ";", "for", "(", "i", "=", "0", ";", "i", "<", "needle", ".", "length", ";", "i", "++", ")", "{", "while", "(", "j", "<", "haystack", ".",...
Test that each item in needle is contained in haystack in the right order.
[ "Test", "that", "each", "item", "in", "needle", "is", "contained", "in", "haystack", "in", "the", "right", "order", "." ]
44739151903dd472dbfa74b3479e2c7ab9682616
https://github.com/jpommerening/node-markdown-bdd/blob/44739151903dd472dbfa74b3479e2c7ab9682616/index.js#L8-L14
train
IonicaBizau/node-package-dependents
lib/index.js
PackageDependents
function PackageDependents(name, version, callback) { if (typeof version === "function") { callback = version version = "latest" } GetDependents(name, function(err, packages) { if (err) { return callback(err) } SameTime(packages.map(function (c) { return function ...
javascript
function PackageDependents(name, version, callback) { if (typeof version === "function") { callback = version version = "latest" } GetDependents(name, function(err, packages) { if (err) { return callback(err) } SameTime(packages.map(function (c) { return function ...
[ "function", "PackageDependents", "(", "name", ",", "version", ",", "callback", ")", "{", "if", "(", "typeof", "version", "===", "\"function\"", ")", "{", "callback", "=", "version", "version", "=", "\"latest\"", "}", "GetDependents", "(", "name", ",", "funct...
PackageDependents Get the dependents of a given packages. The callback function is called with an error and an array of objects. @name PackageDependents @function @param {String} name The package name. @param {String} version The package version (default: `"latest"`). @param {Function} callback The callback function.
[ "PackageDependents", "Get", "the", "dependents", "of", "a", "given", "packages", ".", "The", "callback", "function", "is", "called", "with", "an", "error", "and", "an", "array", "of", "objects", "." ]
e49accbbe767cb81721d9db1063b690c19c5eb48
https://github.com/IonicaBizau/node-package-dependents/blob/e49accbbe767cb81721d9db1063b690c19c5eb48/lib/index.js#L18-L37
train
hl198181/neptune
misc/demo/public/vendor/angular-form-for/form-for.js
function () { if (!filterText) { var filterTextSelector = $element.find('input'); if (filterTextSelector.length) { filterText = filterTextSelector[0]; } } if (filterText) { ...
javascript
function () { if (!filterText) { var filterTextSelector = $element.find('input'); if (filterTextSelector.length) { filterText = filterTextSelector[0]; } } if (filterText) { ...
[ "function", "(", ")", "{", "if", "(", "!", "filterText", ")", "{", "var", "filterTextSelector", "=", "$element", ".", "find", "(", "'input'", ")", ";", "if", "(", "filterTextSelector", ".", "length", ")", "{", "filterText", "=", "filterTextSelector", "[", ...
Helper method for setting focus on an item after a delay
[ "Helper", "method", "for", "setting", "focus", "on", "an", "item", "after", "a", "delay" ]
88030bb4222945900e6a225469380cc43a016c13
https://github.com/hl198181/neptune/blob/88030bb4222945900e6a225469380cc43a016c13/misc/demo/public/vendor/angular-form-for/form-for.js#L2109-L2119
train
JoniDB/trumpygrimm
index.js
newMarkov
function newMarkov() { var options = { maxLength: 140, minWords: 10, minScore: 20, }; //new instance markov = new Markov(data, options); console.log(markov); var markovStrings = []; // Build the corpus markov.buildCorpus(); }
javascript
function newMarkov() { var options = { maxLength: 140, minWords: 10, minScore: 20, }; //new instance markov = new Markov(data, options); console.log(markov); var markovStrings = []; // Build the corpus markov.buildCorpus(); }
[ "function", "newMarkov", "(", ")", "{", "var", "options", "=", "{", "maxLength", ":", "140", ",", "minWords", ":", "10", ",", "minScore", ":", "20", ",", "}", ";", "//new instance", "markov", "=", "new", "Markov", "(", "data", ",", "options", ")", ";...
Some options to generate Twitter-ready strings
[ "Some", "options", "to", "generate", "Twitter", "-", "ready", "strings" ]
f3564dd4709a02d77f0726988fb43e473d024fe4
https://github.com/JoniDB/trumpygrimm/blob/f3564dd4709a02d77f0726988fb43e473d024fe4/index.js#L79-L93
train
novemberborn/thenstream
lib/Thenstream.js
onReadable
function onReadable() { if (self._assimilationState.waiting) { self._assimilationState.waiting = false; self._pushChunks(); } }
javascript
function onReadable() { if (self._assimilationState.waiting) { self._assimilationState.waiting = false; self._pushChunks(); } }
[ "function", "onReadable", "(", ")", "{", "if", "(", "self", ".", "_assimilationState", ".", "waiting", ")", "{", "self", ".", "_assimilationState", ".", "waiting", "=", "false", ";", "self", ".", "_pushChunks", "(", ")", ";", "}", "}" ]
Push more chunks when data becomes available.
[ "Push", "more", "chunks", "when", "data", "becomes", "available", "." ]
57499b6e35d7ecc10662d9080a227be726b11b19
https://github.com/novemberborn/thenstream/blob/57499b6e35d7ecc10662d9080a227be726b11b19/lib/Thenstream.js#L129-L134
train
airosa/sdmxmllib
samples/sdmxmlmap/js/sdmxmlmap.js
function () { if (req.status !== 200) { console.warn(req.responseText); return; } // Show the raw response text on page xmlOutput.textContent = req.responseText; // convert XML to javascript objects var json = sdmxmllib.mapSDMXMLResponse(req.responseTe...
javascript
function () { if (req.status !== 200) { console.warn(req.responseText); return; } // Show the raw response text on page xmlOutput.textContent = req.responseText; // convert XML to javascript objects var json = sdmxmllib.mapSDMXMLResponse(req.responseTe...
[ "function", "(", ")", "{", "if", "(", "req", ".", "status", "!==", "200", ")", "{", "console", ".", "warn", "(", "req", ".", "responseText", ")", ";", "return", ";", "}", "// Show the raw response text on page", "xmlOutput", ".", "textContent", "=", "req",...
Response handler. Check the console for errors.
[ "Response", "handler", ".", "Check", "the", "console", "for", "errors", "." ]
27e1e41a60dcc383ac06edafda6f37fbfed71d83
https://github.com/airosa/sdmxmllib/blob/27e1e41a60dcc383ac06edafda6f37fbfed71d83/samples/sdmxmlmap/js/sdmxmlmap.js#L14-L25
train
tungtung-dev/common-helper
src/object/index.js
convertData
function convertData(objectBody, objectChange) { const keysChange = Object.keys(objectChange); let objectReturn = {}; keysChange.map(keyChange => { let changeOption = objectChange[keyChange]; let valueKeyReturn = getValueChangeOption(objectBody, keyChange, changeOption, objectReturn); ...
javascript
function convertData(objectBody, objectChange) { const keysChange = Object.keys(objectChange); let objectReturn = {}; keysChange.map(keyChange => { let changeOption = objectChange[keyChange]; let valueKeyReturn = getValueChangeOption(objectBody, keyChange, changeOption, objectReturn); ...
[ "function", "convertData", "(", "objectBody", ",", "objectChange", ")", "{", "const", "keysChange", "=", "Object", ".", "keys", "(", "objectChange", ")", ";", "let", "objectReturn", "=", "{", "}", ";", "keysChange", ".", "map", "(", "keyChange", "=>", "{",...
Parse body Object to data Object @param objectBody @param objectChange @returns {{}}
[ "Parse", "body", "Object", "to", "data", "Object" ]
94abeff34fee3b2366b308571e94f2da8b0db655
https://github.com/tungtung-dev/common-helper/blob/94abeff34fee3b2366b308571e94f2da8b0db655/src/object/index.js#L32-L44
train
sourdough-css/preprocessor
lib/index.js
cssToSss
function cssToSss (css, file) { if (path.extname(file) === '.css') { return postcss().process(css, { stringifier: sugarss }).then(function (result) { return result.css }) } else { return css } }
javascript
function cssToSss (css, file) { if (path.extname(file) === '.css') { return postcss().process(css, { stringifier: sugarss }).then(function (result) { return result.css }) } else { return css } }
[ "function", "cssToSss", "(", "css", ",", "file", ")", "{", "if", "(", "path", ".", "extname", "(", "file", ")", "===", "'.css'", ")", "{", "return", "postcss", "(", ")", ".", "process", "(", "css", ",", "{", "stringifier", ":", "sugarss", "}", ")",...
Transform .css files to sss syntax
[ "Transform", ".", "css", "files", "to", "sss", "syntax" ]
d065000ac3c7c31524058793409de2f78a092d04
https://github.com/sourdough-css/preprocessor/blob/d065000ac3c7c31524058793409de2f78a092d04/lib/index.js#L51-L59
train
odentools/denhub-device
scripts/generator.js
generateCode
function generateCode (config, is_all_yes) { console.log(colors.bold('--------------- Code Generator ---------------\n')); // Check the configuration if (!config.commands) { throw new Error('commands undefined in your config.js'); } // Start the processes var entry_js = null, handler_js = null, package_json ...
javascript
function generateCode (config, is_all_yes) { console.log(colors.bold('--------------- Code Generator ---------------\n')); // Check the configuration if (!config.commands) { throw new Error('commands undefined in your config.js'); } // Start the processes var entry_js = null, handler_js = null, package_json ...
[ "function", "generateCode", "(", "config", ",", "is_all_yes", ")", "{", "console", ".", "log", "(", "colors", ".", "bold", "(", "'--------------- Code Generator ---------------\\n'", ")", ")", ";", "// Check the configuration", "if", "(", "!", "config", ".", "comm...
Generate the source code for device daemon @param {Object} config Device configuration @param {Boolea} is_all_yes Whether the response will choose yes automatically
[ "Generate", "the", "source", "code", "for", "device", "daemon" ]
50d35aca96db3a07a3272f1765a660ea893735ce
https://github.com/odentools/denhub-device/blob/50d35aca96db3a07a3272f1765a660ea893735ce/scripts/generator.js#L254-L421
train
odentools/denhub-device
scripts/generator.js
generateCodeEntryJs
function generateCodeEntryJs (config) { // Read the entry point script var entry_js = null; try { // Read from current script entry_js = fs.readFileSync(ENTRY_POINT_FILENAME).toString(); } catch (e) { // Read from template script entry_js = fs.readFileSync(__dirname + '/../templates/' + ENTRY_POINT_FILENAM...
javascript
function generateCodeEntryJs (config) { // Read the entry point script var entry_js = null; try { // Read from current script entry_js = fs.readFileSync(ENTRY_POINT_FILENAME).toString(); } catch (e) { // Read from template script entry_js = fs.readFileSync(__dirname + '/../templates/' + ENTRY_POINT_FILENAM...
[ "function", "generateCodeEntryJs", "(", "config", ")", "{", "// Read the entry point script", "var", "entry_js", "=", "null", ";", "try", "{", "// Read from current script", "entry_js", "=", "fs", ".", "readFileSync", "(", "ENTRY_POINT_FILENAME", ")", ".", "toString",...
Generate the source code for entory point @param {Object} config Device configuration @return {String} Source code
[ "Generate", "the", "source", "code", "for", "entory", "point" ]
50d35aca96db3a07a3272f1765a660ea893735ce
https://github.com/odentools/denhub-device/blob/50d35aca96db3a07a3272f1765a660ea893735ce/scripts/generator.js#L429-L443
train
odentools/denhub-device
scripts/generator.js
generateCodeHandlerJs
function generateCodeHandlerJs (config) { // Read the handler script var handler_js = null; try { // Read from current script handler_js = fs.readFileSync(HANDLER_FILENAME).toString(); } catch (e) { // Read from template script handler_js = fs.readFileSync(__dirname + '/../templates/' + HANDLER_FILENAME + ...
javascript
function generateCodeHandlerJs (config) { // Read the handler script var handler_js = null; try { // Read from current script handler_js = fs.readFileSync(HANDLER_FILENAME).toString(); } catch (e) { // Read from template script handler_js = fs.readFileSync(__dirname + '/../templates/' + HANDLER_FILENAME + ...
[ "function", "generateCodeHandlerJs", "(", "config", ")", "{", "// Read the handler script", "var", "handler_js", "=", "null", ";", "try", "{", "// Read from current script", "handler_js", "=", "fs", ".", "readFileSync", "(", "HANDLER_FILENAME", ")", ".", "toString", ...
Generate the source code for commands handler @param {Object} config Device configuration @return {String} Source code
[ "Generate", "the", "source", "code", "for", "commands", "handler" ]
50d35aca96db3a07a3272f1765a660ea893735ce
https://github.com/odentools/denhub-device/blob/50d35aca96db3a07a3272f1765a660ea893735ce/scripts/generator.js#L451-L539
train
odentools/denhub-device
scripts/generator.js
generatePackageJson
function generatePackageJson (config) { // Read the user's package.json var user_file; try { // Read from current file user_file = fs.readFileSync('./package.json').toString(); } catch (e) { user_file = null; } // Parse the user's package.json var user_json = null; if (user_file) { try { user_json ...
javascript
function generatePackageJson (config) { // Read the user's package.json var user_file; try { // Read from current file user_file = fs.readFileSync('./package.json').toString(); } catch (e) { user_file = null; } // Parse the user's package.json var user_json = null; if (user_file) { try { user_json ...
[ "function", "generatePackageJson", "(", "config", ")", "{", "// Read the user's package.json", "var", "user_file", ";", "try", "{", "// Read from current file", "user_file", "=", "fs", ".", "readFileSync", "(", "'./package.json'", ")", ".", "toString", "(", ")", ";"...
Generate the package.json @param {Object} config Device configuration @return {String} JSON code
[ "Generate", "the", "package", ".", "json" ]
50d35aca96db3a07a3272f1765a660ea893735ce
https://github.com/odentools/denhub-device/blob/50d35aca96db3a07a3272f1765a660ea893735ce/scripts/generator.js#L547-L605
train
odentools/denhub-device
scripts/generator.js
execDependencyInstall
function execDependencyInstall () { console.log('\nExecuting npm install command...'); return new Promise(function(resolve, reject){ var child = require('child_process').spawn('npm', ['install'], { cwd: process.cwd, detached: false, env: process.env, stdio: [process.stdin, process.stdout, process.std...
javascript
function execDependencyInstall () { console.log('\nExecuting npm install command...'); return new Promise(function(resolve, reject){ var child = require('child_process').spawn('npm', ['install'], { cwd: process.cwd, detached: false, env: process.env, stdio: [process.stdin, process.stdout, process.std...
[ "function", "execDependencyInstall", "(", ")", "{", "console", ".", "log", "(", "'\\nExecuting npm install command...'", ")", ";", "return", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "var", "child", "=", "require", "(", "'chil...
Install the dependency modules with using npm command @return {Boolean} Whether the install has been successful
[ "Install", "the", "dependency", "modules", "with", "using", "npm", "command" ]
50d35aca96db3a07a3272f1765a660ea893735ce
https://github.com/odentools/denhub-device/blob/50d35aca96db3a07a3272f1765a660ea893735ce/scripts/generator.js#L612-L642
train
odentools/denhub-device
scripts/generator.js
startCmdEditor
function startCmdEditor (config, is_skip_header) { if (!is_skip_header) { console.log(colors.bold('--------------- Command Editor ---------------')); } // Show a prompt for choose the mode var promise = inquirer.prompt([{ type: 'list', name: 'mode', message: 'What you want to do ?', choices: [ 'Show ...
javascript
function startCmdEditor (config, is_skip_header) { if (!is_skip_header) { console.log(colors.bold('--------------- Command Editor ---------------')); } // Show a prompt for choose the mode var promise = inquirer.prompt([{ type: 'list', name: 'mode', message: 'What you want to do ?', choices: [ 'Show ...
[ "function", "startCmdEditor", "(", "config", ",", "is_skip_header", ")", "{", "if", "(", "!", "is_skip_header", ")", "{", "console", ".", "log", "(", "colors", ".", "bold", "(", "'--------------- Command Editor ---------------'", ")", ")", ";", "}", "// Show a p...
Start the command editor @param {Object} config Current configuration @param {Boolean} is_skip_header Whether the header should be skipped
[ "Start", "the", "command", "editor" ]
50d35aca96db3a07a3272f1765a660ea893735ce
https://github.com/odentools/denhub-device/blob/50d35aca96db3a07a3272f1765a660ea893735ce/scripts/generator.js#L650-L692
train
odentools/denhub-device
scripts/generator.js
showCommandsOnCmdEditor
function showCommandsOnCmdEditor (config) { console.log(colors.bold('\nAvailable Commands for ' + config.deviceName + ':\n')); // Iterate the each commands var commands = config.commands || {}; if (Object.keys(commands).length == 0) { console.log ('\nThere is no command.'); } else { for (var name in commands...
javascript
function showCommandsOnCmdEditor (config) { console.log(colors.bold('\nAvailable Commands for ' + config.deviceName + ':\n')); // Iterate the each commands var commands = config.commands || {}; if (Object.keys(commands).length == 0) { console.log ('\nThere is no command.'); } else { for (var name in commands...
[ "function", "showCommandsOnCmdEditor", "(", "config", ")", "{", "console", ".", "log", "(", "colors", ".", "bold", "(", "'\\nAvailable Commands for '", "+", "config", ".", "deviceName", "+", "':\\n'", ")", ")", ";", "// Iterate the each commands", "var", "commands...
Command Editor - Show a list of the commands @param {Object} config Current configuration @return {Promise}
[ "Command", "Editor", "-", "Show", "a", "list", "of", "the", "commands" ]
50d35aca96db3a07a3272f1765a660ea893735ce
https://github.com/odentools/denhub-device/blob/50d35aca96db3a07a3272f1765a660ea893735ce/scripts/generator.js#L700-L734
train
odentools/denhub-device
scripts/generator.js
addCommandOnCmdEditor
function addCommandOnCmdEditor (config) { var cmd_name = null; var promise = inquirer.prompt([{ type: 'input', name: 'cmdName', message: 'What is name of a command (e.g. setMotorPower) ?', validate: function (value) { if (value.length == 0) return true; if (config.commands[value] != null) return 'This...
javascript
function addCommandOnCmdEditor (config) { var cmd_name = null; var promise = inquirer.prompt([{ type: 'input', name: 'cmdName', message: 'What is name of a command (e.g. setMotorPower) ?', validate: function (value) { if (value.length == 0) return true; if (config.commands[value] != null) return 'This...
[ "function", "addCommandOnCmdEditor", "(", "config", ")", "{", "var", "cmd_name", "=", "null", ";", "var", "promise", "=", "inquirer", ".", "prompt", "(", "[", "{", "type", ":", "'input'", ",", "name", ":", "'cmdName'", ",", "message", ":", "'What is name o...
Command Editor - Add a command @param {Object} config Current configuration @return {Promise}
[ "Command", "Editor", "-", "Add", "a", "command" ]
50d35aca96db3a07a3272f1765a660ea893735ce
https://github.com/odentools/denhub-device/blob/50d35aca96db3a07a3272f1765a660ea893735ce/scripts/generator.js#L742-L795
train
odentools/denhub-device
scripts/generator.js
deleteCommandOnCmdEditor
function deleteCommandOnCmdEditor (config) { var commands = config.commands || {}; var command_names = Object.keys(commands); command_names.unshift('<< Cancel'); var promise = inquirer.prompt([{ type: 'list', name: 'cmdName', message: 'Choose the command you want to delete', choices: command_names }]); ...
javascript
function deleteCommandOnCmdEditor (config) { var commands = config.commands || {}; var command_names = Object.keys(commands); command_names.unshift('<< Cancel'); var promise = inquirer.prompt([{ type: 'list', name: 'cmdName', message: 'Choose the command you want to delete', choices: command_names }]); ...
[ "function", "deleteCommandOnCmdEditor", "(", "config", ")", "{", "var", "commands", "=", "config", ".", "commands", "||", "{", "}", ";", "var", "command_names", "=", "Object", ".", "keys", "(", "commands", ")", ";", "command_names", ".", "unshift", "(", "'...
Command Editor - Delete a command @param {Object} config Current configuration @return {Promise}
[ "Command", "Editor", "-", "Delete", "a", "command" ]
50d35aca96db3a07a3272f1765a660ea893735ce
https://github.com/odentools/denhub-device/blob/50d35aca96db3a07a3272f1765a660ea893735ce/scripts/generator.js#L803-L836
train
gtriggiano/dnsmq-messagebus
src/PubConnection.js
connect
function connect (master) { if (_socket && _socket._master.name === master.name) { debug(`already connected to master ${master.name}`) return } if (_connectingMaster && _connectingMaster.name === master.name) { debug(`already connecting to master ${master.name}`) return } _c...
javascript
function connect (master) { if (_socket && _socket._master.name === master.name) { debug(`already connected to master ${master.name}`) return } if (_connectingMaster && _connectingMaster.name === master.name) { debug(`already connecting to master ${master.name}`) return } _c...
[ "function", "connect", "(", "master", ")", "{", "if", "(", "_socket", "&&", "_socket", ".", "_master", ".", "name", "===", "master", ".", "name", ")", "{", "debug", "(", "`", "${", "master", ".", "name", "}", "`", ")", "return", "}", "if", "(", "...
creates a new pub socket and tries to connect it to the provided master; after connection the socket is used to publish messages in the bus and an eventual previous socket is closed @param {object} master @return {object} the publishConnection instance
[ "creates", "a", "new", "pub", "socket", "and", "tries", "to", "connect", "it", "to", "the", "provided", "master", ";", "after", "connection", "the", "socket", "is", "used", "to", "publish", "messages", "in", "the", "bus", "and", "an", "eventual", "previous...
ab935cae537f8a7e61a6ed6fba247661281c9374
https://github.com/gtriggiano/dnsmq-messagebus/blob/ab935cae537f8a7e61a6ed6fba247661281c9374/src/PubConnection.js#L48-L110
train
gtriggiano/dnsmq-messagebus
src/PubConnection.js
disconnect
function disconnect () { _connectingMaster = null if (_socket) { _socket.close() _socket = null debug('disconnected') connection.emit('disconnect') } return connection }
javascript
function disconnect () { _connectingMaster = null if (_socket) { _socket.close() _socket = null debug('disconnected') connection.emit('disconnect') } return connection }
[ "function", "disconnect", "(", ")", "{", "_connectingMaster", "=", "null", "if", "(", "_socket", ")", "{", "_socket", ".", "close", "(", ")", "_socket", "=", "null", "debug", "(", "'disconnected'", ")", "connection", ".", "emit", "(", "'disconnect'", ")", ...
if present, closes the pub socket @return {object} the publishConnection instance
[ "if", "present", "closes", "the", "pub", "socket" ]
ab935cae537f8a7e61a6ed6fba247661281c9374
https://github.com/gtriggiano/dnsmq-messagebus/blob/ab935cae537f8a7e61a6ed6fba247661281c9374/src/PubConnection.js#L115-L124
train
gtriggiano/dnsmq-messagebus
src/PubConnection.js
publish
function publish (channel, ...args) { _publishStream.emit('message', channel, uniqueId(`${node.name}_`), ...args) }
javascript
function publish (channel, ...args) { _publishStream.emit('message', channel, uniqueId(`${node.name}_`), ...args) }
[ "function", "publish", "(", "channel", ",", "...", "args", ")", "{", "_publishStream", ".", "emit", "(", "'message'", ",", "channel", ",", "uniqueId", "(", "`", "${", "node", ".", "name", "}", "`", ")", ",", "...", "args", ")", "}" ]
takes a list of strings|buffers to publish as message's frames in the channel passed as first argument; decorates each message with a uid @param {string} channel @param {[string|buffer]} args
[ "takes", "a", "list", "of", "strings|buffers", "to", "publish", "as", "message", "s", "frames", "in", "the", "channel", "passed", "as", "first", "argument", ";", "decorates", "each", "message", "with", "a", "uid" ]
ab935cae537f8a7e61a6ed6fba247661281c9374
https://github.com/gtriggiano/dnsmq-messagebus/blob/ab935cae537f8a7e61a6ed6fba247661281c9374/src/PubConnection.js#L132-L134
train
mrdaniellewis/node-tributary
index.js
Tributary
function Tributary( options ) { options = options || {}; stream.Transform.call( this, { encoding: options.encoding } ); this.getStream = options.getStream || function( filename, cb ) { return cb(); }; this._matcher = new Matcher( options.placeholderStart || '<!-- include ', ...
javascript
function Tributary( options ) { options = options || {}; stream.Transform.call( this, { encoding: options.encoding } ); this.getStream = options.getStream || function( filename, cb ) { return cb(); }; this._matcher = new Matcher( options.placeholderStart || '<!-- include ', ...
[ "function", "Tributary", "(", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "stream", ".", "Transform", ".", "call", "(", "this", ",", "{", "encoding", ":", "options", ".", "encoding", "}", ")", ";", "this", ".", "getStream", "...
Include one stream in another @param {String} [options.placeholderStart="<!-- include "] The start placeholder @param {String} [options.placeholderStart=" -->"] The end placeholder @param {Integer} [options.maxPathLength=512] The maximum length of a path @param {String} [options.delmiter="] The delimiter to use for fil...
[ "Include", "one", "stream", "in", "another" ]
8fb0deee6adf1d1a1b075dd51a0511c88215e49f
https://github.com/mrdaniellewis/node-tributary/blob/8fb0deee6adf1d1a1b075dd51a0511c88215e49f/index.js#L115-L140
train
AGCPartners/mysql-transit
index.js
MysqlTransit
function MysqlTransit(dbOriginal, dbTemp, connectionParameters) { this.dbOriginal = dbOriginal; this.dbTemp = dbTemp; this.connectionParameters = connectionParameters; this.queryQueue = []; this.tablesToDrop = []; this.tablesToCreate = []; this.interactive = true; return this._init(); }
javascript
function MysqlTransit(dbOriginal, dbTemp, connectionParameters) { this.dbOriginal = dbOriginal; this.dbTemp = dbTemp; this.connectionParameters = connectionParameters; this.queryQueue = []; this.tablesToDrop = []; this.tablesToCreate = []; this.interactive = true; return this._init(); }
[ "function", "MysqlTransit", "(", "dbOriginal", ",", "dbTemp", ",", "connectionParameters", ")", "{", "this", ".", "dbOriginal", "=", "dbOriginal", ";", "this", ".", "dbTemp", "=", "dbTemp", ";", "this", ".", "connectionParameters", "=", "connectionParameters", "...
Initialize the MysqlTransit object @param dbOriginal name of the database to migrate @param dbTemp name of the database to be migrated @param connectionParameters object with { port: mysqlParams.options.port, host: mysqlParams.options.host, user: mysqlParams.user, password: mysqlParams.password }
[ "Initialize", "the", "MysqlTransit", "object" ]
d3cc3701166be3d41826c4b3bf1a596ed4c1f03a
https://github.com/AGCPartners/mysql-transit/blob/d3cc3701166be3d41826c4b3bf1a596ed4c1f03a/index.js#L22-L31
train
MiguelCastillo/stream-joint
index.js
joint
function joint(streams) { if (!(streams instanceof Array)) { streams = Array.prototype.slice.call(arguments); } return streams.reduce(function(thru, stream) { if (stream) { thru.pipe(stream); } return thru; }, through()); }
javascript
function joint(streams) { if (!(streams instanceof Array)) { streams = Array.prototype.slice.call(arguments); } return streams.reduce(function(thru, stream) { if (stream) { thru.pipe(stream); } return thru; }, through()); }
[ "function", "joint", "(", "streams", ")", "{", "if", "(", "!", "(", "streams", "instanceof", "Array", ")", ")", "{", "streams", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ")", ";", "}", "return", "streams", ".", "red...
Take all incoming streams combine them into a single through stream. Writing to the returned stream will write to all streams passed in. Handy for chaining writable streams. @param {...Streams} List of streams to merge @returns {Stream} Returns a single through stream
[ "Take", "all", "incoming", "streams", "combine", "them", "into", "a", "single", "through", "stream", ".", "Writing", "to", "the", "returned", "stream", "will", "write", "to", "all", "streams", "passed", "in", "." ]
86986b2611e46be6bd84e27016600fc2e5022834
https://github.com/MiguelCastillo/stream-joint/blob/86986b2611e46be6bd84e27016600fc2e5022834/index.js#L14-L25
train
pine/typescript-after-extends
lib/extends.js
createNamedClass
function createNamedClass (name, klass, baseKlass, superFunc) { if (!superFunc) { superFunc = function () { baseKlass.call(this); }; } return new Function( 'klass', 'superFunc', 'return function ' + name + ' () {' + 'superFunc.apply(this...
javascript
function createNamedClass (name, klass, baseKlass, superFunc) { if (!superFunc) { superFunc = function () { baseKlass.call(this); }; } return new Function( 'klass', 'superFunc', 'return function ' + name + ' () {' + 'superFunc.apply(this...
[ "function", "createNamedClass", "(", "name", ",", "klass", ",", "baseKlass", ",", "superFunc", ")", "{", "if", "(", "!", "superFunc", ")", "{", "superFunc", "=", "function", "(", ")", "{", "baseKlass", ".", "call", "(", "this", ")", ";", "}", ";", "}...
Create named class with extends
[ "Create", "named", "class", "with", "extends" ]
bbe2523beef3bcd1c836ca74a07ac0eafd1858d3
https://github.com/pine/typescript-after-extends/blob/bbe2523beef3bcd1c836ca74a07ac0eafd1858d3/lib/extends.js#L18-L32
train
pine/typescript-after-extends
lib/extends.js
afterExtends
function afterExtends (klass, baseKlass, superFunc) { var newKlass = createNamedClass(klass.name, klass, baseKlass, superFunc); newKlass.prototype = createPrototype(klass, baseKlass, newKlass); return newKlass; }
javascript
function afterExtends (klass, baseKlass, superFunc) { var newKlass = createNamedClass(klass.name, klass, baseKlass, superFunc); newKlass.prototype = createPrototype(klass, baseKlass, newKlass); return newKlass; }
[ "function", "afterExtends", "(", "klass", ",", "baseKlass", ",", "superFunc", ")", "{", "var", "newKlass", "=", "createNamedClass", "(", "klass", ".", "name", ",", "klass", ",", "baseKlass", ",", "superFunc", ")", ";", "newKlass", ".", "prototype", "=", "c...
TypeScript extends later
[ "TypeScript", "extends", "later" ]
bbe2523beef3bcd1c836ca74a07ac0eafd1858d3
https://github.com/pine/typescript-after-extends/blob/bbe2523beef3bcd1c836ca74a07ac0eafd1858d3/lib/extends.js#L49-L54
train
allanmboyd/docit
lib/docit.js
processMethodOutTag
function processMethodOutTag(tag, typeMarkdown) { var md = ""; if (tag.type) { md += applyMarkdown(tag.type, settings.get(typeMarkdown)) + " "; } md += tag.comment; return md; }
javascript
function processMethodOutTag(tag, typeMarkdown) { var md = ""; if (tag.type) { md += applyMarkdown(tag.type, settings.get(typeMarkdown)) + " "; } md += tag.comment; return md; }
[ "function", "processMethodOutTag", "(", "tag", ",", "typeMarkdown", ")", "{", "var", "md", "=", "\"\"", ";", "if", "(", "tag", ".", "type", ")", "{", "md", "+=", "applyMarkdown", "(", "tag", ".", "type", ",", "settings", ".", "get", "(", "typeMarkdown"...
Process either a return or throws tag. @param tag the tag @param {String} typeMarkdown the markdown identifier to associate with the type of the tag if present @return {String} the markdown for the tag @private
[ "Process", "either", "a", "return", "or", "throws", "tag", "." ]
e972b6e3a9792f649e9fed9115b45cb010c90c8f
https://github.com/allanmboyd/docit/blob/e972b6e3a9792f649e9fed9115b45cb010c90c8f/lib/docit.js#L303-L310
train
skazska/marking-codes
v0.js
encode
function encode(batch, id, ver) { //producerId min 2 digits let producerId = b36.int2Str36(batch.producerId).padStart(2, '0'); //producerId min 3 digits let batchId = b36.int2Str36(batch.id).padStart(3, '0'); //id min 2 digits id = b36.int2Str36(id).padStart(3, '0'); let msg = composeCode(p...
javascript
function encode(batch, id, ver) { //producerId min 2 digits let producerId = b36.int2Str36(batch.producerId).padStart(2, '0'); //producerId min 3 digits let batchId = b36.int2Str36(batch.id).padStart(3, '0'); //id min 2 digits id = b36.int2Str36(id).padStart(3, '0'); let msg = composeCode(p...
[ "function", "encode", "(", "batch", ",", "id", ",", "ver", ")", "{", "//producerId min 2 digits", "let", "producerId", "=", "b36", ".", "int2Str36", "(", "batch", ".", "producerId", ")", ".", "padStart", "(", "2", ",", "'0'", ")", ";", "//producerId min 3 ...
creates alphanum representation of marking code @param {{id: number, dsa: {q: number, p: number, g: number}, version: number, producerId: number, publicKey: number, privateKey: number}} batch @param {*} id @param {number} [ver]
[ "creates", "alphanum", "representation", "of", "marking", "code" ]
64c81c39db3dd8a8b17b0bf5e66e4da04d13a846
https://github.com/skazska/marking-codes/blob/64c81c39db3dd8a8b17b0bf5e66e4da04d13a846/v0.js#L168-L183
train
elidoran/node-ansi2
lib/index.js
build
function build(writable, options) { return writable && writable._ansi2 || (writable._ansi2 = new Ansi(writable, options)) }
javascript
function build(writable, options) { return writable && writable._ansi2 || (writable._ansi2 = new Ansi(writable, options)) }
[ "function", "build", "(", "writable", ",", "options", ")", "{", "return", "writable", "&&", "writable", ".", "_ansi2", "||", "(", "writable", ".", "_ansi2", "=", "new", "Ansi", "(", "writable", ",", "options", ")", ")", "}" ]
return one we already made or make a new one
[ "return", "one", "we", "already", "made", "or", "make", "a", "new", "one" ]
7171989aeaaa917fba925bd676bb89df19b28525
https://github.com/elidoran/node-ansi2/blob/7171989aeaaa917fba925bd676bb89df19b28525/lib/index.js#L11-L13
train
Augmentedjs/augmented
scripts/legacy/legacy.js
loadAndParseFile
function loadAndParseFile(filename, settings) { Augmented.ajax({ url: filename, async: true, cache: settings.cache, contentType: 'text/plain;charset=' + settings.encoding, dataType: 'text', success: function (data, status) { logger...
javascript
function loadAndParseFile(filename, settings) { Augmented.ajax({ url: filename, async: true, cache: settings.cache, contentType: 'text/plain;charset=' + settings.encoding, dataType: 'text', success: function (data, status) { logger...
[ "function", "loadAndParseFile", "(", "filename", ",", "settings", ")", "{", "Augmented", ".", "ajax", "(", "{", "url", ":", "filename", ",", "async", ":", "true", ",", "cache", ":", "settings", ".", "cache", ",", "contentType", ":", "'text/plain;charset='", ...
Load and parse .properties files @method loadAndParseFile @memberof i18nBase @param filename @param settings
[ "Load", "and", "parse", ".", "properties", "files" ]
430567d411ab9e77953232bb600c08080ed33146
https://github.com/Augmentedjs/augmented/blob/430567d411ab9e77953232bb600c08080ed33146/scripts/legacy/legacy.js#L299-L314
train
Augmentedjs/augmented
scripts/legacy/legacy.js
function(array) { var sarr = []; var i = 0; for (i=0; i<array.length;i++) { var a = array[i]; var o = {}; o.name = a.name; o.value = a.value; o.type = a.type; ...
javascript
function(array) { var sarr = []; var i = 0; for (i=0; i<array.length;i++) { var a = array[i]; var o = {}; o.name = a.name; o.value = a.value; o.type = a.type; ...
[ "function", "(", "array", ")", "{", "var", "sarr", "=", "[", "]", ";", "var", "i", "=", "0", ";", "for", "(", "i", "=", "0", ";", "i", "<", "array", ".", "length", ";", "i", "++", ")", "{", "var", "a", "=", "array", "[", "i", "]", ";", ...
Get form data.
[ "Get", "form", "data", "." ]
430567d411ab9e77953232bb600c08080ed33146
https://github.com/Augmentedjs/augmented/blob/430567d411ab9e77953232bb600c08080ed33146/scripts/legacy/legacy.js#L742-L758
train
exis-io/ngRiffle
release/ngRiffle.js
success
function success(domain){ if(auth0){ //if auth0 then we don't have user storage connection.user = new DomainWrapper(domain); connection.user.join(); sessionPromise.then(resolve); }else{ //if auth1 ...
javascript
function success(domain){ if(auth0){ //if auth0 then we don't have user storage connection.user = new DomainWrapper(domain); connection.user.join(); sessionPromise.then(resolve); }else{ //if auth1 ...
[ "function", "success", "(", "domain", ")", "{", "if", "(", "auth0", ")", "{", "//if auth0 then we don't have user storage", "connection", ".", "user", "=", "new", "DomainWrapper", "(", "domain", ")", ";", "connection", ".", "user", ".", "join", "(", ")", ";"...
if we get success from the registrar on login continue depending on auth level
[ "if", "we", "get", "success", "from", "the", "registrar", "on", "login", "continue", "depending", "on", "auth", "level" ]
e468353262bbe829e74975def19656fe4a37821f
https://github.com/exis-io/ngRiffle/blob/e468353262bbe829e74975def19656fe4a37821f/release/ngRiffle.js#L938-L950
train
Dashron/Roads-Models
libs/model.js
applyModelMethods
function applyModelMethods (model, definition) { for (var i in definition.methods) { if (i === 'definition') { throw new Error('Invalid model definition provided. "definition" is a reserved word'); } model.prototype[i] = definition.methods[i]; } }
javascript
function applyModelMethods (model, definition) { for (var i in definition.methods) { if (i === 'definition') { throw new Error('Invalid model definition provided. "definition" is a reserved word'); } model.prototype[i] = definition.methods[i]; } }
[ "function", "applyModelMethods", "(", "model", ",", "definition", ")", "{", "for", "(", "var", "i", "in", "definition", ".", "methods", ")", "{", "if", "(", "i", "===", "'definition'", ")", "{", "throw", "new", "Error", "(", "'Invalid model definition provid...
Used in setModel @param {[type]} model [description] @param {[type]} definition [description] @return {[type]} [description]
[ "Used", "in", "setModel" ]
e7820410ae75a8f579bad59e3047f8b3e3bc01f1
https://github.com/Dashron/Roads-Models/blob/e7820410ae75a8f579bad59e3047f8b3e3bc01f1/libs/model.js#L470-L478
train
zenflow/obs-router
lib/index.js
function(patterns, options) { var self = this; if (!(typeof patterns=='object')){throw new Error('ObsRouter constructor expects patterns object as first argument')} options = options || {}; EventEmitter.call(self); if (process.browser){ //bind to window by default self._bindToWindow = 'bindToWindow' in ...
javascript
function(patterns, options) { var self = this; if (!(typeof patterns=='object')){throw new Error('ObsRouter constructor expects patterns object as first argument')} options = options || {}; EventEmitter.call(self); if (process.browser){ //bind to window by default self._bindToWindow = 'bindToWindow' in ...
[ "function", "(", "patterns", ",", "options", ")", "{", "var", "self", "=", "this", ";", "if", "(", "!", "(", "typeof", "patterns", "==", "'object'", ")", ")", "{", "throw", "new", "Error", "(", "'ObsRouter constructor expects patterns object as first argument'",...
Mutable observable abstraction of url as route with parameters @example var router = new ObsRouter({ home: '/', blog: '/blog(/tag/:tag)(/:slug)', contact: '/contact' }, { initialEmit: true, bindToWindow: false, url: '/?foo=bar' }); console.log(router.url, router.name, router.params, router.routes); -> '/?foo=bar' 'home...
[ "Mutable", "observable", "abstraction", "of", "url", "as", "route", "with", "parameters" ]
dd9934bfaa5099f477e7f06d8a3f2deed92ee142
https://github.com/zenflow/obs-router/blob/dd9934bfaa5099f477e7f06d8a3f2deed92ee142/lib/index.js#L50-L82
train
deepjs/deep-restful
lib/http.js
function(object, options) { var self = this; return deep.when(getSchema(this)) .done(function(schema) { return deep.Arguments([object, options]); }); }
javascript
function(object, options) { var self = this; return deep.when(getSchema(this)) .done(function(schema) { return deep.Arguments([object, options]); }); }
[ "function", "(", "object", ",", "options", ")", "{", "var", "self", "=", "this", ";", "return", "deep", ".", "when", "(", "getSchema", "(", "this", ")", ")", ".", "done", "(", "function", "(", "schema", ")", "{", "return", "deep", ".", "Arguments", ...
retrieve Schema if @param {[type]} object [description] @param {[type]} options [description] @return {[type]} [description]
[ "retrieve", "Schema", "if" ]
44c5e1e5526a821522ab5e3004f66ffc7840f551
https://github.com/deepjs/deep-restful/blob/44c5e1e5526a821522ab5e3004f66ffc7840f551/lib/http.js#L121-L127
train
tracker1/mssql-ng
src/connections/open.js
handleConnectionCallback
function handleConnectionCallback(err, resolve, reject, key, connection) { debug('handleConnectionCallback','start'); //error, remove cached entry, reject the promise if (err) { debug('handleConnectionCallback','error',err); delete promises[key]; return reject(err); } //patch close method for ca...
javascript
function handleConnectionCallback(err, resolve, reject, key, connection) { debug('handleConnectionCallback','start'); //error, remove cached entry, reject the promise if (err) { debug('handleConnectionCallback','error',err); delete promises[key]; return reject(err); } //patch close method for ca...
[ "function", "handleConnectionCallback", "(", "err", ",", "resolve", ",", "reject", ",", "key", ",", "connection", ")", "{", "debug", "(", "'handleConnectionCallback'", ",", "'start'", ")", ";", "//error, remove cached entry, reject the promise", "if", "(", "err", ")...
handle promise resolution for connection callback
[ "handle", "promise", "resolution", "for", "connection", "callback" ]
7f32135d33f9b8324fdd94656136cae4087464ce
https://github.com/tracker1/mssql-ng/blob/7f32135d33f9b8324fdd94656136cae4087464ce/src/connections/open.js#L80-L102
train
MiguelCastillo/spromise
src/samdy.js
load
function load(mod) { if (typeof(mod.factory) === "function") { return require(mod.deps, mod.factory); } return mod.factory; }
javascript
function load(mod) { if (typeof(mod.factory) === "function") { return require(mod.deps, mod.factory); } return mod.factory; }
[ "function", "load", "(", "mod", ")", "{", "if", "(", "typeof", "(", "mod", ".", "factory", ")", "===", "\"function\"", ")", "{", "return", "require", "(", "mod", ".", "deps", ",", "mod", ".", "factory", ")", ";", "}", "return", "mod", ".", "factory...
Load the module by calling its factory with the appropriate dependencies, if at all possible
[ "Load", "the", "module", "by", "calling", "its", "factory", "with", "the", "appropriate", "dependencies", "if", "at", "all", "possible" ]
faef0a81e88a871095393980fccdd7980e7c3f89
https://github.com/MiguelCastillo/spromise/blob/faef0a81e88a871095393980fccdd7980e7c3f89/src/samdy.js#L14-L19
train
vfile/vfile-find-up
index.js
handle
function handle(filePath) { var file = toVFile(filePath) var result = test(file) if (mask(result, INCLUDE)) { if (one) { callback(null, file) return true } results.push(file) } if (mask(result, BREAK)) { callback(null, one ? null : results) return tru...
javascript
function handle(filePath) { var file = toVFile(filePath) var result = test(file) if (mask(result, INCLUDE)) { if (one) { callback(null, file) return true } results.push(file) } if (mask(result, BREAK)) { callback(null, one ? null : results) return tru...
[ "function", "handle", "(", "filePath", ")", "{", "var", "file", "=", "toVFile", "(", "filePath", ")", "var", "result", "=", "test", "(", "file", ")", "if", "(", "mask", "(", "result", ",", "INCLUDE", ")", ")", "{", "if", "(", "one", ")", "{", "ca...
Test a file and check what should be done with the resulting file.
[ "Test", "a", "file", "and", "check", "what", "should", "be", "done", "with", "the", "resulting", "file", "." ]
93dc51a499a7888b11f8d5e01e4fd0ae3615c391
https://github.com/vfile/vfile-find-up/blob/93dc51a499a7888b11f8d5e01e4fd0ae3615c391/index.js#L47-L64
train
vfile/vfile-find-up
index.js
once
function once(child) { if (handle(current) === true) { return } readdir(current, onread) function onread(error, entries) { var length = entries ? entries.length : 0 var index = -1 var entry if (error) { entries = [] } while (++index < length) { ...
javascript
function once(child) { if (handle(current) === true) { return } readdir(current, onread) function onread(error, entries) { var length = entries ? entries.length : 0 var index = -1 var entry if (error) { entries = [] } while (++index < length) { ...
[ "function", "once", "(", "child", ")", "{", "if", "(", "handle", "(", "current", ")", "===", "true", ")", "{", "return", "}", "readdir", "(", "current", ",", "onread", ")", "function", "onread", "(", "error", ",", "entries", ")", "{", "var", "length"...
Check one directory.
[ "Check", "one", "directory", "." ]
93dc51a499a7888b11f8d5e01e4fd0ae3615c391
https://github.com/vfile/vfile-find-up/blob/93dc51a499a7888b11f8d5e01e4fd0ae3615c391/index.js#L67-L101
train
webwallet/sdk-node
sdk.js
generateTransactionRequest
function generateTransactionRequest(signer, transaction, options) { let iou = { amt: transaction.amount, cur: transaction.currency, sub: signer.address, aud: transaction.destination, nce: String(Math.floor(Math.random() * 1000000000)) }; return createTransactionRequestStatement(signer, iou, o...
javascript
function generateTransactionRequest(signer, transaction, options) { let iou = { amt: transaction.amount, cur: transaction.currency, sub: signer.address, aud: transaction.destination, nce: String(Math.floor(Math.random() * 1000000000)) }; return createTransactionRequestStatement(signer, iou, o...
[ "function", "generateTransactionRequest", "(", "signer", ",", "transaction", ",", "options", ")", "{", "let", "iou", "=", "{", "amt", ":", "transaction", ".", "amount", ",", "cur", ":", "transaction", ".", "currency", ",", "sub", ":", "signer", ".", "addre...
Generates a transaction request document in the form of an IOU @param {Object} signer - Wallet whose private key is to be used for signing the IOU @param {Object} transaction - Transaction parameters @param {Object} options @return {Object} - A cryptographically signed IOU
[ "Generates", "a", "transaction", "request", "document", "in", "the", "form", "of", "an", "IOU" ]
594081202f39dd648c33e6ddaa5da0590826a62f
https://github.com/webwallet/sdk-node/blob/594081202f39dd648c33e6ddaa5da0590826a62f/sdk.js#L68-L78
train
webwallet/sdk-node
sdk.js
registerWalletAddress
function registerWalletAddress(url, body, options) { options = options || {}; url = resolveURL(url, '/address'); return new P(function (resolve, reject) { request({ url: url, method: options.method || 'POST', body: body, json: true, headers: options.headers }, function (err,...
javascript
function registerWalletAddress(url, body, options) { options = options || {}; url = resolveURL(url, '/address'); return new P(function (resolve, reject) { request({ url: url, method: options.method || 'POST', body: body, json: true, headers: options.headers }, function (err,...
[ "function", "registerWalletAddress", "(", "url", ",", "body", ",", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "url", "=", "resolveURL", "(", "url", ",", "'/address'", ")", ";", "return", "new", "P", "(", "function", "(", "reso...
Sends a wallet address registration request to the supplied URL @param {string} url - The URL of a webwallet server @param {Object} body - A wallet address registration statement @param {Object} options - Request parameters such as method and headers @return {Promise} - Resolves to the response body
[ "Sends", "a", "wallet", "address", "registration", "request", "to", "the", "supplied", "URL" ]
594081202f39dd648c33e6ddaa5da0590826a62f
https://github.com/webwallet/sdk-node/blob/594081202f39dd648c33e6ddaa5da0590826a62f/sdk.js#L86-L102
train
webwallet/sdk-node
sdk.js
checkAddressBalance
function checkAddressBalance(url, address, options) { options = options || {}; let path = '/address/.../balance'.replace('...', address); url = resolveURL(url, path); return new P(function (resolve, reject) { request({ url: url, method: 'GET', headers: options.headers }, function (err...
javascript
function checkAddressBalance(url, address, options) { options = options || {}; let path = '/address/.../balance'.replace('...', address); url = resolveURL(url, path); return new P(function (resolve, reject) { request({ url: url, method: 'GET', headers: options.headers }, function (err...
[ "function", "checkAddressBalance", "(", "url", ",", "address", ",", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "let", "path", "=", "'/address/.../balance'", ".", "replace", "(", "'...'", ",", "address", ")", ";", "url", "=", "re...
Checks the balance of a wallet address @param {string} url - The URL of a webwallet server @param {string} address - A wallet address @param {Object} options - Request parameters such as headers @return {Promise} - Resolves to the response body
[ "Checks", "the", "balance", "of", "a", "wallet", "address" ]
594081202f39dd648c33e6ddaa5da0590826a62f
https://github.com/webwallet/sdk-node/blob/594081202f39dd648c33e6ddaa5da0590826a62f/sdk.js#L158-L173
train
webwallet/sdk-node
sdk.js
generateKeyPair
function generateKeyPair(scheme) { let keypair; let keys; switch (scheme) { case 'ed25519': case 'secp256k1': keypair = schemes[scheme].genKeyPair(); keys = { scheme: scheme, private: keypair.getPrivate('hex'), public: keypair.getPublic('hex') }; break; ...
javascript
function generateKeyPair(scheme) { let keypair; let keys; switch (scheme) { case 'ed25519': case 'secp256k1': keypair = schemes[scheme].genKeyPair(); keys = { scheme: scheme, private: keypair.getPrivate('hex'), public: keypair.getPublic('hex') }; break; ...
[ "function", "generateKeyPair", "(", "scheme", ")", "{", "let", "keypair", ";", "let", "keys", ";", "switch", "(", "scheme", ")", "{", "case", "'ed25519'", ":", "case", "'secp256k1'", ":", "keypair", "=", "schemes", "[", "scheme", "]", ".", "genKeyPair", ...
Generates a pair of cryptographic keys @param {string} scheme - A cryptographic scheme @return {Object} keys - A cryptographic key pair
[ "Generates", "a", "pair", "of", "cryptographic", "keys" ]
594081202f39dd648c33e6ddaa5da0590826a62f
https://github.com/webwallet/sdk-node/blob/594081202f39dd648c33e6ddaa5da0590826a62f/sdk.js#L187-L207
train
webwallet/sdk-node
sdk.js
deriveWalletAddress
function deriveWalletAddress(publicKey, type) { let keyBuffer = new Buffer(publicKey, 'hex'); let firstHash = crypto.createHash('sha256').update(keyBuffer).digest(); let secondHash = ripemd160(firstHash); let extendedHash = (type === 'issuer' ? '57' : '87') + secondHash.toString('hex'); let base58Public = bs5...
javascript
function deriveWalletAddress(publicKey, type) { let keyBuffer = new Buffer(publicKey, 'hex'); let firstHash = crypto.createHash('sha256').update(keyBuffer).digest(); let secondHash = ripemd160(firstHash); let extendedHash = (type === 'issuer' ? '57' : '87') + secondHash.toString('hex'); let base58Public = bs5...
[ "function", "deriveWalletAddress", "(", "publicKey", ",", "type", ")", "{", "let", "keyBuffer", "=", "new", "Buffer", "(", "publicKey", ",", "'hex'", ")", ";", "let", "firstHash", "=", "crypto", ".", "createHash", "(", "'sha256'", ")", ".", "update", "(", ...
Derives a wallet address from a public key @param {<type>} publicKey - A public key to derive the address from @param {string} type - The type of wallet address to derive @return {string} base58public - A base58check encoded wallet address
[ "Derives", "a", "wallet", "address", "from", "a", "public", "key" ]
594081202f39dd648c33e6ddaa5da0590826a62f
https://github.com/webwallet/sdk-node/blob/594081202f39dd648c33e6ddaa5da0590826a62f/sdk.js#L214-L222
train
webwallet/sdk-node
sdk.js
createAddressRegistrationStatement
function createAddressRegistrationStatement(address, keys, options) { options = options || {}; /* Create an extended JSON Web Signatures object */ let jws = { hash: { type: (hashes.indexOf(options.hash) > -1) ? options.hash : 'sha256', value: '' }, payload: { address: address, ...
javascript
function createAddressRegistrationStatement(address, keys, options) { options = options || {}; /* Create an extended JSON Web Signatures object */ let jws = { hash: { type: (hashes.indexOf(options.hash) > -1) ? options.hash : 'sha256', value: '' }, payload: { address: address, ...
[ "function", "createAddressRegistrationStatement", "(", "address", ",", "keys", ",", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "/* Create an extended JSON Web Signatures object */", "let", "jws", "=", "{", "hash", ":", "{", "type", ":", ...
Creates and signs a statement to be sent for registering an address @param {string} address - A wallet address @param {Object} keys - An object containing a cryptograhic key pair @param {Object} options - Parameters such as hash type @return {Object} - A cryptographically signed statement
[ "Creates", "and", "signs", "a", "statement", "to", "be", "sent", "for", "registering", "an", "address" ]
594081202f39dd648c33e6ddaa5da0590826a62f
https://github.com/webwallet/sdk-node/blob/594081202f39dd648c33e6ddaa5da0590826a62f/sdk.js#L230-L266
train
webwallet/sdk-node
sdk.js
resolveURL
function resolveURL(url, path) { if (typeof url !== 'string' || typeof path !== 'string') { return new Error('url-and-path-required'); } /* Remove leading and duplicate slashes */ url = url.replace(/\/{2,}/g, '/').replace(/^\//, '').replace(':/','://'); let parsedUrl = urlModule.parse(url); if (protoc...
javascript
function resolveURL(url, path) { if (typeof url !== 'string' || typeof path !== 'string') { return new Error('url-and-path-required'); } /* Remove leading and duplicate slashes */ url = url.replace(/\/{2,}/g, '/').replace(/^\//, '').replace(':/','://'); let parsedUrl = urlModule.parse(url); if (protoc...
[ "function", "resolveURL", "(", "url", ",", "path", ")", "{", "if", "(", "typeof", "url", "!==", "'string'", "||", "typeof", "path", "!==", "'string'", ")", "{", "return", "new", "Error", "(", "'url-and-path-required'", ")", ";", "}", "/* Remove leading and d...
Resolves a URL given a path @param {string} url - URL to resolve @param {string} path - Path to append to base URL @return {string} resolvedUrl - A valid URL
[ "Resolves", "a", "URL", "given", "a", "path" ]
594081202f39dd648c33e6ddaa5da0590826a62f
https://github.com/webwallet/sdk-node/blob/594081202f39dd648c33e6ddaa5da0590826a62f/sdk.js#L312-L327
train
fhellwig/pkgconfig
pkgconfig.js
merge
function merge(target, source) { if (source === null) { return target } var props = Object.getOwnPropertyNames(target) props.forEach(function (name) { var s = gettype(source[name]) if (s !== 'undefined') { var t = gettype(target[name]) if (t !== s) { ...
javascript
function merge(target, source) { if (source === null) { return target } var props = Object.getOwnPropertyNames(target) props.forEach(function (name) { var s = gettype(source[name]) if (s !== 'undefined') { var t = gettype(target[name]) if (t !== s) { ...
[ "function", "merge", "(", "target", ",", "source", ")", "{", "if", "(", "source", "===", "null", ")", "{", "return", "target", "}", "var", "props", "=", "Object", ".", "getOwnPropertyNames", "(", "target", ")", "props", ".", "forEach", "(", "function", ...
Merges the source with the target. The target is modified and returned.
[ "Merges", "the", "source", "with", "the", "target", ".", "The", "target", "is", "modified", "and", "returned", "." ]
f085bae69877d5a1607088ca71018ecf2839e02d
https://github.com/fhellwig/pkgconfig/blob/f085bae69877d5a1607088ca71018ecf2839e02d/pkgconfig.js#L96-L116
train
NexwayGroup/grunt-sass-bootstrapper
tasks/sass_bootstrapper.js
findIndexInArray
function findIndexInArray(array, callback) { var _length = array.length; for (var i = 0; i < _length; i++) { if (callback(array[i])) return i; } return -1; }
javascript
function findIndexInArray(array, callback) { var _length = array.length; for (var i = 0; i < _length; i++) { if (callback(array[i])) return i; } return -1; }
[ "function", "findIndexInArray", "(", "array", ",", "callback", ")", "{", "var", "_length", "=", "array", ".", "length", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "_length", ";", "i", "++", ")", "{", "if", "(", "callback", "(", "array", ...
Find position of an array element when callback function return true. @param array {array} Array to seek @param callback {function} Callback function to test element @returns {number} Index of eleement or -1 if not found
[ "Find", "position", "of", "an", "array", "element", "when", "callback", "function", "return", "true", "." ]
4f152dd7e796e0f289f7085fed28d9e61e8dec47
https://github.com/NexwayGroup/grunt-sass-bootstrapper/blob/4f152dd7e796e0f289f7085fed28d9e61e8dec47/tasks/sass_bootstrapper.js#L95-L101
train
NexwayGroup/grunt-sass-bootstrapper
tasks/sass_bootstrapper.js
replaceInArray
function replaceInArray(array, indexToReplace, indexToInsert) { var _removedArray = array.splice(indexToReplace, 1); array.splice(indexToInsert, 0, _removedArray[0]); return array; }
javascript
function replaceInArray(array, indexToReplace, indexToInsert) { var _removedArray = array.splice(indexToReplace, 1); array.splice(indexToInsert, 0, _removedArray[0]); return array; }
[ "function", "replaceInArray", "(", "array", ",", "indexToReplace", ",", "indexToInsert", ")", "{", "var", "_removedArray", "=", "array", ".", "splice", "(", "indexToReplace", ",", "1", ")", ";", "array", ".", "splice", "(", "indexToInsert", ",", "0", ",", ...
Remove item by its index and place it to another position @param indexToReplace {number} current item position @param indexToInsert {number} index where item should be placed
[ "Remove", "item", "by", "its", "index", "and", "place", "it", "to", "another", "position" ]
4f152dd7e796e0f289f7085fed28d9e61e8dec47
https://github.com/NexwayGroup/grunt-sass-bootstrapper/blob/4f152dd7e796e0f289f7085fed28d9e61e8dec47/tasks/sass_bootstrapper.js#L109-L113
train
NexwayGroup/grunt-sass-bootstrapper
tasks/sass_bootstrapper.js
getArrayOfPartials
function getArrayOfPartials() { var _partialsArr = []; for (var file in mainPartialList) { if (mainPartialList.hasOwnProperty(file)) { _partialsArr.push(file); } } return _partialsArr; }
javascript
function getArrayOfPartials() { var _partialsArr = []; for (var file in mainPartialList) { if (mainPartialList.hasOwnProperty(file)) { _partialsArr.push(file); } } return _partialsArr; }
[ "function", "getArrayOfPartials", "(", ")", "{", "var", "_partialsArr", "=", "[", "]", ";", "for", "(", "var", "file", "in", "mainPartialList", ")", "{", "if", "(", "mainPartialList", ".", "hasOwnProperty", "(", "file", ")", ")", "{", "_partialsArr", ".", ...
Get array of partial names from mainPartialList @returns {Array} Array of partials
[ "Get", "array", "of", "partial", "names", "from", "mainPartialList" ]
4f152dd7e796e0f289f7085fed28d9e61e8dec47
https://github.com/NexwayGroup/grunt-sass-bootstrapper/blob/4f152dd7e796e0f289f7085fed28d9e61e8dec47/tasks/sass_bootstrapper.js#L138-L146
train
NexwayGroup/grunt-sass-bootstrapper
tasks/sass_bootstrapper.js
parseFile
function parseFile(importKeyword, requiresKeyword, filePath) { var _lines = grunt.file.read(filePath).split(NEW_LINE), _values = { imports: {}, requires: {} }; // Search for keywords in file for (var i = _lines.length - 1; i >= 0; i--) { ...
javascript
function parseFile(importKeyword, requiresKeyword, filePath) { var _lines = grunt.file.read(filePath).split(NEW_LINE), _values = { imports: {}, requires: {} }; // Search for keywords in file for (var i = _lines.length - 1; i >= 0; i--) { ...
[ "function", "parseFile", "(", "importKeyword", ",", "requiresKeyword", ",", "filePath", ")", "{", "var", "_lines", "=", "grunt", ".", "file", ".", "read", "(", "filePath", ")", ".", "split", "(", "NEW_LINE", ")", ",", "_values", "=", "{", "imports", ":",...
Parses the given file for import keywords and DI keywords @param importKeyword {string} sass import keyword @param requiresKeyword {string} dependency injection keyword @param filePath {string} file to be parsed @returns {Object} list of all founded import values
[ "Parses", "the", "given", "file", "for", "import", "keywords", "and", "DI", "keywords" ]
4f152dd7e796e0f289f7085fed28d9e61e8dec47
https://github.com/NexwayGroup/grunt-sass-bootstrapper/blob/4f152dd7e796e0f289f7085fed28d9e61e8dec47/tasks/sass_bootstrapper.js#L156-L194
train
NexwayGroup/grunt-sass-bootstrapper
tasks/sass_bootstrapper.js
orderByDependency
function orderByDependency(partialsArray) { var _doPass = true, _reqCache = {}; // repeat sorting operation until // there is no replacing procedure during // one pass (bubble sorting). while (_doPass) { _doPass = false; // Iterate throu...
javascript
function orderByDependency(partialsArray) { var _doPass = true, _reqCache = {}; // repeat sorting operation until // there is no replacing procedure during // one pass (bubble sorting). while (_doPass) { _doPass = false; // Iterate throu...
[ "function", "orderByDependency", "(", "partialsArray", ")", "{", "var", "_doPass", "=", "true", ",", "_reqCache", "=", "{", "}", ";", "// repeat sorting operation until", "// there is no replacing procedure during", "// one pass (bubble sorting).", "while", "(", "_doPass", ...
Reorders partials in a given list by their dependencies. Dependencies are taken from mainPartialList which has to be generated first. @param partialsArray {array} array of sass/scss partials @returns {array} reordered array of partials
[ "Reorders", "partials", "in", "a", "given", "list", "by", "their", "dependencies", ".", "Dependencies", "are", "taken", "from", "mainPartialList", "which", "has", "to", "be", "generated", "first", "." ]
4f152dd7e796e0f289f7085fed28d9e61e8dec47
https://github.com/NexwayGroup/grunt-sass-bootstrapper/blob/4f152dd7e796e0f289f7085fed28d9e61e8dec47/tasks/sass_bootstrapper.js#L204-L271
train
NexwayGroup/grunt-sass-bootstrapper
tasks/sass_bootstrapper.js
generateBootstrapContent
function generateBootstrapContent(partialsArray, lineDelimiter) { var _bootstrapContent = '', _folderGroup = ''; partialsArray.forEach(function (partialName) { var _sassPath = mainPartialList[partialName].removedRoot, _currentRoot = _sassPath.parseRootFo...
javascript
function generateBootstrapContent(partialsArray, lineDelimiter) { var _bootstrapContent = '', _folderGroup = ''; partialsArray.forEach(function (partialName) { var _sassPath = mainPartialList[partialName].removedRoot, _currentRoot = _sassPath.parseRootFo...
[ "function", "generateBootstrapContent", "(", "partialsArray", ",", "lineDelimiter", ")", "{", "var", "_bootstrapContent", "=", "''", ",", "_folderGroup", "=", "''", ";", "partialsArray", ".", "forEach", "(", "function", "(", "partialName", ")", "{", "var", "_sas...
Generate content for bootstrap file @param partialsArray {array} list of partials to import by bootstrap file @param lineDelimiter {string} symbol at the end of the line @returns {string} formatted file content
[ "Generate", "content", "for", "bootstrap", "file" ]
4f152dd7e796e0f289f7085fed28d9e61e8dec47
https://github.com/NexwayGroup/grunt-sass-bootstrapper/blob/4f152dd7e796e0f289f7085fed28d9e61e8dec47/tasks/sass_bootstrapper.js#L280-L312
train
mnichols/ankh
lib/startable-model.js
StartableModel
function StartableModel(model,instance) { if(!model) { throw new Error('model is required') } if(!instance) { throw new Error('instance is required') } if(!(this instanceof StartableModel)) { return new StartableModel(model,instance,index) } this.model = model thi...
javascript
function StartableModel(model,instance) { if(!model) { throw new Error('model is required') } if(!instance) { throw new Error('instance is required') } if(!(this instanceof StartableModel)) { return new StartableModel(model,instance,index) } this.model = model thi...
[ "function", "StartableModel", "(", "model", ",", "instance", ")", "{", "if", "(", "!", "model", ")", "{", "throw", "new", "Error", "(", "'model is required'", ")", "}", "if", "(", "!", "instance", ")", "{", "throw", "new", "Error", "(", "'instance is req...
Encapsulate a startable function description @class StartableModel
[ "Encapsulate", "a", "startable", "function", "description" ]
b5f6eae24b2dece4025b4f11cea7f1560d3b345f
https://github.com/mnichols/ankh/blob/b5f6eae24b2dece4025b4f11cea7f1560d3b345f/lib/startable-model.js#L9-L32
train
Zingle/fail
fail.js
fail
function fail(err, status=1) { console.log(process.env.DEBUG ? err.stack : err.message); process.exit(status); }
javascript
function fail(err, status=1) { console.log(process.env.DEBUG ? err.stack : err.message); process.exit(status); }
[ "function", "fail", "(", "err", ",", "status", "=", "1", ")", "{", "console", ".", "log", "(", "process", ".", "env", ".", "DEBUG", "?", "err", ".", "stack", ":", "err", ".", "message", ")", ";", "process", ".", "exit", "(", "status", ")", ";", ...
Print error and exit. @param {Error} err @param {number} [status]
[ "Print", "error", "and", "exit", "." ]
41bc523da28d222dbcf6be996f5d42b1023a3822
https://github.com/Zingle/fail/blob/41bc523da28d222dbcf6be996f5d42b1023a3822/fail.js#L6-L9
train
relief-melone/limitpromises
src/limitpromises.js
autoSpliceLaunchArray
function autoSpliceLaunchArray(LaunchArray, TypeKey){ var indFirstElement = currentPromiseArrays[TypeKey].indexOf(LaunchArray[0]); var indLastElement = currentPromiseArrays[TypeKey].indexOf(LaunchArray[LaunchArray.length-1]); Promise.all(LaunchArray.map(e => {return e.result})).then(() => { currentP...
javascript
function autoSpliceLaunchArray(LaunchArray, TypeKey){ var indFirstElement = currentPromiseArrays[TypeKey].indexOf(LaunchArray[0]); var indLastElement = currentPromiseArrays[TypeKey].indexOf(LaunchArray[LaunchArray.length-1]); Promise.all(LaunchArray.map(e => {return e.result})).then(() => { currentP...
[ "function", "autoSpliceLaunchArray", "(", "LaunchArray", ",", "TypeKey", ")", "{", "var", "indFirstElement", "=", "currentPromiseArrays", "[", "TypeKey", "]", ".", "indexOf", "(", "LaunchArray", "[", "0", "]", ")", ";", "var", "indLastElement", "=", "currentProm...
As the stack in currentPromiseArrays might get very long and slow down the application we will splice all of the launchArrays already completely resolved out of the currentPromiseArrays As currentPromiseArrays can get extremely large and we want to keep the app performant, autoSplice will automatically remove a Launch...
[ "As", "the", "stack", "in", "currentPromiseArrays", "might", "get", "very", "long", "and", "slow", "down", "the", "application", "we", "will", "splice", "all", "of", "the", "launchArrays", "already", "completely", "resolved", "out", "of", "the", "currentPromiseA...
1735b92749740204b597c1c6026257d54ade8200
https://github.com/relief-melone/limitpromises/blob/1735b92749740204b597c1c6026257d54ade8200/src/limitpromises.js#L168-L176
train
phated/grunt-enyo
tasks/init/bootplate/root/enyo/source/ajax/Jsonp.js
function(inParams, inCallbackFunctionName) { if (enyo.isString(inParams)) { return inParams.replace("=?", "=" + inCallbackFunctionName); } else { var params = enyo.mixin({}, inParams); params[this.callbackName] = inCallbackFunctionName; return enyo.Ajax.objectToQuery(params); } }
javascript
function(inParams, inCallbackFunctionName) { if (enyo.isString(inParams)) { return inParams.replace("=?", "=" + inCallbackFunctionName); } else { var params = enyo.mixin({}, inParams); params[this.callbackName] = inCallbackFunctionName; return enyo.Ajax.objectToQuery(params); } }
[ "function", "(", "inParams", ",", "inCallbackFunctionName", ")", "{", "if", "(", "enyo", ".", "isString", "(", "inParams", ")", ")", "{", "return", "inParams", ".", "replace", "(", "\"=?\"", ",", "\"=\"", "+", "inCallbackFunctionName", ")", ";", "}", "else...
for a string version of inParams, we follow the convention of replacing the string "=?" with the callback name. For the more common case of inParams being an object, we'll add a argument named using the callbackName published property.
[ "for", "a", "string", "version", "of", "inParams", "we", "follow", "the", "convention", "of", "replacing", "the", "string", "=", "?", "with", "the", "callback", "name", ".", "For", "the", "more", "common", "case", "of", "inParams", "being", "an", "object",...
d2990ee4cd85eea8db4108c43086c6d8c3c90c30
https://github.com/phated/grunt-enyo/blob/d2990ee4cd85eea8db4108c43086c6d8c3c90c30/tasks/init/bootplate/root/enyo/source/ajax/Jsonp.js#L111-L119
train
intervolga/bem-utils
lib/dirs-exist.js
stupidDirsExist
function stupidDirsExist(dirs) { const check = []; dirs.forEach((dir) => { check.push(dirExist(dir)); }); return Promise.all(check).then((results) => { // Combine to single object return dirs.reduce(function(prev, item, i) { prev[item] = !!results[i]; return prev; }, {}); }); }
javascript
function stupidDirsExist(dirs) { const check = []; dirs.forEach((dir) => { check.push(dirExist(dir)); }); return Promise.all(check).then((results) => { // Combine to single object return dirs.reduce(function(prev, item, i) { prev[item] = !!results[i]; return prev; }, {}); }); }
[ "function", "stupidDirsExist", "(", "dirs", ")", "{", "const", "check", "=", "[", "]", ";", "dirs", ".", "forEach", "(", "(", "dir", ")", "=>", "{", "check", ".", "push", "(", "dirExist", "(", "dir", ")", ")", ";", "}", ")", ";", "return", "Promi...
Check if dirs exist, all at once @param {Array} dirs @return {Promise} {dir: exist}
[ "Check", "if", "dirs", "exist", "all", "at", "once" ]
3b81bb9bc408275486175326dc7f35c563a46563
https://github.com/intervolga/bem-utils/blob/3b81bb9bc408275486175326dc7f35c563a46563/lib/dirs-exist.js#L9-L23
train
intervolga/bem-utils
lib/dirs-exist.js
dirsExist
function dirsExist(dirs) { if (0 === dirs.length) { return new Promise((resolve) => { resolve({}); }); } // Group dirs by '/' count const dirsByDepth = dirs.reduce(function(prev, curItem) { const depth = curItem.split(path.sep).length; (prev[depth] = prev[depth] || []).push(curItem); ...
javascript
function dirsExist(dirs) { if (0 === dirs.length) { return new Promise((resolve) => { resolve({}); }); } // Group dirs by '/' count const dirsByDepth = dirs.reduce(function(prev, curItem) { const depth = curItem.split(path.sep).length; (prev[depth] = prev[depth] || []).push(curItem); ...
[ "function", "dirsExist", "(", "dirs", ")", "{", "if", "(", "0", "===", "dirs", ".", "length", ")", "{", "return", "new", "Promise", "(", "(", "resolve", ")", "=>", "{", "resolve", "(", "{", "}", ")", ";", "}", ")", ";", "}", "// Group dirs by '/' c...
Check if directories exist. Step by step. From root to leaves. @param {Array} dirs @return {Promise} {dir: exist}
[ "Check", "if", "directories", "exist", ".", "Step", "by", "step", ".", "From", "root", "to", "leaves", "." ]
3b81bb9bc408275486175326dc7f35c563a46563
https://github.com/intervolga/bem-utils/blob/3b81bb9bc408275486175326dc7f35c563a46563/lib/dirs-exist.js#L31-L92
train
usco/usco-stl-parser
dist/parseStream.js
parseASCIIChunk
function parseASCIIChunk(workChunk) { var data = (0, _utils.ensureString)(workChunk); // console.log('parseASCII') var result = void 0, text = void 0; var patternNormal = /normal[\s]+([\-+]?[0-9]+\.?[0-9]*([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE]...
javascript
function parseASCIIChunk(workChunk) { var data = (0, _utils.ensureString)(workChunk); // console.log('parseASCII') var result = void 0, text = void 0; var patternNormal = /normal[\s]+([\-+]?[0-9]+\.?[0-9]*([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE]...
[ "function", "parseASCIIChunk", "(", "workChunk", ")", "{", "var", "data", "=", "(", "0", ",", "_utils", ".", "ensureString", ")", "(", "workChunk", ")", ";", "// console.log('parseASCII')", "var", "result", "=", "void", "0", ",", "text", "=", "void", "0", ...
ASCII stl parsing
[ "ASCII", "stl", "parsing" ]
49eb402f124723d8f74cc67f24a7017c2b99bca4
https://github.com/usco/usco-stl-parser/blob/49eb402f124723d8f74cc67f24a7017c2b99bca4/dist/parseStream.js#L114-L159
train
ikondrat/franky
src/ds/Set.js
function (value) { var res; if (this.has(value)) { res = this.items.splice( x.indexOf(this.items, value), 1 ); } return res; }
javascript
function (value) { var res; if (this.has(value)) { res = this.items.splice( x.indexOf(this.items, value), 1 ); } return res; }
[ "function", "(", "value", ")", "{", "var", "res", ";", "if", "(", "this", ".", "has", "(", "value", ")", ")", "{", "res", "=", "this", ".", "items", ".", "splice", "(", "x", ".", "indexOf", "(", "this", ".", "items", ",", "value", ")", ",", "...
Removes value from Set @param value @returns <Item>
[ "Removes", "value", "from", "Set" ]
6a7368891f39620a225e37c4a56d2bf99644c3e7
https://github.com/ikondrat/franky/blob/6a7368891f39620a225e37c4a56d2bf99644c3e7/src/ds/Set.js#L37-L46
train
ikondrat/franky
src/ds/Set.js
function (callback) { for (var i = 0, l = this.items.length; i < l; i++) { callback(this.items[i], i, this.items); } return this; }
javascript
function (callback) { for (var i = 0, l = this.items.length; i < l; i++) { callback(this.items[i], i, this.items); } return this; }
[ "function", "(", "callback", ")", "{", "for", "(", "var", "i", "=", "0", ",", "l", "=", "this", ".", "items", ".", "length", ";", "i", "<", "l", ";", "i", "++", ")", "{", "callback", "(", "this", ".", "items", "[", "i", "]", ",", "i", ",", ...
Iterates through values and void callback @param callback
[ "Iterates", "through", "values", "and", "void", "callback" ]
6a7368891f39620a225e37c4a56d2bf99644c3e7
https://github.com/ikondrat/franky/blob/6a7368891f39620a225e37c4a56d2bf99644c3e7/src/ds/Set.js#L62-L67
train
ugate/releasebot
lib/committer.js
argv
function argv(k) { if (!nargv) { nargv = process.argv.slice(0, 2); } var v = '', m = null; var x = new RegExp(k + regexKeyVal.source); nargv.every(function(e) { m = e.match(x); if (m && m.length) { v = m[0]; return false; } }); return v; }
javascript
function argv(k) { if (!nargv) { nargv = process.argv.slice(0, 2); } var v = '', m = null; var x = new RegExp(k + regexKeyVal.source); nargv.every(function(e) { m = e.match(x); if (m && m.length) { v = m[0]; return false; } }); return v; }
[ "function", "argv", "(", "k", ")", "{", "if", "(", "!", "nargv", ")", "{", "nargv", "=", "process", ".", "argv", ".", "slice", "(", "0", ",", "2", ")", ";", "}", "var", "v", "=", "''", ",", "m", "=", "null", ";", "var", "x", "=", "new", "...
find via node CLI argument in the format key="value"
[ "find", "via", "node", "CLI", "argument", "in", "the", "format", "key", "=", "value" ]
1a2ff42796e77f47f9590992c014fee461aad80b
https://github.com/ugate/releasebot/blob/1a2ff42796e77f47f9590992c014fee461aad80b/lib/committer.js#L56-L70
train
ugate/releasebot
lib/committer.js
clone
function clone(c, wl, bl) { var cl = {}, cp, t; for (var keys = Object.keys(c), l = 0; l < keys.length; l++) { cp = c[keys[l]]; if (bl && bl.indexOf(cp) >= 0) { continue; } if (Array.isArray(cp)) { cl[keys[l]] = cp.slice(0); } else if ((t = typeof cp) === 'function') { if (!wl || wl.indexOf(cp) >= ...
javascript
function clone(c, wl, bl) { var cl = {}, cp, t; for (var keys = Object.keys(c), l = 0; l < keys.length; l++) { cp = c[keys[l]]; if (bl && bl.indexOf(cp) >= 0) { continue; } if (Array.isArray(cp)) { cl[keys[l]] = cp.slice(0); } else if ((t = typeof cp) === 'function') { if (!wl || wl.indexOf(cp) >= ...
[ "function", "clone", "(", "c", ",", "wl", ",", "bl", ")", "{", "var", "cl", "=", "{", "}", ",", "cp", ",", "t", ";", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "c", ")", ",", "l", "=", "0", ";", "l", "<", "keys", ".", "...
Clones an object @param c the {Commit} to clone @param wl an array of white list functions that will be included in the clone (null to include all) @param bl an array of black list property values that will be excluded from the clone @returns {Object} clone
[ "Clones", "an", "object" ]
1a2ff42796e77f47f9590992c014fee461aad80b
https://github.com/ugate/releasebot/blob/1a2ff42796e77f47f9590992c014fee461aad80b/lib/committer.js#L352-L373
train
ugate/releasebot
lib/committer.js
pkgPropUpd
function pkgPropUpd(pd, u, n, r) { var v = null; if (u && pd.oldVer !== self.version && self.version) { v = self.version; } else if (n && pd.oldVer !== self.next.version && self.next.version) { v = self.next.version; } else if (r && self.prev.version) { v = self.prev.version; } pd.version ...
javascript
function pkgPropUpd(pd, u, n, r) { var v = null; if (u && pd.oldVer !== self.version && self.version) { v = self.version; } else if (n && pd.oldVer !== self.next.version && self.next.version) { v = self.next.version; } else if (r && self.prev.version) { v = self.prev.version; } pd.version ...
[ "function", "pkgPropUpd", "(", "pd", ",", "u", ",", "n", ",", "r", ")", "{", "var", "v", "=", "null", ";", "if", "(", "u", "&&", "pd", ".", "oldVer", "!==", "self", ".", "version", "&&", "self", ".", "version", ")", "{", "v", "=", "self", "."...
updates the package version or a set of properties from a parent package for a given package data element and flag
[ "updates", "the", "package", "version", "or", "a", "set", "of", "properties", "from", "a", "parent", "package", "for", "a", "given", "package", "data", "element", "and", "flag" ]
1a2ff42796e77f47f9590992c014fee461aad80b
https://github.com/ugate/releasebot/blob/1a2ff42796e77f47f9590992c014fee461aad80b/lib/committer.js#L551-L575
train
ugate/releasebot
lib/committer.js
vmtchs
function vmtchs(start, end, skips) { var s = ''; for (var i = start; i <= end; i++) { if (skips && skips.indexOf(i) >= 0) { continue; } s += self.versionMatch[i] || ''; } return s; }
javascript
function vmtchs(start, end, skips) { var s = ''; for (var i = start; i <= end; i++) { if (skips && skips.indexOf(i) >= 0) { continue; } s += self.versionMatch[i] || ''; } return s; }
[ "function", "vmtchs", "(", "start", ",", "end", ",", "skips", ")", "{", "var", "s", "=", "''", ";", "for", "(", "var", "i", "=", "start", ";", "i", "<=", "end", ";", "i", "++", ")", "{", "if", "(", "skips", "&&", "skips", ".", "indexOf", "(",...
reconstructs the version matches
[ "reconstructs", "the", "version", "matches" ]
1a2ff42796e77f47f9590992c014fee461aad80b
https://github.com/ugate/releasebot/blob/1a2ff42796e77f47f9590992c014fee461aad80b/lib/committer.js#L708-L717
train
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/a11yhelp/dialogs/a11yhelp.js
buildHelpContents
function buildHelpContents() { var pageTpl = '<div class="cke_accessibility_legend" role="document" aria-labelledby="' + id + '_arialbl" tabIndex="-1">%1</div>' + '<span id="' + id + '_arialbl" class="cke_voice_label">' + lang.contents + ' </span>', sectionTpl = '<h1>%1</h1><dl>%2</dl>', itemTpl = '<dt>...
javascript
function buildHelpContents() { var pageTpl = '<div class="cke_accessibility_legend" role="document" aria-labelledby="' + id + '_arialbl" tabIndex="-1">%1</div>' + '<span id="' + id + '_arialbl" class="cke_voice_label">' + lang.contents + ' </span>', sectionTpl = '<h1>%1</h1><dl>%2</dl>', itemTpl = '<dt>...
[ "function", "buildHelpContents", "(", ")", "{", "var", "pageTpl", "=", "'<div class=\"cke_accessibility_legend\" role=\"document\" aria-labelledby=\"'", "+", "id", "+", "'_arialbl\" tabIndex=\"-1\">%1</div>'", "+", "'<span id=\"'", "+", "id", "+", "'_arialbl\" class=\"cke_voice_l...
Create the help list directly from lang file entries.
[ "Create", "the", "help", "list", "directly", "from", "lang", "file", "entries", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/a11yhelp/dialogs/a11yhelp.js#L121-L154
train
bvalosek/sack
lib/getArguments.js
getArguments
function getArguments(f, amended) { var functionCode = f.toString(); if(amended){ //This is a fix for when we are passed anonymous functions (which are passed to us as unassigned) //ex: "function (a, b, c) { }" //These are actually parse errors so we'll try adding an assignment to fix the parse error ...
javascript
function getArguments(f, amended) { var functionCode = f.toString(); if(amended){ //This is a fix for when we are passed anonymous functions (which are passed to us as unassigned) //ex: "function (a, b, c) { }" //These are actually parse errors so we'll try adding an assignment to fix the parse error ...
[ "function", "getArguments", "(", "f", ",", "amended", ")", "{", "var", "functionCode", "=", "f", ".", "toString", "(", ")", ";", "if", "(", "amended", ")", "{", "//This is a fix for when we are passed anonymous functions (which are passed to us as unassigned)", "//ex: \...
Get the parameter names of a function. @param {Function} f A function. @return {Array.<String>} An array of the argument names of a function.
[ "Get", "the", "parameter", "names", "of", "a", "function", "." ]
65e2ab133b6c40400c200c2e071052dea6b23c24
https://github.com/bvalosek/sack/blob/65e2ab133b6c40400c200c2e071052dea6b23c24/lib/getArguments.js#L10-L34
train
ForbesLindesay-Unmaintained/sauce-test
lib/run-chromedriver.js
runChromedriver
function runChromedriver(location, remote, options) { assert(remote === 'chromedriver', 'expected remote to be chromedriver'); if (!options.chromedriverStarted) { chromedriver.start(); } var throttle = options.throttle || function (fn) { return fn(); }; return throttle(function () { return runSingleBr...
javascript
function runChromedriver(location, remote, options) { assert(remote === 'chromedriver', 'expected remote to be chromedriver'); if (!options.chromedriverStarted) { chromedriver.start(); } var throttle = options.throttle || function (fn) { return fn(); }; return throttle(function () { return runSingleBr...
[ "function", "runChromedriver", "(", "location", ",", "remote", ",", "options", ")", "{", "assert", "(", "remote", "===", "'chromedriver'", ",", "'expected remote to be chromedriver'", ")", ";", "if", "(", "!", "options", ".", "chromedriverStarted", ")", "{", "ch...
Run a test using chromedriver, then stops chrome driver and returns the result @option {Function} throttle @option {Object} platform|capabilities @option {Boolean} debug @option {Boolean} allowExceptions @option {String|Function} testComplete @option {String|Function} testPassed @option...
[ "Run", "a", "test", "using", "chromedriver", "then", "stops", "chrome", "driver", "and", "returns", "the", "result" ]
7c671b3321dc63aefc00c1c8d49e943ead2e7f5e
https://github.com/ForbesLindesay-Unmaintained/sauce-test/blob/7c671b3321dc63aefc00c1c8d49e943ead2e7f5e/lib/run-chromedriver.js#L33-L61
train
OctaveWealth/passy
lib/bitString.js
pad
function pad (n, width, z) { if (typeof n !== 'string') throw new Error('bitString#pad: Need String'); z = z || '0'; while(n.length < width) { n = z + n; } return n; }
javascript
function pad (n, width, z) { if (typeof n !== 'string') throw new Error('bitString#pad: Need String'); z = z || '0'; while(n.length < width) { n = z + n; } return n; }
[ "function", "pad", "(", "n", ",", "width", ",", "z", ")", "{", "if", "(", "typeof", "n", "!==", "'string'", ")", "throw", "new", "Error", "(", "'bitString#pad: Need String'", ")", ";", "z", "=", "z", "||", "'0'", ";", "while", "(", "n", ".", "lengt...
Pad a string to atleast desired width @param {string} n String to pad @param {integer} width Width to pad to @param {char=} z Optional pad char, defaults to '0' @return {string} Padded string
[ "Pad", "a", "string", "to", "atleast", "desired", "width" ]
6e357b018952f73e8570b89eda95393780328fab
https://github.com/OctaveWealth/passy/blob/6e357b018952f73e8570b89eda95393780328fab/lib/bitString.js#L48-L55
train
OctaveWealth/passy
lib/bitString.js
checksum
function checksum (bits, size) { if (bits == null || !isValid(bits)) throw new Error('bitString#checksum: Need valid bits'); if (size == null || size % 2 !== 0) throw new Error('bitString#checksum: size needs to be even'); var sumA = 0, sumB = 0, i; for (i = 0; i < bits.length; i++) { sumA = (...
javascript
function checksum (bits, size) { if (bits == null || !isValid(bits)) throw new Error('bitString#checksum: Need valid bits'); if (size == null || size % 2 !== 0) throw new Error('bitString#checksum: size needs to be even'); var sumA = 0, sumB = 0, i; for (i = 0; i < bits.length; i++) { sumA = (...
[ "function", "checksum", "(", "bits", ",", "size", ")", "{", "if", "(", "bits", "==", "null", "||", "!", "isValid", "(", "bits", ")", ")", "throw", "new", "Error", "(", "'bitString#checksum: Need valid bits'", ")", ";", "if", "(", "size", "==", "null", ...
Fletcher's checksum on a bitstring @param {string} bits Bitstring to checksum @param {integer} size Size of checksum, must be divisible by 2 @return {string} Return checksum as bitstring. With BA, ie sumA last;
[ "Fletcher", "s", "checksum", "on", "a", "bitstring" ]
6e357b018952f73e8570b89eda95393780328fab
https://github.com/OctaveWealth/passy/blob/6e357b018952f73e8570b89eda95393780328fab/lib/bitString.js#L72-L86
train
OctaveWealth/passy
lib/bitString.js
randomBits
function randomBits (n) { if (typeof n !== 'number') throw new Error('bitString#randomBits: Need number'); var buf = _randomBytes(Math.ceil(n/8)), bits = ''; for (var i = 0; i < n; i++) { bits += (buf[Math.floor(i / 8)] & (0x01 << (i % 8))) ? '1' : '0'; } return bits; }
javascript
function randomBits (n) { if (typeof n !== 'number') throw new Error('bitString#randomBits: Need number'); var buf = _randomBytes(Math.ceil(n/8)), bits = ''; for (var i = 0; i < n; i++) { bits += (buf[Math.floor(i / 8)] & (0x01 << (i % 8))) ? '1' : '0'; } return bits; }
[ "function", "randomBits", "(", "n", ")", "{", "if", "(", "typeof", "n", "!==", "'number'", ")", "throw", "new", "Error", "(", "'bitString#randomBits: Need number'", ")", ";", "var", "buf", "=", "_randomBytes", "(", "Math", ".", "ceil", "(", "n", "/", "8"...
Get n random bits Get N randomBits as bitstring @param {integer} n Number of random bits to get @return {string} The random bitstring
[ "Get", "n", "random", "bits", "Get", "N", "randomBits", "as", "bitstring" ]
6e357b018952f73e8570b89eda95393780328fab
https://github.com/OctaveWealth/passy/blob/6e357b018952f73e8570b89eda95393780328fab/lib/bitString.js#L94-L102
train
meisterplayer/js-dev
gulp/changelog.js
createFormatChangelog
function createFormatChangelog(inPath) { if (!inPath) { throw new Error('Input path argument is required'); } return function formatChangelog() { return gulp.src(inPath) // Replace all version compare links. .pipe(replace(/\(http.*\) /g, ' ')) // Replace ...
javascript
function createFormatChangelog(inPath) { if (!inPath) { throw new Error('Input path argument is required'); } return function formatChangelog() { return gulp.src(inPath) // Replace all version compare links. .pipe(replace(/\(http.*\) /g, ' ')) // Replace ...
[ "function", "createFormatChangelog", "(", "inPath", ")", "{", "if", "(", "!", "inPath", ")", "{", "throw", "new", "Error", "(", "'Input path argument is required'", ")", ";", "}", "return", "function", "formatChangelog", "(", ")", "{", "return", "gulp", ".", ...
Higher order function to create gulp function that strips links to the git repository from changelogs generated by conventional changelog. @param {string} inPath The path for the project's changelog @return {function} Function that can be used as a gulp task
[ "Higher", "order", "function", "to", "create", "gulp", "function", "that", "strips", "links", "to", "the", "git", "repository", "from", "changelogs", "generated", "by", "conventional", "changelog", "." ]
c2646678c49dcdaa120ba3f24824da52b0c63e31
https://github.com/meisterplayer/js-dev/blob/c2646678c49dcdaa120ba3f24824da52b0c63e31/gulp/changelog.js#L29-L42
train
dak0rn/espressojs
lib/espresso/dispatchRequest.js
function(parts) { var urls = []; var start = ''; // If the first part is empty // the original path begins with a slash so we // do that, too if( _.isEmpty(parts[0]) ) { start = '/'; urls[0] = '/'; // would not be generated in reduce() ...
javascript
function(parts) { var urls = []; var start = ''; // If the first part is empty // the original path begins with a slash so we // do that, too if( _.isEmpty(parts[0]) ) { start = '/'; urls[0] = '/'; // would not be generated in reduce() ...
[ "function", "(", "parts", ")", "{", "var", "urls", "=", "[", "]", ";", "var", "start", "=", "''", ";", "// If the first part is empty", "// the original path begins with a slash so we", "// do that, too", "if", "(", "_", ".", "isEmpty", "(", "parts", "[", "0", ...
Function that creates a list of parent URLs for a given relative URL.
[ "Function", "that", "creates", "a", "list", "of", "parent", "URLs", "for", "a", "given", "relative", "URL", "." ]
7f8e015f31113215abbe9988ae7f2c7dd5d8572b
https://github.com/dak0rn/espressojs/blob/7f8e015f31113215abbe9988ae7f2c7dd5d8572b/lib/espresso/dispatchRequest.js#L63-L90
train
dak0rn/espressojs
lib/espresso/dispatchRequest.js
function(urls, skipMissing) { var i = -1; var j; var handlers = []; var url; var resource; var urlsLength = urls.length; var resourcesLength = this._resources.length; var foundHandler; // All URLs while( ++i < urlsLength ) { u...
javascript
function(urls, skipMissing) { var i = -1; var j; var handlers = []; var url; var resource; var urlsLength = urls.length; var resourcesLength = this._resources.length; var foundHandler; // All URLs while( ++i < urlsLength ) { u...
[ "function", "(", "urls", ",", "skipMissing", ")", "{", "var", "i", "=", "-", "1", ";", "var", "j", ";", "var", "handlers", "=", "[", "]", ";", "var", "url", ";", "var", "resource", ";", "var", "urlsLength", "=", "urls", ".", "length", ";", "var",...
Finds all handlers for the given URLs. If `skipMissing` is `false`, `null` will be returned if a handler was not found. this = api$this @param {array} urls List of URLs to handle @param {boolean} skipMissing Skip missing "holes"?
[ "Finds", "all", "handlers", "for", "the", "given", "URLs", ".", "If", "skipMissing", "is", "false", "null", "will", "be", "returned", "if", "a", "handler", "was", "not", "found", "." ]
7f8e015f31113215abbe9988ae7f2c7dd5d8572b
https://github.com/dak0rn/espressojs/blob/7f8e015f31113215abbe9988ae7f2c7dd5d8572b/lib/espresso/dispatchRequest.js#L133-L175
train
dak0rn/espressojs
lib/espresso/dispatchRequest.js
function(resource) { var handler = resource.handler.getCallback(request.method); request.api.handler = handler; request.path = resource.path; var context = resource.handler.getContext(); context.__espressojs = { chainIsComplete: chainIsComplete, // Refer...
javascript
function(resource) { var handler = resource.handler.getCallback(request.method); request.api.handler = handler; request.path = resource.path; var context = resource.handler.getContext(); context.__espressojs = { chainIsComplete: chainIsComplete, // Refer...
[ "function", "(", "resource", ")", "{", "var", "handler", "=", "resource", ".", "handler", ".", "getCallback", "(", "request", ".", "method", ")", ";", "request", ".", "api", ".", "handler", "=", "handler", ";", "request", ".", "path", "=", "resource", ...
Helper function used to prepare the handler invokation Uses and manipulates 'global' state like `chainIsComplete` and `request`. @param {object} resource A resource entry containing a path (`.path`) and the corresponding Handler. @return {object} The `this` context for the resource handler.
[ "Helper", "function", "used", "to", "prepare", "the", "handler", "invokation", "Uses", "and", "manipulates", "global", "state", "like", "chainIsComplete", "and", "request", "." ]
7f8e015f31113215abbe9988ae7f2c7dd5d8572b
https://github.com/dak0rn/espressojs/blob/7f8e015f31113215abbe9988ae7f2c7dd5d8572b/lib/espresso/dispatchRequest.js#L186-L203
train
tether/request-text
index.js
setup
function setup (request, options, ...args) { const len = request.headers['content-length'] const encoding = request.headers['content-encoding'] || 'identity' return Object.assign({}, options, { encoding: options.encoding || 'utf-8', limit: options.limit || '1mb', length: (len && encoding === 'identity...
javascript
function setup (request, options, ...args) { const len = request.headers['content-length'] const encoding = request.headers['content-encoding'] || 'identity' return Object.assign({}, options, { encoding: options.encoding || 'utf-8', limit: options.limit || '1mb', length: (len && encoding === 'identity...
[ "function", "setup", "(", "request", ",", "options", ",", "...", "args", ")", "{", "const", "len", "=", "request", ".", "headers", "[", "'content-length'", "]", "const", "encoding", "=", "request", ".", "headers", "[", "'content-encoding'", "]", "||", "'id...
Clone and setup default options. @param {HttpIncomingMessage} request @param {Object} options @param {Object} mixin @return {Object} @api private
[ "Clone", "and", "setup", "default", "options", "." ]
f3a38bc78dcef21fa495e644c53fc532be6f8bfb
https://github.com/tether/request-text/blob/f3a38bc78dcef21fa495e644c53fc532be6f8bfb/index.js#L33-L41
train
blaugold/express-recaptcha-rest
index.js
getRecaptchaResponse
function getRecaptchaResponse(field, req) { return req.get(field) || (req.query && req.query[field]) || (req.body && req.body[field]) }
javascript
function getRecaptchaResponse(field, req) { return req.get(field) || (req.query && req.query[field]) || (req.body && req.body[field]) }
[ "function", "getRecaptchaResponse", "(", "field", ",", "req", ")", "{", "return", "req", ".", "get", "(", "field", ")", "||", "(", "req", ".", "query", "&&", "req", ".", "query", "[", "field", "]", ")", "||", "(", "req", ".", "body", "&&", "req", ...
Gets recaptcha response from request. @private @param {string} field - Key to look for response. @param {express.req} req - Request object. @returns {string} - Recaptcha response.
[ "Gets", "recaptcha", "response", "from", "request", "." ]
3993ef63ca4a2bbea6e331dfe2a1acbc83564056
https://github.com/blaugold/express-recaptcha-rest/blob/3993ef63ca4a2bbea6e331dfe2a1acbc83564056/index.js#L141-L143
train
morulus/import-sub
resolve.js
resolveAsync
function resolveAsync(p, base, root) { if (!path.isAbsolute(p)) { return new Promise(function(r, j) { resolve(forceRelative(p), { basedir: path.resolve(root, base) }, function(err, res) { if (err) { j(err); } else { r(res); } }); }); } e...
javascript
function resolveAsync(p, base, root) { if (!path.isAbsolute(p)) { return new Promise(function(r, j) { resolve(forceRelative(p), { basedir: path.resolve(root, base) }, function(err, res) { if (err) { j(err); } else { r(res); } }); }); } e...
[ "function", "resolveAsync", "(", "p", ",", "base", ",", "root", ")", "{", "if", "(", "!", "path", ".", "isAbsolute", "(", "p", ")", ")", "{", "return", "new", "Promise", "(", "function", "(", "r", ",", "j", ")", "{", "resolve", "(", "forceRelative"...
Resolve path the same way ans postcss-import @return {Promise}
[ "Resolve", "path", "the", "same", "way", "ans", "postcss", "-", "import" ]
c5e33545bdc2b09714028ef6c44185a3ee59db3c
https://github.com/morulus/import-sub/blob/c5e33545bdc2b09714028ef6c44185a3ee59db3c/resolve.js#L81-L99
train
morulus/import-sub
resolve.js
object
function object(pairs) { let obj = {}; for (let i = 0;i<pairs.length;++i) { obj[pairs[i][0]] = pairs[i][1]; } return obj; }
javascript
function object(pairs) { let obj = {}; for (let i = 0;i<pairs.length;++i) { obj[pairs[i][0]] = pairs[i][1]; } return obj; }
[ "function", "object", "(", "pairs", ")", "{", "let", "obj", "=", "{", "}", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "pairs", ".", "length", ";", "++", "i", ")", "{", "obj", "[", "pairs", "[", "i", "]", "[", "0", "]", "]", "="...
Object fn surrogate
[ "Object", "fn", "surrogate" ]
c5e33545bdc2b09714028ef6c44185a3ee59db3c
https://github.com/morulus/import-sub/blob/c5e33545bdc2b09714028ef6c44185a3ee59db3c/resolve.js#L112-L118
train