repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
leapmotion/leapjs
examples/lib/three.js
expand
function expand( v1, v2, pixels ) { var x = v2.x - v1.x, y = v2.y - v1.y, det = x * x + y * y, idet; if ( det === 0 ) return; idet = pixels / Math.sqrt( det ); x *= idet; y *= idet; v2.x += x; v2.y += y; v1.x -= x; v1.y -= y; }
javascript
function expand( v1, v2, pixels ) { var x = v2.x - v1.x, y = v2.y - v1.y, det = x * x + y * y, idet; if ( det === 0 ) return; idet = pixels / Math.sqrt( det ); x *= idet; y *= idet; v2.x += x; v2.y += y; v1.x -= x; v1.y -= y; }
[ "function", "expand", "(", "v1", ",", "v2", ",", "pixels", ")", "{", "var", "x", "=", "v2", ".", "x", "-", "v1", ".", "x", ",", "y", "=", "v2", ".", "y", "-", "v1", ".", "y", ",", "det", "=", "x", "*", "x", "+", "y", "*", "y", ",", "i...
Hide anti-alias gaps
[ "Hide", "anti", "-", "alias", "gaps" ]
31b00723f98077304acda3200f9fbcbaaf29294a
https://github.com/leapmotion/leapjs/blob/31b00723f98077304acda3200f9fbcbaaf29294a/examples/lib/three.js#L17442-L17456
train
leapmotion/leapjs
examples/lib/three.js
binarySearchIndices
function binarySearchIndices( value ) { function binarySearch( start, end ) { // return closest larger index // if exact number is not found if ( end < start ) return start; var mid = start + Math.floor( ( end - start ) / 2 ); if ( cumulativeAreas[ mid ] > value ) { return binaryS...
javascript
function binarySearchIndices( value ) { function binarySearch( start, end ) { // return closest larger index // if exact number is not found if ( end < start ) return start; var mid = start + Math.floor( ( end - start ) / 2 ); if ( cumulativeAreas[ mid ] > value ) { return binaryS...
[ "function", "binarySearchIndices", "(", "value", ")", "{", "function", "binarySearch", "(", "start", ",", "end", ")", "{", "// return closest larger index", "// if exact number is not found", "if", "(", "end", "<", "start", ")", "return", "start", ";", "var", "mid...
binary search cumulative areas array
[ "binary", "search", "cumulative", "areas", "array" ]
31b00723f98077304acda3200f9fbcbaaf29294a
https://github.com/leapmotion/leapjs/blob/31b00723f98077304acda3200f9fbcbaaf29294a/examples/lib/three.js#L27739-L27770
train
leapmotion/leapjs
examples/lib/three.js
function ( geometry ) { geometry.computeBoundingBox(); var bb = geometry.boundingBox; var offset = new THREE.Vector3(); offset.addVectors( bb.min, bb.max ); offset.multiplyScalar( -0.5 ); geometry.applyMatrix( new THREE.Matrix4().makeTranslation( offset.x, offset.y, offset.z ) ); geometry.computeBoun...
javascript
function ( geometry ) { geometry.computeBoundingBox(); var bb = geometry.boundingBox; var offset = new THREE.Vector3(); offset.addVectors( bb.min, bb.max ); offset.multiplyScalar( -0.5 ); geometry.applyMatrix( new THREE.Matrix4().makeTranslation( offset.x, offset.y, offset.z ) ); geometry.computeBoun...
[ "function", "(", "geometry", ")", "{", "geometry", ".", "computeBoundingBox", "(", ")", ";", "var", "bb", "=", "geometry", ".", "boundingBox", ";", "var", "offset", "=", "new", "THREE", ".", "Vector3", "(", ")", ";", "offset", ".", "addVectors", "(", "...
Center geometry so that 0,0,0 is in center of bounding box
[ "Center", "geometry", "so", "that", "0", "0", "0", "is", "in", "center", "of", "bounding", "box" ]
31b00723f98077304acda3200f9fbcbaaf29294a
https://github.com/leapmotion/leapjs/blob/31b00723f98077304acda3200f9fbcbaaf29294a/examples/lib/three.js#L27825-L27841
train
leapmotion/leapjs
examples/lib/three.js
function ( points, scale ) { var c = [], v3 = [], point, intPoint, weight, w2, w3, pa, pb, pc, pd; point = ( points.length - 1 ) * scale; intPoint = Math.floor( point ); weight = point - intPoint; c[ 0 ] = intPoint === 0 ? intPoint : intPoint - 1; c[ 1 ] = intPoint; c[ 2 ] = intPoint > points.lengt...
javascript
function ( points, scale ) { var c = [], v3 = [], point, intPoint, weight, w2, w3, pa, pb, pc, pd; point = ( points.length - 1 ) * scale; intPoint = Math.floor( point ); weight = point - intPoint; c[ 0 ] = intPoint === 0 ? intPoint : intPoint - 1; c[ 1 ] = intPoint; c[ 2 ] = intPoint > points.lengt...
[ "function", "(", "points", ",", "scale", ")", "{", "var", "c", "=", "[", "]", ",", "v3", "=", "[", "]", ",", "point", ",", "intPoint", ",", "weight", ",", "w2", ",", "w3", ",", "pa", ",", "pb", ",", "pc", ",", "pd", ";", "point", "=", "(", ...
Catmull-Rom spline
[ "Catmull", "-", "Rom", "spline" ]
31b00723f98077304acda3200f9fbcbaaf29294a
https://github.com/leapmotion/leapjs/blob/31b00723f98077304acda3200f9fbcbaaf29294a/examples/lib/three.js#L31762-L31791
train
leapmotion/leapjs
examples/lib/three.js
updateVirtualLight
function updateVirtualLight( light, cascade ) { var virtualLight = light.shadowCascadeArray[ cascade ]; virtualLight.position.copy( light.position ); virtualLight.target.position.copy( light.target.position ); virtualLight.lookAt( virtualLight.target ); virtualLight.shadowCameraVisible = light.shadowCamera...
javascript
function updateVirtualLight( light, cascade ) { var virtualLight = light.shadowCascadeArray[ cascade ]; virtualLight.position.copy( light.position ); virtualLight.target.position.copy( light.target.position ); virtualLight.lookAt( virtualLight.target ); virtualLight.shadowCameraVisible = light.shadowCamera...
[ "function", "updateVirtualLight", "(", "light", ",", "cascade", ")", "{", "var", "virtualLight", "=", "light", ".", "shadowCascadeArray", "[", "cascade", "]", ";", "virtualLight", ".", "position", ".", "copy", "(", "light", ".", "position", ")", ";", "virtua...
Synchronize virtual light with the original light
[ "Synchronize", "virtual", "light", "with", "the", "original", "light" ]
31b00723f98077304acda3200f9fbcbaaf29294a
https://github.com/leapmotion/leapjs/blob/31b00723f98077304acda3200f9fbcbaaf29294a/examples/lib/three.js#L37655-L37683
train
leapmotion/leapjs
examples/lib/three.js
updateShadowCamera
function updateShadowCamera( camera, light ) { var shadowCamera = light.shadowCamera, pointsFrustum = light.pointsFrustum, pointsWorld = light.pointsWorld; _min.set( Infinity, Infinity, Infinity ); _max.set( -Infinity, -Infinity, -Infinity ); for ( var i = 0; i < 8; i ++ ) { var p = pointsWorld[ i ...
javascript
function updateShadowCamera( camera, light ) { var shadowCamera = light.shadowCamera, pointsFrustum = light.pointsFrustum, pointsWorld = light.pointsWorld; _min.set( Infinity, Infinity, Infinity ); _max.set( -Infinity, -Infinity, -Infinity ); for ( var i = 0; i < 8; i ++ ) { var p = pointsWorld[ i ...
[ "function", "updateShadowCamera", "(", "camera", ",", "light", ")", "{", "var", "shadowCamera", "=", "light", ".", "shadowCamera", ",", "pointsFrustum", "=", "light", ".", "pointsFrustum", ",", "pointsWorld", "=", "light", ".", "pointsWorld", ";", "_min", ".",...
Fit shadow camera's ortho frustum to camera frustum
[ "Fit", "shadow", "camera", "s", "ortho", "frustum", "to", "camera", "frustum" ]
31b00723f98077304acda3200f9fbcbaaf29294a
https://github.com/leapmotion/leapjs/blob/31b00723f98077304acda3200f9fbcbaaf29294a/examples/lib/three.js#L37687-L37727
train
leapmotion/leapjs
examples/lib/three.js
getObjectMaterial
function getObjectMaterial( object ) { return object.material instanceof THREE.MeshFaceMaterial ? object.material.materials[ 0 ] : object.material; }
javascript
function getObjectMaterial( object ) { return object.material instanceof THREE.MeshFaceMaterial ? object.material.materials[ 0 ] : object.material; }
[ "function", "getObjectMaterial", "(", "object", ")", "{", "return", "object", ".", "material", "instanceof", "THREE", ".", "MeshFaceMaterial", "?", "object", ".", "material", ".", "materials", "[", "0", "]", ":", "object", ".", "material", ";", "}" ]
For the moment just ignore objects that have multiple materials with different animation methods Only the first material will be taken into account for deciding which depth material to use for shadow maps
[ "For", "the", "moment", "just", "ignore", "objects", "that", "have", "multiple", "materials", "with", "different", "animation", "methods", "Only", "the", "first", "material", "will", "be", "taken", "into", "account", "for", "deciding", "which", "depth", "materia...
31b00723f98077304acda3200f9fbcbaaf29294a
https://github.com/leapmotion/leapjs/blob/31b00723f98077304acda3200f9fbcbaaf29294a/examples/lib/three.js#L37732-L37738
train
leapmotion/leapjs
examples/lib/leap-plugins-0.1.6.js
function(){ this.frameIndex++; if (this.frameIndex >= this.rightCropPosition) { this.frameIndex = this.frameIndex % (this.rightCropPosition || 1); if ((this.frameIndex < this.leftCropPosition)) { this.frameIndex = this.leftCropPosition; } }else{ this.frameIndex--; } }
javascript
function(){ this.frameIndex++; if (this.frameIndex >= this.rightCropPosition) { this.frameIndex = this.frameIndex % (this.rightCropPosition || 1); if ((this.frameIndex < this.leftCropPosition)) { this.frameIndex = this.leftCropPosition; } }else{ this.frameIndex--; } }
[ "function", "(", ")", "{", "this", ".", "frameIndex", "++", ";", "if", "(", "this", ".", "frameIndex", ">=", "this", ".", "rightCropPosition", ")", "{", "this", ".", "frameIndex", "=", "this", ".", "frameIndex", "%", "(", "this", ".", "rightCropPosition"...
resets to beginning if at end
[ "resets", "to", "beginning", "if", "at", "end" ]
31b00723f98077304acda3200f9fbcbaaf29294a
https://github.com/leapmotion/leapjs/blob/31b00723f98077304acda3200f9fbcbaaf29294a/examples/lib/leap-plugins-0.1.6.js#L996-L1007
train
leapmotion/leapjs
examples/lib/leap-plugins-0.1.6.js
function (factor) { console.log('cull frames', factor); factor || (factor = 1); for (var i = 0; i < this.frameData.length; i++) { this.frameData.splice(i, factor); } this.setMetaData(); }
javascript
function (factor) { console.log('cull frames', factor); factor || (factor = 1); for (var i = 0; i < this.frameData.length; i++) { this.frameData.splice(i, factor); } this.setMetaData(); }
[ "function", "(", "factor", ")", "{", "console", ".", "log", "(", "'cull frames'", ",", "factor", ")", ";", "factor", "||", "(", "factor", "=", "1", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "this", ".", "frameData", ".", "length"...
removes every other frame from the array Accepts an optional `factor` integer, which is the number of frames discarded for every frame kept.
[ "removes", "every", "other", "frame", "from", "the", "array", "Accepts", "an", "optional", "factor", "integer", "which", "is", "the", "number", "of", "frames", "discarded", "for", "every", "frame", "kept", "." ]
31b00723f98077304acda3200f9fbcbaaf29294a
https://github.com/leapmotion/leapjs/blob/31b00723f98077304acda3200f9fbcbaaf29294a/examples/lib/leap-plugins-0.1.6.js#L1115-L1122
train
leapmotion/leapjs
examples/lib/leap-plugins-0.1.6.js
function () { if (this.frameData.length == 0) { return 0 } return this.frameData.length / (this.frameData[this.frameData.length - 1].timestamp - this.frameData[0].timestamp) * 1000000; }
javascript
function () { if (this.frameData.length == 0) { return 0 } return this.frameData.length / (this.frameData[this.frameData.length - 1].timestamp - this.frameData[0].timestamp) * 1000000; }
[ "function", "(", ")", "{", "if", "(", "this", ".", "frameData", ".", "length", "==", "0", ")", "{", "return", "0", "}", "return", "this", ".", "frameData", ".", "length", "/", "(", "this", ".", "frameData", "[", "this", ".", "frameData", ".", "leng...
Returns the average frames per second of the recording
[ "Returns", "the", "average", "frames", "per", "second", "of", "the", "recording" ]
31b00723f98077304acda3200f9fbcbaaf29294a
https://github.com/leapmotion/leapjs/blob/31b00723f98077304acda3200f9fbcbaaf29294a/examples/lib/leap-plugins-0.1.6.js#L1125-L1130
train
leapmotion/leapjs
examples/lib/leap-plugins-0.1.6.js
function(){ var frameData = this.croppedFrameData(), packedFrames = [], frameDatum; packedFrames.push(this.packingStructure); for (var i = 0, len = frameData.length; i < len; i++){ frameDatum = frameData[i]; packedFrames.push( this.packArray( this.packingStructur...
javascript
function(){ var frameData = this.croppedFrameData(), packedFrames = [], frameDatum; packedFrames.push(this.packingStructure); for (var i = 0, len = frameData.length; i < len; i++){ frameDatum = frameData[i]; packedFrames.push( this.packArray( this.packingStructur...
[ "function", "(", ")", "{", "var", "frameData", "=", "this", ".", "croppedFrameData", "(", ")", ",", "packedFrames", "=", "[", "]", ",", "frameDatum", ";", "packedFrames", ".", "push", "(", "this", ".", "packingStructure", ")", ";", "for", "(", "var", "...
returns an array the first item is the keys of the following items nested arrays are expected to have idententical siblings
[ "returns", "an", "array", "the", "first", "item", "is", "the", "keys", "of", "the", "following", "items", "nested", "arrays", "are", "expected", "to", "have", "idententical", "siblings" ]
31b00723f98077304acda3200f9fbcbaaf29294a
https://github.com/leapmotion/leapjs/blob/31b00723f98077304acda3200f9fbcbaaf29294a/examples/lib/leap-plugins-0.1.6.js#L1160-L1180
train
leapmotion/leapjs
examples/lib/leap-plugins-0.1.6.js
function(packedFrames){ var packingStructure = packedFrames[0]; var frameData = [], frameDatum; for (var i = 1, len = packedFrames.length; i < len; i++) { frameDatum = packedFrames[i]; frameData.push( this.unPackArray( packingStructure, frameDatum ) ...
javascript
function(packedFrames){ var packingStructure = packedFrames[0]; var frameData = [], frameDatum; for (var i = 1, len = packedFrames.length; i < len; i++) { frameDatum = packedFrames[i]; frameData.push( this.unPackArray( packingStructure, frameDatum ) ...
[ "function", "(", "packedFrames", ")", "{", "var", "packingStructure", "=", "packedFrames", "[", "0", "]", ";", "var", "frameData", "=", "[", "]", ",", "frameDatum", ";", "for", "(", "var", "i", "=", "1", ",", "len", "=", "packedFrames", ".", "length", ...
expects the first array element to describe the following arrays this algorithm copies frames to a new array could there be merit in something which would do an in-place substitution?
[ "expects", "the", "first", "array", "element", "to", "describe", "the", "following", "arrays", "this", "algorithm", "copies", "frames", "to", "a", "new", "array", "could", "there", "be", "merit", "in", "something", "which", "would", "do", "an", "in", "-", ...
31b00723f98077304acda3200f9fbcbaaf29294a
https://github.com/leapmotion/leapjs/blob/31b00723f98077304acda3200f9fbcbaaf29294a/examples/lib/leap-plugins-0.1.6.js#L1236-L1253
train
leapmotion/leapjs
examples/lib/leap-plugins-0.1.6.js
function (callback) { var xhr = new XMLHttpRequest(), url = this.url, recording = this, contentLength = 0; xhr.onreadystatechange = function () { if (xhr.readyState === xhr.DONE) { if (xhr.status === 200 || xhr.status === 0) { if (xhr.responseText) { ...
javascript
function (callback) { var xhr = new XMLHttpRequest(), url = this.url, recording = this, contentLength = 0; xhr.onreadystatechange = function () { if (xhr.readyState === xhr.DONE) { if (xhr.status === 200 || xhr.status === 0) { if (xhr.responseText) { ...
[ "function", "(", "callback", ")", "{", "var", "xhr", "=", "new", "XMLHttpRequest", "(", ")", ",", "url", "=", "this", ".", "url", ",", "recording", "=", "this", ",", "contentLength", "=", "0", ";", "xhr", ".", "onreadystatechange", "=", "function", "("...
optional callback once frames are loaded, will have a context of player
[ "optional", "callback", "once", "frames", "are", "loaded", "will", "have", "a", "context", "of", "player" ]
31b00723f98077304acda3200f9fbcbaaf29294a
https://github.com/leapmotion/leapjs/blob/31b00723f98077304acda3200f9fbcbaaf29294a/examples/lib/leap-plugins-0.1.6.js#L1381-L1420
train
leapmotion/leapjs
examples/lib/leap-plugins-0.1.6.js
function () { this.idle(); delete this.recording; this.recording = new Recording({ timeBetweenLoops: this.options.timeBetweenLoops, loop: this.options.loop, requestProtocolVersion: this.controller.connection.opts.requestProtocolVersion, service...
javascript
function () { this.idle(); delete this.recording; this.recording = new Recording({ timeBetweenLoops: this.options.timeBetweenLoops, loop: this.options.loop, requestProtocolVersion: this.controller.connection.opts.requestProtocolVersion, service...
[ "function", "(", ")", "{", "this", ".", "idle", "(", ")", ";", "delete", "this", ".", "recording", ";", "this", ".", "recording", "=", "new", "Recording", "(", "{", "timeBetweenLoops", ":", "this", ".", "options", ".", "timeBetweenLoops", ",", "loop", ...
used after record
[ "used", "after", "record" ]
31b00723f98077304acda3200f9fbcbaaf29294a
https://github.com/leapmotion/leapjs/blob/31b00723f98077304acda3200f9fbcbaaf29294a/examples/lib/leap-plugins-0.1.6.js#L1646-L1659
train
leapmotion/leapjs
examples/lib/leap-plugins-0.1.6.js
function () { if (!this.recording || this.recording.blank()) return; var finalFrame = this.recording.cloneCurrentFrame(); finalFrame.hands = []; finalFrame.fingers = []; finalFrame.pointables = []; finalFrame.tools = []; this.sendImmediateFrame(finalFrame); }
javascript
function () { if (!this.recording || this.recording.blank()) return; var finalFrame = this.recording.cloneCurrentFrame(); finalFrame.hands = []; finalFrame.fingers = []; finalFrame.pointables = []; finalFrame.tools = []; this.sendImmediateFrame(finalFrame); }
[ "function", "(", ")", "{", "if", "(", "!", "this", ".", "recording", "||", "this", ".", "recording", ".", "blank", "(", ")", ")", "return", ";", "var", "finalFrame", "=", "this", ".", "recording", ".", "cloneCurrentFrame", "(", ")", ";", "finalFrame", ...
if there is existing frame data, sends a frame with nothing in it
[ "if", "there", "is", "existing", "frame", "data", "sends", "a", "frame", "with", "nothing", "in", "it" ]
31b00723f98077304acda3200f9fbcbaaf29294a
https://github.com/leapmotion/leapjs/blob/31b00723f98077304acda3200f9fbcbaaf29294a/examples/lib/leap-plugins-0.1.6.js#L1696-L1704
train
leapmotion/leapjs
examples/lib/leap-plugins-0.1.6.js
function (frameData) { // Would be better to check controller.streaming() in showOverlay, but that method doesn't exist, yet. this.setGraphic('wave'); if (frameData.hands.length > 0) { this.recording.addFrame(frameData); this.hideOverlay(); } else if ( !this.recording.blank() ) {...
javascript
function (frameData) { // Would be better to check controller.streaming() in showOverlay, but that method doesn't exist, yet. this.setGraphic('wave'); if (frameData.hands.length > 0) { this.recording.addFrame(frameData); this.hideOverlay(); } else if ( !this.recording.blank() ) {...
[ "function", "(", "frameData", ")", "{", "// Would be better to check controller.streaming() in showOverlay, but that method doesn't exist, yet.", "this", ".", "setGraphic", "(", "'wave'", ")", ";", "if", "(", "frameData", ".", "hands", ".", "length", ">", "0", ")", "{",...
this method replaces connection.handleData when in record mode It accepts the raw connection data which is used to make a frame.
[ "this", "method", "replaces", "connection", ".", "handleData", "when", "in", "record", "mode", "It", "accepts", "the", "raw", "connection", "data", "which", "is", "used", "to", "make", "a", "frame", "." ]
31b00723f98077304acda3200f9fbcbaaf29294a
https://github.com/leapmotion/leapjs/blob/31b00723f98077304acda3200f9fbcbaaf29294a/examples/lib/leap-plugins-0.1.6.js#L1767-L1776
train
leapmotion/leapjs
examples/lib/leap-plugins-0.1.6.js
function (frames) { this.setFrames(frames); if (player.recording != this){ console.log('recordings changed during load'); return } // it would be better to use streamingCount here, but that won't be in until 0.5.0+ // For now, it just flashes for a moment u...
javascript
function (frames) { this.setFrames(frames); if (player.recording != this){ console.log('recordings changed during load'); return } // it would be better to use streamingCount here, but that won't be in until 0.5.0+ // For now, it just flashes for a moment u...
[ "function", "(", "frames", ")", "{", "this", ".", "setFrames", "(", "frames", ")", ";", "if", "(", "player", ".", "recording", "!=", "this", ")", "{", "console", ".", "log", "(", "'recordings changed during load'", ")", ";", "return", "}", "// it would be ...
this is called on the context of the recording
[ "this", "is", "called", "on", "the", "context", "of", "the", "recording" ]
31b00723f98077304acda3200f9fbcbaaf29294a
https://github.com/leapmotion/leapjs/blob/31b00723f98077304acda3200f9fbcbaaf29294a/examples/lib/leap-plugins-0.1.6.js#L1789-L1809
train
leapmotion/leapjs
examples/lib/leap-plugins-0.1.6.js
function (graphicName) { if (!this.overlay) return; if (this.graphicName == graphicName) return; this.graphicName = graphicName; switch (graphicName) { case 'connect': this.overlay.style.display = 'block'; this.overlay.innerHTML = CONNECT_LEAP_ICON; break; ...
javascript
function (graphicName) { if (!this.overlay) return; if (this.graphicName == graphicName) return; this.graphicName = graphicName; switch (graphicName) { case 'connect': this.overlay.style.display = 'block'; this.overlay.innerHTML = CONNECT_LEAP_ICON; break; ...
[ "function", "(", "graphicName", ")", "{", "if", "(", "!", "this", ".", "overlay", ")", "return", ";", "if", "(", "this", ".", "graphicName", "==", "graphicName", ")", "return", ";", "this", ".", "graphicName", "=", "graphicName", ";", "switch", "(", "g...
Accepts either "connect", "wave", or undefined.
[ "Accepts", "either", "connect", "wave", "or", "undefined", "." ]
31b00723f98077304acda3200f9fbcbaaf29294a
https://github.com/leapmotion/leapjs/blob/31b00723f98077304acda3200f9fbcbaaf29294a/examples/lib/leap-plugins-0.1.6.js#L1858-L1876
train
formly-js/vue-formly
src/util.js
hasNestedProperty
function hasNestedProperty(obj, propertyPath, returnVal = false) { if (!propertyPath) return false; // strip the leading dot propertyPath = propertyPath.replace(/^\./, ''); const properties = propertyPath.split('.'); for (var i = 0; i < properties.length; i++) { var prop = properties[i]; if (!obj |...
javascript
function hasNestedProperty(obj, propertyPath, returnVal = false) { if (!propertyPath) return false; // strip the leading dot propertyPath = propertyPath.replace(/^\./, ''); const properties = propertyPath.split('.'); for (var i = 0; i < properties.length; i++) { var prop = properties[i]; if (!obj |...
[ "function", "hasNestedProperty", "(", "obj", ",", "propertyPath", ",", "returnVal", "=", "false", ")", "{", "if", "(", "!", "propertyPath", ")", "return", "false", ";", "// strip the leading dot", "propertyPath", "=", "propertyPath", ".", "replace", "(", "/", ...
Checks to see whether an object has a deeply nested path @param {Object} target @param {String} propertyPath @param {Boolean} returnVal @returns {Boolean || Any} will return either true/false for existance or the actual value
[ "Checks", "to", "see", "whether", "an", "object", "has", "a", "deeply", "nested", "path" ]
37975d401f1acd17abf31792bb411b60b2dfedf3
https://github.com/formly-js/vue-formly/blob/37975d401f1acd17abf31792bb411b60b2dfedf3/src/util.js#L58-L76
train
aichaos/rivescript-js
eg/web-client/datadumper.js
DumperGetArgs
function DumperGetArgs(a,index) { var args = new Array(); // This is kind of ugly, but I don't want to use js1.2 functions, just in case... for (var i=index; i<a.length; i++) { args[args.length] = a[i]; } return args; }
javascript
function DumperGetArgs(a,index) { var args = new Array(); // This is kind of ugly, but I don't want to use js1.2 functions, just in case... for (var i=index; i<a.length; i++) { args[args.length] = a[i]; } return args; }
[ "function", "DumperGetArgs", "(", "a", ",", "index", ")", "{", "var", "args", "=", "new", "Array", "(", ")", ";", "// This is kind of ugly, but I don't want to use js1.2 functions, just in case...", "for", "(", "var", "i", "=", "index", ";", "i", "<", "a", ".", ...
Holds properties to traverse for certain HTML tags
[ "Holds", "properties", "to", "traverse", "for", "certain", "HTML", "tags" ]
7f9407cda0d663d956666ae338e0f57d9dfe9785
https://github.com/aichaos/rivescript-js/blob/7f9407cda0d663d956666ae338e0f57d9dfe9785/eg/web-client/datadumper.js#L59-L66
train
aichaos/rivescript-js
eg/reply-async/weatherman.js
function(onReady) { var self = this; if (APPID === 'change me') { console.log('Error -- edit weatherman.js and provide the APPID for Open Weathermap.'.bold.yellow); } // Load the replies and process them. rs.loadFile("weatherman.rive").then(function() { rs.sortReplies(); onReady(); }).catch(function(err) ...
javascript
function(onReady) { var self = this; if (APPID === 'change me') { console.log('Error -- edit weatherman.js and provide the APPID for Open Weathermap.'.bold.yellow); } // Load the replies and process them. rs.loadFile("weatherman.rive").then(function() { rs.sortReplies(); onReady(); }).catch(function(err) ...
[ "function", "(", "onReady", ")", "{", "var", "self", "=", "this", ";", "if", "(", "APPID", "===", "'change me'", ")", "{", "console", ".", "log", "(", "'Error -- edit weatherman.js and provide the APPID for Open Weathermap.'", ".", "bold", ".", "yellow", ")", ";...
Create a prototypical class for our own chatbot.
[ "Create", "a", "prototypical", "class", "for", "our", "own", "chatbot", "." ]
7f9407cda0d663d956666ae338e0f57d9dfe9785
https://github.com/aichaos/rivescript-js/blob/7f9407cda0d663d956666ae338e0f57d9dfe9785/eg/reply-async/weatherman.js#L65-L95
train
aichaos/rivescript-js
eg/router/router.js
function(rs, args) { // This function is invoked by messages such as: // what is 5 subtracted by 2 // add 6 to 7 if (args[0].match(/^\d+$/)) { // They used the first form, with a number. return Controllers.doMath(args[1], args[0], args[2]); } else { // The second form, first word being...
javascript
function(rs, args) { // This function is invoked by messages such as: // what is 5 subtracted by 2 // add 6 to 7 if (args[0].match(/^\d+$/)) { // They used the first form, with a number. return Controllers.doMath(args[1], args[0], args[2]); } else { // The second form, first word being...
[ "function", "(", "rs", ",", "args", ")", "{", "// This function is invoked by messages such as:", "// what is 5 subtracted by 2", "// add 6 to 7", "if", "(", "args", "[", "0", "]", ".", "match", "(", "/", "^\\d+$", "/", ")", ")", "{", "// They used the first for...
The object macro function itself.
[ "The", "object", "macro", "function", "itself", "." ]
7f9407cda0d663d956666ae338e0f57d9dfe9785
https://github.com/aichaos/rivescript-js/blob/7f9407cda0d663d956666ae338e0f57d9dfe9785/eg/router/router.js#L29-L41
train
docusign/docusign-node-client
src/auth/errors/docusignapierror.js
DocusignAPIError
function DocusignAPIError(message, type, code, subcode, traceID) { Error.call(this); Error.captureStackTrace(this, arguments.callee); this.name = 'DocusignAPIError'; this.message = message; this.type = type; this.code = code; this.subcode = subcode; this.traceID = traceID; this.status = 500; }
javascript
function DocusignAPIError(message, type, code, subcode, traceID) { Error.call(this); Error.captureStackTrace(this, arguments.callee); this.name = 'DocusignAPIError'; this.message = message; this.type = type; this.code = code; this.subcode = subcode; this.traceID = traceID; this.status = 500; }
[ "function", "DocusignAPIError", "(", "message", ",", "type", ",", "code", ",", "subcode", ",", "traceID", ")", "{", "Error", ".", "call", "(", "this", ")", ";", "Error", ".", "captureStackTrace", "(", "this", ",", "arguments", ".", "callee", ")", ";", ...
`DocusignAPIError` error. References: - https://www.docusign.com/p/RESTAPIGuide/RESTAPIGuide.htm#OAuth2/OAuth2 Response Codes.htm @constructor @param {string} [message] @param {string} [type] @param {number} [code] @param {number} [subcode] @param {string} [traceID] @access public
[ "DocusignAPIError", "error", "." ]
3fb90b1afba3b2e0e94f55592120425b4c4f0aab
https://github.com/docusign/docusign-node-client/blob/3fb90b1afba3b2e0e94f55592120425b4c4f0aab/src/auth/errors/docusignapierror.js#L15-L25
train
koajs/joi-router
joi-router.js
checkMethods
function checkMethods(spec) { assert(spec.method, 'missing route methods'); if (typeof spec.method === 'string') { spec.method = spec.method.split(' '); } if (!Array.isArray(spec.method)) { throw new TypeError('route methods must be an array or string'); } if (spec.method.length === 0) { thro...
javascript
function checkMethods(spec) { assert(spec.method, 'missing route methods'); if (typeof spec.method === 'string') { spec.method = spec.method.split(' '); } if (!Array.isArray(spec.method)) { throw new TypeError('route methods must be an array or string'); } if (spec.method.length === 0) { thro...
[ "function", "checkMethods", "(", "spec", ")", "{", "assert", "(", "spec", ".", "method", ",", "'missing route methods'", ")", ";", "if", "(", "typeof", "spec", ".", "method", "===", "'string'", ")", "{", "spec", ".", "method", "=", "spec", ".", "method",...
Validate the spec.method @param {Object} spec @api private
[ "Validate", "the", "spec", ".", "method" ]
509a0e6c1699ea7cb5bd9c8f340c8bcbae225247
https://github.com/koajs/joi-router/blob/509a0e6c1699ea7cb5bd9c8f340c8bcbae225247/joi-router.js#L206-L225
train
koajs/joi-router
joi-router.js
checkValidators
function checkValidators(spec) { if (!spec.validate) return; let text; if (spec.validate.body) { text = 'validate.type must be declared when using validate.body'; assert(/json|form/.test(spec.validate.type), text); } if (spec.validate.type) { text = 'validate.type must be either json, form, mult...
javascript
function checkValidators(spec) { if (!spec.validate) return; let text; if (spec.validate.body) { text = 'validate.type must be declared when using validate.body'; assert(/json|form/.test(spec.validate.type), text); } if (spec.validate.type) { text = 'validate.type must be either json, form, mult...
[ "function", "checkValidators", "(", "spec", ")", "{", "if", "(", "!", "spec", ".", "validate", ")", "return", ";", "let", "text", ";", "if", "(", "spec", ".", "validate", ".", "body", ")", "{", "text", "=", "'validate.type must be declared when using validat...
Validate the spec.validators @param {Object} spec @api private
[ "Validate", "the", "spec", ".", "validators" ]
509a0e6c1699ea7cb5bd9c8f340c8bcbae225247
https://github.com/koajs/joi-router/blob/509a0e6c1699ea7cb5bd9c8f340c8bcbae225247/joi-router.js#L234-L256
train
koajs/joi-router
joi-router.js
wrapError
function wrapError(spec, parsePayload) { return async function errorHandler(ctx, next) { try { await parsePayload(ctx, next); } catch (err) { captureError(ctx, 'type', err); if (spec.validate.continueOnError) { return await next(); } else { return ctx.throw(err); ...
javascript
function wrapError(spec, parsePayload) { return async function errorHandler(ctx, next) { try { await parsePayload(ctx, next); } catch (err) { captureError(ctx, 'type', err); if (spec.validate.continueOnError) { return await next(); } else { return ctx.throw(err); ...
[ "function", "wrapError", "(", "spec", ",", "parsePayload", ")", "{", "return", "async", "function", "errorHandler", "(", "ctx", ",", "next", ")", "{", "try", "{", "await", "parsePayload", "(", "ctx", ",", "next", ")", ";", "}", "catch", "(", "err", ")"...
Handles parser internal errors @param {Object} spec [description] @param {function} parsePayload [description] @return {async function} [description] @api private
[ "Handles", "parser", "internal", "errors" ]
509a0e6c1699ea7cb5bd9c8f340c8bcbae225247
https://github.com/koajs/joi-router/blob/509a0e6c1699ea7cb5bd9c8f340c8bcbae225247/joi-router.js#L278-L291
train
koajs/joi-router
joi-router.js
makeJSONBodyParser
function makeJSONBodyParser(spec) { const opts = spec.validate.jsonOptions || {}; if (typeof opts.limit === 'undefined') { opts.limit = spec.validate.maxBody; } return async function parseJSONPayload(ctx, next) { if (!ctx.request.is('json')) { return ctx.throw(400, 'expected json'); } ctx...
javascript
function makeJSONBodyParser(spec) { const opts = spec.validate.jsonOptions || {}; if (typeof opts.limit === 'undefined') { opts.limit = spec.validate.maxBody; } return async function parseJSONPayload(ctx, next) { if (!ctx.request.is('json')) { return ctx.throw(400, 'expected json'); } ctx...
[ "function", "makeJSONBodyParser", "(", "spec", ")", "{", "const", "opts", "=", "spec", ".", "validate", ".", "jsonOptions", "||", "{", "}", ";", "if", "(", "typeof", "opts", ".", "limit", "===", "'undefined'", ")", "{", "opts", ".", "limit", "=", "spec...
Creates JSON body parser middleware. @param {Object} spec @return {async function} @api private
[ "Creates", "JSON", "body", "parser", "middleware", "." ]
509a0e6c1699ea7cb5bd9c8f340c8bcbae225247
https://github.com/koajs/joi-router/blob/509a0e6c1699ea7cb5bd9c8f340c8bcbae225247/joi-router.js#L301-L314
train
koajs/joi-router
joi-router.js
makeFormBodyParser
function makeFormBodyParser(spec) { const opts = spec.validate.formOptions || {}; if (typeof opts.limit === 'undefined') { opts.limit = spec.validate.maxBody; } return async function parseFormBody(ctx, next) { if (!ctx.request.is('urlencoded')) { return ctx.throw(400, 'expected x-www-form-urlencod...
javascript
function makeFormBodyParser(spec) { const opts = spec.validate.formOptions || {}; if (typeof opts.limit === 'undefined') { opts.limit = spec.validate.maxBody; } return async function parseFormBody(ctx, next) { if (!ctx.request.is('urlencoded')) { return ctx.throw(400, 'expected x-www-form-urlencod...
[ "function", "makeFormBodyParser", "(", "spec", ")", "{", "const", "opts", "=", "spec", ".", "validate", ".", "formOptions", "||", "{", "}", ";", "if", "(", "typeof", "opts", ".", "limit", "===", "'undefined'", ")", "{", "opts", ".", "limit", "=", "spec...
Creates form body parser middleware. @param {Object} spec @return {async function} @api private
[ "Creates", "form", "body", "parser", "middleware", "." ]
509a0e6c1699ea7cb5bd9c8f340c8bcbae225247
https://github.com/koajs/joi-router/blob/509a0e6c1699ea7cb5bd9c8f340c8bcbae225247/joi-router.js#L324-L336
train
koajs/joi-router
joi-router.js
makeBodyParser
function makeBodyParser(spec) { if (!(spec.validate && spec.validate.type)) return noopMiddleware; switch (spec.validate.type) { case 'json': return wrapError(spec, makeJSONBodyParser(spec)); case 'form': return wrapError(spec, makeFormBodyParser(spec)); case 'stream': case 'multipart':...
javascript
function makeBodyParser(spec) { if (!(spec.validate && spec.validate.type)) return noopMiddleware; switch (spec.validate.type) { case 'json': return wrapError(spec, makeJSONBodyParser(spec)); case 'form': return wrapError(spec, makeFormBodyParser(spec)); case 'stream': case 'multipart':...
[ "function", "makeBodyParser", "(", "spec", ")", "{", "if", "(", "!", "(", "spec", ".", "validate", "&&", "spec", ".", "validate", ".", "type", ")", ")", "return", "noopMiddleware", ";", "switch", "(", "spec", ".", "validate", ".", "type", ")", "{", "...
Creates body parser middleware. @param {Object} spec @return {async function} @api private
[ "Creates", "body", "parser", "middleware", "." ]
509a0e6c1699ea7cb5bd9c8f340c8bcbae225247
https://github.com/koajs/joi-router/blob/509a0e6c1699ea7cb5bd9c8f340c8bcbae225247/joi-router.js#L368-L382
train
koajs/joi-router
joi-router.js
makeValidator
function makeValidator(spec) { const props = 'header query params body'.split(' '); return async function validator(ctx, next) { if (!spec.validate) return await next(); let err; for (let i = 0; i < props.length; ++i) { const prop = props[i]; if (spec.validate[prop]) { err = vali...
javascript
function makeValidator(spec) { const props = 'header query params body'.split(' '); return async function validator(ctx, next) { if (!spec.validate) return await next(); let err; for (let i = 0; i < props.length; ++i) { const prop = props[i]; if (spec.validate[prop]) { err = vali...
[ "function", "makeValidator", "(", "spec", ")", "{", "const", "props", "=", "'header query params body'", ".", "split", "(", "' '", ")", ";", "return", "async", "function", "validator", "(", "ctx", ",", "next", ")", "{", "if", "(", "!", "spec", ".", "vali...
Creates validator middleware. @param {Object} spec @return {async function} @api private
[ "Creates", "validator", "middleware", "." ]
509a0e6c1699ea7cb5bd9c8f340c8bcbae225247
https://github.com/koajs/joi-router/blob/509a0e6c1699ea7cb5bd9c8f340c8bcbae225247/joi-router.js#L403-L436
train
koajs/joi-router
joi-router.js
makeSpecExposer
function makeSpecExposer(spec) { const defn = clone(spec); return async function specExposer(ctx, next) { ctx.state.route = defn; await next(); }; }
javascript
function makeSpecExposer(spec) { const defn = clone(spec); return async function specExposer(ctx, next) { ctx.state.route = defn; await next(); }; }
[ "function", "makeSpecExposer", "(", "spec", ")", "{", "const", "defn", "=", "clone", "(", "spec", ")", ";", "return", "async", "function", "specExposer", "(", "ctx", ",", "next", ")", "{", "ctx", ".", "state", ".", "route", "=", "defn", ";", "await", ...
Exposes route spec @param {Object} spec The route spec @returns {async Function} Middleware @api private
[ "Exposes", "route", "spec" ]
509a0e6c1699ea7cb5bd9c8f340c8bcbae225247
https://github.com/koajs/joi-router/blob/509a0e6c1699ea7cb5bd9c8f340c8bcbae225247/joi-router.js#L444-L450
train
koajs/joi-router
joi-router.js
prepareRequest
async function prepareRequest(ctx, next) { ctx.request.params = ctx.params; await next(); }
javascript
async function prepareRequest(ctx, next) { ctx.request.params = ctx.params; await next(); }
[ "async", "function", "prepareRequest", "(", "ctx", ",", "next", ")", "{", "ctx", ".", "request", ".", "params", "=", "ctx", ".", "params", ";", "await", "next", "(", ")", ";", "}" ]
Middleware which creates `request.params`. @api private
[ "Middleware", "which", "creates", "request", ".", "params", "." ]
509a0e6c1699ea7cb5bd9c8f340c8bcbae225247
https://github.com/koajs/joi-router/blob/509a0e6c1699ea7cb5bd9c8f340c8bcbae225247/joi-router.js#L458-L461
train
unosquare/tubular
src/js/tubular/services/tubularConfig.js
addConfig
function addConfig(configObj, platformObj) { for (const n in configObj) { if (n != PLATFORM && configObj.hasOwnProperty(n)) { if (angular.isObject(configObj[n])) { if (angular.isUndefined(platformObj[n])) { ...
javascript
function addConfig(configObj, platformObj) { for (const n in configObj) { if (n != PLATFORM && configObj.hasOwnProperty(n)) { if (angular.isObject(configObj[n])) { if (angular.isUndefined(platformObj[n])) { ...
[ "function", "addConfig", "(", "configObj", ",", "platformObj", ")", "{", "for", "(", "const", "n", "in", "configObj", ")", "{", "if", "(", "n", "!=", "PLATFORM", "&&", "configObj", ".", "hasOwnProperty", "(", "n", ")", ")", "{", "if", "(", "angular", ...
add new platform configs
[ "add", "new", "platform", "configs" ]
4863f519b838df9f30ae4786704a939bca7a481f
https://github.com/unosquare/tubular/blob/4863f519b838df9f30ae4786704a939bca7a481f/src/js/tubular/services/tubularConfig.js#L66-L80
train
flowtype/flow-remove-types
index.js
removeImplementedInterfaces
function removeImplementedInterfaces(context, node, ast) { if (node.implements && node.implements.length > 0) { var first = node.implements[0]; var last = node.implements[node.implements.length - 1]; var idx = findTokenIndex(ast.tokens, first.start); do { idx--; } while (ast.tokens[idx].valu...
javascript
function removeImplementedInterfaces(context, node, ast) { if (node.implements && node.implements.length > 0) { var first = node.implements[0]; var last = node.implements[node.implements.length - 1]; var idx = findTokenIndex(ast.tokens, first.start); do { idx--; } while (ast.tokens[idx].valu...
[ "function", "removeImplementedInterfaces", "(", "context", ",", "node", ",", "ast", ")", "{", "if", "(", "node", ".", "implements", "&&", "node", ".", "implements", ".", "length", ">", "0", ")", "{", "var", "first", "=", "node", ".", "implements", "[", ...
If this class declaration or expression implements interfaces, remove the associated tokens.
[ "If", "this", "class", "declaration", "or", "expression", "implements", "interfaces", "remove", "the", "associated", "tokens", "." ]
d6e560f21c8f7221f6a6fb7f1bed1ec923397b8f
https://github.com/flowtype/flow-remove-types/blob/d6e560f21c8f7221f6a6fb7f1bed1ec923397b8f/index.js#L200-L216
train
flowtype/flow-remove-types
register.js
regexpPattern
function regexpPattern(pattern) { if (!pattern) { return pattern; } // A very simplified glob transform which allows passing legible strings like // "myPath/*.js" instead of a harder to read RegExp like /\/myPath\/.*\.js/. if (typeof pattern === 'string') { pattern = pattern.replace(/\./g, '\\.').repl...
javascript
function regexpPattern(pattern) { if (!pattern) { return pattern; } // A very simplified glob transform which allows passing legible strings like // "myPath/*.js" instead of a harder to read RegExp like /\/myPath\/.*\.js/. if (typeof pattern === 'string') { pattern = pattern.replace(/\./g, '\\.').repl...
[ "function", "regexpPattern", "(", "pattern", ")", "{", "if", "(", "!", "pattern", ")", "{", "return", "pattern", ";", "}", "// A very simplified glob transform which allows passing legible strings like", "// \"myPath/*.js\" instead of a harder to read RegExp like /\\/myPath\\/.*\\....
Given a null | string | RegExp | any, returns null | Regexp or throws a more helpful error.
[ "Given", "a", "null", "|", "string", "|", "RegExp", "|", "any", "returns", "null", "|", "Regexp", "or", "throws", "a", "more", "helpful", "error", "." ]
d6e560f21c8f7221f6a6fb7f1bed1ec923397b8f
https://github.com/flowtype/flow-remove-types/blob/d6e560f21c8f7221f6a6fb7f1bed1ec923397b8f/register.js#L61-L80
train
jellekralt/Responsive-Tabs
js/jquery.responsiveTabs.js
function(e) { var current = _this._getCurrentTab(); // Fetch current tab var activatedTab = e.data.tab; e.preventDefault(); // Trigger click event for whenever a tab is clicked/touched even if the tab is disabled activatedTab.tab.trigger('tabs-click', activa...
javascript
function(e) { var current = _this._getCurrentTab(); // Fetch current tab var activatedTab = e.data.tab; e.preventDefault(); // Trigger click event for whenever a tab is clicked/touched even if the tab is disabled activatedTab.tab.trigger('tabs-click', activa...
[ "function", "(", "e", ")", "{", "var", "current", "=", "_this", ".", "_getCurrentTab", "(", ")", ";", "// Fetch current tab", "var", "activatedTab", "=", "e", ".", "data", ".", "tab", ";", "e", ".", "preventDefault", "(", ")", ";", "// Trigger click event ...
Define activate event on a tab element
[ "Define", "activate", "event", "on", "a", "tab", "element" ]
7deb5aa383599915c598c7cba54893d253f2c196
https://github.com/jellekralt/Responsive-Tabs/blob/7deb5aa383599915c598c7cba54893d253f2c196/js/jquery.responsiveTabs.js#L227-L269
train
uber-node/ringpop-node
examples/cluster.js
after
function after(count, callback) { var countdown = count; return function shim(err) { if (typeof callback !== 'function') return; if (err) { callback(err); callback = null; return; } if (--countdown === 0) { callback(); ...
javascript
function after(count, callback) { var countdown = count; return function shim(err) { if (typeof callback !== 'function') return; if (err) { callback(err); callback = null; return; } if (--countdown === 0) { callback(); ...
[ "function", "after", "(", "count", ",", "callback", ")", "{", "var", "countdown", "=", "count", ";", "return", "function", "shim", "(", "err", ")", "{", "if", "(", "typeof", "callback", "!==", "'function'", ")", "return", ";", "if", "(", "err", ")", ...
IGNORE THIS! It's a little utility function that invokes a callback after a specified number of invocations of its shim.
[ "IGNORE", "THIS!", "It", "s", "a", "little", "utility", "function", "that", "invokes", "a", "callback", "after", "a", "specified", "number", "of", "invocations", "of", "its", "shim", "." ]
aec09a8ed304f4db3e1d67a4e94c55fffe06206e
https://github.com/uber-node/ringpop-node/blob/aec09a8ed304f4db3e1d67a4e94c55fffe06206e/examples/cluster.js#L85-L102
train
uber-node/ringpop-node
discover-providers.js
createJsonFileDiscoverProvider
function createJsonFileDiscoverProvider(hostsFile) { var fs = require('fs'); return function jsonFileProvider(callback) { fs.readFile(hostsFile, function onFileRead(err, data) { if (err) { callback(err); return; } var hosts; ...
javascript
function createJsonFileDiscoverProvider(hostsFile) { var fs = require('fs'); return function jsonFileProvider(callback) { fs.readFile(hostsFile, function onFileRead(err, data) { if (err) { callback(err); return; } var hosts; ...
[ "function", "createJsonFileDiscoverProvider", "(", "hostsFile", ")", "{", "var", "fs", "=", "require", "(", "'fs'", ")", ";", "return", "function", "jsonFileProvider", "(", "callback", ")", "{", "fs", ".", "readFile", "(", "hostsFile", ",", "function", "onFile...
Create a new DiscoverProvider using a host-file. @param {string} hostsFile The path to a json file containing an array of strings. @returns {DiscoverProvider}
[ "Create", "a", "new", "DiscoverProvider", "using", "a", "host", "-", "file", "." ]
aec09a8ed304f4db3e1d67a4e94c55fffe06206e
https://github.com/uber-node/ringpop-node/blob/aec09a8ed304f4db3e1d67a4e94c55fffe06206e/discover-providers.js#L56-L77
train
uber-node/ringpop-node
discover-providers.js
retryDiscoverProvider
function retryDiscoverProvider(opts, innerDiscoverProvider) { if (!opts) { return innerDiscoverProvider; } return function retryingDiscoverProvider(callback) { var policy; var defaultPolicy = { minDelay: 500, maxDelay: 15000, timeout: 60000 ...
javascript
function retryDiscoverProvider(opts, innerDiscoverProvider) { if (!opts) { return innerDiscoverProvider; } return function retryingDiscoverProvider(callback) { var policy; var defaultPolicy = { minDelay: 500, maxDelay: 15000, timeout: 60000 ...
[ "function", "retryDiscoverProvider", "(", "opts", ",", "innerDiscoverProvider", ")", "{", "if", "(", "!", "opts", ")", "{", "return", "innerDiscoverProvider", ";", "}", "return", "function", "retryingDiscoverProvider", "(", "callback", ")", "{", "var", "policy", ...
Wrap a innerDiscoverProvider with a retrying mechanism. @param {Object} opts the options used as a Backoff policy {@see Backoff} @param {Object} [opts.backoff] a mocked backoff for testing @param {DiscoverProvider} innerDiscoverProvider The discover provider to wrap @returns {DiscoverProvider} The retrying discover p...
[ "Wrap", "a", "innerDiscoverProvider", "with", "a", "retrying", "mechanism", "." ]
aec09a8ed304f4db3e1d67a4e94c55fffe06206e
https://github.com/uber-node/ringpop-node/blob/aec09a8ed304f4db3e1d67a4e94c55fffe06206e/discover-providers.js#L88-L128
train
uber-node/ringpop-node
discover-providers.js
createFromOpts
function createFromOpts(opts) { opts = opts || {}; if (typeof opts === 'function') { return opts; } if (typeof opts === 'string') { return createJsonFileDiscoverProvider(opts); } if (Array.isArray(opts)) { return createStaticHostsProvider(opts); } var discoverPr...
javascript
function createFromOpts(opts) { opts = opts || {}; if (typeof opts === 'function') { return opts; } if (typeof opts === 'string') { return createJsonFileDiscoverProvider(opts); } if (Array.isArray(opts)) { return createStaticHostsProvider(opts); } var discoverPr...
[ "function", "createFromOpts", "(", "opts", ")", "{", "opts", "=", "opts", "||", "{", "}", ";", "if", "(", "typeof", "opts", "===", "'function'", ")", "{", "return", "opts", ";", "}", "if", "(", "typeof", "opts", "===", "'string'", ")", "{", "return",...
Creates a DiscoverProvider from the provided options. @param opts: an object configuring the DiscoverProvider: - if opts or opts.discoverProvider is a function, it's returned as the {DiscoverProvider}. - if opts or opts.hosts is an array, a static hosts discover provider is returned (see {createStaticHostsProvider}) -...
[ "Creates", "a", "DiscoverProvider", "from", "the", "provided", "options", "." ]
aec09a8ed304f4db3e1d67a4e94c55fffe06206e
https://github.com/uber-node/ringpop-node/blob/aec09a8ed304f4db3e1d67a4e94c55fffe06206e/discover-providers.js#L141-L172
train
uber-node/ringpop-node
lib/trace/core.js
resolveEventConfig
function resolveEventConfig(ringpop, traceEvent) { var tracerConfig = tracerConfigMap[traceEvent]; if (!tracerConfig) { return null; } var sourcePath = tracerConfig.sourcePath; // subtle but important -- if we resolve here, then the underlying object // can never change. if we do latent...
javascript
function resolveEventConfig(ringpop, traceEvent) { var tracerConfig = tracerConfigMap[traceEvent]; if (!tracerConfig) { return null; } var sourcePath = tracerConfig.sourcePath; // subtle but important -- if we resolve here, then the underlying object // can never change. if we do latent...
[ "function", "resolveEventConfig", "(", "ringpop", ",", "traceEvent", ")", "{", "var", "tracerConfig", "=", "tracerConfigMap", "[", "traceEvent", "]", ";", "if", "(", "!", "tracerConfig", ")", "{", "return", "null", ";", "}", "var", "sourcePath", "=", "tracer...
resolves and returns a tracer config object, with traceEvent, sourceEmitter, and sourceEvent bound
[ "resolves", "and", "returns", "a", "tracer", "config", "object", "with", "traceEvent", "sourceEmitter", "and", "sourceEvent", "bound" ]
aec09a8ed304f4db3e1d67a4e94c55fffe06206e
https://github.com/uber-node/ringpop-node/blob/aec09a8ed304f4db3e1d67a4e94c55fffe06206e/lib/trace/core.js#L34-L57
train
uber-node/ringpop-node
config.js
Config
function Config(ringpop, seedConfig) { seedConfig = seedConfig || {}; this.ringpop = ringpop; this.store = {}; this._seed(seedConfig); }
javascript
function Config(ringpop, seedConfig) { seedConfig = seedConfig || {}; this.ringpop = ringpop; this.store = {}; this._seed(seedConfig); }
[ "function", "Config", "(", "ringpop", ",", "seedConfig", ")", "{", "seedConfig", "=", "seedConfig", "||", "{", "}", ";", "this", ".", "ringpop", "=", "ringpop", ";", "this", ".", "store", "=", "{", "}", ";", "this", ".", "_seed", "(", "seedConfig", "...
This Config class is meant to be a central store for configurable parameters in Ringpop. Parameters are meant to be initialized in the constructor.
[ "This", "Config", "class", "is", "meant", "to", "be", "a", "central", "store", "for", "configurable", "parameters", "in", "Ringpop", ".", "Parameters", "are", "meant", "to", "be", "initialized", "in", "the", "constructor", "." ]
aec09a8ed304f4db3e1d67a4e94c55fffe06206e
https://github.com/uber-node/ringpop-node/blob/aec09a8ed304f4db3e1d67a4e94c55fffe06206e/config.js#L31-L36
train
uber-node/ringpop-node
lib/membership/update.js
Update
function Update(subject, source) { if (!(this instanceof Update)) { return new Update(subject, source); } this.id = uuid.v4(); this.timestamp = Date.now(); // Populate subject subject = subject || {}; this.address = subject.address; this.incarnationNumber = subject.incarnationNu...
javascript
function Update(subject, source) { if (!(this instanceof Update)) { return new Update(subject, source); } this.id = uuid.v4(); this.timestamp = Date.now(); // Populate subject subject = subject || {}; this.address = subject.address; this.incarnationNumber = subject.incarnationNu...
[ "function", "Update", "(", "subject", ",", "source", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Update", ")", ")", "{", "return", "new", "Update", "(", "subject", ",", "source", ")", ";", "}", "this", ".", "id", "=", "uuid", ".", "v4", ...
Create a new Update @param {IMember} subject the subject of the update. @param {IMember} [source] the source of the update. @constructor
[ "Create", "a", "new", "Update" ]
aec09a8ed304f4db3e1d67a4e94c55fffe06206e
https://github.com/uber-node/ringpop-node/blob/aec09a8ed304f4db3e1d67a4e94c55fffe06206e/lib/membership/update.js#L31-L48
train
uber-node/ringpop-node
lib/gossip/joiner.js
takeNode
function takeNode(hosts) { var index = Math.floor(Math.random() * hosts.length); var host = hosts[index]; hosts.splice(index, 1); return host; }
javascript
function takeNode(hosts) { var index = Math.floor(Math.random() * hosts.length); var host = hosts[index]; hosts.splice(index, 1); return host; }
[ "function", "takeNode", "(", "hosts", ")", "{", "var", "index", "=", "Math", ".", "floor", "(", "Math", ".", "random", "(", ")", "*", "hosts", ".", "length", ")", ";", "var", "host", "=", "hosts", "[", "index", "]", ";", "hosts", ".", "splice", "...
Note that this function mutates the array passed in.
[ "Note", "that", "this", "function", "mutates", "the", "array", "passed", "in", "." ]
aec09a8ed304f4db3e1d67a4e94c55fffe06206e
https://github.com/uber-node/ringpop-node/blob/aec09a8ed304f4db3e1d67a4e94c55fffe06206e/lib/gossip/joiner.js#L55-L60
train
uber-node/ringpop-node
lib/membership/events.js
DampingReusableEvent
function DampingReusableEvent(member, oldDampScore) { this.name = this.constructor.name; this.member = member; this.oldDampScore = oldDampScore; }
javascript
function DampingReusableEvent(member, oldDampScore) { this.name = this.constructor.name; this.member = member; this.oldDampScore = oldDampScore; }
[ "function", "DampingReusableEvent", "(", "member", ",", "oldDampScore", ")", "{", "this", ".", "name", "=", "this", ".", "constructor", ".", "name", ";", "this", ".", "member", "=", "member", ";", "this", ".", "oldDampScore", "=", "oldDampScore", ";", "}" ...
A member becomes reusable when the damp score of a previously damped member falls below the reuse limit as specified in config.js by dampScoringReuseLimit.
[ "A", "member", "becomes", "reusable", "when", "the", "damp", "score", "of", "a", "previously", "damped", "member", "falls", "below", "the", "reuse", "limit", "as", "specified", "in", "config", ".", "js", "by", "dampScoringReuseLimit", "." ]
aec09a8ed304f4db3e1d67a4e94c55fffe06206e
https://github.com/uber-node/ringpop-node/blob/aec09a8ed304f4db3e1d67a4e94c55fffe06206e/lib/membership/events.js#L33-L37
train
uber-node/ringpop-node
lib/gossip/damper.js
createDampReqHandler
function createDampReqHandler(addr) { var start = self.Date.now(); return function onDampReq(err, res) { var timing = self.Date.now() - start; self.ringpop.stat('timing', 'protocol.damp-req', timing); // Prevents double-callback if (typeof callback !== 'f...
javascript
function createDampReqHandler(addr) { var start = self.Date.now(); return function onDampReq(err, res) { var timing = self.Date.now() - start; self.ringpop.stat('timing', 'protocol.damp-req', timing); // Prevents double-callback if (typeof callback !== 'f...
[ "function", "createDampReqHandler", "(", "addr", ")", "{", "var", "start", "=", "self", ".", "Date", ".", "now", "(", ")", ";", "return", "function", "onDampReq", "(", "err", ",", "res", ")", "{", "var", "timing", "=", "self", ".", "Date", ".", "now"...
Accumulate responses until rVal is satisfied or is impossible to satisfy because too many error responses.
[ "Accumulate", "responses", "until", "rVal", "is", "satisfied", "or", "is", "impossible", "to", "satisfy", "because", "too", "many", "error", "responses", "." ]
aec09a8ed304f4db3e1d67a4e94c55fffe06206e
https://github.com/uber-node/ringpop-node/blob/aec09a8ed304f4db3e1d67a4e94c55fffe06206e/lib/gossip/damper.js#L427-L467
train
uber-node/ringpop-node
lib/middleware/stack.js
callRequestMiddleware
function callRequestMiddleware(arg2, arg3) { i += 1; if (i < self.middlewares.length) { var next = self.middlewares[i].request; if (typeof next === 'function') { next(req, arg2, arg3, callRequestMiddleware); } else { // skip this middle...
javascript
function callRequestMiddleware(arg2, arg3) { i += 1; if (i < self.middlewares.length) { var next = self.middlewares[i].request; if (typeof next === 'function') { next(req, arg2, arg3, callRequestMiddleware); } else { // skip this middle...
[ "function", "callRequestMiddleware", "(", "arg2", ",", "arg3", ")", "{", "i", "+=", "1", ";", "if", "(", "i", "<", "self", ".", "middlewares", ".", "length", ")", "{", "var", "next", "=", "self", ".", "middlewares", "[", "i", "]", ".", "request", "...
This function calls the next request middleware in the stack or, if there is none left, calls the first response middleware, in reverse. It also skips any middlewares that don't implement the request method.
[ "This", "function", "calls", "the", "next", "request", "middleware", "in", "the", "stack", "or", "if", "there", "is", "none", "left", "calls", "the", "first", "response", "middleware", "in", "reverse", ".", "It", "also", "skips", "any", "middlewares", "that"...
aec09a8ed304f4db3e1d67a4e94c55fffe06206e
https://github.com/uber-node/ringpop-node/blob/aec09a8ed304f4db3e1d67a4e94c55fffe06206e/lib/middleware/stack.js#L73-L86
train
uber-node/ringpop-node
lib/middleware/stack.js
callResponseMiddleware
function callResponseMiddleware(err, res1, res2) { i -= 1; if (i >= 0) { var next = self.middlewares[i].response; if (typeof next === 'function') { next(req, err, res1, res2, callResponseMiddleware); } else { // skip this middleware if ...
javascript
function callResponseMiddleware(err, res1, res2) { i -= 1; if (i >= 0) { var next = self.middlewares[i].response; if (typeof next === 'function') { next(req, err, res1, res2, callResponseMiddleware); } else { // skip this middleware if ...
[ "function", "callResponseMiddleware", "(", "err", ",", "res1", ",", "res2", ")", "{", "i", "-=", "1", ";", "if", "(", "i", ">=", "0", ")", "{", "var", "next", "=", "self", ".", "middlewares", "[", "i", "]", ".", "response", ";", "if", "(", "typeo...
This function call the next response middleware in the stack until there are none left; in that case the callback is called instead, and the middleware run is completed.
[ "This", "function", "call", "the", "next", "response", "middleware", "in", "the", "stack", "until", "there", "are", "none", "left", ";", "in", "that", "case", "the", "callback", "is", "called", "instead", "and", "the", "middleware", "run", "is", "completed",...
aec09a8ed304f4db3e1d67a4e94c55fffe06206e
https://github.com/uber-node/ringpop-node/blob/aec09a8ed304f4db3e1d67a4e94c55fffe06206e/lib/middleware/stack.js#L90-L103
train
dependents/node-dependency-tree
index.js
dedupeNonExistent
function dedupeNonExistent(nonExistent) { const deduped = new Set(nonExistent); nonExistent.length = deduped.size; let i = 0; for (const elem of deduped) { nonExistent[i] = elem; i++; } }
javascript
function dedupeNonExistent(nonExistent) { const deduped = new Set(nonExistent); nonExistent.length = deduped.size; let i = 0; for (const elem of deduped) { nonExistent[i] = elem; i++; } }
[ "function", "dedupeNonExistent", "(", "nonExistent", ")", "{", "const", "deduped", "=", "new", "Set", "(", "nonExistent", ")", ";", "nonExistent", ".", "length", "=", "deduped", ".", "size", ";", "let", "i", "=", "0", ";", "for", "(", "const", "elem", ...
Mutate the list input to do a dereferenced modification of the user-supplied list
[ "Mutate", "the", "list", "input", "to", "do", "a", "dereferenced", "modification", "of", "the", "user", "-", "supplied", "list" ]
bcb7d304c15590be4bf7d4a533aaaa2f109e5bb1
https://github.com/dependents/node-dependency-tree/blob/bcb7d304c15590be4bf7d4a533aaaa2f109e5bb1/index.js#L190-L199
train
appium/appium-ios-driver
lib/settings.js
setLocale
async function setLocale (sim, opts, localeConfig = {}, safari = false) { if (!opts.language && !opts.locale && !opts.calendarFormat) { logger.debug('No reason to set locale'); return { _updated: false, }; } // we need the simulator to have its directories in place if (await sim.isFresh()) { ...
javascript
async function setLocale (sim, opts, localeConfig = {}, safari = false) { if (!opts.language && !opts.locale && !opts.calendarFormat) { logger.debug('No reason to set locale'); return { _updated: false, }; } // we need the simulator to have its directories in place if (await sim.isFresh()) { ...
[ "async", "function", "setLocale", "(", "sim", ",", "opts", ",", "localeConfig", "=", "{", "}", ",", "safari", "=", "false", ")", "{", "if", "(", "!", "opts", ".", "language", "&&", "!", "opts", ".", "locale", "&&", "!", "opts", ".", "calendarFormat",...
pass in the simulator so that other systems that use the function can supply whatever they have
[ "pass", "in", "the", "simulator", "so", "that", "other", "systems", "that", "use", "the", "function", "can", "supply", "whatever", "they", "have" ]
539ea68298c7cfd6658c7881599cb9d62c82a579
https://github.com/appium/appium-ios-driver/blob/539ea68298c7cfd6658c7881599cb9d62c82a579/lib/settings.js#L42-L73
train
appium/appium-ios-driver
lib/commands/find.js
function (strategy, selector, mult, context) { let ext = mult ? 's' : ''; let command = ''; context = !context ? context : `, '${context}'` ; switch (strategy) { case 'name': command = `au.getElement${ext}ByName('${selector}'${context})`; break; case 'accessibility id': ...
javascript
function (strategy, selector, mult, context) { let ext = mult ? 's' : ''; let command = ''; context = !context ? context : `, '${context}'` ; switch (strategy) { case 'name': command = `au.getElement${ext}ByName('${selector}'${context})`; break; case 'accessibility id': ...
[ "function", "(", "strategy", ",", "selector", ",", "mult", ",", "context", ")", "{", "let", "ext", "=", "mult", "?", "'s'", ":", "''", ";", "let", "command", "=", "''", ";", "context", "=", "!", "context", "?", "context", ":", "`", "${", "context",...
eslint-disable-line curly
[ "eslint", "-", "disable", "-", "line", "curly" ]
539ea68298c7cfd6658c7881599cb9d62c82a579
https://github.com/appium/appium-ios-driver/blob/539ea68298c7cfd6658c7881599cb9d62c82a579/lib/commands/find.js#L60-L82
train
appium/appium-ios-driver
uiauto/lib/mechanic-ext/alert-ext.js
function () { var alert = getAlert(); if (alert.isNil()) { throw new ERROR.NoAlertOpenError(); } var texts = this.getElementsByType('text', alert); // If an alert does not have a title, alert.name() is null, use empty string var text = alert.name() || ""; if (texts.len...
javascript
function () { var alert = getAlert(); if (alert.isNil()) { throw new ERROR.NoAlertOpenError(); } var texts = this.getElementsByType('text', alert); // If an alert does not have a title, alert.name() is null, use empty string var text = alert.name() || ""; if (texts.len...
[ "function", "(", ")", "{", "var", "alert", "=", "getAlert", "(", ")", ";", "if", "(", "alert", ".", "isNil", "(", ")", ")", "{", "throw", "new", "ERROR", ".", "NoAlertOpenError", "(", ")", ";", "}", "var", "texts", "=", "this", ".", "getElementsByT...
Alert-related functions
[ "Alert", "-", "related", "functions" ]
539ea68298c7cfd6658c7881599cb9d62c82a579
https://github.com/appium/appium-ios-driver/blob/539ea68298c7cfd6658c7881599cb9d62c82a579/uiauto/lib/mechanic-ext/alert-ext.js#L39-L69
train
appium/appium-ios-driver
lib/instruments/utils.js
quickLaunch
async function quickLaunch (udid, appPath = path.resolve(__dirname, '..', '..', 'assets', 'TestApp.app')) { let traceTemplatePath = await xcode.getAutomationTraceTemplatePath(); let scriptPath = path.resolve(__dirname, '..', '..', 'assets', 'blank_instruments_test.js'); let traceDocument = path.resolve('/', 'tmp'...
javascript
async function quickLaunch (udid, appPath = path.resolve(__dirname, '..', '..', 'assets', 'TestApp.app')) { let traceTemplatePath = await xcode.getAutomationTraceTemplatePath(); let scriptPath = path.resolve(__dirname, '..', '..', 'assets', 'blank_instruments_test.js'); let traceDocument = path.resolve('/', 'tmp'...
[ "async", "function", "quickLaunch", "(", "udid", ",", "appPath", "=", "path", ".", "resolve", "(", "__dirname", ",", "'..'", ",", "'..'", ",", "'assets'", ",", "'TestApp.app'", ")", ")", "{", "let", "traceTemplatePath", "=", "await", "xcode", ".", "getAuto...
this function launches an instruments test with a default test that immediately passes. In this way we can start a simulator and be notified when it completely launches
[ "this", "function", "launches", "an", "instruments", "test", "with", "a", "default", "test", "that", "immediately", "passes", ".", "In", "this", "way", "we", "can", "start", "a", "simulator", "and", "be", "notified", "when", "it", "completely", "launches" ]
539ea68298c7cfd6658c7881599cb9d62c82a579
https://github.com/appium/appium-ios-driver/blob/539ea68298c7cfd6658c7881599cb9d62c82a579/lib/instruments/utils.js#L96-L116
train
appium/appium-ios-driver
lib/cookies.js
convertCookie
function convertCookie (value, converter) { if (value.indexOf('"') === 0) { // this is a quoted cookied according to RFC2068 // remove enclosing quotes and internal quotes and backslashes value = value.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\'); } let parsedValue; try { parsedValu...
javascript
function convertCookie (value, converter) { if (value.indexOf('"') === 0) { // this is a quoted cookied according to RFC2068 // remove enclosing quotes and internal quotes and backslashes value = value.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\'); } let parsedValue; try { parsedValu...
[ "function", "convertCookie", "(", "value", ",", "converter", ")", "{", "if", "(", "value", ".", "indexOf", "(", "'\"'", ")", "===", "0", ")", "{", "// this is a quoted cookied according to RFC2068", "// remove enclosing quotes and internal quotes and backslashes", "value"...
parses the value if needed and converts the value if a converter is provided internal function, not exported
[ "parses", "the", "value", "if", "needed", "and", "converts", "the", "value", "if", "a", "converter", "is", "provided", "internal", "function", "not", "exported" ]
539ea68298c7cfd6658c7881599cb9d62c82a579
https://github.com/appium/appium-ios-driver/blob/539ea68298c7cfd6658c7881599cb9d62c82a579/lib/cookies.js#L16-L32
train
appium/appium-ios-driver
lib/cookies.js
createJSCookie
function createJSCookie (key, value, options = {}) { return [ encodeURIComponent(key), '=', value, options.expires ? `; expires=${options.expires}` : '', options.path ? `; path=${options.path}` : '', options.domain ? `; domain=${options.domain}` : '', options.se...
javascript
function createJSCookie (key, value, options = {}) { return [ encodeURIComponent(key), '=', value, options.expires ? `; expires=${options.expires}` : '', options.path ? `; path=${options.path}` : '', options.domain ? `; domain=${options.domain}` : '', options.se...
[ "function", "createJSCookie", "(", "key", ",", "value", ",", "options", "=", "{", "}", ")", "{", "return", "[", "encodeURIComponent", "(", "key", ")", ",", "'='", ",", "value", ",", "options", ".", "expires", "?", "`", "${", "options", ".", "expires", ...
takes arguments given and creates a JavaScript Cookie
[ "takes", "arguments", "given", "and", "creates", "a", "JavaScript", "Cookie" ]
539ea68298c7cfd6658c7881599cb9d62c82a579
https://github.com/appium/appium-ios-driver/blob/539ea68298c7cfd6658c7881599cb9d62c82a579/lib/cookies.js#L35-L51
train
appium/appium-ios-driver
lib/cookies.js
createJWPCookie
function createJWPCookie (key, cookieString, converter = null) { let result = {}; let cookies = cookieString ? cookieString.split('; ') : []; for (let cookie of cookies) { let parts = cookie.split('='); // get the first and second element as name and value let name = decodeURIComponent(parts.shift())...
javascript
function createJWPCookie (key, cookieString, converter = null) { let result = {}; let cookies = cookieString ? cookieString.split('; ') : []; for (let cookie of cookies) { let parts = cookie.split('='); // get the first and second element as name and value let name = decodeURIComponent(parts.shift())...
[ "function", "createJWPCookie", "(", "key", ",", "cookieString", ",", "converter", "=", "null", ")", "{", "let", "result", "=", "{", "}", ";", "let", "cookies", "=", "cookieString", "?", "cookieString", ".", "split", "(", "'; '", ")", ":", "[", "]", ";"...
takes the JavaScript cookieString and translates it into a JSONWire formatted cookie
[ "takes", "the", "JavaScript", "cookieString", "and", "translates", "it", "into", "a", "JSONWire", "formatted", "cookie" ]
539ea68298c7cfd6658c7881599cb9d62c82a579
https://github.com/appium/appium-ios-driver/blob/539ea68298c7cfd6658c7881599cb9d62c82a579/lib/cookies.js#L54-L74
train
appium/appium-ios-driver
lib/cookies.js
getValue
function getValue (key, cookieString, converter = null) { let result = createJWPCookie(key, cookieString, converter); // if `key` is undefined we want the entire cookie return _.isUndefined(key) ? result : result.value; }
javascript
function getValue (key, cookieString, converter = null) { let result = createJWPCookie(key, cookieString, converter); // if `key` is undefined we want the entire cookie return _.isUndefined(key) ? result : result.value; }
[ "function", "getValue", "(", "key", ",", "cookieString", ",", "converter", "=", "null", ")", "{", "let", "result", "=", "createJWPCookie", "(", "key", ",", "cookieString", ",", "converter", ")", ";", "// if `key` is undefined we want the entire cookie", "return", ...
takes a JavaScript cookiestring and parses it for the value given the key
[ "takes", "a", "JavaScript", "cookiestring", "and", "parses", "it", "for", "the", "value", "given", "the", "key" ]
539ea68298c7cfd6658c7881599cb9d62c82a579
https://github.com/appium/appium-ios-driver/blob/539ea68298c7cfd6658c7881599cb9d62c82a579/lib/cookies.js#L77-L82
train
appium/appium-ios-driver
uiauto/lib/mechanic-ext/lookup-ext.js
function (selector, ctx) { if (typeof selector !== 'string') { return null; } var _ctx = $.mainApp() , elems = []; if (typeof ctx === 'string') { _ctx = this.cache[ctx]; } else if (typeof ctx !== 'undefined') { _ctx = ctx; } $.target().pushTim...
javascript
function (selector, ctx) { if (typeof selector !== 'string') { return null; } var _ctx = $.mainApp() , elems = []; if (typeof ctx === 'string') { _ctx = this.cache[ctx]; } else if (typeof ctx !== 'undefined') { _ctx = ctx; } $.target().pushTim...
[ "function", "(", "selector", ",", "ctx", ")", "{", "if", "(", "typeof", "selector", "!==", "'string'", ")", "{", "return", "null", ";", "}", "var", "_ctx", "=", "$", ".", "mainApp", "(", ")", ",", "elems", "=", "[", "]", ";", "if", "(", "typeof",...
Element lookup functions
[ "Element", "lookup", "functions" ]
539ea68298c7cfd6658c7881599cb9d62c82a579
https://github.com/appium/appium-ios-driver/blob/539ea68298c7cfd6658c7881599cb9d62c82a579/uiauto/lib/mechanic-ext/lookup-ext.js#L8-L34
train
appium/appium-ios-driver
uiauto/lib/mechanic-ext/screen-ext.js
function () { var orientation = $.orientation() , value = null; switch (orientation) { case UIA_DEVICE_ORIENTATION_UNKNOWN: case UIA_DEVICE_ORIENTATION_FACEUP: case UIA_DEVICE_ORIENTATION_FACEDOWN: value = "UNKNOWN"; break; case UIA_DEVICE_ORIENTAT...
javascript
function () { var orientation = $.orientation() , value = null; switch (orientation) { case UIA_DEVICE_ORIENTATION_UNKNOWN: case UIA_DEVICE_ORIENTATION_FACEUP: case UIA_DEVICE_ORIENTATION_FACEDOWN: value = "UNKNOWN"; break; case UIA_DEVICE_ORIENTAT...
[ "function", "(", ")", "{", "var", "orientation", "=", "$", ".", "orientation", "(", ")", ",", "value", "=", "null", ";", "switch", "(", "orientation", ")", "{", "case", "UIA_DEVICE_ORIENTATION_UNKNOWN", ":", "case", "UIA_DEVICE_ORIENTATION_FACEUP", ":", "case"...
Screen-related functions
[ "Screen", "-", "related", "functions" ]
539ea68298c7cfd6658c7881599cb9d62c82a579
https://github.com/appium/appium-ios-driver/blob/539ea68298c7cfd6658c7881599cb9d62c82a579/uiauto/lib/mechanic-ext/screen-ext.js#L7-L30
train
imsky/pull-review
src/github/graphql.js
Request
function Request(options) { return new Promise(function(resolve, reject) { client(options, function(err, res) { if (err) { reject(err); } else { resolve(res); } }); }); }
javascript
function Request(options) { return new Promise(function(resolve, reject) { client(options, function(err, res) { if (err) { reject(err); } else { resolve(res); } }); }); }
[ "function", "Request", "(", "options", ")", "{", "return", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "client", "(", "options", ",", "function", "(", "err", ",", "res", ")", "{", "if", "(", "err", ")", "{", "reject", ...
Promisified wrapper over github-graphql-client @param {Object} options - GraphQL request options
[ "Promisified", "wrapper", "over", "github", "-", "graphql", "-", "client" ]
9eb6d389ac6b7da1ceff470110cfd382a3cde8c1
https://github.com/imsky/pull-review/blob/9eb6d389ac6b7da1ceff470110cfd382a3cde8c1/src/github/graphql.js#L9-L19
train
imsky/pull-review
src/github/index.js
BlameRangeList
function BlameRangeList(blame) { var ranges = blame.ranges; return ranges .filter(function(range) { return ( range && range.commit && range.commit.author && range.commit.author.user && range.commit.author.user.login ); }) .map(function(range) { ...
javascript
function BlameRangeList(blame) { var ranges = blame.ranges; return ranges .filter(function(range) { return ( range && range.commit && range.commit.author && range.commit.author.user && range.commit.author.user.login ); }) .map(function(range) { ...
[ "function", "BlameRangeList", "(", "blame", ")", "{", "var", "ranges", "=", "blame", ".", "ranges", ";", "return", "ranges", ".", "filter", "(", "function", "(", "range", ")", "{", "return", "(", "range", "&&", "range", ".", "commit", "&&", "range", "....
Convert raw blame data into BlameRanges @param {Object} blame - GitHub blame data @returns {Array} list of BlameRanges
[ "Convert", "raw", "blame", "data", "into", "BlameRanges" ]
9eb6d389ac6b7da1ceff470110cfd382a3cde8c1
https://github.com/imsky/pull-review/blob/9eb6d389ac6b7da1ceff470110cfd382a3cde8c1/src/github/index.js#L33-L54
train
imsky/pull-review
src/github/index.js
parseGithubURL
function parseGithubURL(url) { var githubUrlRe = /github\.com\/([^/]+)\/([^/]+)\/pull\/([0-9]+)/; var match = url.match(githubUrlRe); if (!match) { return null; } return { owner: match[1], repo: match[2], number: match[3] }; }
javascript
function parseGithubURL(url) { var githubUrlRe = /github\.com\/([^/]+)\/([^/]+)\/pull\/([0-9]+)/; var match = url.match(githubUrlRe); if (!match) { return null; } return { owner: match[1], repo: match[2], number: match[3] }; }
[ "function", "parseGithubURL", "(", "url", ")", "{", "var", "githubUrlRe", "=", "/", "github\\.com\\/([^/]+)\\/([^/]+)\\/pull\\/([0-9]+)", "/", ";", "var", "match", "=", "url", ".", "match", "(", "githubUrlRe", ")", ";", "if", "(", "!", "match", ")", "{", "re...
Helper that converts URLs into GitHub resource objects compatible with node-github @param {String} url - A GitHub resource URL @return {Object} GitHub resource parsed from URL
[ "Helper", "that", "converts", "URLs", "into", "GitHub", "resource", "objects", "compatible", "with", "node", "-", "github" ]
9eb6d389ac6b7da1ceff470110cfd382a3cde8c1
https://github.com/imsky/pull-review/blob/9eb6d389ac6b7da1ceff470110cfd382a3cde8c1/src/github/index.js#L62-L75
train
ream/ream
app/client-entry.js
main
async function main() { event.$emit('before-client-render') if (globalState.initialData) { dataStore.replaceState(globalState.initialData) } await routerReady(router) if (router.getMatchedComponents().length === 0) { throw new ReamError(pageNotFound(router.currentRoute.path)) } }
javascript
async function main() { event.$emit('before-client-render') if (globalState.initialData) { dataStore.replaceState(globalState.initialData) } await routerReady(router) if (router.getMatchedComponents().length === 0) { throw new ReamError(pageNotFound(router.currentRoute.path)) } }
[ "async", "function", "main", "(", ")", "{", "event", ".", "$emit", "(", "'before-client-render'", ")", "if", "(", "globalState", ".", "initialData", ")", "{", "dataStore", ".", "replaceState", "(", "globalState", ".", "initialData", ")", "}", "await", "route...
Wait until router has resolved all async before hooks and async components...
[ "Wait", "until", "router", "has", "resolved", "all", "async", "before", "hooks", "and", "async", "components", "..." ]
5f0926c6fe3864ac27c07a6f12503e7b231b0680
https://github.com/ream/ream/blob/5f0926c6fe3864ac27c07a6f12503e7b231b0680/app/client-entry.js#L107-L119
train
pillarjs/send
index.js
SendStream
function SendStream (req, path, options) { Stream.call(this) var opts = options || {} this.options = opts this.path = path this.req = req this._acceptRanges = opts.acceptRanges !== undefined ? Boolean(opts.acceptRanges) : true this._cacheControl = opts.cacheControl !== undefined ? Boolean(...
javascript
function SendStream (req, path, options) { Stream.call(this) var opts = options || {} this.options = opts this.path = path this.req = req this._acceptRanges = opts.acceptRanges !== undefined ? Boolean(opts.acceptRanges) : true this._cacheControl = opts.cacheControl !== undefined ? Boolean(...
[ "function", "SendStream", "(", "req", ",", "path", ",", "options", ")", "{", "Stream", ".", "call", "(", "this", ")", "var", "opts", "=", "options", "||", "{", "}", "this", ".", "options", "=", "opts", "this", ".", "path", "=", "path", "this", ".",...
Initialize a `SendStream` with the given `path`. @param {Request} req @param {String} path @param {object} [options] @private
[ "Initialize", "a", "SendStream", "with", "the", "given", "path", "." ]
0ef8f0cb8d8f3875f034d04d16db37a85f6150d8
https://github.com/pillarjs/send/blob/0ef8f0cb8d8f3875f034d04d16db37a85f6150d8/index.js#L96-L167
train
pillarjs/send
index.js
clearHeaders
function clearHeaders (res) { var headers = getHeaderNames(res) for (var i = 0; i < headers.length; i++) { res.removeHeader(headers[i]) } }
javascript
function clearHeaders (res) { var headers = getHeaderNames(res) for (var i = 0; i < headers.length; i++) { res.removeHeader(headers[i]) } }
[ "function", "clearHeaders", "(", "res", ")", "{", "var", "headers", "=", "getHeaderNames", "(", "res", ")", "for", "(", "var", "i", "=", "0", ";", "i", "<", "headers", ".", "length", ";", "i", "++", ")", "{", "res", ".", "removeHeader", "(", "heade...
Clear all headers from a response. @param {object} res @private
[ "Clear", "all", "headers", "from", "a", "response", "." ]
0ef8f0cb8d8f3875f034d04d16db37a85f6150d8
https://github.com/pillarjs/send/blob/0ef8f0cb8d8f3875f034d04d16db37a85f6150d8/index.js#L901-L907
train
pillarjs/send
index.js
containsDotFile
function containsDotFile (parts) { for (var i = 0; i < parts.length; i++) { var part = parts[i] if (part.length > 1 && part[0] === '.') { return true } } return false }
javascript
function containsDotFile (parts) { for (var i = 0; i < parts.length; i++) { var part = parts[i] if (part.length > 1 && part[0] === '.') { return true } } return false }
[ "function", "containsDotFile", "(", "parts", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "parts", ".", "length", ";", "i", "++", ")", "{", "var", "part", "=", "parts", "[", "i", "]", "if", "(", "part", ".", "length", ">", "1", ...
Determine if path parts contain a dotfile. @api private
[ "Determine", "if", "path", "parts", "contain", "a", "dotfile", "." ]
0ef8f0cb8d8f3875f034d04d16db37a85f6150d8
https://github.com/pillarjs/send/blob/0ef8f0cb8d8f3875f034d04d16db37a85f6150d8/index.js#L933-L942
train
pillarjs/send
index.js
contentRange
function contentRange (type, size, range) { return type + ' ' + (range ? range.start + '-' + range.end : '*') + '/' + size }
javascript
function contentRange (type, size, range) { return type + ' ' + (range ? range.start + '-' + range.end : '*') + '/' + size }
[ "function", "contentRange", "(", "type", ",", "size", ",", "range", ")", "{", "return", "type", "+", "' '", "+", "(", "range", "?", "range", ".", "start", "+", "'-'", "+", "range", ".", "end", ":", "'*'", ")", "+", "'/'", "+", "size", "}" ]
Create a Content-Range header. @param {string} type @param {number} size @param {array} [range]
[ "Create", "a", "Content", "-", "Range", "header", "." ]
0ef8f0cb8d8f3875f034d04d16db37a85f6150d8
https://github.com/pillarjs/send/blob/0ef8f0cb8d8f3875f034d04d16db37a85f6150d8/index.js#L952-L954
train
pillarjs/send
index.js
getHeaderNames
function getHeaderNames (res) { return typeof res.getHeaderNames !== 'function' ? Object.keys(res._headers || {}) : res.getHeaderNames() }
javascript
function getHeaderNames (res) { return typeof res.getHeaderNames !== 'function' ? Object.keys(res._headers || {}) : res.getHeaderNames() }
[ "function", "getHeaderNames", "(", "res", ")", "{", "return", "typeof", "res", ".", "getHeaderNames", "!==", "'function'", "?", "Object", ".", "keys", "(", "res", ".", "_headers", "||", "{", "}", ")", ":", "res", ".", "getHeaderNames", "(", ")", "}" ]
Get the header names on a respnse. @param {object} res @returns {array[string]} @private
[ "Get", "the", "header", "names", "on", "a", "respnse", "." ]
0ef8f0cb8d8f3875f034d04d16db37a85f6150d8
https://github.com/pillarjs/send/blob/0ef8f0cb8d8f3875f034d04d16db37a85f6150d8/index.js#L1003-L1007
train
pillarjs/send
index.js
hasListeners
function hasListeners (emitter, type) { var count = typeof emitter.listenerCount !== 'function' ? emitter.listeners(type).length : emitter.listenerCount(type) return count > 0 }
javascript
function hasListeners (emitter, type) { var count = typeof emitter.listenerCount !== 'function' ? emitter.listeners(type).length : emitter.listenerCount(type) return count > 0 }
[ "function", "hasListeners", "(", "emitter", ",", "type", ")", "{", "var", "count", "=", "typeof", "emitter", ".", "listenerCount", "!==", "'function'", "?", "emitter", ".", "listeners", "(", "type", ")", ".", "length", ":", "emitter", ".", "listenerCount", ...
Determine if emitter has listeners of a given type. The way to do this check is done three different ways in Node.js >= 0.8 so this consolidates them into a minimal set using instance methods. @param {EventEmitter} emitter @param {string} type @returns {boolean} @private
[ "Determine", "if", "emitter", "has", "listeners", "of", "a", "given", "type", "." ]
0ef8f0cb8d8f3875f034d04d16db37a85f6150d8
https://github.com/pillarjs/send/blob/0ef8f0cb8d8f3875f034d04d16db37a85f6150d8/index.js#L1021-L1027
train
pillarjs/send
index.js
normalizeList
function normalizeList (val, name) { var list = [].concat(val || []) for (var i = 0; i < list.length; i++) { if (typeof list[i] !== 'string') { throw new TypeError(name + ' must be array of strings or false') } } return list }
javascript
function normalizeList (val, name) { var list = [].concat(val || []) for (var i = 0; i < list.length; i++) { if (typeof list[i] !== 'string') { throw new TypeError(name + ' must be array of strings or false') } } return list }
[ "function", "normalizeList", "(", "val", ",", "name", ")", "{", "var", "list", "=", "[", "]", ".", "concat", "(", "val", "||", "[", "]", ")", "for", "(", "var", "i", "=", "0", ";", "i", "<", "list", ".", "length", ";", "i", "++", ")", "{", ...
Normalize the index option into an array. @param {boolean|string|array} val @param {string} name @private
[ "Normalize", "the", "index", "option", "into", "an", "array", "." ]
0ef8f0cb8d8f3875f034d04d16db37a85f6150d8
https://github.com/pillarjs/send/blob/0ef8f0cb8d8f3875f034d04d16db37a85f6150d8/index.js#L1051-L1061
train
pillarjs/send
index.js
parseTokenList
function parseTokenList (str) { var end = 0 var list = [] var start = 0 // gather tokens for (var i = 0, len = str.length; i < len; i++) { switch (str.charCodeAt(i)) { case 0x20: /* */ if (start === end) { start = end = i + 1 } break case 0x2c: /* , */ ...
javascript
function parseTokenList (str) { var end = 0 var list = [] var start = 0 // gather tokens for (var i = 0, len = str.length; i < len; i++) { switch (str.charCodeAt(i)) { case 0x20: /* */ if (start === end) { start = end = i + 1 } break case 0x2c: /* , */ ...
[ "function", "parseTokenList", "(", "str", ")", "{", "var", "end", "=", "0", "var", "list", "=", "[", "]", "var", "start", "=", "0", "// gather tokens", "for", "(", "var", "i", "=", "0", ",", "len", "=", "str", ".", "length", ";", "i", "<", "len",...
Parse a HTTP token list. @param {string} str @private
[ "Parse", "a", "HTTP", "token", "list", "." ]
0ef8f0cb8d8f3875f034d04d16db37a85f6150d8
https://github.com/pillarjs/send/blob/0ef8f0cb8d8f3875f034d04d16db37a85f6150d8/index.js#L1085-L1112
train
zkat/pacote
lib/finalize-manifest.js
tarballedProps
function tarballedProps (pkg, spec, opts) { const needsShrinkwrap = (!pkg || ( pkg._hasShrinkwrap !== false && !pkg._shrinkwrap )) const needsBin = !!(!pkg || ( !pkg.bin && pkg.directories && pkg.directories.bin )) const needsIntegrity = !pkg || (!pkg._integrity && pkg._integrity !== false...
javascript
function tarballedProps (pkg, spec, opts) { const needsShrinkwrap = (!pkg || ( pkg._hasShrinkwrap !== false && !pkg._shrinkwrap )) const needsBin = !!(!pkg || ( !pkg.bin && pkg.directories && pkg.directories.bin )) const needsIntegrity = !pkg || (!pkg._integrity && pkg._integrity !== false...
[ "function", "tarballedProps", "(", "pkg", ",", "spec", ",", "opts", ")", "{", "const", "needsShrinkwrap", "=", "(", "!", "pkg", "||", "(", "pkg", ".", "_hasShrinkwrap", "!==", "false", "&&", "!", "pkg", ".", "_shrinkwrap", ")", ")", "const", "needsBin", ...
Some things aren't filled in by standard manifest fetching. If this function needs to do its work, it will grab the package tarball, extract it, and take whatever it needs from the stream.
[ "Some", "things", "aren", "t", "filled", "in", "by", "standard", "manifest", "fetching", ".", "If", "this", "function", "needs", "to", "do", "its", "work", "it", "will", "grab", "the", "package", "tarball", "extract", "it", "and", "take", "whatever", "it",...
33c53cf10b080e78182bccc56ec1d5126f8b627e
https://github.com/zkat/pacote/blob/33c53cf10b080e78182bccc56ec1d5126f8b627e/lib/finalize-manifest.js#L135-L201
train
zkat/pacote
lib/util/read-json.js
stripBOM
function stripBOM (content) { content = content.toString() // Remove byte order marker. This catches EF BB BF (the UTF-8 BOM) // because the buffer-to-string conversion in `fs.readFileSync()` // translates it to FEFF, the UTF-16 BOM. if (content.charCodeAt(0) === 0xFEFF) return content.slice(1) ...
javascript
function stripBOM (content) { content = content.toString() // Remove byte order marker. This catches EF BB BF (the UTF-8 BOM) // because the buffer-to-string conversion in `fs.readFileSync()` // translates it to FEFF, the UTF-16 BOM. if (content.charCodeAt(0) === 0xFEFF) return content.slice(1) ...
[ "function", "stripBOM", "(", "content", ")", "{", "content", "=", "content", ".", "toString", "(", ")", "// Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)", "// because the buffer-to-string conversion in `fs.readFileSync()`", "// translates it to FEFF, the UTF-16 BOM."...
Code also yanked from read-package-json.
[ "Code", "also", "yanked", "from", "read", "-", "package", "-", "json", "." ]
33c53cf10b080e78182bccc56ec1d5126f8b627e
https://github.com/zkat/pacote/blob/33c53cf10b080e78182bccc56ec1d5126f8b627e/lib/util/read-json.js#L5-L12
train
DeviaVir/vue-bar
dist/vue-bars.esm.js
genPoints
function genPoints (inArr, ref, ref$1) { var minX = ref.minX; var minY = ref.minY; var maxX = ref.maxX; var maxY = ref.maxY; var max = ref$1.max; var min = ref$1.min; var arr = inArr.map(function (item) { return (typeof item === 'number' ? item : item.value); }); var minValue = Math.min.apply(Math, arr...
javascript
function genPoints (inArr, ref, ref$1) { var minX = ref.minX; var minY = ref.minY; var maxX = ref.maxX; var maxY = ref.maxY; var max = ref$1.max; var min = ref$1.min; var arr = inArr.map(function (item) { return (typeof item === 'number' ? item : item.value); }); var minValue = Math.min.apply(Math, arr...
[ "function", "genPoints", "(", "inArr", ",", "ref", ",", "ref$1", ")", "{", "var", "minX", "=", "ref", ".", "minX", ";", "var", "minY", "=", "ref", ".", "minY", ";", "var", "maxX", "=", "ref", ".", "maxX", ";", "var", "maxY", "=", "ref", ".", "m...
Calculate the coordinate @param {number[]|object[]} arr @param {object} boundary @return {object[]}
[ "Calculate", "the", "coordinate" ]
079695b3ba0780e6927fdbaad59927e290e95e21
https://github.com/DeviaVir/vue-bar/blob/079695b3ba0780e6927fdbaad59927e290e95e21/dist/vue-bars.esm.js#L57-L82
train
alleyinteractive/sasslint-webpack-plugin
index.js
ignorePlugins
function ignorePlugins(plugins, currentPlugin) { return plugins.reduce(function (acc, plugin) { if (currentPlugin && currentPlugin.indexOf(plugin) > -1) { return true; } return acc; }, false); }
javascript
function ignorePlugins(plugins, currentPlugin) { return plugins.reduce(function (acc, plugin) { if (currentPlugin && currentPlugin.indexOf(plugin) > -1) { return true; } return acc; }, false); }
[ "function", "ignorePlugins", "(", "plugins", ",", "currentPlugin", ")", "{", "return", "plugins", ".", "reduce", "(", "function", "(", "acc", ",", "plugin", ")", "{", "if", "(", "currentPlugin", "&&", "currentPlugin", ".", "indexOf", "(", "plugin", ")", ">...
Check if plugin is ignored
[ "Check", "if", "plugin", "is", "ignored" ]
0f73c610817b89f0f4b2fb025717695fca52f6d7
https://github.com/alleyinteractive/sasslint-webpack-plugin/blob/0f73c610817b89f0f4b2fb025717695fca52f6d7/index.js#L9-L17
train
parse-community/parse-server-push-adapter
src/GCM.js
generateGCMPayload
function generateGCMPayload(requestData, pushId, timeStamp, expirationTime) { let payload = { priority: 'high' }; payload.data = { data: requestData.data, push_id: pushId, time: new Date(timeStamp).toISOString() } const optionalKeys = ['content_available', 'notification']; optionalKeys.forEa...
javascript
function generateGCMPayload(requestData, pushId, timeStamp, expirationTime) { let payload = { priority: 'high' }; payload.data = { data: requestData.data, push_id: pushId, time: new Date(timeStamp).toISOString() } const optionalKeys = ['content_available', 'notification']; optionalKeys.forEa...
[ "function", "generateGCMPayload", "(", "requestData", ",", "pushId", ",", "timeStamp", ",", "expirationTime", ")", "{", "let", "payload", "=", "{", "priority", ":", "'high'", "}", ";", "payload", ".", "data", "=", "{", "data", ":", "requestData", ".", "dat...
Generate the gcm payload from the data we get from api request. @param {Object} requestData The request body @param {String} pushId A random string @param {Number} timeStamp A number whose format is the Unix Epoch @param {Number|undefined} expirationTime A number whose format is the Unix Epoch or undefined @returns {Ob...
[ "Generate", "the", "gcm", "payload", "from", "the", "data", "we", "get", "from", "api", "request", "." ]
30c3e8992c63cf888b43e1a72a10e1da43403844
https://github.com/parse-community/parse-server-push-adapter/blob/30c3e8992c63cf888b43e1a72a10e1da43403844/src/GCM.js#L125-L153
train
parse-community/parse-server-push-adapter
src/GCM.js
sliceDevices
function sliceDevices(devices, chunkSize) { let chunkDevices = []; while (devices.length > 0) { chunkDevices.push(devices.splice(0, chunkSize)); } return chunkDevices; }
javascript
function sliceDevices(devices, chunkSize) { let chunkDevices = []; while (devices.length > 0) { chunkDevices.push(devices.splice(0, chunkSize)); } return chunkDevices; }
[ "function", "sliceDevices", "(", "devices", ",", "chunkSize", ")", "{", "let", "chunkDevices", "=", "[", "]", ";", "while", "(", "devices", ".", "length", ">", "0", ")", "{", "chunkDevices", ".", "push", "(", "devices", ".", "splice", "(", "0", ",", ...
Slice a list of devices to several list of devices with fixed chunk size. @param {Array} devices An array of devices @param {Number} chunkSize The size of the a chunk @returns {Array} An array which contaisn several arries of devices with fixed chunk size
[ "Slice", "a", "list", "of", "devices", "to", "several", "list", "of", "devices", "with", "fixed", "chunk", "size", "." ]
30c3e8992c63cf888b43e1a72a10e1da43403844
https://github.com/parse-community/parse-server-push-adapter/blob/30c3e8992c63cf888b43e1a72a10e1da43403844/src/GCM.js#L161-L167
train
cliqz-oss/adblocker
bench/run_benchmark.js
runMicroBenchmarks
function runMicroBenchmarks(lists, resources) { console.log('Run micro bench...'); // Create adb engine to use in benchmark const { engine, serialized } = createEngine(lists, resources, { loadCosmeticFilters: true, loadNetworkFilters: true, }, true /* Also serialize engine */); const filters = getFil...
javascript
function runMicroBenchmarks(lists, resources) { console.log('Run micro bench...'); // Create adb engine to use in benchmark const { engine, serialized } = createEngine(lists, resources, { loadCosmeticFilters: true, loadNetworkFilters: true, }, true /* Also serialize engine */); const filters = getFil...
[ "function", "runMicroBenchmarks", "(", "lists", ",", "resources", ")", "{", "console", ".", "log", "(", "'Run micro bench...'", ")", ";", "// Create adb engine to use in benchmark", "const", "{", "engine", ",", "serialized", "}", "=", "createEngine", "(", "lists", ...
Micro benchmarks are a set of benchmarks measuring specific aspects of the library
[ "Micro", "benchmarks", "are", "a", "set", "of", "benchmarks", "measuring", "specific", "aspects", "of", "the", "library" ]
fc2af492eefb0a9b251f7ca621b8de59df26ea91
https://github.com/cliqz-oss/adblocker/blob/fc2af492eefb0a9b251f7ca621b8de59df26ea91/bench/run_benchmark.js#L75-L134
train
cliqz-oss/adblocker
bench/comparison/blockers/ublock/filtering-context.js
function() { let docDomain = this.getDocDomain(); if ( docDomain === '' ) { docDomain = this.docHostname; } if ( this.domain !== undefined && this.domain !== '' ) { return this.domain !== docDomain; } const hostname = this.getHostname(); if ( hostname.endsWith...
javascript
function() { let docDomain = this.getDocDomain(); if ( docDomain === '' ) { docDomain = this.docHostname; } if ( this.domain !== undefined && this.domain !== '' ) { return this.domain !== docDomain; } const hostname = this.getHostname(); if ( hostname.endsWith...
[ "function", "(", ")", "{", "let", "docDomain", "=", "this", ".", "getDocDomain", "(", ")", ";", "if", "(", "docDomain", "===", "''", ")", "{", "docDomain", "=", "this", ".", "docHostname", ";", "}", "if", "(", "this", ".", "domain", "!==", "undefined...
The idea is to minimize the amout of work done to figure out whether the resource is 3rd-party to the document.
[ "The", "idea", "is", "to", "minimize", "the", "amout", "of", "work", "done", "to", "figure", "out", "whether", "the", "resource", "is", "3rd", "-", "party", "to", "the", "document", "." ]
fc2af492eefb0a9b251f7ca621b8de59df26ea91
https://github.com/cliqz-oss/adblocker/blob/fc2af492eefb0a9b251f7ca621b8de59df26ea91/bench/comparison/blockers/ublock/filtering-context.js#L202-L213
train
cliqz-oss/adblocker
bench/comparison/blockers/ublock/filtering-context.js
function() { let tabDomain = this.getTabDomain(); if ( tabDomain === '' ) { tabDomain = this.tabHostname; } if ( this.domain !== undefined && this.domain !== '' ) { return this.domain !== tabDomain; } const hostname = this.getHostname(); if ( hostname.endsWith...
javascript
function() { let tabDomain = this.getTabDomain(); if ( tabDomain === '' ) { tabDomain = this.tabHostname; } if ( this.domain !== undefined && this.domain !== '' ) { return this.domain !== tabDomain; } const hostname = this.getHostname(); if ( hostname.endsWith...
[ "function", "(", ")", "{", "let", "tabDomain", "=", "this", ".", "getTabDomain", "(", ")", ";", "if", "(", "tabDomain", "===", "''", ")", "{", "tabDomain", "=", "this", ".", "tabHostname", ";", "}", "if", "(", "this", ".", "domain", "!==", "undefined...
The idea is to minimize the amout of work done to figure out whether the resource is 3rd-party to the top document.
[ "The", "idea", "is", "to", "minimize", "the", "amout", "of", "work", "done", "to", "figure", "out", "whether", "the", "resource", "is", "3rd", "-", "party", "to", "the", "top", "document", "." ]
fc2af492eefb0a9b251f7ca621b8de59df26ea91
https://github.com/cliqz-oss/adblocker/blob/fc2af492eefb0a9b251f7ca621b8de59df26ea91/bench/comparison/blockers/ublock/filtering-context.js#L262-L273
train
cliqz-oss/adblocker
bench/comparison/blockers/ublock/publicsuffixlist.js
function() { const buf8 = pslBuffer8; const buf32 = pslBuffer32; const iCharData = buf32[CHARDATA_PTR_SLOT]; let iNode = pslBuffer32[RULES_PTR_SLOT]; let cursorPos = -1; let iLabel = LABEL_INDICES_SLOT; // Label-lookup loop for (;;) { // Extract label indices const labe...
javascript
function() { const buf8 = pslBuffer8; const buf32 = pslBuffer32; const iCharData = buf32[CHARDATA_PTR_SLOT]; let iNode = pslBuffer32[RULES_PTR_SLOT]; let cursorPos = -1; let iLabel = LABEL_INDICES_SLOT; // Label-lookup loop for (;;) { // Extract label indices const labe...
[ "function", "(", ")", "{", "const", "buf8", "=", "pslBuffer8", ";", "const", "buf32", "=", "pslBuffer32", ";", "const", "iCharData", "=", "buf32", "[", "CHARDATA_PTR_SLOT", "]", ";", "let", "iNode", "=", "pslBuffer32", "[", "RULES_PTR_SLOT", "]", ";", "let...
Returns an offset to the start of the public suffix. WASM-able, because no information outside the buffer content is required.
[ "Returns", "an", "offset", "to", "the", "start", "of", "the", "public", "suffix", ".", "WASM", "-", "able", "because", "no", "information", "outside", "the", "buffer", "content", "is", "required", "." ]
fc2af492eefb0a9b251f7ca621b8de59df26ea91
https://github.com/cliqz-oss/adblocker/blob/fc2af492eefb0a9b251f7ca621b8de59df26ea91/bench/comparison/blockers/ublock/publicsuffixlist.js#L359-L424
train
cliqz-oss/adblocker
bench/comparison/blockers/ublock/tab.js
function(tabId, url) { var entry = tabContexts.get(tabId); if ( entry === undefined ) { entry = new TabContext(tabId); entry.autodestroy(); } entry.push(url); mostRecentRootDocURL = url; mostRecentRootDocURLTimestamp = Date.now(); return en...
javascript
function(tabId, url) { var entry = tabContexts.get(tabId); if ( entry === undefined ) { entry = new TabContext(tabId); entry.autodestroy(); } entry.push(url); mostRecentRootDocURL = url; mostRecentRootDocURLTimestamp = Date.now(); return en...
[ "function", "(", "tabId", ",", "url", ")", "{", "var", "entry", "=", "tabContexts", ".", "get", "(", "tabId", ")", ";", "if", "(", "entry", "===", "undefined", ")", "{", "entry", "=", "new", "TabContext", "(", "tabId", ")", ";", "entry", ".", "auto...
These are to be used for the API of the tab context manager.
[ "These", "are", "to", "be", "used", "for", "the", "API", "of", "the", "tab", "context", "manager", "." ]
fc2af492eefb0a9b251f7ca621b8de59df26ea91
https://github.com/cliqz-oss/adblocker/blob/fc2af492eefb0a9b251f7ca621b8de59df26ea91/bench/comparison/blockers/ublock/tab.js#L376-L386
train
cliqz-oss/adblocker
bench/comparison/blockers/ublock/tab.js
function(tabId) { var entry = tabContexts.get(tabId); if ( entry !== undefined ) { return entry; } // https://github.com/chrisaljoudi/uBlock/issues/1025 // Google Hangout popup opens without a root frame. So for now we will // just discard that best-guess root...
javascript
function(tabId) { var entry = tabContexts.get(tabId); if ( entry !== undefined ) { return entry; } // https://github.com/chrisaljoudi/uBlock/issues/1025 // Google Hangout popup opens without a root frame. So for now we will // just discard that best-guess root...
[ "function", "(", "tabId", ")", "{", "var", "entry", "=", "tabContexts", ".", "get", "(", "tabId", ")", ";", "if", "(", "entry", "!==", "undefined", ")", "{", "return", "entry", ";", "}", "// https://github.com/chrisaljoudi/uBlock/issues/1025", "// Google Hangout...
Find a tab context for a specific tab. If none is found, attempt to fix this. When all fail, the behind-the-scene context is returned.
[ "Find", "a", "tab", "context", "for", "a", "specific", "tab", ".", "If", "none", "is", "found", "attempt", "to", "fix", "this", ".", "When", "all", "fail", "the", "behind", "-", "the", "-", "scene", "context", "is", "returned", "." ]
fc2af492eefb0a9b251f7ca621b8de59df26ea91
https://github.com/cliqz-oss/adblocker/blob/fc2af492eefb0a9b251f7ca621b8de59df26ea91/bench/comparison/blockers/ublock/tab.js#L395-L422
train
cliqz-oss/adblocker
bench/comparison/blockers/ublock/static-ext-filtering.js
function(s) { const match = reParseRegexLiteral.exec(s); let regexDetails; if ( match !== null ) { regexDetails = match[1]; if ( isBadRegex(regexDetails) ) { return; } if ( match[2] ) { regexDetails = [ regexDetails,...
javascript
function(s) { const match = reParseRegexLiteral.exec(s); let regexDetails; if ( match !== null ) { regexDetails = match[1]; if ( isBadRegex(regexDetails) ) { return; } if ( match[2] ) { regexDetails = [ regexDetails,...
[ "function", "(", "s", ")", "{", "const", "match", "=", "reParseRegexLiteral", ".", "exec", "(", "s", ")", ";", "let", "regexDetails", ";", "if", "(", "match", "!==", "null", ")", "{", "regexDetails", "=", "match", "[", "1", "]", ";", "if", "(", "is...
When dealing with literal text, we must first eat _some_ backslash characters.
[ "When", "dealing", "with", "literal", "text", "we", "must", "first", "eat", "_some_", "backslash", "characters", "." ]
fc2af492eefb0a9b251f7ca621b8de59df26ea91
https://github.com/cliqz-oss/adblocker/blob/fc2af492eefb0a9b251f7ca621b8de59df26ea91/bench/comparison/blockers/ublock/static-ext-filtering.js#L187-L202
train
dthree/vantage
lib/index.js
function(server, port, options, cb) { return this.client.connect.call(this.client, server, port, options, cb); }
javascript
function(server, port, options, cb) { return this.client.connect.call(this.client, server, port, options, cb); }
[ "function", "(", "server", ",", "port", ",", "options", ",", "cb", ")", "{", "return", "this", ".", "client", ".", "connect", ".", "call", "(", "this", ".", "client", ",", "server", ",", "port", ",", "options", ",", "cb", ")", ";", "}" ]
Programatically connect to another server instance running Vantage. @param {Server} server @param {Integer} port @param {Object} options @param {Function} cb @return {Promise} @api public
[ "Programatically", "connect", "to", "another", "server", "instance", "running", "Vantage", "." ]
5bbf7e58a94d34d8ce980ae7048dfff3e9569c31
https://github.com/dthree/vantage/blob/5bbf7e58a94d34d8ce980ae7048dfff3e9569c31/lib/index.js#L71-L73
train
dthree/vantage
lib/index.js
function(middleware, options) { if (this.server && this.server.auth) { this.server.auth(middleware, options); } else { throw new Error("vantage.auth is only available in Vantage.IO. Please use this (npm install vantage-io --save)"); } return this; }
javascript
function(middleware, options) { if (this.server && this.server.auth) { this.server.auth(middleware, options); } else { throw new Error("vantage.auth is only available in Vantage.IO. Please use this (npm install vantage-io --save)"); } return this; }
[ "function", "(", "middleware", ",", "options", ")", "{", "if", "(", "this", ".", "server", "&&", "this", ".", "server", ".", "auth", ")", "{", "this", ".", "server", ".", "auth", "(", "middleware", ",", "options", ")", ";", "}", "else", "{", "throw...
Imports an authentication middleware module to replace the server's auth function, which is called when a remote instance of vantage connects. @param {Function} middleware @param {Object} options @return {Vantage} @api public
[ "Imports", "an", "authentication", "middleware", "module", "to", "replace", "the", "server", "s", "auth", "function", "which", "is", "called", "when", "a", "remote", "instance", "of", "vantage", "connects", "." ]
5bbf7e58a94d34d8ce980ae7048dfff3e9569c31
https://github.com/dthree/vantage/blob/5bbf7e58a94d34d8ce980ae7048dfff3e9569c31/lib/index.js#L100-L107
train
dthree/vantage
lib/index.js
function(args, cb) { var ssn = this.getSessionById(args.sessionId); if (!this._authFn) { var nodeEnv = process.env.NODE_ENV || "development"; if (nodeEnv !== "development") { var msg = "The Node server you are connecting to appears " + "to be a production server, and yet its Va...
javascript
function(args, cb) { var ssn = this.getSessionById(args.sessionId); if (!this._authFn) { var nodeEnv = process.env.NODE_ENV || "development"; if (nodeEnv !== "development") { var msg = "The Node server you are connecting to appears " + "to be a production server, and yet its Va...
[ "function", "(", "args", ",", "cb", ")", "{", "var", "ssn", "=", "this", ".", "getSessionById", "(", "args", ".", "sessionId", ")", ";", "if", "(", "!", "this", ".", "_authFn", ")", "{", "var", "nodeEnv", "=", "process", ".", "env", ".", "NODE_ENV"...
Calls authentication middleware @param {Object} args @param {Function} cb @api private
[ "Calls", "authentication", "middleware" ]
5bbf7e58a94d34d8ce980ae7048dfff3e9569c31
https://github.com/dthree/vantage/blob/5bbf7e58a94d34d8ce980ae7048dfff3e9569c31/lib/index.js#L117-L148
train
dthree/vantage
lib/server.js
on
function on(str, opts, cbk) { cbk = (_.isFunction(opts)) ? opts : cbk; cbk = cbk || function() {}; opts = opts || {}; ssn.server.on(str, function() { if (!ssn.server || (!ssn.authenticating && !ssn.authenticated)) { //console.log("Not Authenticated. Closing Session.", ssn...
javascript
function on(str, opts, cbk) { cbk = (_.isFunction(opts)) ? opts : cbk; cbk = cbk || function() {}; opts = opts || {}; ssn.server.on(str, function() { if (!ssn.server || (!ssn.authenticating && !ssn.authenticated)) { //console.log("Not Authenticated. Closing Session.", ssn...
[ "function", "on", "(", "str", ",", "opts", ",", "cbk", ")", "{", "cbk", "=", "(", "_", ".", "isFunction", "(", "opts", ")", ")", "?", "opts", ":", "cbk", ";", "cbk", "=", "cbk", "||", "function", "(", ")", "{", "}", ";", "opts", "=", "opts", ...
Listens for an event, authenticating the session first.
[ "Listens", "for", "an", "event", "authenticating", "the", "session", "first", "." ]
5bbf7e58a94d34d8ce980ae7048dfff3e9569c31
https://github.com/dthree/vantage/blob/5bbf7e58a94d34d8ce980ae7048dfff3e9569c31/lib/server.js#L213-L225
train
infusion/Fraction.js
examples/hesse-convergence.js
matrMult
function matrMult(m, v) { return [ new Fraction(m[0]).mul(v[0]).add(new Fraction(m[1]).mul(v[1])), new Fraction(m[2]).mul(v[0]).add(new Fraction(m[3]).mul(v[1])) ]; }
javascript
function matrMult(m, v) { return [ new Fraction(m[0]).mul(v[0]).add(new Fraction(m[1]).mul(v[1])), new Fraction(m[2]).mul(v[0]).add(new Fraction(m[3]).mul(v[1])) ]; }
[ "function", "matrMult", "(", "m", ",", "v", ")", "{", "return", "[", "new", "Fraction", "(", "m", "[", "0", "]", ")", ".", "mul", "(", "v", "[", "0", "]", ")", ".", "add", "(", "new", "Fraction", "(", "m", "[", "1", "]", ")", ".", "mul", ...
A simple matrix multiplication helper
[ "A", "simple", "matrix", "multiplication", "helper" ]
0298e604eb28a7cf8fba3240e6aa639fbc5c4432
https://github.com/infusion/Fraction.js/blob/0298e604eb28a7cf8fba3240e6aa639fbc5c4432/examples/hesse-convergence.js#L54-L60
train
infusion/Fraction.js
examples/hesse-convergence.js
vecSub
function vecSub(a, b) { return [ new Fraction(a[0]).sub(b[0]), new Fraction(a[1]).sub(b[1]) ]; }
javascript
function vecSub(a, b) { return [ new Fraction(a[0]).sub(b[0]), new Fraction(a[1]).sub(b[1]) ]; }
[ "function", "vecSub", "(", "a", ",", "b", ")", "{", "return", "[", "new", "Fraction", "(", "a", "[", "0", "]", ")", ".", "sub", "(", "b", "[", "0", "]", ")", ",", "new", "Fraction", "(", "a", "[", "1", "]", ")", ".", "sub", "(", "b", "[",...
A simple vector subtraction helper
[ "A", "simple", "vector", "subtraction", "helper" ]
0298e604eb28a7cf8fba3240e6aa639fbc5c4432
https://github.com/infusion/Fraction.js/blob/0298e604eb28a7cf8fba3240e6aa639fbc5c4432/examples/hesse-convergence.js#L63-L69
train
infusion/Fraction.js
examples/hesse-convergence.js
run
function run(V, j) { var t = H(V); //console.log("H(X)"); for (var i in t) { // console.log(t[i].toFraction()); } var s = grad(V); //console.log("vf(X)"); for (var i in s) { // console.log(s[i].toFraction()); } //console.log("multiplikation"); var r = matrMult(t, s); for (var i in r) ...
javascript
function run(V, j) { var t = H(V); //console.log("H(X)"); for (var i in t) { // console.log(t[i].toFraction()); } var s = grad(V); //console.log("vf(X)"); for (var i in s) { // console.log(s[i].toFraction()); } //console.log("multiplikation"); var r = matrMult(t, s); for (var i in r) ...
[ "function", "run", "(", "V", ",", "j", ")", "{", "var", "t", "=", "H", "(", "V", ")", ";", "//console.log(\"H(X)\");", "for", "(", "var", "i", "in", "t", ")", "{", "//\tconsole.log(t[i].toFraction());", "}", "var", "s", "=", "grad", "(", "V", ")", ...
Main function, gets a vector and the actual index
[ "Main", "function", "gets", "a", "vector", "and", "the", "actual", "index" ]
0298e604eb28a7cf8fba3240e6aa639fbc5c4432
https://github.com/infusion/Fraction.js/blob/0298e604eb28a7cf8fba3240e6aa639fbc5c4432/examples/hesse-convergence.js#L72-L103
train
infusion/Fraction.js
bigfraction.js
function(a, b) { parse(a, b); return new Fraction( this["s"] * this["n"] * P["d"] + P["s"] * this["d"] * P["n"], this["d"] * P["d"] ); }
javascript
function(a, b) { parse(a, b); return new Fraction( this["s"] * this["n"] * P["d"] + P["s"] * this["d"] * P["n"], this["d"] * P["d"] ); }
[ "function", "(", "a", ",", "b", ")", "{", "parse", "(", "a", ",", "b", ")", ";", "return", "new", "Fraction", "(", "this", "[", "\"s\"", "]", "*", "this", "[", "\"n\"", "]", "*", "P", "[", "\"d\"", "]", "+", "P", "[", "\"s\"", "]", "*", "th...
Adds two rational numbers Ex: new Fraction({n: 2, d: 3}).add("14.9") => 467 / 30
[ "Adds", "two", "rational", "numbers" ]
0298e604eb28a7cf8fba3240e6aa639fbc5c4432
https://github.com/infusion/Fraction.js/blob/0298e604eb28a7cf8fba3240e6aa639fbc5c4432/bigfraction.js#L400-L407
train
infusion/Fraction.js
fraction.js
function(a, b) { if (isNaN(this['n']) || isNaN(this['d'])) { return new Fraction(NaN); } if (a === undefined) { return new Fraction(this["s"] * this["n"] % this["d"], 1); } parse(a, b); if (0 === P["n"] && 0 === this["d"]) { Fraction(0, 0); // Throw Divisio...
javascript
function(a, b) { if (isNaN(this['n']) || isNaN(this['d'])) { return new Fraction(NaN); } if (a === undefined) { return new Fraction(this["s"] * this["n"] % this["d"], 1); } parse(a, b); if (0 === P["n"] && 0 === this["d"]) { Fraction(0, 0); // Throw Divisio...
[ "function", "(", "a", ",", "b", ")", "{", "if", "(", "isNaN", "(", "this", "[", "'n'", "]", ")", "||", "isNaN", "(", "this", "[", "'d'", "]", ")", ")", "{", "return", "new", "Fraction", "(", "NaN", ")", ";", "}", "if", "(", "a", "===", "und...
Calculates the modulo of two rational numbers - a more precise fmod Ex: new Fraction('4.(3)').mod([7, 8]) => (13/3) % (7/8) = (5/6)
[ "Calculates", "the", "modulo", "of", "two", "rational", "numbers", "-", "a", "more", "precise", "fmod" ]
0298e604eb28a7cf8fba3240e6aa639fbc5c4432
https://github.com/infusion/Fraction.js/blob/0298e604eb28a7cf8fba3240e6aa639fbc5c4432/fraction.js#L465-L498
train
infusion/Fraction.js
fraction.js
function(a, b) { parse(a, b); var t = (this["s"] * this["n"] * P["d"] - P["s"] * P["n"] * this["d"]); return (0 < t) - (t < 0); }
javascript
function(a, b) { parse(a, b); var t = (this["s"] * this["n"] * P["d"] - P["s"] * P["n"] * this["d"]); return (0 < t) - (t < 0); }
[ "function", "(", "a", ",", "b", ")", "{", "parse", "(", "a", ",", "b", ")", ";", "var", "t", "=", "(", "this", "[", "\"s\"", "]", "*", "this", "[", "\"n\"", "]", "*", "P", "[", "\"d\"", "]", "-", "P", "[", "\"s\"", "]", "*", "P", "[", "...
Check if two rational numbers are the same Ex: new Fraction(19.6).equals([98, 5]);
[ "Check", "if", "two", "rational", "numbers", "are", "the", "same" ]
0298e604eb28a7cf8fba3240e6aa639fbc5c4432
https://github.com/infusion/Fraction.js/blob/0298e604eb28a7cf8fba3240e6aa639fbc5c4432/fraction.js#L616-L621
train
skale-me/skale
ml/sgd-linear-model.js
regularizeNone
function regularizeNone(weights, gradientCount) { const [gradient, count] = gradientCount; for (let i = 0; i < gradient.length; i++) { let grad = (gradient[i] || 0) / count; weights[i] = (weights[i] || 0) - grad; } }
javascript
function regularizeNone(weights, gradientCount) { const [gradient, count] = gradientCount; for (let i = 0; i < gradient.length; i++) { let grad = (gradient[i] || 0) / count; weights[i] = (weights[i] || 0) - grad; } }
[ "function", "regularizeNone", "(", "weights", ",", "gradientCount", ")", "{", "const", "[", "gradient", ",", "count", "]", "=", "gradientCount", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "gradient", ".", "length", ";", "i", "++", ")", "{"...
None, a.k.a ordinary least squares
[ "None", "a", ".", "k", ".", "a", "ordinary", "least", "squares" ]
fdb4b5d08ca4f6321ceda888385a68208d04a545
https://github.com/skale-me/skale/blob/fdb4b5d08ca4f6321ceda888385a68208d04a545/ml/sgd-linear-model.js#L91-L98
train
skale-me/skale
ml/sgd-linear-model.js
regularizeL1
function regularizeL1(weights, gradientCount, stepSize) { const [gradient, count] = gradientCount; for (let i = 0; i < gradient.length; i++) { let grad = (gradient[i] || 0) / count; weights[i] = weights[i] || 0; weights[i] -= stepSize * grad + (weights[i] > 0 ? 1 : -1); } }
javascript
function regularizeL1(weights, gradientCount, stepSize) { const [gradient, count] = gradientCount; for (let i = 0; i < gradient.length; i++) { let grad = (gradient[i] || 0) / count; weights[i] = weights[i] || 0; weights[i] -= stepSize * grad + (weights[i] > 0 ? 1 : -1); } }
[ "function", "regularizeL1", "(", "weights", ",", "gradientCount", ",", "stepSize", ")", "{", "const", "[", "gradient", ",", "count", "]", "=", "gradientCount", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "gradient", ".", "length", ";", "i", ...
L1, a.k.a Lasso
[ "L1", "a", ".", "k", ".", "a", "Lasso" ]
fdb4b5d08ca4f6321ceda888385a68208d04a545
https://github.com/skale-me/skale/blob/fdb4b5d08ca4f6321ceda888385a68208d04a545/ml/sgd-linear-model.js#L101-L109
train
skale-me/skale
ml/sgd-linear-model.js
regularizeL2
function regularizeL2(weights, gradientCount, stepSize, regParam) { const [gradient, count] = gradientCount; for (let i = 0; i < gradient.length; i++) { let grad = (gradient[i] || 0) / count; weights[i] = weights[i] || 0; weights[i] -= stepSize * (grad + regParam * weights[i]); } }
javascript
function regularizeL2(weights, gradientCount, stepSize, regParam) { const [gradient, count] = gradientCount; for (let i = 0; i < gradient.length; i++) { let grad = (gradient[i] || 0) / count; weights[i] = weights[i] || 0; weights[i] -= stepSize * (grad + regParam * weights[i]); } }
[ "function", "regularizeL2", "(", "weights", ",", "gradientCount", ",", "stepSize", ",", "regParam", ")", "{", "const", "[", "gradient", ",", "count", "]", "=", "gradientCount", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "gradient", ".", "len...
L2, a.k.a ridge regression
[ "L2", "a", ".", "k", ".", "a", "ridge", "regression" ]
fdb4b5d08ca4f6321ceda888385a68208d04a545
https://github.com/skale-me/skale/blob/fdb4b5d08ca4f6321ceda888385a68208d04a545/ml/sgd-linear-model.js#L112-L120
train
skale-me/skale
lib/dataset.js
randomizeArray
function randomizeArray(array) { let i = array.length; while (i) { let j = Math.floor(Math.random() * i--); [array[i], array[j]] = [array[j], array[i]]; } return array; }
javascript
function randomizeArray(array) { let i = array.length; while (i) { let j = Math.floor(Math.random() * i--); [array[i], array[j]] = [array[j], array[i]]; } return array; }
[ "function", "randomizeArray", "(", "array", ")", "{", "let", "i", "=", "array", ".", "length", ";", "while", "(", "i", ")", "{", "let", "j", "=", "Math", ".", "floor", "(", "Math", ".", "random", "(", ")", "*", "i", "--", ")", ";", "[", "array"...
Randomize order of an array using Fisher-Yates shuffe
[ "Randomize", "order", "of", "an", "array", "using", "Fisher", "-", "Yates", "shuffe" ]
fdb4b5d08ca4f6321ceda888385a68208d04a545
https://github.com/skale-me/skale/blob/fdb4b5d08ca4f6321ceda888385a68208d04a545/lib/dataset.js#L584-L591
train
skale-me/skale
lib/dataset.js
sampleSizeFraction
function sampleSizeFraction(num, total, withReplacement) { const minSamplingRate = 1e-10; // Limited by RNG's resolution const delta = 1e-4; // To have 0.9999 success rate const fraction = num / total; let upperBound; if (withReplacement) { // Poisson upper bound for Pr(num succe...
javascript
function sampleSizeFraction(num, total, withReplacement) { const minSamplingRate = 1e-10; // Limited by RNG's resolution const delta = 1e-4; // To have 0.9999 success rate const fraction = num / total; let upperBound; if (withReplacement) { // Poisson upper bound for Pr(num succe...
[ "function", "sampleSizeFraction", "(", "num", ",", "total", ",", "withReplacement", ")", "{", "const", "minSamplingRate", "=", "1e-10", ";", "// Limited by RNG's resolution", "const", "delta", "=", "1e-4", ";", "// To have 0.9999 success rate", "const", "fraction", "=...
Returns a sampling rate that ensures a size >= lowerBound most of the time. Inspired from spark
[ "Returns", "a", "sampling", "rate", "that", "ensures", "a", "size", ">", "=", "lowerBound", "most", "of", "the", "time", ".", "Inspired", "from", "spark" ]
fdb4b5d08ca4f6321ceda888385a68208d04a545
https://github.com/skale-me/skale/blob/fdb4b5d08ca4f6321ceda888385a68208d04a545/lib/dataset.js#L595-L611
train
skale-me/skale
lib/task.js
iterateDone
function iterateDone() { dlog(start, 'iterate'); blocksToRegister.map(function(block) {mm.register(block);}); if (action) { if (action.opt._postIterate) { action.opt._postIterate(action.init, action.opt, self, tmpPart.partitionIndex, function () { done({data: {host: self.grid.host.uu...
javascript
function iterateDone() { dlog(start, 'iterate'); blocksToRegister.map(function(block) {mm.register(block);}); if (action) { if (action.opt._postIterate) { action.opt._postIterate(action.init, action.opt, self, tmpPart.partitionIndex, function () { done({data: {host: self.grid.host.uu...
[ "function", "iterateDone", "(", ")", "{", "dlog", "(", "start", ",", "'iterate'", ")", ";", "blocksToRegister", ".", "map", "(", "function", "(", "block", ")", "{", "mm", ".", "register", "(", "block", ")", ";", "}", ")", ";", "if", "(", "action", ...
Post-iterate actions
[ "Post", "-", "iterate", "actions" ]
fdb4b5d08ca4f6321ceda888385a68208d04a545
https://github.com/skale-me/skale/blob/fdb4b5d08ca4f6321ceda888385a68208d04a545/lib/task.js#L100-L116
train