id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
36,700
ocadotechnology/quantumjs
quantum-api/lib/entity-transforms/components/type.js
getType
function getType (str, typeLinks) { if (str in typeLinks) { return dom.create('a').class('qm-api-type-link').attr('href', typeLinks[str]).text(str) } else { return str } }
javascript
function getType (str, typeLinks) { if (str in typeLinks) { return dom.create('a').class('qm-api-type-link').attr('href', typeLinks[str]).text(str) } else { return str } }
[ "function", "getType", "(", "str", ",", "typeLinks", ")", "{", "if", "(", "str", "in", "typeLinks", ")", "{", "return", "dom", ".", "create", "(", "'a'", ")", ".", "class", "(", "'qm-api-type-link'", ")", ".", "attr", "(", "'href'", ",", "typeLinks", "[", "str", "]", ")", ".", "text", "(", "str", ")", "}", "else", "{", "return", "str", "}", "}" ]
Lookup the type url from the availble type links
[ "Lookup", "the", "type", "url", "from", "the", "availble", "type", "links" ]
5bc684b750472296f186a816529272c36218db04
https://github.com/ocadotechnology/quantumjs/blob/5bc684b750472296f186a816529272c36218db04/quantum-api/lib/entity-transforms/components/type.js#L6-L12
36,701
misoproject/storyboard
dist/miso.storyboard.r.0.1.0.js
children_to
function children_to( sceneName, argsArr, deferred ) { var toScene = this.scenes[sceneName], fromScene = this._current, args = argsArr ? argsArr : [], complete = this._complete = deferred || _.Deferred(), exitComplete = _.Deferred(), enterComplete = _.Deferred(), publish = _.bind(function(name, isExit) { var sceneName = isExit ? fromScene : toScene; sceneName = sceneName ? sceneName.name : ""; this.publish(name, fromScene, toScene); if (name !== "start" || name !== "end") { this.publish(sceneName + ":" + name); } }, this), bailout = _.bind(function() { this._transitioning = false; this._current = fromScene; publish("fail"); complete.reject(); }, this), success = _.bind(function() { publish("enter"); this._transitioning = false; this._current = toScene; publish("end"); complete.resolve(); }, this); if (!toScene) { throw "Scene \"" + sceneName + "\" not found!"; } // we in the middle of a transition? if (this._transitioning) { return complete.reject(); } publish("start"); this._transitioning = true; if (fromScene) { // we are coming from a scene, so transition out of it. fromScene.to("exit", args, exitComplete); exitComplete.done(function() { publish("exit", true); }); } else { exitComplete.resolve(); } // when we're done exiting, enter the next set _.when(exitComplete).then(function() { toScene.to(toScene._initial || "enter", args, enterComplete); }).fail(bailout); enterComplete .then(success) .fail(bailout); return complete.promise(); }
javascript
function children_to( sceneName, argsArr, deferred ) { var toScene = this.scenes[sceneName], fromScene = this._current, args = argsArr ? argsArr : [], complete = this._complete = deferred || _.Deferred(), exitComplete = _.Deferred(), enterComplete = _.Deferred(), publish = _.bind(function(name, isExit) { var sceneName = isExit ? fromScene : toScene; sceneName = sceneName ? sceneName.name : ""; this.publish(name, fromScene, toScene); if (name !== "start" || name !== "end") { this.publish(sceneName + ":" + name); } }, this), bailout = _.bind(function() { this._transitioning = false; this._current = fromScene; publish("fail"); complete.reject(); }, this), success = _.bind(function() { publish("enter"); this._transitioning = false; this._current = toScene; publish("end"); complete.resolve(); }, this); if (!toScene) { throw "Scene \"" + sceneName + "\" not found!"; } // we in the middle of a transition? if (this._transitioning) { return complete.reject(); } publish("start"); this._transitioning = true; if (fromScene) { // we are coming from a scene, so transition out of it. fromScene.to("exit", args, exitComplete); exitComplete.done(function() { publish("exit", true); }); } else { exitComplete.resolve(); } // when we're done exiting, enter the next set _.when(exitComplete).then(function() { toScene.to(toScene._initial || "enter", args, enterComplete); }).fail(bailout); enterComplete .then(success) .fail(bailout); return complete.promise(); }
[ "function", "children_to", "(", "sceneName", ",", "argsArr", ",", "deferred", ")", "{", "var", "toScene", "=", "this", ".", "scenes", "[", "sceneName", "]", ",", "fromScene", "=", "this", ".", "_current", ",", "args", "=", "argsArr", "?", "argsArr", ":", "[", "]", ",", "complete", "=", "this", ".", "_complete", "=", "deferred", "||", "_", ".", "Deferred", "(", ")", ",", "exitComplete", "=", "_", ".", "Deferred", "(", ")", ",", "enterComplete", "=", "_", ".", "Deferred", "(", ")", ",", "publish", "=", "_", ".", "bind", "(", "function", "(", "name", ",", "isExit", ")", "{", "var", "sceneName", "=", "isExit", "?", "fromScene", ":", "toScene", ";", "sceneName", "=", "sceneName", "?", "sceneName", ".", "name", ":", "\"\"", ";", "this", ".", "publish", "(", "name", ",", "fromScene", ",", "toScene", ")", ";", "if", "(", "name", "!==", "\"start\"", "||", "name", "!==", "\"end\"", ")", "{", "this", ".", "publish", "(", "sceneName", "+", "\":\"", "+", "name", ")", ";", "}", "}", ",", "this", ")", ",", "bailout", "=", "_", ".", "bind", "(", "function", "(", ")", "{", "this", ".", "_transitioning", "=", "false", ";", "this", ".", "_current", "=", "fromScene", ";", "publish", "(", "\"fail\"", ")", ";", "complete", ".", "reject", "(", ")", ";", "}", ",", "this", ")", ",", "success", "=", "_", ".", "bind", "(", "function", "(", ")", "{", "publish", "(", "\"enter\"", ")", ";", "this", ".", "_transitioning", "=", "false", ";", "this", ".", "_current", "=", "toScene", ";", "publish", "(", "\"end\"", ")", ";", "complete", ".", "resolve", "(", ")", ";", "}", ",", "this", ")", ";", "if", "(", "!", "toScene", ")", "{", "throw", "\"Scene \\\"\"", "+", "sceneName", "+", "\"\\\" not found!\"", ";", "}", "// we in the middle of a transition?", "if", "(", "this", ".", "_transitioning", ")", "{", "return", "complete", ".", "reject", "(", ")", ";", "}", "publish", "(", "\"start\"", ")", ";", "this", ".", "_transitioning", "=", "true", ";", "if", "(", "fromScene", ")", "{", "// we are coming from a scene, so transition out of it.", "fromScene", ".", "to", "(", "\"exit\"", ",", "args", ",", "exitComplete", ")", ";", "exitComplete", ".", "done", "(", "function", "(", ")", "{", "publish", "(", "\"exit\"", ",", "true", ")", ";", "}", ")", ";", "}", "else", "{", "exitComplete", ".", "resolve", "(", ")", ";", "}", "// when we're done exiting, enter the next set", "_", ".", "when", "(", "exitComplete", ")", ".", "then", "(", "function", "(", ")", "{", "toScene", ".", "to", "(", "toScene", ".", "_initial", "||", "\"enter\"", ",", "args", ",", "enterComplete", ")", ";", "}", ")", ".", "fail", "(", "bailout", ")", ";", "enterComplete", ".", "then", "(", "success", ")", ".", "fail", "(", "bailout", ")", ";", "return", "complete", ".", "promise", "(", ")", ";", "}" ]
Used as the function to scenes that do have children.
[ "Used", "as", "the", "function", "to", "scenes", "that", "do", "have", "children", "." ]
96d6cdfe756e0e4f2df7c9a55c414fe93a4c38ec
https://github.com/misoproject/storyboard/blob/96d6cdfe756e0e4f2df7c9a55c414fe93a4c38ec/dist/miso.storyboard.r.0.1.0.js#L377-L446
36,702
ocadotechnology/quantumjs
quantum-markdown/lib/index.js
sluggifyText
function sluggifyText (text) { const slug = unEscapeHtmlTags(text).toLowerCase() // Replace 'unsafe' chars with dashes (!!!! is changed to -) .replace(unsafeCharsRegex, '-') // Replace multiple concurrent dashes with a single dash .replace(multiDashRegex, '-') // Remove trailing - .replace(lastCharDashRegex, '') // Encode the resulting string to make it url-safe return encodeURIComponent(slug) }
javascript
function sluggifyText (text) { const slug = unEscapeHtmlTags(text).toLowerCase() // Replace 'unsafe' chars with dashes (!!!! is changed to -) .replace(unsafeCharsRegex, '-') // Replace multiple concurrent dashes with a single dash .replace(multiDashRegex, '-') // Remove trailing - .replace(lastCharDashRegex, '') // Encode the resulting string to make it url-safe return encodeURIComponent(slug) }
[ "function", "sluggifyText", "(", "text", ")", "{", "const", "slug", "=", "unEscapeHtmlTags", "(", "text", ")", ".", "toLowerCase", "(", ")", "// Replace 'unsafe' chars with dashes (!!!! is changed to -)", ".", "replace", "(", "unsafeCharsRegex", ",", "'-'", ")", "// Replace multiple concurrent dashes with a single dash", ".", "replace", "(", "multiDashRegex", ",", "'-'", ")", "// Remove trailing -", ".", "replace", "(", "lastCharDashRegex", ",", "''", ")", "// Encode the resulting string to make it url-safe", "return", "encodeURIComponent", "(", "slug", ")", "}" ]
Takes a text string and returns a url-safe string for use when de-duplicating
[ "Takes", "a", "text", "string", "and", "returns", "a", "url", "-", "safe", "string", "for", "use", "when", "de", "-", "duplicating" ]
5bc684b750472296f186a816529272c36218db04
https://github.com/ocadotechnology/quantumjs/blob/5bc684b750472296f186a816529272c36218db04/quantum-markdown/lib/index.js#L56-L66
36,703
ocadotechnology/quantumjs
quantum-markdown/lib/index.js
dedupeAndSluggify
function dedupeAndSluggify (sluggify) { const existingHeadings = {} return (heading) => { const sluggifiedText = sluggify(heading) const existingCount = existingHeadings[sluggifiedText] || 0 existingHeadings[sluggifiedText] = existingCount + 1 return existingCount > 0 ? `${sluggifiedText}-${existingCount}` : sluggifiedText } }
javascript
function dedupeAndSluggify (sluggify) { const existingHeadings = {} return (heading) => { const sluggifiedText = sluggify(heading) const existingCount = existingHeadings[sluggifiedText] || 0 existingHeadings[sluggifiedText] = existingCount + 1 return existingCount > 0 ? `${sluggifiedText}-${existingCount}` : sluggifiedText } }
[ "function", "dedupeAndSluggify", "(", "sluggify", ")", "{", "const", "existingHeadings", "=", "{", "}", "return", "(", "heading", ")", "=>", "{", "const", "sluggifiedText", "=", "sluggify", "(", "heading", ")", "const", "existingCount", "=", "existingHeadings", "[", "sluggifiedText", "]", "||", "0", "existingHeadings", "[", "sluggifiedText", "]", "=", "existingCount", "+", "1", "return", "existingCount", ">", "0", "?", "`", "${", "sluggifiedText", "}", "${", "existingCount", "}", "`", ":", "sluggifiedText", "}", "}" ]
Takes an array and an sluggify function and returns a function that de-duplicates headings
[ "Takes", "an", "array", "and", "an", "sluggify", "function", "and", "returns", "a", "function", "that", "de", "-", "duplicates", "headings" ]
5bc684b750472296f186a816529272c36218db04
https://github.com/ocadotechnology/quantumjs/blob/5bc684b750472296f186a816529272c36218db04/quantum-markdown/lib/index.js#L69-L77
36,704
retsr/rets.js
lib/client.js
Client
function Client(name, password) { if (!(this instanceof Client)) { return new Client(name, password); } this.name = name || 'RETS-Connector1/2'; this.password = password || ''; }
javascript
function Client(name, password) { if (!(this instanceof Client)) { return new Client(name, password); } this.name = name || 'RETS-Connector1/2'; this.password = password || ''; }
[ "function", "Client", "(", "name", ",", "password", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Client", ")", ")", "{", "return", "new", "Client", "(", "name", ",", "password", ")", ";", "}", "this", ".", "name", "=", "name", "||", "'RETS-Connector1/2'", ";", "this", ".", "password", "=", "password", "||", "''", ";", "}" ]
Client class encapsulates User Agent instance data. @param {Object} config @param {string} config.name - The user agent's name @param {string} config.password - The user agent's password
[ "Client", "class", "encapsulates", "User", "Agent", "instance", "data", "." ]
52f0287390a1d0cb93bbbd7edf630d7ebcb6de26
https://github.com/retsr/rets.js/blob/52f0287390a1d0cb93bbbd7edf630d7ebcb6de26/lib/client.js#L24-L33
36,705
mariusc23/express-query-int
lib/parse.js
parseNums
function parseNums(obj, options) { var result = Array.isArray(obj) ? [] : {}, key, value, parsedValue; for (key in obj) { if (obj.hasOwnProperty(key)) { value = obj[key]; parsedValue = options.parser.call(null, value, 10, key); if (typeof value === 'string' && !isNaN(parsedValue)) { result[key] = parsedValue; } else if (value.constructor === Object || Array.isArray(value)) { result[key] = parseNums(value, options); } else { result[key] = value; } } } return result; }
javascript
function parseNums(obj, options) { var result = Array.isArray(obj) ? [] : {}, key, value, parsedValue; for (key in obj) { if (obj.hasOwnProperty(key)) { value = obj[key]; parsedValue = options.parser.call(null, value, 10, key); if (typeof value === 'string' && !isNaN(parsedValue)) { result[key] = parsedValue; } else if (value.constructor === Object || Array.isArray(value)) { result[key] = parseNums(value, options); } else { result[key] = value; } } } return result; }
[ "function", "parseNums", "(", "obj", ",", "options", ")", "{", "var", "result", "=", "Array", ".", "isArray", "(", "obj", ")", "?", "[", "]", ":", "{", "}", ",", "key", ",", "value", ",", "parsedValue", ";", "for", "(", "key", "in", "obj", ")", "{", "if", "(", "obj", ".", "hasOwnProperty", "(", "key", ")", ")", "{", "value", "=", "obj", "[", "key", "]", ";", "parsedValue", "=", "options", ".", "parser", ".", "call", "(", "null", ",", "value", ",", "10", ",", "key", ")", ";", "if", "(", "typeof", "value", "===", "'string'", "&&", "!", "isNaN", "(", "parsedValue", ")", ")", "{", "result", "[", "key", "]", "=", "parsedValue", ";", "}", "else", "if", "(", "value", ".", "constructor", "===", "Object", "||", "Array", ".", "isArray", "(", "value", ")", ")", "{", "result", "[", "key", "]", "=", "parseNums", "(", "value", ",", "options", ")", ";", "}", "else", "{", "result", "[", "key", "]", "=", "value", ";", "}", "}", "}", "return", "result", ";", "}" ]
Attempts to convert object properties recursively to numbers. @param {Object} obj - Object to iterate over. @param {Object} options - Options. @param {Function} options.parser - Parser to process string with. Should return NaN if not a valid number. Defaults to parseInt. @return {Object} Returns new object with same properties (shallow copy).
[ "Attempts", "to", "convert", "object", "properties", "recursively", "to", "numbers", "." ]
01aad8c910c006aae7bc87306a742d35c510a0a5
https://github.com/mariusc23/express-query-int/blob/01aad8c910c006aae7bc87306a742d35c510a0a5/lib/parse.js#L10-L34
36,706
ocadotechnology/quantumjs
quantum-template/lib/index.js
wrapper
function wrapper (fileContent, wrapperOptions) { const selection = quantum.select({ type: '', params: [], content: fileContent.content }) if (selection.has('template')) { const template = selection.select('template') // find out the name of the entity to replace with the page content const contentEntityType = template.has('contentEntityName') ? template.select('contentEntityName').ps() : 'content' // find the place to mount the rest of the page's content const contentEntity = template.select('content').select(contentEntityType, {recursive: true}) const parentContent = contentEntity.parent().content() // find out where the mount point is const position = parentContent.indexOf(contentEntity.entity()) // get the content to place at the mount point (ie remove all @templates from the page) const nonTemplateContent = selection.filter(x => x.type !== 'template') // make the replacement parentContent.splice.apply(parentContent, [position, 1].concat(nonTemplateContent.content())) return { content: template.select('content').content() } } else { return fileContent } }
javascript
function wrapper (fileContent, wrapperOptions) { const selection = quantum.select({ type: '', params: [], content: fileContent.content }) if (selection.has('template')) { const template = selection.select('template') // find out the name of the entity to replace with the page content const contentEntityType = template.has('contentEntityName') ? template.select('contentEntityName').ps() : 'content' // find the place to mount the rest of the page's content const contentEntity = template.select('content').select(contentEntityType, {recursive: true}) const parentContent = contentEntity.parent().content() // find out where the mount point is const position = parentContent.indexOf(contentEntity.entity()) // get the content to place at the mount point (ie remove all @templates from the page) const nonTemplateContent = selection.filter(x => x.type !== 'template') // make the replacement parentContent.splice.apply(parentContent, [position, 1].concat(nonTemplateContent.content())) return { content: template.select('content').content() } } else { return fileContent } }
[ "function", "wrapper", "(", "fileContent", ",", "wrapperOptions", ")", "{", "const", "selection", "=", "quantum", ".", "select", "(", "{", "type", ":", "''", ",", "params", ":", "[", "]", ",", "content", ":", "fileContent", ".", "content", "}", ")", "if", "(", "selection", ".", "has", "(", "'template'", ")", ")", "{", "const", "template", "=", "selection", ".", "select", "(", "'template'", ")", "// find out the name of the entity to replace with the page content", "const", "contentEntityType", "=", "template", ".", "has", "(", "'contentEntityName'", ")", "?", "template", ".", "select", "(", "'contentEntityName'", ")", ".", "ps", "(", ")", ":", "'content'", "// find the place to mount the rest of the page's content", "const", "contentEntity", "=", "template", ".", "select", "(", "'content'", ")", ".", "select", "(", "contentEntityType", ",", "{", "recursive", ":", "true", "}", ")", "const", "parentContent", "=", "contentEntity", ".", "parent", "(", ")", ".", "content", "(", ")", "// find out where the mount point is", "const", "position", "=", "parentContent", ".", "indexOf", "(", "contentEntity", ".", "entity", "(", ")", ")", "// get the content to place at the mount point (ie remove all @templates from the page)", "const", "nonTemplateContent", "=", "selection", ".", "filter", "(", "x", "=>", "x", ".", "type", "!==", "'template'", ")", "// make the replacement", "parentContent", ".", "splice", ".", "apply", "(", "parentContent", ",", "[", "position", ",", "1", "]", ".", "concat", "(", "nonTemplateContent", ".", "content", "(", ")", ")", ")", "return", "{", "content", ":", "template", ".", "select", "(", "'content'", ")", ".", "content", "(", ")", "}", "}", "else", "{", "return", "fileContent", "}", "}" ]
Processes the page for wrapping templates.
[ "Processes", "the", "page", "for", "wrapping", "templates", "." ]
5bc684b750472296f186a816529272c36218db04
https://github.com/ocadotechnology/quantumjs/blob/5bc684b750472296f186a816529272c36218db04/quantum-template/lib/index.js#L233-L267
36,707
gauravchl/ansi-art
webapp/src/index.js
readFile
function readFile(e) { const file = e.currentTarget.files && e.currentTarget.files[0]; const reader = new FileReader(); reader.onload = event => ArtBoard.loadANSI(event.target.result); if (file) reader.readAsText(file); }
javascript
function readFile(e) { const file = e.currentTarget.files && e.currentTarget.files[0]; const reader = new FileReader(); reader.onload = event => ArtBoard.loadANSI(event.target.result); if (file) reader.readAsText(file); }
[ "function", "readFile", "(", "e", ")", "{", "const", "file", "=", "e", ".", "currentTarget", ".", "files", "&&", "e", ".", "currentTarget", ".", "files", "[", "0", "]", ";", "const", "reader", "=", "new", "FileReader", "(", ")", ";", "reader", ".", "onload", "=", "event", "=>", "ArtBoard", ".", "loadANSI", "(", "event", ".", "target", ".", "result", ")", ";", "if", "(", "file", ")", "reader", ".", "readAsText", "(", "file", ")", ";", "}" ]
Init file uploader
[ "Init", "file", "uploader" ]
ed23b07320999728d2eeee07872c9e7881a700f9
https://github.com/gauravchl/ansi-art/blob/ed23b07320999728d2eeee07872c9e7881a700f9/webapp/src/index.js#L14-L20
36,708
Banno/polymer-lint
spec/support/helpers/streamFromString.js
streamFromString
function streamFromString(string) { const s = new stream.Readable(); s.push(string); s.push(null); return s; }
javascript
function streamFromString(string) { const s = new stream.Readable(); s.push(string); s.push(null); return s; }
[ "function", "streamFromString", "(", "string", ")", "{", "const", "s", "=", "new", "stream", ".", "Readable", "(", ")", ";", "s", ".", "push", "(", "string", ")", ";", "s", ".", "push", "(", "null", ")", ";", "return", "s", ";", "}" ]
helpers.streamFromString @param {string} string @return {stream.Readable} A Readable stream that will emit the given string
[ "helpers", ".", "streamFromString" ]
cf4ffdc63837280080b67f496d038d33a3975b6f
https://github.com/Banno/polymer-lint/blob/cf4ffdc63837280080b67f496d038d33a3975b6f/spec/support/helpers/streamFromString.js#L8-L13
36,709
fullstackers/bus.io
demo/chat/public/js/chat.js
share
function share() { var status = $.trim($('#status').val()), target = $('#target').val(); // Nothing to share if(status === '') { return; } // When messaging an individual user, update the target to be the user // that is being messaged. if(target === 'user') { target = $('#target_user').val(); } // Dispatch the message to the server. socket.emit('post', status, target); // Clear the status input for the next message. $('#status').val(''); }
javascript
function share() { var status = $.trim($('#status').val()), target = $('#target').val(); // Nothing to share if(status === '') { return; } // When messaging an individual user, update the target to be the user // that is being messaged. if(target === 'user') { target = $('#target_user').val(); } // Dispatch the message to the server. socket.emit('post', status, target); // Clear the status input for the next message. $('#status').val(''); }
[ "function", "share", "(", ")", "{", "var", "status", "=", "$", ".", "trim", "(", "$", "(", "'#status'", ")", ".", "val", "(", ")", ")", ",", "target", "=", "$", "(", "'#target'", ")", ".", "val", "(", ")", ";", "// Nothing to share", "if", "(", "status", "===", "''", ")", "{", "return", ";", "}", "// When messaging an individual user, update the target to be the user", "// that is being messaged.", "if", "(", "target", "===", "'user'", ")", "{", "target", "=", "$", "(", "'#target_user'", ")", ".", "val", "(", ")", ";", "}", "// Dispatch the message to the server.", "socket", ".", "emit", "(", "'post'", ",", "status", ",", "target", ")", ";", "// Clear the status input for the next message.", "$", "(", "'#status'", ")", ".", "val", "(", "''", ")", ";", "}" ]
Call this method when you are ready to send a message to the server.
[ "Call", "this", "method", "when", "you", "are", "ready", "to", "send", "a", "message", "to", "the", "server", "." ]
8bc8f38938925a31f67a9b03cf24f8fdb12f3353
https://github.com/fullstackers/bus.io/blob/8bc8f38938925a31f67a9b03cf24f8fdb12f3353/demo/chat/public/js/chat.js#L6-L26
36,710
jhermsmeier/node-flightstats
lib/flightstats.js
function( options, callback ) { if( typeof options === 'function' ) { callback = options options = null } options = options != null ? options : {} var self = this var baseUrl = 'airlines/rest/v1/json' var isCode = options.fs || options.iata || options.icao var supportsDate = !options.all || isCode if( !options.all && !isCode ) { baseUrl += '/active' } else if( !isCode ) { baseUrl += '/all' } if( options.fs ) { baseUrl += '/fs/' + options.fs } else if( options.iata ) { baseUrl += '/iata/' + options.iata } else if( options.icao ) { baseUrl += '/icao/' + options.icao } if( options.date && supportsDate ) { var year = options.date.getFullYear() var month = options.date.getMonth() + 1 var day = options.date.getDate() baseUrl += '/' + year + '/' + month + '/' + day } return this._clientRequest({ url: baseUrl, extendedOptions: [ 'includeNewFields' ], }, function( error, data ) { if( error != null ) return callback.call( self, error ) var airlines = [].concat( data.airlines || data.airline || [] ) // Trim excessive whitespace in airline names airlines.forEach( function( airline ) { airline.name = airline.name.replace( /^\s|\s$/g, '' ) }) // Expand the airline category to a detailed object if( options.expandCategory ) { airlines.forEach( function( airline ) { var info = FlightStats.AirlineCategory[ airline.category ] airline.category = { code: ( info && info.code ) || airline.category, scheduled: info && info.scheduled, passenger: info && info.passenger, cargo: info && info.cargo, } }) } callback.call( self, error, airlines ) }) }
javascript
function( options, callback ) { if( typeof options === 'function' ) { callback = options options = null } options = options != null ? options : {} var self = this var baseUrl = 'airlines/rest/v1/json' var isCode = options.fs || options.iata || options.icao var supportsDate = !options.all || isCode if( !options.all && !isCode ) { baseUrl += '/active' } else if( !isCode ) { baseUrl += '/all' } if( options.fs ) { baseUrl += '/fs/' + options.fs } else if( options.iata ) { baseUrl += '/iata/' + options.iata } else if( options.icao ) { baseUrl += '/icao/' + options.icao } if( options.date && supportsDate ) { var year = options.date.getFullYear() var month = options.date.getMonth() + 1 var day = options.date.getDate() baseUrl += '/' + year + '/' + month + '/' + day } return this._clientRequest({ url: baseUrl, extendedOptions: [ 'includeNewFields' ], }, function( error, data ) { if( error != null ) return callback.call( self, error ) var airlines = [].concat( data.airlines || data.airline || [] ) // Trim excessive whitespace in airline names airlines.forEach( function( airline ) { airline.name = airline.name.replace( /^\s|\s$/g, '' ) }) // Expand the airline category to a detailed object if( options.expandCategory ) { airlines.forEach( function( airline ) { var info = FlightStats.AirlineCategory[ airline.category ] airline.category = { code: ( info && info.code ) || airline.category, scheduled: info && info.scheduled, passenger: info && info.passenger, cargo: info && info.cargo, } }) } callback.call( self, error, airlines ) }) }
[ "function", "(", "options", ",", "callback", ")", "{", "if", "(", "typeof", "options", "===", "'function'", ")", "{", "callback", "=", "options", "options", "=", "null", "}", "options", "=", "options", "!=", "null", "?", "options", ":", "{", "}", "var", "self", "=", "this", "var", "baseUrl", "=", "'airlines/rest/v1/json'", "var", "isCode", "=", "options", ".", "fs", "||", "options", ".", "iata", "||", "options", ".", "icao", "var", "supportsDate", "=", "!", "options", ".", "all", "||", "isCode", "if", "(", "!", "options", ".", "all", "&&", "!", "isCode", ")", "{", "baseUrl", "+=", "'/active'", "}", "else", "if", "(", "!", "isCode", ")", "{", "baseUrl", "+=", "'/all'", "}", "if", "(", "options", ".", "fs", ")", "{", "baseUrl", "+=", "'/fs/'", "+", "options", ".", "fs", "}", "else", "if", "(", "options", ".", "iata", ")", "{", "baseUrl", "+=", "'/iata/'", "+", "options", ".", "iata", "}", "else", "if", "(", "options", ".", "icao", ")", "{", "baseUrl", "+=", "'/icao/'", "+", "options", ".", "icao", "}", "if", "(", "options", ".", "date", "&&", "supportsDate", ")", "{", "var", "year", "=", "options", ".", "date", ".", "getFullYear", "(", ")", "var", "month", "=", "options", ".", "date", ".", "getMonth", "(", ")", "+", "1", "var", "day", "=", "options", ".", "date", ".", "getDate", "(", ")", "baseUrl", "+=", "'/'", "+", "year", "+", "'/'", "+", "month", "+", "'/'", "+", "day", "}", "return", "this", ".", "_clientRequest", "(", "{", "url", ":", "baseUrl", ",", "extendedOptions", ":", "[", "'includeNewFields'", "]", ",", "}", ",", "function", "(", "error", ",", "data", ")", "{", "if", "(", "error", "!=", "null", ")", "return", "callback", ".", "call", "(", "self", ",", "error", ")", "var", "airlines", "=", "[", "]", ".", "concat", "(", "data", ".", "airlines", "||", "data", ".", "airline", "||", "[", "]", ")", "// Trim excessive whitespace in airline names", "airlines", ".", "forEach", "(", "function", "(", "airline", ")", "{", "airline", ".", "name", "=", "airline", ".", "name", ".", "replace", "(", "/", "^\\s|\\s$", "/", "g", ",", "''", ")", "}", ")", "// Expand the airline category to a detailed object", "if", "(", "options", ".", "expandCategory", ")", "{", "airlines", ".", "forEach", "(", "function", "(", "airline", ")", "{", "var", "info", "=", "FlightStats", ".", "AirlineCategory", "[", "airline", ".", "category", "]", "airline", ".", "category", "=", "{", "code", ":", "(", "info", "&&", "info", ".", "code", ")", "||", "airline", ".", "category", ",", "scheduled", ":", "info", "&&", "info", ".", "scheduled", ",", "passenger", ":", "info", "&&", "info", ".", "passenger", ",", "cargo", ":", "info", "&&", "info", ".", "cargo", ",", "}", "}", ")", "}", "callback", ".", "call", "(", "self", ",", "error", ",", "airlines", ")", "}", ")", "}" ]
Retrieve a list of airlines @param {Object} options @param {Boolean} [options.all=false] optional @param {?Date} [options.date] optional @param {?String} [options.iata] optional @param {?String} [options.icao] optional @param {?String} [options.fs] optional @param {Function} callback @return {Request}
[ "Retrieve", "a", "list", "of", "airlines" ]
023d46e11db4f4ba45ed414b1dc23084b1c9749d
https://github.com/jhermsmeier/node-flightstats/blob/023d46e11db4f4ba45ed414b1dc23084b1c9749d/lib/flightstats.js#L170-L245
36,711
jhermsmeier/node-flightstats
lib/flightstats.js
function( options, callback ) { if( typeof options === 'function' ) { callback = options options = null } options = options != null ? options : {} var self = this var baseUrl = 'airports/rest/v1/json' var isCode = options.fs || options.iata || options.icao var isLocationCode = options.city || options.country var isLocation = options.latitude && options.longitude && options.radius var supportsDate = !options.all && isCode if( !options.all && !isCode ) { baseUrl += '/active' } else if( !isCode && !isLocationCode && !isLocation ) { baseUrl += '/all' } if( isCode || isLocationCode ) { if( options.fs ) { baseUrl += '/fs/' + options.fs } else if( options.iata ) { baseUrl += '/iata/' + options.iata } else if( options.icao ) { baseUrl += '/icao/' + options.icao } else if( options.city ) { baseUrl += '/cityCode/' + options.city } else if( options.country ) { baseUrl += '/countryCode/' + options.country } } if( options.date && supportsDate ) { var year = options.date.getFullYear() var month = options.date.getMonth() + 1 var day = options.date.getDate() baseUrl += '/' + year + '/' + month + '/' + day } if( isLocation ) { baseUrl += '/' + options.longitude + '/' + options.latitude + '/' + options.radius } return this._clientRequest({ url: baseUrl, extendedOptions: [ 'includeNewFields' ], }, function( error, data ) { if( error != null ) return callback.call( self, error ) var airports = [].concat( data.airports || data.airport || [] ) .map( function( airport ) { airport.tzOffset = airport.utcOffsetHours airport.tzRegion = airport.timeZoneRegionName airport.elevation = airport.elevationFeet * 0.305 airport.utcOffsetHours = undefined delete airport.utcOffsetHours airport.timeZoneRegionName = undefined delete airport.timeZoneRegionName return airport }) callback.call( self, error, airports ) }) }
javascript
function( options, callback ) { if( typeof options === 'function' ) { callback = options options = null } options = options != null ? options : {} var self = this var baseUrl = 'airports/rest/v1/json' var isCode = options.fs || options.iata || options.icao var isLocationCode = options.city || options.country var isLocation = options.latitude && options.longitude && options.radius var supportsDate = !options.all && isCode if( !options.all && !isCode ) { baseUrl += '/active' } else if( !isCode && !isLocationCode && !isLocation ) { baseUrl += '/all' } if( isCode || isLocationCode ) { if( options.fs ) { baseUrl += '/fs/' + options.fs } else if( options.iata ) { baseUrl += '/iata/' + options.iata } else if( options.icao ) { baseUrl += '/icao/' + options.icao } else if( options.city ) { baseUrl += '/cityCode/' + options.city } else if( options.country ) { baseUrl += '/countryCode/' + options.country } } if( options.date && supportsDate ) { var year = options.date.getFullYear() var month = options.date.getMonth() + 1 var day = options.date.getDate() baseUrl += '/' + year + '/' + month + '/' + day } if( isLocation ) { baseUrl += '/' + options.longitude + '/' + options.latitude + '/' + options.radius } return this._clientRequest({ url: baseUrl, extendedOptions: [ 'includeNewFields' ], }, function( error, data ) { if( error != null ) return callback.call( self, error ) var airports = [].concat( data.airports || data.airport || [] ) .map( function( airport ) { airport.tzOffset = airport.utcOffsetHours airport.tzRegion = airport.timeZoneRegionName airport.elevation = airport.elevationFeet * 0.305 airport.utcOffsetHours = undefined delete airport.utcOffsetHours airport.timeZoneRegionName = undefined delete airport.timeZoneRegionName return airport }) callback.call( self, error, airports ) }) }
[ "function", "(", "options", ",", "callback", ")", "{", "if", "(", "typeof", "options", "===", "'function'", ")", "{", "callback", "=", "options", "options", "=", "null", "}", "options", "=", "options", "!=", "null", "?", "options", ":", "{", "}", "var", "self", "=", "this", "var", "baseUrl", "=", "'airports/rest/v1/json'", "var", "isCode", "=", "options", ".", "fs", "||", "options", ".", "iata", "||", "options", ".", "icao", "var", "isLocationCode", "=", "options", ".", "city", "||", "options", ".", "country", "var", "isLocation", "=", "options", ".", "latitude", "&&", "options", ".", "longitude", "&&", "options", ".", "radius", "var", "supportsDate", "=", "!", "options", ".", "all", "&&", "isCode", "if", "(", "!", "options", ".", "all", "&&", "!", "isCode", ")", "{", "baseUrl", "+=", "'/active'", "}", "else", "if", "(", "!", "isCode", "&&", "!", "isLocationCode", "&&", "!", "isLocation", ")", "{", "baseUrl", "+=", "'/all'", "}", "if", "(", "isCode", "||", "isLocationCode", ")", "{", "if", "(", "options", ".", "fs", ")", "{", "baseUrl", "+=", "'/fs/'", "+", "options", ".", "fs", "}", "else", "if", "(", "options", ".", "iata", ")", "{", "baseUrl", "+=", "'/iata/'", "+", "options", ".", "iata", "}", "else", "if", "(", "options", ".", "icao", ")", "{", "baseUrl", "+=", "'/icao/'", "+", "options", ".", "icao", "}", "else", "if", "(", "options", ".", "city", ")", "{", "baseUrl", "+=", "'/cityCode/'", "+", "options", ".", "city", "}", "else", "if", "(", "options", ".", "country", ")", "{", "baseUrl", "+=", "'/countryCode/'", "+", "options", ".", "country", "}", "}", "if", "(", "options", ".", "date", "&&", "supportsDate", ")", "{", "var", "year", "=", "options", ".", "date", ".", "getFullYear", "(", ")", "var", "month", "=", "options", ".", "date", ".", "getMonth", "(", ")", "+", "1", "var", "day", "=", "options", ".", "date", ".", "getDate", "(", ")", "baseUrl", "+=", "'/'", "+", "year", "+", "'/'", "+", "month", "+", "'/'", "+", "day", "}", "if", "(", "isLocation", ")", "{", "baseUrl", "+=", "'/'", "+", "options", ".", "longitude", "+", "'/'", "+", "options", ".", "latitude", "+", "'/'", "+", "options", ".", "radius", "}", "return", "this", ".", "_clientRequest", "(", "{", "url", ":", "baseUrl", ",", "extendedOptions", ":", "[", "'includeNewFields'", "]", ",", "}", ",", "function", "(", "error", ",", "data", ")", "{", "if", "(", "error", "!=", "null", ")", "return", "callback", ".", "call", "(", "self", ",", "error", ")", "var", "airports", "=", "[", "]", ".", "concat", "(", "data", ".", "airports", "||", "data", ".", "airport", "||", "[", "]", ")", ".", "map", "(", "function", "(", "airport", ")", "{", "airport", ".", "tzOffset", "=", "airport", ".", "utcOffsetHours", "airport", ".", "tzRegion", "=", "airport", ".", "timeZoneRegionName", "airport", ".", "elevation", "=", "airport", ".", "elevationFeet", "*", "0.305", "airport", ".", "utcOffsetHours", "=", "undefined", "delete", "airport", ".", "utcOffsetHours", "airport", ".", "timeZoneRegionName", "=", "undefined", "delete", "airport", ".", "timeZoneRegionName", "return", "airport", "}", ")", "callback", ".", "call", "(", "self", ",", "error", ",", "airports", ")", "}", ")", "}" ]
Retrieve a list of airports @param {Object} options @param {?Boolean} [options.all=false] optional @param {?Date} [options.date] optional @param {?String} [options.iata] optional @param {?String} [options.icao] optional @param {?String} [options.fs] optional @param {?String} [options.city] optional @param {?String} [options.country] optional @param {?Number} [options.latitude] optional @param {?Number} [options.longitude] optional @param {?Number} [options.radius] optional @param {Function} callback @return {Request}
[ "Retrieve", "a", "list", "of", "airports" ]
023d46e11db4f4ba45ed414b1dc23084b1c9749d
https://github.com/jhermsmeier/node-flightstats/blob/023d46e11db4f4ba45ed414b1dc23084b1c9749d/lib/flightstats.js#L263-L344
36,712
jhermsmeier/node-flightstats
lib/flightstats.js
function( options, callback ) { debug( 'lookup' ) var now = Date.now() var target = options.date.getTime() // NOTE: `.status()` is only available within a window of -7 to +3 days var timeMin = now - ( 8 * 24 ) * 60 * 60 * 1000 var timeMax = now + ( 3 * 24 ) * 60 * 60 * 1000 var method = target < timeMin || target > timeMax ? 'schedule' : 'status' debug( 'lookup:time:target ', target ) debug( 'lookup:time:window', timeMin, timeMax ) debug( 'lookup:type', method ) return this[ method ]( options, callback ) }
javascript
function( options, callback ) { debug( 'lookup' ) var now = Date.now() var target = options.date.getTime() // NOTE: `.status()` is only available within a window of -7 to +3 days var timeMin = now - ( 8 * 24 ) * 60 * 60 * 1000 var timeMax = now + ( 3 * 24 ) * 60 * 60 * 1000 var method = target < timeMin || target > timeMax ? 'schedule' : 'status' debug( 'lookup:time:target ', target ) debug( 'lookup:time:window', timeMin, timeMax ) debug( 'lookup:type', method ) return this[ method ]( options, callback ) }
[ "function", "(", "options", ",", "callback", ")", "{", "debug", "(", "'lookup'", ")", "var", "now", "=", "Date", ".", "now", "(", ")", "var", "target", "=", "options", ".", "date", ".", "getTime", "(", ")", "// NOTE: `.status()` is only available within a window of -7 to +3 days", "var", "timeMin", "=", "now", "-", "(", "8", "*", "24", ")", "*", "60", "*", "60", "*", "1000", "var", "timeMax", "=", "now", "+", "(", "3", "*", "24", ")", "*", "60", "*", "60", "*", "1000", "var", "method", "=", "target", "<", "timeMin", "||", "target", ">", "timeMax", "?", "'schedule'", ":", "'status'", "debug", "(", "'lookup:time:target '", ",", "target", ")", "debug", "(", "'lookup:time:window'", ",", "timeMin", ",", "timeMax", ")", "debug", "(", "'lookup:type'", ",", "method", ")", "return", "this", "[", "method", "]", "(", "options", ",", "callback", ")", "}" ]
Look up a flight @param {Object} options @param {Date} options.date @param {String} options.airlineCode @param {String} options.flightNumber @param {?String} [options.airport] optional @param {?String} [options.direction='arr'] optional @param {?Array<String>} [options.extendedOptions] optional @param {Function} callback @return {Request}
[ "Look", "up", "a", "flight" ]
023d46e11db4f4ba45ed414b1dc23084b1c9749d
https://github.com/jhermsmeier/node-flightstats/blob/023d46e11db4f4ba45ed414b1dc23084b1c9749d/lib/flightstats.js#L358-L378
36,713
jhermsmeier/node-flightstats
lib/flightstats.js
function( options, callback ) { debug( 'schedule', options ) var self = this var protocol = options.protocol || 'rest' var format = options.format || 'json' var baseUrl = 'schedules/' + protocol + '/v1/' + format + '/flight' var carrier = options.airlineCode var flightNumber = options.flightNumber var year = options.date.getFullYear() var month = options.date.getMonth() + 1 var day = options.date.getDate() var direction = /^dep/i.test( options.direction ) ? 'departing' : 'arriving' var extensions = [ 'includeDirects', 'includeCargo', 'useInlinedReferences' ] if( Array.isArray( options.extendedOptions ) ) { extensions = extensions.concat( options.extendedOptions ) } return this._clientRequest({ url: baseUrl + '/' + carrier + '/' + flightNumber + '/' + direction + '/' + year + '/' + month + '/' + day, extendedOptions: extensions, }, function( error, data ) { if( data != null ) { data = FlightStats.formatSchedule( data ) if( options.airport && data.flights ) { data.flights = FlightStats.filterByAirport( data.flights, options.airport, options.direction ) } } callback.call( self, error, data ) }) }
javascript
function( options, callback ) { debug( 'schedule', options ) var self = this var protocol = options.protocol || 'rest' var format = options.format || 'json' var baseUrl = 'schedules/' + protocol + '/v1/' + format + '/flight' var carrier = options.airlineCode var flightNumber = options.flightNumber var year = options.date.getFullYear() var month = options.date.getMonth() + 1 var day = options.date.getDate() var direction = /^dep/i.test( options.direction ) ? 'departing' : 'arriving' var extensions = [ 'includeDirects', 'includeCargo', 'useInlinedReferences' ] if( Array.isArray( options.extendedOptions ) ) { extensions = extensions.concat( options.extendedOptions ) } return this._clientRequest({ url: baseUrl + '/' + carrier + '/' + flightNumber + '/' + direction + '/' + year + '/' + month + '/' + day, extendedOptions: extensions, }, function( error, data ) { if( data != null ) { data = FlightStats.formatSchedule( data ) if( options.airport && data.flights ) { data.flights = FlightStats.filterByAirport( data.flights, options.airport, options.direction ) } } callback.call( self, error, data ) }) }
[ "function", "(", "options", ",", "callback", ")", "{", "debug", "(", "'schedule'", ",", "options", ")", "var", "self", "=", "this", "var", "protocol", "=", "options", ".", "protocol", "||", "'rest'", "var", "format", "=", "options", ".", "format", "||", "'json'", "var", "baseUrl", "=", "'schedules/'", "+", "protocol", "+", "'/v1/'", "+", "format", "+", "'/flight'", "var", "carrier", "=", "options", ".", "airlineCode", "var", "flightNumber", "=", "options", ".", "flightNumber", "var", "year", "=", "options", ".", "date", ".", "getFullYear", "(", ")", "var", "month", "=", "options", ".", "date", ".", "getMonth", "(", ")", "+", "1", "var", "day", "=", "options", ".", "date", ".", "getDate", "(", ")", "var", "direction", "=", "/", "^dep", "/", "i", ".", "test", "(", "options", ".", "direction", ")", "?", "'departing'", ":", "'arriving'", "var", "extensions", "=", "[", "'includeDirects'", ",", "'includeCargo'", ",", "'useInlinedReferences'", "]", "if", "(", "Array", ".", "isArray", "(", "options", ".", "extendedOptions", ")", ")", "{", "extensions", "=", "extensions", ".", "concat", "(", "options", ".", "extendedOptions", ")", "}", "return", "this", ".", "_clientRequest", "(", "{", "url", ":", "baseUrl", "+", "'/'", "+", "carrier", "+", "'/'", "+", "flightNumber", "+", "'/'", "+", "direction", "+", "'/'", "+", "year", "+", "'/'", "+", "month", "+", "'/'", "+", "day", ",", "extendedOptions", ":", "extensions", ",", "}", ",", "function", "(", "error", ",", "data", ")", "{", "if", "(", "data", "!=", "null", ")", "{", "data", "=", "FlightStats", ".", "formatSchedule", "(", "data", ")", "if", "(", "options", ".", "airport", "&&", "data", ".", "flights", ")", "{", "data", ".", "flights", "=", "FlightStats", ".", "filterByAirport", "(", "data", ".", "flights", ",", "options", ".", "airport", ",", "options", ".", "direction", ")", "}", "}", "callback", ".", "call", "(", "self", ",", "error", ",", "data", ")", "}", ")", "}" ]
Get a flight's schedule status information @param {Object} options - see [.lookup()]{@link FlightStats#lookup} @param {Function} callback @return {Request}
[ "Get", "a", "flight", "s", "schedule", "status", "information" ]
023d46e11db4f4ba45ed414b1dc23084b1c9749d
https://github.com/jhermsmeier/node-flightstats/blob/023d46e11db4f4ba45ed414b1dc23084b1c9749d/lib/flightstats.js#L440-L484
36,714
jhermsmeier/node-flightstats
lib/flightstats.js
function( options, callback ) { options = Object.assign({ type: 'firstflightin', verb: '/arriving_before/' }, options ) return this.connections( options, callback ) }
javascript
function( options, callback ) { options = Object.assign({ type: 'firstflightin', verb: '/arriving_before/' }, options ) return this.connections( options, callback ) }
[ "function", "(", "options", ",", "callback", ")", "{", "options", "=", "Object", ".", "assign", "(", "{", "type", ":", "'firstflightin'", ",", "verb", ":", "'/arriving_before/'", "}", ",", "options", ")", "return", "this", ".", "connections", "(", "options", ",", "callback", ")", "}" ]
Get the first inbound flight between two airports @param {Object} options - see [.connections()]{@link FlightStats#connections} @param {Function} callback @return {Request}
[ "Get", "the", "first", "inbound", "flight", "between", "two", "airports" ]
023d46e11db4f4ba45ed414b1dc23084b1c9749d
https://github.com/jhermsmeier/node-flightstats/blob/023d46e11db4f4ba45ed414b1dc23084b1c9749d/lib/flightstats.js#L492-L495
36,715
jhermsmeier/node-flightstats
lib/flightstats.js
function( options, callback ) { var self = this var year = options.date.getFullYear() var month = options.date.getMonth() + 1 var day = options.date.getDate() var hour = options.date.getHours() var minute = options.date.getMinutes() var url = '/connections/rest/v2/json/' + options.type + '/' + options.departureAirport + '/to/' + options.arrivalAirport + options.verb + year + '/' + month + '/' + day + '/' + hour + '/' + minute var extensions = [] if( Array.isArray( options.extendedOptions ) ) { extensions = extensions.concat( options.extendedOptions ) } var query = { numHours: options.numHours, maxResults: options.maxResults, maxConnections: options.maxConnections, minimumConnectTime: options.minimumConnectTime, payloadType: options.payloadType, includeAirlines: options.includeAirlines, excludeAirlines: options.excludeAirlines, includeAirports: options.includeAirports, excludeAirports: options.excludeAirports, includeSurface: options.includeSurface, includeCodeshares: options.includeCodeshares, includeMultipleCarriers: options.includeMultipleCarriers, } Object.keys( query ).forEach( function( key ) { query[key] = query[key] != null ? query[key] : undefined }) return this._clientRequest({ url: url, qs: query, extendedOptions: extensions, }, function( error, data ) { callback.call( self, error, data ) }) }
javascript
function( options, callback ) { var self = this var year = options.date.getFullYear() var month = options.date.getMonth() + 1 var day = options.date.getDate() var hour = options.date.getHours() var minute = options.date.getMinutes() var url = '/connections/rest/v2/json/' + options.type + '/' + options.departureAirport + '/to/' + options.arrivalAirport + options.verb + year + '/' + month + '/' + day + '/' + hour + '/' + minute var extensions = [] if( Array.isArray( options.extendedOptions ) ) { extensions = extensions.concat( options.extendedOptions ) } var query = { numHours: options.numHours, maxResults: options.maxResults, maxConnections: options.maxConnections, minimumConnectTime: options.minimumConnectTime, payloadType: options.payloadType, includeAirlines: options.includeAirlines, excludeAirlines: options.excludeAirlines, includeAirports: options.includeAirports, excludeAirports: options.excludeAirports, includeSurface: options.includeSurface, includeCodeshares: options.includeCodeshares, includeMultipleCarriers: options.includeMultipleCarriers, } Object.keys( query ).forEach( function( key ) { query[key] = query[key] != null ? query[key] : undefined }) return this._clientRequest({ url: url, qs: query, extendedOptions: extensions, }, function( error, data ) { callback.call( self, error, data ) }) }
[ "function", "(", "options", ",", "callback", ")", "{", "var", "self", "=", "this", "var", "year", "=", "options", ".", "date", ".", "getFullYear", "(", ")", "var", "month", "=", "options", ".", "date", ".", "getMonth", "(", ")", "+", "1", "var", "day", "=", "options", ".", "date", ".", "getDate", "(", ")", "var", "hour", "=", "options", ".", "date", ".", "getHours", "(", ")", "var", "minute", "=", "options", ".", "date", ".", "getMinutes", "(", ")", "var", "url", "=", "'/connections/rest/v2/json/'", "+", "options", ".", "type", "+", "'/'", "+", "options", ".", "departureAirport", "+", "'/to/'", "+", "options", ".", "arrivalAirport", "+", "options", ".", "verb", "+", "year", "+", "'/'", "+", "month", "+", "'/'", "+", "day", "+", "'/'", "+", "hour", "+", "'/'", "+", "minute", "var", "extensions", "=", "[", "]", "if", "(", "Array", ".", "isArray", "(", "options", ".", "extendedOptions", ")", ")", "{", "extensions", "=", "extensions", ".", "concat", "(", "options", ".", "extendedOptions", ")", "}", "var", "query", "=", "{", "numHours", ":", "options", ".", "numHours", ",", "maxResults", ":", "options", ".", "maxResults", ",", "maxConnections", ":", "options", ".", "maxConnections", ",", "minimumConnectTime", ":", "options", ".", "minimumConnectTime", ",", "payloadType", ":", "options", ".", "payloadType", ",", "includeAirlines", ":", "options", ".", "includeAirlines", ",", "excludeAirlines", ":", "options", ".", "excludeAirlines", ",", "includeAirports", ":", "options", ".", "includeAirports", ",", "excludeAirports", ":", "options", ".", "excludeAirports", ",", "includeSurface", ":", "options", ".", "includeSurface", ",", "includeCodeshares", ":", "options", ".", "includeCodeshares", ",", "includeMultipleCarriers", ":", "options", ".", "includeMultipleCarriers", ",", "}", "Object", ".", "keys", "(", "query", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "query", "[", "key", "]", "=", "query", "[", "key", "]", "!=", "null", "?", "query", "[", "key", "]", ":", "undefined", "}", ")", "return", "this", ".", "_clientRequest", "(", "{", "url", ":", "url", ",", "qs", ":", "query", ",", "extendedOptions", ":", "extensions", ",", "}", ",", "function", "(", "error", ",", "data", ")", "{", "callback", ".", "call", "(", "self", ",", "error", ",", "data", ")", "}", ")", "}" ]
Get connecting flights between two airports @internal used by {first,last}Flight{In,Out} methods @param {Object} options @param {?String} [options.type] optional, only used by `.connections()` @param {String} options.departureAirport @param {String} options.arrivalAirport @param {Date} options.date @param {?Number} [options.numHours=6] optional @param {?Number} [options.maxResults=25] optional @param {?Number} [options.maxConnections=2] optional @param {?Number} [options.minimumConnectTime] optional @param {?String} [options.payloadType='passenger'] optional @param {?Array<String>} [options.includeAirlines] optional @param {?Array<String>} [options.excludeAirlines] optional @param {?Array<String>} [options.includeAirports] optional @param {?Array<String>} [options.excludeAirports] optional @param {?Boolean} [options.includeSurface=false] optional @param {?Boolean} [options.includeCodeshares=true] optional @param {?Boolean} [options.includeMultipleCarriers=true] optional @param {Array<String>} [options.extendedOptions] @param {Function} callback @return {Request}
[ "Get", "connecting", "flights", "between", "two", "airports" ]
023d46e11db4f4ba45ed414b1dc23084b1c9749d
https://github.com/jhermsmeier/node-flightstats/blob/023d46e11db4f4ba45ed414b1dc23084b1c9749d/lib/flightstats.js#L554-L601
36,716
jhermsmeier/node-flightstats
lib/flightstats.js
function( options, callback ) { var self = this var url = '/ratings/rest/v1/json/flight/' + options.carrier + '/' + options.flightNumber var extensions = [] if( Array.isArray( options.extendedOptions ) ) { extensions = extensions.concat( options.extendedOptions ) } return this._clientRequest({ url: url, extendedOptions: extensions, qs: { departureAirport: options.departureAirport, codeType: options.codeType, } }, function( error, data ) { callback.call( self, error, data ) }) }
javascript
function( options, callback ) { var self = this var url = '/ratings/rest/v1/json/flight/' + options.carrier + '/' + options.flightNumber var extensions = [] if( Array.isArray( options.extendedOptions ) ) { extensions = extensions.concat( options.extendedOptions ) } return this._clientRequest({ url: url, extendedOptions: extensions, qs: { departureAirport: options.departureAirport, codeType: options.codeType, } }, function( error, data ) { callback.call( self, error, data ) }) }
[ "function", "(", "options", ",", "callback", ")", "{", "var", "self", "=", "this", "var", "url", "=", "'/ratings/rest/v1/json/flight/'", "+", "options", ".", "carrier", "+", "'/'", "+", "options", ".", "flightNumber", "var", "extensions", "=", "[", "]", "if", "(", "Array", ".", "isArray", "(", "options", ".", "extendedOptions", ")", ")", "{", "extensions", "=", "extensions", ".", "concat", "(", "options", ".", "extendedOptions", ")", "}", "return", "this", ".", "_clientRequest", "(", "{", "url", ":", "url", ",", "extendedOptions", ":", "extensions", ",", "qs", ":", "{", "departureAirport", ":", "options", ".", "departureAirport", ",", "codeType", ":", "options", ".", "codeType", ",", "}", "}", ",", "function", "(", "error", ",", "data", ")", "{", "callback", ".", "call", "(", "self", ",", "error", ",", "data", ")", "}", ")", "}" ]
Get ratings for a specified flight @param {Object} options @param {String} options.carrier @param {String|Number} options.flightNumber @param {Array<String>} [options.extendedOptions] @param {Function} callback @return {Request}
[ "Get", "ratings", "for", "a", "specified", "flight" ]
023d46e11db4f4ba45ed414b1dc23084b1c9749d
https://github.com/jhermsmeier/node-flightstats/blob/023d46e11db4f4ba45ed414b1dc23084b1c9749d/lib/flightstats.js#L612-L634
36,717
jhermsmeier/node-flightstats
lib/flightstats.js
function( options, callback ) { debug( 'route', options ) var self = this var year = options.date.getFullYear() var month = options.date.getMonth() + 1 var day = options.date.getDate() var direction = /^dep/i.test( options.direction ) ? 'dep' : 'arr' var url = 'flightstatus/rest/v2/json/route/status/' + options.departureAirport + '/' + options.arrivalAirport + '/' + direction + '/' + year + '/' + month + '/' + day var extensions = [ 'useInlinedReferences' ] if( Array.isArray( options.extendedOptions ) ) { extensions = extensions.concat( options.extendedOptions ) } return this._clientRequest({ url: url, extendedOptions: extensions, qs: { maxFlights: options.maxFlights, codeType: options.codeType, numHours: options.numHours, utc: options.utc, hourOfDay: options.hourOfDay, } }, function( error, data ) { callback.call( self, error, data ) }) }
javascript
function( options, callback ) { debug( 'route', options ) var self = this var year = options.date.getFullYear() var month = options.date.getMonth() + 1 var day = options.date.getDate() var direction = /^dep/i.test( options.direction ) ? 'dep' : 'arr' var url = 'flightstatus/rest/v2/json/route/status/' + options.departureAirport + '/' + options.arrivalAirport + '/' + direction + '/' + year + '/' + month + '/' + day var extensions = [ 'useInlinedReferences' ] if( Array.isArray( options.extendedOptions ) ) { extensions = extensions.concat( options.extendedOptions ) } return this._clientRequest({ url: url, extendedOptions: extensions, qs: { maxFlights: options.maxFlights, codeType: options.codeType, numHours: options.numHours, utc: options.utc, hourOfDay: options.hourOfDay, } }, function( error, data ) { callback.call( self, error, data ) }) }
[ "function", "(", "options", ",", "callback", ")", "{", "debug", "(", "'route'", ",", "options", ")", "var", "self", "=", "this", "var", "year", "=", "options", ".", "date", ".", "getFullYear", "(", ")", "var", "month", "=", "options", ".", "date", ".", "getMonth", "(", ")", "+", "1", "var", "day", "=", "options", ".", "date", ".", "getDate", "(", ")", "var", "direction", "=", "/", "^dep", "/", "i", ".", "test", "(", "options", ".", "direction", ")", "?", "'dep'", ":", "'arr'", "var", "url", "=", "'flightstatus/rest/v2/json/route/status/'", "+", "options", ".", "departureAirport", "+", "'/'", "+", "options", ".", "arrivalAirport", "+", "'/'", "+", "direction", "+", "'/'", "+", "year", "+", "'/'", "+", "month", "+", "'/'", "+", "day", "var", "extensions", "=", "[", "'useInlinedReferences'", "]", "if", "(", "Array", ".", "isArray", "(", "options", ".", "extendedOptions", ")", ")", "{", "extensions", "=", "extensions", ".", "concat", "(", "options", ".", "extendedOptions", ")", "}", "return", "this", ".", "_clientRequest", "(", "{", "url", ":", "url", ",", "extendedOptions", ":", "extensions", ",", "qs", ":", "{", "maxFlights", ":", "options", ".", "maxFlights", ",", "codeType", ":", "options", ".", "codeType", ",", "numHours", ":", "options", ".", "numHours", ",", "utc", ":", "options", ".", "utc", ",", "hourOfDay", ":", "options", ".", "hourOfDay", ",", "}", "}", ",", "function", "(", "error", ",", "data", ")", "{", "callback", ".", "call", "(", "self", ",", "error", ",", "data", ")", "}", ")", "}" ]
Get routes between two airports @param {Object} options @param {Date} options.date @param {String} options.departureAirport @param {String} options.arrivalAirport @param {String} options.codeType @param {Number} options.maxFlights @param {Number} options.numHours @param {Number} options.hourOfDay @param {Boolean} options.utc @param {Array<String>} [options.extendedOptions] @param {Function} callback @return {Request}
[ "Get", "routes", "between", "two", "airports" ]
023d46e11db4f4ba45ed414b1dc23084b1c9749d
https://github.com/jhermsmeier/node-flightstats/blob/023d46e11db4f4ba45ed414b1dc23084b1c9749d/lib/flightstats.js#L752-L789
36,718
ocadotechnology/quantumjs
quantum-dom/lib/index.js
randomId
function randomId () { const res = new Array(32) const alphabet = 'ABCDEF0123456789' for (let i = 0; i < 32; i++) { res[i] = alphabet[Math.floor(Math.random() * 16)] } return res.join('') }
javascript
function randomId () { const res = new Array(32) const alphabet = 'ABCDEF0123456789' for (let i = 0; i < 32; i++) { res[i] = alphabet[Math.floor(Math.random() * 16)] } return res.join('') }
[ "function", "randomId", "(", ")", "{", "const", "res", "=", "new", "Array", "(", "32", ")", "const", "alphabet", "=", "'ABCDEF0123456789'", "for", "(", "let", "i", "=", "0", ";", "i", "<", "32", ";", "i", "++", ")", "{", "res", "[", "i", "]", "=", "alphabet", "[", "Math", ".", "floor", "(", "Math", ".", "random", "(", ")", "*", "16", ")", "]", "}", "return", "res", ".", "join", "(", "''", ")", "}" ]
creates a random id
[ "creates", "a", "random", "id" ]
5bc684b750472296f186a816529272c36218db04
https://github.com/ocadotechnology/quantumjs/blob/5bc684b750472296f186a816529272c36218db04/quantum-dom/lib/index.js#L33-L40
36,719
ocadotechnology/quantumjs
examples/all-modules/src/transforms/custom-transforms.js
signIn
function signIn (selection) { return dom.create('div').class('sign-in') .add(dom.create('input').class('username-input')) .add(dom.create('input').class('password-input')) .add(dom.create('button').class('sign-in-button').text('Sign in')) }
javascript
function signIn (selection) { return dom.create('div').class('sign-in') .add(dom.create('input').class('username-input')) .add(dom.create('input').class('password-input')) .add(dom.create('button').class('sign-in-button').text('Sign in')) }
[ "function", "signIn", "(", "selection", ")", "{", "return", "dom", ".", "create", "(", "'div'", ")", ".", "class", "(", "'sign-in'", ")", ".", "add", "(", "dom", ".", "create", "(", "'input'", ")", ".", "class", "(", "'username-input'", ")", ")", ".", "add", "(", "dom", ".", "create", "(", "'input'", ")", ".", "class", "(", "'password-input'", ")", ")", ".", "add", "(", "dom", ".", "create", "(", "'button'", ")", ".", "class", "(", "'sign-in-button'", ")", ".", "text", "(", "'Sign in'", ")", ")", "}" ]
creates a sign in block for the @signIn entity
[ "creates", "a", "sign", "in", "block", "for", "the" ]
5bc684b750472296f186a816529272c36218db04
https://github.com/ocadotechnology/quantumjs/blob/5bc684b750472296f186a816529272c36218db04/examples/all-modules/src/transforms/custom-transforms.js#L4-L9
36,720
ocadotechnology/quantumjs
quantum-core/lib/select.js
isEntity
function isEntity (d) { return isText(d.type) && Array.isArray(d.params) && Array.isArray(d.content) }
javascript
function isEntity (d) { return isText(d.type) && Array.isArray(d.params) && Array.isArray(d.content) }
[ "function", "isEntity", "(", "d", ")", "{", "return", "isText", "(", "d", ".", "type", ")", "&&", "Array", ".", "isArray", "(", "d", ".", "params", ")", "&&", "Array", ".", "isArray", "(", "d", ".", "content", ")", "}" ]
duck type check for an entity
[ "duck", "type", "check", "for", "an", "entity" ]
5bc684b750472296f186a816529272c36218db04
https://github.com/ocadotechnology/quantumjs/blob/5bc684b750472296f186a816529272c36218db04/quantum-core/lib/select.js#L17-L19
36,721
Banno/polymer-lint
spec/support/helpers/inspect.js
inspect
function inspect(stringsOrOpts, ...values) { if (Array.isArray(stringsOrOpts)) { return DEFAULT_INSPECT(stringsOrOpts, ...values); } return inspector(stringsOrOpts); }
javascript
function inspect(stringsOrOpts, ...values) { if (Array.isArray(stringsOrOpts)) { return DEFAULT_INSPECT(stringsOrOpts, ...values); } return inspector(stringsOrOpts); }
[ "function", "inspect", "(", "stringsOrOpts", ",", "...", "values", ")", "{", "if", "(", "Array", ".", "isArray", "(", "stringsOrOpts", ")", ")", "{", "return", "DEFAULT_INSPECT", "(", "stringsOrOpts", ",", "...", "values", ")", ";", "}", "return", "inspector", "(", "stringsOrOpts", ")", ";", "}" ]
helpers.inspect A tagged template function that automatically calls `util.inspect` on interpolated values in template string literals. If called with an options object, `helpers.inspect` will return a tagged template function that passes the options to `util.inspect`. @example const foo = 'xyz'; const bar = { a: { b: { c: 'def' } } }; // Without helpers.inspect console.log(`foo is ${foo} and bar is ${bar}`); // => foo is xyz and bar is [object Object] // With helpers.inspect console.log( helpers.inspect`foo is ${foo} and bar is ${bar}` ); // => foo is 'xyz' and bar is { a: { b: { c: 'def' } } } // With options console.log( helpers.inspect({ depth: 0 })`foo is ${foo} and bar is ${bar}` ); // => foo is 'xyz' and bar is { a: [Object] } @param {string[]|Object} stringsOrOpts @param {...*} values @return {string}
[ "helpers", ".", "inspect" ]
cf4ffdc63837280080b67f496d038d33a3975b6f
https://github.com/Banno/polymer-lint/blob/cf4ffdc63837280080b67f496d038d33a3975b6f/spec/support/helpers/inspect.js#L54-L59
36,722
Banno/polymer-lint
spec/lib/util/filterErrorsSpec.js
noisyRule
function noisyRule(context, parser, onError) { parser.on('startTag', (name, attrs, selfClosing, location) => { onError({ rule: name, message: getAttribute(attrs, 'message') || '', location, }); }); }
javascript
function noisyRule(context, parser, onError) { parser.on('startTag', (name, attrs, selfClosing, location) => { onError({ rule: name, message: getAttribute(attrs, 'message') || '', location, }); }); }
[ "function", "noisyRule", "(", "context", ",", "parser", ",", "onError", ")", "{", "parser", ".", "on", "(", "'startTag'", ",", "(", "name", ",", "attrs", ",", "selfClosing", ",", "location", ")", "=>", "{", "onError", "(", "{", "rule", ":", "name", ",", "message", ":", "getAttribute", "(", "attrs", ",", "'message'", ")", "||", "''", ",", "location", ",", "}", ")", ";", "}", ")", ";", "}" ]
This is a rule that reports an error for every startTag, with the ruleName equal to the startTag's name.
[ "This", "is", "a", "rule", "that", "reports", "an", "error", "for", "every", "startTag", "with", "the", "ruleName", "equal", "to", "the", "startTag", "s", "name", "." ]
cf4ffdc63837280080b67f496d038d33a3975b6f
https://github.com/Banno/polymer-lint/blob/cf4ffdc63837280080b67f496d038d33a3975b6f/spec/lib/util/filterErrorsSpec.js#L9-L17
36,723
Banno/polymer-lint
lib/CLI.js
execute
function execute(argv) { const opts = Options.parse(argv); if (opts.version) { /* eslint-disable global-require */ console.log(`v${ require('../package.json').version }`); return Promise.resolve(0); } if (opts.help || !opts._.length) { console.log(Options.generateHelp()); return Promise.resolve(0); } return lint(resolvePatterns(opts), opts); }
javascript
function execute(argv) { const opts = Options.parse(argv); if (opts.version) { /* eslint-disable global-require */ console.log(`v${ require('../package.json').version }`); return Promise.resolve(0); } if (opts.help || !opts._.length) { console.log(Options.generateHelp()); return Promise.resolve(0); } return lint(resolvePatterns(opts), opts); }
[ "function", "execute", "(", "argv", ")", "{", "const", "opts", "=", "Options", ".", "parse", "(", "argv", ")", ";", "if", "(", "opts", ".", "version", ")", "{", "/* eslint-disable global-require */", "console", ".", "log", "(", "`", "${", "require", "(", "'../package.json'", ")", ".", "version", "}", "`", ")", ";", "return", "Promise", ".", "resolve", "(", "0", ")", ";", "}", "if", "(", "opts", ".", "help", "||", "!", "opts", ".", "_", ".", "length", ")", "{", "console", ".", "log", "(", "Options", ".", "generateHelp", "(", ")", ")", ";", "return", "Promise", ".", "resolve", "(", "0", ")", ";", "}", "return", "lint", "(", "resolvePatterns", "(", "opts", ")", ",", "opts", ")", ";", "}" ]
Parse the command line arguments and run the linter @memberof module:lib/CLI @param {string[]} argv - Command line arguments @return {number|Promise<number>} A Promise that resolves with a numeric exit code
[ "Parse", "the", "command", "line", "arguments", "and", "run", "the", "linter" ]
cf4ffdc63837280080b67f496d038d33a3975b6f
https://github.com/Banno/polymer-lint/blob/cf4ffdc63837280080b67f496d038d33a3975b6f/lib/CLI.js#L30-L45
36,724
misoproject/storyboard
dist/miso.storyboard.deps.0.1.0.js
compareAscending
function compareAscending(a, b) { var ai = a.index, bi = b.index; a = a.criteria; b = b.criteria; // ensure a stable sort in V8 and other engines // http://code.google.com/p/v8/issues/detail?id=90 if (a !== b) { if (a > b || typeof a == 'undefined') { return 1; } if (a < b || typeof b == 'undefined') { return -1; } } return ai < bi ? -1 : 1; }
javascript
function compareAscending(a, b) { var ai = a.index, bi = b.index; a = a.criteria; b = b.criteria; // ensure a stable sort in V8 and other engines // http://code.google.com/p/v8/issues/detail?id=90 if (a !== b) { if (a > b || typeof a == 'undefined') { return 1; } if (a < b || typeof b == 'undefined') { return -1; } } return ai < bi ? -1 : 1; }
[ "function", "compareAscending", "(", "a", ",", "b", ")", "{", "var", "ai", "=", "a", ".", "index", ",", "bi", "=", "b", ".", "index", ";", "a", "=", "a", ".", "criteria", ";", "b", "=", "b", ".", "criteria", ";", "// ensure a stable sort in V8 and other engines", "// http://code.google.com/p/v8/issues/detail?id=90", "if", "(", "a", "!==", "b", ")", "{", "if", "(", "a", ">", "b", "||", "typeof", "a", "==", "'undefined'", ")", "{", "return", "1", ";", "}", "if", "(", "a", "<", "b", "||", "typeof", "b", "==", "'undefined'", ")", "{", "return", "-", "1", ";", "}", "}", "return", "ai", "<", "bi", "?", "-", "1", ":", "1", ";", "}" ]
Used by `sortBy` to compare transformed `collection` values, stable sorting them in ascending order. @private @param {Object} a The object to compare to `b`. @param {Object} b The object to compare to `a`. @returns {Number} Returns the sort order indicator of `1` or `-1`.
[ "Used", "by", "sortBy", "to", "compare", "transformed", "collection", "values", "stable", "sorting", "them", "in", "ascending", "order", "." ]
96d6cdfe756e0e4f2df7c9a55c414fe93a4c38ec
https://github.com/misoproject/storyboard/blob/96d6cdfe756e0e4f2df7c9a55c414fe93a4c38ec/dist/miso.storyboard.deps.0.1.0.js#L423-L441
36,725
misoproject/storyboard
dist/miso.storyboard.deps.0.1.0.js
createBound
function createBound(func, thisArg, partialArgs, indicator) { var isFunc = isFunction(func), isPartial = !partialArgs, key = thisArg; // juggle arguments if (isPartial) { var rightIndicator = indicator; partialArgs = thisArg; } else if (!isFunc) { if (!indicator) { throw new TypeError; } thisArg = func; } function bound() { // `Function#bind` spec // http://es5.github.com/#x15.3.4.5 var args = arguments, thisBinding = isPartial ? this : thisArg; if (!isFunc) { func = thisArg[key]; } if (partialArgs.length) { args = args.length ? (args = nativeSlice.call(args), rightIndicator ? args.concat(partialArgs) : partialArgs.concat(args)) : partialArgs; } if (this instanceof bound) { // ensure `new bound` is an instance of `func` noop.prototype = func.prototype; thisBinding = new noop; noop.prototype = null; // mimic the constructor's `return` behavior // http://es5.github.com/#x13.2.2 var result = func.apply(thisBinding, args); return isObject(result) ? result : thisBinding; } return func.apply(thisBinding, args); } return bound; }
javascript
function createBound(func, thisArg, partialArgs, indicator) { var isFunc = isFunction(func), isPartial = !partialArgs, key = thisArg; // juggle arguments if (isPartial) { var rightIndicator = indicator; partialArgs = thisArg; } else if (!isFunc) { if (!indicator) { throw new TypeError; } thisArg = func; } function bound() { // `Function#bind` spec // http://es5.github.com/#x15.3.4.5 var args = arguments, thisBinding = isPartial ? this : thisArg; if (!isFunc) { func = thisArg[key]; } if (partialArgs.length) { args = args.length ? (args = nativeSlice.call(args), rightIndicator ? args.concat(partialArgs) : partialArgs.concat(args)) : partialArgs; } if (this instanceof bound) { // ensure `new bound` is an instance of `func` noop.prototype = func.prototype; thisBinding = new noop; noop.prototype = null; // mimic the constructor's `return` behavior // http://es5.github.com/#x13.2.2 var result = func.apply(thisBinding, args); return isObject(result) ? result : thisBinding; } return func.apply(thisBinding, args); } return bound; }
[ "function", "createBound", "(", "func", ",", "thisArg", ",", "partialArgs", ",", "indicator", ")", "{", "var", "isFunc", "=", "isFunction", "(", "func", ")", ",", "isPartial", "=", "!", "partialArgs", ",", "key", "=", "thisArg", ";", "// juggle arguments", "if", "(", "isPartial", ")", "{", "var", "rightIndicator", "=", "indicator", ";", "partialArgs", "=", "thisArg", ";", "}", "else", "if", "(", "!", "isFunc", ")", "{", "if", "(", "!", "indicator", ")", "{", "throw", "new", "TypeError", ";", "}", "thisArg", "=", "func", ";", "}", "function", "bound", "(", ")", "{", "// `Function#bind` spec", "// http://es5.github.com/#x15.3.4.5", "var", "args", "=", "arguments", ",", "thisBinding", "=", "isPartial", "?", "this", ":", "thisArg", ";", "if", "(", "!", "isFunc", ")", "{", "func", "=", "thisArg", "[", "key", "]", ";", "}", "if", "(", "partialArgs", ".", "length", ")", "{", "args", "=", "args", ".", "length", "?", "(", "args", "=", "nativeSlice", ".", "call", "(", "args", ")", ",", "rightIndicator", "?", "args", ".", "concat", "(", "partialArgs", ")", ":", "partialArgs", ".", "concat", "(", "args", ")", ")", ":", "partialArgs", ";", "}", "if", "(", "this", "instanceof", "bound", ")", "{", "// ensure `new bound` is an instance of `func`", "noop", ".", "prototype", "=", "func", ".", "prototype", ";", "thisBinding", "=", "new", "noop", ";", "noop", ".", "prototype", "=", "null", ";", "// mimic the constructor's `return` behavior", "// http://es5.github.com/#x13.2.2", "var", "result", "=", "func", ".", "apply", "(", "thisBinding", ",", "args", ")", ";", "return", "isObject", "(", "result", ")", "?", "result", ":", "thisBinding", ";", "}", "return", "func", ".", "apply", "(", "thisBinding", ",", "args", ")", ";", "}", "return", "bound", ";", "}" ]
Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any `partialArgs` to the arguments passed to the bound function. @private @param {Function|String} func The function to bind or the method name. @param {Mixed} [thisArg] The `this` binding of `func`. @param {Array} partialArgs An array of arguments to be partially applied. @param {Object} [idicator] Used to indicate binding by key or partially applying arguments from the right. @returns {Function} Returns the new bound function.
[ "Creates", "a", "function", "that", "when", "called", "invokes", "func", "with", "the", "this", "binding", "of", "thisArg", "and", "prepends", "any", "partialArgs", "to", "the", "arguments", "passed", "to", "the", "bound", "function", "." ]
96d6cdfe756e0e4f2df7c9a55c414fe93a4c38ec
https://github.com/misoproject/storyboard/blob/96d6cdfe756e0e4f2df7c9a55c414fe93a4c38ec/dist/miso.storyboard.deps.0.1.0.js#L456-L501
36,726
misoproject/storyboard
dist/miso.storyboard.deps.0.1.0.js
findKey
function findKey(object, callback, thisArg) { var result; callback = lodash.createCallback(callback, thisArg); forOwn(object, function(value, key, object) { if (callback(value, key, object)) { result = key; return false; } }); return result; }
javascript
function findKey(object, callback, thisArg) { var result; callback = lodash.createCallback(callback, thisArg); forOwn(object, function(value, key, object) { if (callback(value, key, object)) { result = key; return false; } }); return result; }
[ "function", "findKey", "(", "object", ",", "callback", ",", "thisArg", ")", "{", "var", "result", ";", "callback", "=", "lodash", ".", "createCallback", "(", "callback", ",", "thisArg", ")", ";", "forOwn", "(", "object", ",", "function", "(", "value", ",", "key", ",", "object", ")", "{", "if", "(", "callback", "(", "value", ",", "key", ",", "object", ")", ")", "{", "result", "=", "key", ";", "return", "false", ";", "}", "}", ")", ";", "return", "result", ";", "}" ]
This method is similar to `_.find`, except that it returns the key of the element that passes the callback check, instead of the element itself. @static @memberOf _ @category Objects @param {Object} object The object to search. @param {Function|Object|String} [callback=identity] The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. @param {Mixed} [thisArg] The `this` binding of `callback`. @returns {Mixed} Returns the key of the found element, else `undefined`. @example _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { return num % 2 == 0; }); // => 'b'
[ "This", "method", "is", "similar", "to", "_", ".", "find", "except", "that", "it", "returns", "the", "key", "of", "the", "element", "that", "passes", "the", "callback", "check", "instead", "of", "the", "element", "itself", "." ]
96d6cdfe756e0e4f2df7c9a55c414fe93a4c38ec
https://github.com/misoproject/storyboard/blob/96d6cdfe756e0e4f2df7c9a55c414fe93a4c38ec/dist/miso.storyboard.deps.0.1.0.js#L1027-L1037
36,727
misoproject/storyboard
dist/miso.storyboard.deps.0.1.0.js
reduceRight
function reduceRight(collection, callback, accumulator, thisArg) { var iterable = collection, length = collection ? collection.length : 0, noaccum = arguments.length < 3; if (typeof length != 'number') { var props = keys(collection); length = props.length; } callback = lodash.createCallback(callback, thisArg, 4); forEach(collection, function(value, index, collection) { index = props ? props[--length] : --length; accumulator = noaccum ? (noaccum = false, iterable[index]) : callback(accumulator, iterable[index], index, collection); }); return accumulator; }
javascript
function reduceRight(collection, callback, accumulator, thisArg) { var iterable = collection, length = collection ? collection.length : 0, noaccum = arguments.length < 3; if (typeof length != 'number') { var props = keys(collection); length = props.length; } callback = lodash.createCallback(callback, thisArg, 4); forEach(collection, function(value, index, collection) { index = props ? props[--length] : --length; accumulator = noaccum ? (noaccum = false, iterable[index]) : callback(accumulator, iterable[index], index, collection); }); return accumulator; }
[ "function", "reduceRight", "(", "collection", ",", "callback", ",", "accumulator", ",", "thisArg", ")", "{", "var", "iterable", "=", "collection", ",", "length", "=", "collection", "?", "collection", ".", "length", ":", "0", ",", "noaccum", "=", "arguments", ".", "length", "<", "3", ";", "if", "(", "typeof", "length", "!=", "'number'", ")", "{", "var", "props", "=", "keys", "(", "collection", ")", ";", "length", "=", "props", ".", "length", ";", "}", "callback", "=", "lodash", ".", "createCallback", "(", "callback", ",", "thisArg", ",", "4", ")", ";", "forEach", "(", "collection", ",", "function", "(", "value", ",", "index", ",", "collection", ")", "{", "index", "=", "props", "?", "props", "[", "--", "length", "]", ":", "--", "length", ";", "accumulator", "=", "noaccum", "?", "(", "noaccum", "=", "false", ",", "iterable", "[", "index", "]", ")", ":", "callback", "(", "accumulator", ",", "iterable", "[", "index", "]", ",", "index", ",", "collection", ")", ";", "}", ")", ";", "return", "accumulator", ";", "}" ]
This method is similar to `_.reduce`, except that it iterates over a `collection` from right to left. @static @memberOf _ @alias foldr @category Collections @param {Array|Object|String} collection The collection to iterate over. @param {Function} [callback=identity] The function called per iteration. @param {Mixed} [accumulator] Initial value of the accumulator. @param {Mixed} [thisArg] The `this` binding of `callback`. @returns {Mixed} Returns the accumulated value. @example var list = [[0, 1], [2, 3], [4, 5]]; var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); // => [4, 5, 2, 3, 0, 1]
[ "This", "method", "is", "similar", "to", "_", ".", "reduce", "except", "that", "it", "iterates", "over", "a", "collection", "from", "right", "to", "left", "." ]
96d6cdfe756e0e4f2df7c9a55c414fe93a4c38ec
https://github.com/misoproject/storyboard/blob/96d6cdfe756e0e4f2df7c9a55c414fe93a4c38ec/dist/miso.storyboard.deps.0.1.0.js#L2731-L2748
36,728
misoproject/storyboard
dist/miso.storyboard.deps.0.1.0.js
findIndex
function findIndex(array, callback, thisArg) { var index = -1, length = array ? array.length : 0; callback = lodash.createCallback(callback, thisArg); while (++index < length) { if (callback(array[index], index, array)) { return index; } } return -1; }
javascript
function findIndex(array, callback, thisArg) { var index = -1, length = array ? array.length : 0; callback = lodash.createCallback(callback, thisArg); while (++index < length) { if (callback(array[index], index, array)) { return index; } } return -1; }
[ "function", "findIndex", "(", "array", ",", "callback", ",", "thisArg", ")", "{", "var", "index", "=", "-", "1", ",", "length", "=", "array", "?", "array", ".", "length", ":", "0", ";", "callback", "=", "lodash", ".", "createCallback", "(", "callback", ",", "thisArg", ")", ";", "while", "(", "++", "index", "<", "length", ")", "{", "if", "(", "callback", "(", "array", "[", "index", "]", ",", "index", ",", "array", ")", ")", "{", "return", "index", ";", "}", "}", "return", "-", "1", ";", "}" ]
This method is similar to `_.find`, except that it returns the index of the element that passes the callback check, instead of the element itself. @static @memberOf _ @category Arrays @param {Array} array The array to search. @param {Function|Object|String} [callback=identity] The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. @param {Mixed} [thisArg] The `this` binding of `callback`. @returns {Mixed} Returns the index of the found element, else `-1`. @example _.findIndex(['apple', 'banana', 'beet'], function(food) { return /^b/.test(food); }); // => 1
[ "This", "method", "is", "similar", "to", "_", ".", "find", "except", "that", "it", "returns", "the", "index", "of", "the", "element", "that", "passes", "the", "callback", "check", "instead", "of", "the", "element", "itself", "." ]
96d6cdfe756e0e4f2df7c9a55c414fe93a4c38ec
https://github.com/misoproject/storyboard/blob/96d6cdfe756e0e4f2df7c9a55c414fe93a4c38ec/dist/miso.storyboard.deps.0.1.0.js#L3095-L3106
36,729
misoproject/storyboard
dist/miso.storyboard.deps.0.1.0.js
unzip
function unzip(array) { var index = -1, length = array ? array.length : 0, tupleLength = length ? max(pluck(array, 'length')) : 0, result = Array(tupleLength); while (++index < length) { var tupleIndex = -1, tuple = array[index]; while (++tupleIndex < tupleLength) { (result[tupleIndex] || (result[tupleIndex] = Array(length)))[index] = tuple[tupleIndex]; } } return result; }
javascript
function unzip(array) { var index = -1, length = array ? array.length : 0, tupleLength = length ? max(pluck(array, 'length')) : 0, result = Array(tupleLength); while (++index < length) { var tupleIndex = -1, tuple = array[index]; while (++tupleIndex < tupleLength) { (result[tupleIndex] || (result[tupleIndex] = Array(length)))[index] = tuple[tupleIndex]; } } return result; }
[ "function", "unzip", "(", "array", ")", "{", "var", "index", "=", "-", "1", ",", "length", "=", "array", "?", "array", ".", "length", ":", "0", ",", "tupleLength", "=", "length", "?", "max", "(", "pluck", "(", "array", ",", "'length'", ")", ")", ":", "0", ",", "result", "=", "Array", "(", "tupleLength", ")", ";", "while", "(", "++", "index", "<", "length", ")", "{", "var", "tupleIndex", "=", "-", "1", ",", "tuple", "=", "array", "[", "index", "]", ";", "while", "(", "++", "tupleIndex", "<", "tupleLength", ")", "{", "(", "result", "[", "tupleIndex", "]", "||", "(", "result", "[", "tupleIndex", "]", "=", "Array", "(", "length", ")", ")", ")", "[", "index", "]", "=", "tuple", "[", "tupleIndex", "]", ";", "}", "}", "return", "result", ";", "}" ]
The inverse of `_.zip`, this method splits groups of elements into arrays composed of elements from each group at their corresponding indexes. @static @memberOf _ @category Arrays @param {Array} array The array to process. @returns {Array} Returns a new array of the composed arrays. @example _.unzip([['moe', 30, true], ['larry', 40, false]]); // => [['moe', 'larry'], [30, 40], [true, false]];
[ "The", "inverse", "of", "_", ".", "zip", "this", "method", "splits", "groups", "of", "elements", "into", "arrays", "composed", "of", "elements", "from", "each", "group", "at", "their", "corresponding", "indexes", "." ]
96d6cdfe756e0e4f2df7c9a55c414fe93a4c38ec
https://github.com/misoproject/storyboard/blob/96d6cdfe756e0e4f2df7c9a55c414fe93a4c38ec/dist/miso.storyboard.deps.0.1.0.js#L3845-L3860
36,730
misoproject/storyboard
dist/miso.storyboard.deps.0.1.0.js
bind
function bind(func, thisArg) { // use `Function#bind` if it exists and is fast // (in V8 `Function#bind` is slower except when partially applied) return support.fastBind || (nativeBind && arguments.length > 2) ? nativeBind.call.apply(nativeBind, arguments) : createBound(func, thisArg, nativeSlice.call(arguments, 2)); }
javascript
function bind(func, thisArg) { // use `Function#bind` if it exists and is fast // (in V8 `Function#bind` is slower except when partially applied) return support.fastBind || (nativeBind && arguments.length > 2) ? nativeBind.call.apply(nativeBind, arguments) : createBound(func, thisArg, nativeSlice.call(arguments, 2)); }
[ "function", "bind", "(", "func", ",", "thisArg", ")", "{", "// use `Function#bind` if it exists and is fast", "// (in V8 `Function#bind` is slower except when partially applied)", "return", "support", ".", "fastBind", "||", "(", "nativeBind", "&&", "arguments", ".", "length", ">", "2", ")", "?", "nativeBind", ".", "call", ".", "apply", "(", "nativeBind", ",", "arguments", ")", ":", "createBound", "(", "func", ",", "thisArg", ",", "nativeSlice", ".", "call", "(", "arguments", ",", "2", ")", ")", ";", "}" ]
Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. @static @memberOf _ @category Functions @param {Function} func The function to bind. @param {Mixed} [thisArg] The `this` binding of `func`. @param {Mixed} [arg1, arg2, ...] Arguments to be partially applied. @returns {Function} Returns the new bound function. @example var func = function(greeting) { return greeting + ' ' + this.name; }; func = _.bind(func, { 'name': 'moe' }, 'hi'); func(); // => 'hi moe'
[ "Creates", "a", "function", "that", "when", "called", "invokes", "func", "with", "the", "this", "binding", "of", "thisArg", "and", "prepends", "any", "additional", "bind", "arguments", "to", "those", "passed", "to", "the", "bound", "function", "." ]
96d6cdfe756e0e4f2df7c9a55c414fe93a4c38ec
https://github.com/misoproject/storyboard/blob/96d6cdfe756e0e4f2df7c9a55c414fe93a4c38ec/dist/miso.storyboard.deps.0.1.0.js#L3999-L4005
36,731
misoproject/storyboard
dist/miso.storyboard.deps.0.1.0.js
bindAll
function bindAll(object) { var funcs = arguments.length > 1 ? concat.apply(arrayRef, nativeSlice.call(arguments, 1)) : functions(object), index = -1, length = funcs.length; while (++index < length) { var key = funcs[index]; object[key] = bind(object[key], object); } return object; }
javascript
function bindAll(object) { var funcs = arguments.length > 1 ? concat.apply(arrayRef, nativeSlice.call(arguments, 1)) : functions(object), index = -1, length = funcs.length; while (++index < length) { var key = funcs[index]; object[key] = bind(object[key], object); } return object; }
[ "function", "bindAll", "(", "object", ")", "{", "var", "funcs", "=", "arguments", ".", "length", ">", "1", "?", "concat", ".", "apply", "(", "arrayRef", ",", "nativeSlice", ".", "call", "(", "arguments", ",", "1", ")", ")", ":", "functions", "(", "object", ")", ",", "index", "=", "-", "1", ",", "length", "=", "funcs", ".", "length", ";", "while", "(", "++", "index", "<", "length", ")", "{", "var", "key", "=", "funcs", "[", "index", "]", ";", "object", "[", "key", "]", "=", "bind", "(", "object", "[", "key", "]", ",", "object", ")", ";", "}", "return", "object", ";", "}" ]
Binds methods on `object` to `object`, overwriting the existing method. Method names may be specified as individual arguments or as arrays of method names. If no method names are provided, all the function properties of `object` will be bound. @static @memberOf _ @category Functions @param {Object} object The object to bind and assign the bound methods to. @param {String} [methodName1, methodName2, ...] Method names on the object to bind. @returns {Object} Returns `object`. @example var view = { 'label': 'docs', 'onClick': function() { alert('clicked ' + this.label); } }; _.bindAll(view); jQuery('#docs').on('click', view.onClick); // => alerts 'clicked docs', when the button is clicked
[ "Binds", "methods", "on", "object", "to", "object", "overwriting", "the", "existing", "method", ".", "Method", "names", "may", "be", "specified", "as", "individual", "arguments", "or", "as", "arrays", "of", "method", "names", ".", "If", "no", "method", "names", "are", "provided", "all", "the", "function", "properties", "of", "object", "will", "be", "bound", "." ]
96d6cdfe756e0e4f2df7c9a55c414fe93a4c38ec
https://github.com/misoproject/storyboard/blob/96d6cdfe756e0e4f2df7c9a55c414fe93a4c38ec/dist/miso.storyboard.deps.0.1.0.js#L4030-L4040
36,732
misoproject/storyboard
dist/miso.storyboard.deps.0.1.0.js
defer
function defer(func) { var args = nativeSlice.call(arguments, 1); return setTimeout(function() { func.apply(undefined, args); }, 1); }
javascript
function defer(func) { var args = nativeSlice.call(arguments, 1); return setTimeout(function() { func.apply(undefined, args); }, 1); }
[ "function", "defer", "(", "func", ")", "{", "var", "args", "=", "nativeSlice", ".", "call", "(", "arguments", ",", "1", ")", ";", "return", "setTimeout", "(", "function", "(", ")", "{", "func", ".", "apply", "(", "undefined", ",", "args", ")", ";", "}", ",", "1", ")", ";", "}" ]
Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @static @memberOf _ @category Functions @param {Function} func The function to defer. @param {Mixed} [arg1, arg2, ...] Arguments to invoke the function with. @returns {Number} Returns the timer id. @example _.defer(function() { alert('deferred'); }); // returns from the function before `alert` is called
[ "Defers", "executing", "the", "func", "function", "until", "the", "current", "call", "stack", "has", "cleared", ".", "Additional", "arguments", "will", "be", "passed", "to", "func", "when", "it", "is", "invoked", "." ]
96d6cdfe756e0e4f2df7c9a55c414fe93a4c38ec
https://github.com/misoproject/storyboard/blob/96d6cdfe756e0e4f2df7c9a55c414fe93a4c38ec/dist/miso.storyboard.deps.0.1.0.js#L4285-L4288
36,733
misoproject/storyboard
dist/miso.storyboard.deps.0.1.0.js
memoize
function memoize(func, resolver) { var cache = {}; return function() { var key = keyPrefix + (resolver ? resolver.apply(this, arguments) : arguments[0]); return hasOwnProperty.call(cache, key) ? cache[key] : (cache[key] = func.apply(this, arguments)); }; }
javascript
function memoize(func, resolver) { var cache = {}; return function() { var key = keyPrefix + (resolver ? resolver.apply(this, arguments) : arguments[0]); return hasOwnProperty.call(cache, key) ? cache[key] : (cache[key] = func.apply(this, arguments)); }; }
[ "function", "memoize", "(", "func", ",", "resolver", ")", "{", "var", "cache", "=", "{", "}", ";", "return", "function", "(", ")", "{", "var", "key", "=", "keyPrefix", "+", "(", "resolver", "?", "resolver", ".", "apply", "(", "this", ",", "arguments", ")", ":", "arguments", "[", "0", "]", ")", ";", "return", "hasOwnProperty", ".", "call", "(", "cache", ",", "key", ")", "?", "cache", "[", "key", "]", ":", "(", "cache", "[", "key", "]", "=", "func", ".", "apply", "(", "this", ",", "arguments", ")", ")", ";", "}", ";", "}" ]
Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @static @memberOf _ @category Functions @param {Function} func The function to have its output memoized. @param {Function} [resolver] A function used to resolve the cache key. @returns {Function} Returns the new memoizing function. @example var fibonacci = _.memoize(function(n) { return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2); });
[ "Creates", "a", "function", "that", "memoizes", "the", "result", "of", "func", ".", "If", "resolver", "is", "passed", "it", "will", "be", "used", "to", "determine", "the", "cache", "key", "for", "storing", "the", "result", "based", "on", "the", "arguments", "passed", "to", "the", "memoized", "function", ".", "By", "default", "the", "first", "argument", "passed", "to", "the", "memoized", "function", "is", "used", "as", "the", "cache", "key", ".", "The", "func", "is", "executed", "with", "the", "this", "binding", "of", "the", "memoized", "function", "." ]
96d6cdfe756e0e4f2df7c9a55c414fe93a4c38ec
https://github.com/misoproject/storyboard/blob/96d6cdfe756e0e4f2df7c9a55c414fe93a4c38ec/dist/miso.storyboard.deps.0.1.0.js#L4335-L4343
36,734
misoproject/storyboard
dist/miso.storyboard.deps.0.1.0.js
wrap
function wrap(value, wrapper) { return function() { var args = [value]; push.apply(args, arguments); return wrapper.apply(this, args); }; }
javascript
function wrap(value, wrapper) { return function() { var args = [value]; push.apply(args, arguments); return wrapper.apply(this, args); }; }
[ "function", "wrap", "(", "value", ",", "wrapper", ")", "{", "return", "function", "(", ")", "{", "var", "args", "=", "[", "value", "]", ";", "push", ".", "apply", "(", "args", ",", "arguments", ")", ";", "return", "wrapper", ".", "apply", "(", "this", ",", "args", ")", ";", "}", ";", "}" ]
Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @static @memberOf _ @category Functions @param {Mixed} value The value to wrap. @param {Function} wrapper The wrapper function. @returns {Function} Returns the new function. @example var hello = function(name) { return 'hello ' + name; }; hello = _.wrap(hello, function(func) { return 'before, ' + func('moe') + ', after'; }); hello(); // => 'before, hello moe, after'
[ "Creates", "a", "function", "that", "passes", "value", "to", "the", "wrapper", "function", "as", "its", "first", "argument", ".", "Additional", "arguments", "passed", "to", "the", "function", "are", "appended", "to", "those", "passed", "to", "the", "wrapper", "function", ".", "The", "wrapper", "is", "executed", "with", "the", "this", "binding", "of", "the", "created", "function", "." ]
96d6cdfe756e0e4f2df7c9a55c414fe93a4c38ec
https://github.com/misoproject/storyboard/blob/96d6cdfe756e0e4f2df7c9a55c414fe93a4c38ec/dist/miso.storyboard.deps.0.1.0.js#L4526-L4532
36,735
misoproject/storyboard
dist/miso.storyboard.deps.0.1.0.js
function( obj ) { _each( slice.call( arguments, 1), function( source ) { var prop; for ( prop in source ) { if ( source[prop] !== void 0 ) { obj[ prop ] = source[ prop ]; } } }); return obj; }
javascript
function( obj ) { _each( slice.call( arguments, 1), function( source ) { var prop; for ( prop in source ) { if ( source[prop] !== void 0 ) { obj[ prop ] = source[ prop ]; } } }); return obj; }
[ "function", "(", "obj", ")", "{", "_each", "(", "slice", ".", "call", "(", "arguments", ",", "1", ")", ",", "function", "(", "source", ")", "{", "var", "prop", ";", "for", "(", "prop", "in", "source", ")", "{", "if", "(", "source", "[", "prop", "]", "!==", "void", "0", ")", "{", "obj", "[", "prop", "]", "=", "source", "[", "prop", "]", ";", "}", "}", "}", ")", ";", "return", "obj", ";", "}" ]
_.extend
[ "_", ".", "extend" ]
96d6cdfe756e0e4f2df7c9a55c414fe93a4c38ec
https://github.com/misoproject/storyboard/blob/96d6cdfe756e0e4f2df7c9a55c414fe93a4c38ec/dist/miso.storyboard.deps.0.1.0.js#L5318-L5330
36,736
sendanor/json-schema-orm
src/build.js
string_starts_with
function string_starts_with(str, what) { return (str.substr(0, what.length) === what) ? true : false; }
javascript
function string_starts_with(str, what) { return (str.substr(0, what.length) === what) ? true : false; }
[ "function", "string_starts_with", "(", "str", ",", "what", ")", "{", "return", "(", "str", ".", "substr", "(", "0", ",", "what", ".", "length", ")", "===", "what", ")", "?", "true", ":", "false", ";", "}" ]
Returns true if `str` starts with same string as `what`
[ "Returns", "true", "if", "str", "starts", "with", "same", "string", "as", "what" ]
c6d52b3cbefc904e89cab5ad3c4ecfa26aaf4ea6
https://github.com/sendanor/json-schema-orm/blob/c6d52b3cbefc904e89cab5ad3c4ecfa26aaf4ea6/src/build.js#L35-L37
36,737
sendanor/json-schema-orm
src/build.js
create_constructor
function create_constructor(type_name) { if(Object.prototype.hasOwnProperty.call(constructors, type_name)) { return constructors[type_name]; } if(!( Object.prototype.hasOwnProperty.call(_schema.definitions, type_name) && is.def(_schema.definitions[type_name]) )) { throw new TypeError("No definition for " + type_name); } var definition = _schema.definitions[type_name]; // ParentType is either SchemaObject or another definition var ParentType = SchemaObject; if( is.obj(definition) && is.def(definition.$ref) && string_starts_with(definition.$ref, '#/definitions/') ) { ParentType = create_constructor( definition.$ref.split('/').slice(2).join('/') ); } // FIXME: If a type has $refs, we should create a copy of schema which defines all those $refs. // Currently just copies schema and changes it to point our definition. Not ideal solution. var copy_definition = JSON.parse(JSON.stringify(_schema)); copy_definition.oneOf = [{"$ref": '#/definitions/'+type_name }]; /* This is our real constructor which will be called in `new Function()` */ function _constructor(self, opts) { var tmp; // Check opts validity var validity = SchemaObject.validate(opts, copy_definition); if(!validity.valid) { throw new TypeError("bad argument: " + util.inspect(validity) ); } // Call parent constructors ParentType.call(self, opts); // Call custom constructors //util.debug( util.inspect( _user_defined_constructors )); if(Object.prototype.hasOwnProperty.call(_user_defined_constructors, type_name)) { tmp = _user_defined_constructors[type_name].call(self, opts); if(is.def(tmp)) { SchemaObject.prototype._setValueOf.call(self, tmp); } //util.debug( util.inspect( tmp ) ); } // Setup getters and setters if schema has properties //util.debug( "\ndefinition = \n----\n" + util.inspect( definition ) + "\n----\n\n" ); if(definition && definition.properties) { Object.getOwnPropertyNames(definition.properties).forEach(function(key) { self.__defineGetter__(key, function(){ return self.valueOf()[key]; }); self.__defineSetter__(key, function(val){ // FIXME: Implement value validation and do not use `.valueOf()`! self.valueOf()[key] = val; }); }); } } var func_name = escape_func_name(type_name); // JavaScript does not support better way to change function names... var code = [ 'function '+func_name+' (opts) {', ' if(!(this instanceof '+func_name+')) {', ' return new '+func_name+'(opts);', ' };', ' _constructor.call(this, this, opts);', '};' ]; var Type = (new Function('_constructor', 'return '+code.join('\n')))(_constructor); util.inherits(Type, ParentType); /* Returns source code for type */ //Type.toSource = function() { // return '(new Function(\'' + [''+_constructor, ''+Type].join('\n') + '))();'; //}; constructors[type_name] = Type; // User-defined methods function post_user_defines(context) { if(Object.prototype.hasOwnProperty.call(_user_defined_methods, type_name)) { _user_defined_methods[type_name].call(context, Type, context); } } post_user_defines({'constructors':constructors, 'schema':_schema}); return constructors[type_name]; }
javascript
function create_constructor(type_name) { if(Object.prototype.hasOwnProperty.call(constructors, type_name)) { return constructors[type_name]; } if(!( Object.prototype.hasOwnProperty.call(_schema.definitions, type_name) && is.def(_schema.definitions[type_name]) )) { throw new TypeError("No definition for " + type_name); } var definition = _schema.definitions[type_name]; // ParentType is either SchemaObject or another definition var ParentType = SchemaObject; if( is.obj(definition) && is.def(definition.$ref) && string_starts_with(definition.$ref, '#/definitions/') ) { ParentType = create_constructor( definition.$ref.split('/').slice(2).join('/') ); } // FIXME: If a type has $refs, we should create a copy of schema which defines all those $refs. // Currently just copies schema and changes it to point our definition. Not ideal solution. var copy_definition = JSON.parse(JSON.stringify(_schema)); copy_definition.oneOf = [{"$ref": '#/definitions/'+type_name }]; /* This is our real constructor which will be called in `new Function()` */ function _constructor(self, opts) { var tmp; // Check opts validity var validity = SchemaObject.validate(opts, copy_definition); if(!validity.valid) { throw new TypeError("bad argument: " + util.inspect(validity) ); } // Call parent constructors ParentType.call(self, opts); // Call custom constructors //util.debug( util.inspect( _user_defined_constructors )); if(Object.prototype.hasOwnProperty.call(_user_defined_constructors, type_name)) { tmp = _user_defined_constructors[type_name].call(self, opts); if(is.def(tmp)) { SchemaObject.prototype._setValueOf.call(self, tmp); } //util.debug( util.inspect( tmp ) ); } // Setup getters and setters if schema has properties //util.debug( "\ndefinition = \n----\n" + util.inspect( definition ) + "\n----\n\n" ); if(definition && definition.properties) { Object.getOwnPropertyNames(definition.properties).forEach(function(key) { self.__defineGetter__(key, function(){ return self.valueOf()[key]; }); self.__defineSetter__(key, function(val){ // FIXME: Implement value validation and do not use `.valueOf()`! self.valueOf()[key] = val; }); }); } } var func_name = escape_func_name(type_name); // JavaScript does not support better way to change function names... var code = [ 'function '+func_name+' (opts) {', ' if(!(this instanceof '+func_name+')) {', ' return new '+func_name+'(opts);', ' };', ' _constructor.call(this, this, opts);', '};' ]; var Type = (new Function('_constructor', 'return '+code.join('\n')))(_constructor); util.inherits(Type, ParentType); /* Returns source code for type */ //Type.toSource = function() { // return '(new Function(\'' + [''+_constructor, ''+Type].join('\n') + '))();'; //}; constructors[type_name] = Type; // User-defined methods function post_user_defines(context) { if(Object.prototype.hasOwnProperty.call(_user_defined_methods, type_name)) { _user_defined_methods[type_name].call(context, Type, context); } } post_user_defines({'constructors':constructors, 'schema':_schema}); return constructors[type_name]; }
[ "function", "create_constructor", "(", "type_name", ")", "{", "if", "(", "Object", ".", "prototype", ".", "hasOwnProperty", ".", "call", "(", "constructors", ",", "type_name", ")", ")", "{", "return", "constructors", "[", "type_name", "]", ";", "}", "if", "(", "!", "(", "Object", ".", "prototype", ".", "hasOwnProperty", ".", "call", "(", "_schema", ".", "definitions", ",", "type_name", ")", "&&", "is", ".", "def", "(", "_schema", ".", "definitions", "[", "type_name", "]", ")", ")", ")", "{", "throw", "new", "TypeError", "(", "\"No definition for \"", "+", "type_name", ")", ";", "}", "var", "definition", "=", "_schema", ".", "definitions", "[", "type_name", "]", ";", "// ParentType is either SchemaObject or another definition", "var", "ParentType", "=", "SchemaObject", ";", "if", "(", "is", ".", "obj", "(", "definition", ")", "&&", "is", ".", "def", "(", "definition", ".", "$ref", ")", "&&", "string_starts_with", "(", "definition", ".", "$ref", ",", "'#/definitions/'", ")", ")", "{", "ParentType", "=", "create_constructor", "(", "definition", ".", "$ref", ".", "split", "(", "'/'", ")", ".", "slice", "(", "2", ")", ".", "join", "(", "'/'", ")", ")", ";", "}", "// FIXME: If a type has $refs, we should create a copy of schema which defines all those $refs.", "// Currently just copies schema and changes it to point our definition. Not ideal solution.", "var", "copy_definition", "=", "JSON", ".", "parse", "(", "JSON", ".", "stringify", "(", "_schema", ")", ")", ";", "copy_definition", ".", "oneOf", "=", "[", "{", "\"$ref\"", ":", "'#/definitions/'", "+", "type_name", "}", "]", ";", "/* This is our real constructor which will be called in `new Function()` */", "function", "_constructor", "(", "self", ",", "opts", ")", "{", "var", "tmp", ";", "// Check opts validity", "var", "validity", "=", "SchemaObject", ".", "validate", "(", "opts", ",", "copy_definition", ")", ";", "if", "(", "!", "validity", ".", "valid", ")", "{", "throw", "new", "TypeError", "(", "\"bad argument: \"", "+", "util", ".", "inspect", "(", "validity", ")", ")", ";", "}", "// Call parent constructors", "ParentType", ".", "call", "(", "self", ",", "opts", ")", ";", "// Call custom constructors", "//util.debug( util.inspect( _user_defined_constructors ));", "if", "(", "Object", ".", "prototype", ".", "hasOwnProperty", ".", "call", "(", "_user_defined_constructors", ",", "type_name", ")", ")", "{", "tmp", "=", "_user_defined_constructors", "[", "type_name", "]", ".", "call", "(", "self", ",", "opts", ")", ";", "if", "(", "is", ".", "def", "(", "tmp", ")", ")", "{", "SchemaObject", ".", "prototype", ".", "_setValueOf", ".", "call", "(", "self", ",", "tmp", ")", ";", "}", "//util.debug( util.inspect( tmp ) );", "}", "// Setup getters and setters if schema has properties", "//util.debug( \"\\ndefinition = \\n----\\n\" + util.inspect( definition ) + \"\\n----\\n\\n\" );", "if", "(", "definition", "&&", "definition", ".", "properties", ")", "{", "Object", ".", "getOwnPropertyNames", "(", "definition", ".", "properties", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "self", ".", "__defineGetter__", "(", "key", ",", "function", "(", ")", "{", "return", "self", ".", "valueOf", "(", ")", "[", "key", "]", ";", "}", ")", ";", "self", ".", "__defineSetter__", "(", "key", ",", "function", "(", "val", ")", "{", "// FIXME: Implement value validation and do not use `.valueOf()`!", "self", ".", "valueOf", "(", ")", "[", "key", "]", "=", "val", ";", "}", ")", ";", "}", ")", ";", "}", "}", "var", "func_name", "=", "escape_func_name", "(", "type_name", ")", ";", "// JavaScript does not support better way to change function names...", "var", "code", "=", "[", "'function '", "+", "func_name", "+", "' (opts) {'", ",", "'\tif(!(this instanceof '", "+", "func_name", "+", "')) {'", ",", "'\t\treturn new '", "+", "func_name", "+", "'(opts);'", ",", "'\t};'", ",", "'\t_constructor.call(this, this, opts);'", ",", "'};'", "]", ";", "var", "Type", "=", "(", "new", "Function", "(", "'_constructor'", ",", "'return '", "+", "code", ".", "join", "(", "'\\n'", ")", ")", ")", "(", "_constructor", ")", ";", "util", ".", "inherits", "(", "Type", ",", "ParentType", ")", ";", "/* Returns source code for type */", "//Type.toSource = function() {", "//\treturn '(new Function(\\'' + [''+_constructor, ''+Type].join('\\n') + '))();';", "//};", "constructors", "[", "type_name", "]", "=", "Type", ";", "// User-defined methods", "function", "post_user_defines", "(", "context", ")", "{", "if", "(", "Object", ".", "prototype", ".", "hasOwnProperty", ".", "call", "(", "_user_defined_methods", ",", "type_name", ")", ")", "{", "_user_defined_methods", "[", "type_name", "]", ".", "call", "(", "context", ",", "Type", ",", "context", ")", ";", "}", "}", "post_user_defines", "(", "{", "'constructors'", ":", "constructors", ",", "'schema'", ":", "_schema", "}", ")", ";", "return", "constructors", "[", "type_name", "]", ";", "}" ]
Creates a new constructor unless it's created already
[ "Creates", "a", "new", "constructor", "unless", "it", "s", "created", "already" ]
c6d52b3cbefc904e89cab5ad3c4ecfa26aaf4ea6
https://github.com/sendanor/json-schema-orm/blob/c6d52b3cbefc904e89cab5ad3c4ecfa26aaf4ea6/src/build.js#L40-L132
36,738
sendanor/json-schema-orm
src/build.js
post_user_defines
function post_user_defines(context) { if(Object.prototype.hasOwnProperty.call(_user_defined_methods, type_name)) { _user_defined_methods[type_name].call(context, Type, context); } }
javascript
function post_user_defines(context) { if(Object.prototype.hasOwnProperty.call(_user_defined_methods, type_name)) { _user_defined_methods[type_name].call(context, Type, context); } }
[ "function", "post_user_defines", "(", "context", ")", "{", "if", "(", "Object", ".", "prototype", ".", "hasOwnProperty", ".", "call", "(", "_user_defined_methods", ",", "type_name", ")", ")", "{", "_user_defined_methods", "[", "type_name", "]", ".", "call", "(", "context", ",", "Type", ",", "context", ")", ";", "}", "}" ]
User-defined methods
[ "User", "-", "defined", "methods" ]
c6d52b3cbefc904e89cab5ad3c4ecfa26aaf4ea6
https://github.com/sendanor/json-schema-orm/blob/c6d52b3cbefc904e89cab5ad3c4ecfa26aaf4ea6/src/build.js#L123-L127
36,739
cwrc/CWRC-PublicEntityDialogs
src/index.js
setEnabledSources
function setEnabledSources(config) { for (let source in config) { setSourceEnabled(source, config[source]); } haveSourcesBeenSelected = true; }
javascript
function setEnabledSources(config) { for (let source in config) { setSourceEnabled(source, config[source]); } haveSourcesBeenSelected = true; }
[ "function", "setEnabledSources", "(", "config", ")", "{", "for", "(", "let", "source", "in", "config", ")", "{", "setSourceEnabled", "(", "source", ",", "config", "[", "source", "]", ")", ";", "}", "haveSourcesBeenSelected", "=", "true", ";", "}" ]
expects an object whose keys are source names and whose values are boolean
[ "expects", "an", "object", "whose", "keys", "are", "source", "names", "and", "whose", "values", "are", "boolean" ]
4d828b8f184f8c86f5abbc92cc8e4909ee22b7b4
https://github.com/cwrc/CWRC-PublicEntityDialogs/blob/4d828b8f184f8c86f5abbc92cc8e4909ee22b7b4/src/index.js#L312-L317
36,740
sehrope/node-pg-spice
index.js
convertParamValues
function convertParamValues(parsedSql, values) { var ret = []; _.each(parsedSql.params, function(param) { if( !_.has(values, param.name) ) { throw new Error("No value found for parameter: " + param.name); } ret.push(values[param.name]); }); return ret; }
javascript
function convertParamValues(parsedSql, values) { var ret = []; _.each(parsedSql.params, function(param) { if( !_.has(values, param.name) ) { throw new Error("No value found for parameter: " + param.name); } ret.push(values[param.name]); }); return ret; }
[ "function", "convertParamValues", "(", "parsedSql", ",", "values", ")", "{", "var", "ret", "=", "[", "]", ";", "_", ".", "each", "(", "parsedSql", ".", "params", ",", "function", "(", "param", ")", "{", "if", "(", "!", "_", ".", "has", "(", "values", ",", "param", ".", "name", ")", ")", "{", "throw", "new", "Error", "(", "\"No value found for parameter: \"", "+", "param", ".", "name", ")", ";", "}", "ret", ".", "push", "(", "values", "[", "param", ".", "name", "]", ")", ";", "}", ")", ";", "return", "ret", ";", "}" ]
Converts parameter values from object to an array. Parameter value indexes come from the parsedSql object and a given parameter may appear in multiple positions.
[ "Converts", "parameter", "values", "from", "object", "to", "an", "array", ".", "Parameter", "value", "indexes", "come", "from", "the", "parsedSql", "object", "and", "a", "given", "parameter", "may", "appear", "in", "multiple", "positions", "." ]
943bac3aa0db5c4ac1aa5bc8abb0549950292a63
https://github.com/sehrope/node-pg-spice/blob/943bac3aa0db5c4ac1aa5bc8abb0549950292a63/index.js#L262-L271
36,741
openmason/cloudd
lib/dag.js
function(links) { this.dependencies = _buildDependencies(links); this.tasks = graph.tsort(this.dependencies).reverse(); this.index = 0; }
javascript
function(links) { this.dependencies = _buildDependencies(links); this.tasks = graph.tsort(this.dependencies).reverse(); this.index = 0; }
[ "function", "(", "links", ")", "{", "this", ".", "dependencies", "=", "_buildDependencies", "(", "links", ")", ";", "this", ".", "tasks", "=", "graph", ".", "tsort", "(", "this", ".", "dependencies", ")", ".", "reverse", "(", ")", ";", "this", ".", "index", "=", "0", ";", "}" ]
DAG - routines related to DAG go here
[ "DAG", "-", "routines", "related", "to", "DAG", "go", "here" ]
207bad115a0a4148f35e238fd1121a30b8f0bd5a
https://github.com/openmason/cloudd/blob/207bad115a0a4148f35e238fd1121a30b8f0bd5a/lib/dag.js#L12-L16
36,742
mozilla/grunt-l10n-lint
lib/check-translation.js
function (tagName, tagAttributes) { if (this._done) { return; } this._openElementStack.push(tagName); try { this._errorIfUnexpectedTag(tagName); for (var attributeName in tagAttributes) { var attributeValue = tagAttributes[attributeName]; this._errorIfUnexpectedAttribute(tagName, attributeName); this._errorIfUnexpectedAttributeValue(tagName, attributeName, attributeValue); } } catch (err) { this._finish(err); } }
javascript
function (tagName, tagAttributes) { if (this._done) { return; } this._openElementStack.push(tagName); try { this._errorIfUnexpectedTag(tagName); for (var attributeName in tagAttributes) { var attributeValue = tagAttributes[attributeName]; this._errorIfUnexpectedAttribute(tagName, attributeName); this._errorIfUnexpectedAttributeValue(tagName, attributeName, attributeValue); } } catch (err) { this._finish(err); } }
[ "function", "(", "tagName", ",", "tagAttributes", ")", "{", "if", "(", "this", ".", "_done", ")", "{", "return", ";", "}", "this", ".", "_openElementStack", ".", "push", "(", "tagName", ")", ";", "try", "{", "this", ".", "_errorIfUnexpectedTag", "(", "tagName", ")", ";", "for", "(", "var", "attributeName", "in", "tagAttributes", ")", "{", "var", "attributeValue", "=", "tagAttributes", "[", "attributeName", "]", ";", "this", ".", "_errorIfUnexpectedAttribute", "(", "tagName", ",", "attributeName", ")", ";", "this", ".", "_errorIfUnexpectedAttributeValue", "(", "tagName", ",", "attributeName", ",", "attributeValue", ")", ";", "}", "}", "catch", "(", "err", ")", "{", "this", ".", "_finish", "(", "err", ")", ";", "}", "}" ]
Check all tags, attributes, and attriute values against the allowed list in expectedTagsData.
[ "Check", "all", "tags", "attributes", "and", "attriute", "values", "against", "the", "allowed", "list", "in", "expectedTagsData", "." ]
287f5cd3b3a6af4fabc524ce4a6086ce8fd17a89
https://github.com/mozilla/grunt-l10n-lint/blob/287f5cd3b3a6af4fabc524ce4a6086ce8fd17a89/lib/check-translation.js#L212-L231
36,743
WorldMobileCoin/wmcc-core
src/utils/lru.js
LRUItem
function LRUItem(key, value) { this.key = key; this.value = value; this.next = null; this.prev = null; }
javascript
function LRUItem(key, value) { this.key = key; this.value = value; this.next = null; this.prev = null; }
[ "function", "LRUItem", "(", "key", ",", "value", ")", "{", "this", ".", "key", "=", "key", ";", "this", ".", "value", "=", "value", ";", "this", ".", "next", "=", "null", ";", "this", ".", "prev", "=", "null", ";", "}" ]
Represents an LRU item. @alias module:utils.LRUItem @constructor @private @param {String} key @param {Object} value
[ "Represents", "an", "LRU", "item", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/utils/lru.js#L424-L429
36,744
WorldMobileCoin/wmcc-core
src/script/scripterror.js
ScriptError
function ScriptError(code, op, ip) { if (!(this instanceof ScriptError)) return new ScriptError(code, op, ip); Error.call(this); this.type = 'ScriptError'; this.code = code; this.message = code; this.op = -1; this.ip = -1; if (typeof op === 'string') { this.message = op; } else if (op) { this.message = `${code} (op=${op.toSymbol()}, ip=${ip})`; this.op = op.value; this.ip = ip; } if (Error.captureStackTrace) Error.captureStackTrace(this, ScriptError); }
javascript
function ScriptError(code, op, ip) { if (!(this instanceof ScriptError)) return new ScriptError(code, op, ip); Error.call(this); this.type = 'ScriptError'; this.code = code; this.message = code; this.op = -1; this.ip = -1; if (typeof op === 'string') { this.message = op; } else if (op) { this.message = `${code} (op=${op.toSymbol()}, ip=${ip})`; this.op = op.value; this.ip = ip; } if (Error.captureStackTrace) Error.captureStackTrace(this, ScriptError); }
[ "function", "ScriptError", "(", "code", ",", "op", ",", "ip", ")", "{", "if", "(", "!", "(", "this", "instanceof", "ScriptError", ")", ")", "return", "new", "ScriptError", "(", "code", ",", "op", ",", "ip", ")", ";", "Error", ".", "call", "(", "this", ")", ";", "this", ".", "type", "=", "'ScriptError'", ";", "this", ".", "code", "=", "code", ";", "this", ".", "message", "=", "code", ";", "this", ".", "op", "=", "-", "1", ";", "this", ".", "ip", "=", "-", "1", ";", "if", "(", "typeof", "op", "===", "'string'", ")", "{", "this", ".", "message", "=", "op", ";", "}", "else", "if", "(", "op", ")", "{", "this", ".", "message", "=", "`", "${", "code", "}", "${", "op", ".", "toSymbol", "(", ")", "}", "${", "ip", "}", "`", ";", "this", ".", "op", "=", "op", ".", "value", ";", "this", ".", "ip", "=", "ip", ";", "}", "if", "(", "Error", ".", "captureStackTrace", ")", "Error", ".", "captureStackTrace", "(", "this", ",", "ScriptError", ")", ";", "}" ]
An error thrown from the scripting system, potentially pertaining to Script execution. @alias module:script.ScriptError @constructor @extends Error @param {String} code - Error code. @param {Opcode} op - Opcode. @param {Number?} ip - Instruction pointer. @property {String} message - Error message. @property {String} code - Original code passed in. @property {Number} op - Opcode. @property {Number} ip - Instruction pointer.
[ "An", "error", "thrown", "from", "the", "scripting", "system", "potentially", "pertaining", "to", "Script", "execution", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/script/scripterror.js#L28-L50
36,745
WorldMobileCoin/wmcc-core
src/protocol/network.js
Network
function Network(options) { if (!(this instanceof Network)) return new Network(options); assert(!Network[options.type], 'Cannot create two networks.'); this.type = options.type; this.seeds = options.seeds; this.magic = options.magic; this.port = options.port; this.checkpointMap = options.checkpointMap; this.lastCheckpoint = options.lastCheckpoint; this.checkpoints = []; this.halvingInterval = options.halvingInterval; this.genesis = options.genesis; this.genesisBlock = options.genesisBlock; this.pow = options.pow; this.block = options.block; this.bip30 = options.bip30; this.activationThreshold = options.activationThreshold; this.minerWindow = options.minerWindow; this.deployments = options.deployments; this.deploys = options.deploys; this.unknownBits = ~consensus.VERSION_TOP_MASK; this.keyPrefix = options.keyPrefix; this.addressPrefix = options.addressPrefix; this.requireStandard = options.requireStandard; this.rpcPort = options.rpcPort; this.minRelay = options.minRelay; this.feeRate = options.feeRate; this.maxFeeRate = options.maxFeeRate; this.selfConnect = options.selfConnect; this.requestMempool = options.requestMempool; this.time = new TimeData(); this._init(); }
javascript
function Network(options) { if (!(this instanceof Network)) return new Network(options); assert(!Network[options.type], 'Cannot create two networks.'); this.type = options.type; this.seeds = options.seeds; this.magic = options.magic; this.port = options.port; this.checkpointMap = options.checkpointMap; this.lastCheckpoint = options.lastCheckpoint; this.checkpoints = []; this.halvingInterval = options.halvingInterval; this.genesis = options.genesis; this.genesisBlock = options.genesisBlock; this.pow = options.pow; this.block = options.block; this.bip30 = options.bip30; this.activationThreshold = options.activationThreshold; this.minerWindow = options.minerWindow; this.deployments = options.deployments; this.deploys = options.deploys; this.unknownBits = ~consensus.VERSION_TOP_MASK; this.keyPrefix = options.keyPrefix; this.addressPrefix = options.addressPrefix; this.requireStandard = options.requireStandard; this.rpcPort = options.rpcPort; this.minRelay = options.minRelay; this.feeRate = options.feeRate; this.maxFeeRate = options.maxFeeRate; this.selfConnect = options.selfConnect; this.requestMempool = options.requestMempool; this.time = new TimeData(); this._init(); }
[ "function", "Network", "(", "options", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Network", ")", ")", "return", "new", "Network", "(", "options", ")", ";", "assert", "(", "!", "Network", "[", "options", ".", "type", "]", ",", "'Cannot create two networks.'", ")", ";", "this", ".", "type", "=", "options", ".", "type", ";", "this", ".", "seeds", "=", "options", ".", "seeds", ";", "this", ".", "magic", "=", "options", ".", "magic", ";", "this", ".", "port", "=", "options", ".", "port", ";", "this", ".", "checkpointMap", "=", "options", ".", "checkpointMap", ";", "this", ".", "lastCheckpoint", "=", "options", ".", "lastCheckpoint", ";", "this", ".", "checkpoints", "=", "[", "]", ";", "this", ".", "halvingInterval", "=", "options", ".", "halvingInterval", ";", "this", ".", "genesis", "=", "options", ".", "genesis", ";", "this", ".", "genesisBlock", "=", "options", ".", "genesisBlock", ";", "this", ".", "pow", "=", "options", ".", "pow", ";", "this", ".", "block", "=", "options", ".", "block", ";", "this", ".", "bip30", "=", "options", ".", "bip30", ";", "this", ".", "activationThreshold", "=", "options", ".", "activationThreshold", ";", "this", ".", "minerWindow", "=", "options", ".", "minerWindow", ";", "this", ".", "deployments", "=", "options", ".", "deployments", ";", "this", ".", "deploys", "=", "options", ".", "deploys", ";", "this", ".", "unknownBits", "=", "~", "consensus", ".", "VERSION_TOP_MASK", ";", "this", ".", "keyPrefix", "=", "options", ".", "keyPrefix", ";", "this", ".", "addressPrefix", "=", "options", ".", "addressPrefix", ";", "this", ".", "requireStandard", "=", "options", ".", "requireStandard", ";", "this", ".", "rpcPort", "=", "options", ".", "rpcPort", ";", "this", ".", "minRelay", "=", "options", ".", "minRelay", ";", "this", ".", "feeRate", "=", "options", ".", "feeRate", ";", "this", ".", "maxFeeRate", "=", "options", ".", "maxFeeRate", ";", "this", ".", "selfConnect", "=", "options", ".", "selfConnect", ";", "this", ".", "requestMempool", "=", "options", ".", "requestMempool", ";", "this", ".", "time", "=", "new", "TimeData", "(", ")", ";", "this", ".", "_init", "(", ")", ";", "}" ]
Represents a network. @alias module:protocol.Network @constructor @param {Object|NetworkType} options - See {@link module:network}.
[ "Represents", "a", "network", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/protocol/network.js#L27-L63
36,746
lukebond/json-override
json-override.js
overwriteKeys
function overwriteKeys(baseObject, overrideObject, createNew) { if (!baseObject) { baseObject = {}; } if (createNew) { baseObject = JSON.parse(JSON.stringify(baseObject)); } Object.keys(overrideObject).forEach(function(key) { if (isObjectAndNotArray(baseObject[key]) && isObjectAndNotArray(overrideObject[key])) { overwriteKeys(baseObject[key], overrideObject[key]); } else { baseObject[key] = overrideObject[key]; } }); return baseObject; }
javascript
function overwriteKeys(baseObject, overrideObject, createNew) { if (!baseObject) { baseObject = {}; } if (createNew) { baseObject = JSON.parse(JSON.stringify(baseObject)); } Object.keys(overrideObject).forEach(function(key) { if (isObjectAndNotArray(baseObject[key]) && isObjectAndNotArray(overrideObject[key])) { overwriteKeys(baseObject[key], overrideObject[key]); } else { baseObject[key] = overrideObject[key]; } }); return baseObject; }
[ "function", "overwriteKeys", "(", "baseObject", ",", "overrideObject", ",", "createNew", ")", "{", "if", "(", "!", "baseObject", ")", "{", "baseObject", "=", "{", "}", ";", "}", "if", "(", "createNew", ")", "{", "baseObject", "=", "JSON", ".", "parse", "(", "JSON", ".", "stringify", "(", "baseObject", ")", ")", ";", "}", "Object", ".", "keys", "(", "overrideObject", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "if", "(", "isObjectAndNotArray", "(", "baseObject", "[", "key", "]", ")", "&&", "isObjectAndNotArray", "(", "overrideObject", "[", "key", "]", ")", ")", "{", "overwriteKeys", "(", "baseObject", "[", "key", "]", ",", "overrideObject", "[", "key", "]", ")", ";", "}", "else", "{", "baseObject", "[", "key", "]", "=", "overrideObject", "[", "key", "]", ";", "}", "}", ")", ";", "return", "baseObject", ";", "}" ]
'createNew' defaults to false
[ "createNew", "defaults", "to", "false" ]
2a3403765de6350a231e7ec41788f71008ca8a17
https://github.com/lukebond/json-override/blob/2a3403765de6350a231e7ec41788f71008ca8a17/json-override.js#L6-L22
36,747
gsdriver/blackjack-strategy
src/Suggestion.js
ShouldPlayerStand
function ShouldPlayerStand(playerCards, dealerCard, handValue, handCount, options) { var shouldStand = false; if (handValue.soft) { // Don't stand until you hit 18 if (handValue.total > 18) { shouldStand = true; } else if (handValue.total == 18) { // Stand against dealer 2-8, and against a dealer Ace in single deck if they dealer will stand on soft 17 shouldStand = ((dealerCard >= 2) && (dealerCard <= 8)) || ((dealerCard == 1) && (options.numberOfDecks == 1) && !options.hitSoft17); } } else { // Stand on 17 or above if (handValue.total > 16) { shouldStand = true; } else if (handValue.total > 12) { // 13-16 you should stand against dealer 2-6 shouldStand = (dealerCard >= 2) && (dealerCard <= 6); } else if (handValue.total == 12) { // Stand on dealer 4-6 shouldStand = (dealerCard >= 4) && (dealerCard <= 6); } // Advanced option - in single deck a pair of 7s should stand against a dealer 10 if ((options.strategyComplexity != "simple") && (handValue.total == 14) && (playerCards[0] == 7) && (dealerCard == 10) && (options.numberOfDecks == 1)) { shouldStand = true; } } return shouldStand; }
javascript
function ShouldPlayerStand(playerCards, dealerCard, handValue, handCount, options) { var shouldStand = false; if (handValue.soft) { // Don't stand until you hit 18 if (handValue.total > 18) { shouldStand = true; } else if (handValue.total == 18) { // Stand against dealer 2-8, and against a dealer Ace in single deck if they dealer will stand on soft 17 shouldStand = ((dealerCard >= 2) && (dealerCard <= 8)) || ((dealerCard == 1) && (options.numberOfDecks == 1) && !options.hitSoft17); } } else { // Stand on 17 or above if (handValue.total > 16) { shouldStand = true; } else if (handValue.total > 12) { // 13-16 you should stand against dealer 2-6 shouldStand = (dealerCard >= 2) && (dealerCard <= 6); } else if (handValue.total == 12) { // Stand on dealer 4-6 shouldStand = (dealerCard >= 4) && (dealerCard <= 6); } // Advanced option - in single deck a pair of 7s should stand against a dealer 10 if ((options.strategyComplexity != "simple") && (handValue.total == 14) && (playerCards[0] == 7) && (dealerCard == 10) && (options.numberOfDecks == 1)) { shouldStand = true; } } return shouldStand; }
[ "function", "ShouldPlayerStand", "(", "playerCards", ",", "dealerCard", ",", "handValue", ",", "handCount", ",", "options", ")", "{", "var", "shouldStand", "=", "false", ";", "if", "(", "handValue", ".", "soft", ")", "{", "// Don't stand until you hit 18", "if", "(", "handValue", ".", "total", ">", "18", ")", "{", "shouldStand", "=", "true", ";", "}", "else", "if", "(", "handValue", ".", "total", "==", "18", ")", "{", "// Stand against dealer 2-8, and against a dealer Ace in single deck if they dealer will stand on soft 17", "shouldStand", "=", "(", "(", "dealerCard", ">=", "2", ")", "&&", "(", "dealerCard", "<=", "8", ")", ")", "||", "(", "(", "dealerCard", "==", "1", ")", "&&", "(", "options", ".", "numberOfDecks", "==", "1", ")", "&&", "!", "options", ".", "hitSoft17", ")", ";", "}", "}", "else", "{", "// Stand on 17 or above", "if", "(", "handValue", ".", "total", ">", "16", ")", "{", "shouldStand", "=", "true", ";", "}", "else", "if", "(", "handValue", ".", "total", ">", "12", ")", "{", "// 13-16 you should stand against dealer 2-6", "shouldStand", "=", "(", "dealerCard", ">=", "2", ")", "&&", "(", "dealerCard", "<=", "6", ")", ";", "}", "else", "if", "(", "handValue", ".", "total", "==", "12", ")", "{", "// Stand on dealer 4-6", "shouldStand", "=", "(", "dealerCard", ">=", "4", ")", "&&", "(", "dealerCard", "<=", "6", ")", ";", "}", "// Advanced option - in single deck a pair of 7s should stand against a dealer 10", "if", "(", "(", "options", ".", "strategyComplexity", "!=", "\"simple\"", ")", "&&", "(", "handValue", ".", "total", "==", "14", ")", "&&", "(", "playerCards", "[", "0", "]", "==", "7", ")", "&&", "(", "dealerCard", "==", "10", ")", "&&", "(", "options", ".", "numberOfDecks", "==", "1", ")", ")", "{", "shouldStand", "=", "true", ";", "}", "}", "return", "shouldStand", ";", "}" ]
Stand Strategy Note that we've already checkd other actions such as double, split, and surrender So at this point we're only assessing whether you should stand as opposed to hitting
[ "Stand", "Strategy", "Note", "that", "we", "ve", "already", "checkd", "other", "actions", "such", "as", "double", "split", "and", "surrender", "So", "at", "this", "point", "we", "re", "only", "assessing", "whether", "you", "should", "stand", "as", "opposed", "to", "hitting" ]
dfcb976ab9bb33c74c24c9bacf369e8ffb6506f3
https://github.com/gsdriver/blackjack-strategy/blob/dfcb976ab9bb33c74c24c9bacf369e8ffb6506f3/src/Suggestion.js#L524-L568
36,748
WorldMobileCoin/wmcc-core
src/net/pool.js
Pool
function Pool(options) { if (!(this instanceof Pool)) return new Pool(options); AsyncObject.call(this); this.options = new PoolOptions(options); this.network = this.options.network; this.logger = this.options.logger.context('net'); this.chain = this.options.chain; this.mempool = this.options.mempool; this.server = this.options.createServer(); this.nonces = this.options.nonces; this.locker = new Lock(true); this.connected = false; this.disconnecting = false; this.syncing = false; this.spvFilter = null; this.txFilter = null; this.blockMap = new Set(); this.txMap = new Set(); this.compactBlocks = new Set(); this.invMap = new Map(); this.pendingFilter = null; this.pendingRefill = null; this.checkpoints = false; this.headerChain = new List(); this.headerNext = null; this.headerTip = null; this.peers = new PeerList(); this.authdb = new BIP150.AuthDB(this.options); this.hosts = new HostList(this.options); this.id = 0; if (this.options.spv) this.spvFilter = Bloom.fromRate(20000, 0.001, Bloom.flags.ALL); if (!this.options.mempool) this.txFilter = new RollingFilter(50000, 0.000001); this._init(); }
javascript
function Pool(options) { if (!(this instanceof Pool)) return new Pool(options); AsyncObject.call(this); this.options = new PoolOptions(options); this.network = this.options.network; this.logger = this.options.logger.context('net'); this.chain = this.options.chain; this.mempool = this.options.mempool; this.server = this.options.createServer(); this.nonces = this.options.nonces; this.locker = new Lock(true); this.connected = false; this.disconnecting = false; this.syncing = false; this.spvFilter = null; this.txFilter = null; this.blockMap = new Set(); this.txMap = new Set(); this.compactBlocks = new Set(); this.invMap = new Map(); this.pendingFilter = null; this.pendingRefill = null; this.checkpoints = false; this.headerChain = new List(); this.headerNext = null; this.headerTip = null; this.peers = new PeerList(); this.authdb = new BIP150.AuthDB(this.options); this.hosts = new HostList(this.options); this.id = 0; if (this.options.spv) this.spvFilter = Bloom.fromRate(20000, 0.001, Bloom.flags.ALL); if (!this.options.mempool) this.txFilter = new RollingFilter(50000, 0.000001); this._init(); }
[ "function", "Pool", "(", "options", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Pool", ")", ")", "return", "new", "Pool", "(", "options", ")", ";", "AsyncObject", ".", "call", "(", "this", ")", ";", "this", ".", "options", "=", "new", "PoolOptions", "(", "options", ")", ";", "this", ".", "network", "=", "this", ".", "options", ".", "network", ";", "this", ".", "logger", "=", "this", ".", "options", ".", "logger", ".", "context", "(", "'net'", ")", ";", "this", ".", "chain", "=", "this", ".", "options", ".", "chain", ";", "this", ".", "mempool", "=", "this", ".", "options", ".", "mempool", ";", "this", ".", "server", "=", "this", ".", "options", ".", "createServer", "(", ")", ";", "this", ".", "nonces", "=", "this", ".", "options", ".", "nonces", ";", "this", ".", "locker", "=", "new", "Lock", "(", "true", ")", ";", "this", ".", "connected", "=", "false", ";", "this", ".", "disconnecting", "=", "false", ";", "this", ".", "syncing", "=", "false", ";", "this", ".", "spvFilter", "=", "null", ";", "this", ".", "txFilter", "=", "null", ";", "this", ".", "blockMap", "=", "new", "Set", "(", ")", ";", "this", ".", "txMap", "=", "new", "Set", "(", ")", ";", "this", ".", "compactBlocks", "=", "new", "Set", "(", ")", ";", "this", ".", "invMap", "=", "new", "Map", "(", ")", ";", "this", ".", "pendingFilter", "=", "null", ";", "this", ".", "pendingRefill", "=", "null", ";", "this", ".", "checkpoints", "=", "false", ";", "this", ".", "headerChain", "=", "new", "List", "(", ")", ";", "this", ".", "headerNext", "=", "null", ";", "this", ".", "headerTip", "=", "null", ";", "this", ".", "peers", "=", "new", "PeerList", "(", ")", ";", "this", ".", "authdb", "=", "new", "BIP150", ".", "AuthDB", "(", "this", ".", "options", ")", ";", "this", ".", "hosts", "=", "new", "HostList", "(", "this", ".", "options", ")", ";", "this", ".", "id", "=", "0", ";", "if", "(", "this", ".", "options", ".", "spv", ")", "this", ".", "spvFilter", "=", "Bloom", ".", "fromRate", "(", "20000", ",", "0.001", ",", "Bloom", ".", "flags", ".", "ALL", ")", ";", "if", "(", "!", "this", ".", "options", ".", "mempool", ")", "this", ".", "txFilter", "=", "new", "RollingFilter", "(", "50000", ",", "0.000001", ")", ";", "this", ".", "_init", "(", ")", ";", "}" ]
A pool of peers for handling all network activity. @alias module:net.Pool @constructor @param {Object} options @param {Chain} options.chain @param {Mempool?} options.mempool @param {Number?} [options.maxOutbound=8] - Maximum number of peers. @param {Boolean?} options.spv - Do an SPV sync. @param {Boolean?} options.noRelay - Whether to ask for relayed transactions. @param {Number?} [options.feeRate] - Fee filter rate. @param {Number?} [options.invTimeout=60000] - Timeout for broadcasted objects. @param {Boolean?} options.listen - Whether to spin up a server socket and listen for peers. @param {Boolean?} options.selfish - A selfish pool. Will not serve blocks, headers, hashes, utxos, or transactions to peers. @param {Boolean?} options.broadcast - Whether to automatically broadcast transactions accepted to our mempool. @param {String[]} options.seeds @param {Function?} options.createSocket - Custom function to create a socket. Must accept (port, host) and return a node-like socket. @param {Function?} options.createServer - Custom function to create a server. Must return a node-like server. @emits Pool#block @emits Pool#tx @emits Pool#peer @emits Pool#open @emits Pool#close @emits Pool#error @emits Pool#reject
[ "A", "pool", "of", "peers", "for", "handling", "all", "network", "activity", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/net/pool.js#L79-L124
36,749
WorldMobileCoin/wmcc-core
src/primitives/txmeta.js
TXMeta
function TXMeta(options) { if (!(this instanceof TXMeta)) return new TXMeta(options); this.tx = new TX(); this.mtime = util.now(); this.height = -1; this.block = null; this.time = 0; this.index = -1; if (options) this.fromOptions(options); }
javascript
function TXMeta(options) { if (!(this instanceof TXMeta)) return new TXMeta(options); this.tx = new TX(); this.mtime = util.now(); this.height = -1; this.block = null; this.time = 0; this.index = -1; if (options) this.fromOptions(options); }
[ "function", "TXMeta", "(", "options", ")", "{", "if", "(", "!", "(", "this", "instanceof", "TXMeta", ")", ")", "return", "new", "TXMeta", "(", "options", ")", ";", "this", ".", "tx", "=", "new", "TX", "(", ")", ";", "this", ".", "mtime", "=", "util", ".", "now", "(", ")", ";", "this", ".", "height", "=", "-", "1", ";", "this", ".", "block", "=", "null", ";", "this", ".", "time", "=", "0", ";", "this", ".", "index", "=", "-", "1", ";", "if", "(", "options", ")", "this", ".", "fromOptions", "(", "options", ")", ";", "}" ]
An extended transaction object. @alias module:primitives.TXMeta @constructor @param {Object} options
[ "An", "extended", "transaction", "object", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/primitives/txmeta.js#L26-L39
36,750
WorldMobileCoin/wmcc-core
src/bip70/paymentack.js
PaymentACK
function PaymentACK(options) { if (!(this instanceof PaymentACK)) return new PaymentACK(options); this.payment = new Payment(); this.memo = null; if (options) this.fromOptions(options); }
javascript
function PaymentACK(options) { if (!(this instanceof PaymentACK)) return new PaymentACK(options); this.payment = new Payment(); this.memo = null; if (options) this.fromOptions(options); }
[ "function", "PaymentACK", "(", "options", ")", "{", "if", "(", "!", "(", "this", "instanceof", "PaymentACK", ")", ")", "return", "new", "PaymentACK", "(", "options", ")", ";", "this", ".", "payment", "=", "new", "Payment", "(", ")", ";", "this", ".", "memo", "=", "null", ";", "if", "(", "options", ")", "this", ".", "fromOptions", "(", "options", ")", ";", "}" ]
Represents a BIP70 payment ack. @alias module:bip70.PaymentACK @constructor @param {Object?} options @property {Payment} payment @property {String|null} memo
[ "Represents", "a", "BIP70", "payment", "ack", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/bip70/paymentack.js#L27-L36
36,751
WorldMobileCoin/wmcc-core
src/crypto/sha256.js
hash256
function hash256(data) { const out = Buffer.allocUnsafe(32); ctx.init(); ctx.update(data); ctx._finish(out); ctx.init(); ctx.update(out); ctx._finish(out); return out; }
javascript
function hash256(data) { const out = Buffer.allocUnsafe(32); ctx.init(); ctx.update(data); ctx._finish(out); ctx.init(); ctx.update(out); ctx._finish(out); return out; }
[ "function", "hash256", "(", "data", ")", "{", "const", "out", "=", "Buffer", ".", "allocUnsafe", "(", "32", ")", ";", "ctx", ".", "init", "(", ")", ";", "ctx", ".", "update", "(", "data", ")", ";", "ctx", ".", "_finish", "(", "out", ")", ";", "ctx", ".", "init", "(", ")", ";", "ctx", ".", "update", "(", "out", ")", ";", "ctx", ".", "_finish", "(", "out", ")", ";", "return", "out", ";", "}" ]
Hash buffer with double sha256. @alias module:crypto/sha256.hash256 @param {Buffer} data @returns {Buffer}
[ "Hash", "buffer", "with", "double", "sha256", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/crypto/sha256.js#L367-L376
36,752
WorldMobileCoin/wmcc-core
src/crypto/sha256.js
hmac
function hmac(data, key) { mctx.init(key); mctx.update(data); return mctx.finish(); }
javascript
function hmac(data, key) { mctx.init(key); mctx.update(data); return mctx.finish(); }
[ "function", "hmac", "(", "data", ",", "key", ")", "{", "mctx", ".", "init", "(", "key", ")", ";", "mctx", ".", "update", "(", "data", ")", ";", "return", "mctx", ".", "finish", "(", ")", ";", "}" ]
Create a sha256 HMAC from buffer and key. @alias module:crypto/sha256.hmac @param {Buffer} data @param {Buffer} key @returns {Buffer}
[ "Create", "a", "sha256", "HMAC", "from", "buffer", "and", "key", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/crypto/sha256.js#L386-L390
36,753
WorldMobileCoin/wmcc-core
src/utils/bech32.js
polymod
function polymod(pre) { const b = pre >>> 25; return ((pre & 0x1ffffff) << 5) ^ (-((b >> 0) & 1) & 0x3b6a57b2) ^ (-((b >> 1) & 1) & 0x26508e6d) ^ (-((b >> 2) & 1) & 0x1ea119fa) ^ (-((b >> 3) & 1) & 0x3d4233dd) ^ (-((b >> 4) & 1) & 0x2a1462b3); }
javascript
function polymod(pre) { const b = pre >>> 25; return ((pre & 0x1ffffff) << 5) ^ (-((b >> 0) & 1) & 0x3b6a57b2) ^ (-((b >> 1) & 1) & 0x26508e6d) ^ (-((b >> 2) & 1) & 0x1ea119fa) ^ (-((b >> 3) & 1) & 0x3d4233dd) ^ (-((b >> 4) & 1) & 0x2a1462b3); }
[ "function", "polymod", "(", "pre", ")", "{", "const", "b", "=", "pre", ">>>", "25", ";", "return", "(", "(", "pre", "&", "0x1ffffff", ")", "<<", "5", ")", "^", "(", "-", "(", "(", "b", ">>", "0", ")", "&", "1", ")", "&", "0x3b6a57b2", ")", "^", "(", "-", "(", "(", "b", ">>", "1", ")", "&", "1", ")", "&", "0x26508e6d", ")", "^", "(", "-", "(", "(", "b", ">>", "2", ")", "&", "1", ")", "&", "0x1ea119fa", ")", "^", "(", "-", "(", "(", "b", ">>", "3", ")", "&", "1", ")", "&", "0x3d4233dd", ")", "^", "(", "-", "(", "(", "b", ">>", "4", ")", "&", "1", ")", "&", "0x2a1462b3", ")", ";", "}" ]
Update checksum. @ignore @param {Number} chk @returns {Number}
[ "Update", "checksum", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/utils/bech32.js#L62-L70
36,754
WorldMobileCoin/wmcc-core
src/utils/bech32.js
serialize
function serialize(hrp, data) { let chk = 1; let i; for (i = 0; i < hrp.length; i++) { const ch = hrp.charCodeAt(i); if ((ch >> 5) === 0) throw new Error('Invalid bech32 character.'); chk = polymod(chk) ^ (ch >> 5); } if (i + 7 + data.length > 90) throw new Error('Invalid bech32 data length.'); chk = polymod(chk); let str = ''; for (let i = 0; i < hrp.length; i++) { const ch = hrp.charCodeAt(i); chk = polymod(chk) ^ (ch & 0x1f); str += hrp[i]; } str += '1'; for (let i = 0; i < data.length; i++) { const ch = data[i]; if ((ch >> 5) !== 0) throw new Error('Invalid bech32 value.'); chk = polymod(chk) ^ ch; str += CHARSET[ch]; } for (let i = 0; i < 6; i++) chk = polymod(chk); chk ^= 1; for (let i = 0; i < 6; i++) str += CHARSET[(chk >>> ((5 - i) * 5)) & 0x1f]; return str; }
javascript
function serialize(hrp, data) { let chk = 1; let i; for (i = 0; i < hrp.length; i++) { const ch = hrp.charCodeAt(i); if ((ch >> 5) === 0) throw new Error('Invalid bech32 character.'); chk = polymod(chk) ^ (ch >> 5); } if (i + 7 + data.length > 90) throw new Error('Invalid bech32 data length.'); chk = polymod(chk); let str = ''; for (let i = 0; i < hrp.length; i++) { const ch = hrp.charCodeAt(i); chk = polymod(chk) ^ (ch & 0x1f); str += hrp[i]; } str += '1'; for (let i = 0; i < data.length; i++) { const ch = data[i]; if ((ch >> 5) !== 0) throw new Error('Invalid bech32 value.'); chk = polymod(chk) ^ ch; str += CHARSET[ch]; } for (let i = 0; i < 6; i++) chk = polymod(chk); chk ^= 1; for (let i = 0; i < 6; i++) str += CHARSET[(chk >>> ((5 - i) * 5)) & 0x1f]; return str; }
[ "function", "serialize", "(", "hrp", ",", "data", ")", "{", "let", "chk", "=", "1", ";", "let", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "hrp", ".", "length", ";", "i", "++", ")", "{", "const", "ch", "=", "hrp", ".", "charCodeAt", "(", "i", ")", ";", "if", "(", "(", "ch", ">>", "5", ")", "===", "0", ")", "throw", "new", "Error", "(", "'Invalid bech32 character.'", ")", ";", "chk", "=", "polymod", "(", "chk", ")", "^", "(", "ch", ">>", "5", ")", ";", "}", "if", "(", "i", "+", "7", "+", "data", ".", "length", ">", "90", ")", "throw", "new", "Error", "(", "'Invalid bech32 data length.'", ")", ";", "chk", "=", "polymod", "(", "chk", ")", ";", "let", "str", "=", "''", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "hrp", ".", "length", ";", "i", "++", ")", "{", "const", "ch", "=", "hrp", ".", "charCodeAt", "(", "i", ")", ";", "chk", "=", "polymod", "(", "chk", ")", "^", "(", "ch", "&", "0x1f", ")", ";", "str", "+=", "hrp", "[", "i", "]", ";", "}", "str", "+=", "'1'", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "data", ".", "length", ";", "i", "++", ")", "{", "const", "ch", "=", "data", "[", "i", "]", ";", "if", "(", "(", "ch", ">>", "5", ")", "!==", "0", ")", "throw", "new", "Error", "(", "'Invalid bech32 value.'", ")", ";", "chk", "=", "polymod", "(", "chk", ")", "^", "ch", ";", "str", "+=", "CHARSET", "[", "ch", "]", ";", "}", "for", "(", "let", "i", "=", "0", ";", "i", "<", "6", ";", "i", "++", ")", "chk", "=", "polymod", "(", "chk", ")", ";", "chk", "^=", "1", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "6", ";", "i", "++", ")", "str", "+=", "CHARSET", "[", "(", "chk", ">>>", "(", "(", "5", "-", "i", ")", "*", "5", ")", ")", "&", "0x1f", "]", ";", "return", "str", ";", "}" ]
Encode hrp and data as a bech32 string. @ignore @param {String} hrp @param {Buffer} data @returns {String}
[ "Encode", "hrp", "and", "data", "as", "a", "bech32", "string", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/utils/bech32.js#L80-L127
36,755
WorldMobileCoin/wmcc-core
src/utils/bech32.js
deserialize
function deserialize(str) { let dlen = 0; if (str.length < 8 || str.length > 90) throw new Error('Invalid bech32 string length.'); while (dlen < str.length && str[(str.length - 1) - dlen] !== '1') dlen++; const hlen = str.length - (1 + dlen); if (hlen < 1 || dlen < 6) throw new Error('Invalid bech32 data length.'); dlen -= 6; const data = Buffer.allocUnsafe(dlen); let chk = 1; let lower = false; let upper = false; let hrp = ''; for (let i = 0; i < hlen; i++) { let ch = str.charCodeAt(i); if (ch < 0x21 || ch > 0x7e) throw new Error('Invalid bech32 character.'); if (ch >= 0x61 && ch <= 0x7a) { lower = true; } else if (ch >= 0x41 && ch <= 0x5a) { upper = true; ch = (ch - 0x41) + 0x61; } hrp += String.fromCharCode(ch); chk = polymod(chk) ^ (ch >> 5); } chk = polymod(chk); let i; for (i = 0; i < hlen; i++) chk = polymod(chk) ^ (str.charCodeAt(i) & 0x1f); i++; while (i < str.length) { const ch = str.charCodeAt(i); const v = (ch & 0x80) ? -1 : TABLE[ch]; if (ch >= 0x61 && ch <= 0x7a) lower = true; else if (ch >= 0x41 && ch <= 0x5a) upper = true; if (v === -1) throw new Error('Invalid bech32 character.'); chk = polymod(chk) ^ v; if (i + 6 < str.length) data[i - (1 + hlen)] = v; i++; } if (lower && upper) throw new Error('Invalid bech32 casing.'); if (chk !== 1) throw new Error('Invalid bech32 checksum.'); return [hrp, data.slice(0, dlen)]; }
javascript
function deserialize(str) { let dlen = 0; if (str.length < 8 || str.length > 90) throw new Error('Invalid bech32 string length.'); while (dlen < str.length && str[(str.length - 1) - dlen] !== '1') dlen++; const hlen = str.length - (1 + dlen); if (hlen < 1 || dlen < 6) throw new Error('Invalid bech32 data length.'); dlen -= 6; const data = Buffer.allocUnsafe(dlen); let chk = 1; let lower = false; let upper = false; let hrp = ''; for (let i = 0; i < hlen; i++) { let ch = str.charCodeAt(i); if (ch < 0x21 || ch > 0x7e) throw new Error('Invalid bech32 character.'); if (ch >= 0x61 && ch <= 0x7a) { lower = true; } else if (ch >= 0x41 && ch <= 0x5a) { upper = true; ch = (ch - 0x41) + 0x61; } hrp += String.fromCharCode(ch); chk = polymod(chk) ^ (ch >> 5); } chk = polymod(chk); let i; for (i = 0; i < hlen; i++) chk = polymod(chk) ^ (str.charCodeAt(i) & 0x1f); i++; while (i < str.length) { const ch = str.charCodeAt(i); const v = (ch & 0x80) ? -1 : TABLE[ch]; if (ch >= 0x61 && ch <= 0x7a) lower = true; else if (ch >= 0x41 && ch <= 0x5a) upper = true; if (v === -1) throw new Error('Invalid bech32 character.'); chk = polymod(chk) ^ v; if (i + 6 < str.length) data[i - (1 + hlen)] = v; i++; } if (lower && upper) throw new Error('Invalid bech32 casing.'); if (chk !== 1) throw new Error('Invalid bech32 checksum.'); return [hrp, data.slice(0, dlen)]; }
[ "function", "deserialize", "(", "str", ")", "{", "let", "dlen", "=", "0", ";", "if", "(", "str", ".", "length", "<", "8", "||", "str", ".", "length", ">", "90", ")", "throw", "new", "Error", "(", "'Invalid bech32 string length.'", ")", ";", "while", "(", "dlen", "<", "str", ".", "length", "&&", "str", "[", "(", "str", ".", "length", "-", "1", ")", "-", "dlen", "]", "!==", "'1'", ")", "dlen", "++", ";", "const", "hlen", "=", "str", ".", "length", "-", "(", "1", "+", "dlen", ")", ";", "if", "(", "hlen", "<", "1", "||", "dlen", "<", "6", ")", "throw", "new", "Error", "(", "'Invalid bech32 data length.'", ")", ";", "dlen", "-=", "6", ";", "const", "data", "=", "Buffer", ".", "allocUnsafe", "(", "dlen", ")", ";", "let", "chk", "=", "1", ";", "let", "lower", "=", "false", ";", "let", "upper", "=", "false", ";", "let", "hrp", "=", "''", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "hlen", ";", "i", "++", ")", "{", "let", "ch", "=", "str", ".", "charCodeAt", "(", "i", ")", ";", "if", "(", "ch", "<", "0x21", "||", "ch", ">", "0x7e", ")", "throw", "new", "Error", "(", "'Invalid bech32 character.'", ")", ";", "if", "(", "ch", ">=", "0x61", "&&", "ch", "<=", "0x7a", ")", "{", "lower", "=", "true", ";", "}", "else", "if", "(", "ch", ">=", "0x41", "&&", "ch", "<=", "0x5a", ")", "{", "upper", "=", "true", ";", "ch", "=", "(", "ch", "-", "0x41", ")", "+", "0x61", ";", "}", "hrp", "+=", "String", ".", "fromCharCode", "(", "ch", ")", ";", "chk", "=", "polymod", "(", "chk", ")", "^", "(", "ch", ">>", "5", ")", ";", "}", "chk", "=", "polymod", "(", "chk", ")", ";", "let", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "hlen", ";", "i", "++", ")", "chk", "=", "polymod", "(", "chk", ")", "^", "(", "str", ".", "charCodeAt", "(", "i", ")", "&", "0x1f", ")", ";", "i", "++", ";", "while", "(", "i", "<", "str", ".", "length", ")", "{", "const", "ch", "=", "str", ".", "charCodeAt", "(", "i", ")", ";", "const", "v", "=", "(", "ch", "&", "0x80", ")", "?", "-", "1", ":", "TABLE", "[", "ch", "]", ";", "if", "(", "ch", ">=", "0x61", "&&", "ch", "<=", "0x7a", ")", "lower", "=", "true", ";", "else", "if", "(", "ch", ">=", "0x41", "&&", "ch", "<=", "0x5a", ")", "upper", "=", "true", ";", "if", "(", "v", "===", "-", "1", ")", "throw", "new", "Error", "(", "'Invalid bech32 character.'", ")", ";", "chk", "=", "polymod", "(", "chk", ")", "^", "v", ";", "if", "(", "i", "+", "6", "<", "str", ".", "length", ")", "data", "[", "i", "-", "(", "1", "+", "hlen", ")", "]", "=", "v", ";", "i", "++", ";", "}", "if", "(", "lower", "&&", "upper", ")", "throw", "new", "Error", "(", "'Invalid bech32 casing.'", ")", ";", "if", "(", "chk", "!==", "1", ")", "throw", "new", "Error", "(", "'Invalid bech32 checksum.'", ")", ";", "return", "[", "hrp", ",", "data", ".", "slice", "(", "0", ",", "dlen", ")", "]", ";", "}" ]
Decode a bech32 string. @param {String} str @returns {Array} [hrp, data]
[ "Decode", "a", "bech32", "string", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/utils/bech32.js#L135-L210
36,756
WorldMobileCoin/wmcc-core
src/utils/bech32.js
convert
function convert(data, output, frombits, tobits, pad, off) { const maxv = (1 << tobits) - 1; let acc = 0; let bits = 0; let j = 0; if (pad !== -1) output[j++] = pad; for (let i = off; i < data.length; i++) { const value = data[i]; if ((value >> frombits) !== 0) throw new Error('Invalid bech32 bits.'); acc = (acc << frombits) | value; bits += frombits; while (bits >= tobits) { bits -= tobits; output[j++] = (acc >>> bits) & maxv; } } if (pad !== -1) { if (bits > 0) output[j++] = (acc << (tobits - bits)) & maxv; } else { if (bits >= frombits || ((acc << (tobits - bits)) & maxv)) throw new Error('Invalid bech32 bits.'); } return output.slice(0, j); }
javascript
function convert(data, output, frombits, tobits, pad, off) { const maxv = (1 << tobits) - 1; let acc = 0; let bits = 0; let j = 0; if (pad !== -1) output[j++] = pad; for (let i = off; i < data.length; i++) { const value = data[i]; if ((value >> frombits) !== 0) throw new Error('Invalid bech32 bits.'); acc = (acc << frombits) | value; bits += frombits; while (bits >= tobits) { bits -= tobits; output[j++] = (acc >>> bits) & maxv; } } if (pad !== -1) { if (bits > 0) output[j++] = (acc << (tobits - bits)) & maxv; } else { if (bits >= frombits || ((acc << (tobits - bits)) & maxv)) throw new Error('Invalid bech32 bits.'); } return output.slice(0, j); }
[ "function", "convert", "(", "data", ",", "output", ",", "frombits", ",", "tobits", ",", "pad", ",", "off", ")", "{", "const", "maxv", "=", "(", "1", "<<", "tobits", ")", "-", "1", ";", "let", "acc", "=", "0", ";", "let", "bits", "=", "0", ";", "let", "j", "=", "0", ";", "if", "(", "pad", "!==", "-", "1", ")", "output", "[", "j", "++", "]", "=", "pad", ";", "for", "(", "let", "i", "=", "off", ";", "i", "<", "data", ".", "length", ";", "i", "++", ")", "{", "const", "value", "=", "data", "[", "i", "]", ";", "if", "(", "(", "value", ">>", "frombits", ")", "!==", "0", ")", "throw", "new", "Error", "(", "'Invalid bech32 bits.'", ")", ";", "acc", "=", "(", "acc", "<<", "frombits", ")", "|", "value", ";", "bits", "+=", "frombits", ";", "while", "(", "bits", ">=", "tobits", ")", "{", "bits", "-=", "tobits", ";", "output", "[", "j", "++", "]", "=", "(", "acc", ">>>", "bits", ")", "&", "maxv", ";", "}", "}", "if", "(", "pad", "!==", "-", "1", ")", "{", "if", "(", "bits", ">", "0", ")", "output", "[", "j", "++", "]", "=", "(", "acc", "<<", "(", "tobits", "-", "bits", ")", ")", "&", "maxv", ";", "}", "else", "{", "if", "(", "bits", ">=", "frombits", "||", "(", "(", "acc", "<<", "(", "tobits", "-", "bits", ")", ")", "&", "maxv", ")", ")", "throw", "new", "Error", "(", "'Invalid bech32 bits.'", ")", ";", "}", "return", "output", ".", "slice", "(", "0", ",", "j", ")", ";", "}" ]
Convert serialized data to bits, suitable to be serialized as bech32. @param {Buffer} data @param {Buffer} output @param {Number} frombits @param {Number} tobits @param {Number} pad @param {Number} off @returns {Buffer}
[ "Convert", "serialized", "data", "to", "bits", "suitable", "to", "be", "serialized", "as", "bech32", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/utils/bech32.js#L224-L257
36,757
WorldMobileCoin/wmcc-core
src/utils/bech32.js
encode
function encode(hrp, version, hash) { const output = POOL65; if (version < 0 || version > 16) throw new Error('Invalid bech32 version.'); if (hash.length < 2 || hash.length > 40) throw new Error('Invalid bech32 data length.'); const data = convert(hash, output, 8, 5, version, 0); return serialize(hrp, data); }
javascript
function encode(hrp, version, hash) { const output = POOL65; if (version < 0 || version > 16) throw new Error('Invalid bech32 version.'); if (hash.length < 2 || hash.length > 40) throw new Error('Invalid bech32 data length.'); const data = convert(hash, output, 8, 5, version, 0); return serialize(hrp, data); }
[ "function", "encode", "(", "hrp", ",", "version", ",", "hash", ")", "{", "const", "output", "=", "POOL65", ";", "if", "(", "version", "<", "0", "||", "version", ">", "16", ")", "throw", "new", "Error", "(", "'Invalid bech32 version.'", ")", ";", "if", "(", "hash", ".", "length", "<", "2", "||", "hash", ".", "length", ">", "40", ")", "throw", "new", "Error", "(", "'Invalid bech32 data length.'", ")", ";", "const", "data", "=", "convert", "(", "hash", ",", "output", ",", "8", ",", "5", ",", "version", ",", "0", ")", ";", "return", "serialize", "(", "hrp", ",", "data", ")", ";", "}" ]
Serialize data to bech32 address. @param {String} hrp @param {Number} version @param {Buffer} hash @returns {String}
[ "Serialize", "data", "to", "bech32", "address", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/utils/bech32.js#L267-L279
36,758
WorldMobileCoin/wmcc-core
src/utils/bech32.js
decode
function decode(str) { const [hrp, data] = deserialize(str); if (data.length === 0 || data.length > 65) throw new Error('Invalid bech32 data length.'); if (data[0] > 16) throw new Error('Invalid bech32 version.'); const version = data[0]; const output = data; const hash = convert(data, output, 5, 8, -1, 1); if (hash.length < 2 || hash.length > 40) throw new Error('Invalid bech32 data length.'); return new AddrResult(hrp, version, hash); }
javascript
function decode(str) { const [hrp, data] = deserialize(str); if (data.length === 0 || data.length > 65) throw new Error('Invalid bech32 data length.'); if (data[0] > 16) throw new Error('Invalid bech32 version.'); const version = data[0]; const output = data; const hash = convert(data, output, 5, 8, -1, 1); if (hash.length < 2 || hash.length > 40) throw new Error('Invalid bech32 data length.'); return new AddrResult(hrp, version, hash); }
[ "function", "decode", "(", "str", ")", "{", "const", "[", "hrp", ",", "data", "]", "=", "deserialize", "(", "str", ")", ";", "if", "(", "data", ".", "length", "===", "0", "||", "data", ".", "length", ">", "65", ")", "throw", "new", "Error", "(", "'Invalid bech32 data length.'", ")", ";", "if", "(", "data", "[", "0", "]", ">", "16", ")", "throw", "new", "Error", "(", "'Invalid bech32 version.'", ")", ";", "const", "version", "=", "data", "[", "0", "]", ";", "const", "output", "=", "data", ";", "const", "hash", "=", "convert", "(", "data", ",", "output", ",", "5", ",", "8", ",", "-", "1", ",", "1", ")", ";", "if", "(", "hash", ".", "length", "<", "2", "||", "hash", ".", "length", ">", "40", ")", "throw", "new", "Error", "(", "'Invalid bech32 data length.'", ")", ";", "return", "new", "AddrResult", "(", "hrp", ",", "version", ",", "hash", ")", ";", "}" ]
Deserialize data from bech32 address. @param {String} str @returns {Object}
[ "Deserialize", "data", "from", "bech32", "address", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/utils/bech32.js#L290-L307
36,759
WorldMobileCoin/wmcc-core
src/primitives/netaddress.js
NetAddress
function NetAddress(options) { if (!(this instanceof NetAddress)) return new NetAddress(options); this.host = '0.0.0.0'; this.port = 0; this.services = 0; this.time = 0; this.hostname = '0.0.0.0:0'; this.raw = IP.ZERO_IP; if (options) this.fromOptions(options); }
javascript
function NetAddress(options) { if (!(this instanceof NetAddress)) return new NetAddress(options); this.host = '0.0.0.0'; this.port = 0; this.services = 0; this.time = 0; this.hostname = '0.0.0.0:0'; this.raw = IP.ZERO_IP; if (options) this.fromOptions(options); }
[ "function", "NetAddress", "(", "options", ")", "{", "if", "(", "!", "(", "this", "instanceof", "NetAddress", ")", ")", "return", "new", "NetAddress", "(", "options", ")", ";", "this", ".", "host", "=", "'0.0.0.0'", ";", "this", ".", "port", "=", "0", ";", "this", ".", "services", "=", "0", ";", "this", ".", "time", "=", "0", ";", "this", ".", "hostname", "=", "'0.0.0.0:0'", ";", "this", ".", "raw", "=", "IP", ".", "ZERO_IP", ";", "if", "(", "options", ")", "this", ".", "fromOptions", "(", "options", ")", ";", "}" ]
Represents a network address. @alias module:primitives.NetAddress @constructor @param {Object} options @param {Number?} options.time - Timestamp. @param {Number?} options.services - Service bits. @param {String?} options.host - IP address (IPv6 or IPv4). @param {Number?} options.port - Port. @property {Host} host @property {Number} port @property {Number} services @property {Number} time
[ "Represents", "a", "network", "address", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/primitives/netaddress.js#L36-L49
36,760
perfectapi/node-perfectapi
lib/worker.js
function(err, commandName, config, resultFunction) { //max Number in javascript is 9,007,199,254,740,992. At 10,000 requests per second, that is 28,561 years until we get an overflow on messageId messageId += 1; messageStack[messageId] = resultFunction; //tell the parent process to run the command process.send({id: messageId, err: err, commandName: commandName, config: config}); }
javascript
function(err, commandName, config, resultFunction) { //max Number in javascript is 9,007,199,254,740,992. At 10,000 requests per second, that is 28,561 years until we get an overflow on messageId messageId += 1; messageStack[messageId] = resultFunction; //tell the parent process to run the command process.send({id: messageId, err: err, commandName: commandName, config: config}); }
[ "function", "(", "err", ",", "commandName", ",", "config", ",", "resultFunction", ")", "{", "//max Number in javascript is 9,007,199,254,740,992. At 10,000 requests per second, that is 28,561 years until we get an overflow on messageId", "messageId", "+=", "1", ";", "messageStack", "[", "messageId", "]", "=", "resultFunction", ";", "//tell the parent process to run the command", "process", ".", "send", "(", "{", "id", ":", "messageId", ",", "err", ":", "err", ",", "commandName", ":", "commandName", ",", "config", ":", "config", "}", ")", ";", "}" ]
define a function for the webserver to call when it receives a command
[ "define", "a", "function", "for", "the", "webserver", "to", "call", "when", "it", "receives", "a", "command" ]
aea295ede31994bf7f3c2903cedbe6d316b30062
https://github.com/perfectapi/node-perfectapi/blob/aea295ede31994bf7f3c2903cedbe6d316b30062/lib/worker.js#L34-L41
36,761
WorldMobileCoin/wmcc-core
src/utils/murmur3.js
murmur3
function murmur3(data, seed) { const tail = data.length - (data.length % 4); const c1 = 0xcc9e2d51; const c2 = 0x1b873593; let h1 = seed; let k1; for (let i = 0; i < tail; i += 4) { k1 = (data[i + 3] << 24) | (data[i + 2] << 16) | (data[i + 1] << 8) | data[i]; k1 = mul32(k1, c1); k1 = rotl32(k1, 15); k1 = mul32(k1, c2); h1 ^= k1; h1 = rotl32(h1, 13); h1 = sum32(mul32(h1, 5), 0xe6546b64); } k1 = 0; switch (data.length & 3) { case 3: k1 ^= data[tail + 2] << 16; case 2: k1 ^= data[tail + 1] << 8; case 1: k1 ^= data[tail + 0]; k1 = mul32(k1, c1); k1 = rotl32(k1, 15); k1 = mul32(k1, c2); h1 ^= k1; } h1 ^= data.length; h1 ^= h1 >>> 16; h1 = mul32(h1, 0x85ebca6b); h1 ^= h1 >>> 13; h1 = mul32(h1, 0xc2b2ae35); h1 ^= h1 >>> 16; if (h1 < 0) h1 += 0x100000000; return h1; }
javascript
function murmur3(data, seed) { const tail = data.length - (data.length % 4); const c1 = 0xcc9e2d51; const c2 = 0x1b873593; let h1 = seed; let k1; for (let i = 0; i < tail; i += 4) { k1 = (data[i + 3] << 24) | (data[i + 2] << 16) | (data[i + 1] << 8) | data[i]; k1 = mul32(k1, c1); k1 = rotl32(k1, 15); k1 = mul32(k1, c2); h1 ^= k1; h1 = rotl32(h1, 13); h1 = sum32(mul32(h1, 5), 0xe6546b64); } k1 = 0; switch (data.length & 3) { case 3: k1 ^= data[tail + 2] << 16; case 2: k1 ^= data[tail + 1] << 8; case 1: k1 ^= data[tail + 0]; k1 = mul32(k1, c1); k1 = rotl32(k1, 15); k1 = mul32(k1, c2); h1 ^= k1; } h1 ^= data.length; h1 ^= h1 >>> 16; h1 = mul32(h1, 0x85ebca6b); h1 ^= h1 >>> 13; h1 = mul32(h1, 0xc2b2ae35); h1 ^= h1 >>> 16; if (h1 < 0) h1 += 0x100000000; return h1; }
[ "function", "murmur3", "(", "data", ",", "seed", ")", "{", "const", "tail", "=", "data", ".", "length", "-", "(", "data", ".", "length", "%", "4", ")", ";", "const", "c1", "=", "0xcc9e2d51", ";", "const", "c2", "=", "0x1b873593", ";", "let", "h1", "=", "seed", ";", "let", "k1", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "tail", ";", "i", "+=", "4", ")", "{", "k1", "=", "(", "data", "[", "i", "+", "3", "]", "<<", "24", ")", "|", "(", "data", "[", "i", "+", "2", "]", "<<", "16", ")", "|", "(", "data", "[", "i", "+", "1", "]", "<<", "8", ")", "|", "data", "[", "i", "]", ";", "k1", "=", "mul32", "(", "k1", ",", "c1", ")", ";", "k1", "=", "rotl32", "(", "k1", ",", "15", ")", ";", "k1", "=", "mul32", "(", "k1", ",", "c2", ")", ";", "h1", "^=", "k1", ";", "h1", "=", "rotl32", "(", "h1", ",", "13", ")", ";", "h1", "=", "sum32", "(", "mul32", "(", "h1", ",", "5", ")", ",", "0xe6546b64", ")", ";", "}", "k1", "=", "0", ";", "switch", "(", "data", ".", "length", "&", "3", ")", "{", "case", "3", ":", "k1", "^=", "data", "[", "tail", "+", "2", "]", "<<", "16", ";", "case", "2", ":", "k1", "^=", "data", "[", "tail", "+", "1", "]", "<<", "8", ";", "case", "1", ":", "k1", "^=", "data", "[", "tail", "+", "0", "]", ";", "k1", "=", "mul32", "(", "k1", ",", "c1", ")", ";", "k1", "=", "rotl32", "(", "k1", ",", "15", ")", ";", "k1", "=", "mul32", "(", "k1", ",", "c2", ")", ";", "h1", "^=", "k1", ";", "}", "h1", "^=", "data", ".", "length", ";", "h1", "^=", "h1", ">>>", "16", ";", "h1", "=", "mul32", "(", "h1", ",", "0x85ebca6b", ")", ";", "h1", "^=", "h1", ">>>", "13", ";", "h1", "=", "mul32", "(", "h1", ",", "0xc2b2ae35", ")", ";", "h1", "^=", "h1", ">>>", "16", ";", "if", "(", "h1", "<", "0", ")", "h1", "+=", "0x100000000", ";", "return", "h1", ";", "}" ]
Murmur3 hash. @alias module:utils.murmur3 @param {Buffer} data @param {Number} seed @returns {Number}
[ "Murmur3", "hash", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/utils/murmur3.js#L24-L69
36,762
WorldMobileCoin/wmcc-core
src/blockchain/chain.js
Chain
function Chain(options) { if (!(this instanceof Chain)) return new Chain(options); AsyncObject.call(this); this.options = new ChainOptions(options); this.network = this.options.network; this.logger = this.options.logger.context('chain'); this.workers = this.options.workers; this.db = new ChainDB(this.options); this.locker = new Lock(true); this.invalid = new LRU(100); this.state = new DeploymentState(); this.tip = new ChainEntry(); this.height = -1; this.synced = false; this.orphanMap = new Map(); this.orphanPrev = new Map(); this.subscribers = {}; this.subscribeJobs = {}; this._subscribes = { cmds: [], cp: null }; this._notifies = { cmds: [], cp: null }; }
javascript
function Chain(options) { if (!(this instanceof Chain)) return new Chain(options); AsyncObject.call(this); this.options = new ChainOptions(options); this.network = this.options.network; this.logger = this.options.logger.context('chain'); this.workers = this.options.workers; this.db = new ChainDB(this.options); this.locker = new Lock(true); this.invalid = new LRU(100); this.state = new DeploymentState(); this.tip = new ChainEntry(); this.height = -1; this.synced = false; this.orphanMap = new Map(); this.orphanPrev = new Map(); this.subscribers = {}; this.subscribeJobs = {}; this._subscribes = { cmds: [], cp: null }; this._notifies = { cmds: [], cp: null }; }
[ "function", "Chain", "(", "options", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Chain", ")", ")", "return", "new", "Chain", "(", "options", ")", ";", "AsyncObject", ".", "call", "(", "this", ")", ";", "this", ".", "options", "=", "new", "ChainOptions", "(", "options", ")", ";", "this", ".", "network", "=", "this", ".", "options", ".", "network", ";", "this", ".", "logger", "=", "this", ".", "options", ".", "logger", ".", "context", "(", "'chain'", ")", ";", "this", ".", "workers", "=", "this", ".", "options", ".", "workers", ";", "this", ".", "db", "=", "new", "ChainDB", "(", "this", ".", "options", ")", ";", "this", ".", "locker", "=", "new", "Lock", "(", "true", ")", ";", "this", ".", "invalid", "=", "new", "LRU", "(", "100", ")", ";", "this", ".", "state", "=", "new", "DeploymentState", "(", ")", ";", "this", ".", "tip", "=", "new", "ChainEntry", "(", ")", ";", "this", ".", "height", "=", "-", "1", ";", "this", ".", "synced", "=", "false", ";", "this", ".", "orphanMap", "=", "new", "Map", "(", ")", ";", "this", ".", "orphanPrev", "=", "new", "Map", "(", ")", ";", "this", ".", "subscribers", "=", "{", "}", ";", "this", ".", "subscribeJobs", "=", "{", "}", ";", "this", ".", "_subscribes", "=", "{", "cmds", ":", "[", "]", ",", "cp", ":", "null", "}", ";", "this", ".", "_notifies", "=", "{", "cmds", ":", "[", "]", ",", "cp", ":", "null", "}", ";", "}" ]
Represents a blockchain. @alias module:blockchain.Chain @constructor @param {Object} options @param {String?} options.name - Database name. @param {String?} options.location - Database file location. @param {String?} options.db - Database backend (`"leveldb"` by default). @param {Number?} options.maxOrphans @param {Boolean?} options.spv @property {Boolean} loaded @property {ChainDB} db - Note that Chain `options` will be passed to the instantiated ChainDB. @property {Lock} locker @property {Object} invalid @property {ChainEntry?} tip @property {Number} height @property {DeploymentState} state @property {Object} orphan - Orphan map. @emits Chain#open @emits Chain#error @emits Chain#block @emits Chain#competitor @emits Chain#resolved @emits Chain#checkpoint @emits Chain#fork @emits Chain#reorganize @emits Chain#invalid @emits Chain#exists @emits Chain#purge @emits Chain#connect @emits Chain#reconnect @emits Chain#disconnect
[ "Represents", "a", "blockchain", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/blockchain/chain.js#L68-L103
36,763
WorldMobileCoin/wmcc-core
src/blockchain/chain.js
DeploymentState
function DeploymentState() { if (!(this instanceof DeploymentState)) return new DeploymentState(); this.flags = Script.flags.MANDATORY_VERIFY_FLAGS; this.flags &= ~Script.flags.VERIFY_P2SH; this.lockFlags = common.lockFlags.MANDATORY_LOCKTIME_FLAGS; this.bip34 = false; this.bip91 = false; this.bip148 = false; }
javascript
function DeploymentState() { if (!(this instanceof DeploymentState)) return new DeploymentState(); this.flags = Script.flags.MANDATORY_VERIFY_FLAGS; this.flags &= ~Script.flags.VERIFY_P2SH; this.lockFlags = common.lockFlags.MANDATORY_LOCKTIME_FLAGS; this.bip34 = false; this.bip91 = false; this.bip148 = false; }
[ "function", "DeploymentState", "(", ")", "{", "if", "(", "!", "(", "this", "instanceof", "DeploymentState", ")", ")", "return", "new", "DeploymentState", "(", ")", ";", "this", ".", "flags", "=", "Script", ".", "flags", ".", "MANDATORY_VERIFY_FLAGS", ";", "this", ".", "flags", "&=", "~", "Script", ".", "flags", ".", "VERIFY_P2SH", ";", "this", ".", "lockFlags", "=", "common", ".", "lockFlags", ".", "MANDATORY_LOCKTIME_FLAGS", ";", "this", ".", "bip34", "=", "false", ";", "this", ".", "bip91", "=", "false", ";", "this", ".", "bip148", "=", "false", ";", "}" ]
Represents the deployment state of the chain. @alias module:blockchain.DeploymentState @constructor @property {VerifyFlags} flags @property {LockFlags} lockFlags @property {Boolean} bip34
[ "Represents", "the", "deployment", "state", "of", "the", "chain", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/blockchain/chain.js#L3110-L3120
36,764
Mercateo/less-plugin-bower-resolve
lib/bower-file-manager.js
createVirtualLessFileFromBowerJson
function createVirtualLessFileFromBowerJson(bowerJsonPath) { return new PromiseConstructor(function(fullfill, reject) { bowerJson.read(bowerJsonPath, { validate: false }, function(err, bowerJsonData) { if (err) { return reject(err); } if (!bowerJsonData.main) { err = bowerJsonPath + ' has no "main" property.'; return reject(new Error(err)); } // convert bower json into less file var virtualLessFile = bowerJsonData.main.filter(function(filename) { return path.extname(filename) === '.less'; }).map(function(filename) { return '@import "' + filename + '";'; }).join('\n'); if (virtualLessFile) { var file = { contents: virtualLessFile, filename: bowerJsonPath }; return fullfill(file); } else { err = 'Couldn\'t find a less file in ' + bowerJsonPath + '.'; return reject(new Error(err)); } }); }); }
javascript
function createVirtualLessFileFromBowerJson(bowerJsonPath) { return new PromiseConstructor(function(fullfill, reject) { bowerJson.read(bowerJsonPath, { validate: false }, function(err, bowerJsonData) { if (err) { return reject(err); } if (!bowerJsonData.main) { err = bowerJsonPath + ' has no "main" property.'; return reject(new Error(err)); } // convert bower json into less file var virtualLessFile = bowerJsonData.main.filter(function(filename) { return path.extname(filename) === '.less'; }).map(function(filename) { return '@import "' + filename + '";'; }).join('\n'); if (virtualLessFile) { var file = { contents: virtualLessFile, filename: bowerJsonPath }; return fullfill(file); } else { err = 'Couldn\'t find a less file in ' + bowerJsonPath + '.'; return reject(new Error(err)); } }); }); }
[ "function", "createVirtualLessFileFromBowerJson", "(", "bowerJsonPath", ")", "{", "return", "new", "PromiseConstructor", "(", "function", "(", "fullfill", ",", "reject", ")", "{", "bowerJson", ".", "read", "(", "bowerJsonPath", ",", "{", "validate", ":", "false", "}", ",", "function", "(", "err", ",", "bowerJsonData", ")", "{", "if", "(", "err", ")", "{", "return", "reject", "(", "err", ")", ";", "}", "if", "(", "!", "bowerJsonData", ".", "main", ")", "{", "err", "=", "bowerJsonPath", "+", "' has no \"main\" property.'", ";", "return", "reject", "(", "new", "Error", "(", "err", ")", ")", ";", "}", "// convert bower json into less file", "var", "virtualLessFile", "=", "bowerJsonData", ".", "main", ".", "filter", "(", "function", "(", "filename", ")", "{", "return", "path", ".", "extname", "(", "filename", ")", "===", "'.less'", ";", "}", ")", ".", "map", "(", "function", "(", "filename", ")", "{", "return", "'@import \"'", "+", "filename", "+", "'\";'", ";", "}", ")", ".", "join", "(", "'\\n'", ")", ";", "if", "(", "virtualLessFile", ")", "{", "var", "file", "=", "{", "contents", ":", "virtualLessFile", ",", "filename", ":", "bowerJsonPath", "}", ";", "return", "fullfill", "(", "file", ")", ";", "}", "else", "{", "err", "=", "'Couldn\\'t find a less file in '", "+", "bowerJsonPath", "+", "'.'", ";", "return", "reject", "(", "new", "Error", "(", "err", ")", ")", ";", "}", "}", ")", ";", "}", ")", ";", "}" ]
Tries to convert a Bower JSON into a virtual Less file. @param {string} bowerJsonPath @returns {PromiseConstructor}
[ "Tries", "to", "convert", "a", "Bower", "JSON", "into", "a", "virtual", "Less", "file", "." ]
f346cad68e90e4c445ebd3ccc95ed9d18ecaca86
https://github.com/Mercateo/less-plugin-bower-resolve/blob/f346cad68e90e4c445ebd3ccc95ed9d18ecaca86/lib/bower-file-manager.js#L25-L55
36,765
Karnith/machinepack-sailsgulpify
lib/gulp/index.js
function (cb) { sails.log.verbose('Loading app Gulpfile...'); // Start task depending on environment if(sails.config.environment === 'production'){ return this.runTask('prod', cb); } this.runTask('default', cb); }
javascript
function (cb) { sails.log.verbose('Loading app Gulpfile...'); // Start task depending on environment if(sails.config.environment === 'production'){ return this.runTask('prod', cb); } this.runTask('default', cb); }
[ "function", "(", "cb", ")", "{", "sails", ".", "log", ".", "verbose", "(", "'Loading app Gulpfile...'", ")", ";", "// Start task depending on environment", "if", "(", "sails", ".", "config", ".", "environment", "===", "'production'", ")", "{", "return", "this", ".", "runTask", "(", "'prod'", ",", "cb", ")", ";", "}", "this", ".", "runTask", "(", "'default'", ",", "cb", ")", ";", "}" ]
Initialize this project's Grunt tasks and execute the environment-specific gulpfile
[ "Initialize", "this", "project", "s", "Grunt", "tasks", "and", "execute", "the", "environment", "-", "specific", "gulpfile" ]
38424f98d59cac4240e676159bd25e3bc82ad8ac
https://github.com/Karnith/machinepack-sailsgulpify/blob/38424f98d59cac4240e676159bd25e3bc82ad8ac/lib/gulp/index.js#L25-L35
36,766
Karnith/machinepack-sailsgulpify
lib/gulp/index.js
_sanitize
function _sanitize (chunk) { if (chunk && typeof chunk === 'object' && chunk.toString) { chunk = chunk.toString(); } if (typeof chunk === 'string') { chunk = chunk.replace(/^[\s\n]*/, ''); chunk = chunk.replace(/[\s\n]*$/, ''); } return chunk; }
javascript
function _sanitize (chunk) { if (chunk && typeof chunk === 'object' && chunk.toString) { chunk = chunk.toString(); } if (typeof chunk === 'string') { chunk = chunk.replace(/^[\s\n]*/, ''); chunk = chunk.replace(/[\s\n]*$/, ''); } return chunk; }
[ "function", "_sanitize", "(", "chunk", ")", "{", "if", "(", "chunk", "&&", "typeof", "chunk", "===", "'object'", "&&", "chunk", ".", "toString", ")", "{", "chunk", "=", "chunk", ".", "toString", "(", ")", ";", "}", "if", "(", "typeof", "chunk", "===", "'string'", ")", "{", "chunk", "=", "chunk", ".", "replace", "(", "/", "^[\\s\\n]*", "/", ",", "''", ")", ";", "chunk", "=", "chunk", ".", "replace", "(", "/", "[\\s\\n]*$", "/", ",", "''", ")", ";", "}", "return", "chunk", ";", "}" ]
After ensuring a chunk is a string, trim any leading or trailing whitespace. If chunk cannot be nicely casted to a string, pass it straight through. @param {*} chunk @return {*}
[ "After", "ensuring", "a", "chunk", "is", "a", "string", "trim", "any", "leading", "or", "trailing", "whitespace", ".", "If", "chunk", "cannot", "be", "nicely", "casted", "to", "a", "string", "pass", "it", "straight", "through", "." ]
38424f98d59cac4240e676159bd25e3bc82ad8ac
https://github.com/Karnith/machinepack-sailsgulpify/blob/38424f98d59cac4240e676159bd25e3bc82ad8ac/lib/gulp/index.js#L203-L213
36,767
jedmao/blink
js/lib/overrides/background.js
background
function background(options) { options = options || {}; // ReSharper disable once UnusedParameter return function (config) { var values = []; [ 'attachment', 'clip', 'color', 'image', 'origin', 'position', 'repeat', 'size' ].forEach(function (prop) { if (options.hasOwnProperty(prop)) { values.push(options[prop]); } }); if (values.length) { return [['background', values.join(' ')]]; } return []; }; }
javascript
function background(options) { options = options || {}; // ReSharper disable once UnusedParameter return function (config) { var values = []; [ 'attachment', 'clip', 'color', 'image', 'origin', 'position', 'repeat', 'size' ].forEach(function (prop) { if (options.hasOwnProperty(prop)) { values.push(options[prop]); } }); if (values.length) { return [['background', values.join(' ')]]; } return []; }; }
[ "function", "background", "(", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "// ReSharper disable once UnusedParameter", "return", "function", "(", "config", ")", "{", "var", "values", "=", "[", "]", ";", "[", "'attachment'", ",", "'clip'", ",", "'color'", ",", "'image'", ",", "'origin'", ",", "'position'", ",", "'repeat'", ",", "'size'", "]", ".", "forEach", "(", "function", "(", "prop", ")", "{", "if", "(", "options", ".", "hasOwnProperty", "(", "prop", ")", ")", "{", "values", ".", "push", "(", "options", "[", "prop", "]", ")", ";", "}", "}", ")", ";", "if", "(", "values", ".", "length", ")", "{", "return", "[", "[", "'background'", ",", "values", ".", "join", "(", "' '", ")", "]", "]", ";", "}", "return", "[", "]", ";", "}", ";", "}" ]
ReSharper disable once UnusedLocals
[ "ReSharper", "disable", "once", "UnusedLocals" ]
f80fb591d33ee0cf063b6d6afae897e69ffcf407
https://github.com/jedmao/blink/blob/f80fb591d33ee0cf063b6d6afae897e69ffcf407/js/lib/overrides/background.js#L2-L26
36,768
WorldMobileCoin/wmcc-core
src/net/packets.js
PingPacket
function PingPacket(nonce) { if (!(this instanceof PingPacket)) return new PingPacket(nonce); Packet.call(this); this.nonce = nonce || null; }
javascript
function PingPacket(nonce) { if (!(this instanceof PingPacket)) return new PingPacket(nonce); Packet.call(this); this.nonce = nonce || null; }
[ "function", "PingPacket", "(", "nonce", ")", "{", "if", "(", "!", "(", "this", "instanceof", "PingPacket", ")", ")", "return", "new", "PingPacket", "(", "nonce", ")", ";", "Packet", ".", "call", "(", "this", ")", ";", "this", ".", "nonce", "=", "nonce", "||", "null", ";", "}" ]
Represents a `ping` packet. @constructor @param {BN?} nonce @property {BN|null} nonce
[ "Represents", "a", "ping", "packet", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/net/packets.js#L408-L415
36,769
WorldMobileCoin/wmcc-core
src/net/packets.js
PongPacket
function PongPacket(nonce) { if (!(this instanceof PongPacket)) return new PongPacket(nonce); Packet.call(this); this.nonce = nonce || encoding.ZERO_U64; }
javascript
function PongPacket(nonce) { if (!(this instanceof PongPacket)) return new PongPacket(nonce); Packet.call(this); this.nonce = nonce || encoding.ZERO_U64; }
[ "function", "PongPacket", "(", "nonce", ")", "{", "if", "(", "!", "(", "this", "instanceof", "PongPacket", ")", ")", "return", "new", "PongPacket", "(", "nonce", ")", ";", "Packet", ".", "call", "(", "this", ")", ";", "this", ".", "nonce", "=", "nonce", "||", "encoding", ".", "ZERO_U64", ";", "}" ]
Represents a `pong` packet. @constructor @param {BN?} nonce @property {BN} nonce
[ "Represents", "a", "pong", "packet", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/net/packets.js#L504-L511
36,770
WorldMobileCoin/wmcc-core
src/net/packets.js
GetBlocksPacket
function GetBlocksPacket(locator, stop) { if (!(this instanceof GetBlocksPacket)) return new GetBlocksPacket(locator, stop); Packet.call(this); this.version = common.PROTOCOL_VERSION; this.locator = locator || []; this.stop = stop || null; }
javascript
function GetBlocksPacket(locator, stop) { if (!(this instanceof GetBlocksPacket)) return new GetBlocksPacket(locator, stop); Packet.call(this); this.version = common.PROTOCOL_VERSION; this.locator = locator || []; this.stop = stop || null; }
[ "function", "GetBlocksPacket", "(", "locator", ",", "stop", ")", "{", "if", "(", "!", "(", "this", "instanceof", "GetBlocksPacket", ")", ")", "return", "new", "GetBlocksPacket", "(", "locator", ",", "stop", ")", ";", "Packet", ".", "call", "(", "this", ")", ";", "this", ".", "version", "=", "common", ".", "PROTOCOL_VERSION", ";", "this", ".", "locator", "=", "locator", "||", "[", "]", ";", "this", ".", "stop", "=", "stop", "||", "null", ";", "}" ]
Represents a `getblocks` packet. @constructor @param {Hash[]} locator @param {Hash?} stop @property {Hash[]} locator @property {Hash|null} stop
[ "Represents", "a", "getblocks", "packet", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/net/packets.js#L928-L937
36,771
WorldMobileCoin/wmcc-core
src/net/packets.js
GetHeadersPacket
function GetHeadersPacket(locator, stop) { if (!(this instanceof GetHeadersPacket)) return new GetHeadersPacket(locator, stop); GetBlocksPacket.call(this, locator, stop); }
javascript
function GetHeadersPacket(locator, stop) { if (!(this instanceof GetHeadersPacket)) return new GetHeadersPacket(locator, stop); GetBlocksPacket.call(this, locator, stop); }
[ "function", "GetHeadersPacket", "(", "locator", ",", "stop", ")", "{", "if", "(", "!", "(", "this", "instanceof", "GetHeadersPacket", ")", ")", "return", "new", "GetHeadersPacket", "(", "locator", ",", "stop", ")", ";", "GetBlocksPacket", ".", "call", "(", "this", ",", "locator", ",", "stop", ")", ";", "}" ]
Represents a `getheaders` packet. @extends GetBlocksPacket @constructor @param {Hash[]} locator @param {Hash?} stop
[ "Represents", "a", "getheaders", "packet", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/net/packets.js#L1042-L1047
36,772
WorldMobileCoin/wmcc-core
src/net/packets.js
BlockPacket
function BlockPacket(block, witness) { if (!(this instanceof BlockPacket)) return new BlockPacket(block, witness); Packet.call(this); this.block = block || new MemBlock(); this.witness = witness || false; }
javascript
function BlockPacket(block, witness) { if (!(this instanceof BlockPacket)) return new BlockPacket(block, witness); Packet.call(this); this.block = block || new MemBlock(); this.witness = witness || false; }
[ "function", "BlockPacket", "(", "block", ",", "witness", ")", "{", "if", "(", "!", "(", "this", "instanceof", "BlockPacket", ")", ")", "return", "new", "BlockPacket", "(", "block", ",", "witness", ")", ";", "Packet", ".", "call", "(", "this", ")", ";", "this", ".", "block", "=", "block", "||", "new", "MemBlock", "(", ")", ";", "this", ".", "witness", "=", "witness", "||", "false", ";", "}" ]
Represents a `block` packet. @constructor @param {Block|null} block @param {Boolean?} witness @property {Block} block @property {Boolean} witness
[ "Represents", "a", "block", "packet", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/net/packets.js#L1229-L1237
36,773
WorldMobileCoin/wmcc-core
src/net/packets.js
TXPacket
function TXPacket(tx, witness) { if (!(this instanceof TXPacket)) return new TXPacket(tx, witness); Packet.call(this); this.tx = tx || new TX(); this.witness = witness || false; }
javascript
function TXPacket(tx, witness) { if (!(this instanceof TXPacket)) return new TXPacket(tx, witness); Packet.call(this); this.tx = tx || new TX(); this.witness = witness || false; }
[ "function", "TXPacket", "(", "tx", ",", "witness", ")", "{", "if", "(", "!", "(", "this", "instanceof", "TXPacket", ")", ")", "return", "new", "TXPacket", "(", "tx", ",", "witness", ")", ";", "Packet", ".", "call", "(", "this", ")", ";", "this", ".", "tx", "=", "tx", "||", "new", "TX", "(", ")", ";", "this", ".", "witness", "=", "witness", "||", "false", ";", "}" ]
Represents a `tx` packet. @constructor @param {TX|null} tx @param {Boolean?} witness @property {TX} block @property {Boolean} witness
[ "Represents", "a", "tx", "packet", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/net/packets.js#L1331-L1339
36,774
WorldMobileCoin/wmcc-core
src/net/packets.js
FilterLoadPacket
function FilterLoadPacket(filter) { if (!(this instanceof FilterLoadPacket)) return new FilterLoadPacket(filter); Packet.call(this); this.filter = filter || new Bloom(); }
javascript
function FilterLoadPacket(filter) { if (!(this instanceof FilterLoadPacket)) return new FilterLoadPacket(filter); Packet.call(this); this.filter = filter || new Bloom(); }
[ "function", "FilterLoadPacket", "(", "filter", ")", "{", "if", "(", "!", "(", "this", "instanceof", "FilterLoadPacket", ")", ")", "return", "new", "FilterLoadPacket", "(", "filter", ")", ";", "Packet", ".", "call", "(", "this", ")", ";", "this", ".", "filter", "=", "filter", "||", "new", "Bloom", "(", ")", ";", "}" ]
Represents a `filterload` packet. @constructor @param {Bloom|null} filter
[ "Represents", "a", "filterload", "packet", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/net/packets.js#L1770-L1777
36,775
WorldMobileCoin/wmcc-core
src/net/packets.js
FilterAddPacket
function FilterAddPacket(data) { if (!(this instanceof FilterAddPacket)) return new FilterAddPacket(data); Packet.call(this); this.data = data || DUMMY; }
javascript
function FilterAddPacket(data) { if (!(this instanceof FilterAddPacket)) return new FilterAddPacket(data); Packet.call(this); this.data = data || DUMMY; }
[ "function", "FilterAddPacket", "(", "data", ")", "{", "if", "(", "!", "(", "this", "instanceof", "FilterAddPacket", ")", ")", "return", "new", "FilterAddPacket", "(", "data", ")", ";", "Packet", ".", "call", "(", "this", ")", ";", "this", ".", "data", "=", "data", "||", "DUMMY", ";", "}" ]
Represents a `filteradd` packet. @constructor @param {Buffer?} data @property {Buffer} data
[ "Represents", "a", "filteradd", "packet", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/net/packets.js#L1872-L1879
36,776
WorldMobileCoin/wmcc-core
src/net/packets.js
MerkleBlockPacket
function MerkleBlockPacket(block) { if (!(this instanceof MerkleBlockPacket)) return new MerkleBlockPacket(block); Packet.call(this); this.block = block || new MerkleBlock(); }
javascript
function MerkleBlockPacket(block) { if (!(this instanceof MerkleBlockPacket)) return new MerkleBlockPacket(block); Packet.call(this); this.block = block || new MerkleBlock(); }
[ "function", "MerkleBlockPacket", "(", "block", ")", "{", "if", "(", "!", "(", "this", "instanceof", "MerkleBlockPacket", ")", ")", "return", "new", "MerkleBlockPacket", "(", "block", ")", ";", "Packet", ".", "call", "(", "this", ")", ";", "this", ".", "block", "=", "block", "||", "new", "MerkleBlock", "(", ")", ";", "}" ]
Represents a `merkleblock` packet. @constructor @param {MerkleBlock?} block @property {MerkleBlock} block
[ "Represents", "a", "merkleblock", "packet", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/net/packets.js#L1986-L1993
36,777
WorldMobileCoin/wmcc-core
src/net/packets.js
SendCmpctPacket
function SendCmpctPacket(mode, version) { if (!(this instanceof SendCmpctPacket)) return new SendCmpctPacket(mode, version); Packet.call(this); this.mode = mode || 0; this.version = version || 1; }
javascript
function SendCmpctPacket(mode, version) { if (!(this instanceof SendCmpctPacket)) return new SendCmpctPacket(mode, version); Packet.call(this); this.mode = mode || 0; this.version = version || 1; }
[ "function", "SendCmpctPacket", "(", "mode", ",", "version", ")", "{", "if", "(", "!", "(", "this", "instanceof", "SendCmpctPacket", ")", ")", "return", "new", "SendCmpctPacket", "(", "mode", ",", "version", ")", ";", "Packet", ".", "call", "(", "this", ")", ";", "this", ".", "mode", "=", "mode", "||", "0", ";", "this", ".", "version", "=", "version", "||", "1", ";", "}" ]
Represents a `sendcmpct` packet. @constructor @param {Number|null} mode @param {Number|null} version @property {Number} mode @property {Number} version
[ "Represents", "a", "sendcmpct", "packet", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/net/packets.js#L2164-L2172
36,778
WorldMobileCoin/wmcc-core
src/net/packets.js
CmpctBlockPacket
function CmpctBlockPacket(block, witness) { if (!(this instanceof CmpctBlockPacket)) return new CmpctBlockPacket(block, witness); Packet.call(this); this.block = block || new bip152.CompactBlock(); this.witness = witness || false; }
javascript
function CmpctBlockPacket(block, witness) { if (!(this instanceof CmpctBlockPacket)) return new CmpctBlockPacket(block, witness); Packet.call(this); this.block = block || new bip152.CompactBlock(); this.witness = witness || false; }
[ "function", "CmpctBlockPacket", "(", "block", ",", "witness", ")", "{", "if", "(", "!", "(", "this", "instanceof", "CmpctBlockPacket", ")", ")", "return", "new", "CmpctBlockPacket", "(", "block", ",", "witness", ")", ";", "Packet", ".", "call", "(", "this", ")", ";", "this", ".", "block", "=", "block", "||", "new", "bip152", ".", "CompactBlock", "(", ")", ";", "this", ".", "witness", "=", "witness", "||", "false", ";", "}" ]
Represents a `cmpctblock` packet. @constructor @param {Block|null} block @param {Boolean|null} witness @property {Block} block @property {Boolean} witness
[ "Represents", "a", "cmpctblock", "packet", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/net/packets.js#L2272-L2280
36,779
WorldMobileCoin/wmcc-core
src/net/packets.js
GetBlockTxnPacket
function GetBlockTxnPacket(request) { if (!(this instanceof GetBlockTxnPacket)) return new GetBlockTxnPacket(request); Packet.call(this); this.request = request || new bip152.TXRequest(); }
javascript
function GetBlockTxnPacket(request) { if (!(this instanceof GetBlockTxnPacket)) return new GetBlockTxnPacket(request); Packet.call(this); this.request = request || new bip152.TXRequest(); }
[ "function", "GetBlockTxnPacket", "(", "request", ")", "{", "if", "(", "!", "(", "this", "instanceof", "GetBlockTxnPacket", ")", ")", "return", "new", "GetBlockTxnPacket", "(", "request", ")", ";", "Packet", ".", "call", "(", "this", ")", ";", "this", ".", "request", "=", "request", "||", "new", "bip152", ".", "TXRequest", "(", ")", ";", "}" ]
Represents a `getblocktxn` packet. @constructor @param {TXRequest?} request @property {TXRequest} request
[ "Represents", "a", "getblocktxn", "packet", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/net/packets.js#L2372-L2379
36,780
WorldMobileCoin/wmcc-core
src/net/packets.js
BlockTxnPacket
function BlockTxnPacket(response, witness) { if (!(this instanceof BlockTxnPacket)) return new BlockTxnPacket(response, witness); Packet.call(this); this.response = response || new bip152.TXResponse(); this.witness = witness || false; }
javascript
function BlockTxnPacket(response, witness) { if (!(this instanceof BlockTxnPacket)) return new BlockTxnPacket(response, witness); Packet.call(this); this.response = response || new bip152.TXResponse(); this.witness = witness || false; }
[ "function", "BlockTxnPacket", "(", "response", ",", "witness", ")", "{", "if", "(", "!", "(", "this", "instanceof", "BlockTxnPacket", ")", ")", "return", "new", "BlockTxnPacket", "(", "response", ",", "witness", ")", ";", "Packet", ".", "call", "(", "this", ")", ";", "this", ".", "response", "=", "response", "||", "new", "bip152", ".", "TXResponse", "(", ")", ";", "this", ".", "witness", "=", "witness", "||", "false", ";", "}" ]
Represents a `blocktxn` packet. @constructor @param {TXResponse?} response @param {Boolean?} witness @property {TXResponse} response @property {Boolean} witness
[ "Represents", "a", "blocktxn", "packet", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/net/packets.js#L2467-L2475
36,781
WorldMobileCoin/wmcc-core
src/net/packets.js
EncinitPacket
function EncinitPacket(publicKey, cipher) { if (!(this instanceof EncinitPacket)) return new EncinitPacket(publicKey, cipher); Packet.call(this); this.publicKey = publicKey || encoding.ZERO_KEY; this.cipher = cipher || 0; }
javascript
function EncinitPacket(publicKey, cipher) { if (!(this instanceof EncinitPacket)) return new EncinitPacket(publicKey, cipher); Packet.call(this); this.publicKey = publicKey || encoding.ZERO_KEY; this.cipher = cipher || 0; }
[ "function", "EncinitPacket", "(", "publicKey", ",", "cipher", ")", "{", "if", "(", "!", "(", "this", "instanceof", "EncinitPacket", ")", ")", "return", "new", "EncinitPacket", "(", "publicKey", ",", "cipher", ")", ";", "Packet", ".", "call", "(", "this", ")", ";", "this", ".", "publicKey", "=", "publicKey", "||", "encoding", ".", "ZERO_KEY", ";", "this", ".", "cipher", "=", "cipher", "||", "0", ";", "}" ]
Represents a `encinit` packet. @constructor @param {Buffer|null} publicKey @param {Number|null} cipher @property {Buffer} publicKey @property {Number} cipher
[ "Represents", "a", "encinit", "packet", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/net/packets.js#L2569-L2577
36,782
WorldMobileCoin/wmcc-core
src/net/packets.js
EncackPacket
function EncackPacket(publicKey) { if (!(this instanceof EncackPacket)) return new EncackPacket(publicKey); Packet.call(this); this.publicKey = publicKey || encoding.ZERO_KEY; }
javascript
function EncackPacket(publicKey) { if (!(this instanceof EncackPacket)) return new EncackPacket(publicKey); Packet.call(this); this.publicKey = publicKey || encoding.ZERO_KEY; }
[ "function", "EncackPacket", "(", "publicKey", ")", "{", "if", "(", "!", "(", "this", "instanceof", "EncackPacket", ")", ")", "return", "new", "EncackPacket", "(", "publicKey", ")", ";", "Packet", ".", "call", "(", "this", ")", ";", "this", ".", "publicKey", "=", "publicKey", "||", "encoding", ".", "ZERO_KEY", ";", "}" ]
Represents a `encack` packet. @constructor @param {Buffer?} publicKey @property {Buffer} publicKey
[ "Represents", "a", "encack", "packet", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/net/packets.js#L2665-L2672
36,783
WorldMobileCoin/wmcc-core
src/net/packets.js
AuthChallengePacket
function AuthChallengePacket(hash) { if (!(this instanceof AuthChallengePacket)) return new AuthChallengePacket(hash); Packet.call(this); this.hash = hash || encoding.ZERO_HASH; }
javascript
function AuthChallengePacket(hash) { if (!(this instanceof AuthChallengePacket)) return new AuthChallengePacket(hash); Packet.call(this); this.hash = hash || encoding.ZERO_HASH; }
[ "function", "AuthChallengePacket", "(", "hash", ")", "{", "if", "(", "!", "(", "this", "instanceof", "AuthChallengePacket", ")", ")", "return", "new", "AuthChallengePacket", "(", "hash", ")", ";", "Packet", ".", "call", "(", "this", ")", ";", "this", ".", "hash", "=", "hash", "||", "encoding", ".", "ZERO_HASH", ";", "}" ]
Represents a `authchallenge` packet. @constructor @param {Buffer?} hash @property {Buffer} hash
[ "Represents", "a", "authchallenge", "packet", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/net/packets.js#L2758-L2765
36,784
WorldMobileCoin/wmcc-core
src/net/packets.js
AuthReplyPacket
function AuthReplyPacket(signature) { if (!(this instanceof AuthReplyPacket)) return new AuthReplyPacket(signature); Packet.call(this); this.signature = signature || encoding.ZERO_SIG64; }
javascript
function AuthReplyPacket(signature) { if (!(this instanceof AuthReplyPacket)) return new AuthReplyPacket(signature); Packet.call(this); this.signature = signature || encoding.ZERO_SIG64; }
[ "function", "AuthReplyPacket", "(", "signature", ")", "{", "if", "(", "!", "(", "this", "instanceof", "AuthReplyPacket", ")", ")", "return", "new", "AuthReplyPacket", "(", "signature", ")", ";", "Packet", ".", "call", "(", "this", ")", ";", "this", ".", "signature", "=", "signature", "||", "encoding", ".", "ZERO_SIG64", ";", "}" ]
Represents a `authreply` packet. @constructor @param {Buffer?} signature @property {Buffer} signature
[ "Represents", "a", "authreply", "packet", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/net/packets.js#L2851-L2858
36,785
WorldMobileCoin/wmcc-core
src/net/packets.js
AuthProposePacket
function AuthProposePacket(hash) { if (!(this instanceof AuthProposePacket)) return new AuthProposePacket(hash); Packet.call(this); this.hash = hash || encoding.ZERO_HASH; }
javascript
function AuthProposePacket(hash) { if (!(this instanceof AuthProposePacket)) return new AuthProposePacket(hash); Packet.call(this); this.hash = hash || encoding.ZERO_HASH; }
[ "function", "AuthProposePacket", "(", "hash", ")", "{", "if", "(", "!", "(", "this", "instanceof", "AuthProposePacket", ")", ")", "return", "new", "AuthProposePacket", "(", "hash", ")", ";", "Packet", ".", "call", "(", "this", ")", ";", "this", ".", "hash", "=", "hash", "||", "encoding", ".", "ZERO_HASH", ";", "}" ]
Represents a `authpropose` packet. @constructor @param {Hash?} hash @property {Hash} hash
[ "Represents", "a", "authpropose", "packet", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/net/packets.js#L2944-L2951
36,786
WorldMobileCoin/wmcc-core
src/net/packets.js
UnknownPacket
function UnknownPacket(cmd, data) { if (!(this instanceof UnknownPacket)) return new UnknownPacket(cmd, data); Packet.call(this); this.cmd = cmd; this.data = data; }
javascript
function UnknownPacket(cmd, data) { if (!(this instanceof UnknownPacket)) return new UnknownPacket(cmd, data); Packet.call(this); this.cmd = cmd; this.data = data; }
[ "function", "UnknownPacket", "(", "cmd", ",", "data", ")", "{", "if", "(", "!", "(", "this", "instanceof", "UnknownPacket", ")", ")", "return", "new", "UnknownPacket", "(", "cmd", ",", "data", ")", ";", "Packet", ".", "call", "(", "this", ")", ";", "this", ".", "cmd", "=", "cmd", ";", "this", ".", "data", "=", "data", ";", "}" ]
Represents an unknown packet. @constructor @param {String|null} cmd @param {Buffer|null} data @property {String} cmd @property {Buffer} data
[ "Represents", "an", "unknown", "packet", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/net/packets.js#L3039-L3047
36,787
WorldMobileCoin/wmcc-core
src/script/sigcache.js
SigCache
function SigCache(size) { if (!(this instanceof SigCache)) return new SigCache(size); if (size == null) size = 10000; assert(util.isU32(size)); this.size = size; this.keys = []; this.valid = new Map(); }
javascript
function SigCache(size) { if (!(this instanceof SigCache)) return new SigCache(size); if (size == null) size = 10000; assert(util.isU32(size)); this.size = size; this.keys = []; this.valid = new Map(); }
[ "function", "SigCache", "(", "size", ")", "{", "if", "(", "!", "(", "this", "instanceof", "SigCache", ")", ")", "return", "new", "SigCache", "(", "size", ")", ";", "if", "(", "size", "==", "null", ")", "size", "=", "10000", ";", "assert", "(", "util", ".", "isU32", "(", "size", ")", ")", ";", "this", ".", "size", "=", "size", ";", "this", ".", "keys", "=", "[", "]", ";", "this", ".", "valid", "=", "new", "Map", "(", ")", ";", "}" ]
Signature cache. @alias module:script.SigCache @constructor @param {Number} [size=10000] @property {Number} size @property {Hash[]} keys @property {Object} valid
[ "Signature", "cache", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/script/sigcache.js#L27-L39
36,788
WorldMobileCoin/wmcc-core
src/script/sigcache.js
SigCacheEntry
function SigCacheEntry(sig, key) { this.sig = Buffer.from(sig); this.key = Buffer.from(key); }
javascript
function SigCacheEntry(sig, key) { this.sig = Buffer.from(sig); this.key = Buffer.from(key); }
[ "function", "SigCacheEntry", "(", "sig", ",", "key", ")", "{", "this", ".", "sig", "=", "Buffer", ".", "from", "(", "sig", ")", ";", "this", ".", "key", "=", "Buffer", ".", "from", "(", "key", ")", ";", "}" ]
Signature cache entry. @constructor @ignore @param {Buffer} sig @param {Buffer} key @property {Buffer} sig @property {Buffer} key
[ "Signature", "cache", "entry", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/script/sigcache.js#L133-L136
36,789
blakeembrey/kroute
lib/proto.js
sanitize
function sanitize (fn) { return function (/* path, ...middleware */) { var middleware = [] var startindex = 0 var endindex = arguments.length var path var options if (typeof arguments[0] === 'string') { path = arguments[0] startindex = 1 } if (typeof arguments[arguments.length - 1] === 'object') { endindex = arguments.length - 1 options = arguments[endindex] } // Concat all the middleware functions. for (var i = startindex; i < endindex; i++) { middleware.push(arguments[i]) } middleware = flatten(middleware) if (middleware.length === 0) { throw new TypeError('Expected a function but got no arguments') } if (middleware.length === 1) { middleware = middleware[0] } else { middleware = compose(middleware) } fn.call(this, path, middleware, extend({}, this._options, options)) return this } }
javascript
function sanitize (fn) { return function (/* path, ...middleware */) { var middleware = [] var startindex = 0 var endindex = arguments.length var path var options if (typeof arguments[0] === 'string') { path = arguments[0] startindex = 1 } if (typeof arguments[arguments.length - 1] === 'object') { endindex = arguments.length - 1 options = arguments[endindex] } // Concat all the middleware functions. for (var i = startindex; i < endindex; i++) { middleware.push(arguments[i]) } middleware = flatten(middleware) if (middleware.length === 0) { throw new TypeError('Expected a function but got no arguments') } if (middleware.length === 1) { middleware = middleware[0] } else { middleware = compose(middleware) } fn.call(this, path, middleware, extend({}, this._options, options)) return this } }
[ "function", "sanitize", "(", "fn", ")", "{", "return", "function", "(", "/* path, ...middleware */", ")", "{", "var", "middleware", "=", "[", "]", "var", "startindex", "=", "0", "var", "endindex", "=", "arguments", ".", "length", "var", "path", "var", "options", "if", "(", "typeof", "arguments", "[", "0", "]", "===", "'string'", ")", "{", "path", "=", "arguments", "[", "0", "]", "startindex", "=", "1", "}", "if", "(", "typeof", "arguments", "[", "arguments", ".", "length", "-", "1", "]", "===", "'object'", ")", "{", "endindex", "=", "arguments", ".", "length", "-", "1", "options", "=", "arguments", "[", "endindex", "]", "}", "// Concat all the middleware functions.", "for", "(", "var", "i", "=", "startindex", ";", "i", "<", "endindex", ";", "i", "++", ")", "{", "middleware", ".", "push", "(", "arguments", "[", "i", "]", ")", "}", "middleware", "=", "flatten", "(", "middleware", ")", "if", "(", "middleware", ".", "length", "===", "0", ")", "{", "throw", "new", "TypeError", "(", "'Expected a function but got no arguments'", ")", "}", "if", "(", "middleware", ".", "length", "===", "1", ")", "{", "middleware", "=", "middleware", "[", "0", "]", "}", "else", "{", "middleware", "=", "compose", "(", "middleware", ")", "}", "fn", ".", "call", "(", "this", ",", "path", ",", "middleware", ",", "extend", "(", "{", "}", ",", "this", ".", "_options", ",", "options", ")", ")", "return", "this", "}", "}" ]
Sanitize a function to accept an optional path and unlimited middleware. @param {Function} fn @return {Function}
[ "Sanitize", "a", "function", "to", "accept", "an", "optional", "path", "and", "unlimited", "middleware", "." ]
b39f76fb6402e257a8b4d6b26b6511d16fa22871
https://github.com/blakeembrey/kroute/blob/b39f76fb6402e257a8b4d6b26b6511d16fa22871/lib/proto.js#L22-L61
36,790
WorldMobileCoin/wmcc-core
src/utils/rbt.js
RBT
function RBT(compare, unique) { if (!(this instanceof RBT)) return new RBT(compare, unique); assert(typeof compare === 'function'); this.root = SENTINEL; this.compare = compare; this.unique = unique || false; }
javascript
function RBT(compare, unique) { if (!(this instanceof RBT)) return new RBT(compare, unique); assert(typeof compare === 'function'); this.root = SENTINEL; this.compare = compare; this.unique = unique || false; }
[ "function", "RBT", "(", "compare", ",", "unique", ")", "{", "if", "(", "!", "(", "this", "instanceof", "RBT", ")", ")", "return", "new", "RBT", "(", "compare", ",", "unique", ")", ";", "assert", "(", "typeof", "compare", "===", "'function'", ")", ";", "this", ".", "root", "=", "SENTINEL", ";", "this", ".", "compare", "=", "compare", ";", "this", ".", "unique", "=", "unique", "||", "false", ";", "}" ]
An iterative red black tree. @alias module:utils.RBT @constructor @param {Function} compare - Comparator. @param {Boolean?} unique
[ "An", "iterative", "red", "black", "tree", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/utils/rbt.js#L26-L35
36,791
WorldMobileCoin/wmcc-core
src/utils/rbt.js
RBTSentinel
function RBTSentinel() { this.key = null; this.value = null; this.color = BLACK; this.parent = null; this.left = null; this.right = null; }
javascript
function RBTSentinel() { this.key = null; this.value = null; this.color = BLACK; this.parent = null; this.left = null; this.right = null; }
[ "function", "RBTSentinel", "(", ")", "{", "this", ".", "key", "=", "null", ";", "this", ".", "value", "=", "null", ";", "this", ".", "color", "=", "BLACK", ";", "this", ".", "parent", "=", "null", ";", "this", ".", "left", "=", "null", ";", "this", ".", "right", "=", "null", ";", "}" ]
RBT Sentinel Node @constructor @ignore @property {null} key @property {null} value @property {Number} [color=BLACK] @property {null} parent @property {null} left @property {null} right
[ "RBT", "Sentinel", "Node" ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/utils/rbt.js#L820-L827
36,792
gsdriver/blackjack-strategy
src/ExactComposition.js
function (playerCards, dealerCard, handValue, handCount, dealerCheckedBlackjack, options) { // If exactComposition isn't set, no override if (options.strategyComplexity != "exactComposition") { return null; } // Now look at strategies based on game options if ((options.numberOfDecks == 2) && (!options.hitSoft17)) { return TwoDeckStandSoft17(playerCards, dealerCard, handValue, handCount, dealerCheckedBlackjack, options); } }
javascript
function (playerCards, dealerCard, handValue, handCount, dealerCheckedBlackjack, options) { // If exactComposition isn't set, no override if (options.strategyComplexity != "exactComposition") { return null; } // Now look at strategies based on game options if ((options.numberOfDecks == 2) && (!options.hitSoft17)) { return TwoDeckStandSoft17(playerCards, dealerCard, handValue, handCount, dealerCheckedBlackjack, options); } }
[ "function", "(", "playerCards", ",", "dealerCard", ",", "handValue", ",", "handCount", ",", "dealerCheckedBlackjack", ",", "options", ")", "{", "// If exactComposition isn't set, no override", "if", "(", "options", ".", "strategyComplexity", "!=", "\"exactComposition\"", ")", "{", "return", "null", ";", "}", "// Now look at strategies based on game options", "if", "(", "(", "options", ".", "numberOfDecks", "==", "2", ")", "&&", "(", "!", "options", ".", "hitSoft17", ")", ")", "{", "return", "TwoDeckStandSoft17", "(", "playerCards", ",", "dealerCard", ",", "handValue", ",", "handCount", ",", "dealerCheckedBlackjack", ",", "options", ")", ";", "}", "}" ]
Special-case overrides based on exact composition of cards
[ "Special", "-", "case", "overrides", "based", "on", "exact", "composition", "of", "cards" ]
dfcb976ab9bb33c74c24c9bacf369e8ffb6506f3
https://github.com/gsdriver/blackjack-strategy/blob/dfcb976ab9bb33c74c24c9bacf369e8ffb6506f3/src/ExactComposition.js#L27-L40
36,793
eccentric-j/cli-glob
lib/index.js
globcmd
function globcmd(globstr) { var dir = arguments.length <= 1 || arguments[1] === undefined ? process.cwd() : arguments[1]; return new Promise(function (resolve, reject) { if (!globstr || !globstr.length) { return reject(new Error('No glob string given.')); } // Use glob to read the files in the dir (0, _glob2.default)(String(globstr), { cwd: dir }, function (err, files) { if (err) return reject(err); // Files if (files.length === 0) { reject(new Error('No files match the glob string "' + globstr + '"')); } // Append the matching file to an array resolve(files.map(function (filename) { return { path: _path2.default.resolve(dir, filename), relative: _path2.default.relative(dir, filename) }; })); }); }); }
javascript
function globcmd(globstr) { var dir = arguments.length <= 1 || arguments[1] === undefined ? process.cwd() : arguments[1]; return new Promise(function (resolve, reject) { if (!globstr || !globstr.length) { return reject(new Error('No glob string given.')); } // Use glob to read the files in the dir (0, _glob2.default)(String(globstr), { cwd: dir }, function (err, files) { if (err) return reject(err); // Files if (files.length === 0) { reject(new Error('No files match the glob string "' + globstr + '"')); } // Append the matching file to an array resolve(files.map(function (filename) { return { path: _path2.default.resolve(dir, filename), relative: _path2.default.relative(dir, filename) }; })); }); }); }
[ "function", "globcmd", "(", "globstr", ")", "{", "var", "dir", "=", "arguments", ".", "length", "<=", "1", "||", "arguments", "[", "1", "]", "===", "undefined", "?", "process", ".", "cwd", "(", ")", ":", "arguments", "[", "1", "]", ";", "return", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "if", "(", "!", "globstr", "||", "!", "globstr", ".", "length", ")", "{", "return", "reject", "(", "new", "Error", "(", "'No glob string given.'", ")", ")", ";", "}", "// Use glob to read the files in the dir", "(", "0", ",", "_glob2", ".", "default", ")", "(", "String", "(", "globstr", ")", ",", "{", "cwd", ":", "dir", "}", ",", "function", "(", "err", ",", "files", ")", "{", "if", "(", "err", ")", "return", "reject", "(", "err", ")", ";", "// Files", "if", "(", "files", ".", "length", "===", "0", ")", "{", "reject", "(", "new", "Error", "(", "'No files match the glob string \"'", "+", "globstr", "+", "'\"'", ")", ")", ";", "}", "// Append the matching file to an array", "resolve", "(", "files", ".", "map", "(", "function", "(", "filename", ")", "{", "return", "{", "path", ":", "_path2", ".", "default", ".", "resolve", "(", "dir", ",", "filename", ")", ",", "relative", ":", "_path2", ".", "default", ".", "relative", "(", "dir", ",", "filename", ")", "}", ";", "}", ")", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
Globcmd Returns a promise that will be resolved with an array of files @param {string} globstr - Glob str to look for @param {string} [dir=process.cwd()] - Root directory @returns {Promise} A promise object to be resolved with an array of files or rejected with an error.
[ "Globcmd", "Returns", "a", "promise", "that", "will", "be", "resolved", "with", "an", "array", "of", "files" ]
a2f5bfdb29e1ccac6a93c509ca1f9172c06939a4
https://github.com/eccentric-j/cli-glob/blob/a2f5bfdb29e1ccac6a93c509ca1f9172c06939a4/lib/index.js#L31-L57
36,794
Spiffyk/twitch-node-sdk
lib/twitch.init.js
init
function init(options, callback) { if (!options.clientId) { throw new Error('client id not specified'); } core.setClientId(options.clientId); if (options.nw) { if (options.nw === true) { core.log('NW.js 0.13 is experimental.'); gui.setGUIType('nw13'); } else { gui.setGUIType('nw', options.nw); } } else if (options.electron) { gui.setGUIType('electron'); } auth.initSession(options.session, callback); }
javascript
function init(options, callback) { if (!options.clientId) { throw new Error('client id not specified'); } core.setClientId(options.clientId); if (options.nw) { if (options.nw === true) { core.log('NW.js 0.13 is experimental.'); gui.setGUIType('nw13'); } else { gui.setGUIType('nw', options.nw); } } else if (options.electron) { gui.setGUIType('electron'); } auth.initSession(options.session, callback); }
[ "function", "init", "(", "options", ",", "callback", ")", "{", "if", "(", "!", "options", ".", "clientId", ")", "{", "throw", "new", "Error", "(", "'client id not specified'", ")", ";", "}", "core", ".", "setClientId", "(", "options", ".", "clientId", ")", ";", "if", "(", "options", ".", "nw", ")", "{", "if", "(", "options", ".", "nw", "===", "true", ")", "{", "core", ".", "log", "(", "'NW.js 0.13 is experimental.'", ")", ";", "gui", ".", "setGUIType", "(", "'nw13'", ")", ";", "}", "else", "{", "gui", ".", "setGUIType", "(", "'nw'", ",", "options", ".", "nw", ")", ";", "}", "}", "else", "if", "(", "options", ".", "electron", ")", "{", "gui", ".", "setGUIType", "(", "'electron'", ")", ";", "}", "auth", ".", "initSession", "(", "options", ".", "session", ",", "callback", ")", ";", "}" ]
Initializes the SDK. The `options` parameter can have the following properties (optional if not stated otherwise): * `clientId` (**required**) - The client ID of your application * `session` - If your application has stored the session object somewhere, you can pass it to the SDK to speed up the login process. * `electron` - `true` if **Electron** is used. * `nw` - `true` if **NW.js v0.13 or higher** is used. If you use **NW.js v0.12 or lower**, set to the object you get by calling `require('nw.gui')` @method init @param {Object} options Options to initialize the SDK with @param {function} [callback] The callback to run after the SDK is initialized. @memberof Twitch
[ "Initializes", "the", "SDK", "." ]
e98234ca52b12569298213869439d17169e26f27
https://github.com/Spiffyk/twitch-node-sdk/blob/e98234ca52b12569298213869439d17169e26f27/lib/twitch.init.js#L31-L52
36,795
WorldMobileCoin/wmcc-core
src/mining/mine.js
mine
function mine(data, target, min, max) { let nonce = min; data.writeUInt32LE(nonce, 76, true); // The heart and soul of the miner: match the target. while (nonce <= max) { // Hash and test against the next target. // if (rcmp(digest.hash256(data), target) <= 0) // cfc // if (rcmp(powHash(data), target) <= 0) // ctl if (rcmp(calHash(data), target) <= 0) return nonce; // Increment the nonce to get a different hash. nonce++; // Update the raw buffer. data.writeUInt32LE(nonce, 76, true); } return -1; }
javascript
function mine(data, target, min, max) { let nonce = min; data.writeUInt32LE(nonce, 76, true); // The heart and soul of the miner: match the target. while (nonce <= max) { // Hash and test against the next target. // if (rcmp(digest.hash256(data), target) <= 0) // cfc // if (rcmp(powHash(data), target) <= 0) // ctl if (rcmp(calHash(data), target) <= 0) return nonce; // Increment the nonce to get a different hash. nonce++; // Update the raw buffer. data.writeUInt32LE(nonce, 76, true); } return -1; }
[ "function", "mine", "(", "data", ",", "target", ",", "min", ",", "max", ")", "{", "let", "nonce", "=", "min", ";", "data", ".", "writeUInt32LE", "(", "nonce", ",", "76", ",", "true", ")", ";", "// The heart and soul of the miner: match the target.", "while", "(", "nonce", "<=", "max", ")", "{", "// Hash and test against the next target.", "// if (rcmp(digest.hash256(data), target) <= 0) // cfc", "// if (rcmp(powHash(data), target) <= 0) // ctl", "if", "(", "rcmp", "(", "calHash", "(", "data", ")", ",", "target", ")", "<=", "0", ")", "return", "nonce", ";", "// Increment the nonce to get a different hash.", "nonce", "++", ";", "// Update the raw buffer.", "data", ".", "writeUInt32LE", "(", "nonce", ",", "76", ",", "true", ")", ";", "}", "return", "-", "1", ";", "}" ]
Hash until the nonce overflows. @alias module:mining.mine @param {Buffer} data @param {Buffer} target - Big endian. @param {Number} min @param {Number} max @returns {Number} Nonce or -1.
[ "Hash", "until", "the", "nonce", "overflows", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/mining/mine.js#L28-L49
36,796
WorldMobileCoin/wmcc-core
src/bip70/payment.js
Payment
function Payment(options) { if (!(this instanceof Payment)) return new Payment(options); this.merchantData = null; this.transactions = []; this.refundTo = []; this.memo = null; if (options) this.fromOptions(options); }
javascript
function Payment(options) { if (!(this instanceof Payment)) return new Payment(options); this.merchantData = null; this.transactions = []; this.refundTo = []; this.memo = null; if (options) this.fromOptions(options); }
[ "function", "Payment", "(", "options", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Payment", ")", ")", "return", "new", "Payment", "(", "options", ")", ";", "this", ".", "merchantData", "=", "null", ";", "this", ".", "transactions", "=", "[", "]", ";", "this", ".", "refundTo", "=", "[", "]", ";", "this", ".", "memo", "=", "null", ";", "if", "(", "options", ")", "this", ".", "fromOptions", "(", "options", ")", ";", "}" ]
Represents a BIP70 payment. @alias module:bip70.Payment @constructor @param {Object?} options @property {Buffer} merchantData @property {TX[]} transactions @property {Output[]} refundTo @property {String|null} memo
[ "Represents", "a", "BIP70", "payment", "." ]
29c3759a175341cedae6b744c53eda628c669317
https://github.com/WorldMobileCoin/wmcc-core/blob/29c3759a175341cedae6b744c53eda628c669317/src/bip70/payment.js#L32-L43
36,797
ahtohbi4/postcss-bgimage
src/isNodeIgnored.js
isNodeIgnored
function isNodeIgnored(node) { const parent = node.parent; if (!parent) { // Root was reached. return false; } if (parent.some((child) => (child.type === 'comment' && PATTERN_IGNORE.test(child.text)))) { // Instruction to ignore the node was detected. return true; } // Check the instruction on one level above. return isNodeIgnored(parent); }
javascript
function isNodeIgnored(node) { const parent = node.parent; if (!parent) { // Root was reached. return false; } if (parent.some((child) => (child.type === 'comment' && PATTERN_IGNORE.test(child.text)))) { // Instruction to ignore the node was detected. return true; } // Check the instruction on one level above. return isNodeIgnored(parent); }
[ "function", "isNodeIgnored", "(", "node", ")", "{", "const", "parent", "=", "node", ".", "parent", ";", "if", "(", "!", "parent", ")", "{", "// Root was reached.", "return", "false", ";", "}", "if", "(", "parent", ".", "some", "(", "(", "child", ")", "=>", "(", "child", ".", "type", "===", "'comment'", "&&", "PATTERN_IGNORE", ".", "test", "(", "child", ".", "text", ")", ")", ")", ")", "{", "// Instruction to ignore the node was detected.", "return", "true", ";", "}", "// Check the instruction on one level above.", "return", "isNodeIgnored", "(", "parent", ")", ";", "}" ]
Check instruction to ignore the node. @param {Node} node @return {boolean}
[ "Check", "instruction", "to", "ignore", "the", "node", "." ]
b955c9f0aa0e24e57b17825c9aaec3016ef3b715
https://github.com/ahtohbi4/postcss-bgimage/blob/b955c9f0aa0e24e57b17825c9aaec3016ef3b715/src/isNodeIgnored.js#L8-L23
36,798
bunnybones1/threejs-light-probe
lib/three.js
function ( contour, indices ) { var n = contour.length; if ( n < 3 ) return null; var result = [], verts = [], vertIndices = []; /* we want a counter-clockwise polygon in verts */ var u, v, w; if ( area( contour ) > 0.0 ) { for ( v = 0; v < n; v ++ ) verts[ v ] = v; } else { for ( v = 0; v < n; v ++ ) verts[ v ] = ( n - 1 ) - v; } var nv = n; /* remove nv - 2 vertices, creating 1 triangle every time */ var count = 2 * nv; /* error detection */ for ( v = nv - 1; nv > 2; ) { /* if we loop, it is probably a non-simple polygon */ if ( ( count -- ) <= 0 ) { //** Triangulate: ERROR - probable bad polygon! //throw ( "Warning, unable to triangulate polygon!" ); //return null; // Sometimes warning is fine, especially polygons are triangulated in reverse. console.log( 'Warning, unable to triangulate polygon!' ); if ( indices ) return vertIndices; return result; } /* three consecutive vertices in current polygon, <u,v,w> */ u = v; if ( nv <= u ) u = 0; /* previous */ v = u + 1; if ( nv <= v ) v = 0; /* new v */ w = v + 1; if ( nv <= w ) w = 0; /* next */ if ( snip( contour, u, v, w, nv, verts ) ) { var a, b, c, s, t; /* true names of the vertices */ a = verts[ u ]; b = verts[ v ]; c = verts[ w ]; /* output Triangle */ result.push( [ contour[ a ], contour[ b ], contour[ c ] ] ); vertIndices.push( [ verts[ u ], verts[ v ], verts[ w ] ] ); /* remove v from the remaining polygon */ for ( s = v, t = v + 1; t < nv; s++, t++ ) { verts[ s ] = verts[ t ]; } nv --; /* reset error detection counter */ count = 2 * nv; } } if ( indices ) return vertIndices; return result; }
javascript
function ( contour, indices ) { var n = contour.length; if ( n < 3 ) return null; var result = [], verts = [], vertIndices = []; /* we want a counter-clockwise polygon in verts */ var u, v, w; if ( area( contour ) > 0.0 ) { for ( v = 0; v < n; v ++ ) verts[ v ] = v; } else { for ( v = 0; v < n; v ++ ) verts[ v ] = ( n - 1 ) - v; } var nv = n; /* remove nv - 2 vertices, creating 1 triangle every time */ var count = 2 * nv; /* error detection */ for ( v = nv - 1; nv > 2; ) { /* if we loop, it is probably a non-simple polygon */ if ( ( count -- ) <= 0 ) { //** Triangulate: ERROR - probable bad polygon! //throw ( "Warning, unable to triangulate polygon!" ); //return null; // Sometimes warning is fine, especially polygons are triangulated in reverse. console.log( 'Warning, unable to triangulate polygon!' ); if ( indices ) return vertIndices; return result; } /* three consecutive vertices in current polygon, <u,v,w> */ u = v; if ( nv <= u ) u = 0; /* previous */ v = u + 1; if ( nv <= v ) v = 0; /* new v */ w = v + 1; if ( nv <= w ) w = 0; /* next */ if ( snip( contour, u, v, w, nv, verts ) ) { var a, b, c, s, t; /* true names of the vertices */ a = verts[ u ]; b = verts[ v ]; c = verts[ w ]; /* output Triangle */ result.push( [ contour[ a ], contour[ b ], contour[ c ] ] ); vertIndices.push( [ verts[ u ], verts[ v ], verts[ w ] ] ); /* remove v from the remaining polygon */ for ( s = v, t = v + 1; t < nv; s++, t++ ) { verts[ s ] = verts[ t ]; } nv --; /* reset error detection counter */ count = 2 * nv; } } if ( indices ) return vertIndices; return result; }
[ "function", "(", "contour", ",", "indices", ")", "{", "var", "n", "=", "contour", ".", "length", ";", "if", "(", "n", "<", "3", ")", "return", "null", ";", "var", "result", "=", "[", "]", ",", "verts", "=", "[", "]", ",", "vertIndices", "=", "[", "]", ";", "/* we want a counter-clockwise polygon in verts */", "var", "u", ",", "v", ",", "w", ";", "if", "(", "area", "(", "contour", ")", ">", "0.0", ")", "{", "for", "(", "v", "=", "0", ";", "v", "<", "n", ";", "v", "++", ")", "verts", "[", "v", "]", "=", "v", ";", "}", "else", "{", "for", "(", "v", "=", "0", ";", "v", "<", "n", ";", "v", "++", ")", "verts", "[", "v", "]", "=", "(", "n", "-", "1", ")", "-", "v", ";", "}", "var", "nv", "=", "n", ";", "/* remove nv - 2 vertices, creating 1 triangle every time */", "var", "count", "=", "2", "*", "nv", ";", "/* error detection */", "for", "(", "v", "=", "nv", "-", "1", ";", "nv", ">", "2", ";", ")", "{", "/* if we loop, it is probably a non-simple polygon */", "if", "(", "(", "count", "--", ")", "<=", "0", ")", "{", "//** Triangulate: ERROR - probable bad polygon!", "//throw ( \"Warning, unable to triangulate polygon!\" );", "//return null;", "// Sometimes warning is fine, especially polygons are triangulated in reverse.", "console", ".", "log", "(", "'Warning, unable to triangulate polygon!'", ")", ";", "if", "(", "indices", ")", "return", "vertIndices", ";", "return", "result", ";", "}", "/* three consecutive vertices in current polygon, <u,v,w> */", "u", "=", "v", ";", "if", "(", "nv", "<=", "u", ")", "u", "=", "0", ";", "/* previous */", "v", "=", "u", "+", "1", ";", "if", "(", "nv", "<=", "v", ")", "v", "=", "0", ";", "/* new v */", "w", "=", "v", "+", "1", ";", "if", "(", "nv", "<=", "w", ")", "w", "=", "0", ";", "/* next */", "if", "(", "snip", "(", "contour", ",", "u", ",", "v", ",", "w", ",", "nv", ",", "verts", ")", ")", "{", "var", "a", ",", "b", ",", "c", ",", "s", ",", "t", ";", "/* true names of the vertices */", "a", "=", "verts", "[", "u", "]", ";", "b", "=", "verts", "[", "v", "]", ";", "c", "=", "verts", "[", "w", "]", ";", "/* output Triangle */", "result", ".", "push", "(", "[", "contour", "[", "a", "]", ",", "contour", "[", "b", "]", ",", "contour", "[", "c", "]", "]", ")", ";", "vertIndices", ".", "push", "(", "[", "verts", "[", "u", "]", ",", "verts", "[", "v", "]", ",", "verts", "[", "w", "]", "]", ")", ";", "/* remove v from the remaining polygon */", "for", "(", "s", "=", "v", ",", "t", "=", "v", "+", "1", ";", "t", "<", "nv", ";", "s", "++", ",", "t", "++", ")", "{", "verts", "[", "s", "]", "=", "verts", "[", "t", "]", ";", "}", "nv", "--", ";", "/* reset error detection counter */", "count", "=", "2", "*", "nv", ";", "}", "}", "if", "(", "indices", ")", "return", "vertIndices", ";", "return", "result", ";", "}" ]
takes in an contour array and returns
[ "takes", "in", "an", "contour", "array", "and", "returns" ]
1d74986ef4477cb7c2d667522855c04cbc0edcb0
https://github.com/bunnybones1/threejs-light-probe/blob/1d74986ef4477cb7c2d667522855c04cbc0edcb0/lib/three.js#L26695-L26789
36,799
ucd-cws/calvin-network-tools
nodejs/pri/debugger/parser.js
parseNode
function parseNode(line) { current = { is : 'NODE', type : 'NODE', id : line.substr(10, 10).trim().toLowerCase(), initialStorage : line.substr(20, 10).trim(), areaCapfactor : line.substr(30, 10).trim(), endingStorage : line.substr(40, 10).trim() }; }
javascript
function parseNode(line) { current = { is : 'NODE', type : 'NODE', id : line.substr(10, 10).trim().toLowerCase(), initialStorage : line.substr(20, 10).trim(), areaCapfactor : line.substr(30, 10).trim(), endingStorage : line.substr(40, 10).trim() }; }
[ "function", "parseNode", "(", "line", ")", "{", "current", "=", "{", "is", ":", "'NODE'", ",", "type", ":", "'NODE'", ",", "id", ":", "line", ".", "substr", "(", "10", ",", "10", ")", ".", "trim", "(", ")", ".", "toLowerCase", "(", ")", ",", "initialStorage", ":", "line", ".", "substr", "(", "20", ",", "10", ")", ".", "trim", "(", ")", ",", "areaCapfactor", ":", "line", ".", "substr", "(", "30", ",", "10", ")", ".", "trim", "(", ")", ",", "endingStorage", ":", "line", ".", "substr", "(", "40", ",", "10", ")", ".", "trim", "(", ")", "}", ";", "}" ]
LINK DIVR DIVR SR_SCC
[ "LINK", "DIVR", "DIVR", "SR_SCC" ]
9c276972394878dfb6927b56303fca4c4a2bf8f5
https://github.com/ucd-cws/calvin-network-tools/blob/9c276972394878dfb6927b56303fca4c4a2bf8f5/nodejs/pri/debugger/parser.js#L45-L54