id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
sequence
docstring
stringlengths
4
11.8k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
86
226
53,400
vivangkumar/node-data-structures
lib/Iterator.js
function() { if(this._collection.getAll()[this._pos + 1]) { this._hasNext = true; } else { this._hasNext = false; } if(!this._nextCalled) { this._pos ++; this._hasNextCalled = true; } return this._hasNext; }
javascript
function() { if(this._collection.getAll()[this._pos + 1]) { this._hasNext = true; } else { this._hasNext = false; } if(!this._nextCalled) { this._pos ++; this._hasNextCalled = true; } return this._hasNext; }
[ "function", "(", ")", "{", "if", "(", "this", ".", "_collection", ".", "getAll", "(", ")", "[", "this", ".", "_pos", "+", "1", "]", ")", "{", "this", ".", "_hasNext", "=", "true", ";", "}", "else", "{", "this", ".", "_hasNext", "=", "false", ";", "}", "if", "(", "!", "this", ".", "_nextCalled", ")", "{", "this", ".", "_pos", "++", ";", "this", ".", "_hasNextCalled", "=", "true", ";", "}", "return", "this", ".", "_hasNext", ";", "}" ]
Returns true if there are more elements. @return boolean @throws Error
[ "Returns", "true", "if", "there", "are", "more", "elements", "." ]
703d0795fba9d15534fa149f605d54fcfe0844e0
https://github.com/vivangkumar/node-data-structures/blob/703d0795fba9d15534fa149f605d54fcfe0844e0/lib/Iterator.js#L58-L71
53,401
wallacegibbon/sqlmaker
index.js
mkInsert
function mkInsert(table, obj) { const ks = Object.keys(obj).map(x => `\`${x}\``); const vs = Object.values(obj).map(toMysqlObj); return `INSERT INTO \`${table}\`(${ks}) VALUES(${vs})`; }
javascript
function mkInsert(table, obj) { const ks = Object.keys(obj).map(x => `\`${x}\``); const vs = Object.values(obj).map(toMysqlObj); return `INSERT INTO \`${table}\`(${ks}) VALUES(${vs})`; }
[ "function", "mkInsert", "(", "table", ",", "obj", ")", "{", "const", "ks", "=", "Object", ".", "keys", "(", "obj", ")", ".", "map", "(", "x", "=>", "`", "\\`", "${", "x", "}", "\\`", "`", ")", ";", "const", "vs", "=", "Object", ".", "values", "(", "obj", ")", ".", "map", "(", "toMysqlObj", ")", ";", "return", "`", "\\`", "${", "table", "}", "\\`", "${", "ks", "}", "${", "vs", "}", "`", ";", "}" ]
INSERT is the simplest operation, because there is no WHERE part in it. @param {Object} obj - Object like { name: "Abc", age: 15 }. @returns {string} - e.g. "INSERT INTO X(name, age) VALUES('Abc', 15)"
[ "INSERT", "is", "the", "simplest", "operation", "because", "there", "is", "no", "WHERE", "part", "in", "it", "." ]
58e4b84ca120e6ff1b12779f941c04b431e961be
https://github.com/wallacegibbon/sqlmaker/blob/58e4b84ca120e6ff1b12779f941c04b431e961be/index.js#L21-L26
53,402
wallacegibbon/sqlmaker
index.js
toMysqlObj
function toMysqlObj(obj) { if (obj === undefined || obj === null) return "NULL"; switch (obj.constructor) { case Date: return `'${formatDate(obj)}'`; case String: return `'${obj.replace(/'/g, "''")}'`; case Number: return obj; default: throw new TypeError(`${util.inspect(obj)}`); } }
javascript
function toMysqlObj(obj) { if (obj === undefined || obj === null) return "NULL"; switch (obj.constructor) { case Date: return `'${formatDate(obj)}'`; case String: return `'${obj.replace(/'/g, "''")}'`; case Number: return obj; default: throw new TypeError(`${util.inspect(obj)}`); } }
[ "function", "toMysqlObj", "(", "obj", ")", "{", "if", "(", "obj", "===", "undefined", "||", "obj", "===", "null", ")", "return", "\"NULL\"", ";", "switch", "(", "obj", ".", "constructor", ")", "{", "case", "Date", ":", "return", "`", "${", "formatDate", "(", "obj", ")", "}", "`", ";", "case", "String", ":", "return", "`", "${", "obj", ".", "replace", "(", "/", "'", "/", "g", ",", "\"''\"", ")", "}", "`", ";", "case", "Number", ":", "return", "obj", ";", "default", ":", "throw", "new", "TypeError", "(", "`", "${", "util", ".", "inspect", "(", "obj", ")", "}", "`", ")", ";", "}", "}" ]
Transform normal Javascript object to Mysql object. Only String, Number, Date are supported.
[ "Transform", "normal", "Javascript", "object", "to", "Mysql", "object", ".", "Only", "String", "Number", "Date", "are", "supported", "." ]
58e4b84ca120e6ff1b12779f941c04b431e961be
https://github.com/wallacegibbon/sqlmaker/blob/58e4b84ca120e6ff1b12779f941c04b431e961be/index.js#L84-L101
53,403
atd-schubert/node-stream-lib
lib/pipe.js
function (chain) { if (chain.readable) { chain.chainAfter = chain.chainAfter || Pipe.Chain.prototype.chainAfter; chain.nextChain = chain.nextChain || Pipe.Chain.prototype.nextChain; } if (chain.writable) { // Duplex chain.chainBefore = chain.chainBefore || Pipe.Chain.prototype.chainBefore; chain.previousChain = chain.previousChain || Pipe.Chain.prototype.previousChain; } chain.autoEnhance = true; chain.enhanceForeignStream = chain.enhanceForeignStream || Pipe.Chain.prototype.enhanceForeignStream; }
javascript
function (chain) { if (chain.readable) { chain.chainAfter = chain.chainAfter || Pipe.Chain.prototype.chainAfter; chain.nextChain = chain.nextChain || Pipe.Chain.prototype.nextChain; } if (chain.writable) { // Duplex chain.chainBefore = chain.chainBefore || Pipe.Chain.prototype.chainBefore; chain.previousChain = chain.previousChain || Pipe.Chain.prototype.previousChain; } chain.autoEnhance = true; chain.enhanceForeignStream = chain.enhanceForeignStream || Pipe.Chain.prototype.enhanceForeignStream; }
[ "function", "(", "chain", ")", "{", "if", "(", "chain", ".", "readable", ")", "{", "chain", ".", "chainAfter", "=", "chain", ".", "chainAfter", "||", "Pipe", ".", "Chain", ".", "prototype", ".", "chainAfter", ";", "chain", ".", "nextChain", "=", "chain", ".", "nextChain", "||", "Pipe", ".", "Chain", ".", "prototype", ".", "nextChain", ";", "}", "if", "(", "chain", ".", "writable", ")", "{", "// Duplex", "chain", ".", "chainBefore", "=", "chain", ".", "chainBefore", "||", "Pipe", ".", "Chain", ".", "prototype", ".", "chainBefore", ";", "chain", ".", "previousChain", "=", "chain", ".", "previousChain", "||", "Pipe", ".", "Chain", ".", "prototype", ".", "previousChain", ";", "}", "chain", ".", "autoEnhance", "=", "true", ";", "chain", ".", "enhanceForeignStream", "=", "chain", ".", "enhanceForeignStream", "||", "Pipe", ".", "Chain", ".", "prototype", ".", "enhanceForeignStream", ";", "}" ]
Enhance a stream to a chainable one @private @param {stream} chain
[ "Enhance", "a", "stream", "to", "a", "chainable", "one" ]
90f27042fae84d2fbdbf9d28149b0673997f151a
https://github.com/atd-schubert/node-stream-lib/blob/90f27042fae84d2fbdbf9d28149b0673997f151a/lib/pipe.js#L78-L92
53,404
atd-schubert/node-stream-lib
lib/pipe.js
function (chain) { if (chain.previousChain) { chain.previousChain.unpipe(chain); chain.previousChain.pipe(this); chain.previousChain.nextChain = this; } if (this.autoEnhance) { this.enhanceForeignStream(chain); } this.pipe(chain); chain.previousChain = this; this.nextChain = chain; return this; }
javascript
function (chain) { if (chain.previousChain) { chain.previousChain.unpipe(chain); chain.previousChain.pipe(this); chain.previousChain.nextChain = this; } if (this.autoEnhance) { this.enhanceForeignStream(chain); } this.pipe(chain); chain.previousChain = this; this.nextChain = chain; return this; }
[ "function", "(", "chain", ")", "{", "if", "(", "chain", ".", "previousChain", ")", "{", "chain", ".", "previousChain", ".", "unpipe", "(", "chain", ")", ";", "chain", ".", "previousChain", ".", "pipe", "(", "this", ")", ";", "chain", ".", "previousChain", ".", "nextChain", "=", "this", ";", "}", "if", "(", "this", ".", "autoEnhance", ")", "{", "this", ".", "enhanceForeignStream", "(", "chain", ")", ";", "}", "this", ".", "pipe", "(", "chain", ")", ";", "chain", ".", "previousChain", "=", "this", ";", "this", ".", "nextChain", "=", "chain", ";", "return", "this", ";", "}" ]
Chain this chain before the stream given as parameter @param {stream.Writable|stream.Transform|stream.Duplex} chain - Next stream @returns {Pipe.Chain}
[ "Chain", "this", "chain", "before", "the", "stream", "given", "as", "parameter" ]
90f27042fae84d2fbdbf9d28149b0673997f151a
https://github.com/atd-schubert/node-stream-lib/blob/90f27042fae84d2fbdbf9d28149b0673997f151a/lib/pipe.js#L98-L114
53,405
ernestoalejo/grunt-diff-deploy
tasks/push.js
function(callback) { ftpout.raw.pwd(function(err) { if (err && err.code === 530) { grunt.fatal('bad username or password'); } callback(err); }); }
javascript
function(callback) { ftpout.raw.pwd(function(err) { if (err && err.code === 530) { grunt.fatal('bad username or password'); } callback(err); }); }
[ "function", "(", "callback", ")", "{", "ftpout", ".", "raw", ".", "pwd", "(", "function", "(", "err", ")", "{", "if", "(", "err", "&&", "err", ".", "code", "===", "530", ")", "{", "grunt", ".", "fatal", "(", "'bad username or password'", ")", ";", "}", "callback", "(", "err", ")", ";", "}", ")", ";", "}" ]
Check user name & password
[ "Check", "user", "name", "&", "password" ]
c1cdf9f95865fcb784499418e60a0b7682786c91
https://github.com/ernestoalejo/grunt-diff-deploy/blob/c1cdf9f95865fcb784499418e60a0b7682786c91/tasks/push.js#L78-L85
53,406
ernestoalejo/grunt-diff-deploy
tasks/push.js
function(callback) { grunt.log.write(wrap('===== saving hashes... ')); ftpout.put(new Buffer(JSON.stringify(localHashes)), 'push-hashes', function(err) { if (err) { done(err); } grunt.log.writeln(wrapRight('[SUCCESS]').green); callback(); }); }
javascript
function(callback) { grunt.log.write(wrap('===== saving hashes... ')); ftpout.put(new Buffer(JSON.stringify(localHashes)), 'push-hashes', function(err) { if (err) { done(err); } grunt.log.writeln(wrapRight('[SUCCESS]').green); callback(); }); }
[ "function", "(", "callback", ")", "{", "grunt", ".", "log", ".", "write", "(", "wrap", "(", "'===== saving hashes... '", ")", ")", ";", "ftpout", ".", "put", "(", "new", "Buffer", "(", "JSON", ".", "stringify", "(", "localHashes", ")", ")", ",", "'push-hashes'", ",", "function", "(", "err", ")", "{", "if", "(", "err", ")", "{", "done", "(", "err", ")", ";", "}", "grunt", ".", "log", ".", "writeln", "(", "wrapRight", "(", "'[SUCCESS]'", ")", ".", "green", ")", ";", "callback", "(", ")", ";", "}", ")", ";", "}" ]
Change folder & files perms
[ "Change", "folder", "&", "files", "perms" ]
c1cdf9f95865fcb784499418e60a0b7682786c91
https://github.com/ernestoalejo/grunt-diff-deploy/blob/c1cdf9f95865fcb784499418e60a0b7682786c91/tasks/push.js#L269-L276
53,407
ernestoalejo/grunt-diff-deploy
tasks/push.js
function(localHashes, files, done) { fetchRemoteHashes(function(err, remoteHashes) { done(err, localHashes, remoteHashes, files); }); }
javascript
function(localHashes, files, done) { fetchRemoteHashes(function(err, remoteHashes) { done(err, localHashes, remoteHashes, files); }); }
[ "function", "(", "localHashes", ",", "files", ",", "done", ")", "{", "fetchRemoteHashes", "(", "function", "(", "err", ",", "remoteHashes", ")", "{", "done", "(", "err", ",", "localHashes", ",", "remoteHashes", ",", "files", ")", ";", "}", ")", ";", "}" ]
Fetch the remote hashes
[ "Fetch", "the", "remote", "hashes" ]
c1cdf9f95865fcb784499418e60a0b7682786c91
https://github.com/ernestoalejo/grunt-diff-deploy/blob/c1cdf9f95865fcb784499418e60a0b7682786c91/tasks/push.js#L330-L334
53,408
psalaets/ray-vs-line-segment
index.js
rayVsLineSegment
function rayVsLineSegment(ray, segment) { var result = lineIntersect.checkIntersection( ray.start.x, ray.start.y, ray.end.x, ray.end.y, segment.start.x, segment.start.y, segment.end.x, segment.end.y ); // definitely no intersection if (result.type == 'none' || result.type == 'parallel') return null; // single intersection point if (result.type == 'intersecting') return result.point; // colinear, so now check if ray/segment overlap if (segmentContainsPoint(segment, ray.start)) { return ray.start; } else { // return segment endpoint that is // - within ray // - closest to ray start var rayStart = new Vec2(ray.start); var endpointsInRay = segmentEndpointsInRay(ray, segment); return rayStart.nearest(endpointsInRay); } }
javascript
function rayVsLineSegment(ray, segment) { var result = lineIntersect.checkIntersection( ray.start.x, ray.start.y, ray.end.x, ray.end.y, segment.start.x, segment.start.y, segment.end.x, segment.end.y ); // definitely no intersection if (result.type == 'none' || result.type == 'parallel') return null; // single intersection point if (result.type == 'intersecting') return result.point; // colinear, so now check if ray/segment overlap if (segmentContainsPoint(segment, ray.start)) { return ray.start; } else { // return segment endpoint that is // - within ray // - closest to ray start var rayStart = new Vec2(ray.start); var endpointsInRay = segmentEndpointsInRay(ray, segment); return rayStart.nearest(endpointsInRay); } }
[ "function", "rayVsLineSegment", "(", "ray", ",", "segment", ")", "{", "var", "result", "=", "lineIntersect", ".", "checkIntersection", "(", "ray", ".", "start", ".", "x", ",", "ray", ".", "start", ".", "y", ",", "ray", ".", "end", ".", "x", ",", "ray", ".", "end", ".", "y", ",", "segment", ".", "start", ".", "x", ",", "segment", ".", "start", ".", "y", ",", "segment", ".", "end", ".", "x", ",", "segment", ".", "end", ".", "y", ")", ";", "// definitely no intersection", "if", "(", "result", ".", "type", "==", "'none'", "||", "result", ".", "type", "==", "'parallel'", ")", "return", "null", ";", "// single intersection point", "if", "(", "result", ".", "type", "==", "'intersecting'", ")", "return", "result", ".", "point", ";", "// colinear, so now check if ray/segment overlap", "if", "(", "segmentContainsPoint", "(", "segment", ",", "ray", ".", "start", ")", ")", "{", "return", "ray", ".", "start", ";", "}", "else", "{", "// return segment endpoint that is", "// - within ray", "// - closest to ray start", "var", "rayStart", "=", "new", "Vec2", "(", "ray", ".", "start", ")", ";", "var", "endpointsInRay", "=", "segmentEndpointsInRay", "(", "ray", ",", "segment", ")", ";", "return", "rayStart", ".", "nearest", "(", "endpointsInRay", ")", ";", "}", "}" ]
Finds where a ray hits a line segment, if at all. @param {object} ray - Object that looks like { start: {x: number, y: number}, end: {x: number, y: number} } @param {object} segment - Object that looks like { start: {x: number, y: number}, end: {x: number, y: number} } @return {object} point (x/y) where ray hits segment or null if it doesn't hit
[ "Finds", "where", "a", "ray", "hits", "a", "line", "segment", "if", "at", "all", "." ]
7dfde5f2c7853bf34ca4394fa897f4c315a9be88
https://github.com/psalaets/ray-vs-line-segment/blob/7dfde5f2c7853bf34ca4394fa897f4c315a9be88/index.js#L21-L44
53,409
influx6/ToolStack
lib/stack.structures.js
function(elem){ if(!this.root){ this.root = struct.Node(elem); this.tail = this.root; this.size = 1; return this; // this.root.isRoot = true; } this.root.prepend(elem); this.root = this.root.previous; this.size += 1; // this.add(elem,this.root); return this; }
javascript
function(elem){ if(!this.root){ this.root = struct.Node(elem); this.tail = this.root; this.size = 1; return this; // this.root.isRoot = true; } this.root.prepend(elem); this.root = this.root.previous; this.size += 1; // this.add(elem,this.root); return this; }
[ "function", "(", "elem", ")", "{", "if", "(", "!", "this", ".", "root", ")", "{", "this", ".", "root", "=", "struct", ".", "Node", "(", "elem", ")", ";", "this", ".", "tail", "=", "this", ".", "root", ";", "this", ".", "size", "=", "1", ";", "return", "this", ";", "// this.root.isRoot = true;", "}", "this", ".", "root", ".", "prepend", "(", "elem", ")", ";", "this", ".", "root", "=", "this", ".", "root", ".", "previous", ";", "this", ".", "size", "+=", "1", ";", "// this.add(elem,this.root);", "return", "this", ";", "}" ]
adds from the back of the tail element
[ "adds", "from", "the", "back", "of", "the", "tail", "element" ]
d0c7b1acc1546f5e7ff9d04ca6c9222b2577e0db
https://github.com/influx6/ToolStack/blob/d0c7b1acc1546f5e7ff9d04ca6c9222b2577e0db/lib/stack.structures.js#L111-L124
53,410
influx6/ToolStack
lib/stack.structures.js
function(elem){ if(!this.root){ this.root = struct.Node(elem); this.tail = this.root; this.size = 1; return this; // this.root.isRoot = true; } // this.add(elem); this.tail.append(elem); this.tail = this.tail.next; this.size += 1; return this; }
javascript
function(elem){ if(!this.root){ this.root = struct.Node(elem); this.tail = this.root; this.size = 1; return this; // this.root.isRoot = true; } // this.add(elem); this.tail.append(elem); this.tail = this.tail.next; this.size += 1; return this; }
[ "function", "(", "elem", ")", "{", "if", "(", "!", "this", ".", "root", ")", "{", "this", ".", "root", "=", "struct", ".", "Node", "(", "elem", ")", ";", "this", ".", "tail", "=", "this", ".", "root", ";", "this", ".", "size", "=", "1", ";", "return", "this", ";", "// this.root.isRoot = true;", "}", "// this.add(elem);", "this", ".", "tail", ".", "append", "(", "elem", ")", ";", "this", ".", "tail", "=", "this", ".", "tail", ".", "next", ";", "this", ".", "size", "+=", "1", ";", "return", "this", ";", "}" ]
adds in front of the tail element
[ "adds", "in", "front", "of", "the", "tail", "element" ]
d0c7b1acc1546f5e7ff9d04ca6c9222b2577e0db
https://github.com/influx6/ToolStack/blob/d0c7b1acc1546f5e7ff9d04ca6c9222b2577e0db/lib/stack.structures.js#L126-L139
53,411
influx6/ToolStack
lib/stack.structures.js
function(){ if(!this.size) return; var n = this.root, pr = n.previous, nx = n.next; if(this.size === 1){ this.root = this.tail = null; this.size = 0; return n; } nx.previous = pr; delete this.root; this.root = nx; this.size -= 1; return n; }
javascript
function(){ if(!this.size) return; var n = this.root, pr = n.previous, nx = n.next; if(this.size === 1){ this.root = this.tail = null; this.size = 0; return n; } nx.previous = pr; delete this.root; this.root = nx; this.size -= 1; return n; }
[ "function", "(", ")", "{", "if", "(", "!", "this", ".", "size", ")", "return", ";", "var", "n", "=", "this", ".", "root", ",", "pr", "=", "n", ".", "previous", ",", "nx", "=", "n", ".", "next", ";", "if", "(", "this", ".", "size", "===", "1", ")", "{", "this", ".", "root", "=", "this", ".", "tail", "=", "null", ";", "this", ".", "size", "=", "0", ";", "return", "n", ";", "}", "nx", ".", "previous", "=", "pr", ";", "delete", "this", ".", "root", ";", "this", ".", "root", "=", "nx", ";", "this", ".", "size", "-=", "1", ";", "return", "n", ";", "}" ]
pops of the root of the list
[ "pops", "of", "the", "root", "of", "the", "list" ]
d0c7b1acc1546f5e7ff9d04ca6c9222b2577e0db
https://github.com/influx6/ToolStack/blob/d0c7b1acc1546f5e7ff9d04ca6c9222b2577e0db/lib/stack.structures.js#L141-L153
53,412
skerit/alchemy
lib/core/client_alchemy.js
markLinkElement
function markLinkElement(element, active_nr) { var mark_wrapper; // Always remove the current classes element.classList.remove('active-link'); element.classList.remove('active-sublink'); if (element.parentElement && element.parentElement.classList.contains('js-he-link-wrapper')) { markLinkElement(element.parentElement, active_nr); } if (!active_nr) { return; } if (active_nr == 1) { element.classList.add('active-link'); } else if (active_nr == 2) { element.classList.add('active-sublink'); } }
javascript
function markLinkElement(element, active_nr) { var mark_wrapper; // Always remove the current classes element.classList.remove('active-link'); element.classList.remove('active-sublink'); if (element.parentElement && element.parentElement.classList.contains('js-he-link-wrapper')) { markLinkElement(element.parentElement, active_nr); } if (!active_nr) { return; } if (active_nr == 1) { element.classList.add('active-link'); } else if (active_nr == 2) { element.classList.add('active-sublink'); } }
[ "function", "markLinkElement", "(", "element", ",", "active_nr", ")", "{", "var", "mark_wrapper", ";", "// Always remove the current classes", "element", ".", "classList", ".", "remove", "(", "'active-link'", ")", ";", "element", ".", "classList", ".", "remove", "(", "'active-sublink'", ")", ";", "if", "(", "element", ".", "parentElement", "&&", "element", ".", "parentElement", ".", "classList", ".", "contains", "(", "'js-he-link-wrapper'", ")", ")", "{", "markLinkElement", "(", "element", ".", "parentElement", ",", "active_nr", ")", ";", "}", "if", "(", "!", "active_nr", ")", "{", "return", ";", "}", "if", "(", "active_nr", "==", "1", ")", "{", "element", ".", "classList", ".", "add", "(", "'active-link'", ")", ";", "}", "else", "if", "(", "active_nr", "==", "2", ")", "{", "element", ".", "classList", ".", "add", "(", "'active-sublink'", ")", ";", "}", "}" ]
Mark element as active or not @author Jelle De Loecker <[email protected]> @since 0.3.0 @version 0.3.0 @param {Element} element @param {Number} active_nr
[ "Mark", "element", "as", "active", "or", "not" ]
ede1dad07a5a737d5d1e10c2ff87fdfb057443f8
https://github.com/skerit/alchemy/blob/ede1dad07a5a737d5d1e10c2ff87fdfb057443f8/lib/core/client_alchemy.js#L439-L460
53,413
sjberry/bristol-hipchat
main.js
Target
function Target(options = {}) { options = clone(options); let client = new Hipchatter(options.token); let room = options.room; delete options.token; delete options.room; let proto = { message_format: 'html', notify: false }; for (let key in options) { if (!options.hasOwnProperty(key)) { break; } proto[key] = options[key]; } return function(options, severity, date, message) { let payload = clone(proto); if (typeof payload.color !== 'string') { switch(severity) { case 'info': payload.color = 'green'; break; case 'warn': payload.color = 'yellow'; break; case 'error': payload.color = 'red'; break; default: payload.color = 'gray'; break; } } if (proto.message_format === 'html') { payload.message = escape(message) .replace(/\n/g, '<br/>') .replace(/\t/g, '&nbsp;&nbsp;&nbsp;&nbsp;'); } else { payload.message = message; } client.notify(room, payload, function(err) { if (err) { console.log(err); } }); }; }
javascript
function Target(options = {}) { options = clone(options); let client = new Hipchatter(options.token); let room = options.room; delete options.token; delete options.room; let proto = { message_format: 'html', notify: false }; for (let key in options) { if (!options.hasOwnProperty(key)) { break; } proto[key] = options[key]; } return function(options, severity, date, message) { let payload = clone(proto); if (typeof payload.color !== 'string') { switch(severity) { case 'info': payload.color = 'green'; break; case 'warn': payload.color = 'yellow'; break; case 'error': payload.color = 'red'; break; default: payload.color = 'gray'; break; } } if (proto.message_format === 'html') { payload.message = escape(message) .replace(/\n/g, '<br/>') .replace(/\t/g, '&nbsp;&nbsp;&nbsp;&nbsp;'); } else { payload.message = message; } client.notify(room, payload, function(err) { if (err) { console.log(err); } }); }; }
[ "function", "Target", "(", "options", "=", "{", "}", ")", "{", "options", "=", "clone", "(", "options", ")", ";", "let", "client", "=", "new", "Hipchatter", "(", "options", ".", "token", ")", ";", "let", "room", "=", "options", ".", "room", ";", "delete", "options", ".", "token", ";", "delete", "options", ".", "room", ";", "let", "proto", "=", "{", "message_format", ":", "'html'", ",", "notify", ":", "false", "}", ";", "for", "(", "let", "key", "in", "options", ")", "{", "if", "(", "!", "options", ".", "hasOwnProperty", "(", "key", ")", ")", "{", "break", ";", "}", "proto", "[", "key", "]", "=", "options", "[", "key", "]", ";", "}", "return", "function", "(", "options", ",", "severity", ",", "date", ",", "message", ")", "{", "let", "payload", "=", "clone", "(", "proto", ")", ";", "if", "(", "typeof", "payload", ".", "color", "!==", "'string'", ")", "{", "switch", "(", "severity", ")", "{", "case", "'info'", ":", "payload", ".", "color", "=", "'green'", ";", "break", ";", "case", "'warn'", ":", "payload", ".", "color", "=", "'yellow'", ";", "break", ";", "case", "'error'", ":", "payload", ".", "color", "=", "'red'", ";", "break", ";", "default", ":", "payload", ".", "color", "=", "'gray'", ";", "break", ";", "}", "}", "if", "(", "proto", ".", "message_format", "===", "'html'", ")", "{", "payload", ".", "message", "=", "escape", "(", "message", ")", ".", "replace", "(", "/", "\\n", "/", "g", ",", "'<br/>'", ")", ".", "replace", "(", "/", "\\t", "/", "g", ",", "'&nbsp;&nbsp;&nbsp;&nbsp;'", ")", ";", "}", "else", "{", "payload", ".", "message", "=", "message", ";", "}", "client", ".", "notify", "(", "room", ",", "payload", ",", "function", "(", "err", ")", "{", "if", "(", "err", ")", "{", "console", ".", "log", "(", "err", ")", ";", "}", "}", ")", ";", "}", ";", "}" ]
Creates and configures an instance of the bristol-hipchat target. Establishes message defaults by way of an internal Message constructor. @constructor @param {Object} options @param {String} options.token The API key (must have the notification permission to send messages). @param {Number} options.room The Room ID to which a message should be sent. @param {String} options.from The name of the "person" from whom the message will be sent. @param {String} [options.color='yellow'] The color scheme of the message. @param {String} [options.message_format='html'] The format of the message that will be sent. @param {Boolean} [options.notify=false] A flag indicating whether or not to notify the room. Note that this setting will not override the users' notification preferences for the target room. @returns {Function} A target log function that can be registered with Bristol via `.addTarget()`.
[ "Creates", "and", "configures", "an", "instance", "of", "the", "bristol", "-", "hipchat", "target", ".", "Establishes", "message", "defaults", "by", "way", "of", "an", "internal", "Message", "constructor", "." ]
c90f64721543e3b00e28657ba841fbc04214dbf9
https://github.com/sjberry/bristol-hipchat/blob/c90f64721543e3b00e28657ba841fbc04214dbf9/main.js#L23-L83
53,414
CascadeEnergy/dispatch-fn
index.js
dispatch
function dispatch() { var commands = [].slice.call(arguments); return function fn() { var args = [].slice.call(arguments); var result; for (var i = 0; i < commands.length; i++) { result = commands[i].apply(undefined, args); if (result !== undefined) { break; } } return result; }; }
javascript
function dispatch() { var commands = [].slice.call(arguments); return function fn() { var args = [].slice.call(arguments); var result; for (var i = 0; i < commands.length; i++) { result = commands[i].apply(undefined, args); if (result !== undefined) { break; } } return result; }; }
[ "function", "dispatch", "(", ")", "{", "var", "commands", "=", "[", "]", ".", "slice", ".", "call", "(", "arguments", ")", ";", "return", "function", "fn", "(", ")", "{", "var", "args", "=", "[", "]", ".", "slice", ".", "call", "(", "arguments", ")", ";", "var", "result", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "commands", ".", "length", ";", "i", "++", ")", "{", "result", "=", "commands", "[", "i", "]", ".", "apply", "(", "undefined", ",", "args", ")", ";", "if", "(", "result", "!==", "undefined", ")", "{", "break", ";", "}", "}", "return", "result", ";", "}", ";", "}" ]
Dispatch returns a function which iterates a series of commands looking for one to return something other than undefined. @param commands @returns {Function}
[ "Dispatch", "returns", "a", "function", "which", "iterates", "a", "series", "of", "commands", "looking", "for", "one", "to", "return", "something", "other", "than", "undefined", "." ]
e3ac8135f4c15c21016c9c972a9652b09474074d
https://github.com/CascadeEnergy/dispatch-fn/blob/e3ac8135f4c15c21016c9c972a9652b09474074d/index.js#L8-L25
53,415
hyjin/node-oauth-toolkit
index.js
toArray
function toArray(obj) { var key, val, arr = []; for (key in obj) { val = obj[key]; if (Array.isArray(val)) for (var i = 0; i < val.length; i++) arr.push([ key, val[i] ]); else arr.push([ key, val ]); } return arr; }
javascript
function toArray(obj) { var key, val, arr = []; for (key in obj) { val = obj[key]; if (Array.isArray(val)) for (var i = 0; i < val.length; i++) arr.push([ key, val[i] ]); else arr.push([ key, val ]); } return arr; }
[ "function", "toArray", "(", "obj", ")", "{", "var", "key", ",", "val", ",", "arr", "=", "[", "]", ";", "for", "(", "key", "in", "obj", ")", "{", "val", "=", "obj", "[", "key", "]", ";", "if", "(", "Array", ".", "isArray", "(", "val", ")", ")", "for", "(", "var", "i", "=", "0", ";", "i", "<", "val", ".", "length", ";", "i", "++", ")", "arr", ".", "push", "(", "[", "key", ",", "val", "[", "i", "]", "]", ")", ";", "else", "arr", ".", "push", "(", "[", "key", ",", "val", "]", ")", ";", "}", "return", "arr", ";", "}" ]
Maps object to bi-dimensional array @example toArray({ foo: 'A', bar: [ 'b', 'B' ]}) will be [ ['foo', 'A'], ['bar', 'b'], ['bar', 'B'] ]
[ "Maps", "object", "to", "bi", "-", "dimensional", "array" ]
17135947c2b888cd1cfa0e80aa09f981ec1d854e
https://github.com/hyjin/node-oauth-toolkit/blob/17135947c2b888cd1cfa0e80aa09f981ec1d854e/index.js#L126-L137
53,416
chickendinosaur/yeoman-generator-node-package
generators/app/1-initializing.js
assignDeep
function assignDeep(dest, source) { if (source && source.constructor === Object) { var sourceBaseKeys = Object.keys(source); for (var i = 0; i < sourceBaseKeys.length; ++i) { var sourceBaseKey = sourceBaseKeys[i]; var destinationField = dest[sourceBaseKey]; var sourceField = source[sourceBaseKey]; if (destinationField === undefined) { dest[sourceBaseKey] = sourceField; } else { // Recursive assign. assignDeep(destinationField, sourceField); } } } }
javascript
function assignDeep(dest, source) { if (source && source.constructor === Object) { var sourceBaseKeys = Object.keys(source); for (var i = 0; i < sourceBaseKeys.length; ++i) { var sourceBaseKey = sourceBaseKeys[i]; var destinationField = dest[sourceBaseKey]; var sourceField = source[sourceBaseKey]; if (destinationField === undefined) { dest[sourceBaseKey] = sourceField; } else { // Recursive assign. assignDeep(destinationField, sourceField); } } } }
[ "function", "assignDeep", "(", "dest", ",", "source", ")", "{", "if", "(", "source", "&&", "source", ".", "constructor", "===", "Object", ")", "{", "var", "sourceBaseKeys", "=", "Object", ".", "keys", "(", "source", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "sourceBaseKeys", ".", "length", ";", "++", "i", ")", "{", "var", "sourceBaseKey", "=", "sourceBaseKeys", "[", "i", "]", ";", "var", "destinationField", "=", "dest", "[", "sourceBaseKey", "]", ";", "var", "sourceField", "=", "source", "[", "sourceBaseKey", "]", ";", "if", "(", "destinationField", "===", "undefined", ")", "{", "dest", "[", "sourceBaseKey", "]", "=", "sourceField", ";", "}", "else", "{", "// Recursive assign.", "assignDeep", "(", "destinationField", ",", "sourceField", ")", ";", "}", "}", "}", "}" ]
Object.assign removes special characters that are needed for the pacakge name and ruins the default value.
[ "Object", ".", "assign", "removes", "special", "characters", "that", "are", "needed", "for", "the", "pacakge", "name", "and", "ruins", "the", "default", "value", "." ]
53e3020595294e10c5ef2428a385501a8a5cd2ac
https://github.com/chickendinosaur/yeoman-generator-node-package/blob/53e3020595294e10c5ef2428a385501a8a5cd2ac/generators/app/1-initializing.js#L92-L109
53,417
coderaiser/util-io
lib/util.js
check
function check(args, names) { var msg = '', name = '', template = '{{ name }} coud not be empty!', indexOf = Array.prototype.indexOf, lenNames = names.length, lenArgs = args.length, lessArgs = lenArgs < lenNames, emptyIndex = indexOf.call(args), isEmpty = ~emptyIndex; if (lessArgs || isEmpty) { if (lessArgs) name = names[lenNames - 1]; else name = names[emptyIndex]; msg = Util.render(template, { name: name }); throw(Error(msg)); } return check; }
javascript
function check(args, names) { var msg = '', name = '', template = '{{ name }} coud not be empty!', indexOf = Array.prototype.indexOf, lenNames = names.length, lenArgs = args.length, lessArgs = lenArgs < lenNames, emptyIndex = indexOf.call(args), isEmpty = ~emptyIndex; if (lessArgs || isEmpty) { if (lessArgs) name = names[lenNames - 1]; else name = names[emptyIndex]; msg = Util.render(template, { name: name }); throw(Error(msg)); } return check; }
[ "function", "check", "(", "args", ",", "names", ")", "{", "var", "msg", "=", "''", ",", "name", "=", "''", ",", "template", "=", "'{{ name }} coud not be empty!'", ",", "indexOf", "=", "Array", ".", "prototype", ".", "indexOf", ",", "lenNames", "=", "names", ".", "length", ",", "lenArgs", "=", "args", ".", "length", ",", "lessArgs", "=", "lenArgs", "<", "lenNames", ",", "emptyIndex", "=", "indexOf", ".", "call", "(", "args", ")", ",", "isEmpty", "=", "~", "emptyIndex", ";", "if", "(", "lessArgs", "||", "isEmpty", ")", "{", "if", "(", "lessArgs", ")", "name", "=", "names", "[", "lenNames", "-", "1", "]", ";", "else", "name", "=", "names", "[", "emptyIndex", "]", ";", "msg", "=", "Util", ".", "render", "(", "template", ",", "{", "name", ":", "name", "}", ")", ";", "throw", "(", "Error", "(", "msg", ")", ")", ";", "}", "return", "check", ";", "}" ]
Check is all arguments with names present @param name @param arg @param type
[ "Check", "is", "all", "arguments", "with", "names", "present" ]
cccd3550f96a99e3176d24de5328663a3f7f1c1e
https://github.com/coderaiser/util-io/blob/cccd3550f96a99e3176d24de5328663a3f7f1c1e/lib/util.js#L72-L99
53,418
coderaiser/util-io
lib/util.js
type
function type(variable) { var regExp = /\s([a-zA-Z]+)/, str = {}.toString.call(variable), typeBig = str.match(regExp)[1], result = typeBig.toLowerCase(); return result; }
javascript
function type(variable) { var regExp = /\s([a-zA-Z]+)/, str = {}.toString.call(variable), typeBig = str.match(regExp)[1], result = typeBig.toLowerCase(); return result; }
[ "function", "type", "(", "variable", ")", "{", "var", "regExp", "=", "/", "\\s([a-zA-Z]+)", "/", ",", "str", "=", "{", "}", ".", "toString", ".", "call", "(", "variable", ")", ",", "typeBig", "=", "str", ".", "match", "(", "regExp", ")", "[", "1", "]", ",", "result", "=", "typeBig", ".", "toLowerCase", "(", ")", ";", "return", "result", ";", "}" ]
get type of variable @param variable
[ "get", "type", "of", "variable" ]
cccd3550f96a99e3176d24de5328663a3f7f1c1e
https://github.com/coderaiser/util-io/blob/cccd3550f96a99e3176d24de5328663a3f7f1c1e/lib/util.js#L285-L292
53,419
coderaiser/util-io
lib/util.js
function(callback) { var ret, isFunc = Util.type.function(callback), args = [].slice.call(arguments, 1); if (isFunc) ret = callback.apply(null, args); return ret; }
javascript
function(callback) { var ret, isFunc = Util.type.function(callback), args = [].slice.call(arguments, 1); if (isFunc) ret = callback.apply(null, args); return ret; }
[ "function", "(", "callback", ")", "{", "var", "ret", ",", "isFunc", "=", "Util", ".", "type", ".", "function", "(", "callback", ")", ",", "args", "=", "[", "]", ".", "slice", ".", "call", "(", "arguments", ",", "1", ")", ";", "if", "(", "isFunc", ")", "ret", "=", "callback", ".", "apply", "(", "null", ",", "args", ")", ";", "return", "ret", ";", "}" ]
function do save exec of function @param callback @param arg1 ... @param argN
[ "function", "do", "save", "exec", "of", "function" ]
cccd3550f96a99e3176d24de5328663a3f7f1c1e
https://github.com/coderaiser/util-io/blob/cccd3550f96a99e3176d24de5328663a3f7f1c1e/lib/util.js#L330-L339
53,420
novemberborn/chai-sentinels
lib/Sentinel.js
Sentinel
function Sentinel(label, propertiesObject) { if (!(this instanceof Sentinel)) { return new Sentinel(label, propertiesObject); } if (typeof label === 'object' && label) { propertiesObject = label; label = undefined; } if (typeof label === 'number') { label = String(label); } else if (typeof label !== 'undefined') { if (typeof label !== 'string' || !label) { throw new TypeError('Expected label to be a non-empty string or number.'); } } Object.defineProperties(this, { _sentinel_id: { value: ++instanceCount, //enumerable to work with Chai's `deep-eql`. enumerable: true }, _sentinel_label: { value: label } }); if (propertiesObject) { Object.defineProperties(this, propertiesObject); } }
javascript
function Sentinel(label, propertiesObject) { if (!(this instanceof Sentinel)) { return new Sentinel(label, propertiesObject); } if (typeof label === 'object' && label) { propertiesObject = label; label = undefined; } if (typeof label === 'number') { label = String(label); } else if (typeof label !== 'undefined') { if (typeof label !== 'string' || !label) { throw new TypeError('Expected label to be a non-empty string or number.'); } } Object.defineProperties(this, { _sentinel_id: { value: ++instanceCount, //enumerable to work with Chai's `deep-eql`. enumerable: true }, _sentinel_label: { value: label } }); if (propertiesObject) { Object.defineProperties(this, propertiesObject); } }
[ "function", "Sentinel", "(", "label", ",", "propertiesObject", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Sentinel", ")", ")", "{", "return", "new", "Sentinel", "(", "label", ",", "propertiesObject", ")", ";", "}", "if", "(", "typeof", "label", "===", "'object'", "&&", "label", ")", "{", "propertiesObject", "=", "label", ";", "label", "=", "undefined", ";", "}", "if", "(", "typeof", "label", "===", "'number'", ")", "{", "label", "=", "String", "(", "label", ")", ";", "}", "else", "if", "(", "typeof", "label", "!==", "'undefined'", ")", "{", "if", "(", "typeof", "label", "!==", "'string'", "||", "!", "label", ")", "{", "throw", "new", "TypeError", "(", "'Expected label to be a non-empty string or number.'", ")", ";", "}", "}", "Object", ".", "defineProperties", "(", "this", ",", "{", "_sentinel_id", ":", "{", "value", ":", "++", "instanceCount", ",", "//enumerable to work with Chai's `deep-eql`.", "enumerable", ":", "true", "}", ",", "_sentinel_label", ":", "{", "value", ":", "label", "}", "}", ")", ";", "if", "(", "propertiesObject", ")", "{", "Object", ".", "defineProperties", "(", "this", ",", "propertiesObject", ")", ";", "}", "}" ]
If truey, `propertiesObject` is used to define properties on the sentinel instance. Can be used without `new`.
[ "If", "truey", "propertiesObject", "is", "used", "to", "define", "properties", "on", "the", "sentinel", "instance", ".", "Can", "be", "used", "without", "new", "." ]
23b52bb40eba43b053ed4236dddc8a5f9ba82d0c
https://github.com/novemberborn/chai-sentinels/blob/23b52bb40eba43b053ed4236dddc8a5f9ba82d0c/lib/Sentinel.js#L20-L53
53,421
johnpaulvaughan/itunes-music-library-path
index.js
_buildPaths
function _buildPaths() { var home = os.homedir(); var path1 = path.resolve(home + '/Music/iTunes/iTunes Music Library.xml'); var path2 = path.resolve(home + '/Music/iTunes/iTunes Library.xml'); return [path1, path1]; }
javascript
function _buildPaths() { var home = os.homedir(); var path1 = path.resolve(home + '/Music/iTunes/iTunes Music Library.xml'); var path2 = path.resolve(home + '/Music/iTunes/iTunes Library.xml'); return [path1, path1]; }
[ "function", "_buildPaths", "(", ")", "{", "var", "home", "=", "os", ".", "homedir", "(", ")", ";", "var", "path1", "=", "path", ".", "resolve", "(", "home", "+", "'/Music/iTunes/iTunes Music Library.xml'", ")", ";", "var", "path2", "=", "path", ".", "resolve", "(", "home", "+", "'/Music/iTunes/iTunes Library.xml'", ")", ";", "return", "[", "path1", ",", "path1", "]", ";", "}" ]
return an array containing the two most likely iTunes XML filepaths. @param null @return Array<string>
[ "return", "an", "array", "containing", "the", "two", "most", "likely", "iTunes", "XML", "filepaths", "." ]
b798340d9ece1a8a9cc575e50a23f34df86a6ac5
https://github.com/johnpaulvaughan/itunes-music-library-path/blob/b798340d9ece1a8a9cc575e50a23f34df86a6ac5/index.js#L25-L30
53,422
Wiredcraft/carcass
lib/proto/loader.js
function() { var parser, source; source = this.source(); if (source == null) { return; } parser = this.parser(); if (parser != null) { return parser(source); } else { return source; } }
javascript
function() { var parser, source; source = this.source(); if (source == null) { return; } parser = this.parser(); if (parser != null) { return parser(source); } else { return source; } }
[ "function", "(", ")", "{", "var", "parser", ",", "source", ";", "source", "=", "this", ".", "source", "(", ")", ";", "if", "(", "source", "==", "null", ")", "{", "return", ";", "}", "parser", "=", "this", ".", "parser", "(", ")", ";", "if", "(", "parser", "!=", "null", ")", "{", "return", "parser", "(", "source", ")", ";", "}", "else", "{", "return", "source", ";", "}", "}" ]
Reload from source. Parse source if a parser is available. @return {value}
[ "Reload", "from", "source", ".", "Parse", "source", "if", "a", "parser", "is", "available", "." ]
3527ec0253f55abba8e6b255e7bf3412b3ca7501
https://github.com/Wiredcraft/carcass/blob/3527ec0253f55abba8e6b255e7bf3412b3ca7501/lib/proto/loader.js#L22-L34
53,423
dalekjs/dalek-driver-sauce
index.js
function (opts) { // get the browser configuration & the browser module var browserConf = {name: null}; var browser = opts.browserMo; // prepare properties this._initializeProperties(opts); // create a new webdriver client instance this.webdriverClient = new WD(browser, this.events); // listen on browser events this._startBrowserEventListeners(browser); // assign the current browser name browserConf.name = this.browserName; // store desired capabilities of this session this.desiredCapabilities = browser.getDesiredCapabilities(this.browserName, this.config); this.browserDefaults = browser.driverDefaults; this.browserDefaults.status = browser.getStatusDefaults(this.desiredCapabilities); this.browserData = browser; // set auth data var driverConfig = this.config.get('driver.sauce'); browser.setAuth(driverConfig.user, driverConfig.key); // launch the browser & when the browser launch // promise is fullfilled, issue the driver:ready event // for the particular browser browser .launch(browserConf, this.reporterEvents, this.config) .then(this.events.emit.bind(this.events, 'driver:ready:sauce:' + this.browserName, browser)); }
javascript
function (opts) { // get the browser configuration & the browser module var browserConf = {name: null}; var browser = opts.browserMo; // prepare properties this._initializeProperties(opts); // create a new webdriver client instance this.webdriverClient = new WD(browser, this.events); // listen on browser events this._startBrowserEventListeners(browser); // assign the current browser name browserConf.name = this.browserName; // store desired capabilities of this session this.desiredCapabilities = browser.getDesiredCapabilities(this.browserName, this.config); this.browserDefaults = browser.driverDefaults; this.browserDefaults.status = browser.getStatusDefaults(this.desiredCapabilities); this.browserData = browser; // set auth data var driverConfig = this.config.get('driver.sauce'); browser.setAuth(driverConfig.user, driverConfig.key); // launch the browser & when the browser launch // promise is fullfilled, issue the driver:ready event // for the particular browser browser .launch(browserConf, this.reporterEvents, this.config) .then(this.events.emit.bind(this.events, 'driver:ready:sauce:' + this.browserName, browser)); }
[ "function", "(", "opts", ")", "{", "// get the browser configuration & the browser module", "var", "browserConf", "=", "{", "name", ":", "null", "}", ";", "var", "browser", "=", "opts", ".", "browserMo", ";", "// prepare properties", "this", ".", "_initializeProperties", "(", "opts", ")", ";", "// create a new webdriver client instance", "this", ".", "webdriverClient", "=", "new", "WD", "(", "browser", ",", "this", ".", "events", ")", ";", "// listen on browser events", "this", ".", "_startBrowserEventListeners", "(", "browser", ")", ";", "// assign the current browser name", "browserConf", ".", "name", "=", "this", ".", "browserName", ";", "// store desired capabilities of this session", "this", ".", "desiredCapabilities", "=", "browser", ".", "getDesiredCapabilities", "(", "this", ".", "browserName", ",", "this", ".", "config", ")", ";", "this", ".", "browserDefaults", "=", "browser", ".", "driverDefaults", ";", "this", ".", "browserDefaults", ".", "status", "=", "browser", ".", "getStatusDefaults", "(", "this", ".", "desiredCapabilities", ")", ";", "this", ".", "browserData", "=", "browser", ";", "// set auth data", "var", "driverConfig", "=", "this", ".", "config", ".", "get", "(", "'driver.sauce'", ")", ";", "browser", ".", "setAuth", "(", "driverConfig", ".", "user", ",", "driverConfig", ".", "key", ")", ";", "// launch the browser & when the browser launch", "// promise is fullfilled, issue the driver:ready event", "// for the particular browser", "browser", ".", "launch", "(", "browserConf", ",", "this", ".", "reporterEvents", ",", "this", ".", "config", ")", ".", "then", "(", "this", ".", "events", ".", "emit", ".", "bind", "(", "this", ".", "events", ",", "'driver:ready:sauce:'", "+", "this", ".", "browserName", ",", "browser", ")", ")", ";", "}" ]
Initializes the sauce labs driver & the remote browser instance @param {object} opts Initializer options @constructor
[ "Initializes", "the", "sauce", "labs", "driver", "&", "the", "remote", "browser", "instance" ]
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/index.js#L42-L75
53,424
dalekjs/dalek-driver-sauce
index.js
function (opts) { // prepare properties this.actionQueue = []; this.config = opts.config; this.lastCalledUrl = null; this.driverStatus = {}; this.sessionStatus = {}; // store injcted options in object properties this.events = opts.events; this.reporterEvents = opts.reporter; this.browserName = opts.browser; return this; }
javascript
function (opts) { // prepare properties this.actionQueue = []; this.config = opts.config; this.lastCalledUrl = null; this.driverStatus = {}; this.sessionStatus = {}; // store injcted options in object properties this.events = opts.events; this.reporterEvents = opts.reporter; this.browserName = opts.browser; return this; }
[ "function", "(", "opts", ")", "{", "// prepare properties", "this", ".", "actionQueue", "=", "[", "]", ";", "this", ".", "config", "=", "opts", ".", "config", ";", "this", ".", "lastCalledUrl", "=", "null", ";", "this", ".", "driverStatus", "=", "{", "}", ";", "this", ".", "sessionStatus", "=", "{", "}", ";", "// store injcted options in object properties", "this", ".", "events", "=", "opts", ".", "events", ";", "this", ".", "reporterEvents", "=", "opts", ".", "reporter", ";", "this", ".", "browserName", "=", "opts", ".", "browser", ";", "return", "this", ";", "}" ]
Initializes the driver properties @method _initializeProperties @param {object} opts Options needed to kick off the driver @chainable @private
[ "Initializes", "the", "driver", "properties" ]
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/index.js#L175-L187
53,425
dalekjs/dalek-driver-sauce
index.js
function (browser) { // issue the kill command to the browser, when all tests are completed this.events.on('tests:complete:sauce:' + this.browserName, browser.kill.bind(browser)); // clear the webdriver session, when all tests are completed this.events.on('tests:complete:sauce:' + this.browserName, this.webdriverClient.closeSession.bind(this.webdriverClient)); return this; }
javascript
function (browser) { // issue the kill command to the browser, when all tests are completed this.events.on('tests:complete:sauce:' + this.browserName, browser.kill.bind(browser)); // clear the webdriver session, when all tests are completed this.events.on('tests:complete:sauce:' + this.browserName, this.webdriverClient.closeSession.bind(this.webdriverClient)); return this; }
[ "function", "(", "browser", ")", "{", "// issue the kill command to the browser, when all tests are completed", "this", ".", "events", ".", "on", "(", "'tests:complete:sauce:'", "+", "this", ".", "browserName", ",", "browser", ".", "kill", ".", "bind", "(", "browser", ")", ")", ";", "// clear the webdriver session, when all tests are completed", "this", ".", "events", ".", "on", "(", "'tests:complete:sauce:'", "+", "this", ".", "browserName", ",", "this", ".", "webdriverClient", ".", "closeSession", ".", "bind", "(", "this", ".", "webdriverClient", ")", ")", ";", "return", "this", ";", "}" ]
Binds listeners on browser events @method _initializeProperties @param {object} browser Browser module @chainable @private
[ "Binds", "listeners", "on", "browser", "events" ]
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/index.js#L198-L204
53,426
dalekjs/dalek-driver-sauce
index.js
function () { var deferred = Q.defer(); // store desired capabilities of this session this.desiredCapabilities = this.browserData.getDesiredCapabilities(this.browserName, this.config); this.browserDefaults = this.browserData.driverDefaults; this.browserDefaults.status = this.browserData.getStatusDefaults(this.desiredCapabilities); // start a browser session this._startBrowserSession(deferred, this.desiredCapabilities, this.browserDefaults); return deferred.promise; }
javascript
function () { var deferred = Q.defer(); // store desired capabilities of this session this.desiredCapabilities = this.browserData.getDesiredCapabilities(this.browserName, this.config); this.browserDefaults = this.browserData.driverDefaults; this.browserDefaults.status = this.browserData.getStatusDefaults(this.desiredCapabilities); // start a browser session this._startBrowserSession(deferred, this.desiredCapabilities, this.browserDefaults); return deferred.promise; }
[ "function", "(", ")", "{", "var", "deferred", "=", "Q", ".", "defer", "(", ")", ";", "// store desired capabilities of this session", "this", ".", "desiredCapabilities", "=", "this", ".", "browserData", ".", "getDesiredCapabilities", "(", "this", ".", "browserName", ",", "this", ".", "config", ")", ";", "this", ".", "browserDefaults", "=", "this", ".", "browserData", ".", "driverDefaults", ";", "this", ".", "browserDefaults", ".", "status", "=", "this", ".", "browserData", ".", "getStatusDefaults", "(", "this", ".", "desiredCapabilities", ")", ";", "// start a browser session", "this", ".", "_startBrowserSession", "(", "deferred", ",", "this", ".", "desiredCapabilities", ",", "this", ".", "browserDefaults", ")", ";", "return", "deferred", ".", "promise", ";", "}" ]
Checks if a webdriver session has already been established, if not, create a new one @method start @return {object} promise Driver promise
[ "Checks", "if", "a", "webdriver", "session", "has", "already", "been", "established", "if", "not", "create", "a", "new", "one" ]
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/index.js#L214-L226
53,427
dalekjs/dalek-driver-sauce
index.js
function () { var result = Q.resolve(); // loop through all promises created by the remote methods // this is synchronous, so it waits if a method is finished before // the next one will be executed this.actionQueue.forEach(function (f) { result = result.then(f); }); // flush the queue & fire an event // when the queue finished its executions result.then(this.flushQueue.bind(this)); return this; }
javascript
function () { var result = Q.resolve(); // loop through all promises created by the remote methods // this is synchronous, so it waits if a method is finished before // the next one will be executed this.actionQueue.forEach(function (f) { result = result.then(f); }); // flush the queue & fire an event // when the queue finished its executions result.then(this.flushQueue.bind(this)); return this; }
[ "function", "(", ")", "{", "var", "result", "=", "Q", ".", "resolve", "(", ")", ";", "// loop through all promises created by the remote methods", "// this is synchronous, so it waits if a method is finished before", "// the next one will be executed", "this", ".", "actionQueue", ".", "forEach", "(", "function", "(", "f", ")", "{", "result", "=", "result", ".", "then", "(", "f", ")", ";", "}", ")", ";", "// flush the queue & fire an event", "// when the queue finished its executions", "result", ".", "then", "(", "this", ".", "flushQueue", ".", "bind", "(", "this", ")", ")", ";", "return", "this", ";", "}" ]
Starts to execution of a batch of tests @method end @chainable
[ "Starts", "to", "execution", "of", "a", "batch", "of", "tests" ]
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/index.js#L281-L295
53,428
dalekjs/dalek-driver-sauce
index.js
function (sessionInfo) { var defer = Q.defer(); this.sessionStatus = JSON.parse(sessionInfo).value; this.events.emit('driver:sessionStatus:sauce:' + this.browserName, this.sessionStatus); defer.resolve(); return defer.promise; }
javascript
function (sessionInfo) { var defer = Q.defer(); this.sessionStatus = JSON.parse(sessionInfo).value; this.events.emit('driver:sessionStatus:sauce:' + this.browserName, this.sessionStatus); defer.resolve(); return defer.promise; }
[ "function", "(", "sessionInfo", ")", "{", "var", "defer", "=", "Q", ".", "defer", "(", ")", ";", "this", ".", "sessionStatus", "=", "JSON", ".", "parse", "(", "sessionInfo", ")", ".", "value", ";", "this", ".", "events", ".", "emit", "(", "'driver:sessionStatus:sauce:'", "+", "this", ".", "browserName", ",", "this", ".", "sessionStatus", ")", ";", "defer", ".", "resolve", "(", ")", ";", "return", "defer", ".", "promise", ";", "}" ]
Loads the browser session status @method _sessionStatus @param {object} sessionInfo Session information @return {object} promise Browser session promise @private
[ "Loads", "the", "browser", "session", "status" ]
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/index.js#L328-L334
53,429
dalekjs/dalek-driver-sauce
index.js
function (statusInfo) { var defer = Q.defer(); this.driverStatus = JSON.parse(statusInfo).value; this.events.emit('driver:status:sauce:' + this.browserName, this.driverStatus); defer.resolve(); return defer.promise; }
javascript
function (statusInfo) { var defer = Q.defer(); this.driverStatus = JSON.parse(statusInfo).value; this.events.emit('driver:status:sauce:' + this.browserName, this.driverStatus); defer.resolve(); return defer.promise; }
[ "function", "(", "statusInfo", ")", "{", "var", "defer", "=", "Q", ".", "defer", "(", ")", ";", "this", ".", "driverStatus", "=", "JSON", ".", "parse", "(", "statusInfo", ")", ".", "value", ";", "this", ".", "events", ".", "emit", "(", "'driver:status:sauce:'", "+", "this", ".", "browserName", ",", "this", ".", "driverStatus", ")", ";", "defer", ".", "resolve", "(", ")", ";", "return", "defer", ".", "promise", ";", "}" ]
Loads the browser driver status @method _driverStatus @param {object} statusInfo Driver status information @return {object} promise Driver status promise @private
[ "Loads", "the", "browser", "driver", "status" ]
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/index.js#L345-L351
53,430
OpenSmartEnvironment/ose-lirc
lib/lirc/node.js
onError
function onError() { // {{{2 O.log.unhandled('LIRC ERROR', arguments); delete this.socket; setTimeout(connect.bind(null, this), 1000); }
javascript
function onError() { // {{{2 O.log.unhandled('LIRC ERROR', arguments); delete this.socket; setTimeout(connect.bind(null, this), 1000); }
[ "function", "onError", "(", ")", "{", "// {{{2", "O", ".", "log", ".", "unhandled", "(", "'LIRC ERROR'", ",", "arguments", ")", ";", "delete", "this", ".", "socket", ";", "setTimeout", "(", "connect", ".", "bind", "(", "null", ",", "this", ")", ",", "1000", ")", ";", "}" ]
Entry Event Handlers {{{1 `this` is bound to entry.
[ "Entry", "Event", "Handlers", "{{{", "1", "this", "is", "bound", "to", "entry", "." ]
a9882e44d84d75420eae3da25f89977ac70a33fe
https://github.com/OpenSmartEnvironment/ose-lirc/blob/a9882e44d84d75420eae3da25f89977ac70a33fe/lib/lirc/node.js#L14-L20
53,431
lr360/fidem-signer
lib/auth-header.js
extractParameters
function extractParameters(header) { var SEPARATOR = /(?: |,)/g; var OPERATOR = /=/; return header.split(SEPARATOR).reduce(function (parameters, property) { var parts = property.split(OPERATOR).map(function (part) { return part.trim(); }); if (parts.length === 2) parameters[parts[0]] = parts[1]; return parameters; }, {}); }
javascript
function extractParameters(header) { var SEPARATOR = /(?: |,)/g; var OPERATOR = /=/; return header.split(SEPARATOR).reduce(function (parameters, property) { var parts = property.split(OPERATOR).map(function (part) { return part.trim(); }); if (parts.length === 2) parameters[parts[0]] = parts[1]; return parameters; }, {}); }
[ "function", "extractParameters", "(", "header", ")", "{", "var", "SEPARATOR", "=", "/", "(?: |,)", "/", "g", ";", "var", "OPERATOR", "=", "/", "=", "/", ";", "return", "header", ".", "split", "(", "SEPARATOR", ")", ".", "reduce", "(", "function", "(", "parameters", ",", "property", ")", "{", "var", "parts", "=", "property", ".", "split", "(", "OPERATOR", ")", ".", "map", "(", "function", "(", "part", ")", "{", "return", "part", ".", "trim", "(", ")", ";", "}", ")", ";", "if", "(", "parts", ".", "length", "===", "2", ")", "parameters", "[", "parts", "[", "0", "]", "]", "=", "parts", "[", "1", "]", ";", "return", "parameters", ";", "}", ",", "{", "}", ")", ";", "}" ]
Extract parameters from header. @param {string} header @returns {object}
[ "Extract", "parameters", "from", "header", "." ]
12b3265f5373195d2842a65ed0d0ae4f242027c9
https://github.com/lr360/fidem-signer/blob/12b3265f5373195d2842a65ed0d0ae4f242027c9/lib/auth-header.js#L54-L68
53,432
jka6502/stratum
lib/require.js
each
function each(object, callback) { if (!object) { return true; } if (object.forEach) { return object.forEach(callback); } if (object instanceof Array) { var length = array ? array.length : 0; for(var index = 0; index < length; index++) { callback(array[index], index); } }else{ for(var key in object) { if (!object.hasOwnProperty(key)) { continue; } callback(object[key], key); } } return false; }
javascript
function each(object, callback) { if (!object) { return true; } if (object.forEach) { return object.forEach(callback); } if (object instanceof Array) { var length = array ? array.length : 0; for(var index = 0; index < length; index++) { callback(array[index], index); } }else{ for(var key in object) { if (!object.hasOwnProperty(key)) { continue; } callback(object[key], key); } } return false; }
[ "function", "each", "(", "object", ",", "callback", ")", "{", "if", "(", "!", "object", ")", "{", "return", "true", ";", "}", "if", "(", "object", ".", "forEach", ")", "{", "return", "object", ".", "forEach", "(", "callback", ")", ";", "}", "if", "(", "object", "instanceof", "Array", ")", "{", "var", "length", "=", "array", "?", "array", ".", "length", ":", "0", ";", "for", "(", "var", "index", "=", "0", ";", "index", "<", "length", ";", "index", "++", ")", "{", "callback", "(", "array", "[", "index", "]", ",", "index", ")", ";", "}", "}", "else", "{", "for", "(", "var", "key", "in", "object", ")", "{", "if", "(", "!", "object", ".", "hasOwnProperty", "(", "key", ")", ")", "{", "continue", ";", "}", "callback", "(", "object", "[", "key", "]", ",", "key", ")", ";", "}", "}", "return", "false", ";", "}" ]
Generic iterator. Iterate over array elements, or object properties, invoking the `callback` specified on each item, using `Array.prototype.forEach` when available, or a polyfill, when not.
[ "Generic", "iterator", ".", "Iterate", "over", "array", "elements", "or", "object", "properties", "invoking", "the", "callback", "specified", "on", "each", "item", "using", "Array", ".", "prototype", ".", "forEach", "when", "available", "or", "a", "polyfill", "when", "not", "." ]
698a8abfb07436eda76813786de2d49f08d4081b
https://github.com/jka6502/stratum/blob/698a8abfb07436eda76813786de2d49f08d4081b/lib/require.js#L15-L30
53,433
jka6502/stratum
lib/require.js
every
function every(object, callback) { if (!object) { return true; } if (object.every) { return object.every(callback); } if (object instanceof Array) { var length = array ? array.length : 0; for(var index = 0; index < length; index++) { if (!callback(array[index], index)) { return false; } } }else{ for(var key in object) { if (!object.hasOwnProperty(key)) { continue; } if (!callback(object[key], key)) { return false; } } } return true; }
javascript
function every(object, callback) { if (!object) { return true; } if (object.every) { return object.every(callback); } if (object instanceof Array) { var length = array ? array.length : 0; for(var index = 0; index < length; index++) { if (!callback(array[index], index)) { return false; } } }else{ for(var key in object) { if (!object.hasOwnProperty(key)) { continue; } if (!callback(object[key], key)) { return false; } } } return true; }
[ "function", "every", "(", "object", ",", "callback", ")", "{", "if", "(", "!", "object", ")", "{", "return", "true", ";", "}", "if", "(", "object", ".", "every", ")", "{", "return", "object", ".", "every", "(", "callback", ")", ";", "}", "if", "(", "object", "instanceof", "Array", ")", "{", "var", "length", "=", "array", "?", "array", ".", "length", ":", "0", ";", "for", "(", "var", "index", "=", "0", ";", "index", "<", "length", ";", "index", "++", ")", "{", "if", "(", "!", "callback", "(", "array", "[", "index", "]", ",", "index", ")", ")", "{", "return", "false", ";", "}", "}", "}", "else", "{", "for", "(", "var", "key", "in", "object", ")", "{", "if", "(", "!", "object", ".", "hasOwnProperty", "(", "key", ")", ")", "{", "continue", ";", "}", "if", "(", "!", "callback", "(", "object", "[", "key", "]", ",", "key", ")", ")", "{", "return", "false", ";", "}", "}", "}", "return", "true", ";", "}" ]
Generic 'every' function. Tolerant of null 'objects' and works on arrays or arbitrary objects.
[ "Generic", "every", "function", ".", "Tolerant", "of", "null", "objects", "and", "works", "on", "arrays", "or", "arbitrary", "objects", "." ]
698a8abfb07436eda76813786de2d49f08d4081b
https://github.com/jka6502/stratum/blob/698a8abfb07436eda76813786de2d49f08d4081b/lib/require.js#L62-L77
53,434
jka6502/stratum
lib/require.js
clone
function clone(object, deep) { if (!object) { return object; } var clone = object.prototype ? Object.create(object.prototype.constructor) : {}; for(var key in object) { if (!object.hasOwnProperty(key)) { continue; } clone[key] = deep ? clone(object[key], deep) : object[key]; } return clone; }
javascript
function clone(object, deep) { if (!object) { return object; } var clone = object.prototype ? Object.create(object.prototype.constructor) : {}; for(var key in object) { if (!object.hasOwnProperty(key)) { continue; } clone[key] = deep ? clone(object[key], deep) : object[key]; } return clone; }
[ "function", "clone", "(", "object", ",", "deep", ")", "{", "if", "(", "!", "object", ")", "{", "return", "object", ";", "}", "var", "clone", "=", "object", ".", "prototype", "?", "Object", ".", "create", "(", "object", ".", "prototype", ".", "constructor", ")", ":", "{", "}", ";", "for", "(", "var", "key", "in", "object", ")", "{", "if", "(", "!", "object", ".", "hasOwnProperty", "(", "key", ")", ")", "{", "continue", ";", "}", "clone", "[", "key", "]", "=", "deep", "?", "clone", "(", "object", "[", "key", "]", ",", "deep", ")", ":", "object", "[", "key", "]", ";", "}", "return", "clone", ";", "}" ]
Create a clone of the object specified. If `deep` is truthy, clone any referenced properties too.
[ "Create", "a", "clone", "of", "the", "object", "specified", ".", "If", "deep", "is", "truthy", "clone", "any", "referenced", "properties", "too", "." ]
698a8abfb07436eda76813786de2d49f08d4081b
https://github.com/jka6502/stratum/blob/698a8abfb07436eda76813786de2d49f08d4081b/lib/require.js#L102-L112
53,435
jka6502/stratum
lib/require.js
function(paths) { var base = Script.current(this).absolute; each(paths, function(item, index) { var path = paths[index] = URL.absolute(URL.clean(item), base); if (path[path.length - 1] !== '/') { paths[index] += '/'; } }); return paths; }
javascript
function(paths) { var base = Script.current(this).absolute; each(paths, function(item, index) { var path = paths[index] = URL.absolute(URL.clean(item), base); if (path[path.length - 1] !== '/') { paths[index] += '/'; } }); return paths; }
[ "function", "(", "paths", ")", "{", "var", "base", "=", "Script", ".", "current", "(", "this", ")", ".", "absolute", ";", "each", "(", "paths", ",", "function", "(", "item", ",", "index", ")", "{", "var", "path", "=", "paths", "[", "index", "]", "=", "URL", ".", "absolute", "(", "URL", ".", "clean", "(", "item", ")", ",", "base", ")", ";", "if", "(", "path", "[", "path", ".", "length", "-", "1", "]", "!==", "'/'", ")", "{", "paths", "[", "index", "]", "+=", "'/'", ";", "}", "}", ")", ";", "return", "paths", ";", "}" ]
Resolve supplied paths relative to the current script, or page URL, to configure absolute base paths of a `Loader` instance.
[ "Resolve", "supplied", "paths", "relative", "to", "the", "current", "script", "or", "page", "URL", "to", "configure", "absolute", "base", "paths", "of", "a", "Loader", "instance", "." ]
698a8abfb07436eda76813786de2d49f08d4081b
https://github.com/jka6502/stratum/blob/698a8abfb07436eda76813786de2d49f08d4081b/lib/require.js#L165-L174
53,436
jka6502/stratum
lib/require.js
function(script) { if (script.loader !== this) { return script.loader.load(script); } Loader.loaded = false; if (this.loaded[script.id]) { return true; } if (this.failed[script.id]) { throw new Error('No such file: ' + script.url); } this.pending[script.id] = script; return false; }
javascript
function(script) { if (script.loader !== this) { return script.loader.load(script); } Loader.loaded = false; if (this.loaded[script.id]) { return true; } if (this.failed[script.id]) { throw new Error('No such file: ' + script.url); } this.pending[script.id] = script; return false; }
[ "function", "(", "script", ")", "{", "if", "(", "script", ".", "loader", "!==", "this", ")", "{", "return", "script", ".", "loader", ".", "load", "(", "script", ")", ";", "}", "Loader", ".", "loaded", "=", "false", ";", "if", "(", "this", ".", "loaded", "[", "script", ".", "id", "]", ")", "{", "return", "true", ";", "}", "if", "(", "this", ".", "failed", "[", "script", ".", "id", "]", ")", "{", "throw", "new", "Error", "(", "'No such file: '", "+", "script", ".", "url", ")", ";", "}", "this", ".", "pending", "[", "script", ".", "id", "]", "=", "script", ";", "return", "false", ";", "}" ]
Queue the `Script` specified for loading.
[ "Queue", "the", "Script", "specified", "for", "loading", "." ]
698a8abfb07436eda76813786de2d49f08d4081b
https://github.com/jka6502/stratum/blob/698a8abfb07436eda76813786de2d49f08d4081b/lib/require.js#L185-L195
53,437
jka6502/stratum
lib/require.js
function() { if (Loader.loading) { return false; } var count = 0; if (some(this.pending, function(script) { count++; if (script.satisfied()) { Loader.loading = script; script.module.install(); script.load(); return true; } return false; }) || count === 0) { return true; } return false; }
javascript
function() { if (Loader.loading) { return false; } var count = 0; if (some(this.pending, function(script) { count++; if (script.satisfied()) { Loader.loading = script; script.module.install(); script.load(); return true; } return false; }) || count === 0) { return true; } return false; }
[ "function", "(", ")", "{", "if", "(", "Loader", ".", "loading", ")", "{", "return", "false", ";", "}", "var", "count", "=", "0", ";", "if", "(", "some", "(", "this", ".", "pending", ",", "function", "(", "script", ")", "{", "count", "++", ";", "if", "(", "script", ".", "satisfied", "(", ")", ")", "{", "Loader", ".", "loading", "=", "script", ";", "script", ".", "module", ".", "install", "(", ")", ";", "script", ".", "load", "(", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}", ")", "||", "count", "===", "0", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Begin loading the next viable `Script`.
[ "Begin", "loading", "the", "next", "viable", "Script", "." ]
698a8abfb07436eda76813786de2d49f08d4081b
https://github.com/jka6502/stratum/blob/698a8abfb07436eda76813786de2d49f08d4081b/lib/require.js#L199-L215
53,438
jka6502/stratum
lib/require.js
function() { var pending = this.pending, script; for(var name in pending) { if (!pending.hasOwnProperty(name)) { continue; } var cycle = pending[name].cycle(); if (cycle) { cycle[0].allow(cycle[1]); this.load(cycle[0]); return true; } } }
javascript
function() { var pending = this.pending, script; for(var name in pending) { if (!pending.hasOwnProperty(name)) { continue; } var cycle = pending[name].cycle(); if (cycle) { cycle[0].allow(cycle[1]); this.load(cycle[0]); return true; } } }
[ "function", "(", ")", "{", "var", "pending", "=", "this", ".", "pending", ",", "script", ";", "for", "(", "var", "name", "in", "pending", ")", "{", "if", "(", "!", "pending", ".", "hasOwnProperty", "(", "name", ")", ")", "{", "continue", ";", "}", "var", "cycle", "=", "pending", "[", "name", "]", ".", "cycle", "(", ")", ";", "if", "(", "cycle", ")", "{", "cycle", "[", "0", "]", ".", "allow", "(", "cycle", "[", "1", "]", ")", ";", "this", ".", "load", "(", "cycle", "[", "0", "]", ")", ";", "return", "true", ";", "}", "}", "}" ]
Resolve a cyclic dependency between queued `Script`s.
[ "Resolve", "a", "cyclic", "dependency", "between", "queued", "Script", "s", "." ]
698a8abfb07436eda76813786de2d49f08d4081b
https://github.com/jka6502/stratum/blob/698a8abfb07436eda76813786de2d49f08d4081b/lib/require.js#L219-L232
53,439
jka6502/stratum
lib/require.js
function(script) { script.module.uninstall(); if (script.stopped || (!script.callback && Loader.loading !== script)) { script.loader.load(script); Loader.next(); return; } this.loaded[script.id] = script; delete this.pending[script.id]; Loader.loading = null; Loader.next(); }
javascript
function(script) { script.module.uninstall(); if (script.stopped || (!script.callback && Loader.loading !== script)) { script.loader.load(script); Loader.next(); return; } this.loaded[script.id] = script; delete this.pending[script.id]; Loader.loading = null; Loader.next(); }
[ "function", "(", "script", ")", "{", "script", ".", "module", ".", "uninstall", "(", ")", ";", "if", "(", "script", ".", "stopped", "||", "(", "!", "script", ".", "callback", "&&", "Loader", ".", "loading", "!==", "script", ")", ")", "{", "script", ".", "loader", ".", "load", "(", "script", ")", ";", "Loader", ".", "next", "(", ")", ";", "return", ";", "}", "this", ".", "loaded", "[", "script", ".", "id", "]", "=", "script", ";", "delete", "this", ".", "pending", "[", "script", ".", "id", "]", ";", "Loader", ".", "loading", "=", "null", ";", "Loader", ".", "next", "(", ")", ";", "}" ]
Event fired when a `Script` managed by this `Loader` has loaded.
[ "Event", "fired", "when", "a", "Script", "managed", "by", "this", "Loader", "has", "loaded", "." ]
698a8abfb07436eda76813786de2d49f08d4081b
https://github.com/jka6502/stratum/blob/698a8abfb07436eda76813786de2d49f08d4081b/lib/require.js#L236-L247
53,440
jka6502/stratum
lib/require.js
function(script) { script.module.uninstall(); if (Loader.loading === script) { Loader.loading = null; } script.destroy(); if (!script.next()) { delete this.pending[script.id]; this.failed[script.id] = script; } Loader.next(); }
javascript
function(script) { script.module.uninstall(); if (Loader.loading === script) { Loader.loading = null; } script.destroy(); if (!script.next()) { delete this.pending[script.id]; this.failed[script.id] = script; } Loader.next(); }
[ "function", "(", "script", ")", "{", "script", ".", "module", ".", "uninstall", "(", ")", ";", "if", "(", "Loader", ".", "loading", "===", "script", ")", "{", "Loader", ".", "loading", "=", "null", ";", "}", "script", ".", "destroy", "(", ")", ";", "if", "(", "!", "script", ".", "next", "(", ")", ")", "{", "delete", "this", ".", "pending", "[", "script", ".", "id", "]", ";", "this", ".", "failed", "[", "script", ".", "id", "]", "=", "script", ";", "}", "Loader", ".", "next", "(", ")", ";", "}" ]
Even fired when a `Script` managed by this `Loader` has failed.
[ "Even", "fired", "when", "a", "Script", "managed", "by", "this", "Loader", "has", "failed", "." ]
698a8abfb07436eda76813786de2d49f08d4081b
https://github.com/jka6502/stratum/blob/698a8abfb07436eda76813786de2d49f08d4081b/lib/require.js#L251-L262
53,441
jka6502/stratum
lib/require.js
function(url) { var loaded = this.loaded, pending = this.pending, failed = this.failed, relative = this.relative(url); return loaded[relative] || pending[relative] || [failed[relative]]; }
javascript
function(url) { var loaded = this.loaded, pending = this.pending, failed = this.failed, relative = this.relative(url); return loaded[relative] || pending[relative] || [failed[relative]]; }
[ "function", "(", "url", ")", "{", "var", "loaded", "=", "this", ".", "loaded", ",", "pending", "=", "this", ".", "pending", ",", "failed", "=", "this", ".", "failed", ",", "relative", "=", "this", ".", "relative", "(", "url", ")", ";", "return", "loaded", "[", "relative", "]", "||", "pending", "[", "relative", "]", "||", "[", "failed", "[", "relative", "]", "]", ";", "}" ]
Find the first `Script` that matches the `url` passed, resolving possible base path relative urls.
[ "Find", "the", "first", "Script", "that", "matches", "the", "url", "passed", "resolving", "possible", "base", "path", "relative", "urls", "." ]
698a8abfb07436eda76813786de2d49f08d4081b
https://github.com/jka6502/stratum/blob/698a8abfb07436eda76813786de2d49f08d4081b/lib/require.js#L267-L274
53,442
jka6502/stratum
lib/require.js
function(callback) { var original = Loader.using; Loader.using = this; try{ callback(); }finally{ Loader.using = original; } }
javascript
function(callback) { var original = Loader.using; Loader.using = this; try{ callback(); }finally{ Loader.using = original; } }
[ "function", "(", "callback", ")", "{", "var", "original", "=", "Loader", ".", "using", ";", "Loader", ".", "using", "=", "this", ";", "try", "{", "callback", "(", ")", ";", "}", "finally", "{", "Loader", ".", "using", "=", "original", ";", "}", "}" ]
Use this `Loader` for the duration of the callback specified.
[ "Use", "this", "Loader", "for", "the", "duration", "of", "the", "callback", "specified", "." ]
698a8abfb07436eda76813786de2d49f08d4081b
https://github.com/jka6502/stratum/blob/698a8abfb07436eda76813786de2d49f08d4081b/lib/require.js#L349-L357
53,443
jka6502/stratum
lib/require.js
function(url) { var paths = this.paths; for(var index = 0; index < paths.length; index++) { var path = paths[index]; if (path === url.substring(0, path.length)) { return url.substring(path.length); } } return url; }
javascript
function(url) { var paths = this.paths; for(var index = 0; index < paths.length; index++) { var path = paths[index]; if (path === url.substring(0, path.length)) { return url.substring(path.length); } } return url; }
[ "function", "(", "url", ")", "{", "var", "paths", "=", "this", ".", "paths", ";", "for", "(", "var", "index", "=", "0", ";", "index", "<", "paths", ".", "length", ";", "index", "++", ")", "{", "var", "path", "=", "paths", "[", "index", "]", ";", "if", "(", "path", "===", "url", ".", "substring", "(", "0", ",", "path", ".", "length", ")", ")", "{", "return", "url", ".", "substring", "(", "path", ".", "length", ")", ";", "}", "}", "return", "url", ";", "}" ]
Find the `url` supplied, relative to the first matching base path.
[ "Find", "the", "url", "supplied", "relative", "to", "the", "first", "matching", "base", "path", "." ]
698a8abfb07436eda76813786de2d49f08d4081b
https://github.com/jka6502/stratum/blob/698a8abfb07436eda76813786de2d49f08d4081b/lib/require.js#L361-L370
53,444
jka6502/stratum
lib/require.js
function() { if (!this.remain.length) { return false; } var next = this.remain.shift(); this.absolute = URL.absolute(this.url, next); return true; }
javascript
function() { if (!this.remain.length) { return false; } var next = this.remain.shift(); this.absolute = URL.absolute(this.url, next); return true; }
[ "function", "(", ")", "{", "if", "(", "!", "this", ".", "remain", ".", "length", ")", "{", "return", "false", ";", "}", "var", "next", "=", "this", ".", "remain", ".", "shift", "(", ")", ";", "this", ".", "absolute", "=", "URL", ".", "absolute", "(", "this", ".", "url", ",", "next", ")", ";", "return", "true", ";", "}" ]
Select the next viable `path` from the owning `Loader` to try and load this script from, returns true if another path is viable, false if there are no remaining acceptable paths.
[ "Select", "the", "next", "viable", "path", "from", "the", "owning", "Loader", "to", "try", "and", "load", "this", "script", "from", "returns", "true", "if", "another", "path", "is", "viable", "false", "if", "there", "are", "no", "remaining", "acceptable", "paths", "." ]
698a8abfb07436eda76813786de2d49f08d4081b
https://github.com/jka6502/stratum/blob/698a8abfb07436eda76813786de2d49f08d4081b/lib/require.js#L493-L498
53,445
jka6502/stratum
lib/require.js
function() { delete this.stopped; if (this.callback) { try{ this.module.exports = this.callback(); }catch(e) { if (e === STOP_EVENT) { this.onfail(); }else{ return this.onfail(); } } return this.onload(); }else{ this.create(); this.bind(); document.head.appendChild(this.tag); } }
javascript
function() { delete this.stopped; if (this.callback) { try{ this.module.exports = this.callback(); }catch(e) { if (e === STOP_EVENT) { this.onfail(); }else{ return this.onfail(); } } return this.onload(); }else{ this.create(); this.bind(); document.head.appendChild(this.tag); } }
[ "function", "(", ")", "{", "delete", "this", ".", "stopped", ";", "if", "(", "this", ".", "callback", ")", "{", "try", "{", "this", ".", "module", ".", "exports", "=", "this", ".", "callback", "(", ")", ";", "}", "catch", "(", "e", ")", "{", "if", "(", "e", "===", "STOP_EVENT", ")", "{", "this", ".", "onfail", "(", ")", ";", "}", "else", "{", "return", "this", ".", "onfail", "(", ")", ";", "}", "}", "return", "this", ".", "onload", "(", ")", ";", "}", "else", "{", "this", ".", "create", "(", ")", ";", "this", ".", "bind", "(", ")", ";", "document", ".", "head", ".", "appendChild", "(", "this", ".", "tag", ")", ";", "}", "}" ]
Attempt to load this `Script`.
[ "Attempt", "to", "load", "this", "Script", "." ]
698a8abfb07436eda76813786de2d49f08d4081b
https://github.com/jka6502/stratum/blob/698a8abfb07436eda76813786de2d49f08d4081b/lib/require.js#L502-L520
53,446
jka6502/stratum
lib/require.js
function() { if (this.events) { return; } var tag = this.tag, script = this, prefix = '', method = 'addEventListener'; // The alternative is nuking Redmond from orbit, its the only way to // be sure... if (!tag.addEventListener) { prefix = 'on'; method = 'attachEvent'; } function loaded(event) { script.onload(); } function failed(event) { script.onfail(); } function state(event) { switch(tag.readyState) { case 'complete': return loaded(event); case 'error': return failed(event); } } if (prefix === '') { tag[method](prefix + 'error', failed); tag[method](prefix + 'load', loaded); }else{ tag[method](prefix + 'readystatechange', state); } this.events = { loaded: loaded, failed: failed, state: state }; return this; }
javascript
function() { if (this.events) { return; } var tag = this.tag, script = this, prefix = '', method = 'addEventListener'; // The alternative is nuking Redmond from orbit, its the only way to // be sure... if (!tag.addEventListener) { prefix = 'on'; method = 'attachEvent'; } function loaded(event) { script.onload(); } function failed(event) { script.onfail(); } function state(event) { switch(tag.readyState) { case 'complete': return loaded(event); case 'error': return failed(event); } } if (prefix === '') { tag[method](prefix + 'error', failed); tag[method](prefix + 'load', loaded); }else{ tag[method](prefix + 'readystatechange', state); } this.events = { loaded: loaded, failed: failed, state: state }; return this; }
[ "function", "(", ")", "{", "if", "(", "this", ".", "events", ")", "{", "return", ";", "}", "var", "tag", "=", "this", ".", "tag", ",", "script", "=", "this", ",", "prefix", "=", "''", ",", "method", "=", "'addEventListener'", ";", "// The alternative is nuking Redmond from orbit, its the only way to\r", "// be sure...\r", "if", "(", "!", "tag", ".", "addEventListener", ")", "{", "prefix", "=", "'on'", ";", "method", "=", "'attachEvent'", ";", "}", "function", "loaded", "(", "event", ")", "{", "script", ".", "onload", "(", ")", ";", "}", "function", "failed", "(", "event", ")", "{", "script", ".", "onfail", "(", ")", ";", "}", "function", "state", "(", "event", ")", "{", "switch", "(", "tag", ".", "readyState", ")", "{", "case", "'complete'", ":", "return", "loaded", "(", "event", ")", ";", "case", "'error'", ":", "return", "failed", "(", "event", ")", ";", "}", "}", "if", "(", "prefix", "===", "''", ")", "{", "tag", "[", "method", "]", "(", "prefix", "+", "'error'", ",", "failed", ")", ";", "tag", "[", "method", "]", "(", "prefix", "+", "'load'", ",", "loaded", ")", ";", "}", "else", "{", "tag", "[", "method", "]", "(", "prefix", "+", "'readystatechange'", ",", "state", ")", ";", "}", "this", ".", "events", "=", "{", "loaded", ":", "loaded", ",", "failed", ":", "failed", ",", "state", ":", "state", "}", ";", "return", "this", ";", "}" ]
Bind events to indicate success, or failure, of loading this `Script` instance.
[ "Bind", "events", "to", "indicate", "success", "or", "failure", "of", "loading", "this", "Script", "instance", "." ]
698a8abfb07436eda76813786de2d49f08d4081b
https://github.com/jka6502/stratum/blob/698a8abfb07436eda76813786de2d49f08d4081b/lib/require.js#L572-L616
53,447
jka6502/stratum
lib/require.js
function() { var depends = this.depends, allowed = this.allowed; return every(depends, function(depend) { return depend.loader.loaded[depend.id] || depend.loader.failed[depend.id] || allowed[depend.id]; }); }
javascript
function() { var depends = this.depends, allowed = this.allowed; return every(depends, function(depend) { return depend.loader.loaded[depend.id] || depend.loader.failed[depend.id] || allowed[depend.id]; }); }
[ "function", "(", ")", "{", "var", "depends", "=", "this", ".", "depends", ",", "allowed", "=", "this", ".", "allowed", ";", "return", "every", "(", "depends", ",", "function", "(", "depend", ")", "{", "return", "depend", ".", "loader", ".", "loaded", "[", "depend", ".", "id", "]", "||", "depend", ".", "loader", ".", "failed", "[", "depend", ".", "id", "]", "||", "allowed", "[", "depend", ".", "id", "]", ";", "}", ")", ";", "}" ]
Check whether this `Script`'s dependencies have been satisfied.
[ "Check", "whether", "this", "Script", "s", "dependencies", "have", "been", "satisfied", "." ]
698a8abfb07436eda76813786de2d49f08d4081b
https://github.com/jka6502/stratum/blob/698a8abfb07436eda76813786de2d49f08d4081b/lib/require.js#L665-L674
53,448
jka6502/stratum
lib/require.js
function(requesters, parent) { if (this.satisfied()) { return null; } requesters = requesters || {}; var id = this.id; if (requesters[id] && !parent.allowed[id]) { return [parent, this]; } requesters[id] = this; var depends = this.depends; for(var name in depends) { if (!depends.hasOwnProperty(name)) { continue; } var depend = depends[name], result = depend.cycle(requesters, this); if (result) { return result; } } delete requesters[id]; return null; }
javascript
function(requesters, parent) { if (this.satisfied()) { return null; } requesters = requesters || {}; var id = this.id; if (requesters[id] && !parent.allowed[id]) { return [parent, this]; } requesters[id] = this; var depends = this.depends; for(var name in depends) { if (!depends.hasOwnProperty(name)) { continue; } var depend = depends[name], result = depend.cycle(requesters, this); if (result) { return result; } } delete requesters[id]; return null; }
[ "function", "(", "requesters", ",", "parent", ")", "{", "if", "(", "this", ".", "satisfied", "(", ")", ")", "{", "return", "null", ";", "}", "requesters", "=", "requesters", "||", "{", "}", ";", "var", "id", "=", "this", ".", "id", ";", "if", "(", "requesters", "[", "id", "]", "&&", "!", "parent", ".", "allowed", "[", "id", "]", ")", "{", "return", "[", "parent", ",", "this", "]", ";", "}", "requesters", "[", "id", "]", "=", "this", ";", "var", "depends", "=", "this", ".", "depends", ";", "for", "(", "var", "name", "in", "depends", ")", "{", "if", "(", "!", "depends", ".", "hasOwnProperty", "(", "name", ")", ")", "{", "continue", ";", "}", "var", "depend", "=", "depends", "[", "name", "]", ",", "result", "=", "depend", ".", "cycle", "(", "requesters", ",", "this", ")", ";", "if", "(", "result", ")", "{", "return", "result", ";", "}", "}", "delete", "requesters", "[", "id", "]", ";", "return", "null", ";", "}" ]
Detect cyclic dependencies between this `Script` and those it depends on.
[ "Detect", "cyclic", "dependencies", "between", "this", "Script", "and", "those", "it", "depends", "on", "." ]
698a8abfb07436eda76813786de2d49f08d4081b
https://github.com/jka6502/stratum/blob/698a8abfb07436eda76813786de2d49f08d4081b/lib/require.js#L686-L706
53,449
jka6502/stratum
lib/require.js
function() { this.loaded = false; this.stopped = true; var current = Script.current(this.loader); // Unbind and remove the relevant tag, if any. this.destroy(); // Welcome traveller! You've discovered the ugly truth! This is // the 'magic' of the require script, allowing execution to be // halted until dependencies have been satisfied. Basically it: // // * Sets up top level error handlers // * throws an error // * catches that error at the top level // * reverts the handling functionality back to its original state // // It is definitely not pretty, but by doing so we can halt // execution of a script at an arbitrary point, as long as the stack // does not have any `try{ ... }catch{ ... }` blocks along the way. var existing = window.onerror, tag = this.tag; function handler(event) { if (event.target !== window) { return true; } if (root.removeEventListener) { root.removeEventListener('error', handler, true); }else root.detachEvent('onerror', handler); window.onerror = existing; return Event.cancel(event); } window.onerror = handler; if (root.addEventListener) { root.addEventListener('error', handler, true); }else root.attachEvent('onerror', handler); throw STOP_EVENT; }
javascript
function() { this.loaded = false; this.stopped = true; var current = Script.current(this.loader); // Unbind and remove the relevant tag, if any. this.destroy(); // Welcome traveller! You've discovered the ugly truth! This is // the 'magic' of the require script, allowing execution to be // halted until dependencies have been satisfied. Basically it: // // * Sets up top level error handlers // * throws an error // * catches that error at the top level // * reverts the handling functionality back to its original state // // It is definitely not pretty, but by doing so we can halt // execution of a script at an arbitrary point, as long as the stack // does not have any `try{ ... }catch{ ... }` blocks along the way. var existing = window.onerror, tag = this.tag; function handler(event) { if (event.target !== window) { return true; } if (root.removeEventListener) { root.removeEventListener('error', handler, true); }else root.detachEvent('onerror', handler); window.onerror = existing; return Event.cancel(event); } window.onerror = handler; if (root.addEventListener) { root.addEventListener('error', handler, true); }else root.attachEvent('onerror', handler); throw STOP_EVENT; }
[ "function", "(", ")", "{", "this", ".", "loaded", "=", "false", ";", "this", ".", "stopped", "=", "true", ";", "var", "current", "=", "Script", ".", "current", "(", "this", ".", "loader", ")", ";", "// Unbind and remove the relevant tag, if any.\r", "this", ".", "destroy", "(", ")", ";", "// Welcome traveller! You've discovered the ugly truth! This is\r", "// the 'magic' of the require script, allowing execution to be\r", "// halted until dependencies have been satisfied. Basically it:\r", "//\r", "// * Sets up top level error handlers\r", "// * throws an error\r", "// * catches that error at the top level\r", "// * reverts the handling functionality back to its original state\r", "//\r", "// It is definitely not pretty, but by doing so we can halt\r", "// execution of a script at an arbitrary point, as long as the stack\r", "// does not have any `try{ ... }catch{ ... }` blocks along the way.\r", "var", "existing", "=", "window", ".", "onerror", ",", "tag", "=", "this", ".", "tag", ";", "function", "handler", "(", "event", ")", "{", "if", "(", "event", ".", "target", "!==", "window", ")", "{", "return", "true", ";", "}", "if", "(", "root", ".", "removeEventListener", ")", "{", "root", ".", "removeEventListener", "(", "'error'", ",", "handler", ",", "true", ")", ";", "}", "else", "root", ".", "detachEvent", "(", "'onerror'", ",", "handler", ")", ";", "window", ".", "onerror", "=", "existing", ";", "return", "Event", ".", "cancel", "(", "event", ")", ";", "}", "window", ".", "onerror", "=", "handler", ";", "if", "(", "root", ".", "addEventListener", ")", "{", "root", ".", "addEventListener", "(", "'error'", ",", "handler", ",", "true", ")", ";", "}", "else", "root", ".", "attachEvent", "(", "'onerror'", ",", "handler", ")", ";", "throw", "STOP_EVENT", ";", "}" ]
Stop this `Script` from executing, even if this function has been called from within the actual code referenced by `Script`.
[ "Stop", "this", "Script", "from", "executing", "even", "if", "this", "function", "has", "been", "called", "from", "within", "the", "actual", "code", "referenced", "by", "Script", "." ]
698a8abfb07436eda76813786de2d49f08d4081b
https://github.com/jka6502/stratum/blob/698a8abfb07436eda76813786de2d49f08d4081b/lib/require.js#L711-L755
53,450
jka6502/stratum
lib/require.js
function(url, base) { if (!url || url.indexOf('://') !== -1) { return url; } var anchor = document.createElement('a'); anchor.href = (base || location.href); var protocol = anchor.protocol + '//', host = anchor.host, path = anchor.pathname, parts = filter(path.split('/'), function(part) { return part !== ''; }); each(url.replace(/\?.*/, '').split('/'), function(part, index) { switch(part) { case '..': if (!parts.length) { throw new Error('Path outside of root: ' + url); } parts.length--; break; case '.': break; default: parts.push(part); break } }); return protocol + host + '/' + parts.join('/'); }
javascript
function(url, base) { if (!url || url.indexOf('://') !== -1) { return url; } var anchor = document.createElement('a'); anchor.href = (base || location.href); var protocol = anchor.protocol + '//', host = anchor.host, path = anchor.pathname, parts = filter(path.split('/'), function(part) { return part !== ''; }); each(url.replace(/\?.*/, '').split('/'), function(part, index) { switch(part) { case '..': if (!parts.length) { throw new Error('Path outside of root: ' + url); } parts.length--; break; case '.': break; default: parts.push(part); break } }); return protocol + host + '/' + parts.join('/'); }
[ "function", "(", "url", ",", "base", ")", "{", "if", "(", "!", "url", "||", "url", ".", "indexOf", "(", "'://'", ")", "!==", "-", "1", ")", "{", "return", "url", ";", "}", "var", "anchor", "=", "document", ".", "createElement", "(", "'a'", ")", ";", "anchor", ".", "href", "=", "(", "base", "||", "location", ".", "href", ")", ";", "var", "protocol", "=", "anchor", ".", "protocol", "+", "'//'", ",", "host", "=", "anchor", ".", "host", ",", "path", "=", "anchor", ".", "pathname", ",", "parts", "=", "filter", "(", "path", ".", "split", "(", "'/'", ")", ",", "function", "(", "part", ")", "{", "return", "part", "!==", "''", ";", "}", ")", ";", "each", "(", "url", ".", "replace", "(", "/", "\\?.*", "/", ",", "''", ")", ".", "split", "(", "'/'", ")", ",", "function", "(", "part", ",", "index", ")", "{", "switch", "(", "part", ")", "{", "case", "'..'", ":", "if", "(", "!", "parts", ".", "length", ")", "{", "throw", "new", "Error", "(", "'Path outside of root: '", "+", "url", ")", ";", "}", "parts", ".", "length", "--", ";", "break", ";", "case", "'.'", ":", "break", ";", "default", ":", "parts", ".", "push", "(", "part", ")", ";", "break", "}", "}", ")", ";", "return", "protocol", "+", "host", "+", "'/'", "+", "parts", ".", "join", "(", "'/'", ")", ";", "}" ]
Convert a relative url to an absolute, relative to the `base` url specified.
[ "Convert", "a", "relative", "url", "to", "an", "absolute", "relative", "to", "the", "base", "url", "specified", "." ]
698a8abfb07436eda76813786de2d49f08d4081b
https://github.com/jka6502/stratum/blob/698a8abfb07436eda76813786de2d49f08d4081b/lib/require.js#L931-L955
53,451
jka6502/stratum
lib/require.js
function(url) { var index = url ? url.lastIndexOf('/') : -1; return index == -1 ? url : url.substring(0, index + 1); }
javascript
function(url) { var index = url ? url.lastIndexOf('/') : -1; return index == -1 ? url : url.substring(0, index + 1); }
[ "function", "(", "url", ")", "{", "var", "index", "=", "url", "?", "url", ".", "lastIndexOf", "(", "'/'", ")", ":", "-", "1", ";", "return", "index", "==", "-", "1", "?", "url", ":", "url", ".", "substring", "(", "0", ",", "index", "+", "1", ")", ";", "}" ]
Remove the filename from a url, if possible, returning the url describing only the parent 'path'.
[ "Remove", "the", "filename", "from", "a", "url", "if", "possible", "returning", "the", "url", "describing", "only", "the", "parent", "path", "." ]
698a8abfb07436eda76813786de2d49f08d4081b
https://github.com/jka6502/stratum/blob/698a8abfb07436eda76813786de2d49f08d4081b/lib/require.js#L959-L962
53,452
jka6502/stratum
lib/require.js
extract
function extract(type) { for(var index = 0; index < 3; index++) { if (typeof args[index] === type) { return args[index]; } } }
javascript
function extract(type) { for(var index = 0; index < 3; index++) { if (typeof args[index] === type) { return args[index]; } } }
[ "function", "extract", "(", "type", ")", "{", "for", "(", "var", "index", "=", "0", ";", "index", "<", "3", ";", "index", "++", ")", "{", "if", "(", "typeof", "args", "[", "index", "]", "===", "type", ")", "{", "return", "args", "[", "index", "]", ";", "}", "}", "}" ]
Slightly looser than AMD, identify supplied parameters by type.
[ "Slightly", "looser", "than", "AMD", "identify", "supplied", "parameters", "by", "type", "." ]
698a8abfb07436eda76813786de2d49f08d4081b
https://github.com/jka6502/stratum/blob/698a8abfb07436eda76813786de2d49f08d4081b/lib/require.js#L1039-L1043
53,453
JohnnieFucker/dreamix-monitor
lib/systemMonitor.js
getBasicInfo
function getBasicInfo() { const result = {}; for (const key in info) { if (info.hasOwnProperty(key)) { result[key] = info[key](); } } return result; }
javascript
function getBasicInfo() { const result = {}; for (const key in info) { if (info.hasOwnProperty(key)) { result[key] = info[key](); } } return result; }
[ "function", "getBasicInfo", "(", ")", "{", "const", "result", "=", "{", "}", ";", "for", "(", "const", "key", "in", "info", ")", "{", "if", "(", "info", ".", "hasOwnProperty", "(", "key", ")", ")", "{", "result", "[", "key", "]", "=", "info", "[", "key", "]", "(", ")", ";", "}", "}", "return", "result", ";", "}" ]
get basic information of operating-system @return {Object} result @api private
[ "get", "basic", "information", "of", "operating", "-", "system" ]
c9e18d386f48a9bfca9dcb6211229cea3a0eed0e
https://github.com/JohnnieFucker/dreamix-monitor/blob/c9e18d386f48a9bfca9dcb6211229cea3a0eed0e/lib/systemMonitor.js#L50-L58
53,454
emeryrose/latest-torbrowser-version
index.js
checkPlatformSupported
function checkPlatformSupported(version, platform) { const url = `${base}/${version}`; if (platform === 'darwin') { platform = 'osx64'; } return new Promise((resolve, reject) => { https.get(url, (res) => { let body = ''; res.on('error', reject); res.on('data', (d) => body += d.toString()); res.on('end', () => { if (res.statusCode !== 200) { return reject(new Error(body)); } let $ = cheerio.load(body); let links = []; $('a[href]').each((i, link) => links.push(link.attribs.href)); for (let link of links) { if (link.includes(platform)) { return resolve(true); } } resolve(false); }); }).on('error', reject); }); }
javascript
function checkPlatformSupported(version, platform) { const url = `${base}/${version}`; if (platform === 'darwin') { platform = 'osx64'; } return new Promise((resolve, reject) => { https.get(url, (res) => { let body = ''; res.on('error', reject); res.on('data', (d) => body += d.toString()); res.on('end', () => { if (res.statusCode !== 200) { return reject(new Error(body)); } let $ = cheerio.load(body); let links = []; $('a[href]').each((i, link) => links.push(link.attribs.href)); for (let link of links) { if (link.includes(platform)) { return resolve(true); } } resolve(false); }); }).on('error', reject); }); }
[ "function", "checkPlatformSupported", "(", "version", ",", "platform", ")", "{", "const", "url", "=", "`", "${", "base", "}", "${", "version", "}", "`", ";", "if", "(", "platform", "===", "'darwin'", ")", "{", "platform", "=", "'osx64'", ";", "}", "return", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "https", ".", "get", "(", "url", ",", "(", "res", ")", "=>", "{", "let", "body", "=", "''", ";", "res", ".", "on", "(", "'error'", ",", "reject", ")", ";", "res", ".", "on", "(", "'data'", ",", "(", "d", ")", "=>", "body", "+=", "d", ".", "toString", "(", ")", ")", ";", "res", ".", "on", "(", "'end'", ",", "(", ")", "=>", "{", "if", "(", "res", ".", "statusCode", "!==", "200", ")", "{", "return", "reject", "(", "new", "Error", "(", "body", ")", ")", ";", "}", "let", "$", "=", "cheerio", ".", "load", "(", "body", ")", ";", "let", "links", "=", "[", "]", ";", "$", "(", "'a[href]'", ")", ".", "each", "(", "(", "i", ",", "link", ")", "=>", "links", ".", "push", "(", "link", ".", "attribs", ".", "href", ")", ")", ";", "for", "(", "let", "link", "of", "links", ")", "{", "if", "(", "link", ".", "includes", "(", "platform", ")", ")", "{", "return", "resolve", "(", "true", ")", ";", "}", "}", "resolve", "(", "false", ")", ";", "}", ")", ";", "}", ")", ".", "on", "(", "'error'", ",", "reject", ")", ";", "}", ")", ";", "}" ]
Scrapes the dist page by the given tor version and returns if the platform is supported by the release @param {string} version @param {string} platform
[ "Scrapes", "the", "dist", "page", "by", "the", "given", "tor", "version", "and", "returns", "if", "the", "platform", "is", "supported", "by", "the", "release" ]
2818e5f67528e44c41cfc414c2f470d0f2422b30
https://github.com/emeryrose/latest-torbrowser-version/blob/2818e5f67528e44c41cfc414c2f470d0f2422b30/index.js#L77-L110
53,455
artsy/scribe-plugin-jump-link
index.js
function () { return function (scribe) { var jumpLinkCommand = new scribe.api.Command('createLink'); jumpLinkCommand.nodeName = 'A'; jumpLinkCommand.execute = function () { var selection = new scribe.api.Selection(), that = this; var fullString = selection.selection.baseNode.textContent if($(selection.selection.baseNode.parentNode).hasClass('is-jump-link')){ // Remove the jump link $(selection.selection.baseNode).unwrap() }else{ // Create the jump link var startOffset = selection.range.startOffset var numOfChar = selection.range.endOffset - startOffset var replace = fullString.substr(startOffset, numOfChar) if (selection.selection.baseNode.parentNode.nodeName === 'A'){ var parent = selection.selection.baseNode.parentElement parent.classList.add('is-jump-link') parent.setAttribute('name', replace) }else{ replace = "<a class='is-jump-link' name=" + replace + ">" + replace + '</a>' var newHtml = splice(fullString, startOffset, numOfChar, replace) $(selection.selection.baseNode).replaceWith(newHtml) } } }; // Set this as the jump linking plugin scribe.commands.jumpLink = jumpLinkCommand; }; }
javascript
function () { return function (scribe) { var jumpLinkCommand = new scribe.api.Command('createLink'); jumpLinkCommand.nodeName = 'A'; jumpLinkCommand.execute = function () { var selection = new scribe.api.Selection(), that = this; var fullString = selection.selection.baseNode.textContent if($(selection.selection.baseNode.parentNode).hasClass('is-jump-link')){ // Remove the jump link $(selection.selection.baseNode).unwrap() }else{ // Create the jump link var startOffset = selection.range.startOffset var numOfChar = selection.range.endOffset - startOffset var replace = fullString.substr(startOffset, numOfChar) if (selection.selection.baseNode.parentNode.nodeName === 'A'){ var parent = selection.selection.baseNode.parentElement parent.classList.add('is-jump-link') parent.setAttribute('name', replace) }else{ replace = "<a class='is-jump-link' name=" + replace + ">" + replace + '</a>' var newHtml = splice(fullString, startOffset, numOfChar, replace) $(selection.selection.baseNode).replaceWith(newHtml) } } }; // Set this as the jump linking plugin scribe.commands.jumpLink = jumpLinkCommand; }; }
[ "function", "(", ")", "{", "return", "function", "(", "scribe", ")", "{", "var", "jumpLinkCommand", "=", "new", "scribe", ".", "api", ".", "Command", "(", "'createLink'", ")", ";", "jumpLinkCommand", ".", "nodeName", "=", "'A'", ";", "jumpLinkCommand", ".", "execute", "=", "function", "(", ")", "{", "var", "selection", "=", "new", "scribe", ".", "api", ".", "Selection", "(", ")", ",", "that", "=", "this", ";", "var", "fullString", "=", "selection", ".", "selection", ".", "baseNode", ".", "textContent", "if", "(", "$", "(", "selection", ".", "selection", ".", "baseNode", ".", "parentNode", ")", ".", "hasClass", "(", "'is-jump-link'", ")", ")", "{", "// Remove the jump link", "$", "(", "selection", ".", "selection", ".", "baseNode", ")", ".", "unwrap", "(", ")", "}", "else", "{", "// Create the jump link", "var", "startOffset", "=", "selection", ".", "range", ".", "startOffset", "var", "numOfChar", "=", "selection", ".", "range", ".", "endOffset", "-", "startOffset", "var", "replace", "=", "fullString", ".", "substr", "(", "startOffset", ",", "numOfChar", ")", "if", "(", "selection", ".", "selection", ".", "baseNode", ".", "parentNode", ".", "nodeName", "===", "'A'", ")", "{", "var", "parent", "=", "selection", ".", "selection", ".", "baseNode", ".", "parentElement", "parent", ".", "classList", ".", "add", "(", "'is-jump-link'", ")", "parent", ".", "setAttribute", "(", "'name'", ",", "replace", ")", "}", "else", "{", "replace", "=", "\"<a class='is-jump-link' name=\"", "+", "replace", "+", "\">\"", "+", "replace", "+", "'</a>'", "var", "newHtml", "=", "splice", "(", "fullString", ",", "startOffset", ",", "numOfChar", ",", "replace", ")", "$", "(", "selection", ".", "selection", ".", "baseNode", ")", ".", "replaceWith", "(", "newHtml", ")", "}", "}", "}", ";", "// Set this as the jump linking plugin", "scribe", ".", "commands", ".", "jumpLink", "=", "jumpLinkCommand", ";", "}", ";", "}" ]
The main plugin function
[ "The", "main", "plugin", "function" ]
4d6b6494fcca343666d91f89cf46114179622ffe
https://github.com/artsy/scribe-plugin-jump-link/blob/4d6b6494fcca343666d91f89cf46114179622ffe/index.js#L8-L40
53,456
MakerCollider/node-red-contrib-smartnode-hook
html/scripts/highchart/modules/exporting.src.js
function (svg) { return svg .replace(/zIndex="[^"]+"/g, '') .replace(/isShadow="[^"]+"/g, '') .replace(/symbolName="[^"]+"/g, '') .replace(/jQuery[0-9]+="[^"]+"/g, '') .replace(/url\([^#]+#/g, 'url(#') .replace(/<svg /, '<svg xmlns:xlink="http://www.w3.org/1999/xlink" ') .replace(/ (NS[0-9]+\:)?href=/g, ' xlink:href=') // #3567 .replace(/\n/, ' ') // Any HTML added to the container after the SVG (#894) .replace(/<\/svg>.*?$/, '</svg>') // Batik doesn't support rgba fills and strokes (#3095) .replace(/(fill|stroke)="rgba\(([ 0-9]+,[ 0-9]+,[ 0-9]+),([ 0-9\.]+)\)"/g, '$1="rgb($2)" $1-opacity="$3"') /* This fails in IE < 8 .replace(/([0-9]+)\.([0-9]+)/g, function(s1, s2, s3) { // round off to save weight return s2 +'.'+ s3[0]; })*/ // Replace HTML entities, issue #347 .replace(/&nbsp;/g, '\u00A0') // no-break space .replace(/&shy;/g, '\u00AD') // soft hyphen // IE specific .replace(/<IMG /g, '<image ') .replace(/height=([^" ]+)/g, 'height="$1"') .replace(/width=([^" ]+)/g, 'width="$1"') .replace(/hc-svg-href="([^"]+)">/g, 'xlink:href="$1"/>') .replace(/ id=([^" >]+)/g, 'id="$1"') // #4003 .replace(/class=([^" >]+)/g, 'class="$1"') .replace(/ transform /g, ' ') .replace(/:(path|rect)/g, '$1') .replace(/style="([^"]+)"/g, function (s) { return s.toLowerCase(); }); }
javascript
function (svg) { return svg .replace(/zIndex="[^"]+"/g, '') .replace(/isShadow="[^"]+"/g, '') .replace(/symbolName="[^"]+"/g, '') .replace(/jQuery[0-9]+="[^"]+"/g, '') .replace(/url\([^#]+#/g, 'url(#') .replace(/<svg /, '<svg xmlns:xlink="http://www.w3.org/1999/xlink" ') .replace(/ (NS[0-9]+\:)?href=/g, ' xlink:href=') // #3567 .replace(/\n/, ' ') // Any HTML added to the container after the SVG (#894) .replace(/<\/svg>.*?$/, '</svg>') // Batik doesn't support rgba fills and strokes (#3095) .replace(/(fill|stroke)="rgba\(([ 0-9]+,[ 0-9]+,[ 0-9]+),([ 0-9\.]+)\)"/g, '$1="rgb($2)" $1-opacity="$3"') /* This fails in IE < 8 .replace(/([0-9]+)\.([0-9]+)/g, function(s1, s2, s3) { // round off to save weight return s2 +'.'+ s3[0]; })*/ // Replace HTML entities, issue #347 .replace(/&nbsp;/g, '\u00A0') // no-break space .replace(/&shy;/g, '\u00AD') // soft hyphen // IE specific .replace(/<IMG /g, '<image ') .replace(/height=([^" ]+)/g, 'height="$1"') .replace(/width=([^" ]+)/g, 'width="$1"') .replace(/hc-svg-href="([^"]+)">/g, 'xlink:href="$1"/>') .replace(/ id=([^" >]+)/g, 'id="$1"') // #4003 .replace(/class=([^" >]+)/g, 'class="$1"') .replace(/ transform /g, ' ') .replace(/:(path|rect)/g, '$1') .replace(/style="([^"]+)"/g, function (s) { return s.toLowerCase(); }); }
[ "function", "(", "svg", ")", "{", "return", "svg", ".", "replace", "(", "/", "zIndex=\"[^\"]+\"", "/", "g", ",", "''", ")", ".", "replace", "(", "/", "isShadow=\"[^\"]+\"", "/", "g", ",", "''", ")", ".", "replace", "(", "/", "symbolName=\"[^\"]+\"", "/", "g", ",", "''", ")", ".", "replace", "(", "/", "jQuery[0-9]+=\"[^\"]+\"", "/", "g", ",", "''", ")", ".", "replace", "(", "/", "url\\([^#]+#", "/", "g", ",", "'url(#'", ")", ".", "replace", "(", "/", "<svg ", "/", ",", "'<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" '", ")", ".", "replace", "(", "/", " (NS[0-9]+\\:)?href=", "/", "g", ",", "' xlink:href='", ")", "// #3567", ".", "replace", "(", "/", "\\n", "/", ",", "' '", ")", "// Any HTML added to the container after the SVG (#894)", ".", "replace", "(", "/", "<\\/svg>.*?$", "/", ",", "'</svg>'", ")", "// Batik doesn't support rgba fills and strokes (#3095)", ".", "replace", "(", "/", "(fill|stroke)=\"rgba\\(([ 0-9]+,[ 0-9]+,[ 0-9]+),([ 0-9\\.]+)\\)\"", "/", "g", ",", "'$1=\"rgb($2)\" $1-opacity=\"$3\"'", ")", "/* This fails in IE < 8\n\t\t\t.replace(/([0-9]+)\\.([0-9]+)/g, function(s1, s2, s3) { // round off to save weight\n\t\t\t\treturn s2 +'.'+ s3[0];\n\t\t\t})*/", "// Replace HTML entities, issue #347", ".", "replace", "(", "/", "&nbsp;", "/", "g", ",", "'\\u00A0'", ")", "// no-break space", ".", "replace", "(", "/", "&shy;", "/", "g", ",", "'\\u00AD'", ")", "// soft hyphen", "// IE specific", ".", "replace", "(", "/", "<IMG ", "/", "g", ",", "'<image '", ")", ".", "replace", "(", "/", "height=([^\" ]+)", "/", "g", ",", "'height=\"$1\"'", ")", ".", "replace", "(", "/", "width=([^\" ]+)", "/", "g", ",", "'width=\"$1\"'", ")", ".", "replace", "(", "/", "hc-svg-href=\"([^\"]+)\">", "/", "g", ",", "'xlink:href=\"$1\"/>'", ")", ".", "replace", "(", "/", " id=([^\" >]+)", "/", "g", ",", "'id=\"$1\"'", ")", "// #4003", ".", "replace", "(", "/", "class=([^\" >]+)", "/", "g", ",", "'class=\"$1\"'", ")", ".", "replace", "(", "/", " transform ", "/", "g", ",", "' '", ")", ".", "replace", "(", "/", ":(path|rect)", "/", "g", ",", "'$1'", ")", ".", "replace", "(", "/", "style=\"([^\"]+)\"", "/", "g", ",", "function", "(", "s", ")", "{", "return", "s", ".", "toLowerCase", "(", ")", ";", "}", ")", ";", "}" ]
A collection of regex fixes on the produces SVG to account for expando properties, browser bugs, VML problems and other. Returns a cleaned SVG.
[ "A", "collection", "of", "regex", "fixes", "on", "the", "produces", "SVG", "to", "account", "for", "expando", "properties", "browser", "bugs", "VML", "problems", "and", "other", ".", "Returns", "a", "cleaned", "SVG", "." ]
245c267e832968bad880ca009929043e82c7bc25
https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/exporting.src.js#L198-L233
53,457
MakerCollider/node-red-contrib-smartnode-hook
html/scripts/highchart/modules/exporting.src.js
function (options, chartOptions) { var svg = this.getSVGForExport(options, chartOptions); // merge the options options = merge(this.options.exporting, options); // do the post Highcharts.post(options.url, { filename: options.filename || 'chart', type: options.type, width: options.width || 0, // IE8 fails to post undefined correctly, so use 0 scale: options.scale || 2, svg: svg }, options.formAttributes); }
javascript
function (options, chartOptions) { var svg = this.getSVGForExport(options, chartOptions); // merge the options options = merge(this.options.exporting, options); // do the post Highcharts.post(options.url, { filename: options.filename || 'chart', type: options.type, width: options.width || 0, // IE8 fails to post undefined correctly, so use 0 scale: options.scale || 2, svg: svg }, options.formAttributes); }
[ "function", "(", "options", ",", "chartOptions", ")", "{", "var", "svg", "=", "this", ".", "getSVGForExport", "(", "options", ",", "chartOptions", ")", ";", "// merge the options", "options", "=", "merge", "(", "this", ".", "options", ".", "exporting", ",", "options", ")", ";", "// do the post", "Highcharts", ".", "post", "(", "options", ".", "url", ",", "{", "filename", ":", "options", ".", "filename", "||", "'chart'", ",", "type", ":", "options", ".", "type", ",", "width", ":", "options", ".", "width", "||", "0", ",", "// IE8 fails to post undefined correctly, so use 0", "scale", ":", "options", ".", "scale", "||", "2", ",", "svg", ":", "svg", "}", ",", "options", ".", "formAttributes", ")", ";", "}" ]
Submit the SVG representation of the chart to the server @param {Object} options Exporting options. Possible members are url, type, width and formAttributes. @param {Object} chartOptions Additional chart options for the SVG representation of the chart
[ "Submit", "the", "SVG", "representation", "of", "the", "chart", "to", "the", "server" ]
245c267e832968bad880ca009929043e82c7bc25
https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/exporting.src.js#L372-L388
53,458
MakerCollider/node-red-contrib-smartnode-hook
html/scripts/highchart/modules/exporting.src.js
function () { var chart = this, container = chart.container, origDisplay = [], origParent = container.parentNode, body = doc.body, childNodes = body.childNodes; if (chart.isPrinting) { // block the button while in printing mode return; } chart.isPrinting = true; fireEvent(chart, 'beforePrint'); // hide all body content each(childNodes, function (node, i) { if (node.nodeType === 1) { origDisplay[i] = node.style.display; node.style.display = NONE; } }); // pull out the chart body.appendChild(container); // print win.focus(); // #1510 win.print(); // allow the browser to prepare before reverting setTimeout(function () { // put the chart back in origParent.appendChild(container); // restore all body content each(childNodes, function (node, i) { if (node.nodeType === 1) { node.style.display = origDisplay[i]; } }); chart.isPrinting = false; fireEvent(chart, 'afterPrint'); }, 1000); }
javascript
function () { var chart = this, container = chart.container, origDisplay = [], origParent = container.parentNode, body = doc.body, childNodes = body.childNodes; if (chart.isPrinting) { // block the button while in printing mode return; } chart.isPrinting = true; fireEvent(chart, 'beforePrint'); // hide all body content each(childNodes, function (node, i) { if (node.nodeType === 1) { origDisplay[i] = node.style.display; node.style.display = NONE; } }); // pull out the chart body.appendChild(container); // print win.focus(); // #1510 win.print(); // allow the browser to prepare before reverting setTimeout(function () { // put the chart back in origParent.appendChild(container); // restore all body content each(childNodes, function (node, i) { if (node.nodeType === 1) { node.style.display = origDisplay[i]; } }); chart.isPrinting = false; fireEvent(chart, 'afterPrint'); }, 1000); }
[ "function", "(", ")", "{", "var", "chart", "=", "this", ",", "container", "=", "chart", ".", "container", ",", "origDisplay", "=", "[", "]", ",", "origParent", "=", "container", ".", "parentNode", ",", "body", "=", "doc", ".", "body", ",", "childNodes", "=", "body", ".", "childNodes", ";", "if", "(", "chart", ".", "isPrinting", ")", "{", "// block the button while in printing mode", "return", ";", "}", "chart", ".", "isPrinting", "=", "true", ";", "fireEvent", "(", "chart", ",", "'beforePrint'", ")", ";", "// hide all body content", "each", "(", "childNodes", ",", "function", "(", "node", ",", "i", ")", "{", "if", "(", "node", ".", "nodeType", "===", "1", ")", "{", "origDisplay", "[", "i", "]", "=", "node", ".", "style", ".", "display", ";", "node", ".", "style", ".", "display", "=", "NONE", ";", "}", "}", ")", ";", "// pull out the chart", "body", ".", "appendChild", "(", "container", ")", ";", "// print", "win", ".", "focus", "(", ")", ";", "// #1510", "win", ".", "print", "(", ")", ";", "// allow the browser to prepare before reverting", "setTimeout", "(", "function", "(", ")", "{", "// put the chart back in", "origParent", ".", "appendChild", "(", "container", ")", ";", "// restore all body content", "each", "(", "childNodes", ",", "function", "(", "node", ",", "i", ")", "{", "if", "(", "node", ".", "nodeType", "===", "1", ")", "{", "node", ".", "style", ".", "display", "=", "origDisplay", "[", "i", "]", ";", "}", "}", ")", ";", "chart", ".", "isPrinting", "=", "false", ";", "fireEvent", "(", "chart", ",", "'afterPrint'", ")", ";", "}", ",", "1000", ")", ";", "}" ]
Print the chart
[ "Print", "the", "chart" ]
245c267e832968bad880ca009929043e82c7bc25
https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/exporting.src.js#L393-L444
53,459
MakerCollider/node-red-contrib-smartnode-hook
html/scripts/highchart/modules/exporting.src.js
function (options) { var chart = this, renderer = chart.renderer, btnOptions = merge(chart.options.navigation.buttonOptions, options), onclick = btnOptions.onclick, menuItems = btnOptions.menuItems, symbol, button, symbolAttr = { stroke: btnOptions.symbolStroke, fill: btnOptions.symbolFill }, symbolSize = btnOptions.symbolSize || 12; if (!chart.btnCount) { chart.btnCount = 0; } // Keeps references to the button elements if (!chart.exportDivElements) { chart.exportDivElements = []; chart.exportSVGElements = []; } if (btnOptions.enabled === false) { return; } var attr = btnOptions.theme, states = attr.states, hover = states && states.hover, select = states && states.select, callback; delete attr.states; if (onclick) { callback = function () { onclick.apply(chart, arguments); }; } else if (menuItems) { callback = function () { chart.contextMenu( button.menuClassName, menuItems, button.translateX, button.translateY, button.width, button.height, button ); button.setState(2); }; } if (btnOptions.text && btnOptions.symbol) { attr.paddingLeft = Highcharts.pick(attr.paddingLeft, 25); } else if (!btnOptions.text) { extend(attr, { width: btnOptions.width, height: btnOptions.height, padding: 0 }); } button = renderer.button(btnOptions.text, 0, 0, callback, attr, hover, select) .attr({ title: chart.options.lang[btnOptions._titleKey], 'stroke-linecap': 'round' }); button.menuClassName = options.menuClassName || PREFIX + 'menu-' + chart.btnCount++; if (btnOptions.symbol) { symbol = renderer.symbol( btnOptions.symbol, btnOptions.symbolX - (symbolSize / 2), btnOptions.symbolY - (symbolSize / 2), symbolSize, symbolSize ) .attr(extend(symbolAttr, { 'stroke-width': btnOptions.symbolStrokeWidth || 1, zIndex: 1 })).add(button); } button.add() .align(extend(btnOptions, { width: button.width, x: Highcharts.pick(btnOptions.x, buttonOffset) // #1654 }), true, 'spacingBox'); buttonOffset += (button.width + btnOptions.buttonSpacing) * (btnOptions.align === 'right' ? -1 : 1); chart.exportSVGElements.push(button, symbol); }
javascript
function (options) { var chart = this, renderer = chart.renderer, btnOptions = merge(chart.options.navigation.buttonOptions, options), onclick = btnOptions.onclick, menuItems = btnOptions.menuItems, symbol, button, symbolAttr = { stroke: btnOptions.symbolStroke, fill: btnOptions.symbolFill }, symbolSize = btnOptions.symbolSize || 12; if (!chart.btnCount) { chart.btnCount = 0; } // Keeps references to the button elements if (!chart.exportDivElements) { chart.exportDivElements = []; chart.exportSVGElements = []; } if (btnOptions.enabled === false) { return; } var attr = btnOptions.theme, states = attr.states, hover = states && states.hover, select = states && states.select, callback; delete attr.states; if (onclick) { callback = function () { onclick.apply(chart, arguments); }; } else if (menuItems) { callback = function () { chart.contextMenu( button.menuClassName, menuItems, button.translateX, button.translateY, button.width, button.height, button ); button.setState(2); }; } if (btnOptions.text && btnOptions.symbol) { attr.paddingLeft = Highcharts.pick(attr.paddingLeft, 25); } else if (!btnOptions.text) { extend(attr, { width: btnOptions.width, height: btnOptions.height, padding: 0 }); } button = renderer.button(btnOptions.text, 0, 0, callback, attr, hover, select) .attr({ title: chart.options.lang[btnOptions._titleKey], 'stroke-linecap': 'round' }); button.menuClassName = options.menuClassName || PREFIX + 'menu-' + chart.btnCount++; if (btnOptions.symbol) { symbol = renderer.symbol( btnOptions.symbol, btnOptions.symbolX - (symbolSize / 2), btnOptions.symbolY - (symbolSize / 2), symbolSize, symbolSize ) .attr(extend(symbolAttr, { 'stroke-width': btnOptions.symbolStrokeWidth || 1, zIndex: 1 })).add(button); } button.add() .align(extend(btnOptions, { width: button.width, x: Highcharts.pick(btnOptions.x, buttonOffset) // #1654 }), true, 'spacingBox'); buttonOffset += (button.width + btnOptions.buttonSpacing) * (btnOptions.align === 'right' ? -1 : 1); chart.exportSVGElements.push(button, symbol); }
[ "function", "(", "options", ")", "{", "var", "chart", "=", "this", ",", "renderer", "=", "chart", ".", "renderer", ",", "btnOptions", "=", "merge", "(", "chart", ".", "options", ".", "navigation", ".", "buttonOptions", ",", "options", ")", ",", "onclick", "=", "btnOptions", ".", "onclick", ",", "menuItems", "=", "btnOptions", ".", "menuItems", ",", "symbol", ",", "button", ",", "symbolAttr", "=", "{", "stroke", ":", "btnOptions", ".", "symbolStroke", ",", "fill", ":", "btnOptions", ".", "symbolFill", "}", ",", "symbolSize", "=", "btnOptions", ".", "symbolSize", "||", "12", ";", "if", "(", "!", "chart", ".", "btnCount", ")", "{", "chart", ".", "btnCount", "=", "0", ";", "}", "// Keeps references to the button elements", "if", "(", "!", "chart", ".", "exportDivElements", ")", "{", "chart", ".", "exportDivElements", "=", "[", "]", ";", "chart", ".", "exportSVGElements", "=", "[", "]", ";", "}", "if", "(", "btnOptions", ".", "enabled", "===", "false", ")", "{", "return", ";", "}", "var", "attr", "=", "btnOptions", ".", "theme", ",", "states", "=", "attr", ".", "states", ",", "hover", "=", "states", "&&", "states", ".", "hover", ",", "select", "=", "states", "&&", "states", ".", "select", ",", "callback", ";", "delete", "attr", ".", "states", ";", "if", "(", "onclick", ")", "{", "callback", "=", "function", "(", ")", "{", "onclick", ".", "apply", "(", "chart", ",", "arguments", ")", ";", "}", ";", "}", "else", "if", "(", "menuItems", ")", "{", "callback", "=", "function", "(", ")", "{", "chart", ".", "contextMenu", "(", "button", ".", "menuClassName", ",", "menuItems", ",", "button", ".", "translateX", ",", "button", ".", "translateY", ",", "button", ".", "width", ",", "button", ".", "height", ",", "button", ")", ";", "button", ".", "setState", "(", "2", ")", ";", "}", ";", "}", "if", "(", "btnOptions", ".", "text", "&&", "btnOptions", ".", "symbol", ")", "{", "attr", ".", "paddingLeft", "=", "Highcharts", ".", "pick", "(", "attr", ".", "paddingLeft", ",", "25", ")", ";", "}", "else", "if", "(", "!", "btnOptions", ".", "text", ")", "{", "extend", "(", "attr", ",", "{", "width", ":", "btnOptions", ".", "width", ",", "height", ":", "btnOptions", ".", "height", ",", "padding", ":", "0", "}", ")", ";", "}", "button", "=", "renderer", ".", "button", "(", "btnOptions", ".", "text", ",", "0", ",", "0", ",", "callback", ",", "attr", ",", "hover", ",", "select", ")", ".", "attr", "(", "{", "title", ":", "chart", ".", "options", ".", "lang", "[", "btnOptions", ".", "_titleKey", "]", ",", "'stroke-linecap'", ":", "'round'", "}", ")", ";", "button", ".", "menuClassName", "=", "options", ".", "menuClassName", "||", "PREFIX", "+", "'menu-'", "+", "chart", ".", "btnCount", "++", ";", "if", "(", "btnOptions", ".", "symbol", ")", "{", "symbol", "=", "renderer", ".", "symbol", "(", "btnOptions", ".", "symbol", ",", "btnOptions", ".", "symbolX", "-", "(", "symbolSize", "/", "2", ")", ",", "btnOptions", ".", "symbolY", "-", "(", "symbolSize", "/", "2", ")", ",", "symbolSize", ",", "symbolSize", ")", ".", "attr", "(", "extend", "(", "symbolAttr", ",", "{", "'stroke-width'", ":", "btnOptions", ".", "symbolStrokeWidth", "||", "1", ",", "zIndex", ":", "1", "}", ")", ")", ".", "add", "(", "button", ")", ";", "}", "button", ".", "add", "(", ")", ".", "align", "(", "extend", "(", "btnOptions", ",", "{", "width", ":", "button", ".", "width", ",", "x", ":", "Highcharts", ".", "pick", "(", "btnOptions", ".", "x", ",", "buttonOffset", ")", "// #1654", "}", ")", ",", "true", ",", "'spacingBox'", ")", ";", "buttonOffset", "+=", "(", "button", ".", "width", "+", "btnOptions", ".", "buttonSpacing", ")", "*", "(", "btnOptions", ".", "align", "===", "'right'", "?", "-", "1", ":", "1", ")", ";", "chart", ".", "exportSVGElements", ".", "push", "(", "button", ",", "symbol", ")", ";", "}" ]
Add the export button to the chart
[ "Add", "the", "export", "button", "to", "the", "chart" ]
245c267e832968bad880ca009929043e82c7bc25
https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/exporting.src.js#L578-L677
53,460
MakerCollider/node-red-contrib-smartnode-hook
html/scripts/highchart/modules/exporting.src.js
function (e) { var chart = e.target, i, elem; // Destroy the extra buttons added for (i = 0; i < chart.exportSVGElements.length; i++) { elem = chart.exportSVGElements[i]; // Destroy and null the svg/vml elements if (elem) { // #1822 elem.onclick = elem.ontouchstart = null; chart.exportSVGElements[i] = elem.destroy(); } } // Destroy the divs for the menu for (i = 0; i < chart.exportDivElements.length; i++) { elem = chart.exportDivElements[i]; // Remove the event handler removeEvent(elem, 'mouseleave'); // Remove inline events chart.exportDivElements[i] = elem.onmouseout = elem.onmouseover = elem.ontouchstart = elem.onclick = null; // Destroy the div by moving to garbage bin discardElement(elem); } }
javascript
function (e) { var chart = e.target, i, elem; // Destroy the extra buttons added for (i = 0; i < chart.exportSVGElements.length; i++) { elem = chart.exportSVGElements[i]; // Destroy and null the svg/vml elements if (elem) { // #1822 elem.onclick = elem.ontouchstart = null; chart.exportSVGElements[i] = elem.destroy(); } } // Destroy the divs for the menu for (i = 0; i < chart.exportDivElements.length; i++) { elem = chart.exportDivElements[i]; // Remove the event handler removeEvent(elem, 'mouseleave'); // Remove inline events chart.exportDivElements[i] = elem.onmouseout = elem.onmouseover = elem.ontouchstart = elem.onclick = null; // Destroy the div by moving to garbage bin discardElement(elem); } }
[ "function", "(", "e", ")", "{", "var", "chart", "=", "e", ".", "target", ",", "i", ",", "elem", ";", "// Destroy the extra buttons added", "for", "(", "i", "=", "0", ";", "i", "<", "chart", ".", "exportSVGElements", ".", "length", ";", "i", "++", ")", "{", "elem", "=", "chart", ".", "exportSVGElements", "[", "i", "]", ";", "// Destroy and null the svg/vml elements", "if", "(", "elem", ")", "{", "// #1822", "elem", ".", "onclick", "=", "elem", ".", "ontouchstart", "=", "null", ";", "chart", ".", "exportSVGElements", "[", "i", "]", "=", "elem", ".", "destroy", "(", ")", ";", "}", "}", "// Destroy the divs for the menu", "for", "(", "i", "=", "0", ";", "i", "<", "chart", ".", "exportDivElements", ".", "length", ";", "i", "++", ")", "{", "elem", "=", "chart", ".", "exportDivElements", "[", "i", "]", ";", "// Remove the event handler", "removeEvent", "(", "elem", ",", "'mouseleave'", ")", ";", "// Remove inline events", "chart", ".", "exportDivElements", "[", "i", "]", "=", "elem", ".", "onmouseout", "=", "elem", ".", "onmouseover", "=", "elem", ".", "ontouchstart", "=", "elem", ".", "onclick", "=", "null", ";", "// Destroy the div by moving to garbage bin", "discardElement", "(", "elem", ")", ";", "}", "}" ]
Destroy the buttons.
[ "Destroy", "the", "buttons", "." ]
245c267e832968bad880ca009929043e82c7bc25
https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/exporting.src.js#L682-L711
53,461
vincentpeyrouse/passport-supinfo
lib/passport-supinfo/errors/internalopeniderror.js
InternalOpenIDError
function InternalOpenIDError(message, err) { Error.call(this); Error.captureStackTrace(this, arguments.callee); this.name = 'InternalOpenIDError'; this.message = message; this.openidError = err; }
javascript
function InternalOpenIDError(message, err) { Error.call(this); Error.captureStackTrace(this, arguments.callee); this.name = 'InternalOpenIDError'; this.message = message; this.openidError = err; }
[ "function", "InternalOpenIDError", "(", "message", ",", "err", ")", "{", "Error", ".", "call", "(", "this", ")", ";", "Error", ".", "captureStackTrace", "(", "this", ",", "arguments", ".", "callee", ")", ";", "this", ".", "name", "=", "'InternalOpenIDError'", ";", "this", ".", "message", "=", "message", ";", "this", ".", "openidError", "=", "err", ";", "}" ]
`InternalOpenIDError` error. InternalOpenIDError wraps errors generated by node-openid. By wrapping these objects, error messages can be formatted in a manner that aids in debugging OpenID issues. @api public
[ "InternalOpenIDError", "error", "." ]
1d02da38251710a1a2528eb1c27d23fc43565928
https://github.com/vincentpeyrouse/passport-supinfo/blob/1d02da38251710a1a2528eb1c27d23fc43565928/lib/passport-supinfo/errors/internalopeniderror.js#L10-L16
53,462
chrisJohn404/ljswitchboard-device_scanner
lib/temp_files/oa_managed_device.js
printCollectedDeviceData
function printCollectedDeviceData(results) { var dataToKeep = { 'AIN0': 'val', 'FIRMWARE_VERSION': 'val', 'WIFI_IP': 'str', 'ETHERNET_IP': 'str', 'WIFI_RSSI': 'str', 'WIFI_VERSION': 'val', 'SERIAL_NUMBER': 'val', 'HARDWARE_INSTALLED': 'productType', }; var vals = []; results.forEach(function(result) { result = result.data; var data = {}; var keyToKeep = 'res'; if(dataToKeep[result.name]) { keyToKeep = dataToKeep[result.name]; } data[result.name] = result.res; if(result[keyToKeep]) { data[result.name] = result[keyToKeep]; } vals.push(data); }); if(DEBUG_COLLECTED_DEVICE_DATA) { console.log('Connection Type', self.curatedDevice.savedAttributes.connectionTypeName); console.log('Serial Number', self.curatedDevice.savedAttributes.serialNumber); console.log('Read Data', self.curatedDevice.getDevice().handle,':'); console.log(vals); } }
javascript
function printCollectedDeviceData(results) { var dataToKeep = { 'AIN0': 'val', 'FIRMWARE_VERSION': 'val', 'WIFI_IP': 'str', 'ETHERNET_IP': 'str', 'WIFI_RSSI': 'str', 'WIFI_VERSION': 'val', 'SERIAL_NUMBER': 'val', 'HARDWARE_INSTALLED': 'productType', }; var vals = []; results.forEach(function(result) { result = result.data; var data = {}; var keyToKeep = 'res'; if(dataToKeep[result.name]) { keyToKeep = dataToKeep[result.name]; } data[result.name] = result.res; if(result[keyToKeep]) { data[result.name] = result[keyToKeep]; } vals.push(data); }); if(DEBUG_COLLECTED_DEVICE_DATA) { console.log('Connection Type', self.curatedDevice.savedAttributes.connectionTypeName); console.log('Serial Number', self.curatedDevice.savedAttributes.serialNumber); console.log('Read Data', self.curatedDevice.getDevice().handle,':'); console.log(vals); } }
[ "function", "printCollectedDeviceData", "(", "results", ")", "{", "var", "dataToKeep", "=", "{", "'AIN0'", ":", "'val'", ",", "'FIRMWARE_VERSION'", ":", "'val'", ",", "'WIFI_IP'", ":", "'str'", ",", "'ETHERNET_IP'", ":", "'str'", ",", "'WIFI_RSSI'", ":", "'str'", ",", "'WIFI_VERSION'", ":", "'val'", ",", "'SERIAL_NUMBER'", ":", "'val'", ",", "'HARDWARE_INSTALLED'", ":", "'productType'", ",", "}", ";", "var", "vals", "=", "[", "]", ";", "results", ".", "forEach", "(", "function", "(", "result", ")", "{", "result", "=", "result", ".", "data", ";", "var", "data", "=", "{", "}", ";", "var", "keyToKeep", "=", "'res'", ";", "if", "(", "dataToKeep", "[", "result", ".", "name", "]", ")", "{", "keyToKeep", "=", "dataToKeep", "[", "result", ".", "name", "]", ";", "}", "data", "[", "result", ".", "name", "]", "=", "result", ".", "res", ";", "if", "(", "result", "[", "keyToKeep", "]", ")", "{", "data", "[", "result", ".", "name", "]", "=", "result", "[", "keyToKeep", "]", ";", "}", "vals", ".", "push", "(", "data", ")", ";", "}", ")", ";", "if", "(", "DEBUG_COLLECTED_DEVICE_DATA", ")", "{", "console", ".", "log", "(", "'Connection Type'", ",", "self", ".", "curatedDevice", ".", "savedAttributes", ".", "connectionTypeName", ")", ";", "console", ".", "log", "(", "'Serial Number'", ",", "self", ".", "curatedDevice", ".", "savedAttributes", ".", "serialNumber", ")", ";", "console", ".", "log", "(", "'Read Data'", ",", "self", ".", "curatedDevice", ".", "getDevice", "(", ")", ".", "handle", ",", "':'", ")", ";", "console", ".", "log", "(", "vals", ")", ";", "}", "}" ]
This is a "debugging" function that prints out the important attributes of the data being queried from a device.
[ "This", "is", "a", "debugging", "function", "that", "prints", "out", "the", "important", "attributes", "of", "the", "data", "being", "queried", "from", "a", "device", "." ]
9a8f0936387bfedc09ab1b2d655cecf79ad15a6b
https://github.com/chrisJohn404/ljswitchboard-device_scanner/blob/9a8f0936387bfedc09ab1b2d655cecf79ad15a6b/lib/temp_files/oa_managed_device.js#L50-L82
53,463
chrisJohn404/ljswitchboard-device_scanner
lib/temp_files/oa_managed_device.js
curatedDeviceDisconnected
function curatedDeviceDisconnected(eventData) { self.log(' *** Handle', self.handle, 'triggered event: DEVICE_DISCONNECTED', eventData.name, eventData.operation); }
javascript
function curatedDeviceDisconnected(eventData) { self.log(' *** Handle', self.handle, 'triggered event: DEVICE_DISCONNECTED', eventData.name, eventData.operation); }
[ "function", "curatedDeviceDisconnected", "(", "eventData", ")", "{", "self", ".", "log", "(", "' *** Handle'", ",", "self", ".", "handle", ",", "'triggered event: DEVICE_DISCONNECTED'", ",", "eventData", ".", "name", ",", "eventData", ".", "operation", ")", ";", "}" ]
Define various functions to be used as curated device event listeners.
[ "Define", "various", "functions", "to", "be", "used", "as", "curated", "device", "event", "listeners", "." ]
9a8f0936387bfedc09ab1b2d655cecf79ad15a6b
https://github.com/chrisJohn404/ljswitchboard-device_scanner/blob/9a8f0936387bfedc09ab1b2d655cecf79ad15a6b/lib/temp_files/oa_managed_device.js#L98-L100
53,464
chrisJohn404/ljswitchboard-device_scanner
lib/temp_files/oa_managed_device.js
linkToCuratedDeviceEvents
function linkToCuratedDeviceEvents() { self.curatedDevice.on( 'DEVICE_DISCONNECTED', curatedDeviceDisconnected ); self.curatedDevice.on( 'DEVICE_RECONNECTED', curatedDeviceReconnected ); self.curatedDevice.on( 'DEVICE_ERROR', curatedDeviceError ); self.curatedDevice.on( 'DEVICE_RECONNECTING', curatedDeviceReconnecting ); self.curatedDevice.on( 'DEVICE_ATTRIBUTES_CHANGED', cureatedDeviceAttributesChanged ); }
javascript
function linkToCuratedDeviceEvents() { self.curatedDevice.on( 'DEVICE_DISCONNECTED', curatedDeviceDisconnected ); self.curatedDevice.on( 'DEVICE_RECONNECTED', curatedDeviceReconnected ); self.curatedDevice.on( 'DEVICE_ERROR', curatedDeviceError ); self.curatedDevice.on( 'DEVICE_RECONNECTING', curatedDeviceReconnecting ); self.curatedDevice.on( 'DEVICE_ATTRIBUTES_CHANGED', cureatedDeviceAttributesChanged ); }
[ "function", "linkToCuratedDeviceEvents", "(", ")", "{", "self", ".", "curatedDevice", ".", "on", "(", "'DEVICE_DISCONNECTED'", ",", "curatedDeviceDisconnected", ")", ";", "self", ".", "curatedDevice", ".", "on", "(", "'DEVICE_RECONNECTED'", ",", "curatedDeviceReconnected", ")", ";", "self", ".", "curatedDevice", ".", "on", "(", "'DEVICE_ERROR'", ",", "curatedDeviceError", ")", ";", "self", ".", "curatedDevice", ".", "on", "(", "'DEVICE_RECONNECTING'", ",", "curatedDeviceReconnecting", ")", ";", "self", ".", "curatedDevice", ".", "on", "(", "'DEVICE_ATTRIBUTES_CHANGED'", ",", "cureatedDeviceAttributesChanged", ")", ";", "}" ]
Define a function that links the device manager to several of the curated device's events.
[ "Define", "a", "function", "that", "links", "the", "device", "manager", "to", "several", "of", "the", "curated", "device", "s", "events", "." ]
9a8f0936387bfedc09ab1b2d655cecf79ad15a6b
https://github.com/chrisJohn404/ljswitchboard-device_scanner/blob/9a8f0936387bfedc09ab1b2d655cecf79ad15a6b/lib/temp_files/oa_managed_device.js#L118-L139
53,465
chrisJohn404/ljswitchboard-device_scanner
lib/temp_files/oa_managed_device.js
unlinkFromCuratedDeviceEvents
function unlinkFromCuratedDeviceEvents() { self.curatedDevice.removeListener( 'DEVICE_DISCONNECTED', curatedDeviceDisconnected ); self.curatedDevice.removeListener( 'DEVICE_RECONNECTED', curatedDeviceReconnected ); self.curatedDevice.removeListener( 'DEVICE_ERROR', curatedDeviceError ); self.curatedDevice.removeListener( 'DEVICE_RECONNECTING', curatedDeviceReconnecting ); self.curatedDevice.removeListener( 'DEVICE_ATTRIBUTES_CHANGED', cureatedDeviceAttributesChanged ); }
javascript
function unlinkFromCuratedDeviceEvents() { self.curatedDevice.removeListener( 'DEVICE_DISCONNECTED', curatedDeviceDisconnected ); self.curatedDevice.removeListener( 'DEVICE_RECONNECTED', curatedDeviceReconnected ); self.curatedDevice.removeListener( 'DEVICE_ERROR', curatedDeviceError ); self.curatedDevice.removeListener( 'DEVICE_RECONNECTING', curatedDeviceReconnecting ); self.curatedDevice.removeListener( 'DEVICE_ATTRIBUTES_CHANGED', cureatedDeviceAttributesChanged ); }
[ "function", "unlinkFromCuratedDeviceEvents", "(", ")", "{", "self", ".", "curatedDevice", ".", "removeListener", "(", "'DEVICE_DISCONNECTED'", ",", "curatedDeviceDisconnected", ")", ";", "self", ".", "curatedDevice", ".", "removeListener", "(", "'DEVICE_RECONNECTED'", ",", "curatedDeviceReconnected", ")", ";", "self", ".", "curatedDevice", ".", "removeListener", "(", "'DEVICE_ERROR'", ",", "curatedDeviceError", ")", ";", "self", ".", "curatedDevice", ".", "removeListener", "(", "'DEVICE_RECONNECTING'", ",", "curatedDeviceReconnecting", ")", ";", "self", ".", "curatedDevice", ".", "removeListener", "(", "'DEVICE_ATTRIBUTES_CHANGED'", ",", "cureatedDeviceAttributesChanged", ")", ";", "}" ]
Define a function that unlinks the device manager from several of the curated device's events.
[ "Define", "a", "function", "that", "unlinks", "the", "device", "manager", "from", "several", "of", "the", "curated", "device", "s", "events", "." ]
9a8f0936387bfedc09ab1b2d655cecf79ad15a6b
https://github.com/chrisJohn404/ljswitchboard-device_scanner/blob/9a8f0936387bfedc09ab1b2d655cecf79ad15a6b/lib/temp_files/oa_managed_device.js#L143-L164
53,466
chrisJohn404/ljswitchboard-device_scanner
lib/temp_files/oa_managed_device.js
saveCollectedDeviceData
function saveCollectedDeviceData(results) { self.log('Finished Collecting Data from Device:', self.handle); // Loop through each of the results. results.forEach(function(result) { // De-reference the actual data var data = result.data; // Determine what register was saved var name = data.name; // Save the data to the cached device results object. self.cachedDeviceResults[name] = data; }); }
javascript
function saveCollectedDeviceData(results) { self.log('Finished Collecting Data from Device:', self.handle); // Loop through each of the results. results.forEach(function(result) { // De-reference the actual data var data = result.data; // Determine what register was saved var name = data.name; // Save the data to the cached device results object. self.cachedDeviceResults[name] = data; }); }
[ "function", "saveCollectedDeviceData", "(", "results", ")", "{", "self", ".", "log", "(", "'Finished Collecting Data from Device:'", ",", "self", ".", "handle", ")", ";", "// Loop through each of the results.", "results", ".", "forEach", "(", "function", "(", "result", ")", "{", "// De-reference the actual data", "var", "data", "=", "result", ".", "data", ";", "// Determine what register was saved", "var", "name", "=", "data", ".", "name", ";", "// Save the data to the cached device results object.", "self", ".", "cachedDeviceResults", "[", "name", "]", "=", "data", ";", "}", ")", ";", "}" ]
Save Data to the cached device results object...
[ "Save", "Data", "to", "the", "cached", "device", "results", "object", "..." ]
9a8f0936387bfedc09ab1b2d655cecf79ad15a6b
https://github.com/chrisJohn404/ljswitchboard-device_scanner/blob/9a8f0936387bfedc09ab1b2d655cecf79ad15a6b/lib/temp_files/oa_managed_device.js#L167-L181
53,467
chrisJohn404/ljswitchboard-device_scanner
lib/temp_files/oa_managed_device.js
innerCollectDeviceData
function innerCollectDeviceData(infoToCache) { var defered = q.defer(); self.dataCollectionDefered = defered; self.log('Collecting Data from a handle', self.handle); // Indicate that this device was opened by the device scanner. self.openedByScanner = true; var deviceHandle = self.handle; var dt = self.openParameters.deviceType; var ct = self.openParameters.connectionType; var id = self.openParameters.identifier; // Initialize a curated device object. self.curatedDevice = new device_curator.device(); // Link the device handle to the curated device object. self.curatedDevice.linkToHandle(deviceHandle, dt, ct, id) .then(function finishedLinkingHandle(res) { self.log( 'Finished linking to a handle', deviceHandle, self.curatedDevice.savedAttributes.connectionTypeName ); // Create a data collection timeout. var collectionTimeout = setTimeout( deviceHandleDataCollectionTimeout, DEVICE_DATA_COLLECTION_TIMEOUT ); // Attach event listeners to the curated device. linkToCuratedDeviceEvents(); console.log('reading multiple...', deviceHandle); // Collect information from the curated device. self.curatedDevice.iReadMultiple(infoToCache) .then(function finishedCollectingData(results) { // Clear the data collection timeout clearTimeout(collectionTimeout); self.log('Collecting data from a handle', deviceHandle); printCollectedDeviceData(results); saveCollectedDeviceData(results); // Report that the device is finished collecting data. stopCollectingDeviceData(); }, function(err) { self.log('Error collecting data from a handle', deviceHandle, err); // Report that the device is finished collecting data. stopCollectingDeviceData(); }); }, function errorLinkingHandle(err) { console.error('Error linking to handle...'); defered.resolve(); }); return defered.promise; }
javascript
function innerCollectDeviceData(infoToCache) { var defered = q.defer(); self.dataCollectionDefered = defered; self.log('Collecting Data from a handle', self.handle); // Indicate that this device was opened by the device scanner. self.openedByScanner = true; var deviceHandle = self.handle; var dt = self.openParameters.deviceType; var ct = self.openParameters.connectionType; var id = self.openParameters.identifier; // Initialize a curated device object. self.curatedDevice = new device_curator.device(); // Link the device handle to the curated device object. self.curatedDevice.linkToHandle(deviceHandle, dt, ct, id) .then(function finishedLinkingHandle(res) { self.log( 'Finished linking to a handle', deviceHandle, self.curatedDevice.savedAttributes.connectionTypeName ); // Create a data collection timeout. var collectionTimeout = setTimeout( deviceHandleDataCollectionTimeout, DEVICE_DATA_COLLECTION_TIMEOUT ); // Attach event listeners to the curated device. linkToCuratedDeviceEvents(); console.log('reading multiple...', deviceHandle); // Collect information from the curated device. self.curatedDevice.iReadMultiple(infoToCache) .then(function finishedCollectingData(results) { // Clear the data collection timeout clearTimeout(collectionTimeout); self.log('Collecting data from a handle', deviceHandle); printCollectedDeviceData(results); saveCollectedDeviceData(results); // Report that the device is finished collecting data. stopCollectingDeviceData(); }, function(err) { self.log('Error collecting data from a handle', deviceHandle, err); // Report that the device is finished collecting data. stopCollectingDeviceData(); }); }, function errorLinkingHandle(err) { console.error('Error linking to handle...'); defered.resolve(); }); return defered.promise; }
[ "function", "innerCollectDeviceData", "(", "infoToCache", ")", "{", "var", "defered", "=", "q", ".", "defer", "(", ")", ";", "self", ".", "dataCollectionDefered", "=", "defered", ";", "self", ".", "log", "(", "'Collecting Data from a handle'", ",", "self", ".", "handle", ")", ";", "// Indicate that this device was opened by the device scanner.", "self", ".", "openedByScanner", "=", "true", ";", "var", "deviceHandle", "=", "self", ".", "handle", ";", "var", "dt", "=", "self", ".", "openParameters", ".", "deviceType", ";", "var", "ct", "=", "self", ".", "openParameters", ".", "connectionType", ";", "var", "id", "=", "self", ".", "openParameters", ".", "identifier", ";", "// Initialize a curated device object.", "self", ".", "curatedDevice", "=", "new", "device_curator", ".", "device", "(", ")", ";", "// Link the device handle to the curated device object.", "self", ".", "curatedDevice", ".", "linkToHandle", "(", "deviceHandle", ",", "dt", ",", "ct", ",", "id", ")", ".", "then", "(", "function", "finishedLinkingHandle", "(", "res", ")", "{", "self", ".", "log", "(", "'Finished linking to a handle'", ",", "deviceHandle", ",", "self", ".", "curatedDevice", ".", "savedAttributes", ".", "connectionTypeName", ")", ";", "// Create a data collection timeout.", "var", "collectionTimeout", "=", "setTimeout", "(", "deviceHandleDataCollectionTimeout", ",", "DEVICE_DATA_COLLECTION_TIMEOUT", ")", ";", "// Attach event listeners to the curated device.", "linkToCuratedDeviceEvents", "(", ")", ";", "console", ".", "log", "(", "'reading multiple...'", ",", "deviceHandle", ")", ";", "// Collect information from the curated device.", "self", ".", "curatedDevice", ".", "iReadMultiple", "(", "infoToCache", ")", ".", "then", "(", "function", "finishedCollectingData", "(", "results", ")", "{", "// Clear the data collection timeout", "clearTimeout", "(", "collectionTimeout", ")", ";", "self", ".", "log", "(", "'Collecting data from a handle'", ",", "deviceHandle", ")", ";", "printCollectedDeviceData", "(", "results", ")", ";", "saveCollectedDeviceData", "(", "results", ")", ";", "// Report that the device is finished collecting data.", "stopCollectingDeviceData", "(", ")", ";", "}", ",", "function", "(", "err", ")", "{", "self", ".", "log", "(", "'Error collecting data from a handle'", ",", "deviceHandle", ",", "err", ")", ";", "// Report that the device is finished collecting data.", "stopCollectingDeviceData", "(", ")", ";", "}", ")", ";", "}", ",", "function", "errorLinkingHandle", "(", "err", ")", "{", "console", ".", "error", "(", "'Error linking to handle...'", ")", ";", "defered", ".", "resolve", "(", ")", ";", "}", ")", ";", "return", "defered", ".", "promise", ";", "}" ]
Link supplied device handle to the curated device object and collect the required information from the device.
[ "Link", "supplied", "device", "handle", "to", "the", "curated", "device", "object", "and", "collect", "the", "required", "information", "from", "the", "device", "." ]
9a8f0936387bfedc09ab1b2d655cecf79ad15a6b
https://github.com/chrisJohn404/ljswitchboard-device_scanner/blob/9a8f0936387bfedc09ab1b2d655cecf79ad15a6b/lib/temp_files/oa_managed_device.js#L193-L251
53,468
Whitebolt/lodash-provider
index.js
lodashRequire
function lodashRequire(functionName) { var moduleId = getLodashId(functionName); try { var method = localRequire(moduleId); method.toString = lodashFunctionToString(functionName); return method; } catch (err) { throw new ReferenceError('Could not find '+functionName+', did you forget to install '+moduleId); } }
javascript
function lodashRequire(functionName) { var moduleId = getLodashId(functionName); try { var method = localRequire(moduleId); method.toString = lodashFunctionToString(functionName); return method; } catch (err) { throw new ReferenceError('Could not find '+functionName+', did you forget to install '+moduleId); } }
[ "function", "lodashRequire", "(", "functionName", ")", "{", "var", "moduleId", "=", "getLodashId", "(", "functionName", ")", ";", "try", "{", "var", "method", "=", "localRequire", "(", "moduleId", ")", ";", "method", ".", "toString", "=", "lodashFunctionToString", "(", "functionName", ")", ";", "return", "method", ";", "}", "catch", "(", "err", ")", "{", "throw", "new", "ReferenceError", "(", "'Could not find '", "+", "functionName", "+", "', did you forget to install '", "+", "moduleId", ")", ";", "}", "}" ]
Get the given function from lodash. Given a function name try to load the corresponding module. @throws {ReferenceError} If function not found then throw error. @param {string} functionName The function name to find (this will be lower-cased). @returns {Function} The lodash function.
[ "Get", "the", "given", "function", "from", "lodash", ".", "Given", "a", "function", "name", "try", "to", "load", "the", "corresponding", "module", "." ]
d8e34737346e370f1d4e4cf5595ed4040d1521e8
https://github.com/Whitebolt/lodash-provider/blob/d8e34737346e370f1d4e4cf5595ed4040d1521e8/index.js#L46-L56
53,469
Whitebolt/lodash-provider
index.js
getPathStack
function getPathStack() { return (module.parent || module).paths.map(function(path) { return lop(path) }).filter(function(path) { return (path !== ''); }); }
javascript
function getPathStack() { return (module.parent || module).paths.map(function(path) { return lop(path) }).filter(function(path) { return (path !== ''); }); }
[ "function", "getPathStack", "(", ")", "{", "return", "(", "module", ".", "parent", "||", "module", ")", ".", "paths", ".", "map", "(", "function", "(", "path", ")", "{", "return", "lop", "(", "path", ")", "}", ")", ".", "filter", "(", "function", "(", "path", ")", "{", "return", "(", "path", "!==", "''", ")", ";", "}", ")", ";", "}" ]
Find all possible local directories for node_modules loading. @returns {Array.<string>} Load paths.
[ "Find", "all", "possible", "local", "directories", "for", "node_modules", "loading", "." ]
d8e34737346e370f1d4e4cf5595ed4040d1521e8
https://github.com/Whitebolt/lodash-provider/blob/d8e34737346e370f1d4e4cf5595ed4040d1521e8/index.js#L155-L161
53,470
Whitebolt/lodash-provider
index.js
loadPackageModules
function loadPackageModules(packages, packageData, modType) { Object.keys(packageData[modType] || {}).forEach(function(packageName) { if (lodashTest.test(packageName)) packages.push(tryModule(packageName)); }); }
javascript
function loadPackageModules(packages, packageData, modType) { Object.keys(packageData[modType] || {}).forEach(function(packageName) { if (lodashTest.test(packageName)) packages.push(tryModule(packageName)); }); }
[ "function", "loadPackageModules", "(", "packages", ",", "packageData", ",", "modType", ")", "{", "Object", ".", "keys", "(", "packageData", "[", "modType", "]", "||", "{", "}", ")", ".", "forEach", "(", "function", "(", "packageName", ")", "{", "if", "(", "lodashTest", ".", "test", "(", "packageName", ")", ")", "packages", ".", "push", "(", "tryModule", "(", "packageName", ")", ")", ";", "}", ")", ";", "}" ]
Load all the lodash methods from given packages array. @param {Array.<Object>} packages Packages array to load into. @param {Array.<Object>} packageData Package data array. @param {string} modType Section of package data to load from (eg. 'dependencies').
[ "Load", "all", "the", "lodash", "methods", "from", "given", "packages", "array", "." ]
d8e34737346e370f1d4e4cf5595ed4040d1521e8
https://github.com/Whitebolt/lodash-provider/blob/d8e34737346e370f1d4e4cf5595ed4040d1521e8/index.js#L203-L207
53,471
derdesign/protos
engines/jade.js
Jade
function Jade() { var opts = (app.config.engines && app.config.engines.jade) || {}; this.options = protos.extend({ pretty: true }, opts); this.module = jade; this.multiPart = false; this.extensions = ['jade', 'jade.html']; }
javascript
function Jade() { var opts = (app.config.engines && app.config.engines.jade) || {}; this.options = protos.extend({ pretty: true }, opts); this.module = jade; this.multiPart = false; this.extensions = ['jade', 'jade.html']; }
[ "function", "Jade", "(", ")", "{", "var", "opts", "=", "(", "app", ".", "config", ".", "engines", "&&", "app", ".", "config", ".", "engines", ".", "jade", ")", "||", "{", "}", ";", "this", ".", "options", "=", "protos", ".", "extend", "(", "{", "pretty", ":", "true", "}", ",", "opts", ")", ";", "this", ".", "module", "=", "jade", ";", "this", ".", "multiPart", "=", "false", ";", "this", ".", "extensions", "=", "[", "'jade'", ",", "'jade.html'", "]", ";", "}" ]
Jade engine class https://github.com/visionmedia/jade
[ "Jade", "engine", "class" ]
0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9
https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/engines/jade.js#L15-L27
53,472
IonicaBizau/node-w-json
lib/index.js
wJson
function wJson(path, data, options, callback) { if (typeof options === "function") { callback = options; options = {}; } else if (typeof options === "number") { options = { space: options }; } else if (typeof options === "boolean") { options = { new_line: options }; } options = options || {}; options.space = typeof options.space === "number" ? options.space : 2; options.new_line = !!options.new_line; Fs["writeFile" + (typeof callback === "function" ? "" : "Sync")]( path , JSON.stringify(data, null, options.space) + (options.new_line ? "\n" : "") , callback ); }
javascript
function wJson(path, data, options, callback) { if (typeof options === "function") { callback = options; options = {}; } else if (typeof options === "number") { options = { space: options }; } else if (typeof options === "boolean") { options = { new_line: options }; } options = options || {}; options.space = typeof options.space === "number" ? options.space : 2; options.new_line = !!options.new_line; Fs["writeFile" + (typeof callback === "function" ? "" : "Sync")]( path , JSON.stringify(data, null, options.space) + (options.new_line ? "\n" : "") , callback ); }
[ "function", "wJson", "(", "path", ",", "data", ",", "options", ",", "callback", ")", "{", "if", "(", "typeof", "options", "===", "\"function\"", ")", "{", "callback", "=", "options", ";", "options", "=", "{", "}", ";", "}", "else", "if", "(", "typeof", "options", "===", "\"number\"", ")", "{", "options", "=", "{", "space", ":", "options", "}", ";", "}", "else", "if", "(", "typeof", "options", "===", "\"boolean\"", ")", "{", "options", "=", "{", "new_line", ":", "options", "}", ";", "}", "options", "=", "options", "||", "{", "}", ";", "options", ".", "space", "=", "typeof", "options", ".", "space", "===", "\"number\"", "?", "options", ".", "space", ":", "2", ";", "options", ".", "new_line", "=", "!", "!", "options", ".", "new_line", ";", "Fs", "[", "\"writeFile\"", "+", "(", "typeof", "callback", "===", "\"function\"", "?", "\"\"", ":", "\"Sync\"", ")", "]", "(", "path", ",", "JSON", ".", "stringify", "(", "data", ",", "null", ",", "options", ".", "space", ")", "+", "(", "options", ".", "new_line", "?", "\"\\n\"", ":", "\"\"", ")", ",", "callback", ")", ";", "}" ]
wJson Writes a JSON file. @name wJson @function @param {String} path The JSON file path. @param {Object} data The JSON data to write in the provided file. @param {Object|Number|Boolean} options An object containing the fields below. If boolean, it will be handled as `new_line`, if number it will be handled as `space`. - `space` (Number): An optional space value for beautifying the json output (default: `2`). - `new_line` (Boolean): If `true`, a new line character will be added at the end of the stringified content. @param {Function} callback An optional callback. If not passed, the function will run in sync mode.
[ "wJson", "Writes", "a", "JSON", "file", "." ]
7f709f84325d86d4bee548abac16dfe84b3d94af
https://github.com/IonicaBizau/node-w-json/blob/7f709f84325d86d4bee548abac16dfe84b3d94af/lib/index.js#L20-L45
53,473
sendanor/nor-nopg
src/schema/v0022.js
function(db) { function merge(a_, b_, plv8, ERROR) { function copy_properties(o, a) { Object.keys(a).forEach(function(k) { o[k] = a[k]; }); return o; } function copy(a, b) { return copy_properties(copy_properties({}, a), b); } try { return copy(a_, b_); } catch (e) { plv8.elog(ERROR, e); return; } } return db.query('CREATE SCHEMA IF NOT EXISTS nopg') .query('CREATE OR REPLACE FUNCTION nopg.merge(a json, b json) RETURNS json LANGUAGE plv8 STABLE AS ' + NoPg._escapeFunction(merge, ["a", "b", "plv8", "ERROR"]) ); }
javascript
function(db) { function merge(a_, b_, plv8, ERROR) { function copy_properties(o, a) { Object.keys(a).forEach(function(k) { o[k] = a[k]; }); return o; } function copy(a, b) { return copy_properties(copy_properties({}, a), b); } try { return copy(a_, b_); } catch (e) { plv8.elog(ERROR, e); return; } } return db.query('CREATE SCHEMA IF NOT EXISTS nopg') .query('CREATE OR REPLACE FUNCTION nopg.merge(a json, b json) RETURNS json LANGUAGE plv8 STABLE AS ' + NoPg._escapeFunction(merge, ["a", "b", "plv8", "ERROR"]) ); }
[ "function", "(", "db", ")", "{", "function", "merge", "(", "a_", ",", "b_", ",", "plv8", ",", "ERROR", ")", "{", "function", "copy_properties", "(", "o", ",", "a", ")", "{", "Object", ".", "keys", "(", "a", ")", ".", "forEach", "(", "function", "(", "k", ")", "{", "o", "[", "k", "]", "=", "a", "[", "k", "]", ";", "}", ")", ";", "return", "o", ";", "}", "function", "copy", "(", "a", ",", "b", ")", "{", "return", "copy_properties", "(", "copy_properties", "(", "{", "}", ",", "a", ")", ",", "b", ")", ";", "}", "try", "{", "return", "copy", "(", "a_", ",", "b_", ")", ";", "}", "catch", "(", "e", ")", "{", "plv8", ".", "elog", "(", "ERROR", ",", "e", ")", ";", "return", ";", "}", "}", "return", "db", ".", "query", "(", "'CREATE SCHEMA IF NOT EXISTS nopg'", ")", ".", "query", "(", "'CREATE OR REPLACE FUNCTION nopg.merge(a json, b json) RETURNS json LANGUAGE plv8 STABLE AS '", "+", "NoPg", ".", "_escapeFunction", "(", "merge", ",", "[", "\"a\"", ",", "\"b\"", ",", "\"plv8\"", ",", "\"ERROR\"", "]", ")", ")", ";", "}" ]
Implement merge function to merge two objects for use in UPDATE
[ "Implement", "merge", "function", "to", "merge", "two", "objects", "for", "use", "in", "UPDATE" ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/schema/v0022.js#L7-L31
53,474
byron-dupreez/aws-stream-consumer-core
taskdef-settings.js
describeMessage
function describeMessage(message, batch, context) { const b = batch || context.batch; const state = b && b.states.get(message); return message ? `Message (${state && state.msgDesc})` : ''; }
javascript
function describeMessage(message, batch, context) { const b = batch || context.batch; const state = b && b.states.get(message); return message ? `Message (${state && state.msgDesc})` : ''; }
[ "function", "describeMessage", "(", "message", ",", "batch", ",", "context", ")", "{", "const", "b", "=", "batch", "||", "context", ".", "batch", ";", "const", "state", "=", "b", "&&", "b", ".", "states", ".", "get", "(", "message", ")", ";", "return", "message", "?", "`", "${", "state", "&&", "state", ".", "msgDesc", "}", "`", ":", "''", ";", "}" ]
A `describeItem` implementation that accepts and describes the arguments passed to a "process one message at a time" function. @param {Message} message - the message being processed @param {Batch} batch - the current batch @param {StreamConsumerContext} context - the context to use @returns {string} a short description of the message
[ "A", "describeItem", "implementation", "that", "accepts", "and", "describes", "the", "arguments", "passed", "to", "a", "process", "one", "message", "at", "a", "time", "function", "." ]
9b256084297f80d373bcf483aaf68a9da176b3d7
https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/taskdef-settings.js#L58-L62
53,475
byron-dupreez/aws-stream-consumer-core
taskdef-settings.js
describeUnusableRecord
function describeUnusableRecord(unusableRecord, batch, context) { const b = batch || context.batch; const state = b && b.states.get(unusableRecord); return `Unusable record (${state && state.recDesc})`; }
javascript
function describeUnusableRecord(unusableRecord, batch, context) { const b = batch || context.batch; const state = b && b.states.get(unusableRecord); return `Unusable record (${state && state.recDesc})`; }
[ "function", "describeUnusableRecord", "(", "unusableRecord", ",", "batch", ",", "context", ")", "{", "const", "b", "=", "batch", "||", "context", ".", "batch", ";", "const", "state", "=", "b", "&&", "b", ".", "states", ".", "get", "(", "unusableRecord", ")", ";", "return", "`", "${", "state", "&&", "state", ".", "recDesc", "}", "`", ";", "}" ]
A `describeItem` implementation that accepts and describes the arguments passed to a `discardUnusableRecord` function. @param {UnusableRecord} unusableRecord - the unusable record to be discarded @param {Batch} batch - the batch being processed @param {StreamConsumerContext} context - the context to use @returns {string} a short description of the unusable record
[ "A", "describeItem", "implementation", "that", "accepts", "and", "describes", "the", "arguments", "passed", "to", "a", "discardUnusableRecord", "function", "." ]
9b256084297f80d373bcf483aaf68a9da176b3d7
https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/taskdef-settings.js#L94-L98
53,476
byron-dupreez/aws-stream-consumer-core
taskdef-settings.js
describeRejectedMessage
function describeRejectedMessage(rejectedMessage, batch, context) { const b = batch || context.batch; const state = b && b.states.get(rejectedMessage); return `Rejected message (${state && (state.msgDesc || state.recDesc)})`; }
javascript
function describeRejectedMessage(rejectedMessage, batch, context) { const b = batch || context.batch; const state = b && b.states.get(rejectedMessage); return `Rejected message (${state && (state.msgDesc || state.recDesc)})`; }
[ "function", "describeRejectedMessage", "(", "rejectedMessage", ",", "batch", ",", "context", ")", "{", "const", "b", "=", "batch", "||", "context", ".", "batch", ";", "const", "state", "=", "b", "&&", "b", ".", "states", ".", "get", "(", "rejectedMessage", ")", ";", "return", "`", "${", "state", "&&", "(", "state", ".", "msgDesc", "||", "state", ".", "recDesc", ")", "}", "`", ";", "}" ]
A `describeItem` implementation that accepts and describes the arguments passed to a `discardRejectedMessage` function. @param {Message} rejectedMessage - the rejected message to be discarded @param {Batch} batch - the batch being processed @param {StreamConsumerContext} context - the context to use @returns {string} a short description of the rejected message
[ "A", "describeItem", "implementation", "that", "accepts", "and", "describes", "the", "arguments", "passed", "to", "a", "discardRejectedMessage", "function", "." ]
9b256084297f80d373bcf483aaf68a9da176b3d7
https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/taskdef-settings.js#L107-L111
53,477
tjunghans/stylus-deps-to-css
lib/stylus-deps-to-css.js
readStylusFile
function readStylusFile(file, callback) { fs.readFile(file, function (err, data) { if (err) { throw err; } stylus.render(data.toString(), function (err, css) { if (err) { throw err; } callback(css); }); }); }
javascript
function readStylusFile(file, callback) { fs.readFile(file, function (err, data) { if (err) { throw err; } stylus.render(data.toString(), function (err, css) { if (err) { throw err; } callback(css); }); }); }
[ "function", "readStylusFile", "(", "file", ",", "callback", ")", "{", "fs", ".", "readFile", "(", "file", ",", "function", "(", "err", ",", "data", ")", "{", "if", "(", "err", ")", "{", "throw", "err", ";", "}", "stylus", ".", "render", "(", "data", ".", "toString", "(", ")", ",", "function", "(", "err", ",", "css", ")", "{", "if", "(", "err", ")", "{", "throw", "err", ";", "}", "callback", "(", "css", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
Yields callback with css
[ "Yields", "callback", "with", "css" ]
0957237c993f19339ea89011d4af73c644e75364
https://github.com/tjunghans/stylus-deps-to-css/blob/0957237c993f19339ea89011d4af73c644e75364/lib/stylus-deps-to-css.js#L38-L50
53,478
kevinoid/promised-read
lib/eof-error.js
EOFError
function EOFError(message) { // Like http://www.ecma-international.org/ecma-262/6.0/#sec-error-message if (!(this instanceof EOFError)) { return new EOFError(message); } Error.captureStackTrace(this, EOFError); if (message !== undefined) { Object.defineProperty(this, 'message', { value: String(message), configurable: true, writable: true }); } }
javascript
function EOFError(message) { // Like http://www.ecma-international.org/ecma-262/6.0/#sec-error-message if (!(this instanceof EOFError)) { return new EOFError(message); } Error.captureStackTrace(this, EOFError); if (message !== undefined) { Object.defineProperty(this, 'message', { value: String(message), configurable: true, writable: true }); } }
[ "function", "EOFError", "(", "message", ")", "{", "// Like http://www.ecma-international.org/ecma-262/6.0/#sec-error-message", "if", "(", "!", "(", "this", "instanceof", "EOFError", ")", ")", "{", "return", "new", "EOFError", "(", "message", ")", ";", "}", "Error", ".", "captureStackTrace", "(", "this", ",", "EOFError", ")", ";", "if", "(", "message", "!==", "undefined", ")", "{", "Object", ".", "defineProperty", "(", "this", ",", "'message'", ",", "{", "value", ":", "String", "(", "message", ")", ",", "configurable", ":", "true", ",", "writable", ":", "true", "}", ")", ";", "}", "}" ]
Constructs an EOFError. @class Represents an error caused by reaching the end-of-file (or, more generally, end-of-input). @constructor @param {string=} message Human-readable description of the error.
[ "Constructs", "an", "EOFError", "." ]
c6adf477f4a64d5142363d84f7f83f5f07b8f682
https://github.com/kevinoid/promised-read/blob/c6adf477f4a64d5142363d84f7f83f5f07b8f682/lib/eof-error.js#L17-L28
53,479
dickhardt/node-a2p3
lib/jwt.js
jws
function jws ( details ) { if (!details.header) throw new Error('No header for JWS token') if (!details.header.alg) throw new Error('No JWS signing algorithm specified') if (!signAlg[details.header.alg]) throw new Error('Unsupported JWS signing algorithm:"'+details.header.alg+'"') if (!details.payload) throw new Error('No payload for JWS token') if (!details.credentials) throw new Error('No credentials for JWS token') if (!details.credentials.kid) throw new Error('No credentials.kid for JWS token') if (!details.credentials.key) throw new Error('No credentials.key for JWS token') return signAlg[details.header.alg]( details ) }
javascript
function jws ( details ) { if (!details.header) throw new Error('No header for JWS token') if (!details.header.alg) throw new Error('No JWS signing algorithm specified') if (!signAlg[details.header.alg]) throw new Error('Unsupported JWS signing algorithm:"'+details.header.alg+'"') if (!details.payload) throw new Error('No payload for JWS token') if (!details.credentials) throw new Error('No credentials for JWS token') if (!details.credentials.kid) throw new Error('No credentials.kid for JWS token') if (!details.credentials.key) throw new Error('No credentials.key for JWS token') return signAlg[details.header.alg]( details ) }
[ "function", "jws", "(", "details", ")", "{", "if", "(", "!", "details", ".", "header", ")", "throw", "new", "Error", "(", "'No header for JWS token'", ")", "if", "(", "!", "details", ".", "header", ".", "alg", ")", "throw", "new", "Error", "(", "'No JWS signing algorithm specified'", ")", "if", "(", "!", "signAlg", "[", "details", ".", "header", ".", "alg", "]", ")", "throw", "new", "Error", "(", "'Unsupported JWS signing algorithm:\"'", "+", "details", ".", "header", ".", "alg", "+", "'\"'", ")", "if", "(", "!", "details", ".", "payload", ")", "throw", "new", "Error", "(", "'No payload for JWS token'", ")", "if", "(", "!", "details", ".", "credentials", ")", "throw", "new", "Error", "(", "'No credentials for JWS token'", ")", "if", "(", "!", "details", ".", "credentials", ".", "kid", ")", "throw", "new", "Error", "(", "'No credentials.kid for JWS token'", ")", "if", "(", "!", "details", ".", "credentials", ".", "key", ")", "throw", "new", "Error", "(", "'No credentials.key for JWS token'", ")", "return", "signAlg", "[", "details", ".", "header", ".", "alg", "]", "(", "details", ")", "}" ]
make a JWS
[ "make", "a", "JWS" ]
ca9dd8802d7ed2e90f6754bfced0ac9014c230a3
https://github.com/dickhardt/node-a2p3/blob/ca9dd8802d7ed2e90f6754bfced0ac9014c230a3/lib/jwt.js#L278-L294
53,480
dickhardt/node-a2p3
lib/jwt.js
keygen
function keygen (alg) { var algs = { 'HS256': 256/8 , 'HS512': 512/8 , 'A128CBC+HS256': 256/8 , 'A256CBC+HS512': 512/8 }; if (!algs[alg]) return null; return (b64url.encode(crypto.randomBytes(algs[alg]))) }
javascript
function keygen (alg) { var algs = { 'HS256': 256/8 , 'HS512': 512/8 , 'A128CBC+HS256': 256/8 , 'A256CBC+HS512': 512/8 }; if (!algs[alg]) return null; return (b64url.encode(crypto.randomBytes(algs[alg]))) }
[ "function", "keygen", "(", "alg", ")", "{", "var", "algs", "=", "{", "'HS256'", ":", "256", "/", "8", ",", "'HS512'", ":", "512", "/", "8", ",", "'A128CBC+HS256'", ":", "256", "/", "8", ",", "'A256CBC+HS512'", ":", "512", "/", "8", "}", ";", "if", "(", "!", "algs", "[", "alg", "]", ")", "return", "null", ";", "return", "(", "b64url", ".", "encode", "(", "crypto", ".", "randomBytes", "(", "algs", "[", "alg", "]", ")", ")", ")", "}" ]
generates a key for the passed algorithm
[ "generates", "a", "key", "for", "the", "passed", "algorithm" ]
ca9dd8802d7ed2e90f6754bfced0ac9014c230a3
https://github.com/dickhardt/node-a2p3/blob/ca9dd8802d7ed2e90f6754bfced0ac9014c230a3/lib/jwt.js#L369-L378
53,481
acos-server/acos-jsparsons
static/js-parsons/parsons.js
builtinRead
function builtinRead(x) { if (Sk.builtinFiles === undefined || Sk.builtinFiles["files"][x] === undefined) throw "File not found: '" + x + "'"; return Sk.builtinFiles["files"][x]; }
javascript
function builtinRead(x) { if (Sk.builtinFiles === undefined || Sk.builtinFiles["files"][x] === undefined) throw "File not found: '" + x + "'"; return Sk.builtinFiles["files"][x]; }
[ "function", "builtinRead", "(", "x", ")", "{", "if", "(", "Sk", ".", "builtinFiles", "===", "undefined", "||", "Sk", ".", "builtinFiles", "[", "\"files\"", "]", "[", "x", "]", "===", "undefined", ")", "throw", "\"File not found: '\"", "+", "x", "+", "\"'\"", ";", "return", "Sk", ".", "builtinFiles", "[", "\"files\"", "]", "[", "x", "]", ";", "}" ]
function for reading python imports with skulpt
[ "function", "for", "reading", "python", "imports", "with", "skulpt" ]
8c504c261137b0bedf1939a60dd76cfe21d01d7f
https://github.com/acos-server/acos-jsparsons/blob/8c504c261137b0bedf1939a60dd76cfe21d01d7f/static/js-parsons/parsons.js#L110-L114
53,482
acos-server/acos-jsparsons
static/js-parsons/parsons.js
function(options) { // Contains line objects of the user-draggable code. // The order is not meaningful (unchanged from the initial state) but // indent property for each line object is updated as the user moves // codelines around. (see parseCode for line object description) this.modified_lines = []; // contains line objects of distractors (see parseCode for line object description) this.extra_lines = []; // contains line objects (see parseCode for line object description) this.model_solution = []; //To collect statistics, feedback should not be based on this this.user_actions = []; //State history for feedback purposes this.state_path = []; this.states = {}; var defaults = { 'incorrectSound': false, 'x_indent': 50, 'can_indent': true, 'feedback_cb': false, 'first_error_only': true, 'max_wrong_lines': 10, 'lang': 'en', 'toggleSeparator': '::' }; this.options = jQuery.extend({}, defaults, options); this.feedback_exists = false; this.id_prefix = options['sortableId'] + 'codeline'; if (translations.hasOwnProperty(this.options.lang)) { this.translations = translations[this.options.lang]; } else { this.translations = translations['en']; } // translate trash_label and solution_label if (!this.options.hasOwnProperty("trash_label")) { this.options.trash_label = this.translations.trash_label; } if (!this.options.hasOwnProperty("solution_label")) { this.options.solution_label = this.translations.solution_label; } this.FEEDBACK_STYLES = { 'correctPosition' : 'correctPosition', 'incorrectPosition' : 'incorrectPosition', 'correctIndent' : 'correctIndent', 'incorrectIndent' : 'incorrectIndent'}; // use grader passed as an option if defined and is a function if (this.options.grader && _.isFunction(this.options.grader)) { this.grader = new this.options.grader(this); } else { // initialize the grader if (typeof(this.options.unittests) !== "undefined") { /// unittests are specified this.grader = new UnitTestGrader(this); } else if (typeof(this.options.vartests) !== "undefined") { /// tests for variable values this.grader = new VariableCheckGrader(this); } else { // "traditional" parson feedback this.grader = new LineBasedGrader(this); } } }
javascript
function(options) { // Contains line objects of the user-draggable code. // The order is not meaningful (unchanged from the initial state) but // indent property for each line object is updated as the user moves // codelines around. (see parseCode for line object description) this.modified_lines = []; // contains line objects of distractors (see parseCode for line object description) this.extra_lines = []; // contains line objects (see parseCode for line object description) this.model_solution = []; //To collect statistics, feedback should not be based on this this.user_actions = []; //State history for feedback purposes this.state_path = []; this.states = {}; var defaults = { 'incorrectSound': false, 'x_indent': 50, 'can_indent': true, 'feedback_cb': false, 'first_error_only': true, 'max_wrong_lines': 10, 'lang': 'en', 'toggleSeparator': '::' }; this.options = jQuery.extend({}, defaults, options); this.feedback_exists = false; this.id_prefix = options['sortableId'] + 'codeline'; if (translations.hasOwnProperty(this.options.lang)) { this.translations = translations[this.options.lang]; } else { this.translations = translations['en']; } // translate trash_label and solution_label if (!this.options.hasOwnProperty("trash_label")) { this.options.trash_label = this.translations.trash_label; } if (!this.options.hasOwnProperty("solution_label")) { this.options.solution_label = this.translations.solution_label; } this.FEEDBACK_STYLES = { 'correctPosition' : 'correctPosition', 'incorrectPosition' : 'incorrectPosition', 'correctIndent' : 'correctIndent', 'incorrectIndent' : 'incorrectIndent'}; // use grader passed as an option if defined and is a function if (this.options.grader && _.isFunction(this.options.grader)) { this.grader = new this.options.grader(this); } else { // initialize the grader if (typeof(this.options.unittests) !== "undefined") { /// unittests are specified this.grader = new UnitTestGrader(this); } else if (typeof(this.options.vartests) !== "undefined") { /// tests for variable values this.grader = new VariableCheckGrader(this); } else { // "traditional" parson feedback this.grader = new LineBasedGrader(this); } } }
[ "function", "(", "options", ")", "{", "// Contains line objects of the user-draggable code.", "// The order is not meaningful (unchanged from the initial state) but", "// indent property for each line object is updated as the user moves", "// codelines around. (see parseCode for line object description)", "this", ".", "modified_lines", "=", "[", "]", ";", "// contains line objects of distractors (see parseCode for line object description)", "this", ".", "extra_lines", "=", "[", "]", ";", "// contains line objects (see parseCode for line object description)", "this", ".", "model_solution", "=", "[", "]", ";", "//To collect statistics, feedback should not be based on this", "this", ".", "user_actions", "=", "[", "]", ";", "//State history for feedback purposes", "this", ".", "state_path", "=", "[", "]", ";", "this", ".", "states", "=", "{", "}", ";", "var", "defaults", "=", "{", "'incorrectSound'", ":", "false", ",", "'x_indent'", ":", "50", ",", "'can_indent'", ":", "true", ",", "'feedback_cb'", ":", "false", ",", "'first_error_only'", ":", "true", ",", "'max_wrong_lines'", ":", "10", ",", "'lang'", ":", "'en'", ",", "'toggleSeparator'", ":", "'::'", "}", ";", "this", ".", "options", "=", "jQuery", ".", "extend", "(", "{", "}", ",", "defaults", ",", "options", ")", ";", "this", ".", "feedback_exists", "=", "false", ";", "this", ".", "id_prefix", "=", "options", "[", "'sortableId'", "]", "+", "'codeline'", ";", "if", "(", "translations", ".", "hasOwnProperty", "(", "this", ".", "options", ".", "lang", ")", ")", "{", "this", ".", "translations", "=", "translations", "[", "this", ".", "options", ".", "lang", "]", ";", "}", "else", "{", "this", ".", "translations", "=", "translations", "[", "'en'", "]", ";", "}", "// translate trash_label and solution_label", "if", "(", "!", "this", ".", "options", ".", "hasOwnProperty", "(", "\"trash_label\"", ")", ")", "{", "this", ".", "options", ".", "trash_label", "=", "this", ".", "translations", ".", "trash_label", ";", "}", "if", "(", "!", "this", ".", "options", ".", "hasOwnProperty", "(", "\"solution_label\"", ")", ")", "{", "this", ".", "options", ".", "solution_label", "=", "this", ".", "translations", ".", "solution_label", ";", "}", "this", ".", "FEEDBACK_STYLES", "=", "{", "'correctPosition'", ":", "'correctPosition'", ",", "'incorrectPosition'", ":", "'incorrectPosition'", ",", "'correctIndent'", ":", "'correctIndent'", ",", "'incorrectIndent'", ":", "'incorrectIndent'", "}", ";", "// use grader passed as an option if defined and is a function", "if", "(", "this", ".", "options", ".", "grader", "&&", "_", ".", "isFunction", "(", "this", ".", "options", ".", "grader", ")", ")", "{", "this", ".", "grader", "=", "new", "this", ".", "options", ".", "grader", "(", "this", ")", ";", "}", "else", "{", "// initialize the grader", "if", "(", "typeof", "(", "this", ".", "options", ".", "unittests", ")", "!==", "\"undefined\"", ")", "{", "/// unittests are specified", "this", ".", "grader", "=", "new", "UnitTestGrader", "(", "this", ")", ";", "}", "else", "if", "(", "typeof", "(", "this", ".", "options", ".", "vartests", ")", "!==", "\"undefined\"", ")", "{", "/// tests for variable values", "this", ".", "grader", "=", "new", "VariableCheckGrader", "(", "this", ")", ";", "}", "else", "{", "// \"traditional\" parson feedback", "this", ".", "grader", "=", "new", "LineBasedGrader", "(", "this", ")", ";", "}", "}", "}" ]
Creates a parsons widget. Init must be called after creating an object.
[ "Creates", "a", "parsons", "widget", ".", "Init", "must", "be", "called", "after", "creating", "an", "object", "." ]
8c504c261137b0bedf1939a60dd76cfe21d01d7f
https://github.com/acos-server/acos-jsparsons/blob/8c504c261137b0bedf1939a60dd76cfe21d01d7f/static/js-parsons/parsons.js#L860-L923
53,483
Maultasche/BaconNodeAutoPauseLineStream
src/index.js
createAutoPauseLineStream
function createAutoPauseLineStream(readStream) { //Use readline to read the lines of text const lineReader = readline.createInterface({ input: readStream }); //Create a line queue for the lines that are emitted from the line reader. //Once the line reader has read a chunk from the read stream, it will //continue to emit lines until it has processed the entire chunk. Pausing //the line reader or stream will cause them not to emit or process any more //chunks, but it will not immediately stop lines from being emitted. So //we'll store emitted lines in the line queue until it's time to emit them. const lineQueue = new Queue(); //Keep track of whether the stream has ended let streamEnd = false; //Create and return the Bacon stream generator function return Bacon.fromBinder(sink => { //Keep track of whether the stream is currently paused let paused = false; //Set an event handler for the error events lineReader.on('error', error => sink(new Bacon.Error(error))); //Set an event handler for the line event lineReader.on('line', lineString => { //Add the line to the line buffer lineQueue.enq(lineString); //Pause the line reader readStream.pause(); //If the stream is not currently paused, emit a line if(!paused) { emitLine(); } }); //Set an event handler for the close event, which indicates //that we've read all the lines lineReader.on('close', () => { //Indicate the stream has ended streamEnd = true; //If the stream is not paused, emit a line if(!paused) { emitLine(); } }); //Emits a line if possible function emitLine() { if(lineQueue.size() > 0) { pause(); sink({line: lineQueue.deq(), resume}); } else if(streamEnd) { sink(new Bacon.End()); } else { //If we've run out of lines to emit readStream.resume(); } } //Pauses the stream function pause() { paused = true; } //Resumes the stream function resume() { paused = false; emitLine(); } return () => {}; }); }
javascript
function createAutoPauseLineStream(readStream) { //Use readline to read the lines of text const lineReader = readline.createInterface({ input: readStream }); //Create a line queue for the lines that are emitted from the line reader. //Once the line reader has read a chunk from the read stream, it will //continue to emit lines until it has processed the entire chunk. Pausing //the line reader or stream will cause them not to emit or process any more //chunks, but it will not immediately stop lines from being emitted. So //we'll store emitted lines in the line queue until it's time to emit them. const lineQueue = new Queue(); //Keep track of whether the stream has ended let streamEnd = false; //Create and return the Bacon stream generator function return Bacon.fromBinder(sink => { //Keep track of whether the stream is currently paused let paused = false; //Set an event handler for the error events lineReader.on('error', error => sink(new Bacon.Error(error))); //Set an event handler for the line event lineReader.on('line', lineString => { //Add the line to the line buffer lineQueue.enq(lineString); //Pause the line reader readStream.pause(); //If the stream is not currently paused, emit a line if(!paused) { emitLine(); } }); //Set an event handler for the close event, which indicates //that we've read all the lines lineReader.on('close', () => { //Indicate the stream has ended streamEnd = true; //If the stream is not paused, emit a line if(!paused) { emitLine(); } }); //Emits a line if possible function emitLine() { if(lineQueue.size() > 0) { pause(); sink({line: lineQueue.deq(), resume}); } else if(streamEnd) { sink(new Bacon.End()); } else { //If we've run out of lines to emit readStream.resume(); } } //Pauses the stream function pause() { paused = true; } //Resumes the stream function resume() { paused = false; emitLine(); } return () => {}; }); }
[ "function", "createAutoPauseLineStream", "(", "readStream", ")", "{", "//Use readline to read the lines of text", "const", "lineReader", "=", "readline", ".", "createInterface", "(", "{", "input", ":", "readStream", "}", ")", ";", "//Create a line queue for the lines that are emitted from the line reader.", "//Once the line reader has read a chunk from the read stream, it will", "//continue to emit lines until it has processed the entire chunk. Pausing", "//the line reader or stream will cause them not to emit or process any more", "//chunks, but it will not immediately stop lines from being emitted. So", "//we'll store emitted lines in the line queue until it's time to emit them.", "const", "lineQueue", "=", "new", "Queue", "(", ")", ";", "//Keep track of whether the stream has ended", "let", "streamEnd", "=", "false", ";", "//Create and return the Bacon stream generator function", "return", "Bacon", ".", "fromBinder", "(", "sink", "=>", "{", "//Keep track of whether the stream is currently paused", "let", "paused", "=", "false", ";", "//Set an event handler for the error events", "lineReader", ".", "on", "(", "'error'", ",", "error", "=>", "sink", "(", "new", "Bacon", ".", "Error", "(", "error", ")", ")", ")", ";", "//Set an event handler for the line event", "lineReader", ".", "on", "(", "'line'", ",", "lineString", "=>", "{", "//Add the line to the line buffer", "lineQueue", ".", "enq", "(", "lineString", ")", ";", "//Pause the line reader", "readStream", ".", "pause", "(", ")", ";", "//If the stream is not currently paused, emit a line", "if", "(", "!", "paused", ")", "{", "emitLine", "(", ")", ";", "}", "}", ")", ";", "//Set an event handler for the close event, which indicates", "//that we've read all the lines", "lineReader", ".", "on", "(", "'close'", ",", "(", ")", "=>", "{", "//Indicate the stream has ended", "streamEnd", "=", "true", ";", "//If the stream is not paused, emit a line", "if", "(", "!", "paused", ")", "{", "emitLine", "(", ")", ";", "}", "}", ")", ";", "//Emits a line if possible", "function", "emitLine", "(", ")", "{", "if", "(", "lineQueue", ".", "size", "(", ")", ">", "0", ")", "{", "pause", "(", ")", ";", "sink", "(", "{", "line", ":", "lineQueue", ".", "deq", "(", ")", ",", "resume", "}", ")", ";", "}", "else", "if", "(", "streamEnd", ")", "{", "sink", "(", "new", "Bacon", ".", "End", "(", ")", ")", ";", "}", "else", "{", "//If we've run out of lines to emit", "readStream", ".", "resume", "(", ")", ";", "}", "}", "//Pauses the stream", "function", "pause", "(", ")", "{", "paused", "=", "true", ";", "}", "//Resumes the stream", "function", "resume", "(", ")", "{", "paused", "=", "false", ";", "emitLine", "(", ")", ";", "}", "return", "(", ")", "=>", "{", "}", ";", "}", ")", ";", "}" ]
Creates a Bacon stream that emits lines of text read from a readable stream. The stream pauses itself every time a line is emitted and can be unpaused by calling the unpause function the is emitted along with the line of text @param readStream - A readable stream @returns a Bacon stream that emits objects containing a line of text and an unpause function
[ "Creates", "a", "Bacon", "stream", "that", "emits", "lines", "of", "text", "read", "from", "a", "readable", "stream", ".", "The", "stream", "pauses", "itself", "every", "time", "a", "line", "is", "emitted", "and", "can", "be", "unpaused", "by", "calling", "the", "unpause", "function", "the", "is", "emitted", "along", "with", "the", "line", "of", "text" ]
587684a7e807bb1c0fff4bfda8cf70e96adeafaf
https://github.com/Maultasche/BaconNodeAutoPauseLineStream/blob/587684a7e807bb1c0fff4bfda8cf70e96adeafaf/src/index.js#L15-L99
53,484
Maultasche/BaconNodeAutoPauseLineStream
src/index.js
emitLine
function emitLine() { if(lineQueue.size() > 0) { pause(); sink({line: lineQueue.deq(), resume}); } else if(streamEnd) { sink(new Bacon.End()); } else { //If we've run out of lines to emit readStream.resume(); } }
javascript
function emitLine() { if(lineQueue.size() > 0) { pause(); sink({line: lineQueue.deq(), resume}); } else if(streamEnd) { sink(new Bacon.End()); } else { //If we've run out of lines to emit readStream.resume(); } }
[ "function", "emitLine", "(", ")", "{", "if", "(", "lineQueue", ".", "size", "(", ")", ">", "0", ")", "{", "pause", "(", ")", ";", "sink", "(", "{", "line", ":", "lineQueue", ".", "deq", "(", ")", ",", "resume", "}", ")", ";", "}", "else", "if", "(", "streamEnd", ")", "{", "sink", "(", "new", "Bacon", ".", "End", "(", ")", ")", ";", "}", "else", "{", "//If we've run out of lines to emit", "readStream", ".", "resume", "(", ")", ";", "}", "}" ]
Emits a line if possible
[ "Emits", "a", "line", "if", "possible" ]
587684a7e807bb1c0fff4bfda8cf70e96adeafaf
https://github.com/Maultasche/BaconNodeAutoPauseLineStream/blob/587684a7e807bb1c0fff4bfda8cf70e96adeafaf/src/index.js#L67-L81
53,485
mitchallen/connection-grid-square
modules/index.js
function(x, y, dir) { if(!this.isCell(x, y)) { return null; } // dir must be string and in dirmap if(!this.isDir(dir)) { return null; } let _DX = { "E": 1, "W": -1, "N": 0, "S": 0 }; let _DY = { "E": 0, "W": 0, "N": -1, "S": 1 }; var nx = x + _DX[dir]; var ny = y + _DY[dir]; if(!this.isCell(nx, ny)) { return null; } return { x: nx, y: ny }; }
javascript
function(x, y, dir) { if(!this.isCell(x, y)) { return null; } // dir must be string and in dirmap if(!this.isDir(dir)) { return null; } let _DX = { "E": 1, "W": -1, "N": 0, "S": 0 }; let _DY = { "E": 0, "W": 0, "N": -1, "S": 1 }; var nx = x + _DX[dir]; var ny = y + _DY[dir]; if(!this.isCell(nx, ny)) { return null; } return { x: nx, y: ny }; }
[ "function", "(", "x", ",", "y", ",", "dir", ")", "{", "if", "(", "!", "this", ".", "isCell", "(", "x", ",", "y", ")", ")", "{", "return", "null", ";", "}", "// dir must be string and in dirmap", "if", "(", "!", "this", ".", "isDir", "(", "dir", ")", ")", "{", "return", "null", ";", "}", "let", "_DX", "=", "{", "\"E\"", ":", "1", ",", "\"W\"", ":", "-", "1", ",", "\"N\"", ":", "0", ",", "\"S\"", ":", "0", "}", ";", "let", "_DY", "=", "{", "\"E\"", ":", "0", ",", "\"W\"", ":", "0", ",", "\"N\"", ":", "-", "1", ",", "\"S\"", ":", "1", "}", ";", "var", "nx", "=", "x", "+", "_DX", "[", "dir", "]", ";", "var", "ny", "=", "y", "+", "_DY", "[", "dir", "]", ";", "if", "(", "!", "this", ".", "isCell", "(", "nx", ",", "ny", ")", ")", "{", "return", "null", ";", "}", "return", "{", "x", ":", "nx", ",", "y", ":", "ny", "}", ";", "}" ]
Returns neighbor for direction @param {string} dir A string representing a direction @function @instance @memberof module:connection-grid-square @returns {string} @example <caption>usage</caption> var cell = grid.getNeighbor(1,1,"S");
[ "Returns", "neighbor", "for", "direction" ]
88cea02e210e9814b4c74f6a4c355b7695da6271
https://github.com/mitchallen/connection-grid-square/blob/88cea02e210e9814b4c74f6a4c355b7695da6271/modules/index.js#L84-L96
53,486
novemberborn/legendary
lib/fn.js
compose
function compose() { var funcs = slice.call(arguments); return function() { var thisArg = this; var boundFuncs = funcs.map(function(func) { return function() { return promise.Promise.from(func.apply(thisArg, arguments)); }; }); var args = slice.call(arguments); args.unshift(boundFuncs); return concurrent.pipeline.apply(concurrent, args); }; }
javascript
function compose() { var funcs = slice.call(arguments); return function() { var thisArg = this; var boundFuncs = funcs.map(function(func) { return function() { return promise.Promise.from(func.apply(thisArg, arguments)); }; }); var args = slice.call(arguments); args.unshift(boundFuncs); return concurrent.pipeline.apply(concurrent, args); }; }
[ "function", "compose", "(", ")", "{", "var", "funcs", "=", "slice", ".", "call", "(", "arguments", ")", ";", "return", "function", "(", ")", "{", "var", "thisArg", "=", "this", ";", "var", "boundFuncs", "=", "funcs", ".", "map", "(", "function", "(", "func", ")", "{", "return", "function", "(", ")", "{", "return", "promise", ".", "Promise", ".", "from", "(", "func", ".", "apply", "(", "thisArg", ",", "arguments", ")", ")", ";", "}", ";", "}", ")", ";", "var", "args", "=", "slice", ".", "call", "(", "arguments", ")", ";", "args", ".", "unshift", "(", "boundFuncs", ")", ";", "return", "concurrent", ".", "pipeline", ".", "apply", "(", "concurrent", ",", "args", ")", ";", "}", ";", "}" ]
The first `func` will be invoked with the other arguments that are passed. These arguments may also be promises, however instead of invoking `func` with the promises, it'll be invoked with the fulfillment values. If an argument promise is rejected, the returned promise will be rejected with the same reason.
[ "The", "first", "func", "will", "be", "invoked", "with", "the", "other", "arguments", "that", "are", "passed", ".", "These", "arguments", "may", "also", "be", "promises", "however", "instead", "of", "invoking", "func", "with", "the", "promises", "it", "ll", "be", "invoked", "with", "the", "fulfillment", "values", ".", "If", "an", "argument", "promise", "is", "rejected", "the", "returned", "promise", "will", "be", "rejected", "with", "the", "same", "reason", "." ]
8420f2dd20e2e3eaced51385fb6b0dc65b81a9fc
https://github.com/novemberborn/legendary/blob/8420f2dd20e2e3eaced51385fb6b0dc65b81a9fc/lib/fn.js#L159-L175
53,487
ForgeRock/node-openam-agent-cache-memcached
lib/memcached-cache.js
MemcachedCache
function MemcachedCache(options) { options = options || {}; this.client = memjs.Client.create(options.url || 'localhost/11211'); this.expireAfterSeconds = options.expireAfterSeconds || 60; }
javascript
function MemcachedCache(options) { options = options || {}; this.client = memjs.Client.create(options.url || 'localhost/11211'); this.expireAfterSeconds = options.expireAfterSeconds || 60; }
[ "function", "MemcachedCache", "(", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "this", ".", "client", "=", "memjs", ".", "Client", ".", "create", "(", "options", ".", "url", "||", "'localhost/11211'", ")", ";", "this", ".", "expireAfterSeconds", "=", "options", ".", "expireAfterSeconds", "||", "60", ";", "}" ]
Cache implementation for memcached @extends Cache @param {object} [options] Options @param {string} [options.url=http://localhost/11211] memcached URL @param {number} [options.expireAfterSeconds=60] Expiration time in seconds @example var memcachedCache = new MemcachedCache({ url: 'cache.example.com:11211', expireAfterSeconds: 600 }); @constructor
[ "Cache", "implementation", "for", "memcached" ]
3705fca89a5c4ef251e70944dcd2d6df81e9aa92
https://github.com/ForgeRock/node-openam-agent-cache-memcached/blob/3705fca89a5c4ef251e70944dcd2d6df81e9aa92/lib/memcached-cache.js#L26-L31
53,488
espadrine/queread
learn.js
function() { this.links.forEach(link => { link.labelCount.forEach((count, label) => { link.labelWeight.set(label, count / this.numExamples.get(label)) }) }) this.weightsNeedBuilding = false }
javascript
function() { this.links.forEach(link => { link.labelCount.forEach((count, label) => { link.labelWeight.set(label, count / this.numExamples.get(label)) }) }) this.weightsNeedBuilding = false }
[ "function", "(", ")", "{", "this", ".", "links", ".", "forEach", "(", "link", "=>", "{", "link", ".", "labelCount", ".", "forEach", "(", "(", "count", ",", "label", ")", "=>", "{", "link", ".", "labelWeight", ".", "set", "(", "label", ",", "count", "/", "this", ".", "numExamples", ".", "get", "(", "label", ")", ")", "}", ")", "}", ")", "this", ".", "weightsNeedBuilding", "=", "false", "}" ]
Build link.labelWeight.
[ "Build", "link", ".", "labelWeight", "." ]
5a0d5017ee1d1911983cc5252a27e160438837f7
https://github.com/espadrine/queread/blob/5a0d5017ee1d1911983cc5252a27e160438837f7/learn.js#L44-L51
53,489
smbape/node-fs-explorer
index.js
_explore
function _explore(start, callfile, calldir, options, done) { const {fs, followSymlink, resolve} = options; let count = 0; function take() { ++count; } function give(err) { if (--count === 0 || err) { done(err); } } // Start process take(); fs.lstat(start, (err, stats) => { let linkStats; if (err) { give(err); return; } if (stats.isSymbolicLink() && (followSymlink || resolve)) { linkStats = stats; fs.realpath(start, (err, resolvedPath) => { if (err) { give(err); return; } fs.lstat(resolvedPath, (err, stats) => { if (err) { // invalid symlink callfile(start, stats, give); return; } __doExplore(start, callfile, calldir, options, stats, linkStats, take, give); }); }); } else { __doExplore(start, callfile, calldir, options, stats, linkStats, take, give); } }); }
javascript
function _explore(start, callfile, calldir, options, done) { const {fs, followSymlink, resolve} = options; let count = 0; function take() { ++count; } function give(err) { if (--count === 0 || err) { done(err); } } // Start process take(); fs.lstat(start, (err, stats) => { let linkStats; if (err) { give(err); return; } if (stats.isSymbolicLink() && (followSymlink || resolve)) { linkStats = stats; fs.realpath(start, (err, resolvedPath) => { if (err) { give(err); return; } fs.lstat(resolvedPath, (err, stats) => { if (err) { // invalid symlink callfile(start, stats, give); return; } __doExplore(start, callfile, calldir, options, stats, linkStats, take, give); }); }); } else { __doExplore(start, callfile, calldir, options, stats, linkStats, take, give); } }); }
[ "function", "_explore", "(", "start", ",", "callfile", ",", "calldir", ",", "options", ",", "done", ")", "{", "const", "{", "fs", ",", "followSymlink", ",", "resolve", "}", "=", "options", ";", "let", "count", "=", "0", ";", "function", "take", "(", ")", "{", "++", "count", ";", "}", "function", "give", "(", "err", ")", "{", "if", "(", "--", "count", "===", "0", "||", "err", ")", "{", "done", "(", "err", ")", ";", "}", "}", "// Start process", "take", "(", ")", ";", "fs", ".", "lstat", "(", "start", ",", "(", "err", ",", "stats", ")", "=>", "{", "let", "linkStats", ";", "if", "(", "err", ")", "{", "give", "(", "err", ")", ";", "return", ";", "}", "if", "(", "stats", ".", "isSymbolicLink", "(", ")", "&&", "(", "followSymlink", "||", "resolve", ")", ")", "{", "linkStats", "=", "stats", ";", "fs", ".", "realpath", "(", "start", ",", "(", "err", ",", "resolvedPath", ")", "=>", "{", "if", "(", "err", ")", "{", "give", "(", "err", ")", ";", "return", ";", "}", "fs", ".", "lstat", "(", "resolvedPath", ",", "(", "err", ",", "stats", ")", "=>", "{", "if", "(", "err", ")", "{", "// invalid symlink", "callfile", "(", "start", ",", "stats", ",", "give", ")", ";", "return", ";", "}", "__doExplore", "(", "start", ",", "callfile", ",", "calldir", ",", "options", ",", "stats", ",", "linkStats", ",", "take", ",", "give", ")", ";", "}", ")", ";", "}", ")", ";", "}", "else", "{", "__doExplore", "(", "start", ",", "callfile", ",", "calldir", ",", "options", ",", "stats", ",", "linkStats", ",", "take", ",", "give", ")", ";", "}", "}", ")", ";", "}" ]
Explore a file or a directory with no checking of paramters correctness Calling next with err cancels the reading Not calling next will make the process hang forever If you want fast reading, call next before processing the file or folder If you want listing control, call next after you processed the file or folder @param {String} start File or folder to read @param {Function} callfile called every time a file is encountered with (path, stats, next) @param {Function} calldir called every time a folder is encountered with (path, stats, files, 'begin|end', next)To skip folder, call next(null, true) on begin @param {Object} options options.resolve[=true] => resolve symlink; options.followSymlink => explore symlink if directory @param {Function} done called when there are no more file nor folders to read
[ "Explore", "a", "file", "or", "a", "directory", "with", "no", "checking", "of", "paramters", "correctness" ]
e502aecfbe193506750d2a24680859ae03ca4c1e
https://github.com/smbape/node-fs-explorer/blob/e502aecfbe193506750d2a24680859ae03ca4c1e/index.js#L97-L143
53,490
vorg/fit-rect
index.js
fitRect
function fitRect(rect, target, mode) { mode = mode || 'contain'; var sw = target[2]/rect[2]; var sh = target[3]/rect[3]; var scale = 1; if (mode == 'contain') { scale = Math.min(sw, sh); } else if (mode == 'cover') { scale = Math.max(sw, sh); } return [ target[0] + (target[2] - rect[2]*scale)/2, target[1] + (target[3] - rect[3]*scale)/2, rect[2]*scale, rect[3]*scale ] }
javascript
function fitRect(rect, target, mode) { mode = mode || 'contain'; var sw = target[2]/rect[2]; var sh = target[3]/rect[3]; var scale = 1; if (mode == 'contain') { scale = Math.min(sw, sh); } else if (mode == 'cover') { scale = Math.max(sw, sh); } return [ target[0] + (target[2] - rect[2]*scale)/2, target[1] + (target[3] - rect[3]*scale)/2, rect[2]*scale, rect[3]*scale ] }
[ "function", "fitRect", "(", "rect", ",", "target", ",", "mode", ")", "{", "mode", "=", "mode", "||", "'contain'", ";", "var", "sw", "=", "target", "[", "2", "]", "/", "rect", "[", "2", "]", ";", "var", "sh", "=", "target", "[", "3", "]", "/", "rect", "[", "3", "]", ";", "var", "scale", "=", "1", ";", "if", "(", "mode", "==", "'contain'", ")", "{", "scale", "=", "Math", ".", "min", "(", "sw", ",", "sh", ")", ";", "}", "else", "if", "(", "mode", "==", "'cover'", ")", "{", "scale", "=", "Math", ".", "max", "(", "sw", ",", "sh", ")", ";", "}", "return", "[", "target", "[", "0", "]", "+", "(", "target", "[", "2", "]", "-", "rect", "[", "2", "]", "*", "scale", ")", "/", "2", ",", "target", "[", "1", "]", "+", "(", "target", "[", "3", "]", "-", "rect", "[", "3", "]", "*", "scale", ")", "/", "2", ",", "rect", "[", "2", "]", "*", "scale", ",", "rect", "[", "3", "]", "*", "scale", "]", "}" ]
Fits one rectangle into another @param {Array} rect [x,y,w,h] @param {Array} target [x,y,w,h] @param {String} mode ['contain' (default) or 'cover'] @return {Array} [x,y,w,h]
[ "Fits", "one", "rectangle", "into", "another" ]
cfd54e8f6d413b90e790bd43290e61e326c33abe
https://github.com/vorg/fit-rect/blob/cfd54e8f6d413b90e790bd43290e61e326c33abe/index.js#L8-L28
53,491
azendal/argon
argon/utility/field_encoder.js
encode
function encode(params) { var data, property, className; if(params === null){ return params; } className = Object.prototype.toString.call(params).replace('[object ', '').replace(']', ''); if ( className == 'Object' ) { data = {}; Object.keys(params).forEach(function (property) { if ( (typeof params[property] !== 'undefined') && (typeof params[property] !== 'function') ) { data[property.toString().underscore()] = this.encode(params[property]); } }, this); } else if (className == 'Array') { data = params.map(function (value) { return this.encode(value); }, this); } else { data = params; } return data; }
javascript
function encode(params) { var data, property, className; if(params === null){ return params; } className = Object.prototype.toString.call(params).replace('[object ', '').replace(']', ''); if ( className == 'Object' ) { data = {}; Object.keys(params).forEach(function (property) { if ( (typeof params[property] !== 'undefined') && (typeof params[property] !== 'function') ) { data[property.toString().underscore()] = this.encode(params[property]); } }, this); } else if (className == 'Array') { data = params.map(function (value) { return this.encode(value); }, this); } else { data = params; } return data; }
[ "function", "encode", "(", "params", ")", "{", "var", "data", ",", "property", ",", "className", ";", "if", "(", "params", "===", "null", ")", "{", "return", "params", ";", "}", "className", "=", "Object", ".", "prototype", ".", "toString", ".", "call", "(", "params", ")", ".", "replace", "(", "'[object '", ",", "''", ")", ".", "replace", "(", "']'", ",", "''", ")", ";", "if", "(", "className", "==", "'Object'", ")", "{", "data", "=", "{", "}", ";", "Object", ".", "keys", "(", "params", ")", ".", "forEach", "(", "function", "(", "property", ")", "{", "if", "(", "(", "typeof", "params", "[", "property", "]", "!==", "'undefined'", ")", "&&", "(", "typeof", "params", "[", "property", "]", "!==", "'function'", ")", ")", "{", "data", "[", "property", ".", "toString", "(", ")", ".", "underscore", "(", ")", "]", "=", "this", ".", "encode", "(", "params", "[", "property", "]", ")", ";", "}", "}", ",", "this", ")", ";", "}", "else", "if", "(", "className", "==", "'Array'", ")", "{", "data", "=", "params", ".", "map", "(", "function", "(", "value", ")", "{", "return", "this", ".", "encode", "(", "value", ")", ";", "}", ",", "this", ")", ";", "}", "else", "{", "data", "=", "params", ";", "}", "return", "data", ";", "}" ]
encondes the properties of the object with snake case style in a recursive strategy @property encode [Function] @param params [Object] any JavaScript @return object* [Object] the modified object
[ "encondes", "the", "properties", "of", "the", "object", "with", "snake", "case", "style", "in", "a", "recursive", "strategy" ]
0cfd3a3b3731b69abca55c956c757476779ec1bd
https://github.com/azendal/argon/blob/0cfd3a3b3731b69abca55c956c757476779ec1bd/argon/utility/field_encoder.js#L12-L41
53,492
aledbf/deis-api
lib/config.js
list
function list(appName, callback) { var uri = format('/%s/apps/%s/config/', deis.version, appName); commons.get(uri, function onListResponse(err, result) { callback(err, result ? result.values : null); }); }
javascript
function list(appName, callback) { var uri = format('/%s/apps/%s/config/', deis.version, appName); commons.get(uri, function onListResponse(err, result) { callback(err, result ? result.values : null); }); }
[ "function", "list", "(", "appName", ",", "callback", ")", "{", "var", "uri", "=", "format", "(", "'/%s/apps/%s/config/'", ",", "deis", ".", "version", ",", "appName", ")", ";", "commons", ".", "get", "(", "uri", ",", "function", "onListResponse", "(", "err", ",", "result", ")", "{", "callback", "(", "err", ",", "result", "?", "result", ".", "values", ":", "null", ")", ";", "}", ")", ";", "}" ]
List environment variables for an app
[ "List", "environment", "variables", "for", "an", "app" ]
f0833789998032b11221a3a617bb566ade1fcc13
https://github.com/aledbf/deis-api/blob/f0833789998032b11221a3a617bb566ade1fcc13/lib/config.js#L12-L17
53,493
aledbf/deis-api
lib/config.js
set
function set(appName, keyValues, keyLimits, callback) { var config = {}; if (!isObject(keyValues)) { return callback(new Error('To set a variable pass an object')); } config.values = keyValues; if (isObject(keyLimits)) { if (keyLimits.hasOwnProperty('memory')) { config.memory = keyLimits.memory; } if (keyLimits.hasOwnProperty('cpu')) { config.cpu = keyLimits.cpu; } } else { callback = keyLimits; } var uri = format('/%s/apps/%s/config/', deis.version, appName); commons.post(uri, config, function onSetResponse(err, result) { callback(err, result ? result.values : null); }); }
javascript
function set(appName, keyValues, keyLimits, callback) { var config = {}; if (!isObject(keyValues)) { return callback(new Error('To set a variable pass an object')); } config.values = keyValues; if (isObject(keyLimits)) { if (keyLimits.hasOwnProperty('memory')) { config.memory = keyLimits.memory; } if (keyLimits.hasOwnProperty('cpu')) { config.cpu = keyLimits.cpu; } } else { callback = keyLimits; } var uri = format('/%s/apps/%s/config/', deis.version, appName); commons.post(uri, config, function onSetResponse(err, result) { callback(err, result ? result.values : null); }); }
[ "function", "set", "(", "appName", ",", "keyValues", ",", "keyLimits", ",", "callback", ")", "{", "var", "config", "=", "{", "}", ";", "if", "(", "!", "isObject", "(", "keyValues", ")", ")", "{", "return", "callback", "(", "new", "Error", "(", "'To set a variable pass an object'", ")", ")", ";", "}", "config", ".", "values", "=", "keyValues", ";", "if", "(", "isObject", "(", "keyLimits", ")", ")", "{", "if", "(", "keyLimits", ".", "hasOwnProperty", "(", "'memory'", ")", ")", "{", "config", ".", "memory", "=", "keyLimits", ".", "memory", ";", "}", "if", "(", "keyLimits", ".", "hasOwnProperty", "(", "'cpu'", ")", ")", "{", "config", ".", "cpu", "=", "keyLimits", ".", "cpu", ";", "}", "}", "else", "{", "callback", "=", "keyLimits", ";", "}", "var", "uri", "=", "format", "(", "'/%s/apps/%s/config/'", ",", "deis", ".", "version", ",", "appName", ")", ";", "commons", ".", "post", "(", "uri", ",", "config", ",", "function", "onSetResponse", "(", "err", ",", "result", ")", "{", "callback", "(", "err", ",", "result", "?", "result", ".", "values", ":", "null", ")", ";", "}", ")", ";", "}" ]
Set environment variables for an application
[ "Set", "environment", "variables", "for", "an", "application" ]
f0833789998032b11221a3a617bb566ade1fcc13
https://github.com/aledbf/deis-api/blob/f0833789998032b11221a3a617bb566ade1fcc13/lib/config.js#L22-L46
53,494
aledbf/deis-api
lib/config.js
unset
function unset(appName, variableNames, callback) { if (!util.isArray(variableNames)) { return callback(new Error('To unset a variable pass an array of names')); } var keyValues = {}; variableNames.forEach(function onUnsetResponse(variableName) { keyValues[variableName] = null; }); set(appName, keyValues, callback); }
javascript
function unset(appName, variableNames, callback) { if (!util.isArray(variableNames)) { return callback(new Error('To unset a variable pass an array of names')); } var keyValues = {}; variableNames.forEach(function onUnsetResponse(variableName) { keyValues[variableName] = null; }); set(appName, keyValues, callback); }
[ "function", "unset", "(", "appName", ",", "variableNames", ",", "callback", ")", "{", "if", "(", "!", "util", ".", "isArray", "(", "variableNames", ")", ")", "{", "return", "callback", "(", "new", "Error", "(", "'To unset a variable pass an array of names'", ")", ")", ";", "}", "var", "keyValues", "=", "{", "}", ";", "variableNames", ".", "forEach", "(", "function", "onUnsetResponse", "(", "variableName", ")", "{", "keyValues", "[", "variableName", "]", "=", "null", ";", "}", ")", ";", "set", "(", "appName", ",", "keyValues", ",", "callback", ")", ";", "}" ]
Unset environment variables for an app
[ "Unset", "environment", "variables", "for", "an", "app" ]
f0833789998032b11221a3a617bb566ade1fcc13
https://github.com/aledbf/deis-api/blob/f0833789998032b11221a3a617bb566ade1fcc13/lib/config.js#L51-L62
53,495
glennschler/spotspec
lib/logger.js
LogWrapper
function LogWrapper (isLogging) { if (this.constructor.name === 'Function') { throw new Error('Missing object context') } if (!isLogging) { // stub the logger out this.logger = {} this.logger.info = function () {} this.logger.error = function () {} this.logger.warn = function () {} return } // Else config winston for logging const Winston = require('winston') let winstonTransport = new (Winston.transports.Console)({ json: false, colorize: true }) this.logger = new (Winston.Logger)({ transports: [winstonTransport] }) }
javascript
function LogWrapper (isLogging) { if (this.constructor.name === 'Function') { throw new Error('Missing object context') } if (!isLogging) { // stub the logger out this.logger = {} this.logger.info = function () {} this.logger.error = function () {} this.logger.warn = function () {} return } // Else config winston for logging const Winston = require('winston') let winstonTransport = new (Winston.transports.Console)({ json: false, colorize: true }) this.logger = new (Winston.Logger)({ transports: [winstonTransport] }) }
[ "function", "LogWrapper", "(", "isLogging", ")", "{", "if", "(", "this", ".", "constructor", ".", "name", "===", "'Function'", ")", "{", "throw", "new", "Error", "(", "'Missing object context'", ")", "}", "if", "(", "!", "isLogging", ")", "{", "// stub the logger out", "this", ".", "logger", "=", "{", "}", "this", ".", "logger", ".", "info", "=", "function", "(", ")", "{", "}", "this", ".", "logger", ".", "error", "=", "function", "(", ")", "{", "}", "this", ".", "logger", ".", "warn", "=", "function", "(", ")", "{", "}", "return", "}", "// Else config winston for logging", "const", "Winston", "=", "require", "(", "'winston'", ")", "let", "winstonTransport", "=", "new", "(", "Winston", ".", "transports", ".", "Console", ")", "(", "{", "json", ":", "false", ",", "colorize", ":", "true", "}", ")", "this", ".", "logger", "=", "new", "(", "Winston", ".", "Logger", ")", "(", "{", "transports", ":", "[", "winstonTransport", "]", "}", ")", "}" ]
Function to be assigned to an objects logger method @private @function LogWrapper
[ "Function", "to", "be", "assigned", "to", "an", "objects", "logger", "method" ]
ca6f5b17b84b3536b6b2ce9a472d5ae91c8cd727
https://github.com/glennschler/spotspec/blob/ca6f5b17b84b3536b6b2ce9a472d5ae91c8cd727/lib/logger.js#L8-L34
53,496
unkhz/almost-static-site
main/index.js
function(suffix) { if ( suffix.match(/^([a-z]*:?\d*)\/\//) ) { return suffix; } var base = this.enablePushState ? this.baseUrl : '#/'; return base + suffix.replace(/^\//,''); }
javascript
function(suffix) { if ( suffix.match(/^([a-z]*:?\d*)\/\//) ) { return suffix; } var base = this.enablePushState ? this.baseUrl : '#/'; return base + suffix.replace(/^\//,''); }
[ "function", "(", "suffix", ")", "{", "if", "(", "suffix", ".", "match", "(", "/", "^([a-z]*:?\\d*)\\/\\/", "/", ")", ")", "{", "return", "suffix", ";", "}", "var", "base", "=", "this", ".", "enablePushState", "?", "this", ".", "baseUrl", ":", "'#/'", ";", "return", "base", "+", "suffix", ".", "replace", "(", "/", "^\\/", "/", ",", "''", ")", ";", "}" ]
Generate url for navigation link href
[ "Generate", "url", "for", "navigation", "link", "href" ]
cd09f02ffec06ee2c7494a76ef9a545dbdb58653
https://github.com/unkhz/almost-static-site/blob/cd09f02ffec06ee2c7494a76ef9a545dbdb58653/main/index.js#L20-L24
53,497
carrascoMDD/protractor-relaunchable
lib/protractor.js
function(to, from, fnName, setupFn) { to[fnName] = function() { if (setupFn) { setupFn(); } return from[fnName].apply(from, arguments); }; }
javascript
function(to, from, fnName, setupFn) { to[fnName] = function() { if (setupFn) { setupFn(); } return from[fnName].apply(from, arguments); }; }
[ "function", "(", "to", ",", "from", ",", "fnName", ",", "setupFn", ")", "{", "to", "[", "fnName", "]", "=", "function", "(", ")", "{", "if", "(", "setupFn", ")", "{", "setupFn", "(", ")", ";", "}", "return", "from", "[", "fnName", "]", ".", "apply", "(", "from", ",", "arguments", ")", ";", "}", ";", "}" ]
Mix a function from one object onto another. The function will still be called in the context of the original object. @private @param {Object} to @param {Object} from @param {string} fnName @param {function=} setupFn
[ "Mix", "a", "function", "from", "one", "object", "onto", "another", ".", "The", "function", "will", "still", "be", "called", "in", "the", "context", "of", "the", "original", "object", "." ]
c18e17ecd8b5b036217f87680800c6e14b47361f
https://github.com/carrascoMDD/protractor-relaunchable/blob/c18e17ecd8b5b036217f87680800c6e14b47361f/lib/protractor.js#L53-L60
53,498
carrascoMDD/protractor-relaunchable
lib/protractor.js
function() { return elementArrayFinder.getWebElements().then(function(webElements) { if (webElements.length === 0) { throw new webdriver.error.Error( webdriver.error.ErrorCode.NO_SUCH_ELEMENT, 'No element found using locator: ' + elementArrayFinder.locator_.toString()); } else { if (webElements.length > 1) { console.log('warning: more than one element found for locator ' + elementArrayFinder.locator_.toString() + ' - you may need to be more specific'); } return [webElements[0]]; } }); }
javascript
function() { return elementArrayFinder.getWebElements().then(function(webElements) { if (webElements.length === 0) { throw new webdriver.error.Error( webdriver.error.ErrorCode.NO_SUCH_ELEMENT, 'No element found using locator: ' + elementArrayFinder.locator_.toString()); } else { if (webElements.length > 1) { console.log('warning: more than one element found for locator ' + elementArrayFinder.locator_.toString() + ' - you may need to be more specific'); } return [webElements[0]]; } }); }
[ "function", "(", ")", "{", "return", "elementArrayFinder", ".", "getWebElements", "(", ")", ".", "then", "(", "function", "(", "webElements", ")", "{", "if", "(", "webElements", ".", "length", "===", "0", ")", "{", "throw", "new", "webdriver", ".", "error", ".", "Error", "(", "webdriver", ".", "error", ".", "ErrorCode", ".", "NO_SUCH_ELEMENT", ",", "'No element found using locator: '", "+", "elementArrayFinder", ".", "locator_", ".", "toString", "(", ")", ")", ";", "}", "else", "{", "if", "(", "webElements", ".", "length", ">", "1", ")", "{", "console", ".", "log", "(", "'warning: more than one element found for locator '", "+", "elementArrayFinder", ".", "locator_", ".", "toString", "(", ")", "+", "' - you may need to be more specific'", ")", ";", "}", "return", "[", "webElements", "[", "0", "]", "]", ";", "}", "}", ")", ";", "}" ]
This filter verifies that there is only 1 element returned by the elementArrayFinder. It will warn if there are more than 1 element and throw an error if there are no elements.
[ "This", "filter", "verifies", "that", "there", "is", "only", "1", "element", "returned", "by", "the", "elementArrayFinder", ".", "It", "will", "warn", "if", "there", "are", "more", "than", "1", "element", "and", "throw", "an", "error", "if", "there", "are", "no", "elements", "." ]
c18e17ecd8b5b036217f87680800c6e14b47361f
https://github.com/carrascoMDD/protractor-relaunchable/blob/c18e17ecd8b5b036217f87680800c6e14b47361f/lib/protractor.js#L689-L705
53,499
jonschlinkert/conflicts
lib/diff.js
diffFile
function diffFile(existing, proposed, options) { let { ensureContents, exists, readChunk } = utils; let opts = options || {}; let contentsA = existing.contents; let contentsB = proposed.contents; if (!contentsA && exists(existing)) { contentsA = readChunk(existing.path, 0, 4 + 4096); } if (!contentsB && exists(proposed)) { contentsB = readChunk(proposed.path, 0, 4 + 4096); } if ((contentsA && isBuffer(contentsA)) || (contentsB && isBuffer(contentsB))) { return diffBinary(existing, proposed); } ensureContents(existing); ensureContents(proposed); if (opts.diffText === true) { return diffText(existing.contents.toString(), proposed.contents.toString(), opts); } return diffChars(existing.contents.toString(), proposed.contents.toString(), opts); }
javascript
function diffFile(existing, proposed, options) { let { ensureContents, exists, readChunk } = utils; let opts = options || {}; let contentsA = existing.contents; let contentsB = proposed.contents; if (!contentsA && exists(existing)) { contentsA = readChunk(existing.path, 0, 4 + 4096); } if (!contentsB && exists(proposed)) { contentsB = readChunk(proposed.path, 0, 4 + 4096); } if ((contentsA && isBuffer(contentsA)) || (contentsB && isBuffer(contentsB))) { return diffBinary(existing, proposed); } ensureContents(existing); ensureContents(proposed); if (opts.diffText === true) { return diffText(existing.contents.toString(), proposed.contents.toString(), opts); } return diffChars(existing.contents.toString(), proposed.contents.toString(), opts); }
[ "function", "diffFile", "(", "existing", ",", "proposed", ",", "options", ")", "{", "let", "{", "ensureContents", ",", "exists", ",", "readChunk", "}", "=", "utils", ";", "let", "opts", "=", "options", "||", "{", "}", ";", "let", "contentsA", "=", "existing", ".", "contents", ";", "let", "contentsB", "=", "proposed", ".", "contents", ";", "if", "(", "!", "contentsA", "&&", "exists", "(", "existing", ")", ")", "{", "contentsA", "=", "readChunk", "(", "existing", ".", "path", ",", "0", ",", "4", "+", "4096", ")", ";", "}", "if", "(", "!", "contentsB", "&&", "exists", "(", "proposed", ")", ")", "{", "contentsB", "=", "readChunk", "(", "proposed", ".", "path", ",", "0", ",", "4", "+", "4096", ")", ";", "}", "if", "(", "(", "contentsA", "&&", "isBuffer", "(", "contentsA", ")", ")", "||", "(", "contentsB", "&&", "isBuffer", "(", "contentsB", ")", ")", ")", "{", "return", "diffBinary", "(", "existing", ",", "proposed", ")", ";", "}", "ensureContents", "(", "existing", ")", ";", "ensureContents", "(", "proposed", ")", ";", "if", "(", "opts", ".", "diffText", "===", "true", ")", "{", "return", "diffText", "(", "existing", ".", "contents", ".", "toString", "(", ")", ",", "proposed", ".", "contents", ".", "toString", "(", ")", ",", "opts", ")", ";", "}", "return", "diffChars", "(", "existing", ".", "contents", ".", "toString", "(", ")", ",", "proposed", ".", "contents", ".", "toString", "(", ")", ",", "opts", ")", ";", "}" ]
Returns a formatted diff for binary or text files
[ "Returns", "a", "formatted", "diff", "for", "binary", "or", "text", "files" ]
0f45ab63f6cc24a03ce381b3d2159283923bc20d
https://github.com/jonschlinkert/conflicts/blob/0f45ab63f6cc24a03ce381b3d2159283923bc20d/lib/diff.js#L10-L35