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
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
41,500
chad-autry/hex-grid-map-3D
jsdoc-template/publish.js
linkToSrc
function linkToSrc(shortPath, lineNumber) { var splitPath = shortPath.split("/"); return '<a href="{{srcroot}}' + shortPath+'">' + splitPath[splitPath.length - 1] + '</a>, <a href="{{srcroot}}' + shortPath+'#L'+lineNumber+'">' + lineNumber + '</a>'; }
javascript
function linkToSrc(shortPath, lineNumber) { var splitPath = shortPath.split("/"); return '<a href="{{srcroot}}' + shortPath+'">' + splitPath[splitPath.length - 1] + '</a>, <a href="{{srcroot}}' + shortPath+'#L'+lineNumber+'">' + lineNumber + '</a>'; }
[ "function", "linkToSrc", "(", "shortPath", ",", "lineNumber", ")", "{", "var", "splitPath", "=", "shortPath", ".", "split", "(", "\"/\"", ")", ";", "return", "'<a href=\"{{srcroot}}'", "+", "shortPath", "+", "'\">'", "+", "splitPath", "[", "splitPath", ".", "length", "-", "1", "]", "+", "'</a>, <a href=\"{{srcroot}}'", "+", "shortPath", "+", "'#L'", "+", "lineNumber", "+", "'\">'", "+", "lineNumber", "+", "'</a>'", ";", "}" ]
Create links to the src relative to the external source url Adds a link to the line number according to github's format Since JSDoc seems incapable of accept external parameters, inject a value which will be replaced in Angular
[ "Create", "links", "to", "the", "src", "relative", "to", "the", "external", "source", "url", "Adds", "a", "link", "to", "the", "line", "number", "according", "to", "github", "s", "format", "Since", "JSDoc", "seems", "incapable", "of", "accept", "external", "parameters", "inject", "a", "value", "which", "will", "be", "replaced", "in", "Angular" ]
4c80bcb2580b2ba573df257b40082de97e8938e8
https://github.com/chad-autry/hex-grid-map-3D/blob/4c80bcb2580b2ba573df257b40082de97e8938e8/jsdoc-template/publish.js#L393-L397
41,501
alawatthe/MathLib
build/commonjs/SVG.js
function (circle, options, redraw) { if (typeof options === "undefined") { options = {}; } if (typeof redraw === "undefined") { redraw = false; } var screen = this.screen, prop, opts, svgCircle = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); svgCircle.setAttribute('cx', circle.center[0]); svgCircle.setAttribute('cy', circle.center[1]); svgCircle.setAttribute('r', circle.radius); if (options) { svgCircle.setAttribute('stroke-width', (options.lineWidth || 4) / (screen.scale.x - screen.scale.y) + ''); opts = MathLib.SVG.convertOptions(options); for (prop in opts) { if (opts.hasOwnProperty(prop)) { svgCircle.setAttribute(prop, opts[prop]); } } } this.ctx.appendChild(svgCircle); if (!redraw) { this.stack.push({ type: 'circle', object: circle, options: options }); } return this; }
javascript
function (circle, options, redraw) { if (typeof options === "undefined") { options = {}; } if (typeof redraw === "undefined") { redraw = false; } var screen = this.screen, prop, opts, svgCircle = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); svgCircle.setAttribute('cx', circle.center[0]); svgCircle.setAttribute('cy', circle.center[1]); svgCircle.setAttribute('r', circle.radius); if (options) { svgCircle.setAttribute('stroke-width', (options.lineWidth || 4) / (screen.scale.x - screen.scale.y) + ''); opts = MathLib.SVG.convertOptions(options); for (prop in opts) { if (opts.hasOwnProperty(prop)) { svgCircle.setAttribute(prop, opts[prop]); } } } this.ctx.appendChild(svgCircle); if (!redraw) { this.stack.push({ type: 'circle', object: circle, options: options }); } return this; }
[ "function", "(", "circle", ",", "options", ",", "redraw", ")", "{", "if", "(", "typeof", "options", "===", "\"undefined\"", ")", "{", "options", "=", "{", "}", ";", "}", "if", "(", "typeof", "redraw", "===", "\"undefined\"", ")", "{", "redraw", "=", "false", ";", "}", "var", "screen", "=", "this", ".", "screen", ",", "prop", ",", "opts", ",", "svgCircle", "=", "document", ".", "createElementNS", "(", "'http://www.w3.org/2000/svg'", ",", "'circle'", ")", ";", "svgCircle", ".", "setAttribute", "(", "'cx'", ",", "circle", ".", "center", "[", "0", "]", ")", ";", "svgCircle", ".", "setAttribute", "(", "'cy'", ",", "circle", ".", "center", "[", "1", "]", ")", ";", "svgCircle", ".", "setAttribute", "(", "'r'", ",", "circle", ".", "radius", ")", ";", "if", "(", "options", ")", "{", "svgCircle", ".", "setAttribute", "(", "'stroke-width'", ",", "(", "options", ".", "lineWidth", "||", "4", ")", "/", "(", "screen", ".", "scale", ".", "x", "-", "screen", ".", "scale", ".", "y", ")", "+", "''", ")", ";", "opts", "=", "MathLib", ".", "SVG", ".", "convertOptions", "(", "options", ")", ";", "for", "(", "prop", "in", "opts", ")", "{", "if", "(", "opts", ".", "hasOwnProperty", "(", "prop", ")", ")", "{", "svgCircle", ".", "setAttribute", "(", "prop", ",", "opts", "[", "prop", "]", ")", ";", "}", "}", "}", "this", ".", "ctx", ".", "appendChild", "(", "svgCircle", ")", ";", "if", "(", "!", "redraw", ")", "{", "this", ".", "stack", ".", "push", "(", "{", "type", ":", "'circle'", ",", "object", ":", "circle", ",", "options", ":", "options", "}", ")", ";", "}", "return", "this", ";", "}" ]
Draws a circle on the screen. @param {Circle} circle The circle to be drawn @param {drawingOptions} options Optional drawing options @param {boolean} redraw Indicates if the current draw call is happening during a redraw @return {Screen} Returns the screen
[ "Draws", "a", "circle", "on", "the", "screen", "." ]
43dbd35263da672bd2ca41f93dc447b60da9bdac
https://github.com/alawatthe/MathLib/blob/43dbd35263da672bd2ca41f93dc447b60da9bdac/build/commonjs/SVG.js#L32-L62
41,502
wbyoung/azul
lib/relations/has_many_prefetch.js
function(instances) { var queryKey = this.foreignKey; var pks = _.map(instances, this.primaryKey); if (instances.length === 1) { pks = pks[0]; } else { queryKey += '$in'; } var where = _.object([[queryKey, pks]]); return this._relatedModel.objects.where(where); }
javascript
function(instances) { var queryKey = this.foreignKey; var pks = _.map(instances, this.primaryKey); if (instances.length === 1) { pks = pks[0]; } else { queryKey += '$in'; } var where = _.object([[queryKey, pks]]); return this._relatedModel.objects.where(where); }
[ "function", "(", "instances", ")", "{", "var", "queryKey", "=", "this", ".", "foreignKey", ";", "var", "pks", "=", "_", ".", "map", "(", "instances", ",", "this", ".", "primaryKey", ")", ";", "if", "(", "instances", ".", "length", "===", "1", ")", "{", "pks", "=", "pks", "[", "0", "]", ";", "}", "else", "{", "queryKey", "+=", "'$in'", ";", "}", "var", "where", "=", "_", ".", "object", "(", "[", "[", "queryKey", ",", "pks", "]", "]", ")", ";", "return", "this", ".", "_relatedModel", ".", "objects", ".", "where", "(", "where", ")", ";", "}" ]
Generate the prefetch query. Subclasses can override this. @method @protected @see {@link HasMany#_prefetch}
[ "Generate", "the", "prefetch", "query", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/has_many_prefetch.js#L47-L56
41,503
alawatthe/MathLib
build/MathLib.js
function (options) { var convertedOptions = {}; if ('fillColor' in options) { convertedOptions.fillStyle = MathLib.colorConvert(options.fillColor); } else if ('color' in options) { convertedOptions.fillStyle = MathLib.colorConvert(options.color); } if ('font' in options) { convertedOptions.font = options.font; } if ('fontSize' in options) { convertedOptions.fontSize = options.fontSize; } if ('lineColor' in options) { convertedOptions.strokeStyle = MathLib.colorConvert(options.lineColor); } else if ('color' in options) { convertedOptions.strokeStyle = MathLib.colorConvert(options.color); } return convertedOptions; }
javascript
function (options) { var convertedOptions = {}; if ('fillColor' in options) { convertedOptions.fillStyle = MathLib.colorConvert(options.fillColor); } else if ('color' in options) { convertedOptions.fillStyle = MathLib.colorConvert(options.color); } if ('font' in options) { convertedOptions.font = options.font; } if ('fontSize' in options) { convertedOptions.fontSize = options.fontSize; } if ('lineColor' in options) { convertedOptions.strokeStyle = MathLib.colorConvert(options.lineColor); } else if ('color' in options) { convertedOptions.strokeStyle = MathLib.colorConvert(options.color); } return convertedOptions; }
[ "function", "(", "options", ")", "{", "var", "convertedOptions", "=", "{", "}", ";", "if", "(", "'fillColor'", "in", "options", ")", "{", "convertedOptions", ".", "fillStyle", "=", "MathLib", ".", "colorConvert", "(", "options", ".", "fillColor", ")", ";", "}", "else", "if", "(", "'color'", "in", "options", ")", "{", "convertedOptions", ".", "fillStyle", "=", "MathLib", ".", "colorConvert", "(", "options", ".", "color", ")", ";", "}", "if", "(", "'font'", "in", "options", ")", "{", "convertedOptions", ".", "font", "=", "options", ".", "font", ";", "}", "if", "(", "'fontSize'", "in", "options", ")", "{", "convertedOptions", ".", "fontSize", "=", "options", ".", "fontSize", ";", "}", "if", "(", "'lineColor'", "in", "options", ")", "{", "convertedOptions", ".", "strokeStyle", "=", "MathLib", ".", "colorConvert", "(", "options", ".", "lineColor", ")", ";", "}", "else", "if", "(", "'color'", "in", "options", ")", "{", "convertedOptions", ".", "strokeStyle", "=", "MathLib", ".", "colorConvert", "(", "options", ".", "color", ")", ";", "}", "return", "convertedOptions", ";", "}" ]
Converts the options to the Canvas options format @param {drawingOptions} options The drawing options @return {canvasDrawingOptions} The converted options
[ "Converts", "the", "options", "to", "the", "Canvas", "options", "format" ]
43dbd35263da672bd2ca41f93dc447b60da9bdac
https://github.com/alawatthe/MathLib/blob/43dbd35263da672bd2ca41f93dc447b60da9bdac/build/MathLib.js#L4325-L4349
41,504
alawatthe/MathLib
build/MathLib.js
function (line, options, redraw) { if (typeof options === "undefined") { options = {}; } if (typeof redraw === "undefined") { redraw = false; } var screen = this.screen, points, ctx = this.ctx, prop, opts; ctx.save(); ctx.lineWidth = (options.lineWidth || 4) / (screen.scale.x - screen.scale.y); // Don't try to draw the line at infinity if (line.type === 'line' && MathLib.isZero(line[0]) && MathLib.isZero(line[1])) { return this; } else { points = this.screen.getLineEndPoints(line); } // Set the drawing options if (options) { opts = MathLib.Canvas.convertOptions(options); for (prop in opts) { if (opts.hasOwnProperty(prop)) { ctx[prop] = opts[prop]; } } if ('setLineDash' in ctx) { ctx.setLineDash(('dash' in options ? options.dash : [])); } if ('lineDashOffset' in ctx) { ctx.lineDashOffset = ('dashOffset' in options ? options.dashOffset : 0); } } // Draw the line ctx.beginPath(); ctx.moveTo(points[0][0], points[0][1]); ctx.lineTo(points[1][0], points[1][1]); ctx.stroke(); ctx.closePath(); ctx.restore(); if (!redraw) { this.stack.push({ type: 'line', object: line, options: options }); } return this; }
javascript
function (line, options, redraw) { if (typeof options === "undefined") { options = {}; } if (typeof redraw === "undefined") { redraw = false; } var screen = this.screen, points, ctx = this.ctx, prop, opts; ctx.save(); ctx.lineWidth = (options.lineWidth || 4) / (screen.scale.x - screen.scale.y); // Don't try to draw the line at infinity if (line.type === 'line' && MathLib.isZero(line[0]) && MathLib.isZero(line[1])) { return this; } else { points = this.screen.getLineEndPoints(line); } // Set the drawing options if (options) { opts = MathLib.Canvas.convertOptions(options); for (prop in opts) { if (opts.hasOwnProperty(prop)) { ctx[prop] = opts[prop]; } } if ('setLineDash' in ctx) { ctx.setLineDash(('dash' in options ? options.dash : [])); } if ('lineDashOffset' in ctx) { ctx.lineDashOffset = ('dashOffset' in options ? options.dashOffset : 0); } } // Draw the line ctx.beginPath(); ctx.moveTo(points[0][0], points[0][1]); ctx.lineTo(points[1][0], points[1][1]); ctx.stroke(); ctx.closePath(); ctx.restore(); if (!redraw) { this.stack.push({ type: 'line', object: line, options: options }); } return this; }
[ "function", "(", "line", ",", "options", ",", "redraw", ")", "{", "if", "(", "typeof", "options", "===", "\"undefined\"", ")", "{", "options", "=", "{", "}", ";", "}", "if", "(", "typeof", "redraw", "===", "\"undefined\"", ")", "{", "redraw", "=", "false", ";", "}", "var", "screen", "=", "this", ".", "screen", ",", "points", ",", "ctx", "=", "this", ".", "ctx", ",", "prop", ",", "opts", ";", "ctx", ".", "save", "(", ")", ";", "ctx", ".", "lineWidth", "=", "(", "options", ".", "lineWidth", "||", "4", ")", "/", "(", "screen", ".", "scale", ".", "x", "-", "screen", ".", "scale", ".", "y", ")", ";", "// Don't try to draw the line at infinity", "if", "(", "line", ".", "type", "===", "'line'", "&&", "MathLib", ".", "isZero", "(", "line", "[", "0", "]", ")", "&&", "MathLib", ".", "isZero", "(", "line", "[", "1", "]", ")", ")", "{", "return", "this", ";", "}", "else", "{", "points", "=", "this", ".", "screen", ".", "getLineEndPoints", "(", "line", ")", ";", "}", "// Set the drawing options", "if", "(", "options", ")", "{", "opts", "=", "MathLib", ".", "Canvas", ".", "convertOptions", "(", "options", ")", ";", "for", "(", "prop", "in", "opts", ")", "{", "if", "(", "opts", ".", "hasOwnProperty", "(", "prop", ")", ")", "{", "ctx", "[", "prop", "]", "=", "opts", "[", "prop", "]", ";", "}", "}", "if", "(", "'setLineDash'", "in", "ctx", ")", "{", "ctx", ".", "setLineDash", "(", "(", "'dash'", "in", "options", "?", "options", ".", "dash", ":", "[", "]", ")", ")", ";", "}", "if", "(", "'lineDashOffset'", "in", "ctx", ")", "{", "ctx", ".", "lineDashOffset", "=", "(", "'dashOffset'", "in", "options", "?", "options", ".", "dashOffset", ":", "0", ")", ";", "}", "}", "// Draw the line", "ctx", ".", "beginPath", "(", ")", ";", "ctx", ".", "moveTo", "(", "points", "[", "0", "]", "[", "0", "]", ",", "points", "[", "0", "]", "[", "1", "]", ")", ";", "ctx", ".", "lineTo", "(", "points", "[", "1", "]", "[", "0", "]", ",", "points", "[", "1", "]", "[", "1", "]", ")", ";", "ctx", ".", "stroke", "(", ")", ";", "ctx", ".", "closePath", "(", ")", ";", "ctx", ".", "restore", "(", ")", ";", "if", "(", "!", "redraw", ")", "{", "this", ".", "stack", ".", "push", "(", "{", "type", ":", "'line'", ",", "object", ":", "line", ",", "options", ":", "options", "}", ")", ";", "}", "return", "this", ";", "}" ]
Draws a line on the screen. @param {Line} line The line to be drawn @param {drawingOptions} options Optional drawing options @param {boolean} redraw Indicates if the current draw call is happening during a redraw @return {Screen} Returns the screen
[ "Draws", "a", "line", "on", "the", "screen", "." ]
43dbd35263da672bd2ca41f93dc447b60da9bdac
https://github.com/alawatthe/MathLib/blob/43dbd35263da672bd2ca41f93dc447b60da9bdac/build/MathLib.js#L4358-L4407
41,505
alawatthe/MathLib
build/MathLib.js
function (x) { if (x.length === 2) { return new THREE.Vector2(x[0], x[1]); } else if (x.length === 3) { return new THREE.Vector3(x[0], x[1], x[2]); } }
javascript
function (x) { if (x.length === 2) { return new THREE.Vector2(x[0], x[1]); } else if (x.length === 3) { return new THREE.Vector3(x[0], x[1], x[2]); } }
[ "function", "(", "x", ")", "{", "if", "(", "x", ".", "length", "===", "2", ")", "{", "return", "new", "THREE", ".", "Vector2", "(", "x", "[", "0", "]", ",", "x", "[", "1", "]", ")", ";", "}", "else", "if", "(", "x", ".", "length", "===", "3", ")", "{", "return", "new", "THREE", ".", "Vector3", "(", "x", "[", "0", "]", ",", "x", "[", "1", "]", ",", "x", "[", "2", "]", ")", ";", "}", "}" ]
A function converting arrays to THREE.js vectors
[ "A", "function", "converting", "arrays", "to", "THREE", ".", "js", "vectors" ]
43dbd35263da672bd2ca41f93dc447b60da9bdac
https://github.com/alawatthe/MathLib/blob/43dbd35263da672bd2ca41f93dc447b60da9bdac/build/MathLib.js#L5912-L5918
41,506
bigeasy/udt
index.js
sooner
function sooner (property) { return function (a, b) { if (a[property][0] < b[property][0]) return true; if (a[property][0] > b[property][0]) return false; return a[property][1] < b[property][1]; } }
javascript
function sooner (property) { return function (a, b) { if (a[property][0] < b[property][0]) return true; if (a[property][0] > b[property][0]) return false; return a[property][1] < b[property][1]; } }
[ "function", "sooner", "(", "property", ")", "{", "return", "function", "(", "a", ",", "b", ")", "{", "if", "(", "a", "[", "property", "]", "[", "0", "]", "<", "b", "[", "property", "]", "[", "0", "]", ")", "return", "true", ";", "if", "(", "a", "[", "property", "]", "[", "0", "]", ">", "b", "[", "property", "]", "[", "0", "]", ")", "return", "false", ";", "return", "a", "[", "property", "]", "[", "1", "]", "<", "b", "[", "property", "]", "[", "1", "]", ";", "}", "}" ]
Comparison operator generator for high-resolution time for use with heap.
[ "Comparison", "operator", "generator", "for", "high", "-", "resolution", "time", "for", "use", "with", "heap", "." ]
54e8be61ba263a762cf7db5d4202fbd964c324f5
https://github.com/bigeasy/udt/blob/54e8be61ba263a762cf7db5d4202fbd964c324f5/index.js#L120-L126
41,507
bigeasy/udt
index.js
EndPoint
function EndPoint (local) { this.listeners = 0; this.dgram = dgram.createSocket('udp4'); this.dgram.on('message', EndPoint.prototype.receive.bind(this)); this.dgram.bind(local.port, local.address); this.local = this.dgram.address(); this.packet = new Buffer(2048); this.sockets = {}; }
javascript
function EndPoint (local) { this.listeners = 0; this.dgram = dgram.createSocket('udp4'); this.dgram.on('message', EndPoint.prototype.receive.bind(this)); this.dgram.bind(local.port, local.address); this.local = this.dgram.address(); this.packet = new Buffer(2048); this.sockets = {}; }
[ "function", "EndPoint", "(", "local", ")", "{", "this", ".", "listeners", "=", "0", ";", "this", ".", "dgram", "=", "dgram", ".", "createSocket", "(", "'udp4'", ")", ";", "this", ".", "dgram", ".", "on", "(", "'message'", ",", "EndPoint", ".", "prototype", ".", "receive", ".", "bind", "(", "this", ")", ")", ";", "this", ".", "dgram", ".", "bind", "(", "local", ".", "port", ",", "local", ".", "address", ")", ";", "this", ".", "local", "=", "this", ".", "dgram", ".", "address", "(", ")", ";", "this", ".", "packet", "=", "new", "Buffer", "(", "2048", ")", ";", "this", ".", "sockets", "=", "{", "}", ";", "}" ]
Wrapper around an underlying UDP datagram socket.
[ "Wrapper", "around", "an", "underlying", "UDP", "datagram", "socket", "." ]
54e8be61ba263a762cf7db5d4202fbd964c324f5
https://github.com/bigeasy/udt/blob/54e8be61ba263a762cf7db5d4202fbd964c324f5/index.js#L221-L229
41,508
bigeasy/udt
index.js
lookupEndPoint
function lookupEndPoint (local) { // No interfaces bound by the desired port. Note that this would also work for // zero, which indicates an ephemeral binding, but we check for that case // explicitly before calling this function. if (!endPoints[local.port]) return null; // Read datagram socket from cache. var endPoint = endPoints[local.port][local.address]; // If no datagram exists, ensure that we'll be able to create one. This only // inspects ports that have been bound by UDT, not by other protocols, so // there is still an opportunity for error when the UDP bind is invoked. if (!endPoint) { if (endPoints[local.port][0]) { throw new Error('Already bound to all interfaces.'); } if (local.address == 0) { throw new Error('Cannot bind to all interfaces because some interfaces are already bound.'); } } // Return cached datagram socket or nothing. return endPoint; }
javascript
function lookupEndPoint (local) { // No interfaces bound by the desired port. Note that this would also work for // zero, which indicates an ephemeral binding, but we check for that case // explicitly before calling this function. if (!endPoints[local.port]) return null; // Read datagram socket from cache. var endPoint = endPoints[local.port][local.address]; // If no datagram exists, ensure that we'll be able to create one. This only // inspects ports that have been bound by UDT, not by other protocols, so // there is still an opportunity for error when the UDP bind is invoked. if (!endPoint) { if (endPoints[local.port][0]) { throw new Error('Already bound to all interfaces.'); } if (local.address == 0) { throw new Error('Cannot bind to all interfaces because some interfaces are already bound.'); } } // Return cached datagram socket or nothing. return endPoint; }
[ "function", "lookupEndPoint", "(", "local", ")", "{", "// No interfaces bound by the desired port. Note that this would also work for", "// zero, which indicates an ephemeral binding, but we check for that case", "// explicitly before calling this function.", "if", "(", "!", "endPoints", "[", "local", ".", "port", "]", ")", "return", "null", ";", "// Read datagram socket from cache.", "var", "endPoint", "=", "endPoints", "[", "local", ".", "port", "]", "[", "local", ".", "address", "]", ";", "// If no datagram exists, ensure that we'll be able to create one. This only", "// inspects ports that have been bound by UDT, not by other protocols, so", "// there is still an opportunity for error when the UDP bind is invoked.", "if", "(", "!", "endPoint", ")", "{", "if", "(", "endPoints", "[", "local", ".", "port", "]", "[", "0", "]", ")", "{", "throw", "new", "Error", "(", "'Already bound to all interfaces.'", ")", ";", "}", "if", "(", "local", ".", "address", "==", "0", ")", "{", "throw", "new", "Error", "(", "'Cannot bind to all interfaces because some interfaces are already bound.'", ")", ";", "}", "}", "// Return cached datagram socket or nothing.", "return", "endPoint", ";", "}" ]
Look up an UDP datagram socket in the cache of bound UDP datagram sockets by the user specified port and address.
[ "Look", "up", "an", "UDP", "datagram", "socket", "in", "the", "cache", "of", "bound", "UDP", "datagram", "sockets", "by", "the", "user", "specified", "port", "and", "address", "." ]
54e8be61ba263a762cf7db5d4202fbd964c324f5
https://github.com/bigeasy/udt/blob/54e8be61ba263a762cf7db5d4202fbd964c324f5/index.js#L571-L594
41,509
bigeasy/udt
index.js
peerResolved
function peerResolved (ip, addressType) { // Possible cancelation during DNS lookup. if (!socket._connecting) return; socket._peer = { address: ip || '127.0.0.1', port: options.port }; // Generate random bytes used to set randomized socket properties. // `crypto.randomBytes` calls OpenSSL `RAND_bytes` to generate the bytes. // // * [RAND_bytes](http://www.openssl.org/docs/crypto/RAND_bytes.html). // * [node_crypto.cc](https://github.com/joyent/node/blob/v0.8/src/node_crypto.cc#L4517) crypto.randomBytes(4, valid(randomzied)); }
javascript
function peerResolved (ip, addressType) { // Possible cancelation during DNS lookup. if (!socket._connecting) return; socket._peer = { address: ip || '127.0.0.1', port: options.port }; // Generate random bytes used to set randomized socket properties. // `crypto.randomBytes` calls OpenSSL `RAND_bytes` to generate the bytes. // // * [RAND_bytes](http://www.openssl.org/docs/crypto/RAND_bytes.html). // * [node_crypto.cc](https://github.com/joyent/node/blob/v0.8/src/node_crypto.cc#L4517) crypto.randomBytes(4, valid(randomzied)); }
[ "function", "peerResolved", "(", "ip", ",", "addressType", ")", "{", "// Possible cancelation during DNS lookup.", "if", "(", "!", "socket", ".", "_connecting", ")", "return", ";", "socket", ".", "_peer", "=", "{", "address", ":", "ip", "||", "'127.0.0.1'", ",", "port", ":", "options", ".", "port", "}", ";", "// Generate random bytes used to set randomized socket properties.", "// `crypto.randomBytes` calls OpenSSL `RAND_bytes` to generate the bytes.", "//", "// * [RAND_bytes](http://www.openssl.org/docs/crypto/RAND_bytes.html).", "// * [node_crypto.cc](https://github.com/joyent/node/blob/v0.8/src/node_crypto.cc#L4517)", "crypto", ".", "randomBytes", "(", "4", ",", "valid", "(", "randomzied", ")", ")", ";", "}" ]
Record the DNS resolved IP address.
[ "Record", "the", "DNS", "resolved", "IP", "address", "." ]
54e8be61ba263a762cf7db5d4202fbd964c324f5
https://github.com/bigeasy/udt/blob/54e8be61ba263a762cf7db5d4202fbd964c324f5/index.js#L675-L687
41,510
bigeasy/udt
index.js
randomzied
function randomzied (buffer) { // Randomly generated randomness. socket._sequence = buffer.readUInt32BE(0) % MAX_SEQ_NO; // The end point sends a packet on our behalf. socket._endPoint.shakeHands(socket); }
javascript
function randomzied (buffer) { // Randomly generated randomness. socket._sequence = buffer.readUInt32BE(0) % MAX_SEQ_NO; // The end point sends a packet on our behalf. socket._endPoint.shakeHands(socket); }
[ "function", "randomzied", "(", "buffer", ")", "{", "// Randomly generated randomness.", "socket", ".", "_sequence", "=", "buffer", ".", "readUInt32BE", "(", "0", ")", "%", "MAX_SEQ_NO", ";", "// The end point sends a packet on our behalf.", "socket", ".", "_endPoint", ".", "shakeHands", "(", "socket", ")", ";", "}" ]
Initialize the randomized socket properies.
[ "Initialize", "the", "randomized", "socket", "properies", "." ]
54e8be61ba263a762cf7db5d4202fbd964c324f5
https://github.com/bigeasy/udt/blob/54e8be61ba263a762cf7db5d4202fbd964c324f5/index.js#L690-L696
41,511
fat/haunt
examples/comment-on-diff.js
findOnLine
function findOnLine(find, patch, cb) { if (find.test(patch)) { var lineNum = 0 patch.split('\n').forEach(function(line) { var range = /\@\@ \-\d+,\d+ \+(\d+),\d+ \@\@/g.exec(line) if (range) { lineNum = Number(range[1]) - 1 } else if (line.substr(0, 1) !== '-') { lineNum++ } if (find.test(line)) { return cb(null, lineNum) } }) } }
javascript
function findOnLine(find, patch, cb) { if (find.test(patch)) { var lineNum = 0 patch.split('\n').forEach(function(line) { var range = /\@\@ \-\d+,\d+ \+(\d+),\d+ \@\@/g.exec(line) if (range) { lineNum = Number(range[1]) - 1 } else if (line.substr(0, 1) !== '-') { lineNum++ } if (find.test(line)) { return cb(null, lineNum) } }) } }
[ "function", "findOnLine", "(", "find", ",", "patch", ",", "cb", ")", "{", "if", "(", "find", ".", "test", "(", "patch", ")", ")", "{", "var", "lineNum", "=", "0", "patch", ".", "split", "(", "'\\n'", ")", ".", "forEach", "(", "function", "(", "line", ")", "{", "var", "range", "=", "/", "\\@\\@ \\-\\d+,\\d+ \\+(\\d+),\\d+ \\@\\@", "/", "g", ".", "exec", "(", "line", ")", "if", "(", "range", ")", "{", "lineNum", "=", "Number", "(", "range", "[", "1", "]", ")", "-", "1", "}", "else", "if", "(", "line", ".", "substr", "(", "0", ",", "1", ")", "!==", "'-'", ")", "{", "lineNum", "++", "}", "if", "(", "find", ".", "test", "(", "line", ")", ")", "{", "return", "cb", "(", "null", ",", "lineNum", ")", "}", "}", ")", "}", "}" ]
find stuff in a diff and return the line number
[ "find", "stuff", "in", "a", "diff", "and", "return", "the", "line", "number" ]
e7a0f30032f0afec56652dc9ded06b29f0d61509
https://github.com/fat/haunt/blob/e7a0f30032f0afec56652dc9ded06b29f0d61509/examples/comment-on-diff.js#L28-L43
41,512
lithiumtech/karma-threshold-reporter
istanbul-utils.js
addDerivedInfoForFile
function addDerivedInfoForFile(fileCoverage) { var statementMap = fileCoverage.statementMap, statements = fileCoverage.s, lineMap; if (!fileCoverage.l) { fileCoverage.l = lineMap = {}; Object.keys(statements).forEach(function (st) { var line = statementMap[st].start.line, count = statements[st], prevVal = lineMap[line]; if (count === 0 && statementMap[st].skip) { count = 1; } if (typeof prevVal === 'undefined' || prevVal < count) { lineMap[line] = count; } }); } }
javascript
function addDerivedInfoForFile(fileCoverage) { var statementMap = fileCoverage.statementMap, statements = fileCoverage.s, lineMap; if (!fileCoverage.l) { fileCoverage.l = lineMap = {}; Object.keys(statements).forEach(function (st) { var line = statementMap[st].start.line, count = statements[st], prevVal = lineMap[line]; if (count === 0 && statementMap[st].skip) { count = 1; } if (typeof prevVal === 'undefined' || prevVal < count) { lineMap[line] = count; } }); } }
[ "function", "addDerivedInfoForFile", "(", "fileCoverage", ")", "{", "var", "statementMap", "=", "fileCoverage", ".", "statementMap", ",", "statements", "=", "fileCoverage", ".", "s", ",", "lineMap", ";", "if", "(", "!", "fileCoverage", ".", "l", ")", "{", "fileCoverage", ".", "l", "=", "lineMap", "=", "{", "}", ";", "Object", ".", "keys", "(", "statements", ")", ".", "forEach", "(", "function", "(", "st", ")", "{", "var", "line", "=", "statementMap", "[", "st", "]", ".", "start", ".", "line", ",", "count", "=", "statements", "[", "st", "]", ",", "prevVal", "=", "lineMap", "[", "line", "]", ";", "if", "(", "count", "===", "0", "&&", "statementMap", "[", "st", "]", ".", "skip", ")", "{", "count", "=", "1", ";", "}", "if", "(", "typeof", "prevVal", "===", "'undefined'", "||", "prevVal", "<", "count", ")", "{", "lineMap", "[", "line", "]", "=", "count", ";", "}", "}", ")", ";", "}", "}" ]
adds line coverage information to a file coverage object, reverse-engineering it from statement coverage. The object passed in is updated in place. Note that if line coverage information is already present in the object, it is not recomputed. @method addDerivedInfoForFile @static @param {Object} fileCoverage the coverage object for a single file
[ "adds", "line", "coverage", "information", "to", "a", "file", "coverage", "object", "reverse", "-", "engineering", "it", "from", "statement", "coverage", ".", "The", "object", "passed", "in", "is", "updated", "in", "place", "." ]
fe78c5227819ed1c58eeb5f6b776b64338ab2525
https://github.com/lithiumtech/karma-threshold-reporter/blob/fe78c5227819ed1c58eeb5f6b776b64338ab2525/istanbul-utils.js#L50-L67
41,513
lithiumtech/karma-threshold-reporter
istanbul-utils.js
addDerivedInfo
function addDerivedInfo(coverage) { Object.keys(coverage).forEach(function (k) { addDerivedInfoForFile(coverage[k]); }); }
javascript
function addDerivedInfo(coverage) { Object.keys(coverage).forEach(function (k) { addDerivedInfoForFile(coverage[k]); }); }
[ "function", "addDerivedInfo", "(", "coverage", ")", "{", "Object", ".", "keys", "(", "coverage", ")", ".", "forEach", "(", "function", "(", "k", ")", "{", "addDerivedInfoForFile", "(", "coverage", "[", "k", "]", ")", ";", "}", ")", ";", "}" ]
adds line coverage information to all file coverage objects. @method addDerivedInfo @static @param {Object} coverage the coverage object
[ "adds", "line", "coverage", "information", "to", "all", "file", "coverage", "objects", "." ]
fe78c5227819ed1c58eeb5f6b776b64338ab2525
https://github.com/lithiumtech/karma-threshold-reporter/blob/fe78c5227819ed1c58eeb5f6b776b64338ab2525/istanbul-utils.js#L75-L79
41,514
lithiumtech/karma-threshold-reporter
istanbul-utils.js
removeDerivedInfo
function removeDerivedInfo(coverage) { Object.keys(coverage).forEach(function (k) { delete coverage[k].l; }); }
javascript
function removeDerivedInfo(coverage) { Object.keys(coverage).forEach(function (k) { delete coverage[k].l; }); }
[ "function", "removeDerivedInfo", "(", "coverage", ")", "{", "Object", ".", "keys", "(", "coverage", ")", ".", "forEach", "(", "function", "(", "k", ")", "{", "delete", "coverage", "[", "k", "]", ".", "l", ";", "}", ")", ";", "}" ]
removes line coverage information from all file coverage objects @method removeDerivedInfo @static @param {Object} coverage the coverage object
[ "removes", "line", "coverage", "information", "from", "all", "file", "coverage", "objects" ]
fe78c5227819ed1c58eeb5f6b776b64338ab2525
https://github.com/lithiumtech/karma-threshold-reporter/blob/fe78c5227819ed1c58eeb5f6b776b64338ab2525/istanbul-utils.js#L86-L90
41,515
lithiumtech/karma-threshold-reporter
istanbul-utils.js
mergeSummaryObjects
function mergeSummaryObjects() { var ret = blankSummary(), args = Array.prototype.slice.call(arguments), keys = ['lines', 'statements', 'branches', 'functions'], increment = function (obj) { if (obj) { keys.forEach(function (key) { ret[key].total += obj[key].total; ret[key].covered += obj[key].covered; ret[key].skipped += obj[key].skipped; }); } }; args.forEach(function (arg) { increment(arg); }); keys.forEach(function (key) { ret[key].pct = percent(ret[key].covered, ret[key].total); }); return ret; }
javascript
function mergeSummaryObjects() { var ret = blankSummary(), args = Array.prototype.slice.call(arguments), keys = ['lines', 'statements', 'branches', 'functions'], increment = function (obj) { if (obj) { keys.forEach(function (key) { ret[key].total += obj[key].total; ret[key].covered += obj[key].covered; ret[key].skipped += obj[key].skipped; }); } }; args.forEach(function (arg) { increment(arg); }); keys.forEach(function (key) { ret[key].pct = percent(ret[key].covered, ret[key].total); }); return ret; }
[ "function", "mergeSummaryObjects", "(", ")", "{", "var", "ret", "=", "blankSummary", "(", ")", ",", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ")", ",", "keys", "=", "[", "'lines'", ",", "'statements'", ",", "'branches'", ",", "'functions'", "]", ",", "increment", "=", "function", "(", "obj", ")", "{", "if", "(", "obj", ")", "{", "keys", ".", "forEach", "(", "function", "(", "key", ")", "{", "ret", "[", "key", "]", ".", "total", "+=", "obj", "[", "key", "]", ".", "total", ";", "ret", "[", "key", "]", ".", "covered", "+=", "obj", "[", "key", "]", ".", "covered", ";", "ret", "[", "key", "]", ".", "skipped", "+=", "obj", "[", "key", "]", ".", "skipped", ";", "}", ")", ";", "}", "}", ";", "args", ".", "forEach", "(", "function", "(", "arg", ")", "{", "increment", "(", "arg", ")", ";", "}", ")", ";", "keys", ".", "forEach", "(", "function", "(", "key", ")", "{", "ret", "[", "key", "]", ".", "pct", "=", "percent", "(", "ret", "[", "key", "]", ".", "covered", ",", "ret", "[", "key", "]", ".", "total", ")", ";", "}", ")", ";", "return", "ret", ";", "}" ]
merges multiple summary metrics objects by summing up the `totals` and `covered` fields and recomputing the percentages. This function is generic and can accept any number of arguments. @method mergeSummaryObjects @static @param {Object} summary... multiple summary metrics objects @return {Object} the merged summary metrics
[ "merges", "multiple", "summary", "metrics", "objects", "by", "summing", "up", "the", "totals", "and", "covered", "fields", "and", "recomputing", "the", "percentages", ".", "This", "function", "is", "generic", "and", "can", "accept", "any", "number", "of", "arguments", "." ]
fe78c5227819ed1c58eeb5f6b776b64338ab2525
https://github.com/lithiumtech/karma-threshold-reporter/blob/fe78c5227819ed1c58eeb5f6b776b64338ab2525/istanbul-utils.js#L262-L283
41,516
lithiumtech/karma-threshold-reporter
istanbul-utils.js
summarizeCoverage
function summarizeCoverage(coverage) { var fileSummary = []; Object.keys(coverage).forEach(function (key) { fileSummary.push(summarizeFileCoverage(coverage[key])); }); return mergeSummaryObjects.apply(null, fileSummary); }
javascript
function summarizeCoverage(coverage) { var fileSummary = []; Object.keys(coverage).forEach(function (key) { fileSummary.push(summarizeFileCoverage(coverage[key])); }); return mergeSummaryObjects.apply(null, fileSummary); }
[ "function", "summarizeCoverage", "(", "coverage", ")", "{", "var", "fileSummary", "=", "[", "]", ";", "Object", ".", "keys", "(", "coverage", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "fileSummary", ".", "push", "(", "summarizeFileCoverage", "(", "coverage", "[", "key", "]", ")", ")", ";", "}", ")", ";", "return", "mergeSummaryObjects", ".", "apply", "(", "null", ",", "fileSummary", ")", ";", "}" ]
returns the coverage summary for a single coverage object. This is wrapper over `summarizeFileCoverage` and `mergeSummaryObjects` for the common case of a single coverage object @method summarizeCoverage @static @param {Object} coverage the coverage object @return {Object} summary coverage metrics across all files in the coverage object
[ "returns", "the", "coverage", "summary", "for", "a", "single", "coverage", "object", ".", "This", "is", "wrapper", "over", "summarizeFileCoverage", "and", "mergeSummaryObjects", "for", "the", "common", "case", "of", "a", "single", "coverage", "object" ]
fe78c5227819ed1c58eeb5f6b776b64338ab2525
https://github.com/lithiumtech/karma-threshold-reporter/blob/fe78c5227819ed1c58eeb5f6b776b64338ab2525/istanbul-utils.js#L293-L299
41,517
lithiumtech/karma-threshold-reporter
istanbul-utils.js
toYUICoverage
function toYUICoverage(coverage) { var ret = {}; addDerivedInfo(coverage); Object.keys(coverage).forEach(function (k) { var fileCoverage = coverage[k], lines = fileCoverage.l, functions = fileCoverage.f, fnMap = fileCoverage.fnMap, o; o = ret[k] = { lines: {}, calledLines: 0, coveredLines: 0, functions: {}, calledFunctions: 0, coveredFunctions: 0 }; Object.keys(lines).forEach(function (k) { o.lines[k] = lines[k]; o.coveredLines += 1; if (lines[k] > 0) { o.calledLines += 1; } }); Object.keys(functions).forEach(function (k) { var name = fnMap[k].name + ':' + fnMap[k].line; o.functions[name] = functions[k]; o.coveredFunctions += 1; if (functions[k] > 0) { o.calledFunctions += 1; } }); }); return ret; }
javascript
function toYUICoverage(coverage) { var ret = {}; addDerivedInfo(coverage); Object.keys(coverage).forEach(function (k) { var fileCoverage = coverage[k], lines = fileCoverage.l, functions = fileCoverage.f, fnMap = fileCoverage.fnMap, o; o = ret[k] = { lines: {}, calledLines: 0, coveredLines: 0, functions: {}, calledFunctions: 0, coveredFunctions: 0 }; Object.keys(lines).forEach(function (k) { o.lines[k] = lines[k]; o.coveredLines += 1; if (lines[k] > 0) { o.calledLines += 1; } }); Object.keys(functions).forEach(function (k) { var name = fnMap[k].name + ':' + fnMap[k].line; o.functions[name] = functions[k]; o.coveredFunctions += 1; if (functions[k] > 0) { o.calledFunctions += 1; } }); }); return ret; }
[ "function", "toYUICoverage", "(", "coverage", ")", "{", "var", "ret", "=", "{", "}", ";", "addDerivedInfo", "(", "coverage", ")", ";", "Object", ".", "keys", "(", "coverage", ")", ".", "forEach", "(", "function", "(", "k", ")", "{", "var", "fileCoverage", "=", "coverage", "[", "k", "]", ",", "lines", "=", "fileCoverage", ".", "l", ",", "functions", "=", "fileCoverage", ".", "f", ",", "fnMap", "=", "fileCoverage", ".", "fnMap", ",", "o", ";", "o", "=", "ret", "[", "k", "]", "=", "{", "lines", ":", "{", "}", ",", "calledLines", ":", "0", ",", "coveredLines", ":", "0", ",", "functions", ":", "{", "}", ",", "calledFunctions", ":", "0", ",", "coveredFunctions", ":", "0", "}", ";", "Object", ".", "keys", "(", "lines", ")", ".", "forEach", "(", "function", "(", "k", ")", "{", "o", ".", "lines", "[", "k", "]", "=", "lines", "[", "k", "]", ";", "o", ".", "coveredLines", "+=", "1", ";", "if", "(", "lines", "[", "k", "]", ">", "0", ")", "{", "o", ".", "calledLines", "+=", "1", ";", "}", "}", ")", ";", "Object", ".", "keys", "(", "functions", ")", ".", "forEach", "(", "function", "(", "k", ")", "{", "var", "name", "=", "fnMap", "[", "k", "]", ".", "name", "+", "':'", "+", "fnMap", "[", "k", "]", ".", "line", ";", "o", ".", "functions", "[", "name", "]", "=", "functions", "[", "k", "]", ";", "o", ".", "coveredFunctions", "+=", "1", ";", "if", "(", "functions", "[", "k", "]", ">", "0", ")", "{", "o", ".", "calledFunctions", "+=", "1", ";", "}", "}", ")", ";", "}", ")", ";", "return", "ret", ";", "}" ]
makes the coverage object generated by this library yuitest_coverage compatible. Note that this transformation is lossy since the returned object will not have statement and branch coverage. @method toYUICoverage @static @param {Object} coverage The `istanbul` coverage object @return {Object} a coverage object in `yuitest_coverage` format.
[ "makes", "the", "coverage", "object", "generated", "by", "this", "library", "yuitest_coverage", "compatible", ".", "Note", "that", "this", "transformation", "is", "lossy", "since", "the", "returned", "object", "will", "not", "have", "statement", "and", "branch", "coverage", "." ]
fe78c5227819ed1c58eeb5f6b776b64338ab2525
https://github.com/lithiumtech/karma-threshold-reporter/blob/fe78c5227819ed1c58eeb5f6b776b64338ab2525/istanbul-utils.js#L311-L348
41,518
scijs/nrrd-js
nrrd.js
parseField
function parseField(identifier, descriptor) { switch(identifier) { // Literal (uninterpreted) fields case 'content': case 'number': case 'sampleUnits': break; // Integers case 'dimension': case 'blockSize': case 'lineSkip': case 'byteSkip': case 'spaceDimension': descriptor = parseNRRDInteger(descriptor); break; // Floats case 'min': case 'max': case 'oldMin': case 'oldMax': descriptor = parseNRRDFloat(descriptor); break; // Vectors case 'spaceOrigin': descriptor = parseNRRDVector(descriptor); break; // Lists of strings case 'labels': case 'units': case 'spaceUnits': descriptor = parseNRRDWhitespaceSeparatedList(descriptor, parseNRRDQuotedString); break; // Lists of integers case 'sizes': descriptor = parseNRRDWhitespaceSeparatedList(descriptor, parseNRRDInteger); break; // Lists of floats case 'spacings': case 'thicknesses': case 'axisMins': case 'axisMaxs': descriptor = parseNRRDWhitespaceSeparatedList(descriptor, parseNRRDFloat); break; // Lists of vectors case 'spaceDirections': case 'measurementFrame': descriptor = parseNRRDWhitespaceSeparatedList(descriptor, parseNRRDVector); break; // One-of-a-kind fields case 'type': descriptor = parseNRRDType(descriptor); break; case 'encoding': descriptor = parseNRRDEncoding(descriptor); break; case 'endian': descriptor = parseNRRDEndian(descriptor); break; case 'dataFile': descriptor = parseNRRDDataFile(descriptor); break; case 'centers': descriptor = parseNRRDWhitespaceSeparatedList(descriptor, parseNRRDCenter); break; case 'kinds': descriptor = parseNRRDWhitespaceSeparatedList(descriptor, parseNRRDKind); break; case 'space': descriptor = parseNRRDSpace(descriptor); break; // Something unknown default: console.warn("Unrecognized NRRD field: " + identifier); } return descriptor; }
javascript
function parseField(identifier, descriptor) { switch(identifier) { // Literal (uninterpreted) fields case 'content': case 'number': case 'sampleUnits': break; // Integers case 'dimension': case 'blockSize': case 'lineSkip': case 'byteSkip': case 'spaceDimension': descriptor = parseNRRDInteger(descriptor); break; // Floats case 'min': case 'max': case 'oldMin': case 'oldMax': descriptor = parseNRRDFloat(descriptor); break; // Vectors case 'spaceOrigin': descriptor = parseNRRDVector(descriptor); break; // Lists of strings case 'labels': case 'units': case 'spaceUnits': descriptor = parseNRRDWhitespaceSeparatedList(descriptor, parseNRRDQuotedString); break; // Lists of integers case 'sizes': descriptor = parseNRRDWhitespaceSeparatedList(descriptor, parseNRRDInteger); break; // Lists of floats case 'spacings': case 'thicknesses': case 'axisMins': case 'axisMaxs': descriptor = parseNRRDWhitespaceSeparatedList(descriptor, parseNRRDFloat); break; // Lists of vectors case 'spaceDirections': case 'measurementFrame': descriptor = parseNRRDWhitespaceSeparatedList(descriptor, parseNRRDVector); break; // One-of-a-kind fields case 'type': descriptor = parseNRRDType(descriptor); break; case 'encoding': descriptor = parseNRRDEncoding(descriptor); break; case 'endian': descriptor = parseNRRDEndian(descriptor); break; case 'dataFile': descriptor = parseNRRDDataFile(descriptor); break; case 'centers': descriptor = parseNRRDWhitespaceSeparatedList(descriptor, parseNRRDCenter); break; case 'kinds': descriptor = parseNRRDWhitespaceSeparatedList(descriptor, parseNRRDKind); break; case 'space': descriptor = parseNRRDSpace(descriptor); break; // Something unknown default: console.warn("Unrecognized NRRD field: " + identifier); } return descriptor; }
[ "function", "parseField", "(", "identifier", ",", "descriptor", ")", "{", "switch", "(", "identifier", ")", "{", "// Literal (uninterpreted) fields", "case", "'content'", ":", "case", "'number'", ":", "case", "'sampleUnits'", ":", "break", ";", "// Integers", "case", "'dimension'", ":", "case", "'blockSize'", ":", "case", "'lineSkip'", ":", "case", "'byteSkip'", ":", "case", "'spaceDimension'", ":", "descriptor", "=", "parseNRRDInteger", "(", "descriptor", ")", ";", "break", ";", "// Floats", "case", "'min'", ":", "case", "'max'", ":", "case", "'oldMin'", ":", "case", "'oldMax'", ":", "descriptor", "=", "parseNRRDFloat", "(", "descriptor", ")", ";", "break", ";", "// Vectors", "case", "'spaceOrigin'", ":", "descriptor", "=", "parseNRRDVector", "(", "descriptor", ")", ";", "break", ";", "// Lists of strings", "case", "'labels'", ":", "case", "'units'", ":", "case", "'spaceUnits'", ":", "descriptor", "=", "parseNRRDWhitespaceSeparatedList", "(", "descriptor", ",", "parseNRRDQuotedString", ")", ";", "break", ";", "// Lists of integers", "case", "'sizes'", ":", "descriptor", "=", "parseNRRDWhitespaceSeparatedList", "(", "descriptor", ",", "parseNRRDInteger", ")", ";", "break", ";", "// Lists of floats", "case", "'spacings'", ":", "case", "'thicknesses'", ":", "case", "'axisMins'", ":", "case", "'axisMaxs'", ":", "descriptor", "=", "parseNRRDWhitespaceSeparatedList", "(", "descriptor", ",", "parseNRRDFloat", ")", ";", "break", ";", "// Lists of vectors", "case", "'spaceDirections'", ":", "case", "'measurementFrame'", ":", "descriptor", "=", "parseNRRDWhitespaceSeparatedList", "(", "descriptor", ",", "parseNRRDVector", ")", ";", "break", ";", "// One-of-a-kind fields", "case", "'type'", ":", "descriptor", "=", "parseNRRDType", "(", "descriptor", ")", ";", "break", ";", "case", "'encoding'", ":", "descriptor", "=", "parseNRRDEncoding", "(", "descriptor", ")", ";", "break", ";", "case", "'endian'", ":", "descriptor", "=", "parseNRRDEndian", "(", "descriptor", ")", ";", "break", ";", "case", "'dataFile'", ":", "descriptor", "=", "parseNRRDDataFile", "(", "descriptor", ")", ";", "break", ";", "case", "'centers'", ":", "descriptor", "=", "parseNRRDWhitespaceSeparatedList", "(", "descriptor", ",", "parseNRRDCenter", ")", ";", "break", ";", "case", "'kinds'", ":", "descriptor", "=", "parseNRRDWhitespaceSeparatedList", "(", "descriptor", ",", "parseNRRDKind", ")", ";", "break", ";", "case", "'space'", ":", "descriptor", "=", "parseNRRDSpace", "(", "descriptor", ")", ";", "break", ";", "// Something unknown", "default", ":", "console", ".", "warn", "(", "\"Unrecognized NRRD field: \"", "+", "identifier", ")", ";", "}", "return", "descriptor", ";", "}" ]
Parses and normalizes NRRD fields, assumes the field names are already lower case.
[ "Parses", "and", "normalizes", "NRRD", "fields", "assumes", "the", "field", "names", "are", "already", "lower", "case", "." ]
fc106cd9e911b6e8ab096cc61ece5dcb5ac69c40
https://github.com/scijs/nrrd-js/blob/fc106cd9e911b6e8ab096cc61ece5dcb5ac69c40/nrrd.js#L475-L550
41,519
wbyoung/azul
lib/relations/belongs_to.js
function(instance) { var result = this._related(instance); if (result === undefined) { throw new Error(util.format('The relation "%s" has not yet been ' + 'loaded.', this._name)); } return result; }
javascript
function(instance) { var result = this._related(instance); if (result === undefined) { throw new Error(util.format('The relation "%s" has not yet been ' + 'loaded.', this._name)); } return result; }
[ "function", "(", "instance", ")", "{", "var", "result", "=", "this", ".", "_related", "(", "instance", ")", ";", "if", "(", "result", "===", "undefined", ")", "{", "throw", "new", "Error", "(", "util", ".", "format", "(", "'The relation \"%s\" has not yet been '", "+", "'loaded.'", ",", "this", ".", "_name", ")", ")", ";", "}", "return", "result", ";", "}" ]
The item property for this relation. This property allows access to the cached object that has been fetched for a specific model in a given relation. Before the cache has been filled, accessing this property will throw an exception. It is accessible on an individual model via `<singular>` and via `get<Singular>`. For instance, an article that belongs to an author would cause this method to get triggered via `article.author` or `article.getAuthor`. The naming conventions are set forth in {@link BelongsTo#overrides}. @method @protected @param {Model} instance The model instance on which to operate. @see {@link BaseRelation#methods}
[ "The", "item", "property", "for", "this", "relation", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/belongs_to.js#L125-L132
41,520
wbyoung/azul
lib/relations/belongs_to.js
function(instance) { var cacheName = this._itemObjectsQueryCacheKey; if (!instance[cacheName]) { var where = _.object([ [this.primaryKey, instance.getAttribute(this.foreignKeyAttr)], ]); var cacheResult = _.bind(this.associateFetchedObjects, this, instance); instance[cacheName] = this._relatedModel .objects.where(where).limit(1) .on('result', cacheResult); } return instance[cacheName]; }
javascript
function(instance) { var cacheName = this._itemObjectsQueryCacheKey; if (!instance[cacheName]) { var where = _.object([ [this.primaryKey, instance.getAttribute(this.foreignKeyAttr)], ]); var cacheResult = _.bind(this.associateFetchedObjects, this, instance); instance[cacheName] = this._relatedModel .objects.where(where).limit(1) .on('result', cacheResult); } return instance[cacheName]; }
[ "function", "(", "instance", ")", "{", "var", "cacheName", "=", "this", ".", "_itemObjectsQueryCacheKey", ";", "if", "(", "!", "instance", "[", "cacheName", "]", ")", "{", "var", "where", "=", "_", ".", "object", "(", "[", "[", "this", ".", "primaryKey", ",", "instance", ".", "getAttribute", "(", "this", ".", "foreignKeyAttr", ")", "]", ",", "]", ")", ";", "var", "cacheResult", "=", "_", ".", "bind", "(", "this", ".", "associateFetchedObjects", ",", "this", ",", "instance", ")", ";", "instance", "[", "cacheName", "]", "=", "this", ".", "_relatedModel", ".", "objects", ".", "where", "(", "where", ")", ".", "limit", "(", "1", ")", ".", "on", "(", "'result'", ",", "cacheResult", ")", ";", "}", "return", "instance", "[", "cacheName", "]", ";", "}" ]
The objects query property for this relation. This property allows you access to a query which you can use to fetch the object for a relation on a given model and/or to configure the query to build a new query with more restrictive conditions. When you fetch the object, the result will be cached and accessible via the {@link BelongsTo#collection} (if loaded). The value of this property is a query object that is cached so it will always be the exact same query object (see exceptions below). This allows multiple fetches to simply return the query's cached result. A simple {@link BaseQuery#clone} of the query will ensure that it is always performing a new query in the database. The cache of this property will be invalided (and the resulting object a new query object) when changes are made to the relation. It is currently not accessible on an individual model. @method @protected @param {Model} instance The model instance on which to operate.
[ "The", "objects", "query", "property", "for", "this", "relation", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/belongs_to.js#L214-L226
41,521
wbyoung/azul
lib/relations/belongs_to.js
function(instance) { var self = this; var result = Promise.bind(); var fk = instance.getAttribute(this.foreignKeyAttr); if (fk) { result = result.then(function() { return self.objectsQuery(instance).execute(); }) .then(function(result) { self.validateFetchedObjects(instance, result); return result[0]; }); } else { result = result.then(function() { // pretend like we actually did the whole fetch & got back nothing self.associateFetchedObjects(instance, [null]); }); } return result; }
javascript
function(instance) { var self = this; var result = Promise.bind(); var fk = instance.getAttribute(this.foreignKeyAttr); if (fk) { result = result.then(function() { return self.objectsQuery(instance).execute(); }) .then(function(result) { self.validateFetchedObjects(instance, result); return result[0]; }); } else { result = result.then(function() { // pretend like we actually did the whole fetch & got back nothing self.associateFetchedObjects(instance, [null]); }); } return result; }
[ "function", "(", "instance", ")", "{", "var", "self", "=", "this", ";", "var", "result", "=", "Promise", ".", "bind", "(", ")", ";", "var", "fk", "=", "instance", ".", "getAttribute", "(", "this", ".", "foreignKeyAttr", ")", ";", "if", "(", "fk", ")", "{", "result", "=", "result", ".", "then", "(", "function", "(", ")", "{", "return", "self", ".", "objectsQuery", "(", "instance", ")", ".", "execute", "(", ")", ";", "}", ")", ".", "then", "(", "function", "(", "result", ")", "{", "self", ".", "validateFetchedObjects", "(", "instance", ",", "result", ")", ";", "return", "result", "[", "0", "]", ";", "}", ")", ";", "}", "else", "{", "result", "=", "result", ".", "then", "(", "function", "(", ")", "{", "// pretend like we actually did the whole fetch & got back nothing", "self", ".", "associateFetchedObjects", "(", "instance", ",", "[", "null", "]", ")", ";", "}", ")", ";", "}", "return", "result", ";", "}" ]
Fetch the related object. If there is no foreign key defined on the instance, this method will not actually query the database. @method @protected @param {Model} instance The model instance on which to operate. @see {@link BaseRelation#methods}
[ "Fetch", "the", "related", "object", ".", "If", "there", "is", "no", "foreign", "key", "defined", "on", "the", "instance", "this", "method", "will", "not", "actually", "query", "the", "database", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/belongs_to.js#L278-L298
41,522
wbyoung/azul
lib/relations/belongs_to.js
function(instance, objects) { var foreignKeyAttr = this.foreignKeyAttr; var fk = instance.getAttribute(foreignKeyAttr); if (fk && objects.length === 0) { var relatedModel = this._relatedModel; var relatedClass = relatedModel.__identity__; var relatedName = relatedClass.__name__; throw new Error(util.format('Found no %s with %j %d', relatedName, foreignKeyAttr, fk)); } }
javascript
function(instance, objects) { var foreignKeyAttr = this.foreignKeyAttr; var fk = instance.getAttribute(foreignKeyAttr); if (fk && objects.length === 0) { var relatedModel = this._relatedModel; var relatedClass = relatedModel.__identity__; var relatedName = relatedClass.__name__; throw new Error(util.format('Found no %s with %j %d', relatedName, foreignKeyAttr, fk)); } }
[ "function", "(", "instance", ",", "objects", ")", "{", "var", "foreignKeyAttr", "=", "this", ".", "foreignKeyAttr", ";", "var", "fk", "=", "instance", ".", "getAttribute", "(", "foreignKeyAttr", ")", ";", "if", "(", "fk", "&&", "objects", ".", "length", "===", "0", ")", "{", "var", "relatedModel", "=", "this", ".", "_relatedModel", ";", "var", "relatedClass", "=", "relatedModel", ".", "__identity__", ";", "var", "relatedName", "=", "relatedClass", ".", "__name__", ";", "throw", "new", "Error", "(", "util", ".", "format", "(", "'Found no %s with %j %d'", ",", "relatedName", ",", "foreignKeyAttr", ",", "fk", ")", ")", ";", "}", "}" ]
Validate fetched objects, ensuring that exactly one object was obtained when the foreign key is set. @method @protected @param {Model} instance The model instance on which to operate.
[ "Validate", "fetched", "objects", "ensuring", "that", "exactly", "one", "object", "was", "obtained", "when", "the", "foreign", "key", "is", "set", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/belongs_to.js#L308-L318
41,523
fat/haunt
lib/pull-request.js
attachCommentsToFile
function attachCommentsToFile(files, comments) { return files.filter(function(file) { return file.comments = comments.filter(function(comment) { if (file.filename === comment.path) { return comment.reply = attachCommentReply.call(this, comment); } }.bind(this)); }.bind(this)); }
javascript
function attachCommentsToFile(files, comments) { return files.filter(function(file) { return file.comments = comments.filter(function(comment) { if (file.filename === comment.path) { return comment.reply = attachCommentReply.call(this, comment); } }.bind(this)); }.bind(this)); }
[ "function", "attachCommentsToFile", "(", "files", ",", "comments", ")", "{", "return", "files", ".", "filter", "(", "function", "(", "file", ")", "{", "return", "file", ".", "comments", "=", "comments", ".", "filter", "(", "function", "(", "comment", ")", "{", "if", "(", "file", ".", "filename", "===", "comment", ".", "path", ")", "{", "return", "comment", ".", "reply", "=", "attachCommentReply", ".", "call", "(", "this", ",", "comment", ")", ";", "}", "}", ".", "bind", "(", "this", ")", ")", ";", "}", ".", "bind", "(", "this", ")", ")", ";", "}" ]
attach review comments to the related file
[ "attach", "review", "comments", "to", "the", "related", "file" ]
e7a0f30032f0afec56652dc9ded06b29f0d61509
https://github.com/fat/haunt/blob/e7a0f30032f0afec56652dc9ded06b29f0d61509/lib/pull-request.js#L108-L116
41,524
fat/haunt
lib/pull-request.js
attachCommentReply
function attachCommentReply(comment) { return function reply(body, callback) { github.replyToReviewComment(this.repo.data.owner.login, this.repo.data.name, this.data.number, comment.id, body, callback); }.bind(this); }
javascript
function attachCommentReply(comment) { return function reply(body, callback) { github.replyToReviewComment(this.repo.data.owner.login, this.repo.data.name, this.data.number, comment.id, body, callback); }.bind(this); }
[ "function", "attachCommentReply", "(", "comment", ")", "{", "return", "function", "reply", "(", "body", ",", "callback", ")", "{", "github", ".", "replyToReviewComment", "(", "this", ".", "repo", ".", "data", ".", "owner", ".", "login", ",", "this", ".", "repo", ".", "data", ".", "name", ",", "this", ".", "data", ".", "number", ",", "comment", ".", "id", ",", "body", ",", "callback", ")", ";", "}", ".", "bind", "(", "this", ")", ";", "}" ]
reply to a comment on a diff
[ "reply", "to", "a", "comment", "on", "a", "diff" ]
e7a0f30032f0afec56652dc9ded06b29f0d61509
https://github.com/fat/haunt/blob/e7a0f30032f0afec56652dc9ded06b29f0d61509/lib/pull-request.js#L119-L123
41,525
wbyoung/azul
lib/relations/has_many_through.js
function(message) { return override(function() { if (!this._isToMany) { var modelName = this._modelClass.__identity__.__name__; var relationName = this._name; throw new Error(util.format('%s for non many-to-many through relation ' + '%s#%s.', message, modelName, relationName)); } return this._super.apply(this, arguments); }); }
javascript
function(message) { return override(function() { if (!this._isToMany) { var modelName = this._modelClass.__identity__.__name__; var relationName = this._name; throw new Error(util.format('%s for non many-to-many through relation ' + '%s#%s.', message, modelName, relationName)); } return this._super.apply(this, arguments); }); }
[ "function", "(", "message", ")", "{", "return", "override", "(", "function", "(", ")", "{", "if", "(", "!", "this", ".", "_isToMany", ")", "{", "var", "modelName", "=", "this", ".", "_modelClass", ".", "__identity__", ".", "__name__", ";", "var", "relationName", "=", "this", ".", "_name", ";", "throw", "new", "Error", "(", "util", ".", "format", "(", "'%s for non many-to-many through relation '", "+", "'%s#%s.'", ",", "message", ",", "modelName", ",", "relationName", ")", ")", ";", "}", "return", "this", ".", "_super", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", ")", ";", "}" ]
A convenience function for creating a through-only method override that will throw an exception if this is not a through relation configured as a simple many-to-many. @function HasMany~manyToManyOnly @param {String} message The error message prefix. @return {Function} The method. @see {@link HasMany~throughOverride}
[ "A", "convenience", "function", "for", "creating", "a", "through", "-", "only", "method", "override", "that", "will", "throw", "an", "exception", "if", "this", "is", "not", "a", "through", "relation", "configured", "as", "a", "simple", "many", "-", "to", "-", "many", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/has_many_through.js#L38-L48
41,526
wbyoung/azul
lib/relations/has_many.js
function(name) { var before = 'before' + _.capitalize(name); var after = 'after' + _.capitalize(name); return function() { this[before].apply(this, arguments); this._super.apply(this, arguments); this[after].apply(this, arguments); }; }
javascript
function(name) { var before = 'before' + _.capitalize(name); var after = 'after' + _.capitalize(name); return function() { this[before].apply(this, arguments); this._super.apply(this, arguments); this[after].apply(this, arguments); }; }
[ "function", "(", "name", ")", "{", "var", "before", "=", "'before'", "+", "_", ".", "capitalize", "(", "name", ")", ";", "var", "after", "=", "'after'", "+", "_", ".", "capitalize", "(", "name", ")", ";", "return", "function", "(", ")", "{", "this", "[", "before", "]", ".", "apply", "(", "this", ",", "arguments", ")", ";", "this", ".", "_super", ".", "apply", "(", "this", ",", "arguments", ")", ";", "this", "[", "after", "]", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", ";", "}" ]
Notify of changes around a call to super. @function HasMany~notify @private @param {String} name The suffix of the before/after methods to call. @return {Function} A method that will call before & after methods.
[ "Notify", "of", "changes", "around", "a", "call", "to", "super", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/has_many.js#L77-L85
41,527
wbyoung/azul
lib/relations/has_many.js
function(instance) { var args = _.rest(arguments); var objects = _.flatten(args); this.beforeAddingObjects(instance, objects); this.associateObjects(instance, objects); return Actionable.create(instance.save.bind(instance)); }
javascript
function(instance) { var args = _.rest(arguments); var objects = _.flatten(args); this.beforeAddingObjects(instance, objects); this.associateObjects(instance, objects); return Actionable.create(instance.save.bind(instance)); }
[ "function", "(", "instance", ")", "{", "var", "args", "=", "_", ".", "rest", "(", "arguments", ")", ";", "var", "objects", "=", "_", ".", "flatten", "(", "args", ")", ";", "this", ".", "beforeAddingObjects", "(", "instance", ",", "objects", ")", ";", "this", ".", "associateObjects", "(", "instance", ",", "objects", ")", ";", "return", "Actionable", ".", "create", "(", "instance", ".", "save", ".", "bind", "(", "instance", ")", ")", ";", "}" ]
The add objects method for this relation. This method invalidates the {@link HasMany#objectsQuery} cache and adds the related objects to the {@link HasMany#collection} (if loaded). It is accessible on an individual model via `add<Singular>` and `add<Plural>`. For instance a user that has many articles would cause this method to get triggered via `user.addArticle` or `user.addArticles`. The naming conventions are set forth in {@link HasMany#overrides}. Mixins can override {@link HasMany#addObjects} to change the way related objects are added. This is the default implementation. @method @protected @param {Model} instance The model instance on which to operate. @param {...Object} [args] The arguments to the method. @return {Actionable} A thenable object, use of which will trigger the instance to be saved. @see {@link BaseRelation#methods}
[ "The", "add", "objects", "method", "for", "this", "relation", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/has_many.js#L147-L153
41,528
wbyoung/azul
lib/relations/has_many.js
function(instance, objects) { var self = this; var after = this.afterAddingObjects.bind(this, instance, objects); return self._updateForeignKeys(instance, objects, instance.id).tap(after); }
javascript
function(instance, objects) { var self = this; var after = this.afterAddingObjects.bind(this, instance, objects); return self._updateForeignKeys(instance, objects, instance.id).tap(after); }
[ "function", "(", "instance", ",", "objects", ")", "{", "var", "self", "=", "this", ";", "var", "after", "=", "this", ".", "afterAddingObjects", ".", "bind", "(", "this", ",", "instance", ",", "objects", ")", ";", "return", "self", ".", "_updateForeignKeys", "(", "instance", ",", "objects", ",", "instance", ".", "id", ")", ".", "tap", "(", "after", ")", ";", "}" ]
Perform the necessary updates to add objects for this relation. This method invalidates the {@link HasMany#objectsQuery}. Mixins can override {@link HasMany#executeAdd} to change the way updates are performed when related objects are added. This is the default implementation. @method @protected @param {Model} instance The model instance on which to operate. @param {Array} objects The objects to add to the relationship.
[ "Perform", "the", "necessary", "updates", "to", "add", "objects", "for", "this", "relation", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/has_many.js#L169-L173
41,529
wbyoung/azul
lib/relations/has_many.js
function(instance) { var args = _.rest(arguments); var objects = _.flatten(args); this.beforeRemovingObjects(instance, objects); this.disassociateObjects(instance, objects); return Actionable.create(instance.save.bind(instance)); }
javascript
function(instance) { var args = _.rest(arguments); var objects = _.flatten(args); this.beforeRemovingObjects(instance, objects); this.disassociateObjects(instance, objects); return Actionable.create(instance.save.bind(instance)); }
[ "function", "(", "instance", ")", "{", "var", "args", "=", "_", ".", "rest", "(", "arguments", ")", ";", "var", "objects", "=", "_", ".", "flatten", "(", "args", ")", ";", "this", ".", "beforeRemovingObjects", "(", "instance", ",", "objects", ")", ";", "this", ".", "disassociateObjects", "(", "instance", ",", "objects", ")", ";", "return", "Actionable", ".", "create", "(", "instance", ".", "save", ".", "bind", "(", "instance", ")", ")", ";", "}" ]
The remove objects method for this relation. This method invalidates the {@link HasMany#objectsQuery} cache and removes the related objects from the {@link HasMany#collection} (if loaded). It is accessible on an individual model via `remove<Singular>` and `remove<Plural>`. For instance a user that has many articles would cause this method to get triggered via `user.removeArticle` or `user.removeArticles`. The naming conventions are set forth in {@link HasMany#overrides}. Mixins can override {@link HasMany#removeObjects} to change the way related objects are removed. This is the default implementation. @method @protected @param {Model} instance The model instance on which to operate. @param {...Object} [args] The arguments to the method. @return {Actionable} A thenable object, use of which will trigger the instance to be saved. @see {@link BaseRelation#methods}
[ "The", "remove", "objects", "method", "for", "this", "relation", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/has_many.js#L199-L205
41,530
wbyoung/azul
lib/relations/has_many.js
function(instance, objects) { var self = this; var after = this.afterRemovingObjects.bind(this, instance, objects); var removable = _.filter(objects, 'persisted'); return self._updateForeignKeys(instance, removable, undefined).tap(after); }
javascript
function(instance, objects) { var self = this; var after = this.afterRemovingObjects.bind(this, instance, objects); var removable = _.filter(objects, 'persisted'); return self._updateForeignKeys(instance, removable, undefined).tap(after); }
[ "function", "(", "instance", ",", "objects", ")", "{", "var", "self", "=", "this", ";", "var", "after", "=", "this", ".", "afterRemovingObjects", ".", "bind", "(", "this", ",", "instance", ",", "objects", ")", ";", "var", "removable", "=", "_", ".", "filter", "(", "objects", ",", "'persisted'", ")", ";", "return", "self", ".", "_updateForeignKeys", "(", "instance", ",", "removable", ",", "undefined", ")", ".", "tap", "(", "after", ")", ";", "}" ]
Perform the necessary updates to remove objects for this relation. This method invalidates the {@link HasMany#objectsQuery}. Mixins can override {@link HasMany#executeRemove} to change the way updates are performed when related objects are removed. This is the default implementation. @method @protected @param {Model} instance The model instance on which to operate. @param {Array} objects The objects to remove from the relationship.
[ "Perform", "the", "necessary", "updates", "to", "remove", "objects", "for", "this", "relation", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/has_many.js#L221-L226
41,531
wbyoung/azul
lib/relations/has_many.js
function(instance) { var updates = _.object([[this.foreignKey, undefined]]); var query = this.objectsQuery(instance).update(updates); var after = this.afterClearingObjects.bind(this, instance); return query.execute().tap(after); }
javascript
function(instance) { var updates = _.object([[this.foreignKey, undefined]]); var query = this.objectsQuery(instance).update(updates); var after = this.afterClearingObjects.bind(this, instance); return query.execute().tap(after); }
[ "function", "(", "instance", ")", "{", "var", "updates", "=", "_", ".", "object", "(", "[", "[", "this", ".", "foreignKey", ",", "undefined", "]", "]", ")", ";", "var", "query", "=", "this", ".", "objectsQuery", "(", "instance", ")", ".", "update", "(", "updates", ")", ";", "var", "after", "=", "this", ".", "afterClearingObjects", ".", "bind", "(", "this", ",", "instance", ")", ";", "return", "query", ".", "execute", "(", ")", ".", "tap", "(", "after", ")", ";", "}" ]
Perform the necessary updates to clear objects for this relation. This method invalidates the {@link HasMany#objectsQuery}. Mixins can override {@link HasMany#executeClear} to change the way clears are performed when related objects are cleared. This is the default implementation. @method @protected @param {Model} instance The model instance on which to operate.
[ "Perform", "the", "necessary", "updates", "to", "clear", "objects", "for", "this", "relation", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/has_many.js#L268-L273
41,532
wbyoung/azul
lib/query/mixins/bound_helpers.js
function(association, name) { var context = this._relationCallContext; var through = association.indexOf('.') !== -1 ? util.format(' through %s', association) : ''; return _.extend(new Error(util.format( 'No relation %j found for `%s` on %s query%s.', name, context, this._model.__identity__.__name__, through)), { code: 'RELATION_ITERATION_FAILURE', }); }
javascript
function(association, name) { var context = this._relationCallContext; var through = association.indexOf('.') !== -1 ? util.format(' through %s', association) : ''; return _.extend(new Error(util.format( 'No relation %j found for `%s` on %s query%s.', name, context, this._model.__identity__.__name__, through)), { code: 'RELATION_ITERATION_FAILURE', }); }
[ "function", "(", "association", ",", "name", ")", "{", "var", "context", "=", "this", ".", "_relationCallContext", ";", "var", "through", "=", "association", ".", "indexOf", "(", "'.'", ")", "!==", "-", "1", "?", "util", ".", "format", "(", "' through %s'", ",", "association", ")", ":", "''", ";", "return", "_", ".", "extend", "(", "new", "Error", "(", "util", ".", "format", "(", "'No relation %j found for `%s` on %s query%s.'", ",", "name", ",", "context", ",", "this", ".", "_model", ".", "__identity__", ".", "__name__", ",", "through", ")", ")", ",", "{", "code", ":", "'RELATION_ITERATION_FAILURE'", ",", "}", ")", ";", "}" ]
Create an error for a missing relation during relation iteration. @param {String} association Relation key path. @param {String} name The name that caused the error. @return {Error} The error object.
[ "Create", "an", "error", "for", "a", "missing", "relation", "during", "relation", "iteration", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/query/mixins/bound_helpers.js#L94-L104
41,533
wbyoung/azul
lib/query/mixins/bound_core.js
function(orig) { this._super(orig); this._priorModel = orig._priorModel; this._model = orig._model; this._modelTable = orig._modelTable; this._arrayTransform = orig._arrayTransform; this._modelTransform = orig._modelTransform; }
javascript
function(orig) { this._super(orig); this._priorModel = orig._priorModel; this._model = orig._model; this._modelTable = orig._modelTable; this._arrayTransform = orig._arrayTransform; this._modelTransform = orig._modelTransform; }
[ "function", "(", "orig", ")", "{", "this", ".", "_super", "(", "orig", ")", ";", "this", ".", "_priorModel", "=", "orig", ".", "_priorModel", ";", "this", ".", "_model", "=", "orig", ".", "_model", ";", "this", ".", "_modelTable", "=", "orig", ".", "_modelTable", ";", "this", ".", "_arrayTransform", "=", "orig", ".", "_arrayTransform", ";", "this", ".", "_modelTransform", "=", "orig", ".", "_modelTransform", ";", "}" ]
Duplication implementation. @method @protected @see {@link BaseQuery#_take}
[ "Duplication", "implementation", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/query/mixins/bound_core.js#L20-L27
41,534
wbyoung/azul
lib/query/mixins/bound_core.js
function() { var model = this._model; var arrayTransform = function(result) { // jscs:ignore jsDoc return result.rows; }; var modelTransform = function(rows) { // jscs:ignore jsDoc return rows.map(model.load.bind(model)); }; var dup = this._dup() .transform(arrayTransform) .transform(modelTransform); dup._arrayTransform = arrayTransform; dup._modelTransform = modelTransform; return dup; }
javascript
function() { var model = this._model; var arrayTransform = function(result) { // jscs:ignore jsDoc return result.rows; }; var modelTransform = function(rows) { // jscs:ignore jsDoc return rows.map(model.load.bind(model)); }; var dup = this._dup() .transform(arrayTransform) .transform(modelTransform); dup._arrayTransform = arrayTransform; dup._modelTransform = modelTransform; return dup; }
[ "function", "(", ")", "{", "var", "model", "=", "this", ".", "_model", ";", "var", "arrayTransform", "=", "function", "(", "result", ")", "{", "// jscs:ignore jsDoc", "return", "result", ".", "rows", ";", "}", ";", "var", "modelTransform", "=", "function", "(", "rows", ")", "{", "// jscs:ignore jsDoc", "return", "rows", ".", "map", "(", "model", ".", "load", ".", "bind", "(", "model", ")", ")", ";", "}", ";", "var", "dup", "=", "this", ".", "_dup", "(", ")", ".", "transform", "(", "arrayTransform", ")", ".", "transform", "(", "modelTransform", ")", ";", "dup", ".", "_arrayTransform", "=", "arrayTransform", ";", "dup", ".", "_modelTransform", "=", "modelTransform", ";", "return", "dup", ";", "}" ]
Enable automatic conversion of the query results to model instances. @method @public @return {ChainedQuery} The newly configured query.
[ "Enable", "automatic", "conversion", "of", "the", "query", "results", "to", "model", "instances", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/query/mixins/bound_core.js#L36-L53
41,535
wbyoung/azul
lib/query/mixins/bound_core.js
function() { var dup = this._dup(); dup = dup.transform(dup._modelTransform); dup._model = dup._priorModel; dup._priorModel = undefined; return dup; }
javascript
function() { var dup = this._dup(); dup = dup.transform(dup._modelTransform); dup._model = dup._priorModel; dup._priorModel = undefined; return dup; }
[ "function", "(", ")", "{", "var", "dup", "=", "this", ".", "_dup", "(", ")", ";", "dup", "=", "dup", ".", "transform", "(", "dup", ".", "_modelTransform", ")", ";", "dup", ".", "_model", "=", "dup", ".", "_priorModel", ";", "dup", ".", "_priorModel", "=", "undefined", ";", "return", "dup", ";", "}" ]
Reverse the effects of an unbind. @method @public @return {ChainedQuery} The newly configured query.
[ "Reverse", "the", "effects", "of", "an", "unbind", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/query/mixins/bound_core.js#L81-L87
41,536
wbyoung/azul
lib/cli/actions.js
function(action, azulfile, options, strings) { var db = Database.create(azulfile[env]); var migrator = db.migrator(path.resolve(options.migrations)); var message = ''; var batches = ''; return migrator[action]() .tap(function(migrations) { batches = _(migrations).pluck('batch').unique().join(', '); }) .then(function(migrations) { message += migrations.length ? chalk.magenta(strings.intro, 'migrations, batch', batches, '\n') : chalk.magenta(strings.none, '\n'); migrations.forEach(function(migration) { message += chalk.cyan(migration.name, '\n'); }); message += chalk.gray(_.capitalize(env), 'environment\n'); process.stdout.write(message); }) .catch(function(e) { message += chalk.red(strings.action, 'failed.', e); process.stderr.write(message); process.exit(1); }) .finally(function() { db.disconnect(); }); }
javascript
function(action, azulfile, options, strings) { var db = Database.create(azulfile[env]); var migrator = db.migrator(path.resolve(options.migrations)); var message = ''; var batches = ''; return migrator[action]() .tap(function(migrations) { batches = _(migrations).pluck('batch').unique().join(', '); }) .then(function(migrations) { message += migrations.length ? chalk.magenta(strings.intro, 'migrations, batch', batches, '\n') : chalk.magenta(strings.none, '\n'); migrations.forEach(function(migration) { message += chalk.cyan(migration.name, '\n'); }); message += chalk.gray(_.capitalize(env), 'environment\n'); process.stdout.write(message); }) .catch(function(e) { message += chalk.red(strings.action, 'failed.', e); process.stderr.write(message); process.exit(1); }) .finally(function() { db.disconnect(); }); }
[ "function", "(", "action", ",", "azulfile", ",", "options", ",", "strings", ")", "{", "var", "db", "=", "Database", ".", "create", "(", "azulfile", "[", "env", "]", ")", ";", "var", "migrator", "=", "db", ".", "migrator", "(", "path", ".", "resolve", "(", "options", ".", "migrations", ")", ")", ";", "var", "message", "=", "''", ";", "var", "batches", "=", "''", ";", "return", "migrator", "[", "action", "]", "(", ")", ".", "tap", "(", "function", "(", "migrations", ")", "{", "batches", "=", "_", "(", "migrations", ")", ".", "pluck", "(", "'batch'", ")", ".", "unique", "(", ")", ".", "join", "(", "', '", ")", ";", "}", ")", ".", "then", "(", "function", "(", "migrations", ")", "{", "message", "+=", "migrations", ".", "length", "?", "chalk", ".", "magenta", "(", "strings", ".", "intro", ",", "'migrations, batch'", ",", "batches", ",", "'\\n'", ")", ":", "chalk", ".", "magenta", "(", "strings", ".", "none", ",", "'\\n'", ")", ";", "migrations", ".", "forEach", "(", "function", "(", "migration", ")", "{", "message", "+=", "chalk", ".", "cyan", "(", "migration", ".", "name", ",", "'\\n'", ")", ";", "}", ")", ";", "message", "+=", "chalk", ".", "gray", "(", "_", ".", "capitalize", "(", "env", ")", ",", "'environment\\n'", ")", ";", "process", ".", "stdout", ".", "write", "(", "message", ")", ";", "}", ")", ".", "catch", "(", "function", "(", "e", ")", "{", "message", "+=", "chalk", ".", "red", "(", "strings", ".", "action", ",", "'failed.'", ",", "e", ")", ";", "process", ".", "stderr", ".", "write", "(", "message", ")", ";", "process", ".", "exit", "(", "1", ")", ";", "}", ")", ".", "finally", "(", "function", "(", ")", "{", "db", ".", "disconnect", "(", ")", ";", "}", ")", ";", "}" ]
Run the migrator. @private @function runMigrator @param {String} action Either `migrate` or `rollback`. @param {Object} azulfile Configuration object. @param {Object} options @param {String} options.migrations @param {Object} strings The output format strings to use. @return {Promise}
[ "Run", "the", "migrator", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/cli/actions.js#L23-L49
41,537
Synerzip/loopback-connector-sqlite
lib/sqlite3db.js
function(sqlite3, dbSettings) { if (!(this instanceof SQLiteDB)) { return new SQLiteDB(sqlite3, dbSettings); } this.constructor.super_.call(this, NAME, dbSettings); this.name = NAME; this.settings = dbSettings; this.sqlite3 = sqlite3; this.debug = dbSettings.debug; this.current_order = []; this.file_name = dbSettings.file_name; if (this.debug) { debug('Settings %j', dbSettings); } }
javascript
function(sqlite3, dbSettings) { if (!(this instanceof SQLiteDB)) { return new SQLiteDB(sqlite3, dbSettings); } this.constructor.super_.call(this, NAME, dbSettings); this.name = NAME; this.settings = dbSettings; this.sqlite3 = sqlite3; this.debug = dbSettings.debug; this.current_order = []; this.file_name = dbSettings.file_name; if (this.debug) { debug('Settings %j', dbSettings); } }
[ "function", "(", "sqlite3", ",", "dbSettings", ")", "{", "if", "(", "!", "(", "this", "instanceof", "SQLiteDB", ")", ")", "{", "return", "new", "SQLiteDB", "(", "sqlite3", ",", "dbSettings", ")", ";", "}", "this", ".", "constructor", ".", "super_", ".", "call", "(", "this", ",", "NAME", ",", "dbSettings", ")", ";", "this", ".", "name", "=", "NAME", ";", "this", ".", "settings", "=", "dbSettings", ";", "this", ".", "sqlite3", "=", "sqlite3", ";", "this", ".", "debug", "=", "dbSettings", ".", "debug", ";", "this", ".", "current_order", "=", "[", "]", ";", "this", ".", "file_name", "=", "dbSettings", ".", "file_name", ";", "if", "(", "this", ".", "debug", ")", "{", "debug", "(", "'Settings %j'", ",", "dbSettings", ")", ";", "}", "}" ]
Constructor for SQLite connector @param {Object} settings The settings object @param {DataSource} dataSource The data source instance @constructor
[ "Constructor", "for", "SQLite", "connector" ]
78b8ffb50396311565e93d17b2f0686ec2326190
https://github.com/Synerzip/loopback-connector-sqlite/blob/78b8ffb50396311565e93d17b2f0686ec2326190/lib/sqlite3db.js#L45-L62
41,538
pulseshift/ui5-cache-buster
index.js
_getUi5AppHash
function _getUi5AppHash(sResolvedModulePath, sPreloadPath, oOptions) { // read relevant resources for hash generation const oPreloadFileContent = fs.readFileSync(sPreloadPath, 'utf8') // some resources will be requested additionally to 'Component-preload.js' // fortunately they 'should' be listed in manifest.json, therefore, we will look them up there const sManifestPath = path.resolve(sResolvedModulePath, 'manifest.json') const oManifestFileContent = fs.existsSync(sManifestPath) ? fs.readFileSync(sManifestPath, 'utf8') : null const oManifestJSON = oManifestFileContent ? JSON.parse(oManifestFileContent) : { 'sap.ui5': {} } const aResourceKeys = oManifestJSON['sap.ui5'].resources ? Object.keys(oManifestJSON['sap.ui5'].resources) : [] const aDependedResourceContents = aResourceKeys.reduce( (aContentsList, sResourceKey) => { return aContentsList.concat( oManifestJSON['sap.ui5'].resources[sResourceKey].map(oResource => fs.readFileSync( path.resolve(sResolvedModulePath, oResource.uri), 'utf8' ) ) ) }, [] ) // generate hash based on resource contents of the app const aBufferList = aDependedResourceContents .concat(oPreloadFileContent ? oPreloadFileContent : []) .map(oContent => new Buffer(oContent)) const sNewHash = _createHash(aBufferList, oOptions) return sNewHash }
javascript
function _getUi5AppHash(sResolvedModulePath, sPreloadPath, oOptions) { // read relevant resources for hash generation const oPreloadFileContent = fs.readFileSync(sPreloadPath, 'utf8') // some resources will be requested additionally to 'Component-preload.js' // fortunately they 'should' be listed in manifest.json, therefore, we will look them up there const sManifestPath = path.resolve(sResolvedModulePath, 'manifest.json') const oManifestFileContent = fs.existsSync(sManifestPath) ? fs.readFileSync(sManifestPath, 'utf8') : null const oManifestJSON = oManifestFileContent ? JSON.parse(oManifestFileContent) : { 'sap.ui5': {} } const aResourceKeys = oManifestJSON['sap.ui5'].resources ? Object.keys(oManifestJSON['sap.ui5'].resources) : [] const aDependedResourceContents = aResourceKeys.reduce( (aContentsList, sResourceKey) => { return aContentsList.concat( oManifestJSON['sap.ui5'].resources[sResourceKey].map(oResource => fs.readFileSync( path.resolve(sResolvedModulePath, oResource.uri), 'utf8' ) ) ) }, [] ) // generate hash based on resource contents of the app const aBufferList = aDependedResourceContents .concat(oPreloadFileContent ? oPreloadFileContent : []) .map(oContent => new Buffer(oContent)) const sNewHash = _createHash(aBufferList, oOptions) return sNewHash }
[ "function", "_getUi5AppHash", "(", "sResolvedModulePath", ",", "sPreloadPath", ",", "oOptions", ")", "{", "// read relevant resources for hash generation", "const", "oPreloadFileContent", "=", "fs", ".", "readFileSync", "(", "sPreloadPath", ",", "'utf8'", ")", "// some resources will be requested additionally to 'Component-preload.js'", "// fortunately they 'should' be listed in manifest.json, therefore, we will look them up there", "const", "sManifestPath", "=", "path", ".", "resolve", "(", "sResolvedModulePath", ",", "'manifest.json'", ")", "const", "oManifestFileContent", "=", "fs", ".", "existsSync", "(", "sManifestPath", ")", "?", "fs", ".", "readFileSync", "(", "sManifestPath", ",", "'utf8'", ")", ":", "null", "const", "oManifestJSON", "=", "oManifestFileContent", "?", "JSON", ".", "parse", "(", "oManifestFileContent", ")", ":", "{", "'sap.ui5'", ":", "{", "}", "}", "const", "aResourceKeys", "=", "oManifestJSON", "[", "'sap.ui5'", "]", ".", "resources", "?", "Object", ".", "keys", "(", "oManifestJSON", "[", "'sap.ui5'", "]", ".", "resources", ")", ":", "[", "]", "const", "aDependedResourceContents", "=", "aResourceKeys", ".", "reduce", "(", "(", "aContentsList", ",", "sResourceKey", ")", "=>", "{", "return", "aContentsList", ".", "concat", "(", "oManifestJSON", "[", "'sap.ui5'", "]", ".", "resources", "[", "sResourceKey", "]", ".", "map", "(", "oResource", "=>", "fs", ".", "readFileSync", "(", "path", ".", "resolve", "(", "sResolvedModulePath", ",", "oResource", ".", "uri", ")", ",", "'utf8'", ")", ")", ")", "}", ",", "[", "]", ")", "// generate hash based on resource contents of the app", "const", "aBufferList", "=", "aDependedResourceContents", ".", "concat", "(", "oPreloadFileContent", "?", "oPreloadFileContent", ":", "[", "]", ")", ".", "map", "(", "oContent", "=>", "new", "Buffer", "(", "oContent", ")", ")", "const", "sNewHash", "=", "_createHash", "(", "aBufferList", ",", "oOptions", ")", "return", "sNewHash", "}" ]
Generate hash for UI5 app component. @param {string} [sResolvedModulePath] Module path. @param {string} [sPreloadPath] Path to Component-preload.js. @param {Object} [oOptions] Cach buster options. @param {Object} [oOptions.hash] Hash generation options. @param {string} [oOptions.HASH_TYPE] Hash type. @param {string} [oOptions.DIGEST_TYPE] Digest type. @param {number} [oOptions.MAX_LENGTH] Maximum hash length. @returns {string|null} Generated hash.
[ "Generate", "hash", "for", "UI5", "app", "component", "." ]
55147d25bed7754fee2de69269f78c61079e1167
https://github.com/pulseshift/ui5-cache-buster/blob/55147d25bed7754fee2de69269f78c61079e1167/index.js#L269-L306
41,539
pulseshift/ui5-cache-buster
index.js
_getUi5LibHash
function _getUi5LibHash(sResolvedModulePath, sLibPreloadPath, oOptions) { // read relevant resources for hash generation const oLibPreloadFileContent = fs.readFileSync(sLibPreloadPath, 'utf8') // generate hash based on resource contents of the library const aBufferList = [oLibPreloadFileContent].map( oContent => new Buffer(oContent) ) const sNewHash = _createHash(aBufferList, oOptions) return sNewHash }
javascript
function _getUi5LibHash(sResolvedModulePath, sLibPreloadPath, oOptions) { // read relevant resources for hash generation const oLibPreloadFileContent = fs.readFileSync(sLibPreloadPath, 'utf8') // generate hash based on resource contents of the library const aBufferList = [oLibPreloadFileContent].map( oContent => new Buffer(oContent) ) const sNewHash = _createHash(aBufferList, oOptions) return sNewHash }
[ "function", "_getUi5LibHash", "(", "sResolvedModulePath", ",", "sLibPreloadPath", ",", "oOptions", ")", "{", "// read relevant resources for hash generation", "const", "oLibPreloadFileContent", "=", "fs", ".", "readFileSync", "(", "sLibPreloadPath", ",", "'utf8'", ")", "// generate hash based on resource contents of the library", "const", "aBufferList", "=", "[", "oLibPreloadFileContent", "]", ".", "map", "(", "oContent", "=>", "new", "Buffer", "(", "oContent", ")", ")", "const", "sNewHash", "=", "_createHash", "(", "aBufferList", ",", "oOptions", ")", "return", "sNewHash", "}" ]
Generate hash for UI5 control library. @param {string} [sResolvedModulePath] Module path. @param {string} [sLibPreloadPath] Path to library-preload.js. @param {Object} [oOptions] Cach buster options. @param {Object} [oOptions.hash] Hash generation options. @param {string} [oOptions.HASH_TYPE] Hash type. @param {string} [oOptions.DIGEST_TYPE] Digest type. @param {number} [oOptions.MAX_LENGTH] Maximum hash length. @returns {string|null} Generated hash.
[ "Generate", "hash", "for", "UI5", "control", "library", "." ]
55147d25bed7754fee2de69269f78c61079e1167
https://github.com/pulseshift/ui5-cache-buster/blob/55147d25bed7754fee2de69269f78c61079e1167/index.js#L319-L330
41,540
pulseshift/ui5-cache-buster
index.js
_getThemeRootHash
function _getThemeRootHash(sThemeRootPath, sThemeName, oOptions) { // read relevant resources for hash generation const aAssetContents = _readAllFiles(sThemeRootPath) // generate hash based on library CSS files in theme root const aBufferList = aAssetContents.map(oContent => new Buffer(oContent)) const sNewHash = _createHash(aBufferList, oOptions) return sNewHash }
javascript
function _getThemeRootHash(sThemeRootPath, sThemeName, oOptions) { // read relevant resources for hash generation const aAssetContents = _readAllFiles(sThemeRootPath) // generate hash based on library CSS files in theme root const aBufferList = aAssetContents.map(oContent => new Buffer(oContent)) const sNewHash = _createHash(aBufferList, oOptions) return sNewHash }
[ "function", "_getThemeRootHash", "(", "sThemeRootPath", ",", "sThemeName", ",", "oOptions", ")", "{", "// read relevant resources for hash generation", "const", "aAssetContents", "=", "_readAllFiles", "(", "sThemeRootPath", ")", "// generate hash based on library CSS files in theme root", "const", "aBufferList", "=", "aAssetContents", ".", "map", "(", "oContent", "=>", "new", "Buffer", "(", "oContent", ")", ")", "const", "sNewHash", "=", "_createHash", "(", "aBufferList", ",", "oOptions", ")", "return", "sNewHash", "}" ]
Generate hash for theme roots directory. @param {string} [sThemeRootPath] Theme root path. @param {string} [sThemeName] Theme name. @param {Object} [oOptions] Cach buster options. @param {Object} [oOptions.hash] Hash generation options. @param {string} [oOptions.HASH_TYPE] Hash type. @param {string} [oOptions.DIGEST_TYPE] Digest type. @param {number} [oOptions.MAX_LENGTH] Maximum hash length. @returns {string|null} Generated hash.
[ "Generate", "hash", "for", "theme", "roots", "directory", "." ]
55147d25bed7754fee2de69269f78c61079e1167
https://github.com/pulseshift/ui5-cache-buster/blob/55147d25bed7754fee2de69269f78c61079e1167/index.js#L364-L373
41,541
pulseshift/ui5-cache-buster
index.js
_readAllFiles
function _readAllFiles(sDir = '', aWhitelist = []) { // read all files in current directory const aFiles = fs.readdirSync(sDir) // loop at all files const aContents = aFiles.reduce((aContents, sFileName) => { // get file stats const oFile = fs.statSync(`${sDir}/${sFileName}`) if (oFile.isDirectory()) { // append files of directory to list return aContents.concat(_readAllFiles(`${sDir}/${sFileName}`)) } // append file content to list (if contained in whitelist) return aWhitelist.length === 0 || aWhitelist.indexOf(sFileName) !== -1 ? aContents.concat(fs.readFileSync(`${sDir}/${sFileName}`, 'utf8')) : aContents }, []) return aContents }
javascript
function _readAllFiles(sDir = '', aWhitelist = []) { // read all files in current directory const aFiles = fs.readdirSync(sDir) // loop at all files const aContents = aFiles.reduce((aContents, sFileName) => { // get file stats const oFile = fs.statSync(`${sDir}/${sFileName}`) if (oFile.isDirectory()) { // append files of directory to list return aContents.concat(_readAllFiles(`${sDir}/${sFileName}`)) } // append file content to list (if contained in whitelist) return aWhitelist.length === 0 || aWhitelist.indexOf(sFileName) !== -1 ? aContents.concat(fs.readFileSync(`${sDir}/${sFileName}`, 'utf8')) : aContents }, []) return aContents }
[ "function", "_readAllFiles", "(", "sDir", "=", "''", ",", "aWhitelist", "=", "[", "]", ")", "{", "// read all files in current directory", "const", "aFiles", "=", "fs", ".", "readdirSync", "(", "sDir", ")", "// loop at all files", "const", "aContents", "=", "aFiles", ".", "reduce", "(", "(", "aContents", ",", "sFileName", ")", "=>", "{", "// get file stats", "const", "oFile", "=", "fs", ".", "statSync", "(", "`", "${", "sDir", "}", "${", "sFileName", "}", "`", ")", "if", "(", "oFile", ".", "isDirectory", "(", ")", ")", "{", "// append files of directory to list", "return", "aContents", ".", "concat", "(", "_readAllFiles", "(", "`", "${", "sDir", "}", "${", "sFileName", "}", "`", ")", ")", "}", "// append file content to list (if contained in whitelist)", "return", "aWhitelist", ".", "length", "===", "0", "||", "aWhitelist", ".", "indexOf", "(", "sFileName", ")", "!==", "-", "1", "?", "aContents", ".", "concat", "(", "fs", ".", "readFileSync", "(", "`", "${", "sDir", "}", "${", "sFileName", "}", "`", ",", "'utf8'", ")", ")", ":", "aContents", "}", ",", "[", "]", ")", "return", "aContents", "}" ]
Helper function to read directories recursively. @param {string} [sDir] Directory. @param {Array.string} [aWhitelist] List of file names as whitelist. @returns {Array.string} List of read file contents.
[ "Helper", "function", "to", "read", "directories", "recursively", "." ]
55147d25bed7754fee2de69269f78c61079e1167
https://github.com/pulseshift/ui5-cache-buster/blob/55147d25bed7754fee2de69269f78c61079e1167/index.js#L381-L401
41,542
pulseshift/ui5-cache-buster
index.js
_createHash
function _createHash(aBufferList, { HASH_TYPE, DIGEST_TYPE, MAX_LENGTH }) { // very important to sort buffer list before creating hash!! const aSortedBufferList = (aBufferList || []).sort() // create and return hash return aSortedBufferList.length > 0 ? loaderUtils .getHashDigest( Buffer.concat(aSortedBufferList), HASH_TYPE, DIGEST_TYPE, MAX_LENGTH ) // Windows machines are case insensitive while Linux machines are, so we only will use lower case paths .toLowerCase() : null }
javascript
function _createHash(aBufferList, { HASH_TYPE, DIGEST_TYPE, MAX_LENGTH }) { // very important to sort buffer list before creating hash!! const aSortedBufferList = (aBufferList || []).sort() // create and return hash return aSortedBufferList.length > 0 ? loaderUtils .getHashDigest( Buffer.concat(aSortedBufferList), HASH_TYPE, DIGEST_TYPE, MAX_LENGTH ) // Windows machines are case insensitive while Linux machines are, so we only will use lower case paths .toLowerCase() : null }
[ "function", "_createHash", "(", "aBufferList", ",", "{", "HASH_TYPE", ",", "DIGEST_TYPE", ",", "MAX_LENGTH", "}", ")", "{", "// very important to sort buffer list before creating hash!!", "const", "aSortedBufferList", "=", "(", "aBufferList", "||", "[", "]", ")", ".", "sort", "(", ")", "// create and return hash", "return", "aSortedBufferList", ".", "length", ">", "0", "?", "loaderUtils", ".", "getHashDigest", "(", "Buffer", ".", "concat", "(", "aSortedBufferList", ")", ",", "HASH_TYPE", ",", "DIGEST_TYPE", ",", "MAX_LENGTH", ")", "// Windows machines are case insensitive while Linux machines are, so we only will use lower case paths", ".", "toLowerCase", "(", ")", ":", "null", "}" ]
Generate hash by binary content. @param {Array.Buffer} [aBufferList] Buffer list with binary content. @param {Object} [oOptions] Cach buster options. @param {Object} [oOptions.hash] Hash generation options. @param {string} [oOptions.HASH_TYPE] Hash type. @param {string} [oOptions.DIGEST_TYPE] Digest type. @param {number} [oOptions.MAX_LENGTH] Maximum hash length. @returns {string|null} Generated hash.
[ "Generate", "hash", "by", "binary", "content", "." ]
55147d25bed7754fee2de69269f78c61079e1167
https://github.com/pulseshift/ui5-cache-buster/blob/55147d25bed7754fee2de69269f78c61079e1167/index.js#L413-L429
41,543
fullstackio/cq
packages/cq/dist/index.js
lineNumberOfCharacterIndex
function lineNumberOfCharacterIndex(code, idx) { var everythingUpUntilTheIndex = code.substring(0, idx); // computer science! return everythingUpUntilTheIndex.split("\n").length; }
javascript
function lineNumberOfCharacterIndex(code, idx) { var everythingUpUntilTheIndex = code.substring(0, idx); // computer science! return everythingUpUntilTheIndex.split("\n").length; }
[ "function", "lineNumberOfCharacterIndex", "(", "code", ",", "idx", ")", "{", "var", "everythingUpUntilTheIndex", "=", "code", ".", "substring", "(", "0", ",", "idx", ")", ";", "// computer science!", "return", "everythingUpUntilTheIndex", ".", "split", "(", "\"\\n\"", ")", ".", "length", ";", "}" ]
given character index idx in code, returns the 1-indexed line number
[ "given", "character", "index", "idx", "in", "code", "returns", "the", "1", "-", "indexed", "line", "number" ]
a9425c677b558f92f73a15d38ad39ac1d2deb189
https://github.com/fullstackio/cq/blob/a9425c677b558f92f73a15d38ad39ac1d2deb189/packages/cq/dist/index.js#L503-L507
41,544
wbyoung/azul
lib/database.js
function(name, properties) { var className = _.capitalize(_.camelCase(name)); var known = this._modelClasses; var model = known[className]; if (!model) { model = known[className] = this.Model.extend({}, { __name__: className }); } return model.reopen(properties); }
javascript
function(name, properties) { var className = _.capitalize(_.camelCase(name)); var known = this._modelClasses; var model = known[className]; if (!model) { model = known[className] = this.Model.extend({}, { __name__: className }); } return model.reopen(properties); }
[ "function", "(", "name", ",", "properties", ")", "{", "var", "className", "=", "_", ".", "capitalize", "(", "_", ".", "camelCase", "(", "name", ")", ")", ";", "var", "known", "=", "this", ".", "_modelClasses", ";", "var", "model", "=", "known", "[", "className", "]", ";", "if", "(", "!", "model", ")", "{", "model", "=", "known", "[", "className", "]", "=", "this", ".", "Model", ".", "extend", "(", "{", "}", ",", "{", "__name__", ":", "className", "}", ")", ";", "}", "return", "model", ".", "reopen", "(", "properties", ")", ";", "}" ]
Create a new model class or retrieve an existing class. This is the preferred way of creating new model classes as it also stores the model class by name, allowing you to use strings in certain places to refer to classes (i.e. when defining relationships). @param {String} name The name for the class @param {Object} [properties] Properties to add to the class @return {Class} The model class
[ "Create", "a", "new", "model", "class", "or", "retrieve", "an", "existing", "class", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/database.js#L96-L105
41,545
jwir3/gulp-ssh-deploy
src/index.js
function() { var self = this; if (!self.mHighlightedText) { gulpUtil.log(gulpUtil.colors.yellow('Warning:'), self.mMessage, "You will not be able to deploy."); } else { gulpUtil.log(gulpUtil.colors.yellow('Warning:'), self.mMessage, gulpUtil.colors.cyan(self.mHighlightedText), "You will not be able to deploy."); } }
javascript
function() { var self = this; if (!self.mHighlightedText) { gulpUtil.log(gulpUtil.colors.yellow('Warning:'), self.mMessage, "You will not be able to deploy."); } else { gulpUtil.log(gulpUtil.colors.yellow('Warning:'), self.mMessage, gulpUtil.colors.cyan(self.mHighlightedText), "You will not be able to deploy."); } }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "if", "(", "!", "self", ".", "mHighlightedText", ")", "{", "gulpUtil", ".", "log", "(", "gulpUtil", ".", "colors", ".", "yellow", "(", "'Warning:'", ")", ",", "self", ".", "mMessage", ",", "\"You will not be able to deploy.\"", ")", ";", "}", "else", "{", "gulpUtil", ".", "log", "(", "gulpUtil", ".", "colors", ".", "yellow", "(", "'Warning:'", ")", ",", "self", ".", "mMessage", ",", "gulpUtil", ".", "colors", ".", "cyan", "(", "self", ".", "mHighlightedText", ")", ",", "\"You will not be able to deploy.\"", ")", ";", "}", "}" ]
Print this exception to the gulp log, with some color highlighting.
[ "Print", "this", "exception", "to", "the", "gulp", "log", "with", "some", "color", "highlighting", "." ]
d16f99fe93215b3fdf28796daf1d326154899866
https://github.com/jwir3/gulp-ssh-deploy/blob/d16f99fe93215b3fdf28796daf1d326154899866/src/index.js#L20-L29
41,546
jwir3/gulp-ssh-deploy
src/index.js
function() { var self = this; if (!self.mPackageJson) { self.mPackageJson = jetpack.read(this.mOptions.package_json_file_path, 'json'); } return self.mPackageJson; }
javascript
function() { var self = this; if (!self.mPackageJson) { self.mPackageJson = jetpack.read(this.mOptions.package_json_file_path, 'json'); } return self.mPackageJson; }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "if", "(", "!", "self", ".", "mPackageJson", ")", "{", "self", ".", "mPackageJson", "=", "jetpack", ".", "read", "(", "this", ".", "mOptions", ".", "package_json_file_path", ",", "'json'", ")", ";", "}", "return", "self", ".", "mPackageJson", ";", "}" ]
Retrieve the package.json file, as a JSON object. @return {object} The object containing the contents of the package.json file specified in the options structure.
[ "Retrieve", "the", "package", ".", "json", "file", "as", "a", "JSON", "object", "." ]
d16f99fe93215b3fdf28796daf1d326154899866
https://github.com/jwir3/gulp-ssh-deploy/blob/d16f99fe93215b3fdf28796daf1d326154899866/src/index.js#L124-L131
41,547
wbyoung/azul
lib/relations/base.js
function(baseTable, joinTable) { var jk = [baseTable, this.joinKeyAttr].join('.'); var ik = [joinTable, this.inverseKeyAttr].join('.'); var parts = [jk, ik]; // for readability, we like to keep the foreign key first in the join // condition, so if the join key is the primary key, swap the order of the // condition. if (this.joinKey === this.primaryKey) { parts.reverse(); } return parts.join('='); }
javascript
function(baseTable, joinTable) { var jk = [baseTable, this.joinKeyAttr].join('.'); var ik = [joinTable, this.inverseKeyAttr].join('.'); var parts = [jk, ik]; // for readability, we like to keep the foreign key first in the join // condition, so if the join key is the primary key, swap the order of the // condition. if (this.joinKey === this.primaryKey) { parts.reverse(); } return parts.join('='); }
[ "function", "(", "baseTable", ",", "joinTable", ")", "{", "var", "jk", "=", "[", "baseTable", ",", "this", ".", "joinKeyAttr", "]", ".", "join", "(", "'.'", ")", ";", "var", "ik", "=", "[", "joinTable", ",", "this", ".", "inverseKeyAttr", "]", ".", "join", "(", "'.'", ")", ";", "var", "parts", "=", "[", "jk", ",", "ik", "]", ";", "// for readability, we like to keep the foreign key first in the join", "// condition, so if the join key is the primary key, swap the order of the", "// condition.", "if", "(", "this", ".", "joinKey", "===", "this", ".", "primaryKey", ")", "{", "parts", ".", "reverse", "(", ")", ";", "}", "return", "parts", ".", "join", "(", "'='", ")", ";", "}" ]
Join support for a relation. This method joins a table, `baseTable` to `joinTable` using {@link BaseRelation#joinKey} as the attribute on the `baseTable` and {@link BaseRelation#inverseKey} as the attribute on `joinTable`. It also ensures that the foreign key will come first in the resulting condition (for readability, it's generally a little more understandable to see the foreign key first). @method @protected @param {String} baseTable The table name/alias of the existing table. @param {String} relatedTable The table name/alias being joined. @return {String} A string that represents the appropriate join condition.
[ "Join", "support", "for", "a", "relation", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/base.js#L223-L236
41,548
jpommerening/node-lazystream
lib/lazystream.js
beforeFirstCall
function beforeFirstCall(instance, method, callback) { instance[method] = function() { delete instance[method]; callback.apply(this, arguments); return this[method].apply(this, arguments); }; }
javascript
function beforeFirstCall(instance, method, callback) { instance[method] = function() { delete instance[method]; callback.apply(this, arguments); return this[method].apply(this, arguments); }; }
[ "function", "beforeFirstCall", "(", "instance", ",", "method", ",", "callback", ")", "{", "instance", "[", "method", "]", "=", "function", "(", ")", "{", "delete", "instance", "[", "method", "]", ";", "callback", ".", "apply", "(", "this", ",", "arguments", ")", ";", "return", "this", "[", "method", "]", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", ";", "}" ]
Patch the given method of instance so that the callback is executed once, before the actual method is called the first time.
[ "Patch", "the", "given", "method", "of", "instance", "so", "that", "the", "callback", "is", "executed", "once", "before", "the", "actual", "method", "is", "called", "the", "first", "time", "." ]
f1f047c1957c75d39da6d4c21bb1d5196427d6c6
https://github.com/jpommerening/node-lazystream/blob/f1f047c1957c75d39da6d4c21bb1d5196427d6c6/lib/lazystream.js#L15-L21
41,549
wbyoung/azul
lib/cli/index.js
function(env, action) { if (!env.modulePath) { console.log(chalk.red('Local azul not found in'), chalk.magenta(tildify(env.cwd))); console.log(chalk.red('Try running: npm install azul')); process.exit(1); } if (!env.configPath && action.azulfile) { console.log(chalk.red('No azulfile found')); process.exit(1); } }
javascript
function(env, action) { if (!env.modulePath) { console.log(chalk.red('Local azul not found in'), chalk.magenta(tildify(env.cwd))); console.log(chalk.red('Try running: npm install azul')); process.exit(1); } if (!env.configPath && action.azulfile) { console.log(chalk.red('No azulfile found')); process.exit(1); } }
[ "function", "(", "env", ",", "action", ")", "{", "if", "(", "!", "env", ".", "modulePath", ")", "{", "console", ".", "log", "(", "chalk", ".", "red", "(", "'Local azul not found in'", ")", ",", "chalk", ".", "magenta", "(", "tildify", "(", "env", ".", "cwd", ")", ")", ")", ";", "console", ".", "log", "(", "chalk", ".", "red", "(", "'Try running: npm install azul'", ")", ")", ";", "process", ".", "exit", "(", "1", ")", ";", "}", "if", "(", "!", "env", ".", "configPath", "&&", "action", ".", "azulfile", ")", "{", "console", ".", "log", "(", "chalk", ".", "red", "(", "'No azulfile found'", ")", ")", ";", "process", ".", "exit", "(", "1", ")", ";", "}", "}" ]
Verify the Liftoff environment and exit the program if we are not in a suitable environment to operate. @private @function cli.verifyEnvironment @param {Object} env The liftoff environment.
[ "Verify", "the", "Liftoff", "environment", "and", "exit", "the", "program", "if", "we", "are", "not", "in", "a", "suitable", "environment", "to", "operate", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/cli/index.js#L47-L59
41,550
wbyoung/azul
lib/cli/index.js
function(program) { return program .version(require('../../package.json').version) .usage('[options] command') .option('--cwd <cwd>', 'change the current working directory') .option('--azulfile <azulfile>', 'use a specific config file') .option('--require <require>', 'require external module') .option('--completion <value>', 'a method to handle shell completions'); }
javascript
function(program) { return program .version(require('../../package.json').version) .usage('[options] command') .option('--cwd <cwd>', 'change the current working directory') .option('--azulfile <azulfile>', 'use a specific config file') .option('--require <require>', 'require external module') .option('--completion <value>', 'a method to handle shell completions'); }
[ "function", "(", "program", ")", "{", "return", "program", ".", "version", "(", "require", "(", "'../../package.json'", ")", ".", "version", ")", ".", "usage", "(", "'[options] command'", ")", ".", "option", "(", "'--cwd <cwd>'", ",", "'change the current working directory'", ")", ".", "option", "(", "'--azulfile <azulfile>'", ",", "'use a specific config file'", ")", ".", "option", "(", "'--require <require>'", ",", "'require external module'", ")", ".", "option", "(", "'--completion <value>'", ",", "'a method to handle shell completions'", ")", ";", "}" ]
Setup program. @private @function
[ "Setup", "program", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/cli/index.js#L76-L84
41,551
wbyoung/azul
lib/cli/index.js
function(details) { return function() { var args = _.toArray(arguments); var options = _.last(args); action.options = options; action.name = options.name(); action.args = args; action = _.defaults(action, details, { azulfile: true }); }; }
javascript
function(details) { return function() { var args = _.toArray(arguments); var options = _.last(args); action.options = options; action.name = options.name(); action.args = args; action = _.defaults(action, details, { azulfile: true }); }; }
[ "function", "(", "details", ")", "{", "return", "function", "(", ")", "{", "var", "args", "=", "_", ".", "toArray", "(", "arguments", ")", ";", "var", "options", "=", "_", ".", "last", "(", "args", ")", ";", "action", ".", "options", "=", "options", ";", "action", ".", "name", "=", "options", ".", "name", "(", ")", ";", "action", ".", "args", "=", "args", ";", "action", "=", "_", ".", "defaults", "(", "action", ",", "details", ",", "{", "azulfile", ":", "true", "}", ")", ";", "}", ";", "}" ]
We need capture the requested action & execute it after checking that all required values are set on env. this allows the cli to still run things like help when azul is not installed locally or is missing a configuration file. @function cli~capture @private
[ "We", "need", "capture", "the", "requested", "action", "&", "execute", "it", "after", "checking", "that", "all", "required", "values", "are", "set", "on", "env", ".", "this", "allows", "the", "cli", "to", "still", "run", "things", "like", "help", "when", "azul", "is", "not", "installed", "locally", "or", "is", "missing", "a", "configuration", "file", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/cli/index.js#L160-L169
41,552
fullstackio/cq
packages/react-cq-demo/src/jquery.highlight-within-textarea.js
function(instance) { let type = typeof instance; if (!instance) { return "falsey"; } else if (Array.isArray(instance)) { if ( instance.length === 2 && typeof instance[0] === "number" && typeof instance[1] === "number" ) { return "range"; } else { return "array"; } } else if (type === "object") { if (instance instanceof RegExp) { return "regexp"; } else if (instance.hasOwnProperty("highlight")) { return "custom"; } } else if (type === "function" || type === "string") { return type; } return "other"; }
javascript
function(instance) { let type = typeof instance; if (!instance) { return "falsey"; } else if (Array.isArray(instance)) { if ( instance.length === 2 && typeof instance[0] === "number" && typeof instance[1] === "number" ) { return "range"; } else { return "array"; } } else if (type === "object") { if (instance instanceof RegExp) { return "regexp"; } else if (instance.hasOwnProperty("highlight")) { return "custom"; } } else if (type === "function" || type === "string") { return type; } return "other"; }
[ "function", "(", "instance", ")", "{", "let", "type", "=", "typeof", "instance", ";", "if", "(", "!", "instance", ")", "{", "return", "\"falsey\"", ";", "}", "else", "if", "(", "Array", ".", "isArray", "(", "instance", ")", ")", "{", "if", "(", "instance", ".", "length", "===", "2", "&&", "typeof", "instance", "[", "0", "]", "===", "\"number\"", "&&", "typeof", "instance", "[", "1", "]", "===", "\"number\"", ")", "{", "return", "\"range\"", ";", "}", "else", "{", "return", "\"array\"", ";", "}", "}", "else", "if", "(", "type", "===", "\"object\"", ")", "{", "if", "(", "instance", "instanceof", "RegExp", ")", "{", "return", "\"regexp\"", ";", "}", "else", "if", "(", "instance", ".", "hasOwnProperty", "(", "\"highlight\"", ")", ")", "{", "return", "\"custom\"", ";", "}", "}", "else", "if", "(", "type", "===", "\"function\"", "||", "type", "===", "\"string\"", ")", "{", "return", "type", ";", "}", "return", "\"other\"", ";", "}" ]
returns identifier strings that aren't necessarily "real" JavaScript types
[ "returns", "identifier", "strings", "that", "aren", "t", "necessarily", "real", "JavaScript", "types" ]
a9425c677b558f92f73a15d38ad39ac1d2deb189
https://github.com/fullstackio/cq/blob/a9425c677b558f92f73a15d38ad39ac1d2deb189/packages/react-cq-demo/src/jquery.highlight-within-textarea.js#L33-L58
41,553
fullstackio/cq
packages/react-cq-demo/src/jquery.highlight-within-textarea.js
function() { let ua = window.navigator.userAgent.toLowerCase(); if (ua.indexOf("firefox") !== -1) { return "firefox"; } else if (!!ua.match(/msie|trident\/7|edge/)) { return "ie"; } else if ( !!ua.match(/ipad|iphone|ipod/) && ua.indexOf("windows phone") === -1 ) { // Windows Phone flags itself as "like iPhone", thus the extra check return "ios"; } else { return "other"; } }
javascript
function() { let ua = window.navigator.userAgent.toLowerCase(); if (ua.indexOf("firefox") !== -1) { return "firefox"; } else if (!!ua.match(/msie|trident\/7|edge/)) { return "ie"; } else if ( !!ua.match(/ipad|iphone|ipod/) && ua.indexOf("windows phone") === -1 ) { // Windows Phone flags itself as "like iPhone", thus the extra check return "ios"; } else { return "other"; } }
[ "function", "(", ")", "{", "let", "ua", "=", "window", ".", "navigator", ".", "userAgent", ".", "toLowerCase", "(", ")", ";", "if", "(", "ua", ".", "indexOf", "(", "\"firefox\"", ")", "!==", "-", "1", ")", "{", "return", "\"firefox\"", ";", "}", "else", "if", "(", "!", "!", "ua", ".", "match", "(", "/", "msie|trident\\/7|edge", "/", ")", ")", "{", "return", "\"ie\"", ";", "}", "else", "if", "(", "!", "!", "ua", ".", "match", "(", "/", "ipad|iphone|ipod", "/", ")", "&&", "ua", ".", "indexOf", "(", "\"windows phone\"", ")", "===", "-", "1", ")", "{", "// Windows Phone flags itself as \"like iPhone\", thus the extra check", "return", "\"ios\"", ";", "}", "else", "{", "return", "\"other\"", ";", "}", "}" ]
browser sniffing sucks, but there are browser-specific quirks to handle that are not a matter of feature detection
[ "browser", "sniffing", "sucks", "but", "there", "are", "browser", "-", "specific", "quirks", "to", "handle", "that", "are", "not", "a", "matter", "of", "feature", "detection" ]
a9425c677b558f92f73a15d38ad39ac1d2deb189
https://github.com/fullstackio/cq/blob/a9425c677b558f92f73a15d38ad39ac1d2deb189/packages/react-cq-demo/src/jquery.highlight-within-textarea.js#L98-L113
41,554
fullstackio/cq
packages/react-cq-demo/src/jquery.highlight-within-textarea.js
function() { // take padding and border pixels from highlights div let padding = this.$highlights.css([ "padding-top", "padding-right", "padding-bottom", "padding-left" ]); let border = this.$highlights.css([ "border-top-width", "border-right-width", "border-bottom-width", "border-left-width" ]); this.$highlights.css({ padding: "0", "border-width": "0" }); this.$backdrop .css({ // give padding pixels to backdrop div "margin-top": "+=" + padding["padding-top"], "margin-right": "+=" + padding["padding-right"], "margin-bottom": "+=" + padding["padding-bottom"], "margin-left": "+=" + padding["padding-left"] }) .css({ // give border pixels to backdrop div "margin-top": "+=" + border["border-top-width"], "margin-right": "+=" + border["border-right-width"], "margin-bottom": "+=" + border["border-bottom-width"], "margin-left": "+=" + border["border-left-width"] }); }
javascript
function() { // take padding and border pixels from highlights div let padding = this.$highlights.css([ "padding-top", "padding-right", "padding-bottom", "padding-left" ]); let border = this.$highlights.css([ "border-top-width", "border-right-width", "border-bottom-width", "border-left-width" ]); this.$highlights.css({ padding: "0", "border-width": "0" }); this.$backdrop .css({ // give padding pixels to backdrop div "margin-top": "+=" + padding["padding-top"], "margin-right": "+=" + padding["padding-right"], "margin-bottom": "+=" + padding["padding-bottom"], "margin-left": "+=" + padding["padding-left"] }) .css({ // give border pixels to backdrop div "margin-top": "+=" + border["border-top-width"], "margin-right": "+=" + border["border-right-width"], "margin-bottom": "+=" + border["border-bottom-width"], "margin-left": "+=" + border["border-left-width"] }); }
[ "function", "(", ")", "{", "// take padding and border pixels from highlights div", "let", "padding", "=", "this", ".", "$highlights", ".", "css", "(", "[", "\"padding-top\"", ",", "\"padding-right\"", ",", "\"padding-bottom\"", ",", "\"padding-left\"", "]", ")", ";", "let", "border", "=", "this", ".", "$highlights", ".", "css", "(", "[", "\"border-top-width\"", ",", "\"border-right-width\"", ",", "\"border-bottom-width\"", ",", "\"border-left-width\"", "]", ")", ";", "this", ".", "$highlights", ".", "css", "(", "{", "padding", ":", "\"0\"", ",", "\"border-width\"", ":", "\"0\"", "}", ")", ";", "this", ".", "$backdrop", ".", "css", "(", "{", "// give padding pixels to backdrop div", "\"margin-top\"", ":", "\"+=\"", "+", "padding", "[", "\"padding-top\"", "]", ",", "\"margin-right\"", ":", "\"+=\"", "+", "padding", "[", "\"padding-right\"", "]", ",", "\"margin-bottom\"", ":", "\"+=\"", "+", "padding", "[", "\"padding-bottom\"", "]", ",", "\"margin-left\"", ":", "\"+=\"", "+", "padding", "[", "\"padding-left\"", "]", "}", ")", ".", "css", "(", "{", "// give border pixels to backdrop div", "\"margin-top\"", ":", "\"+=\"", "+", "border", "[", "\"border-top-width\"", "]", ",", "\"margin-right\"", ":", "\"+=\"", "+", "border", "[", "\"border-right-width\"", "]", ",", "\"margin-bottom\"", ":", "\"+=\"", "+", "border", "[", "\"border-bottom-width\"", "]", ",", "\"margin-left\"", ":", "\"+=\"", "+", "border", "[", "\"border-left-width\"", "]", "}", ")", ";", "}" ]
Firefox doesn't show text that scrolls into the padding of a textarea, so rearrange a couple box models to make highlights behave the same way
[ "Firefox", "doesn", "t", "show", "text", "that", "scrolls", "into", "the", "padding", "of", "a", "textarea", "so", "rearrange", "a", "couple", "box", "models", "to", "make", "highlights", "behave", "the", "same", "way" ]
a9425c677b558f92f73a15d38ad39ac1d2deb189
https://github.com/fullstackio/cq/blob/a9425c677b558f92f73a15d38ad39ac1d2deb189/packages/react-cq-demo/src/jquery.highlight-within-textarea.js#L117-L151
41,555
fullstackio/cq
packages/remark-cq/index.js
locateCodeImport
function locateCodeImport(value, fromIndex) { var index = value.indexOf(C_NEWLINE, fromIndex); if (value.charAt(index + 1) !== "<" && value.charAt(index + 2) !== "<") { return; } return index; }
javascript
function locateCodeImport(value, fromIndex) { var index = value.indexOf(C_NEWLINE, fromIndex); if (value.charAt(index + 1) !== "<" && value.charAt(index + 2) !== "<") { return; } return index; }
[ "function", "locateCodeImport", "(", "value", ",", "fromIndex", ")", "{", "var", "index", "=", "value", ".", "indexOf", "(", "C_NEWLINE", ",", "fromIndex", ")", ";", "if", "(", "value", ".", "charAt", "(", "index", "+", "1", ")", "!==", "\"<\"", "&&", "value", ".", "charAt", "(", "index", "+", "2", ")", "!==", "\"<\"", ")", "{", "return", ";", "}", "return", "index", ";", "}" ]
Find a possible Code Imports @example locateCodeImport('foo \n<<[my-file.js](my-file.js)'); // 4 @param {string} value - Value to search. @param {number} fromIndex - Index to start searching at. @return {number} - Location of possible mention sequence.
[ "Find", "a", "possible", "Code", "Imports" ]
a9425c677b558f92f73a15d38ad39ac1d2deb189
https://github.com/fullstackio/cq/blob/a9425c677b558f92f73a15d38ad39ac1d2deb189/packages/remark-cq/index.js#L54-L62
41,556
fullstackio/cq
packages/remark-cq/index.js
codeImportBlock
function codeImportBlock(eat, value, silent) { var index = -1; var length = value.length + 1; var subvalue = EMPTY; var character; var marker; var markerCount; var queue; // eat initial spacing while (++index < length) { character = value.charAt(index); if (character !== C_TAB && character !== C_SPACE) { break; } subvalue += character; } if (value.charAt(index) !== "<") { return; } // require << if (value.charAt(index + 1) !== "<") { return; } marker = character; subvalue += character; markerCount = 1; queue = EMPTY; while (++index < length) { character = value.charAt(index); if (character !== C_RIGHT_PAREN) { markerCount++; subvalue += queue + character; queue = EMPTY; } else if (character === C_RIGHT_PAREN) { subvalue += queue + C_RIGHT_PAREN; break; } } var match = /^(<<.*?)\s*$/m.exec(subvalue); if (!match) return; var fileMatches = /<<\[(.*)\]\((.*)\)/.exec(match[0]); var statedFilename = fileMatches[1]; var actualFilename = fileMatches[2]; var cqOpts = { ...__options }; if (__lastBlockAttributes["undent"]) { cqOpts.undent = true; } if (__lastBlockAttributes["root"]) { cqOpts.root = __lastBlockAttributes["root"]; } if (__lastBlockAttributes["meta"]) { cqOpts.meta = __lastBlockAttributes["meta"]; } let newNode = { type: "cq", lang: null, statedFilename, actualFilename, query: null, cropStartLine: null, cropEndLine: null, options: cqOpts }; if (__lastBlockAttributes["lang"]) { newNode.lang = __lastBlockAttributes["lang"].toLowerCase(); } if (__lastBlockAttributes["crop-query"]) { newNode.query = __lastBlockAttributes["crop-query"]; } if (__lastBlockAttributes["crop-start-line"]) { newNode.cropStartLine = parseInt(__lastBlockAttributes["crop-start-line"]); } if (__lastBlockAttributes["crop-end-line"]) { newNode.cropEndLine = parseInt(__lastBlockAttributes["crop-end-line"]); } // meta: `{ info=string filename="foo/bar/baz.js" githubUrl="https://github.com/foo/bar"}` return eat(subvalue)(newNode); }
javascript
function codeImportBlock(eat, value, silent) { var index = -1; var length = value.length + 1; var subvalue = EMPTY; var character; var marker; var markerCount; var queue; // eat initial spacing while (++index < length) { character = value.charAt(index); if (character !== C_TAB && character !== C_SPACE) { break; } subvalue += character; } if (value.charAt(index) !== "<") { return; } // require << if (value.charAt(index + 1) !== "<") { return; } marker = character; subvalue += character; markerCount = 1; queue = EMPTY; while (++index < length) { character = value.charAt(index); if (character !== C_RIGHT_PAREN) { markerCount++; subvalue += queue + character; queue = EMPTY; } else if (character === C_RIGHT_PAREN) { subvalue += queue + C_RIGHT_PAREN; break; } } var match = /^(<<.*?)\s*$/m.exec(subvalue); if (!match) return; var fileMatches = /<<\[(.*)\]\((.*)\)/.exec(match[0]); var statedFilename = fileMatches[1]; var actualFilename = fileMatches[2]; var cqOpts = { ...__options }; if (__lastBlockAttributes["undent"]) { cqOpts.undent = true; } if (__lastBlockAttributes["root"]) { cqOpts.root = __lastBlockAttributes["root"]; } if (__lastBlockAttributes["meta"]) { cqOpts.meta = __lastBlockAttributes["meta"]; } let newNode = { type: "cq", lang: null, statedFilename, actualFilename, query: null, cropStartLine: null, cropEndLine: null, options: cqOpts }; if (__lastBlockAttributes["lang"]) { newNode.lang = __lastBlockAttributes["lang"].toLowerCase(); } if (__lastBlockAttributes["crop-query"]) { newNode.query = __lastBlockAttributes["crop-query"]; } if (__lastBlockAttributes["crop-start-line"]) { newNode.cropStartLine = parseInt(__lastBlockAttributes["crop-start-line"]); } if (__lastBlockAttributes["crop-end-line"]) { newNode.cropEndLine = parseInt(__lastBlockAttributes["crop-end-line"]); } // meta: `{ info=string filename="foo/bar/baz.js" githubUrl="https://github.com/foo/bar"}` return eat(subvalue)(newNode); }
[ "function", "codeImportBlock", "(", "eat", ",", "value", ",", "silent", ")", "{", "var", "index", "=", "-", "1", ";", "var", "length", "=", "value", ".", "length", "+", "1", ";", "var", "subvalue", "=", "EMPTY", ";", "var", "character", ";", "var", "marker", ";", "var", "markerCount", ";", "var", "queue", ";", "// eat initial spacing", "while", "(", "++", "index", "<", "length", ")", "{", "character", "=", "value", ".", "charAt", "(", "index", ")", ";", "if", "(", "character", "!==", "C_TAB", "&&", "character", "!==", "C_SPACE", ")", "{", "break", ";", "}", "subvalue", "+=", "character", ";", "}", "if", "(", "value", ".", "charAt", "(", "index", ")", "!==", "\"<\"", ")", "{", "return", ";", "}", "// require <<", "if", "(", "value", ".", "charAt", "(", "index", "+", "1", ")", "!==", "\"<\"", ")", "{", "return", ";", "}", "marker", "=", "character", ";", "subvalue", "+=", "character", ";", "markerCount", "=", "1", ";", "queue", "=", "EMPTY", ";", "while", "(", "++", "index", "<", "length", ")", "{", "character", "=", "value", ".", "charAt", "(", "index", ")", ";", "if", "(", "character", "!==", "C_RIGHT_PAREN", ")", "{", "markerCount", "++", ";", "subvalue", "+=", "queue", "+", "character", ";", "queue", "=", "EMPTY", ";", "}", "else", "if", "(", "character", "===", "C_RIGHT_PAREN", ")", "{", "subvalue", "+=", "queue", "+", "C_RIGHT_PAREN", ";", "break", ";", "}", "}", "var", "match", "=", "/", "^(<<.*?)\\s*$", "/", "m", ".", "exec", "(", "subvalue", ")", ";", "if", "(", "!", "match", ")", "return", ";", "var", "fileMatches", "=", "/", "<<\\[(.*)\\]\\((.*)\\)", "/", ".", "exec", "(", "match", "[", "0", "]", ")", ";", "var", "statedFilename", "=", "fileMatches", "[", "1", "]", ";", "var", "actualFilename", "=", "fileMatches", "[", "2", "]", ";", "var", "cqOpts", "=", "{", "...", "__options", "}", ";", "if", "(", "__lastBlockAttributes", "[", "\"undent\"", "]", ")", "{", "cqOpts", ".", "undent", "=", "true", ";", "}", "if", "(", "__lastBlockAttributes", "[", "\"root\"", "]", ")", "{", "cqOpts", ".", "root", "=", "__lastBlockAttributes", "[", "\"root\"", "]", ";", "}", "if", "(", "__lastBlockAttributes", "[", "\"meta\"", "]", ")", "{", "cqOpts", ".", "meta", "=", "__lastBlockAttributes", "[", "\"meta\"", "]", ";", "}", "let", "newNode", "=", "{", "type", ":", "\"cq\"", ",", "lang", ":", "null", ",", "statedFilename", ",", "actualFilename", ",", "query", ":", "null", ",", "cropStartLine", ":", "null", ",", "cropEndLine", ":", "null", ",", "options", ":", "cqOpts", "}", ";", "if", "(", "__lastBlockAttributes", "[", "\"lang\"", "]", ")", "{", "newNode", ".", "lang", "=", "__lastBlockAttributes", "[", "\"lang\"", "]", ".", "toLowerCase", "(", ")", ";", "}", "if", "(", "__lastBlockAttributes", "[", "\"crop-query\"", "]", ")", "{", "newNode", ".", "query", "=", "__lastBlockAttributes", "[", "\"crop-query\"", "]", ";", "}", "if", "(", "__lastBlockAttributes", "[", "\"crop-start-line\"", "]", ")", "{", "newNode", ".", "cropStartLine", "=", "parseInt", "(", "__lastBlockAttributes", "[", "\"crop-start-line\"", "]", ")", ";", "}", "if", "(", "__lastBlockAttributes", "[", "\"crop-end-line\"", "]", ")", "{", "newNode", ".", "cropEndLine", "=", "parseInt", "(", "__lastBlockAttributes", "[", "\"crop-end-line\"", "]", ")", ";", "}", "// meta: `{ info=string filename=\"foo/bar/baz.js\" githubUrl=\"https://github.com/foo/bar\"}`", "return", "eat", "(", "subvalue", ")", "(", "newNode", ")", ";", "}" ]
Tokenize a code import @example codeImportBlock(eat, '\n<<[my-file.js](my-file.js)'); @property {Function} locator - Mention locator. @param {function(string)} eat - Eater. @param {string} value - Rest of content. @param {boolean?} [silent] - Whether this is a dry run. @return {Node?|boolean} - `delete` node.
[ "Tokenize", "a", "code", "import" ]
a9425c677b558f92f73a15d38ad39ac1d2deb189
https://github.com/fullstackio/cq/blob/a9425c677b558f92f73a15d38ad39ac1d2deb189/packages/remark-cq/index.js#L77-L173
41,557
fullstackio/cq
packages/remark-cq/index.js
tokenizeBlockInlineAttributeList
function tokenizeBlockInlineAttributeList(eat, value, silent) { var self = this; var index = -1; var length = value.length + 1; var subvalue = EMPTY; var character; var marker; var markerCount; var queue; // eat initial spacing while (++index < length) { character = value.charAt(index); if (character !== C_TAB && character !== C_SPACE) { break; } subvalue += character; } if (value.charAt(index) !== C_LEFT_BRACE) { return; } // ignore {{ thing }} if (value.charAt(index + 1) === C_LEFT_BRACE) { return; } // ignore {% thing %} if (value.charAt(index + 1) === C_PERCENT) { return; } marker = character; subvalue += character; markerCount = 1; queue = EMPTY; while (++index < length) { character = value.charAt(index); if (character !== C_RIGHT_BRACE) { // no newlines allowed in the attribute blocks if (character === C_NEWLINE) { return; } markerCount++; subvalue += queue + character; queue = EMPTY; } else if (character === C_RIGHT_BRACE) { subvalue += queue + C_RIGHT_BRACE; // eat trailing spacing because we don't even want this block to leave a linebreak in the output while (++index < length) { character = value.charAt(index); if ( character !== C_TAB && character !== C_SPACE && character !== C_NEWLINE ) { break; } subvalue += character; } function parseBlockAttributes(attrString) { // e.g. {lang='JavaScript',starting-line=4,crop-start-line=4,crop-end-line=26} var matches = /{(.*?)}/.exec(attrString); var blockAttrs = {}; if (!matches || !matches[1]) { console.log("WARNING: remark-cq unknown attrString", attrString); // hmm... return blockAttrs; } var pairs = splitNoParen(matches[1]); pairs.forEach(function(pair) { var kv = pair.split(/=\s*/); blockAttrs[kv[0]] = kv[1]; }); return blockAttrs; } __lastBlockAttributes = parseBlockAttributes(subvalue); if (__options.preserveEmptyLines) { return eat(subvalue)({ type: T_BREAK }); } else { return eat(subvalue); } } else { return; } } }
javascript
function tokenizeBlockInlineAttributeList(eat, value, silent) { var self = this; var index = -1; var length = value.length + 1; var subvalue = EMPTY; var character; var marker; var markerCount; var queue; // eat initial spacing while (++index < length) { character = value.charAt(index); if (character !== C_TAB && character !== C_SPACE) { break; } subvalue += character; } if (value.charAt(index) !== C_LEFT_BRACE) { return; } // ignore {{ thing }} if (value.charAt(index + 1) === C_LEFT_BRACE) { return; } // ignore {% thing %} if (value.charAt(index + 1) === C_PERCENT) { return; } marker = character; subvalue += character; markerCount = 1; queue = EMPTY; while (++index < length) { character = value.charAt(index); if (character !== C_RIGHT_BRACE) { // no newlines allowed in the attribute blocks if (character === C_NEWLINE) { return; } markerCount++; subvalue += queue + character; queue = EMPTY; } else if (character === C_RIGHT_BRACE) { subvalue += queue + C_RIGHT_BRACE; // eat trailing spacing because we don't even want this block to leave a linebreak in the output while (++index < length) { character = value.charAt(index); if ( character !== C_TAB && character !== C_SPACE && character !== C_NEWLINE ) { break; } subvalue += character; } function parseBlockAttributes(attrString) { // e.g. {lang='JavaScript',starting-line=4,crop-start-line=4,crop-end-line=26} var matches = /{(.*?)}/.exec(attrString); var blockAttrs = {}; if (!matches || !matches[1]) { console.log("WARNING: remark-cq unknown attrString", attrString); // hmm... return blockAttrs; } var pairs = splitNoParen(matches[1]); pairs.forEach(function(pair) { var kv = pair.split(/=\s*/); blockAttrs[kv[0]] = kv[1]; }); return blockAttrs; } __lastBlockAttributes = parseBlockAttributes(subvalue); if (__options.preserveEmptyLines) { return eat(subvalue)({ type: T_BREAK }); } else { return eat(subvalue); } } else { return; } } }
[ "function", "tokenizeBlockInlineAttributeList", "(", "eat", ",", "value", ",", "silent", ")", "{", "var", "self", "=", "this", ";", "var", "index", "=", "-", "1", ";", "var", "length", "=", "value", ".", "length", "+", "1", ";", "var", "subvalue", "=", "EMPTY", ";", "var", "character", ";", "var", "marker", ";", "var", "markerCount", ";", "var", "queue", ";", "// eat initial spacing", "while", "(", "++", "index", "<", "length", ")", "{", "character", "=", "value", ".", "charAt", "(", "index", ")", ";", "if", "(", "character", "!==", "C_TAB", "&&", "character", "!==", "C_SPACE", ")", "{", "break", ";", "}", "subvalue", "+=", "character", ";", "}", "if", "(", "value", ".", "charAt", "(", "index", ")", "!==", "C_LEFT_BRACE", ")", "{", "return", ";", "}", "// ignore {{ thing }}", "if", "(", "value", ".", "charAt", "(", "index", "+", "1", ")", "===", "C_LEFT_BRACE", ")", "{", "return", ";", "}", "// ignore {% thing %}", "if", "(", "value", ".", "charAt", "(", "index", "+", "1", ")", "===", "C_PERCENT", ")", "{", "return", ";", "}", "marker", "=", "character", ";", "subvalue", "+=", "character", ";", "markerCount", "=", "1", ";", "queue", "=", "EMPTY", ";", "while", "(", "++", "index", "<", "length", ")", "{", "character", "=", "value", ".", "charAt", "(", "index", ")", ";", "if", "(", "character", "!==", "C_RIGHT_BRACE", ")", "{", "// no newlines allowed in the attribute blocks", "if", "(", "character", "===", "C_NEWLINE", ")", "{", "return", ";", "}", "markerCount", "++", ";", "subvalue", "+=", "queue", "+", "character", ";", "queue", "=", "EMPTY", ";", "}", "else", "if", "(", "character", "===", "C_RIGHT_BRACE", ")", "{", "subvalue", "+=", "queue", "+", "C_RIGHT_BRACE", ";", "// eat trailing spacing because we don't even want this block to leave a linebreak in the output", "while", "(", "++", "index", "<", "length", ")", "{", "character", "=", "value", ".", "charAt", "(", "index", ")", ";", "if", "(", "character", "!==", "C_TAB", "&&", "character", "!==", "C_SPACE", "&&", "character", "!==", "C_NEWLINE", ")", "{", "break", ";", "}", "subvalue", "+=", "character", ";", "}", "function", "parseBlockAttributes", "(", "attrString", ")", "{", "// e.g. {lang='JavaScript',starting-line=4,crop-start-line=4,crop-end-line=26}", "var", "matches", "=", "/", "{(.*?)}", "/", ".", "exec", "(", "attrString", ")", ";", "var", "blockAttrs", "=", "{", "}", ";", "if", "(", "!", "matches", "||", "!", "matches", "[", "1", "]", ")", "{", "console", ".", "log", "(", "\"WARNING: remark-cq unknown attrString\"", ",", "attrString", ")", ";", "// hmm...", "return", "blockAttrs", ";", "}", "var", "pairs", "=", "splitNoParen", "(", "matches", "[", "1", "]", ")", ";", "pairs", ".", "forEach", "(", "function", "(", "pair", ")", "{", "var", "kv", "=", "pair", ".", "split", "(", "/", "=\\s*", "/", ")", ";", "blockAttrs", "[", "kv", "[", "0", "]", "]", "=", "kv", "[", "1", "]", ";", "}", ")", ";", "return", "blockAttrs", ";", "}", "__lastBlockAttributes", "=", "parseBlockAttributes", "(", "subvalue", ")", ";", "if", "(", "__options", ".", "preserveEmptyLines", ")", "{", "return", "eat", "(", "subvalue", ")", "(", "{", "type", ":", "T_BREAK", "}", ")", ";", "}", "else", "{", "return", "eat", "(", "subvalue", ")", ";", "}", "}", "else", "{", "return", ";", "}", "}", "}" ]
Tokenise a block inline attribute list @example tokenizeBlockInlineAttributeList(eat, '{lang=javascript}'); @param {function(string)} eat - Eater. @param {string} value - Rest of content. @param {boolean?} [silent] - Whether this is a dry run. @return {Node?|boolean} - `thematicBreak` node.
[ "Tokenise", "a", "block", "inline", "attribute", "list" ]
a9425c677b558f92f73a15d38ad39ac1d2deb189
https://github.com/fullstackio/cq/blob/a9425c677b558f92f73a15d38ad39ac1d2deb189/packages/remark-cq/index.js#L232-L333
41,558
fullstackio/cq
packages/cq/dist/engines/util.js
rangeExtents
function rangeExtents(ranges) { var start = Number.MAX_VALUE; var end = Number.MIN_VALUE; ranges.map(function (_ref) { var rs = _ref.start, re = _ref.end; start = Math.min(start, rs); end = Math.max(end, re); }); return { start: start, end: end }; }
javascript
function rangeExtents(ranges) { var start = Number.MAX_VALUE; var end = Number.MIN_VALUE; ranges.map(function (_ref) { var rs = _ref.start, re = _ref.end; start = Math.min(start, rs); end = Math.max(end, re); }); return { start: start, end: end }; }
[ "function", "rangeExtents", "(", "ranges", ")", "{", "var", "start", "=", "Number", ".", "MAX_VALUE", ";", "var", "end", "=", "Number", ".", "MIN_VALUE", ";", "ranges", ".", "map", "(", "function", "(", "_ref", ")", "{", "var", "rs", "=", "_ref", ".", "start", ",", "re", "=", "_ref", ".", "end", ";", "start", "=", "Math", ".", "min", "(", "start", ",", "rs", ")", ";", "end", "=", "Math", ".", "max", "(", "end", ",", "re", ")", ";", "}", ")", ";", "return", "{", "start", ":", "start", ",", "end", ":", "end", "}", ";", "}" ]
cq Engine Util Utility functions
[ "cq", "Engine", "Util" ]
a9425c677b558f92f73a15d38ad39ac1d2deb189
https://github.com/fullstackio/cq/blob/a9425c677b558f92f73a15d38ad39ac1d2deb189/packages/cq/dist/engines/util.js#L14-L25
41,559
alawatthe/MathLib
build/es6/Functn.js
function (f, a, b, fa, fc, fb, options) { var h = b - a, c = (a + b) / 2, fd = f((a + c) / 2), fe = f((c + b) / 2), Q1 = (h / 6) * (fa + 4 * fc + fb), Q2 = (h / 12) * (fa + 4 * fd + 2 * fc + 4 * fe + fb), Q = Q2 + (Q2 - Q1) / 15; options.calls = options.calls + 2; // Infinite or Not-a-Number function value encountered if (!isFinite(Q)) { options.warn = Math.max(options.warn, 3); return Q; } // Maximum function count exceeded; singularity likely if (options.calls > options.maxCalls) { options.warn = Math.max(options.warn, 2); return Q; } // Accuracy over this subinterval is acceptable if (Math.abs(Q2 - Q) <= options.tolerance) { return Q; } // Minimum step size reached; singularity possible if (Math.abs(h) < options.minStep || c === a || c === b) { options.warn = Math.max(options.warn, 1); return Q; } // Otherwise, divide the interval into two subintervals return quadstep(f, a, c, fa, fd, fc, options) + quadstep(f, c, b, fc, fe, fb, options); }
javascript
function (f, a, b, fa, fc, fb, options) { var h = b - a, c = (a + b) / 2, fd = f((a + c) / 2), fe = f((c + b) / 2), Q1 = (h / 6) * (fa + 4 * fc + fb), Q2 = (h / 12) * (fa + 4 * fd + 2 * fc + 4 * fe + fb), Q = Q2 + (Q2 - Q1) / 15; options.calls = options.calls + 2; // Infinite or Not-a-Number function value encountered if (!isFinite(Q)) { options.warn = Math.max(options.warn, 3); return Q; } // Maximum function count exceeded; singularity likely if (options.calls > options.maxCalls) { options.warn = Math.max(options.warn, 2); return Q; } // Accuracy over this subinterval is acceptable if (Math.abs(Q2 - Q) <= options.tolerance) { return Q; } // Minimum step size reached; singularity possible if (Math.abs(h) < options.minStep || c === a || c === b) { options.warn = Math.max(options.warn, 1); return Q; } // Otherwise, divide the interval into two subintervals return quadstep(f, a, c, fa, fd, fc, options) + quadstep(f, c, b, fc, fe, fb, options); }
[ "function", "(", "f", ",", "a", ",", "b", ",", "fa", ",", "fc", ",", "fb", ",", "options", ")", "{", "var", "h", "=", "b", "-", "a", ",", "c", "=", "(", "a", "+", "b", ")", "/", "2", ",", "fd", "=", "f", "(", "(", "a", "+", "c", ")", "/", "2", ")", ",", "fe", "=", "f", "(", "(", "c", "+", "b", ")", "/", "2", ")", ",", "Q1", "=", "(", "h", "/", "6", ")", "*", "(", "fa", "+", "4", "*", "fc", "+", "fb", ")", ",", "Q2", "=", "(", "h", "/", "12", ")", "*", "(", "fa", "+", "4", "*", "fd", "+", "2", "*", "fc", "+", "4", "*", "fe", "+", "fb", ")", ",", "Q", "=", "Q2", "+", "(", "Q2", "-", "Q1", ")", "/", "15", ";", "options", ".", "calls", "=", "options", ".", "calls", "+", "2", ";", "// Infinite or Not-a-Number function value encountered", "if", "(", "!", "isFinite", "(", "Q", ")", ")", "{", "options", ".", "warn", "=", "Math", ".", "max", "(", "options", ".", "warn", ",", "3", ")", ";", "return", "Q", ";", "}", "// Maximum function count exceeded; singularity likely", "if", "(", "options", ".", "calls", ">", "options", ".", "maxCalls", ")", "{", "options", ".", "warn", "=", "Math", ".", "max", "(", "options", ".", "warn", ",", "2", ")", ";", "return", "Q", ";", "}", "// Accuracy over this subinterval is acceptable", "if", "(", "Math", ".", "abs", "(", "Q2", "-", "Q", ")", "<=", "options", ".", "tolerance", ")", "{", "return", "Q", ";", "}", "// Minimum step size reached; singularity possible", "if", "(", "Math", ".", "abs", "(", "h", ")", "<", "options", ".", "minStep", "||", "c", "===", "a", "||", "c", "===", "b", ")", "{", "options", ".", "warn", "=", "Math", ".", "max", "(", "options", ".", "warn", ",", "1", ")", ";", "return", "Q", ";", "}", "// Otherwise, divide the interval into two subintervals", "return", "quadstep", "(", "f", ",", "a", ",", "c", ",", "fa", ",", "fd", ",", "fc", ",", "options", ")", "+", "quadstep", "(", "f", ",", "c", ",", "b", ",", "fc", ",", "fe", ",", "fb", ",", "options", ")", ";", "}" ]
Recursive function for the quad method
[ "Recursive", "function", "for", "the", "quad", "method" ]
43dbd35263da672bd2ca41f93dc447b60da9bdac
https://github.com/alawatthe/MathLib/blob/43dbd35263da672bd2ca41f93dc447b60da9bdac/build/es6/Functn.js#L1120-L1150
41,560
wbyoung/azul
lib/relations/has_one.js
function() { this._super.apply(this, arguments); if (this._options.through) { this._options.through = inflection.singularize(this._options.through); } }
javascript
function() { this._super.apply(this, arguments); if (this._options.through) { this._options.through = inflection.singularize(this._options.through); } }
[ "function", "(", ")", "{", "this", ".", "_super", ".", "apply", "(", "this", ",", "arguments", ")", ";", "if", "(", "this", ".", "_options", ".", "through", ")", "{", "this", ".", "_options", ".", "through", "=", "inflection", ".", "singularize", "(", "this", ".", "_options", ".", "through", ")", ";", "}", "}" ]
Create a HasOne relation. @protected @constructor HasOne @see {@link Database#hasOne}
[ "Create", "a", "HasOne", "relation", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/has_one.js#L51-L57
41,561
wbyoung/azul
lib/relations/has_one.js
function(instance, value) { var collection = this._getCollectionCache(instance); var current = collection && collection[0]; if (current) { this.removeObjects(instance, current); } if (value) { this.addObjects(instance, value); } }
javascript
function(instance, value) { var collection = this._getCollectionCache(instance); var current = collection && collection[0]; if (current) { this.removeObjects(instance, current); } if (value) { this.addObjects(instance, value); } }
[ "function", "(", "instance", ",", "value", ")", "{", "var", "collection", "=", "this", ".", "_getCollectionCache", "(", "instance", ")", ";", "var", "current", "=", "collection", "&&", "collection", "[", "0", "]", ";", "if", "(", "current", ")", "{", "this", ".", "removeObjects", "(", "instance", ",", "current", ")", ";", "}", "if", "(", "value", ")", "{", "this", ".", "addObjects", "(", "instance", ",", "value", ")", ";", "}", "}" ]
The item property setter for this relation. This property allows altering the associated object of a specific model in a given relation. It is accessible on an individual model via assignment with `<singular>` and via `set<Singular>`. For instance, a user that has one blog would cause this method to get triggered via `user.blog = '...'` or `user.setBlog`. The naming conventions are set forth in {@link HasOne#overrides}. @method @protected @param {Model} instance The model instance on which to operate. @see {@link BaseRelation#methods}
[ "The", "item", "property", "setter", "for", "this", "relation", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/has_one.js#L99-L104
41,562
DFFR-NT/dffrnt.route
lib/routes.js
AddDocuments
function AddDocuments () { // Create Helpdoc Route HLP .all("/", ReqHandle.Valid(true), GetHelp); API .use('/docs', HLP); }
javascript
function AddDocuments () { // Create Helpdoc Route HLP .all("/", ReqHandle.Valid(true), GetHelp); API .use('/docs', HLP); }
[ "function", "AddDocuments", "(", ")", "{", "// Create Helpdoc Route", "HLP", ".", "all", "(", "\"/\"", ",", "ReqHandle", ".", "Valid", "(", "true", ")", ",", "GetHelp", ")", ";", "API", ".", "use", "(", "'/docs'", ",", "HLP", ")", ";", "}" ]
Endpoints for when API documentation is requested or during API errors
[ "Endpoints", "for", "when", "API", "documentation", "is", "requested", "or", "during", "API", "errors" ]
3b0ff9510de0e458a373e9c0e260d5ed6ff8b249
https://github.com/DFFR-NT/dffrnt.route/blob/3b0ff9510de0e458a373e9c0e260d5ed6ff8b249/lib/routes.js#L655-L659
41,563
bigeasy/procession
splitter.js
Splitter
function Splitter (queue, splits) { this._shifter = queue.shifter() this._map = {} this._array = [] for (var key in splits) { var queue = new Procession var split = { selector: splits[key], queue: queue, shifter: queue.shifter() } this._map[key] = split this._array.push(split) } }
javascript
function Splitter (queue, splits) { this._shifter = queue.shifter() this._map = {} this._array = [] for (var key in splits) { var queue = new Procession var split = { selector: splits[key], queue: queue, shifter: queue.shifter() } this._map[key] = split this._array.push(split) } }
[ "function", "Splitter", "(", "queue", ",", "splits", ")", "{", "this", ".", "_shifter", "=", "queue", ".", "shifter", "(", ")", "this", ".", "_map", "=", "{", "}", "this", ".", "_array", "=", "[", "]", "for", "(", "var", "key", "in", "splits", ")", "{", "var", "queue", "=", "new", "Procession", "var", "split", "=", "{", "selector", ":", "splits", "[", "key", "]", ",", "queue", ":", "queue", ",", "shifter", ":", "queue", ".", "shifter", "(", ")", "}", "this", ".", "_map", "[", "key", "]", "=", "split", "this", ".", "_array", ".", "push", "(", "split", ")", "}", "}" ]
Create a splitter that will split the given queue.
[ "Create", "a", "splitter", "that", "will", "split", "the", "given", "queue", "." ]
c8ea48a72a55cbe8b9b153e23ffcef9902e67038
https://github.com/bigeasy/procession/blob/c8ea48a72a55cbe8b9b153e23ffcef9902e67038/splitter.js#L10-L24
41,564
LeisureLink/magicbus
lib/subscriber.js
Subscriber
function Subscriber(consumer, eventDispatcher, logger, events) { assert.object(consumer, 'consumer'); assert.object(eventDispatcher, 'eventDispatcher'); assert.object(logger, 'logger'); assert.object(events, 'events'); /** * Internal message handler, passes message to event dispatcher * * @private * @method * @param {Any} data - message payload * @param {Array} messageTypes - message types * @param {Object} msg - raw message */ const internalHandler = (data, messageTypes, msg) => { logger.debug('Subscriber received message with types ' + JSON.stringify(messageTypes) + ', handing off to event dispatcher.'); return eventDispatcher.dispatch(messageTypes, data, msg) .catch(function (err){ events.emit('unhandled-error', { data: data, messageTypes: messageTypes, message: msg, error: err }); logger.error('Error during message dispatch', err); return Promise.reject(err); }) .then(function(executed){ if (!executed){ events.emit('unhandled-event', { data: data, messageTypes: messageTypes, message: msg }); return Promise.reject(new Error('No handler registered for ' + messageTypes)); } return Promise.resolve(); }); }; /** * Subscribe to an event * * @public * @method * @param {String} eventName - name of event (required) * @param {Subscriber.handlerCallback} handler - the handler to be called with the message */ const on = (eventName, handler) => { eventDispatcher.on(eventName, handler); }; /** * Subscribe to an event, for one iteration only * * @public * @method * @param {String} eventName - name of event (required) * @param {Subscriber.handlerCallback} handler - the handler to be called with the message * @returns {Promise} a promise that is fulfilled when the event has been fired - useful for automated testing of handler behavior */ const once = (eventName, handler) => { return eventDispatcher.once(eventName, handler); }; /** * Use a middleware function * * @public * @method * @param {Function} middleware - middleware to run {@see middleware.contract} */ const use = (middleware) => { consumer.use(middleware); }; /** * Start consuming events * * @param {Object} options - details in consuming from the queue * @param {Number} options.limit - the channel prefetch limit * @param {bool} options.noBatch - if true, ack/nack/reject operations will execute immediately and not be batched * @param {bool} options.noAck - if true, the broker won't expect an acknowledgement of messages delivered to this consumer; i.e., it will dequeue messages as soon as they've been sent down the wire. Defaults to false (i.e., you will be expected to acknowledge messages). * @param {String} options.consumerTag - a name which the server will use to distinguish message deliveries for the consumer; mustn't be already in use on the channel. It's usually easier to omit this, in which case the server will create a random name and supply it in the reply. * @param {bool} options.exclusive - if true, the broker won't let anyone else consume from this queue; if there already is a consumer, there goes your channel (so usually only useful if you've made a 'private' queue by letting the server choose its name). * @param {Number} options.priority - gives a priority to the consumer; higher priority consumers get messages in preference to lower priority consumers. See this RabbitMQ extension's documentation * @param {Object} options.arguments - arbitrary arguments. Go to town. * @public * @method */ const startSubscription = (options) => { return consumer.startConsuming(internalHandler, options); }; /** * Gets the route being used for consuming * * @public * @method * @returns {Object} details of the route */ const getRoute = () => { return consumer.getRoute(); }; /** * Purges messages from a route's queue. Useful for testing, to ensure your queue is empty before subscribing * * @public * @method * @returns {Promise} a promise that is fulfilled when the queue has been purged */ const purgeQueue = () => { return consumer.purgeQueue(); }; return { on: on, once: once, use: use, startSubscription: startSubscription, getRoute: getRoute, purgeQueue: purgeQueue }; }
javascript
function Subscriber(consumer, eventDispatcher, logger, events) { assert.object(consumer, 'consumer'); assert.object(eventDispatcher, 'eventDispatcher'); assert.object(logger, 'logger'); assert.object(events, 'events'); /** * Internal message handler, passes message to event dispatcher * * @private * @method * @param {Any} data - message payload * @param {Array} messageTypes - message types * @param {Object} msg - raw message */ const internalHandler = (data, messageTypes, msg) => { logger.debug('Subscriber received message with types ' + JSON.stringify(messageTypes) + ', handing off to event dispatcher.'); return eventDispatcher.dispatch(messageTypes, data, msg) .catch(function (err){ events.emit('unhandled-error', { data: data, messageTypes: messageTypes, message: msg, error: err }); logger.error('Error during message dispatch', err); return Promise.reject(err); }) .then(function(executed){ if (!executed){ events.emit('unhandled-event', { data: data, messageTypes: messageTypes, message: msg }); return Promise.reject(new Error('No handler registered for ' + messageTypes)); } return Promise.resolve(); }); }; /** * Subscribe to an event * * @public * @method * @param {String} eventName - name of event (required) * @param {Subscriber.handlerCallback} handler - the handler to be called with the message */ const on = (eventName, handler) => { eventDispatcher.on(eventName, handler); }; /** * Subscribe to an event, for one iteration only * * @public * @method * @param {String} eventName - name of event (required) * @param {Subscriber.handlerCallback} handler - the handler to be called with the message * @returns {Promise} a promise that is fulfilled when the event has been fired - useful for automated testing of handler behavior */ const once = (eventName, handler) => { return eventDispatcher.once(eventName, handler); }; /** * Use a middleware function * * @public * @method * @param {Function} middleware - middleware to run {@see middleware.contract} */ const use = (middleware) => { consumer.use(middleware); }; /** * Start consuming events * * @param {Object} options - details in consuming from the queue * @param {Number} options.limit - the channel prefetch limit * @param {bool} options.noBatch - if true, ack/nack/reject operations will execute immediately and not be batched * @param {bool} options.noAck - if true, the broker won't expect an acknowledgement of messages delivered to this consumer; i.e., it will dequeue messages as soon as they've been sent down the wire. Defaults to false (i.e., you will be expected to acknowledge messages). * @param {String} options.consumerTag - a name which the server will use to distinguish message deliveries for the consumer; mustn't be already in use on the channel. It's usually easier to omit this, in which case the server will create a random name and supply it in the reply. * @param {bool} options.exclusive - if true, the broker won't let anyone else consume from this queue; if there already is a consumer, there goes your channel (so usually only useful if you've made a 'private' queue by letting the server choose its name). * @param {Number} options.priority - gives a priority to the consumer; higher priority consumers get messages in preference to lower priority consumers. See this RabbitMQ extension's documentation * @param {Object} options.arguments - arbitrary arguments. Go to town. * @public * @method */ const startSubscription = (options) => { return consumer.startConsuming(internalHandler, options); }; /** * Gets the route being used for consuming * * @public * @method * @returns {Object} details of the route */ const getRoute = () => { return consumer.getRoute(); }; /** * Purges messages from a route's queue. Useful for testing, to ensure your queue is empty before subscribing * * @public * @method * @returns {Promise} a promise that is fulfilled when the queue has been purged */ const purgeQueue = () => { return consumer.purgeQueue(); }; return { on: on, once: once, use: use, startSubscription: startSubscription, getRoute: getRoute, purgeQueue: purgeQueue }; }
[ "function", "Subscriber", "(", "consumer", ",", "eventDispatcher", ",", "logger", ",", "events", ")", "{", "assert", ".", "object", "(", "consumer", ",", "'consumer'", ")", ";", "assert", ".", "object", "(", "eventDispatcher", ",", "'eventDispatcher'", ")", ";", "assert", ".", "object", "(", "logger", ",", "'logger'", ")", ";", "assert", ".", "object", "(", "events", ",", "'events'", ")", ";", "/**\n * Internal message handler, passes message to event dispatcher\n *\n * @private\n * @method\n * @param {Any} data - message payload\n * @param {Array} messageTypes - message types\n * @param {Object} msg - raw message\n */", "const", "internalHandler", "=", "(", "data", ",", "messageTypes", ",", "msg", ")", "=>", "{", "logger", ".", "debug", "(", "'Subscriber received message with types '", "+", "JSON", ".", "stringify", "(", "messageTypes", ")", "+", "', handing off to event dispatcher.'", ")", ";", "return", "eventDispatcher", ".", "dispatch", "(", "messageTypes", ",", "data", ",", "msg", ")", ".", "catch", "(", "function", "(", "err", ")", "{", "events", ".", "emit", "(", "'unhandled-error'", ",", "{", "data", ":", "data", ",", "messageTypes", ":", "messageTypes", ",", "message", ":", "msg", ",", "error", ":", "err", "}", ")", ";", "logger", ".", "error", "(", "'Error during message dispatch'", ",", "err", ")", ";", "return", "Promise", ".", "reject", "(", "err", ")", ";", "}", ")", ".", "then", "(", "function", "(", "executed", ")", "{", "if", "(", "!", "executed", ")", "{", "events", ".", "emit", "(", "'unhandled-event'", ",", "{", "data", ":", "data", ",", "messageTypes", ":", "messageTypes", ",", "message", ":", "msg", "}", ")", ";", "return", "Promise", ".", "reject", "(", "new", "Error", "(", "'No handler registered for '", "+", "messageTypes", ")", ")", ";", "}", "return", "Promise", ".", "resolve", "(", ")", ";", "}", ")", ";", "}", ";", "/**\n * Subscribe to an event\n *\n * @public\n * @method\n * @param {String} eventName - name of event (required)\n * @param {Subscriber.handlerCallback} handler - the handler to be called with the message\n */", "const", "on", "=", "(", "eventName", ",", "handler", ")", "=>", "{", "eventDispatcher", ".", "on", "(", "eventName", ",", "handler", ")", ";", "}", ";", "/**\n * Subscribe to an event, for one iteration only\n *\n * @public\n * @method\n * @param {String} eventName - name of event (required)\n * @param {Subscriber.handlerCallback} handler - the handler to be called with the message\n * @returns {Promise} a promise that is fulfilled when the event has been fired - useful for automated testing of handler behavior\n */", "const", "once", "=", "(", "eventName", ",", "handler", ")", "=>", "{", "return", "eventDispatcher", ".", "once", "(", "eventName", ",", "handler", ")", ";", "}", ";", "/**\n * Use a middleware function\n *\n * @public\n * @method\n * @param {Function} middleware - middleware to run {@see middleware.contract}\n */", "const", "use", "=", "(", "middleware", ")", "=>", "{", "consumer", ".", "use", "(", "middleware", ")", ";", "}", ";", "/**\n * Start consuming events\n *\n * @param {Object} options - details in consuming from the queue\n * @param {Number} options.limit - the channel prefetch limit\n * @param {bool} options.noBatch - if true, ack/nack/reject operations will execute immediately and not be batched\n * @param {bool} options.noAck - if true, the broker won't expect an acknowledgement of messages delivered to this consumer; i.e., it will dequeue messages as soon as they've been sent down the wire. Defaults to false (i.e., you will be expected to acknowledge messages).\n * @param {String} options.consumerTag - a name which the server will use to distinguish message deliveries for the consumer; mustn't be already in use on the channel. It's usually easier to omit this, in which case the server will create a random name and supply it in the reply.\n * @param {bool} options.exclusive - if true, the broker won't let anyone else consume from this queue; if there already is a consumer, there goes your channel (so usually only useful if you've made a 'private' queue by letting the server choose its name).\n * @param {Number} options.priority - gives a priority to the consumer; higher priority consumers get messages in preference to lower priority consumers. See this RabbitMQ extension's documentation\n * @param {Object} options.arguments - arbitrary arguments. Go to town.\n * @public\n * @method\n */", "const", "startSubscription", "=", "(", "options", ")", "=>", "{", "return", "consumer", ".", "startConsuming", "(", "internalHandler", ",", "options", ")", ";", "}", ";", "/**\n * Gets the route being used for consuming\n *\n * @public\n * @method\n * @returns {Object} details of the route\n */", "const", "getRoute", "=", "(", ")", "=>", "{", "return", "consumer", ".", "getRoute", "(", ")", ";", "}", ";", "/**\n * Purges messages from a route's queue. Useful for testing, to ensure your queue is empty before subscribing\n *\n * @public\n * @method\n * @returns {Promise} a promise that is fulfilled when the queue has been purged\n */", "const", "purgeQueue", "=", "(", ")", "=>", "{", "return", "consumer", ".", "purgeQueue", "(", ")", ";", "}", ";", "return", "{", "on", ":", "on", ",", "once", ":", "once", ",", "use", ":", "use", ",", "startSubscription", ":", "startSubscription", ",", "getRoute", ":", "getRoute", ",", "purgeQueue", ":", "purgeQueue", "}", ";", "}" ]
Handles consumption of event messages from the bus @public @constructor @param {Object} consumer - instance of the {@link Consumer} class @param {Object} eventDispatcher - instance of the {@link EventDispatcher} class @param {Object} logger - the logger @param {EventEmitter} events - the event emitter for unhandled exception events
[ "Handles", "consumption", "of", "event", "messages", "from", "the", "bus" ]
0370c38ebb8c7917cfd3894263d734aefc2d3d29
https://github.com/LeisureLink/magicbus/blob/0370c38ebb8c7917cfd3894263d734aefc2d3d29/lib/subscriber.js#L16-L142
41,565
whitfin/dep-validate
lib/dep-validate.js
format
function format(results) { if (_isFormatted(results)) { return results; } var dependencyErrors = results.dependencies || []; var devDependencyErrors = results.devDependencies || []; var formattedErrors = { }; formattedErrors.dependencies = dependencyErrors.length ? _formatErrors('Dependencies', dependencyErrors) : dependencyErrors; formattedErrors.devDependencies = devDependencyErrors.length ? _formatErrors('Dev Dependencies', devDependencyErrors) : devDependencyErrors; return formattedErrors; }
javascript
function format(results) { if (_isFormatted(results)) { return results; } var dependencyErrors = results.dependencies || []; var devDependencyErrors = results.devDependencies || []; var formattedErrors = { }; formattedErrors.dependencies = dependencyErrors.length ? _formatErrors('Dependencies', dependencyErrors) : dependencyErrors; formattedErrors.devDependencies = devDependencyErrors.length ? _formatErrors('Dev Dependencies', devDependencyErrors) : devDependencyErrors; return formattedErrors; }
[ "function", "format", "(", "results", ")", "{", "if", "(", "_isFormatted", "(", "results", ")", ")", "{", "return", "results", ";", "}", "var", "dependencyErrors", "=", "results", ".", "dependencies", "||", "[", "]", ";", "var", "devDependencyErrors", "=", "results", ".", "devDependencies", "||", "[", "]", ";", "var", "formattedErrors", "=", "{", "}", ";", "formattedErrors", ".", "dependencies", "=", "dependencyErrors", ".", "length", "?", "_formatErrors", "(", "'Dependencies'", ",", "dependencyErrors", ")", ":", "dependencyErrors", ";", "formattedErrors", ".", "devDependencies", "=", "devDependencyErrors", ".", "length", "?", "_formatErrors", "(", "'Dev Dependencies'", ",", "devDependencyErrors", ")", ":", "devDependencyErrors", ";", "return", "formattedErrors", ";", "}" ]
Formats an Object of results. The Object should be of the same form as the result of calling #validate, as the formatter expects the values to be piped straight through. @param results our Object containing validation results. @returns {{dependencies: Array, devDependencies: Array}}.
[ "Formats", "an", "Object", "of", "results", "." ]
2f334d1c0a6e9f93429ce34ca165e28c1c072c1b
https://github.com/whitfin/dep-validate/blob/2f334d1c0a6e9f93429ce34ca165e28c1c072c1b/lib/dep-validate.js#L62-L81
41,566
whitfin/dep-validate
lib/dep-validate.js
hasErrors
function hasErrors(results) { return (results.dependencies && results.dependencies.length) || (results.devDependencies && results.devDependencies.length) }
javascript
function hasErrors(results) { return (results.dependencies && results.dependencies.length) || (results.devDependencies && results.devDependencies.length) }
[ "function", "hasErrors", "(", "results", ")", "{", "return", "(", "results", ".", "dependencies", "&&", "results", ".", "dependencies", ".", "length", ")", "||", "(", "results", ".", "devDependencies", "&&", "results", ".", "devDependencies", ".", "length", ")", "}" ]
Detects if a results Object contains any errors. @param results our Object containing validation results. @returns true if errors are contained in the results.
[ "Detects", "if", "a", "results", "Object", "contains", "any", "errors", "." ]
2f334d1c0a6e9f93429ce34ca165e28c1c072c1b
https://github.com/whitfin/dep-validate/blob/2f334d1c0a6e9f93429ce34ca165e28c1c072c1b/lib/dep-validate.js#L89-L92
41,567
whitfin/dep-validate
lib/dep-validate.js
gulp
function gulp(opts) { opts = opts || {}; var failOnError = opts['failOnError'] || false; var interimFiles = []; var failedValidations = []; return Through( function (file) { interimFiles.push(file.path); this.queue(file); }, function () { var baseFile = opts.packageFile; interimFiles.forEach(function (file) { opts.packageFile = file; var results = validate(opts); if (hasErrors(results)) { failedValidations.push(file); log(results); } }); opts.packageFile = baseFile; if (failOnError && failedValidations.length) { this.emit('error', new PluginError('dep-validate', 'Unable to validate dependencies')); } else { this.emit('end'); } } ); }
javascript
function gulp(opts) { opts = opts || {}; var failOnError = opts['failOnError'] || false; var interimFiles = []; var failedValidations = []; return Through( function (file) { interimFiles.push(file.path); this.queue(file); }, function () { var baseFile = opts.packageFile; interimFiles.forEach(function (file) { opts.packageFile = file; var results = validate(opts); if (hasErrors(results)) { failedValidations.push(file); log(results); } }); opts.packageFile = baseFile; if (failOnError && failedValidations.length) { this.emit('error', new PluginError('dep-validate', 'Unable to validate dependencies')); } else { this.emit('end'); } } ); }
[ "function", "gulp", "(", "opts", ")", "{", "opts", "=", "opts", "||", "{", "}", ";", "var", "failOnError", "=", "opts", "[", "'failOnError'", "]", "||", "false", ";", "var", "interimFiles", "=", "[", "]", ";", "var", "failedValidations", "=", "[", "]", ";", "return", "Through", "(", "function", "(", "file", ")", "{", "interimFiles", ".", "push", "(", "file", ".", "path", ")", ";", "this", ".", "queue", "(", "file", ")", ";", "}", ",", "function", "(", ")", "{", "var", "baseFile", "=", "opts", ".", "packageFile", ";", "interimFiles", ".", "forEach", "(", "function", "(", "file", ")", "{", "opts", ".", "packageFile", "=", "file", ";", "var", "results", "=", "validate", "(", "opts", ")", ";", "if", "(", "hasErrors", "(", "results", ")", ")", "{", "failedValidations", ".", "push", "(", "file", ")", ";", "log", "(", "results", ")", ";", "}", "}", ")", ";", "opts", ".", "packageFile", "=", "baseFile", ";", "if", "(", "failOnError", "&&", "failedValidations", ".", "length", ")", "{", "this", ".", "emit", "(", "'error'", ",", "new", "PluginError", "(", "'dep-validate'", ",", "'Unable to validate dependencies'", ")", ")", ";", "}", "else", "{", "this", ".", "emit", "(", "'end'", ")", ";", "}", "}", ")", ";", "}" ]
Returns a Transform Stream for use with Gulp. @param opts an options Object (see README.md). @returns a Stream instance for Gulp use.
[ "Returns", "a", "Transform", "Stream", "for", "use", "with", "Gulp", "." ]
2f334d1c0a6e9f93429ce34ca165e28c1c072c1b
https://github.com/whitfin/dep-validate/blob/2f334d1c0a6e9f93429ce34ca165e28c1c072c1b/lib/dep-validate.js#L100-L135
41,568
whitfin/dep-validate
lib/dep-validate.js
log
function log(results, stream) { stream = stream || process.stdout; if (results instanceof Error) { results = results.meta; } if (!_isFormatted(results)) { results = format(results); } stream.write(_join(results)); }
javascript
function log(results, stream) { stream = stream || process.stdout; if (results instanceof Error) { results = results.meta; } if (!_isFormatted(results)) { results = format(results); } stream.write(_join(results)); }
[ "function", "log", "(", "results", ",", "stream", ")", "{", "stream", "=", "stream", "||", "process", ".", "stdout", ";", "if", "(", "results", "instanceof", "Error", ")", "{", "results", "=", "results", ".", "meta", ";", "}", "if", "(", "!", "_isFormatted", "(", "results", ")", ")", "{", "results", "=", "format", "(", "results", ")", ";", "}", "stream", ".", "write", "(", "_join", "(", "results", ")", ")", ";", "}" ]
Logs a results Object out to a given write stream. The stream defaults to `process.stdout`, and results will be formatted on-demand if needed. @param results our Object containing validation results. @param stream a write stream to write the log to.
[ "Logs", "a", "results", "Object", "out", "to", "a", "given", "write", "stream", "." ]
2f334d1c0a6e9f93429ce34ca165e28c1c072c1b
https://github.com/whitfin/dep-validate/blob/2f334d1c0a6e9f93429ce34ca165e28c1c072c1b/lib/dep-validate.js#L146-L158
41,569
ofidj/fidj
.todo/miapp.tools.array.js
removeKeyFromList
function removeKeyFromList(list, key, value) { for (var i = list.length - 1; i >= 0; i--) { if (list[i][key] == value) { return list.splice(i, 1); // remove from array } } return false; }
javascript
function removeKeyFromList(list, key, value) { for (var i = list.length - 1; i >= 0; i--) { if (list[i][key] == value) { return list.splice(i, 1); // remove from array } } return false; }
[ "function", "removeKeyFromList", "(", "list", ",", "key", ",", "value", ")", "{", "for", "(", "var", "i", "=", "list", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "list", "[", "i", "]", "[", "key", "]", "==", "value", ")", "{", "return", "list", ".", "splice", "(", "i", ",", "1", ")", ";", "// remove from array", "}", "}", "return", "false", ";", "}" ]
Remove from list the last object having the same key attribute as value @param list Array of objects having key attribute comparable to value @param {string} key @param value @return {*} Array of deleted item or false
[ "Remove", "from", "list", "the", "last", "object", "having", "the", "same", "key", "attribute", "as", "value" ]
e57ebece54ee68211d43802a8e0feeef098d3e36
https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.array.js#L146-L153
41,570
ofidj/fidj
.todo/miapp.tools.array.js
replaceKeyFromList
function replaceKeyFromList(list, key, value, object) { for (var i = list.length - 1; i >= 0; i--) { if (list[i][key] == value) { return list.splice(i, 1, object); // remove from array and replace by the new object } } return false; }
javascript
function replaceKeyFromList(list, key, value, object) { for (var i = list.length - 1; i >= 0; i--) { if (list[i][key] == value) { return list.splice(i, 1, object); // remove from array and replace by the new object } } return false; }
[ "function", "replaceKeyFromList", "(", "list", ",", "key", ",", "value", ",", "object", ")", "{", "for", "(", "var", "i", "=", "list", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "list", "[", "i", "]", "[", "key", "]", "==", "value", ")", "{", "return", "list", ".", "splice", "(", "i", ",", "1", ",", "object", ")", ";", "// remove from array and replace by the new object", "}", "}", "return", "false", ";", "}" ]
Replace in list the last object having the same key attribute as value @param list Array of objects having key attribute comparable to value @param {string} key @param value @param object New object replacing the old one @return {*} Array of replaced item or false
[ "Replace", "in", "list", "the", "last", "object", "having", "the", "same", "key", "attribute", "as", "value" ]
e57ebece54ee68211d43802a8e0feeef098d3e36
https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.array.js#L164-L171
41,571
ofidj/fidj
.todo/miapp.tools.array.js
addKeyToList
function addKeyToList(list, key, object) { for (var i = list.length - 1; i >= 0; i--) { if (list[i][key] == object[key]) { return false; } } list.push(object); return true; }
javascript
function addKeyToList(list, key, object) { for (var i = list.length - 1; i >= 0; i--) { if (list[i][key] == object[key]) { return false; } } list.push(object); return true; }
[ "function", "addKeyToList", "(", "list", ",", "key", ",", "object", ")", "{", "for", "(", "var", "i", "=", "list", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "list", "[", "i", "]", "[", "key", "]", "==", "object", "[", "key", "]", ")", "{", "return", "false", ";", "}", "}", "list", ".", "push", "(", "object", ")", ";", "return", "true", ";", "}" ]
Add in list the argument object if none has the same key attribute @param list Array of objects having key attribute @param {string} key @param object New object to add @return {boolean} True if added or false if already exists in list
[ "Add", "in", "list", "the", "argument", "object", "if", "none", "has", "the", "same", "key", "attribute" ]
e57ebece54ee68211d43802a8e0feeef098d3e36
https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.array.js#L181-L189
41,572
ofidj/fidj
.todo/miapp.tools.array.js
getKeyFromList
function getKeyFromList(list, key, value) { for (var i = list.length - 1; i >= 0; i--) { if (list[i][key] == value) { return list[i]; } } return false; }
javascript
function getKeyFromList(list, key, value) { for (var i = list.length - 1; i >= 0; i--) { if (list[i][key] == value) { return list[i]; } } return false; }
[ "function", "getKeyFromList", "(", "list", ",", "key", ",", "value", ")", "{", "for", "(", "var", "i", "=", "list", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "list", "[", "i", "]", "[", "key", "]", "==", "value", ")", "{", "return", "list", "[", "i", "]", ";", "}", "}", "return", "false", ";", "}" ]
Check if one object in list has the same key attribute as value and return it @param list Array of objects having key attribute comparable to value @param {string} key @param value @return {*} Object if exists or false if none exists in list
[ "Check", "if", "one", "object", "in", "list", "has", "the", "same", "key", "attribute", "as", "value", "and", "return", "it" ]
e57ebece54ee68211d43802a8e0feeef098d3e36
https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.array.js#L199-L206
41,573
ofidj/fidj
.todo/miapp.tools.array.js
removeSubKeyFromList
function removeSubKeyFromList(list, sub, key, value) { for (var i = list.length - 1; i >= 0; i--) { if (a4p.isDefined(list[i][sub]) && (list[i][sub][key] == value)) { return list.splice(i, 1); // remove from array } } return false; }
javascript
function removeSubKeyFromList(list, sub, key, value) { for (var i = list.length - 1; i >= 0; i--) { if (a4p.isDefined(list[i][sub]) && (list[i][sub][key] == value)) { return list.splice(i, 1); // remove from array } } return false; }
[ "function", "removeSubKeyFromList", "(", "list", ",", "sub", ",", "key", ",", "value", ")", "{", "for", "(", "var", "i", "=", "list", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "a4p", ".", "isDefined", "(", "list", "[", "i", "]", "[", "sub", "]", ")", "&&", "(", "list", "[", "i", "]", "[", "sub", "]", "[", "key", "]", "==", "value", ")", ")", "{", "return", "list", ".", "splice", "(", "i", ",", "1", ")", ";", "// remove from array", "}", "}", "return", "false", ";", "}" ]
Remove from list the last object having the same sub.key attribute as value @param list Array of objects having sub.key attribute comparable to value @param {string} sub @param {string} key @param value @return {*} Array of deleted item or false
[ "Remove", "from", "list", "the", "last", "object", "having", "the", "same", "sub", ".", "key", "attribute", "as", "value" ]
e57ebece54ee68211d43802a8e0feeef098d3e36
https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.array.js#L217-L224
41,574
ofidj/fidj
.todo/miapp.tools.array.js
replaceSubKeyFromList
function replaceSubKeyFromList(list, sub, key, value, object) { for (var i = list.length - 1; i >= 0; i--) { if (a4p.isDefined(list[i][sub]) && (list[i][sub][key] == value)) { return list.splice(i, 1, object); // remove from array and replace by the new object } } return false; }
javascript
function replaceSubKeyFromList(list, sub, key, value, object) { for (var i = list.length - 1; i >= 0; i--) { if (a4p.isDefined(list[i][sub]) && (list[i][sub][key] == value)) { return list.splice(i, 1, object); // remove from array and replace by the new object } } return false; }
[ "function", "replaceSubKeyFromList", "(", "list", ",", "sub", ",", "key", ",", "value", ",", "object", ")", "{", "for", "(", "var", "i", "=", "list", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "a4p", ".", "isDefined", "(", "list", "[", "i", "]", "[", "sub", "]", ")", "&&", "(", "list", "[", "i", "]", "[", "sub", "]", "[", "key", "]", "==", "value", ")", ")", "{", "return", "list", ".", "splice", "(", "i", ",", "1", ",", "object", ")", ";", "// remove from array and replace by the new object", "}", "}", "return", "false", ";", "}" ]
Replace in list the last object having the same sub.key attribute as value @param list Array of objects having sub.key attribute comparable to value @param {string} sub @param {string} key @param value @param object New object replacing the old one @return {*} Array of replaced item or false
[ "Replace", "in", "list", "the", "last", "object", "having", "the", "same", "sub", ".", "key", "attribute", "as", "value" ]
e57ebece54ee68211d43802a8e0feeef098d3e36
https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.array.js#L236-L243
41,575
ofidj/fidj
.todo/miapp.tools.array.js
addSubKeyToList
function addSubKeyToList(list, sub, key, object) { for (var i = list.length - 1; i >= 0; i--) { if (a4p.isDefined(list[i][sub]) && (list[i][sub][key] == object[sub][key])) { return false; } } list.push(object); return true; }
javascript
function addSubKeyToList(list, sub, key, object) { for (var i = list.length - 1; i >= 0; i--) { if (a4p.isDefined(list[i][sub]) && (list[i][sub][key] == object[sub][key])) { return false; } } list.push(object); return true; }
[ "function", "addSubKeyToList", "(", "list", ",", "sub", ",", "key", ",", "object", ")", "{", "for", "(", "var", "i", "=", "list", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "a4p", ".", "isDefined", "(", "list", "[", "i", "]", "[", "sub", "]", ")", "&&", "(", "list", "[", "i", "]", "[", "sub", "]", "[", "key", "]", "==", "object", "[", "sub", "]", "[", "key", "]", ")", ")", "{", "return", "false", ";", "}", "}", "list", ".", "push", "(", "object", ")", ";", "return", "true", ";", "}" ]
Add in list the argument object if none has the same sub.key attribute @param list Array of objects having sub.key attribute @param {string} sub @param {string} key @param object New object to add @return {boolean} True if added or false if already exists in list
[ "Add", "in", "list", "the", "argument", "object", "if", "none", "has", "the", "same", "sub", ".", "key", "attribute" ]
e57ebece54ee68211d43802a8e0feeef098d3e36
https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.array.js#L254-L262
41,576
ofidj/fidj
.todo/miapp.tools.array.js
getSubKeyFromList
function getSubKeyFromList(list, sub, key, value) { for (var i = list.length - 1; i >= 0; i--) { if (a4p.isDefined(list[i][sub]) && (list[i][sub][key] == value)) { return list[i]; } } return false; }
javascript
function getSubKeyFromList(list, sub, key, value) { for (var i = list.length - 1; i >= 0; i--) { if (a4p.isDefined(list[i][sub]) && (list[i][sub][key] == value)) { return list[i]; } } return false; }
[ "function", "getSubKeyFromList", "(", "list", ",", "sub", ",", "key", ",", "value", ")", "{", "for", "(", "var", "i", "=", "list", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "a4p", ".", "isDefined", "(", "list", "[", "i", "]", "[", "sub", "]", ")", "&&", "(", "list", "[", "i", "]", "[", "sub", "]", "[", "key", "]", "==", "value", ")", ")", "{", "return", "list", "[", "i", "]", ";", "}", "}", "return", "false", ";", "}" ]
Check if one object in list has the same sub.key attribute as value and return it @param list Array of objects having sub.key attribute comparable to value @param {string} sub @param {string} key @param value @return {*} Object if exists or false if none exists in list
[ "Check", "if", "one", "object", "in", "list", "has", "the", "same", "sub", ".", "key", "attribute", "as", "value", "and", "return", "it" ]
e57ebece54ee68211d43802a8e0feeef098d3e36
https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.array.js#L273-L280
41,577
ofidj/fidj
.todo/miapp.tools.array.js
removeValueFromList
function removeValueFromList(list, value) { for (var i = list.length - 1; i >= 0; i--) { if (list[i] == value) { return list.splice(i, 1); // remove from array } } return false; }
javascript
function removeValueFromList(list, value) { for (var i = list.length - 1; i >= 0; i--) { if (list[i] == value) { return list.splice(i, 1); // remove from array } } return false; }
[ "function", "removeValueFromList", "(", "list", ",", "value", ")", "{", "for", "(", "var", "i", "=", "list", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "list", "[", "i", "]", "==", "value", ")", "{", "return", "list", ".", "splice", "(", "i", ",", "1", ")", ";", "// remove from array", "}", "}", "return", "false", ";", "}" ]
Remove from list the last object being equal to value @param list Array of objects comparable to value @param value @return {*} Array of deleted item or false
[ "Remove", "from", "list", "the", "last", "object", "being", "equal", "to", "value" ]
e57ebece54ee68211d43802a8e0feeef098d3e36
https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.array.js#L289-L296
41,578
ofidj/fidj
.todo/miapp.tools.array.js
replaceValueFromList
function replaceValueFromList(list, oldValue, newValue) { for (var i = list.length - 1; i >= 0; i--) { if (list[i] == oldValue) { return list.splice(i, 1, newValue); // remove from array and replace by the new object } } return false; }
javascript
function replaceValueFromList(list, oldValue, newValue) { for (var i = list.length - 1; i >= 0; i--) { if (list[i] == oldValue) { return list.splice(i, 1, newValue); // remove from array and replace by the new object } } return false; }
[ "function", "replaceValueFromList", "(", "list", ",", "oldValue", ",", "newValue", ")", "{", "for", "(", "var", "i", "=", "list", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "list", "[", "i", "]", "==", "oldValue", ")", "{", "return", "list", ".", "splice", "(", "i", ",", "1", ",", "newValue", ")", ";", "// remove from array and replace by the new object", "}", "}", "return", "false", ";", "}" ]
Replace in list the last object being equal to oldValue. Beware, this can insert duplicates in the list ! @param list Array of objects comparable to oldValue @param oldValue @param newValue New object replacing the old one @return {*} Array of replaced item or false
[ "Replace", "in", "list", "the", "last", "object", "being", "equal", "to", "oldValue", ".", "Beware", "this", "can", "insert", "duplicates", "in", "the", "list", "!" ]
e57ebece54ee68211d43802a8e0feeef098d3e36
https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.array.js#L307-L314
41,579
ofidj/fidj
.todo/miapp.tools.array.js
addValueToList
function addValueToList(list, value) { for (var i = list.length - 1; i >= 0; i--) { if (list[i] == value) { return false; } } list.push(value); return true; }
javascript
function addValueToList(list, value) { for (var i = list.length - 1; i >= 0; i--) { if (list[i] == value) { return false; } } list.push(value); return true; }
[ "function", "addValueToList", "(", "list", ",", "value", ")", "{", "for", "(", "var", "i", "=", "list", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "list", "[", "i", "]", "==", "value", ")", "{", "return", "false", ";", "}", "}", "list", ".", "push", "(", "value", ")", ";", "return", "true", ";", "}" ]
Add in list the value if none equals value @param list Array of objects comparable to value @param value New value to add @return {boolean} True if added or false if already exists in list
[ "Add", "in", "list", "the", "value", "if", "none", "equals", "value" ]
e57ebece54ee68211d43802a8e0feeef098d3e36
https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.array.js#L323-L331
41,580
ofidj/fidj
.todo/miapp.tools.array.js
isValueInList
function isValueInList(list, value) { for (var i = list.length - 1; i >= 0; i--) { if (list[i] == value) { return true; } } return false; }
javascript
function isValueInList(list, value) { for (var i = list.length - 1; i >= 0; i--) { if (list[i] == value) { return true; } } return false; }
[ "function", "isValueInList", "(", "list", ",", "value", ")", "{", "for", "(", "var", "i", "=", "list", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "list", "[", "i", "]", "==", "value", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check if one value in list has the same value @param list Array of objects comparable to value @param value @return {boolean} True if exists or false if none exists in list
[ "Check", "if", "one", "value", "in", "list", "has", "the", "same", "value" ]
e57ebece54ee68211d43802a8e0feeef098d3e36
https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.array.js#L340-L347
41,581
urturn/urturn-expression-api
lib/expression-api/PublicCollection.js
function(oldItem, newItem) { if(data.operations) { for(var i = 0; i < data.operations.length; i++) { var operation = data.operations[i]; if(newItem && newItem[operation.field] !== undefined || oldItem && oldItem[operation.field] !== undefined) { opsToolbox[operation.operation].recompute(operations[operation.field], operation, oldItem, newItem); } } } }
javascript
function(oldItem, newItem) { if(data.operations) { for(var i = 0; i < data.operations.length; i++) { var operation = data.operations[i]; if(newItem && newItem[operation.field] !== undefined || oldItem && oldItem[operation.field] !== undefined) { opsToolbox[operation.operation].recompute(operations[operation.field], operation, oldItem, newItem); } } } }
[ "function", "(", "oldItem", ",", "newItem", ")", "{", "if", "(", "data", ".", "operations", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "data", ".", "operations", ".", "length", ";", "i", "++", ")", "{", "var", "operation", "=", "data", ".", "operations", "[", "i", "]", ";", "if", "(", "newItem", "&&", "newItem", "[", "operation", ".", "field", "]", "!==", "undefined", "||", "oldItem", "&&", "oldItem", "[", "operation", ".", "field", "]", "!==", "undefined", ")", "{", "opsToolbox", "[", "operation", ".", "operation", "]", ".", "recompute", "(", "operations", "[", "operation", ".", "field", "]", ",", "operation", ",", "oldItem", ",", "newItem", ")", ";", "}", "}", "}", "}" ]
PRIVATE Methods Recompute the operations results
[ "PRIVATE", "Methods", "Recompute", "the", "operations", "results" ]
009a272ee670dbbe5eefb5c070ed827dd778bb07
https://github.com/urturn/urturn-expression-api/blob/009a272ee670dbbe5eefb5c070ed827dd778bb07/lib/expression-api/PublicCollection.js#L289-L298
41,582
jonschlinkert/lookup-deps
index.js
Lookup
function Lookup(options) { this.options = options || {}; this.cwd = this.options.cwd || process.cwd(); this.limit = this.options.limit || 25; this.versions = {}; this.history = {}; this.parents = {}; this.cache = {}; this._paths = []; this.init(options); }
javascript
function Lookup(options) { this.options = options || {}; this.cwd = this.options.cwd || process.cwd(); this.limit = this.options.limit || 25; this.versions = {}; this.history = {}; this.parents = {}; this.cache = {}; this._paths = []; this.init(options); }
[ "function", "Lookup", "(", "options", ")", "{", "this", ".", "options", "=", "options", "||", "{", "}", ";", "this", ".", "cwd", "=", "this", ".", "options", ".", "cwd", "||", "process", ".", "cwd", "(", ")", ";", "this", ".", "limit", "=", "this", ".", "options", ".", "limit", "||", "25", ";", "this", ".", "versions", "=", "{", "}", ";", "this", ".", "history", "=", "{", "}", ";", "this", ".", "parents", "=", "{", "}", ";", "this", ".", "cache", "=", "{", "}", ";", "this", ".", "_paths", "=", "[", "]", ";", "this", ".", "init", "(", "options", ")", ";", "}" ]
Create a new instance of `Lookup`. ```js var Lookup = require('lookup-deps'); var deps = new Lookup(); ``` @param {Object} `config` Optionally pass a default config object instead of `package.json` For now there is no reason to do this. @param {Object} `options` @api public
[ "Create", "a", "new", "instance", "of", "Lookup", "." ]
fd9ca05abdaf543b954bfb170896ac6a4bf3fe07
https://github.com/jonschlinkert/lookup-deps/blob/fd9ca05abdaf543b954bfb170896ac6a4bf3fe07/index.js#L46-L56
41,583
Mammut-FE/nejm
src/util/dispatcher/dsp/group.js
function(_node){ var _module; _node = _node._$getParent(); while(!!_node){ _module = _node._$getData().module; if (_t2._$isModule(_module)){ return _module._$getExportData(); } _node = _node._$getParent(); } return null; }
javascript
function(_node){ var _module; _node = _node._$getParent(); while(!!_node){ _module = _node._$getData().module; if (_t2._$isModule(_module)){ return _module._$getExportData(); } _node = _node._$getParent(); } return null; }
[ "function", "(", "_node", ")", "{", "var", "_module", ";", "_node", "=", "_node", ".", "_$getParent", "(", ")", ";", "while", "(", "!", "!", "_node", ")", "{", "_module", "=", "_node", ".", "_$getData", "(", ")", ".", "module", ";", "if", "(", "_t2", ".", "_$isModule", "(", "_module", ")", ")", "{", "return", "_module", ".", "_$getExportData", "(", ")", ";", "}", "_node", "=", "_node", ".", "_$getParent", "(", ")", ";", "}", "return", "null", ";", "}" ]
get nearest parent export data
[ "get", "nearest", "parent", "export", "data" ]
dfc09ac66a8d67620a7aea65e34d8a179976b3fb
https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/dispatcher/dsp/group.js#L203-L214
41,584
Mammut-FE/nejm
src/util/dispatcher/dsp/group.js
function (module, config) { var ret = { url: (config.root||'')+module, version: (config.ver||_o)[module] }; // convert xxx.html to xxx_ver.html if (!!config.mode&&!!ret.version){ ret.url = ret.url.replace( /(\.[^.\/]*?)$/, '_'+ret.version+'$1' ); ret.version = null; } return ret; }
javascript
function (module, config) { var ret = { url: (config.root||'')+module, version: (config.ver||_o)[module] }; // convert xxx.html to xxx_ver.html if (!!config.mode&&!!ret.version){ ret.url = ret.url.replace( /(\.[^.\/]*?)$/, '_'+ret.version+'$1' ); ret.version = null; } return ret; }
[ "function", "(", "module", ",", "config", ")", "{", "var", "ret", "=", "{", "url", ":", "(", "config", ".", "root", "||", "''", ")", "+", "module", ",", "version", ":", "(", "config", ".", "ver", "||", "_o", ")", "[", "module", "]", "}", ";", "// convert xxx.html to xxx_ver.html", "if", "(", "!", "!", "config", ".", "mode", "&&", "!", "!", "ret", ".", "version", ")", "{", "ret", ".", "url", "=", "ret", ".", "url", ".", "replace", "(", "/", "(\\.[^.\\/]*?)$", "/", ",", "'_'", "+", "ret", ".", "version", "+", "'$1'", ")", ";", "ret", ".", "version", "=", "null", ";", "}", "return", "ret", ";", "}" ]
parse module url config - ver,root,mode
[ "parse", "module", "url", "config", "-", "ver", "root", "mode" ]
dfc09ac66a8d67620a7aea65e34d8a179976b3fb
https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/dispatcher/dsp/group.js#L217-L231
41,585
zazuko/trifid-core
plugins/locals.js
locals
function locals (router) { router.use((req, res, next) => { absoluteUrl.attach(req) // requested resource res.locals.iri = req.iri // requested resource parsed into URL object res.locals.url = url.parse(res.locals.iri) // dummy translation res.locals.t = res.locals.t || ((x) => { return x.substring(x.indexOf(':') + 1) }) next() }) }
javascript
function locals (router) { router.use((req, res, next) => { absoluteUrl.attach(req) // requested resource res.locals.iri = req.iri // requested resource parsed into URL object res.locals.url = url.parse(res.locals.iri) // dummy translation res.locals.t = res.locals.t || ((x) => { return x.substring(x.indexOf(':') + 1) }) next() }) }
[ "function", "locals", "(", "router", ")", "{", "router", ".", "use", "(", "(", "req", ",", "res", ",", "next", ")", "=>", "{", "absoluteUrl", ".", "attach", "(", "req", ")", "// requested resource", "res", ".", "locals", ".", "iri", "=", "req", ".", "iri", "// requested resource parsed into URL object", "res", ".", "locals", ".", "url", "=", "url", ".", "parse", "(", "res", ".", "locals", ".", "iri", ")", "// dummy translation", "res", ".", "locals", ".", "t", "=", "res", ".", "locals", ".", "t", "||", "(", "(", "x", ")", "=>", "{", "return", "x", ".", "substring", "(", "x", ".", "indexOf", "(", "':'", ")", "+", "1", ")", "}", ")", "next", "(", ")", "}", ")", "}" ]
Adds router and request locals variables @param router
[ "Adds", "router", "and", "request", "locals", "variables" ]
47068ef508971f562e35768d829e15699ce3e19c
https://github.com/zazuko/trifid-core/blob/47068ef508971f562e35768d829e15699ce3e19c/plugins/locals.js#L8-L25
41,586
jmjuanes/stattic
index.js
function (res, errorCode, errorMessage) { res.writeHead(errorCode, {"Content-Type": "text/html"}); //Read the local error file return fs.readFile(options.error, "utf8", function (error, content) { //Check the error if (error) { return res.end("<" + "h1>Error</h1><p>" + errorMessage + "</p>"); } let data = {code: errorCode, message: errorMessage}; content = content.replace(/{{([^{}]+)}}/g, function(match, found) { found = found.trim(); if(typeof data[found] !== "undefined") { return data[found].toString(); } else { return match; } }); return res.end(content); }); }
javascript
function (res, errorCode, errorMessage) { res.writeHead(errorCode, {"Content-Type": "text/html"}); //Read the local error file return fs.readFile(options.error, "utf8", function (error, content) { //Check the error if (error) { return res.end("<" + "h1>Error</h1><p>" + errorMessage + "</p>"); } let data = {code: errorCode, message: errorMessage}; content = content.replace(/{{([^{}]+)}}/g, function(match, found) { found = found.trim(); if(typeof data[found] !== "undefined") { return data[found].toString(); } else { return match; } }); return res.end(content); }); }
[ "function", "(", "res", ",", "errorCode", ",", "errorMessage", ")", "{", "res", ".", "writeHead", "(", "errorCode", ",", "{", "\"Content-Type\"", ":", "\"text/html\"", "}", ")", ";", "//Read the local error file", "return", "fs", ".", "readFile", "(", "options", ".", "error", ",", "\"utf8\"", ",", "function", "(", "error", ",", "content", ")", "{", "//Check the error", "if", "(", "error", ")", "{", "return", "res", ".", "end", "(", "\"<\"", "+", "\"h1>Error</h1><p>\"", "+", "errorMessage", "+", "\"</p>\"", ")", ";", "}", "let", "data", "=", "{", "code", ":", "errorCode", ",", "message", ":", "errorMessage", "}", ";", "content", "=", "content", ".", "replace", "(", "/", "{{([^{}]+)}}", "/", "g", ",", "function", "(", "match", ",", "found", ")", "{", "found", "=", "found", ".", "trim", "(", ")", ";", "if", "(", "typeof", "data", "[", "found", "]", "!==", "\"undefined\"", ")", "{", "return", "data", "[", "found", "]", ".", "toString", "(", ")", ";", "}", "else", "{", "return", "match", ";", "}", "}", ")", ";", "return", "res", ".", "end", "(", "content", ")", ";", "}", ")", ";", "}" ]
Display an error page
[ "Display", "an", "error", "page" ]
b7930953f235690f1458de0b95c0c759aa9da7f3
https://github.com/jmjuanes/stattic/blob/b7930953f235690f1458de0b95c0c759aa9da7f3/index.js#L113-L133
41,587
veo-labs/openveo-api
lib/controllers/SocketController.js
SocketController
function SocketController(namespace) { SocketController.super_.call(this); Object.defineProperties(this, { /** * Socket's namespace associated to the controller. * * @property namespace * @type SocketNamespace * @final */ namespace: {value: namespace}, /** * An emitter to emits clients' messages. * * @property emitter * @type AdvancedEmitter * @final */ emitter: {value: new AdvancedEmitter()} }); }
javascript
function SocketController(namespace) { SocketController.super_.call(this); Object.defineProperties(this, { /** * Socket's namespace associated to the controller. * * @property namespace * @type SocketNamespace * @final */ namespace: {value: namespace}, /** * An emitter to emits clients' messages. * * @property emitter * @type AdvancedEmitter * @final */ emitter: {value: new AdvancedEmitter()} }); }
[ "function", "SocketController", "(", "namespace", ")", "{", "SocketController", ".", "super_", ".", "call", "(", "this", ")", ";", "Object", ".", "defineProperties", "(", "this", ",", "{", "/**\n * Socket's namespace associated to the controller.\n *\n * @property namespace\n * @type SocketNamespace\n * @final\n */", "namespace", ":", "{", "value", ":", "namespace", "}", ",", "/**\n * An emitter to emits clients' messages.\n *\n * @property emitter\n * @type AdvancedEmitter\n * @final\n */", "emitter", ":", "{", "value", ":", "new", "AdvancedEmitter", "(", ")", "}", "}", ")", ";", "}" ]
Defines base controller for all controllers which need to handle socket messages. A SocketController is associated to a namespace to be able to emit a message to the whole socket namespace. A SocketController is also associated to an emitter to emit socket's clients' messages to pilots. // Implement a SocketController : "CustomSocketController" var util = require('util'); var openVeoApi = require('@openveo/api'); function CustomSocketController(namespace) { CustomSocketController.super_.call(this, namespace); } util.inherits(CustomSocketController, openVeoApi.controllers.SocketController); @class SocketController @extends Controller @constructor @param {SocketNamespace} namespace The socket namespace associated to the controller
[ "Defines", "base", "controller", "for", "all", "controllers", "which", "need", "to", "handle", "socket", "messages", "." ]
493a811e9a5ba4d3e14910facaa7452caba1ab38
https://github.com/veo-labs/openveo-api/blob/493a811e9a5ba4d3e14910facaa7452caba1ab38/lib/controllers/SocketController.js#L34-L58
41,588
Bartvds/ministyle
lib/flow.js
toggle
function toggle(main, alt) { var mw = core.base(); mw.enabled = true; mw.main = main; mw.alt = (alt || common.plain()); mw.active = mw.main; mw.swap = function () { mw.active = (mw.active !== mw.main ? mw.main : mw.alt); }; mw.error = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.error(str); } return str; }; mw.warning = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.warning(str); } return str; }; mw.success = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.error(str); } return str; }; mw.accent = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.accent(str); } return str; }; mw.signal = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.signal(str); } return str; }; mw.muted = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.muted(str); } return str; }; mw.plain = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.plain(str); } return str; }; mw.toString = function () { return '<ministyle-toggle>'; }; return mw; }
javascript
function toggle(main, alt) { var mw = core.base(); mw.enabled = true; mw.main = main; mw.alt = (alt || common.plain()); mw.active = mw.main; mw.swap = function () { mw.active = (mw.active !== mw.main ? mw.main : mw.alt); }; mw.error = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.error(str); } return str; }; mw.warning = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.warning(str); } return str; }; mw.success = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.error(str); } return str; }; mw.accent = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.accent(str); } return str; }; mw.signal = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.signal(str); } return str; }; mw.muted = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.muted(str); } return str; }; mw.plain = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.plain(str); } return str; }; mw.toString = function () { return '<ministyle-toggle>'; }; return mw; }
[ "function", "toggle", "(", "main", ",", "alt", ")", "{", "var", "mw", "=", "core", ".", "base", "(", ")", ";", "mw", ".", "enabled", "=", "true", ";", "mw", ".", "main", "=", "main", ";", "mw", ".", "alt", "=", "(", "alt", "||", "common", ".", "plain", "(", ")", ")", ";", "mw", ".", "active", "=", "mw", ".", "main", ";", "mw", ".", "swap", "=", "function", "(", ")", "{", "mw", ".", "active", "=", "(", "mw", ".", "active", "!==", "mw", ".", "main", "?", "mw", ".", "main", ":", "mw", ".", "alt", ")", ";", "}", ";", "mw", ".", "error", "=", "function", "(", "str", ")", "{", "str", "=", "String", "(", "str", ")", ";", "if", "(", "mw", ".", "enabled", "&&", "mw", ".", "active", ")", "{", "return", "mw", ".", "active", ".", "error", "(", "str", ")", ";", "}", "return", "str", ";", "}", ";", "mw", ".", "warning", "=", "function", "(", "str", ")", "{", "str", "=", "String", "(", "str", ")", ";", "if", "(", "mw", ".", "enabled", "&&", "mw", ".", "active", ")", "{", "return", "mw", ".", "active", ".", "warning", "(", "str", ")", ";", "}", "return", "str", ";", "}", ";", "mw", ".", "success", "=", "function", "(", "str", ")", "{", "str", "=", "String", "(", "str", ")", ";", "if", "(", "mw", ".", "enabled", "&&", "mw", ".", "active", ")", "{", "return", "mw", ".", "active", ".", "error", "(", "str", ")", ";", "}", "return", "str", ";", "}", ";", "mw", ".", "accent", "=", "function", "(", "str", ")", "{", "str", "=", "String", "(", "str", ")", ";", "if", "(", "mw", ".", "enabled", "&&", "mw", ".", "active", ")", "{", "return", "mw", ".", "active", ".", "accent", "(", "str", ")", ";", "}", "return", "str", ";", "}", ";", "mw", ".", "signal", "=", "function", "(", "str", ")", "{", "str", "=", "String", "(", "str", ")", ";", "if", "(", "mw", ".", "enabled", "&&", "mw", ".", "active", ")", "{", "return", "mw", ".", "active", ".", "signal", "(", "str", ")", ";", "}", "return", "str", ";", "}", ";", "mw", ".", "muted", "=", "function", "(", "str", ")", "{", "str", "=", "String", "(", "str", ")", ";", "if", "(", "mw", ".", "enabled", "&&", "mw", ".", "active", ")", "{", "return", "mw", ".", "active", ".", "muted", "(", "str", ")", ";", "}", "return", "str", ";", "}", ";", "mw", ".", "plain", "=", "function", "(", "str", ")", "{", "str", "=", "String", "(", "str", ")", ";", "if", "(", "mw", ".", "enabled", "&&", "mw", ".", "active", ")", "{", "return", "mw", ".", "active", ".", "plain", "(", "str", ")", ";", "}", "return", "str", ";", "}", ";", "mw", ".", "toString", "=", "function", "(", ")", "{", "return", "'<ministyle-toggle>'", ";", "}", ";", "return", "mw", ";", "}" ]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - toggle flow
[ "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "toggle", "flow" ]
92681e81d4c93faddd4e5d1d6edf44990b3a9e68
https://github.com/Bartvds/ministyle/blob/92681e81d4c93faddd4e5d1d6edf44990b3a9e68/lib/flow.js#L50-L113
41,589
atsid/circuits-js
js/NativeXhrDataProvider.js
function (url) { var ret = true, xhr; try { // try the lowest footprint synchronous request to specific url. xhr = new XMLHttpRequest(); xhr.open("HEAD", url, false); xhr.send(); } catch (e) { ret = false; } return ret; }
javascript
function (url) { var ret = true, xhr; try { // try the lowest footprint synchronous request to specific url. xhr = new XMLHttpRequest(); xhr.open("HEAD", url, false); xhr.send(); } catch (e) { ret = false; } return ret; }
[ "function", "(", "url", ")", "{", "var", "ret", "=", "true", ",", "xhr", ";", "try", "{", "// try the lowest footprint synchronous request to specific url.\r", "xhr", "=", "new", "XMLHttpRequest", "(", ")", ";", "xhr", ".", "open", "(", "\"HEAD\"", ",", "url", ",", "false", ")", ";", "xhr", ".", "send", "(", ")", ";", "}", "catch", "(", "e", ")", "{", "ret", "=", "false", ";", "}", "return", "ret", ";", "}" ]
test - do a network test with a synchronous call. @param url to test.
[ "test", "-", "do", "a", "network", "test", "with", "a", "synchronous", "call", "." ]
f1fa5e98d406b3b9f577dd8995782c7115d6b346
https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/NativeXhrDataProvider.js#L38-L49
41,590
atsid/circuits-js
js/NativeXhrDataProvider.js
function (params) { var xhr = new XMLHttpRequest(), async = typeof (params.asynchronous) === "boolean" ? params.asynchronous : this.asynchronous, readystatechange = function () { if (params.onreadystatechange) { params.onreadystatechange.call(this); } else { if (this.readyState === this.DONE) { if (!this.loadcalled) { // prevent multiple done calls from xhr. var resp; if (!xhr.timedOut) { resp = this.response || this.responseText; } this.loadcalled = true; if (resp && !this.responseType && params.responseType === "json") { try { resp = JSON.parse(resp); } catch (e) { logger.debug('Unable to parse JSON: ' + resp + '\n' + e); } } params.handler.call(this, (xhr.timedOut) ? -1 : this.status, resp, params); } } } }; // setup pre-open parameters params.xhr = xhr; if (params.responseType && typeof (xhr.responseType) === 'string') { // types for level 2 are still draft. Don't attempt to set until // support is more universal. // // xhr.responseType = params.responseType; logger.debug("Ignoring responseType on XHR until fully supported."); } xhr.open(params.method, params.url, async); Object.keys((params.headers || {})).forEach(function (val) { if (!(val === "Content-Type" && params.headers[val] === "multipart/form-data")) { xhr.setRequestHeader(val, params.headers[val]); } }); // If level 2, then attach the handlers directly. if (xhr.upload) { Object.keys(params).forEach(function (key) { if (key.indexOf("on") === 0 && typeof (params[key]) === 'function') { if (typeof (xhr[key]) !== 'undefined') { xhr[key] = params[key]; } if (typeof (xhr.upload[key]) !== 'undefined') { xhr.upload[key] = params[key]; } } }); } // still support readystate event. if (params.handler || params.onreadystatechange) { xhr.onreadystatechange = readystatechange; } if (params.timeout && typeof (params.timeout) === 'number') { xhr.timeout = params.timeout; xhr.ontimeout = function () { xhr.timedOut = true; xhr.abort(); }; setTimeout(function () { /* vs. xhr.timeout */ this.response = {}; if (xhr.readyState < 4 && !xhr.timedOut) { xhr.ontimeout(); } }, xhr.timeout); } xhr.send(params.payload); }
javascript
function (params) { var xhr = new XMLHttpRequest(), async = typeof (params.asynchronous) === "boolean" ? params.asynchronous : this.asynchronous, readystatechange = function () { if (params.onreadystatechange) { params.onreadystatechange.call(this); } else { if (this.readyState === this.DONE) { if (!this.loadcalled) { // prevent multiple done calls from xhr. var resp; if (!xhr.timedOut) { resp = this.response || this.responseText; } this.loadcalled = true; if (resp && !this.responseType && params.responseType === "json") { try { resp = JSON.parse(resp); } catch (e) { logger.debug('Unable to parse JSON: ' + resp + '\n' + e); } } params.handler.call(this, (xhr.timedOut) ? -1 : this.status, resp, params); } } } }; // setup pre-open parameters params.xhr = xhr; if (params.responseType && typeof (xhr.responseType) === 'string') { // types for level 2 are still draft. Don't attempt to set until // support is more universal. // // xhr.responseType = params.responseType; logger.debug("Ignoring responseType on XHR until fully supported."); } xhr.open(params.method, params.url, async); Object.keys((params.headers || {})).forEach(function (val) { if (!(val === "Content-Type" && params.headers[val] === "multipart/form-data")) { xhr.setRequestHeader(val, params.headers[val]); } }); // If level 2, then attach the handlers directly. if (xhr.upload) { Object.keys(params).forEach(function (key) { if (key.indexOf("on") === 0 && typeof (params[key]) === 'function') { if (typeof (xhr[key]) !== 'undefined') { xhr[key] = params[key]; } if (typeof (xhr.upload[key]) !== 'undefined') { xhr.upload[key] = params[key]; } } }); } // still support readystate event. if (params.handler || params.onreadystatechange) { xhr.onreadystatechange = readystatechange; } if (params.timeout && typeof (params.timeout) === 'number') { xhr.timeout = params.timeout; xhr.ontimeout = function () { xhr.timedOut = true; xhr.abort(); }; setTimeout(function () { /* vs. xhr.timeout */ this.response = {}; if (xhr.readyState < 4 && !xhr.timedOut) { xhr.ontimeout(); } }, xhr.timeout); } xhr.send(params.payload); }
[ "function", "(", "params", ")", "{", "var", "xhr", "=", "new", "XMLHttpRequest", "(", ")", ",", "async", "=", "typeof", "(", "params", ".", "asynchronous", ")", "===", "\"boolean\"", "?", "params", ".", "asynchronous", ":", "this", ".", "asynchronous", ",", "readystatechange", "=", "function", "(", ")", "{", "if", "(", "params", ".", "onreadystatechange", ")", "{", "params", ".", "onreadystatechange", ".", "call", "(", "this", ")", ";", "}", "else", "{", "if", "(", "this", ".", "readyState", "===", "this", ".", "DONE", ")", "{", "if", "(", "!", "this", ".", "loadcalled", ")", "{", "// prevent multiple done calls from xhr.\r", "var", "resp", ";", "if", "(", "!", "xhr", ".", "timedOut", ")", "{", "resp", "=", "this", ".", "response", "||", "this", ".", "responseText", ";", "}", "this", ".", "loadcalled", "=", "true", ";", "if", "(", "resp", "&&", "!", "this", ".", "responseType", "&&", "params", ".", "responseType", "===", "\"json\"", ")", "{", "try", "{", "resp", "=", "JSON", ".", "parse", "(", "resp", ")", ";", "}", "catch", "(", "e", ")", "{", "logger", ".", "debug", "(", "'Unable to parse JSON: '", "+", "resp", "+", "'\\n'", "+", "e", ")", ";", "}", "}", "params", ".", "handler", ".", "call", "(", "this", ",", "(", "xhr", ".", "timedOut", ")", "?", "-", "1", ":", "this", ".", "status", ",", "resp", ",", "params", ")", ";", "}", "}", "}", "}", ";", "// setup pre-open parameters\r", "params", ".", "xhr", "=", "xhr", ";", "if", "(", "params", ".", "responseType", "&&", "typeof", "(", "xhr", ".", "responseType", ")", "===", "'string'", ")", "{", "// types for level 2 are still draft. Don't attempt to set until\r", "// support is more universal.\r", "//\r", "// xhr.responseType = params.responseType;\r", "logger", ".", "debug", "(", "\"Ignoring responseType on XHR until fully supported.\"", ")", ";", "}", "xhr", ".", "open", "(", "params", ".", "method", ",", "params", ".", "url", ",", "async", ")", ";", "Object", ".", "keys", "(", "(", "params", ".", "headers", "||", "{", "}", ")", ")", ".", "forEach", "(", "function", "(", "val", ")", "{", "if", "(", "!", "(", "val", "===", "\"Content-Type\"", "&&", "params", ".", "headers", "[", "val", "]", "===", "\"multipart/form-data\"", ")", ")", "{", "xhr", ".", "setRequestHeader", "(", "val", ",", "params", ".", "headers", "[", "val", "]", ")", ";", "}", "}", ")", ";", "// If level 2, then attach the handlers directly.\r", "if", "(", "xhr", ".", "upload", ")", "{", "Object", ".", "keys", "(", "params", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "if", "(", "key", ".", "indexOf", "(", "\"on\"", ")", "===", "0", "&&", "typeof", "(", "params", "[", "key", "]", ")", "===", "'function'", ")", "{", "if", "(", "typeof", "(", "xhr", "[", "key", "]", ")", "!==", "'undefined'", ")", "{", "xhr", "[", "key", "]", "=", "params", "[", "key", "]", ";", "}", "if", "(", "typeof", "(", "xhr", ".", "upload", "[", "key", "]", ")", "!==", "'undefined'", ")", "{", "xhr", ".", "upload", "[", "key", "]", "=", "params", "[", "key", "]", ";", "}", "}", "}", ")", ";", "}", "// still support readystate event.\r", "if", "(", "params", ".", "handler", "||", "params", ".", "onreadystatechange", ")", "{", "xhr", ".", "onreadystatechange", "=", "readystatechange", ";", "}", "if", "(", "params", ".", "timeout", "&&", "typeof", "(", "params", ".", "timeout", ")", "===", "'number'", ")", "{", "xhr", ".", "timeout", "=", "params", ".", "timeout", ";", "xhr", ".", "ontimeout", "=", "function", "(", ")", "{", "xhr", ".", "timedOut", "=", "true", ";", "xhr", ".", "abort", "(", ")", ";", "}", ";", "setTimeout", "(", "function", "(", ")", "{", "/* vs. xhr.timeout */", "this", ".", "response", "=", "{", "}", ";", "if", "(", "xhr", ".", "readyState", "<", "4", "&&", "!", "xhr", ".", "timedOut", ")", "{", "xhr", ".", "ontimeout", "(", ")", ";", "}", "}", ",", "xhr", ".", "timeout", ")", ";", "}", "xhr", ".", "send", "(", "params", ".", "payload", ")", ";", "}" ]
Perform the actual XMLHttpRequest call, interpreting the params as necessary. Although this method accepts the bulk of the parameters that can be set on XMLHttpRequest 2, only a few are passed through from the upstream calls. @param params - object of the form: { onprogress {function} onloadstart {function} onabort {function} ontimeout {function} onloadend {function} onreadystatechange {function} asynchronous {boolean} method {String} headers {Object} payload {Object} url {String} timeout {Number} responseType {String} handler {function} }
[ "Perform", "the", "actual", "XMLHttpRequest", "call", "interpreting", "the", "params", "as", "necessary", ".", "Although", "this", "method", "accepts", "the", "bulk", "of", "the", "parameters", "that", "can", "be", "set", "on", "XMLHttpRequest", "2", "only", "a", "few", "are", "passed", "through", "from", "the", "upstream", "calls", "." ]
f1fa5e98d406b3b9f577dd8995782c7115d6b346
https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/NativeXhrDataProvider.js#L183-L263
41,591
chip-js/observations-js
src/observer.js
function(value) { if (!this.context) return; if (this.setter === false) return; if (!this.setter) { try { this.setter = typeof this.expression === 'string' ? expressions.parseSetter(this.expression, this.observations.globals, this.observations.formatters) : false; } catch (e) { this.setter = false; } if (!this.setter) return; } try { var result = this.setter.call(this.context, value); } catch(e) { return; } // We can't expect code in fragments outside Observer to be aware of "sync" since observer can be replaced by other // types (e.g. one without a `sync()` method, such as one that uses `Object.observe`) in other systems. this.sync(); this.observations.sync(); return result; }
javascript
function(value) { if (!this.context) return; if (this.setter === false) return; if (!this.setter) { try { this.setter = typeof this.expression === 'string' ? expressions.parseSetter(this.expression, this.observations.globals, this.observations.formatters) : false; } catch (e) { this.setter = false; } if (!this.setter) return; } try { var result = this.setter.call(this.context, value); } catch(e) { return; } // We can't expect code in fragments outside Observer to be aware of "sync" since observer can be replaced by other // types (e.g. one without a `sync()` method, such as one that uses `Object.observe`) in other systems. this.sync(); this.observations.sync(); return result; }
[ "function", "(", "value", ")", "{", "if", "(", "!", "this", ".", "context", ")", "return", ";", "if", "(", "this", ".", "setter", "===", "false", ")", "return", ";", "if", "(", "!", "this", ".", "setter", ")", "{", "try", "{", "this", ".", "setter", "=", "typeof", "this", ".", "expression", "===", "'string'", "?", "expressions", ".", "parseSetter", "(", "this", ".", "expression", ",", "this", ".", "observations", ".", "globals", ",", "this", ".", "observations", ".", "formatters", ")", ":", "false", ";", "}", "catch", "(", "e", ")", "{", "this", ".", "setter", "=", "false", ";", "}", "if", "(", "!", "this", ".", "setter", ")", "return", ";", "}", "try", "{", "var", "result", "=", "this", ".", "setter", ".", "call", "(", "this", ".", "context", ",", "value", ")", ";", "}", "catch", "(", "e", ")", "{", "return", ";", "}", "// We can't expect code in fragments outside Observer to be aware of \"sync\" since observer can be replaced by other", "// types (e.g. one without a `sync()` method, such as one that uses `Object.observe`) in other systems.", "this", ".", "sync", "(", ")", ";", "this", ".", "observations", ".", "sync", "(", ")", ";", "return", "result", ";", "}" ]
Sets the value of this expression
[ "Sets", "the", "value", "of", "this", "expression" ]
a48b32a648089bc86b502712d78cd0b3f8317d50
https://github.com/chip-js/observations-js/blob/a48b32a648089bc86b502712d78cd0b3f8317d50/src/observer.js#L77-L102
41,592
chip-js/observations-js
src/observer.js
function() { var value = this.get(); // Don't call the callback if `skipNextSync` was called on the observer if (this.skip || !this.callback) { this.skip = false; if (this.getChangeRecords) { // Store an immutable version of the value, allowing for arrays and objects to change instance but not content and // still refrain from dispatching callbacks (e.g. when using an object in bind-class or when using array formatters // in bind-each) this.oldValue = diff.clone(value); } else { this.oldValue = value; } } else { var change; var useCompareBy = this.getChangeRecords && this.compareBy && Array.isArray(value) && Array.isArray(this.oldValue); if (useCompareBy) { var compareExpression = this.compareBy; var name = this.compareByName; var index = this.compareByIndex || '__index__'; var ctx = this.context; var globals = this.observations.globals; var formatters = this.observations.formatters; var oldValue = this.oldValue; if (!name) { name = '__item__'; // Turn "id" into "__item__.id" compareExpression = name + '.' + compareExpression; } var getCompareValue = expressions.parse(compareExpression, globals, formatters, name, index); changed = diff.values(value.map(getCompareValue, ctx), oldValue.map(getCompareValue, ctx)); } else if (this.getChangeRecords) { changed = diff.values(value, this.oldValue); } else { changed = diff.basic(value, this.oldValue); } var oldValue = this.oldValue; if (this.getChangeRecords) { // Store an immutable version of the value, allowing for arrays and objects to change instance but not content and // still refrain from dispatching callbacks (e.g. when using an object in bind-class or when using array formatters // in bind-each) this.oldValue = diff.clone(value); } else { this.oldValue = value; } // If an array has changed calculate the splices and call the callback. if (!changed && !this.forceUpdateNextSync) return; this.forceUpdateNextSync = false; if (Array.isArray(changed)) { this.callback.call(this.callbackContext, value, oldValue, changed); } else { this.callback.call(this.callbackContext, value, oldValue); } } }
javascript
function() { var value = this.get(); // Don't call the callback if `skipNextSync` was called on the observer if (this.skip || !this.callback) { this.skip = false; if (this.getChangeRecords) { // Store an immutable version of the value, allowing for arrays and objects to change instance but not content and // still refrain from dispatching callbacks (e.g. when using an object in bind-class or when using array formatters // in bind-each) this.oldValue = diff.clone(value); } else { this.oldValue = value; } } else { var change; var useCompareBy = this.getChangeRecords && this.compareBy && Array.isArray(value) && Array.isArray(this.oldValue); if (useCompareBy) { var compareExpression = this.compareBy; var name = this.compareByName; var index = this.compareByIndex || '__index__'; var ctx = this.context; var globals = this.observations.globals; var formatters = this.observations.formatters; var oldValue = this.oldValue; if (!name) { name = '__item__'; // Turn "id" into "__item__.id" compareExpression = name + '.' + compareExpression; } var getCompareValue = expressions.parse(compareExpression, globals, formatters, name, index); changed = diff.values(value.map(getCompareValue, ctx), oldValue.map(getCompareValue, ctx)); } else if (this.getChangeRecords) { changed = diff.values(value, this.oldValue); } else { changed = diff.basic(value, this.oldValue); } var oldValue = this.oldValue; if (this.getChangeRecords) { // Store an immutable version of the value, allowing for arrays and objects to change instance but not content and // still refrain from dispatching callbacks (e.g. when using an object in bind-class or when using array formatters // in bind-each) this.oldValue = diff.clone(value); } else { this.oldValue = value; } // If an array has changed calculate the splices and call the callback. if (!changed && !this.forceUpdateNextSync) return; this.forceUpdateNextSync = false; if (Array.isArray(changed)) { this.callback.call(this.callbackContext, value, oldValue, changed); } else { this.callback.call(this.callbackContext, value, oldValue); } } }
[ "function", "(", ")", "{", "var", "value", "=", "this", ".", "get", "(", ")", ";", "// Don't call the callback if `skipNextSync` was called on the observer", "if", "(", "this", ".", "skip", "||", "!", "this", ".", "callback", ")", "{", "this", ".", "skip", "=", "false", ";", "if", "(", "this", ".", "getChangeRecords", ")", "{", "// Store an immutable version of the value, allowing for arrays and objects to change instance but not content and", "// still refrain from dispatching callbacks (e.g. when using an object in bind-class or when using array formatters", "// in bind-each)", "this", ".", "oldValue", "=", "diff", ".", "clone", "(", "value", ")", ";", "}", "else", "{", "this", ".", "oldValue", "=", "value", ";", "}", "}", "else", "{", "var", "change", ";", "var", "useCompareBy", "=", "this", ".", "getChangeRecords", "&&", "this", ".", "compareBy", "&&", "Array", ".", "isArray", "(", "value", ")", "&&", "Array", ".", "isArray", "(", "this", ".", "oldValue", ")", ";", "if", "(", "useCompareBy", ")", "{", "var", "compareExpression", "=", "this", ".", "compareBy", ";", "var", "name", "=", "this", ".", "compareByName", ";", "var", "index", "=", "this", ".", "compareByIndex", "||", "'__index__'", ";", "var", "ctx", "=", "this", ".", "context", ";", "var", "globals", "=", "this", ".", "observations", ".", "globals", ";", "var", "formatters", "=", "this", ".", "observations", ".", "formatters", ";", "var", "oldValue", "=", "this", ".", "oldValue", ";", "if", "(", "!", "name", ")", "{", "name", "=", "'__item__'", ";", "// Turn \"id\" into \"__item__.id\"", "compareExpression", "=", "name", "+", "'.'", "+", "compareExpression", ";", "}", "var", "getCompareValue", "=", "expressions", ".", "parse", "(", "compareExpression", ",", "globals", ",", "formatters", ",", "name", ",", "index", ")", ";", "changed", "=", "diff", ".", "values", "(", "value", ".", "map", "(", "getCompareValue", ",", "ctx", ")", ",", "oldValue", ".", "map", "(", "getCompareValue", ",", "ctx", ")", ")", ";", "}", "else", "if", "(", "this", ".", "getChangeRecords", ")", "{", "changed", "=", "diff", ".", "values", "(", "value", ",", "this", ".", "oldValue", ")", ";", "}", "else", "{", "changed", "=", "diff", ".", "basic", "(", "value", ",", "this", ".", "oldValue", ")", ";", "}", "var", "oldValue", "=", "this", ".", "oldValue", ";", "if", "(", "this", ".", "getChangeRecords", ")", "{", "// Store an immutable version of the value, allowing for arrays and objects to change instance but not content and", "// still refrain from dispatching callbacks (e.g. when using an object in bind-class or when using array formatters", "// in bind-each)", "this", ".", "oldValue", "=", "diff", ".", "clone", "(", "value", ")", ";", "}", "else", "{", "this", ".", "oldValue", "=", "value", ";", "}", "// If an array has changed calculate the splices and call the callback.", "if", "(", "!", "changed", "&&", "!", "this", ".", "forceUpdateNextSync", ")", "return", ";", "this", ".", "forceUpdateNextSync", "=", "false", ";", "if", "(", "Array", ".", "isArray", "(", "changed", ")", ")", "{", "this", ".", "callback", ".", "call", "(", "this", ".", "callbackContext", ",", "value", ",", "oldValue", ",", "changed", ")", ";", "}", "else", "{", "this", ".", "callback", ".", "call", "(", "this", ".", "callbackContext", ",", "value", ",", "oldValue", ")", ";", "}", "}", "}" ]
Syncs this observer now, calling the callback immediately if there have been changes
[ "Syncs", "this", "observer", "now", "calling", "the", "callback", "immediately", "if", "there", "have", "been", "changes" ]
a48b32a648089bc86b502712d78cd0b3f8317d50
https://github.com/chip-js/observations-js/blob/a48b32a648089bc86b502712d78cd0b3f8317d50/src/observer.js#L112-L176
41,593
Mammut-FE/nejm
src/util/focus/platform/focus.js
function(_clazz,_event){ var _element = _v._$getElement(_event); if (!_element.value) _e._$delClassName(_element,_clazz); }
javascript
function(_clazz,_event){ var _element = _v._$getElement(_event); if (!_element.value) _e._$delClassName(_element,_clazz); }
[ "function", "(", "_clazz", ",", "_event", ")", "{", "var", "_element", "=", "_v", ".", "_$getElement", "(", "_event", ")", ";", "if", "(", "!", "_element", ".", "value", ")", "_e", ".", "_$delClassName", "(", "_element", ",", "_clazz", ")", ";", "}" ]
do blur check
[ "do", "blur", "check" ]
dfc09ac66a8d67620a7aea65e34d8a179976b3fb
https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/focus/platform/focus.js#L21-L25
41,594
Mammut-FE/nejm
src/util/ajax/rest.js
function(_headers,_key,_default){ var _value = _headers[_key]|| _headers[_key.toLowerCase()]; if (!_value){ _value = _default; _headers[_key] = _value; } return _value; }
javascript
function(_headers,_key,_default){ var _value = _headers[_key]|| _headers[_key.toLowerCase()]; if (!_value){ _value = _default; _headers[_key] = _value; } return _value; }
[ "function", "(", "_headers", ",", "_key", ",", "_default", ")", "{", "var", "_value", "=", "_headers", "[", "_key", "]", "||", "_headers", "[", "_key", ".", "toLowerCase", "(", ")", "]", ";", "if", "(", "!", "_value", ")", "{", "_value", "=", "_default", ";", "_headers", "[", "_key", "]", "=", "_value", ";", "}", "return", "_value", ";", "}" ]
check default headers
[ "check", "default", "headers" ]
dfc09ac66a8d67620a7aea65e34d8a179976b3fb
https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/ajax/rest.js#L132-L140
41,595
Mammut-FE/nejm
src/util/ajax/rest.js
function(_data,_key,_map){ if (_u._$isArray(_data)){ _map[_key] = JSON.stringify(_data); } }
javascript
function(_data,_key,_map){ if (_u._$isArray(_data)){ _map[_key] = JSON.stringify(_data); } }
[ "function", "(", "_data", ",", "_key", ",", "_map", ")", "{", "if", "(", "_u", ".", "_$isArray", "(", "_data", ")", ")", "{", "_map", "[", "_key", "]", "=", "JSON", ".", "stringify", "(", "_data", ")", ";", "}", "}" ]
pre convert array
[ "pre", "convert", "array" ]
dfc09ac66a8d67620a7aea65e34d8a179976b3fb
https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/ajax/rest.js#L142-L146
41,596
urturn/urturn-expression-api
lib/modules/antiscroll.costum.js
Antiscroll
function Antiscroll (el, opts) { this.el = $(el); this.options = opts || {}; // CUSTOM // this.x = (false !== this.options.x) || this.options.forceHorizontal; this.x = false; // Always hide horizontal scroll this.y = (false !== this.options.y) || this.options.forceVertical; this.autoHide = false !== this.options.autoHide; this.padding = undefined === this.options.padding ? 2 : this.options.padding; this.inner = this.el.find('.antiscroll-inner'); /* CUSTOM */ /* Don't add space to hide scrollbar multiple times */ if (this.inner.outerWidth() <= this.el.outerWidth()) { this.inner.css({ 'width': '+=' + (this.y ? scrollbarSize() : 0) // 'height': '+=' + (this.x ? scrollbarSize() : 0) }); } var cssMap = {}; if (this.x) cssMap.width = '+=' + scrollbarSize(); // if (this.y) cssMap.height = '+=' + scrollbarSize(); this.inner.css(cssMap); this.refresh(); }
javascript
function Antiscroll (el, opts) { this.el = $(el); this.options = opts || {}; // CUSTOM // this.x = (false !== this.options.x) || this.options.forceHorizontal; this.x = false; // Always hide horizontal scroll this.y = (false !== this.options.y) || this.options.forceVertical; this.autoHide = false !== this.options.autoHide; this.padding = undefined === this.options.padding ? 2 : this.options.padding; this.inner = this.el.find('.antiscroll-inner'); /* CUSTOM */ /* Don't add space to hide scrollbar multiple times */ if (this.inner.outerWidth() <= this.el.outerWidth()) { this.inner.css({ 'width': '+=' + (this.y ? scrollbarSize() : 0) // 'height': '+=' + (this.x ? scrollbarSize() : 0) }); } var cssMap = {}; if (this.x) cssMap.width = '+=' + scrollbarSize(); // if (this.y) cssMap.height = '+=' + scrollbarSize(); this.inner.css(cssMap); this.refresh(); }
[ "function", "Antiscroll", "(", "el", ",", "opts", ")", "{", "this", ".", "el", "=", "$", "(", "el", ")", ";", "this", ".", "options", "=", "opts", "||", "{", "}", ";", "// CUSTOM", "// this.x = (false !== this.options.x) || this.options.forceHorizontal;", "this", ".", "x", "=", "false", ";", "// Always hide horizontal scroll", "this", ".", "y", "=", "(", "false", "!==", "this", ".", "options", ".", "y", ")", "||", "this", ".", "options", ".", "forceVertical", ";", "this", ".", "autoHide", "=", "false", "!==", "this", ".", "options", ".", "autoHide", ";", "this", ".", "padding", "=", "undefined", "===", "this", ".", "options", ".", "padding", "?", "2", ":", "this", ".", "options", ".", "padding", ";", "this", ".", "inner", "=", "this", ".", "el", ".", "find", "(", "'.antiscroll-inner'", ")", ";", "/* CUSTOM */", "/* Don't add space to hide scrollbar multiple times */", "if", "(", "this", ".", "inner", ".", "outerWidth", "(", ")", "<=", "this", ".", "el", ".", "outerWidth", "(", ")", ")", "{", "this", ".", "inner", ".", "css", "(", "{", "'width'", ":", "'+='", "+", "(", "this", ".", "y", "?", "scrollbarSize", "(", ")", ":", "0", ")", "// 'height': '+=' + (this.x ? scrollbarSize() : 0)", "}", ")", ";", "}", "var", "cssMap", "=", "{", "}", ";", "if", "(", "this", ".", "x", ")", "cssMap", ".", "width", "=", "'+='", "+", "scrollbarSize", "(", ")", ";", "// if (this.y) cssMap.height = '+=' + scrollbarSize();", "this", ".", "inner", ".", "css", "(", "cssMap", ")", ";", "this", ".", "refresh", "(", ")", ";", "}" ]
Antiscroll pane constructor. @param {Element|jQuery} main pane @parma {Object} options @api public
[ "Antiscroll", "pane", "constructor", "." ]
009a272ee670dbbe5eefb5c070ed827dd778bb07
https://github.com/urturn/urturn-expression-api/blob/009a272ee670dbbe5eefb5c070ed827dd778bb07/lib/modules/antiscroll.costum.js#L46-L73
41,597
urturn/urturn-expression-api
lib/modules/antiscroll.costum.js
Scrollbar
function Scrollbar (pane) { this.pane = pane; this.pane.el.append(this.el); this.innerEl = this.pane.inner.get(0); this.dragging = false; this.enter = false; this.shown = false; // hovering this.pane.el.mouseenter($.proxy(this, 'mouseenter')); this.pane.el.mouseleave($.proxy(this, 'mouseleave')); // dragging this.el.mousedown($.proxy(this, 'mousedown')); // scrolling this.innerPaneScrollListener = $.proxy(this, 'scroll'); this.pane.inner.scroll(this.innerPaneScrollListener); // wheel -optional- this.innerPaneMouseWheelListener = $.proxy(this, 'mousewheel'); this.pane.inner.bind('mousewheel', this.innerPaneMouseWheelListener); // show var initialDisplay = this.pane.options.initialDisplay; if (initialDisplay !== false) { this.show(); if (this.pane.autoHide) { this.hiding = setTimeout($.proxy(this, 'hide'), parseInt(initialDisplay, 10) || 3000); } } }
javascript
function Scrollbar (pane) { this.pane = pane; this.pane.el.append(this.el); this.innerEl = this.pane.inner.get(0); this.dragging = false; this.enter = false; this.shown = false; // hovering this.pane.el.mouseenter($.proxy(this, 'mouseenter')); this.pane.el.mouseleave($.proxy(this, 'mouseleave')); // dragging this.el.mousedown($.proxy(this, 'mousedown')); // scrolling this.innerPaneScrollListener = $.proxy(this, 'scroll'); this.pane.inner.scroll(this.innerPaneScrollListener); // wheel -optional- this.innerPaneMouseWheelListener = $.proxy(this, 'mousewheel'); this.pane.inner.bind('mousewheel', this.innerPaneMouseWheelListener); // show var initialDisplay = this.pane.options.initialDisplay; if (initialDisplay !== false) { this.show(); if (this.pane.autoHide) { this.hiding = setTimeout($.proxy(this, 'hide'), parseInt(initialDisplay, 10) || 3000); } } }
[ "function", "Scrollbar", "(", "pane", ")", "{", "this", ".", "pane", "=", "pane", ";", "this", ".", "pane", ".", "el", ".", "append", "(", "this", ".", "el", ")", ";", "this", ".", "innerEl", "=", "this", ".", "pane", ".", "inner", ".", "get", "(", "0", ")", ";", "this", ".", "dragging", "=", "false", ";", "this", ".", "enter", "=", "false", ";", "this", ".", "shown", "=", "false", ";", "// hovering", "this", ".", "pane", ".", "el", ".", "mouseenter", "(", "$", ".", "proxy", "(", "this", ",", "'mouseenter'", ")", ")", ";", "this", ".", "pane", ".", "el", ".", "mouseleave", "(", "$", ".", "proxy", "(", "this", ",", "'mouseleave'", ")", ")", ";", "// dragging", "this", ".", "el", ".", "mousedown", "(", "$", ".", "proxy", "(", "this", ",", "'mousedown'", ")", ")", ";", "// scrolling", "this", ".", "innerPaneScrollListener", "=", "$", ".", "proxy", "(", "this", ",", "'scroll'", ")", ";", "this", ".", "pane", ".", "inner", ".", "scroll", "(", "this", ".", "innerPaneScrollListener", ")", ";", "// wheel -optional-", "this", ".", "innerPaneMouseWheelListener", "=", "$", ".", "proxy", "(", "this", ",", "'mousewheel'", ")", ";", "this", ".", "pane", ".", "inner", ".", "bind", "(", "'mousewheel'", ",", "this", ".", "innerPaneMouseWheelListener", ")", ";", "// show", "var", "initialDisplay", "=", "this", ".", "pane", ".", "options", ".", "initialDisplay", ";", "if", "(", "initialDisplay", "!==", "false", ")", "{", "this", ".", "show", "(", ")", ";", "if", "(", "this", ".", "pane", ".", "autoHide", ")", "{", "this", ".", "hiding", "=", "setTimeout", "(", "$", ".", "proxy", "(", "this", ",", "'hide'", ")", ",", "parseInt", "(", "initialDisplay", ",", "10", ")", "||", "3000", ")", ";", "}", "}", "}" ]
Scrollbar constructor. @param {Element|jQuery} element @api public
[ "Scrollbar", "constructor", "." ]
009a272ee670dbbe5eefb5c070ed827dd778bb07
https://github.com/urturn/urturn-expression-api/blob/009a272ee670dbbe5eefb5c070ed827dd778bb07/lib/modules/antiscroll.costum.js#L149-L182
41,598
urturn/urturn-expression-api
lib/modules/antiscroll.costum.js
inherits
function inherits (ctorA, ctorB) { function f() {} f.prototype = ctorB.prototype; ctorA.prototype = new f(); }
javascript
function inherits (ctorA, ctorB) { function f() {} f.prototype = ctorB.prototype; ctorA.prototype = new f(); }
[ "function", "inherits", "(", "ctorA", ",", "ctorB", ")", "{", "function", "f", "(", ")", "{", "}", "f", ".", "prototype", "=", "ctorB", ".", "prototype", ";", "ctorA", ".", "prototype", "=", "new", "f", "(", ")", ";", "}" ]
Cross-browser inheritance. @param {Function} constructor @param {Function} constructor we inherit from @api private
[ "Cross", "-", "browser", "inheritance", "." ]
009a272ee670dbbe5eefb5c070ed827dd778bb07
https://github.com/urturn/urturn-expression-api/blob/009a272ee670dbbe5eefb5c070ed827dd778bb07/lib/modules/antiscroll.costum.js#L461-L465
41,599
emeryrose/coalescent
lib/middleware/router.js
Router
function Router(socket, options) { stream.Transform.call(this, { objectMode: true }); this.options = merge(Object.create(Router.DEFAULTS), options || {}); this.socket = socket; }
javascript
function Router(socket, options) { stream.Transform.call(this, { objectMode: true }); this.options = merge(Object.create(Router.DEFAULTS), options || {}); this.socket = socket; }
[ "function", "Router", "(", "socket", ",", "options", ")", "{", "stream", ".", "Transform", ".", "call", "(", "this", ",", "{", "objectMode", ":", "true", "}", ")", ";", "this", ".", "options", "=", "merge", "(", "Object", ".", "create", "(", "Router", ".", "DEFAULTS", ")", ",", "options", "||", "{", "}", ")", ";", "this", ".", "socket", "=", "socket", ";", "}" ]
Routes messages parsed with courier to defined handlers by `type` @constructor @param {object} socket @param {object} options
[ "Routes", "messages", "parsed", "with", "courier", "to", "defined", "handlers", "by", "type" ]
5e722d4e1c16b9a9e959b281f6bb07713c60c46a
https://github.com/emeryrose/coalescent/blob/5e722d4e1c16b9a9e959b281f6bb07713c60c46a/lib/middleware/router.js#L23-L28