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
22,500
ArnaudValensi/node-jsencrypt
index.js
function () { if ((i = x.getLowestSetBit()) > 0) { x.rShiftTo(i, x); } if ((i = y.getLowestSetBit()) > 0) { y.rShiftTo(i, y); } if (x.compareTo(y) >= 0) { x.subTo(y, x); ...
javascript
function () { if ((i = x.getLowestSetBit()) > 0) { x.rShiftTo(i, x); } if ((i = y.getLowestSetBit()) > 0) { y.rShiftTo(i, y); } if (x.compareTo(y) >= 0) { x.subTo(y, x); ...
[ "function", "(", ")", "{", "if", "(", "(", "i", "=", "x", ".", "getLowestSetBit", "(", ")", ")", ">", "0", ")", "{", "x", ".", "rShiftTo", "(", "i", ",", "x", ")", ";", "}", "if", "(", "(", "i", "=", "y", ".", "getLowestSetBit", "(", ")", ...
Workhorse of the algorithm, gets called 200 - 800 times per 512 bit keygen.
[ "Workhorse", "of", "the", "algorithm", "gets", "called", "200", "-", "800", "times", "per", "512", "bit", "keygen", "." ]
ddea7f3a5ac4635bd462327f0005caba10cc0870
https://github.com/ArnaudValensi/node-jsencrypt/blob/ddea7f3a5ac4635bd462327f0005caba10cc0870/index.js#L2514-L2536
22,501
ArnaudValensi/node-jsencrypt
index.js
b64tohex
function b64tohex(s) { var ret = "" var i; var k = 0; // b64 state, 0-3 var slop; for (i = 0; i < s.length; ++i) { if (s.charAt(i) == b64pad) break; v = b64map.indexOf(s.charAt(i)); if (v < 0) continue; if (k == 0) { ...
javascript
function b64tohex(s) { var ret = "" var i; var k = 0; // b64 state, 0-3 var slop; for (i = 0; i < s.length; ++i) { if (s.charAt(i) == b64pad) break; v = b64map.indexOf(s.charAt(i)); if (v < 0) continue; if (k == 0) { ...
[ "function", "b64tohex", "(", "s", ")", "{", "var", "ret", "=", "\"\"", "var", "i", ";", "var", "k", "=", "0", ";", "// b64 state, 0-3", "var", "slop", ";", "for", "(", "i", "=", "0", ";", "i", "<", "s", ".", "length", ";", "++", "i", ")", "{"...
convert a base64 string to hex
[ "convert", "a", "base64", "string", "to", "hex" ]
ddea7f3a5ac4635bd462327f0005caba10cc0870
https://github.com/ArnaudValensi/node-jsencrypt/blob/ddea7f3a5ac4635bd462327f0005caba10cc0870/index.js#L2603-L2637
22,502
ArnaudValensi/node-jsencrypt
index.js
function (key) { // Call the super constructor. RSAKey.call(this); // If a key key was provided. if (key) { // If this is a string... if (typeof key === 'string') { this.parseKey(key); } else if ( this.hasPri...
javascript
function (key) { // Call the super constructor. RSAKey.call(this); // If a key key was provided. if (key) { // If this is a string... if (typeof key === 'string') { this.parseKey(key); } else if ( this.hasPri...
[ "function", "(", "key", ")", "{", "// Call the super constructor.", "RSAKey", ".", "call", "(", "this", ")", ";", "// If a key key was provided.", "if", "(", "key", ")", "{", "// If this is a string...", "if", "(", "typeof", "key", "===", "'string'", ")", "{", ...
Create a new JSEncryptRSAKey that extends Tom Wu's RSA key object. This object is just a decorator for parsing the key parameter @param {string|Object} key - The key in string format, or an object containing the parameters needed to build a RSAKey object. @constructor
[ "Create", "a", "new", "JSEncryptRSAKey", "that", "extends", "Tom", "Wu", "s", "RSA", "key", "object", ".", "This", "object", "is", "just", "a", "decorator", "for", "parsing", "the", "key", "parameter" ]
ddea7f3a5ac4635bd462327f0005caba10cc0870
https://github.com/ArnaudValensi/node-jsencrypt/blob/ddea7f3a5ac4635bd462327f0005caba10cc0870/index.js#L4386-L4403
22,503
dasmoth/dalliance
js/das.js
DASSequence
function DASSequence(name, start, end, alpha, seq) { this.name = name; this.start = start; this.end = end; this.alphabet = alpha; this.seq = seq; }
javascript
function DASSequence(name, start, end, alpha, seq) { this.name = name; this.start = start; this.end = end; this.alphabet = alpha; this.seq = seq; }
[ "function", "DASSequence", "(", "name", ",", "start", ",", "end", ",", "alpha", ",", "seq", ")", "{", "this", ".", "name", "=", "name", ";", "this", ".", "start", "=", "start", ";", "this", ".", "end", "=", "end", ";", "this", ".", "alphabet", "=...
DAS 1.6 sequence command Do we need an option to fall back to the dna command?
[ "DAS", "1", ".", "6", "sequence", "command", "Do", "we", "need", "an", "option", "to", "fall", "back", "to", "the", "dna", "command?" ]
64565abc974433a5dcd5406d17fa0a202e1e55fc
https://github.com/dasmoth/dalliance/blob/64565abc974433a5dcd5406d17fa0a202e1e55fc/js/das.js#L140-L146
22,504
thlorenz/flamegraph
index.js
flamegraph
function flamegraph(arr, opts) { var profile if (!Array.isArray(arr)) throw new TypeError('First arg needs to be an array of lines.') opts = opts || {} try { profile = cpuprofilify().convert(arr, opts.profile) } catch (err) { // not a valid input to cpuprofilify -- maybe it's an actual cpuprofile alr...
javascript
function flamegraph(arr, opts) { var profile if (!Array.isArray(arr)) throw new TypeError('First arg needs to be an array of lines.') opts = opts || {} try { profile = cpuprofilify().convert(arr, opts.profile) } catch (err) { // not a valid input to cpuprofilify -- maybe it's an actual cpuprofile alr...
[ "function", "flamegraph", "(", "arr", ",", "opts", ")", "{", "var", "profile", "if", "(", "!", "Array", ".", "isArray", "(", "arr", ")", ")", "throw", "new", "TypeError", "(", "'First arg needs to be an array of lines.'", ")", "opts", "=", "opts", "||", "{...
Converts an array of call graph lines into an svg document. @name flamegraph @function @param {Array.<string>} arr input lines to render svg for @param {Object} opts objects that affect the visualization @param {Object} opts.profile options passed to cpuprofilify @see [cpuprofilify.con...
[ "Converts", "an", "array", "of", "call", "graph", "lines", "into", "an", "svg", "document", "." ]
2871eabaef5e8de1941a09077d83d41e24baca85
https://github.com/thlorenz/flamegraph/blob/2871eabaef5e8de1941a09077d83d41e24baca85/index.js#L43-L62
22,505
thlorenz/flamegraph
from-stream.js
fromStream
function fromStream(stream, opts) { opts = opts || {} var out = through() function ondata(res) { try { var svg = flamegraph(res.toString().split('\n'), opts) out.write(svg) } catch (err) { out.emit('error', err) } } // Once memory becomes an issue we need to make this truly str...
javascript
function fromStream(stream, opts) { opts = opts || {} var out = through() function ondata(res) { try { var svg = flamegraph(res.toString().split('\n'), opts) out.write(svg) } catch (err) { out.emit('error', err) } } // Once memory becomes an issue we need to make this truly str...
[ "function", "fromStream", "(", "stream", ",", "opts", ")", "{", "opts", "=", "opts", "||", "{", "}", "var", "out", "=", "through", "(", ")", "function", "ondata", "(", "res", ")", "{", "try", "{", "var", "svg", "=", "flamegraph", "(", "res", ".", ...
Converts a stream of call graph lines into an svg document. Not truly streaming, concats all lines before processing. **Example**: ```js var fromStream = require('flamegraph/from-stream') fromStream(process.stdin, opts).pipe(process.stdout) ``` @name flamegraph::fromStream @function @param {ReadableStream} stream th...
[ "Converts", "a", "stream", "of", "call", "graph", "lines", "into", "an", "svg", "document", ".", "Not", "truly", "streaming", "concats", "all", "lines", "before", "processing", "." ]
2871eabaef5e8de1941a09077d83d41e24baca85
https://github.com/thlorenz/flamegraph/blob/2871eabaef5e8de1941a09077d83d41e24baca85/from-stream.js#L29-L45
22,506
ralucas/node-zillow
lib/helpers.js
httpRequest
function httpRequest(url) { var deferred = Q.defer(); request(url, function(err, response, body) { if (err) { deferred.reject(new Error(err)); } else if (!err && response.statusCode !== 200) { deferred.reject(new Error(response.statusCode)); } else { deferred.resolve(bo...
javascript
function httpRequest(url) { var deferred = Q.defer(); request(url, function(err, response, body) { if (err) { deferred.reject(new Error(err)); } else if (!err && response.statusCode !== 200) { deferred.reject(new Error(response.statusCode)); } else { deferred.resolve(bo...
[ "function", "httpRequest", "(", "url", ")", "{", "var", "deferred", "=", "Q", ".", "defer", "(", ")", ";", "request", "(", "url", ",", "function", "(", "err", ",", "response", ",", "body", ")", "{", "if", "(", "err", ")", "{", "deferred", ".", "r...
Helper function that handles the http request @param {string} url
[ "Helper", "function", "that", "handles", "the", "http", "request" ]
236aa710b60fd3713bf1245be163cd64c2045985
https://github.com/ralucas/node-zillow/blob/236aa710b60fd3713bf1245be163cd64c2045985/lib/helpers.js#L17-L29
22,507
ralucas/node-zillow
lib/helpers.js
toJson
function toJson(xml) { var deferred = Q.defer(); xml2js.parseString(xml, function(err, result) { if (err) { deferred.reject(new Error(err)); } else { deferred.resolve(result); } }); return deferred.promise; }
javascript
function toJson(xml) { var deferred = Q.defer(); xml2js.parseString(xml, function(err, result) { if (err) { deferred.reject(new Error(err)); } else { deferred.resolve(result); } }); return deferred.promise; }
[ "function", "toJson", "(", "xml", ")", "{", "var", "deferred", "=", "Q", ".", "defer", "(", ")", ";", "xml2js", ".", "parseString", "(", "xml", ",", "function", "(", "err", ",", "result", ")", "{", "if", "(", "err", ")", "{", "deferred", ".", "re...
Helper function that converts xml to json @param {xml} xml
[ "Helper", "function", "that", "converts", "xml", "to", "json" ]
236aa710b60fd3713bf1245be163cd64c2045985
https://github.com/ralucas/node-zillow/blob/236aa710b60fd3713bf1245be163cd64c2045985/lib/helpers.js#L36-L46
22,508
ralucas/node-zillow
lib/helpers.js
toQueryString
function toQueryString(params, id) { var paramsString = ''; for (var key in params) { if (params.hasOwnProperty(key)) { paramsString += '&' + key + '=' + encodeURIComponent(params[key]); } } return 'zws-id=' + id + paramsString; }
javascript
function toQueryString(params, id) { var paramsString = ''; for (var key in params) { if (params.hasOwnProperty(key)) { paramsString += '&' + key + '=' + encodeURIComponent(params[key]); } } return 'zws-id=' + id + paramsString; }
[ "function", "toQueryString", "(", "params", ",", "id", ")", "{", "var", "paramsString", "=", "''", ";", "for", "(", "var", "key", "in", "params", ")", "{", "if", "(", "params", ".", "hasOwnProperty", "(", "key", ")", ")", "{", "paramsString", "+=", "...
Helper function that takes params hash and converts it into query string @param {object} params @param {Number} id
[ "Helper", "function", "that", "takes", "params", "hash", "and", "converts", "it", "into", "query", "string" ]
236aa710b60fd3713bf1245be163cd64c2045985
https://github.com/ralucas/node-zillow/blob/236aa710b60fd3713bf1245be163cd64c2045985/lib/helpers.js#L54-L62
22,509
ralucas/node-zillow
lib/helpers.js
checkParams
function checkParams(params, reqParams) { if ( reqParams.length < 1 ) { return; } if ( (_.isEmpty(params) || !params) && (reqParams.length > 0) ) { throw new Error('Missing parameters: ' + reqParams.join(', ')); } var paramsKeys = _.keys(params); _.each(reqParams, function(reqPa...
javascript
function checkParams(params, reqParams) { if ( reqParams.length < 1 ) { return; } if ( (_.isEmpty(params) || !params) && (reqParams.length > 0) ) { throw new Error('Missing parameters: ' + reqParams.join(', ')); } var paramsKeys = _.keys(params); _.each(reqParams, function(reqPa...
[ "function", "checkParams", "(", "params", ",", "reqParams", ")", "{", "if", "(", "reqParams", ".", "length", "<", "1", ")", "{", "return", ";", "}", "if", "(", "(", "_", ".", "isEmpty", "(", "params", ")", "||", "!", "params", ")", "&&", "(", "re...
Helper function that checks for the required params @param {object} params @param {array} reqParams -- required parameters
[ "Helper", "function", "that", "checks", "for", "the", "required", "params" ]
236aa710b60fd3713bf1245be163cd64c2045985
https://github.com/ralucas/node-zillow/blob/236aa710b60fd3713bf1245be163cd64c2045985/lib/helpers.js#L70-L86
22,510
gosquared/mmdb-reader
src/Reader.js
Reader
function Reader(buf, filePath) { // Allow instantiating without `new` if (!(this instanceof Reader)) { return new Reader(buf); } // Allow passing either a path to a file or a raw buffer if (typeof buf === 'string') { filePath = buf; buf = fs.readFileSync(buf); } // LRU cache that'll hold obj...
javascript
function Reader(buf, filePath) { // Allow instantiating without `new` if (!(this instanceof Reader)) { return new Reader(buf); } // Allow passing either a path to a file or a raw buffer if (typeof buf === 'string') { filePath = buf; buf = fs.readFileSync(buf); } // LRU cache that'll hold obj...
[ "function", "Reader", "(", "buf", ",", "filePath", ")", "{", "// Allow instantiating without `new`", "if", "(", "!", "(", "this", "instanceof", "Reader", ")", ")", "{", "return", "new", "Reader", "(", "buf", ")", ";", "}", "// Allow passing either a path to a fi...
Main reader constructor
[ "Main", "reader", "constructor" ]
65adbb40709020a3b13ec5619b83efae75b77a5e
https://github.com/gosquared/mmdb-reader/blob/65adbb40709020a3b13ec5619b83efae75b77a5e/src/Reader.js#L26-L48
22,511
vacuumlabs/data-provider
src/config.js
changeCfgOption
function changeCfgOption(options, key) { if (expectKey(options, key, typeof cfg[key])) { cfg[key] = options[key] } }
javascript
function changeCfgOption(options, key) { if (expectKey(options, key, typeof cfg[key])) { cfg[key] = options[key] } }
[ "function", "changeCfgOption", "(", "options", ",", "key", ")", "{", "if", "(", "expectKey", "(", "options", ",", "key", ",", "typeof", "cfg", "[", "key", "]", ")", ")", "{", "cfg", "[", "key", "]", "=", "options", "[", "key", "]", "}", "}" ]
if supplied options contain given field, override its value in global cfg
[ "if", "supplied", "options", "contain", "given", "field", "override", "its", "value", "in", "global", "cfg" ]
2acbd4698a3d5050dd15d25d023409dee126cc41
https://github.com/vacuumlabs/data-provider/blob/2acbd4698a3d5050dd15d25d023409dee126cc41/src/config.js#L38-L42
22,512
vacuumlabs/data-provider
src/config.js
expectKey
function expectKey(options, key, type) { if (key in options) { if (typeof options[key] === type) { return true } // eslint-disable-next-line no-console console.warn(`Ignoring options key '${key}' - ` + `expected type '${type}', received '${typeof options[key]}'`) } return false }
javascript
function expectKey(options, key, type) { if (key in options) { if (typeof options[key] === type) { return true } // eslint-disable-next-line no-console console.warn(`Ignoring options key '${key}' - ` + `expected type '${type}', received '${typeof options[key]}'`) } return false }
[ "function", "expectKey", "(", "options", ",", "key", ",", "type", ")", "{", "if", "(", "key", "in", "options", ")", "{", "if", "(", "typeof", "options", "[", "key", "]", "===", "type", ")", "{", "return", "true", "}", "// eslint-disable-next-line no-cons...
check whether options contain given key and that it is the same type as in cfg
[ "check", "whether", "options", "contain", "given", "key", "and", "that", "it", "is", "the", "same", "type", "as", "in", "cfg" ]
2acbd4698a3d5050dd15d25d023409dee126cc41
https://github.com/vacuumlabs/data-provider/blob/2acbd4698a3d5050dd15d25d023409dee126cc41/src/config.js#L45-L55
22,513
kmi/node-red-contrib-noble
noble/node-red-contrib-noble.js
startScan
function startScan(stateChange, error) { if (!node.scanning) { // send status message var msg = { statusUpdate: true, error: error, stateChange: stateChange, state: noble.state }; ...
javascript
function startScan(stateChange, error) { if (!node.scanning) { // send status message var msg = { statusUpdate: true, error: error, stateChange: stateChange, state: noble.state }; ...
[ "function", "startScan", "(", "stateChange", ",", "error", ")", "{", "if", "(", "!", "node", ".", "scanning", ")", "{", "// send status message", "var", "msg", "=", "{", "statusUpdate", ":", "true", ",", "error", ":", "error", ",", "stateChange", ":", "s...
Take care of starting the scan and sending the status message
[ "Take", "care", "of", "starting", "the", "scan", "and", "sending", "the", "status", "message" ]
9f30d0928df8e4b432891820c6ff97d4c18f49f4
https://github.com/kmi/node-red-contrib-noble/blob/9f30d0928df8e4b432891820c6ff97d4c18f49f4/noble/node-red-contrib-noble.js#L90-L107
22,514
kmi/node-red-contrib-noble
noble/node-red-contrib-noble.js
stopScan
function stopScan(stateChange, error) { if (node.scanning) { // send status message var msg = { statusUpdate: true, error: error, stateChange: stateChange, state: noble.state }; ...
javascript
function stopScan(stateChange, error) { if (node.scanning) { // send status message var msg = { statusUpdate: true, error: error, stateChange: stateChange, state: noble.state }; ...
[ "function", "stopScan", "(", "stateChange", ",", "error", ")", "{", "if", "(", "node", ".", "scanning", ")", "{", "// send status message", "var", "msg", "=", "{", "statusUpdate", ":", "true", ",", "error", ":", "error", ",", "stateChange", ":", "stateChan...
Take care of stopping the scan and sending the status message
[ "Take", "care", "of", "stopping", "the", "scan", "and", "sending", "the", "status", "message" ]
9f30d0928df8e4b432891820c6ff97d4c18f49f4
https://github.com/kmi/node-red-contrib-noble/blob/9f30d0928df8e4b432891820c6ff97d4c18f49f4/noble/node-red-contrib-noble.js#L110-L130
22,515
maxogden/bytewiser
exercises/modifying_buffers/exercise.js
query
function query (mode) { var exercise = this function send (stream) { var input = through2() input .pipe(stream) .on('error', function(err) { exercise.emit( 'fail', exercise.__('fail.never_read_stdin') ) }) input.write('wow. such wow.'); input.en...
javascript
function query (mode) { var exercise = this function send (stream) { var input = through2() input .pipe(stream) .on('error', function(err) { exercise.emit( 'fail', exercise.__('fail.never_read_stdin') ) }) input.write('wow. such wow.'); input.en...
[ "function", "query", "(", "mode", ")", "{", "var", "exercise", "=", "this", "function", "send", "(", "stream", ")", "{", "var", "input", "=", "through2", "(", ")", "input", ".", "pipe", "(", "stream", ")", ".", "on", "(", "'error'", ",", "function", ...
delayed for 500ms to wait for servers to start so we can start playing with them
[ "delayed", "for", "500ms", "to", "wait", "for", "servers", "to", "start", "so", "we", "can", "start", "playing", "with", "them" ]
b111cda74ba0021b0ed69a51fb2c5f40e74284a1
https://github.com/maxogden/bytewiser/blob/b111cda74ba0021b0ed69a51fb2c5f40e74284a1/exercises/modifying_buffers/exercise.js#L29-L50
22,516
DamienP33/express-mongoose-generator
lib/formatTools.js
getFieldsForModelTemplate
function getFieldsForModelTemplate(fields) { var lg = fields.length - 1; var modelFields = '{' + os.EOL; fields.forEach(function(field, index, array) { modelFields += '\t\'' + field.name + '\' : '+ (field.isArray ? '[' : '') + (allowedFieldsTypes[field.type]).name + (field.isArray ? ']' : ''); ...
javascript
function getFieldsForModelTemplate(fields) { var lg = fields.length - 1; var modelFields = '{' + os.EOL; fields.forEach(function(field, index, array) { modelFields += '\t\'' + field.name + '\' : '+ (field.isArray ? '[' : '') + (allowedFieldsTypes[field.type]).name + (field.isArray ? ']' : ''); ...
[ "function", "getFieldsForModelTemplate", "(", "fields", ")", "{", "var", "lg", "=", "fields", ".", "length", "-", "1", ";", "var", "modelFields", "=", "'{'", "+", "os", ".", "EOL", ";", "fields", ".", "forEach", "(", "function", "(", "field", ",", "ind...
Format the fields for the model template @param {array} fields fields input @returns {string} formatted fields
[ "Format", "the", "fields", "for", "the", "model", "template" ]
ce1439c4c9c291e539fc6190907364d70e75d4d6
https://github.com/DamienP33/express-mongoose-generator/blob/ce1439c4c9c291e539fc6190907364d70e75d4d6/lib/formatTools.js#L18-L33
22,517
DamienP33/express-mongoose-generator
lib/generators.js
generateModel
function generateModel(path, modelName, modelFields, generateMethod, ts, cb) { var fields = formatTools.getFieldsForModelTemplate(modelFields); var schemaName = modelName + 'Schema'; var extension = (ts) ? 'ts' : 'js'; var model = ft.loadTemplateSync('model.' + extension); model = model.replace(/{m...
javascript
function generateModel(path, modelName, modelFields, generateMethod, ts, cb) { var fields = formatTools.getFieldsForModelTemplate(modelFields); var schemaName = modelName + 'Schema'; var extension = (ts) ? 'ts' : 'js'; var model = ft.loadTemplateSync('model.' + extension); model = model.replace(/{m...
[ "function", "generateModel", "(", "path", ",", "modelName", ",", "modelFields", ",", "generateMethod", ",", "ts", ",", "cb", ")", "{", "var", "fields", "=", "formatTools", ".", "getFieldsForModelTemplate", "(", "modelFields", ")", ";", "var", "schemaName", "="...
Generate a Mongoose model @param {string} path @param {string} modelName @param {array} modelFields @param {string} generateMethod @param {boolean} ts generating code in TS @param {function} cb
[ "Generate", "a", "Mongoose", "model" ]
ce1439c4c9c291e539fc6190907364d70e75d4d6
https://github.com/DamienP33/express-mongoose-generator/blob/ce1439c4c9c291e539fc6190907364d70e75d4d6/lib/generators.js#L17-L36
22,518
DamienP33/express-mongoose-generator
lib/generators.js
generateRouter
function generateRouter(path, modelName, generateMethod, ts, cb) { var extension = (ts) ? 'ts' : 'js'; var router = ft.loadTemplateSync('router.' + extension); router = router.replace(/{controllerName}/g, modelName + 'Controller'); if (generateMethod === 't') { ft.createDirIfIsNotDefined(path, ...
javascript
function generateRouter(path, modelName, generateMethod, ts, cb) { var extension = (ts) ? 'ts' : 'js'; var router = ft.loadTemplateSync('router.' + extension); router = router.replace(/{controllerName}/g, modelName + 'Controller'); if (generateMethod === 't') { ft.createDirIfIsNotDefined(path, ...
[ "function", "generateRouter", "(", "path", ",", "modelName", ",", "generateMethod", ",", "ts", ",", "cb", ")", "{", "var", "extension", "=", "(", "ts", ")", "?", "'ts'", ":", "'js'", ";", "var", "router", "=", "ft", ".", "loadTemplateSync", "(", "'rout...
Generate a Express router @param {string} path @param {string} modelName @param {string} generateMethod @param {boolean} ts generating code in TS @param {function} cb
[ "Generate", "a", "Express", "router" ]
ce1439c4c9c291e539fc6190907364d70e75d4d6
https://github.com/DamienP33/express-mongoose-generator/blob/ce1439c4c9c291e539fc6190907364d70e75d4d6/lib/generators.js#L46-L62
22,519
DamienP33/express-mongoose-generator
lib/fileTools.js
createDirIfIsNotDefined
function createDirIfIsNotDefined(dirPath, dirName, cb) { if (!fs.existsSync(dirPath + '/' + dirName)){ fs.mkdirSync(dirPath + '/' + dirName); console.info(cliStyles.cyan + '\tcreate' + cliStyles.reset + ': ' + dirPath + '/' + dirName); } cb(); }
javascript
function createDirIfIsNotDefined(dirPath, dirName, cb) { if (!fs.existsSync(dirPath + '/' + dirName)){ fs.mkdirSync(dirPath + '/' + dirName); console.info(cliStyles.cyan + '\tcreate' + cliStyles.reset + ': ' + dirPath + '/' + dirName); } cb(); }
[ "function", "createDirIfIsNotDefined", "(", "dirPath", ",", "dirName", ",", "cb", ")", "{", "if", "(", "!", "fs", ".", "existsSync", "(", "dirPath", "+", "'/'", "+", "dirName", ")", ")", "{", "fs", ".", "mkdirSync", "(", "dirPath", "+", "'/'", "+", "...
Create a directory if not defined @param {string} dirPath directory path parent @param {string} dirName directory name to find @param {function} cb callback
[ "Create", "a", "directory", "if", "not", "defined" ]
ce1439c4c9c291e539fc6190907364d70e75d4d6
https://github.com/DamienP33/express-mongoose-generator/blob/ce1439c4c9c291e539fc6190907364d70e75d4d6/lib/fileTools.js#L14-L21
22,520
enricostara/telegram-mt-node
lib/auth/index.js
createAuthKey
function createAuthKey(callback, channel) { flow.retryUntilIsDone(callback, null, function (callback) { flow.runSeries([ require('./request-pq'), require('./request-dh-params'), require('./set-client-dh-params') ], callback, channel); ...
javascript
function createAuthKey(callback, channel) { flow.retryUntilIsDone(callback, null, function (callback) { flow.runSeries([ require('./request-pq'), require('./request-dh-params'), require('./set-client-dh-params') ], callback, channel); ...
[ "function", "createAuthKey", "(", "callback", ",", "channel", ")", "{", "flow", ".", "retryUntilIsDone", "(", "callback", ",", "null", ",", "function", "(", "callback", ")", "{", "flow", ".", "runSeries", "(", "[", "require", "(", "'./request-pq'", ")", ",...
Create the authorization key
[ "Create", "the", "authorization", "key" ]
f069dfcea2d023fc1ca837c5673d3abe26d44d28
https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/index.js#L18-L28
22,521
enricostara/telegram-mt-node
lib/auth/request-pq.js
requestPQ
function requestPQ(callback, channel) { // Create a nonce for the client var clientNonce = utility.createNonce(16); mtproto.service.req_pq({ props: { nonce: clientNonce }, channel: channel, callback: function (ex, resPQ) { if (clientNonce === resPQ.non...
javascript
function requestPQ(callback, channel) { // Create a nonce for the client var clientNonce = utility.createNonce(16); mtproto.service.req_pq({ props: { nonce: clientNonce }, channel: channel, callback: function (ex, resPQ) { if (clientNonce === resPQ.non...
[ "function", "requestPQ", "(", "callback", ",", "channel", ")", "{", "// Create a nonce for the client", "var", "clientNonce", "=", "utility", ".", "createNonce", "(", "16", ")", ";", "mtproto", ".", "service", ".", "req_pq", "(", "{", "props", ":", "{", "non...
Request a PQ pair number
[ "Request", "a", "PQ", "pair", "number" ]
f069dfcea2d023fc1ca837c5673d3abe26d44d28
https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/request-pq.js#L27-L47
22,522
enricostara/telegram-mt-node
lib/auth/request-pq.js
findPAndQ
function findPAndQ(context) { var pqFinder = new security.PQFinder(context.resPQ.pq); if (logger.isDebugEnabled()) { logger.debug('Start finding P and Q, with PQ = %s', pqFinder.getPQPairNumber()); } var pq = pqFinder.findPQ(); if (logger.isDebugEnabled()) { logger.debug('Found P = %...
javascript
function findPAndQ(context) { var pqFinder = new security.PQFinder(context.resPQ.pq); if (logger.isDebugEnabled()) { logger.debug('Start finding P and Q, with PQ = %s', pqFinder.getPQPairNumber()); } var pq = pqFinder.findPQ(); if (logger.isDebugEnabled()) { logger.debug('Found P = %...
[ "function", "findPAndQ", "(", "context", ")", "{", "var", "pqFinder", "=", "new", "security", ".", "PQFinder", "(", "context", ".", "resPQ", ".", "pq", ")", ";", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", ...
Find the P and Q prime numbers
[ "Find", "the", "P", "and", "Q", "prime", "numbers" ]
f069dfcea2d023fc1ca837c5673d3abe26d44d28
https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/request-pq.js#L50-L62
22,523
enricostara/telegram-mt-node
lib/auth/request-pq.js
findPublicKey
function findPublicKey(context) { var fingerprints = context.resPQ.server_public_key_fingerprints.getList(); if (logger.isDebugEnabled()) { logger.debug('Public keys fingerprints from server: %s', fingerprints); } for (var i = 0; i < fingerprints.length; i++) { var fingerprint = fingerpr...
javascript
function findPublicKey(context) { var fingerprints = context.resPQ.server_public_key_fingerprints.getList(); if (logger.isDebugEnabled()) { logger.debug('Public keys fingerprints from server: %s', fingerprints); } for (var i = 0; i < fingerprints.length; i++) { var fingerprint = fingerpr...
[ "function", "findPublicKey", "(", "context", ")", "{", "var", "fingerprints", "=", "context", ".", "resPQ", ".", "server_public_key_fingerprints", ".", "getList", "(", ")", ";", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", ...
Find the correct Public Key using fingerprint from server response
[ "Find", "the", "correct", "Public", "Key", "using", "fingerprint", "from", "server", "response" ]
f069dfcea2d023fc1ca837c5673d3abe26d44d28
https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/request-pq.js#L65-L86
22,524
enricostara/telegram-mt-node
lib/utility.js
createMessageId
function createMessageId() { var logger = getLogger('utility.createMessageId'); // Constants // Take the time and sum the time-offset with the server clock var time = new BigInteger((require('./time').getLocalTime()).toString()); // Divide the time by 1000 `result[0]` and take the fractional part `r...
javascript
function createMessageId() { var logger = getLogger('utility.createMessageId'); // Constants // Take the time and sum the time-offset with the server clock var time = new BigInteger((require('./time').getLocalTime()).toString()); // Divide the time by 1000 `result[0]` and take the fractional part `r...
[ "function", "createMessageId", "(", ")", "{", "var", "logger", "=", "getLogger", "(", "'utility.createMessageId'", ")", ";", "// Constants", "// Take the time and sum the time-offset with the server clock", "var", "time", "=", "new", "BigInteger", "(", "(", "require", "...
Create a message ID starting from the local time
[ "Create", "a", "message", "ID", "starting", "from", "the", "local", "time" ]
f069dfcea2d023fc1ca837c5673d3abe26d44d28
https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/utility.js#L27-L43
22,525
enricostara/telegram-mt-node
lib/utility.js
createSHAHash
function createSHAHash(buffer, algorithm) { var logger = getLogger('utility.createSHA1Hash'); var sha1sum = crypto.createHash(algorithm || 'sha1'); if (require('util').isArray(buffer)) { if (logger.isDebugEnabled()) { logger.debug('It\'s an Array of buffers'); } for (var ...
javascript
function createSHAHash(buffer, algorithm) { var logger = getLogger('utility.createSHA1Hash'); var sha1sum = crypto.createHash(algorithm || 'sha1'); if (require('util').isArray(buffer)) { if (logger.isDebugEnabled()) { logger.debug('It\'s an Array of buffers'); } for (var ...
[ "function", "createSHAHash", "(", "buffer", ",", "algorithm", ")", "{", "var", "logger", "=", "getLogger", "(", "'utility.createSHA1Hash'", ")", ";", "var", "sha1sum", "=", "crypto", ".", "createHash", "(", "algorithm", "||", "'sha1'", ")", ";", "if", "(", ...
Create SHA1 hash starting from a buffer or an array of buffers
[ "Create", "SHA1", "hash", "starting", "from", "a", "buffer", "or", "an", "array", "of", "buffers" ]
f069dfcea2d023fc1ca837c5673d3abe26d44d28
https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/utility.js#L46-L63
22,526
enricostara/telegram-mt-node
lib/utility.js
xor
function xor(buffer1, buffer2) { var length = Math.min(buffer1.length, buffer2.length); var retBuffer = new Buffer(length); for (var i = 0; i < length; i++) { retBuffer[i] = buffer1[i] ^ buffer2[i]; } return retBuffer; }
javascript
function xor(buffer1, buffer2) { var length = Math.min(buffer1.length, buffer2.length); var retBuffer = new Buffer(length); for (var i = 0; i < length; i++) { retBuffer[i] = buffer1[i] ^ buffer2[i]; } return retBuffer; }
[ "function", "xor", "(", "buffer1", ",", "buffer2", ")", "{", "var", "length", "=", "Math", ".", "min", "(", "buffer1", ".", "length", ",", "buffer2", ".", "length", ")", ";", "var", "retBuffer", "=", "new", "Buffer", "(", "length", ")", ";", "for", ...
Xor op on buffers
[ "Xor", "op", "on", "buffers" ]
f069dfcea2d023fc1ca837c5673d3abe26d44d28
https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/utility.js#L93-L100
22,527
enricostara/telegram-mt-node
lib/auth/request-dh-params.js
createPQInnerData
function createPQInnerData(context) { var resPQ = context.resPQ; var newNonce = utility.createNonce(32); var pqInnerData = new mtproto.type.P_q_inner_data({ props: { pq: resPQ.pq, p: context.pBuffer, q: context.qBuffer, nonce: resPQ.nonce, ...
javascript
function createPQInnerData(context) { var resPQ = context.resPQ; var newNonce = utility.createNonce(32); var pqInnerData = new mtproto.type.P_q_inner_data({ props: { pq: resPQ.pq, p: context.pBuffer, q: context.qBuffer, nonce: resPQ.nonce, ...
[ "function", "createPQInnerData", "(", "context", ")", "{", "var", "resPQ", "=", "context", ".", "resPQ", ";", "var", "newNonce", "=", "utility", ".", "createNonce", "(", "32", ")", ";", "var", "pqInnerData", "=", "new", "mtproto", ".", "type", ".", "P_q_...
Create the pq_inner_data buffer
[ "Create", "the", "pq_inner_data", "buffer" ]
f069dfcea2d023fc1ca837c5673d3abe26d44d28
https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/request-dh-params.js#L32-L48
22,528
enricostara/telegram-mt-node
lib/auth/request-dh-params.js
encryptPQInnerDataWithRSA
function encryptPQInnerDataWithRSA(context) { // Create the data with hash to be encrypt var hash = utility.createSHAHash(context.pqInnerData); var dataWithHash = Buffer.concat([hash, context.pqInnerData]); if (logger.isDebugEnabled()) { logger.debug('Data to be encrypted contains: hash(%s), pqI...
javascript
function encryptPQInnerDataWithRSA(context) { // Create the data with hash to be encrypt var hash = utility.createSHAHash(context.pqInnerData); var dataWithHash = Buffer.concat([hash, context.pqInnerData]); if (logger.isDebugEnabled()) { logger.debug('Data to be encrypted contains: hash(%s), pqI...
[ "function", "encryptPQInnerDataWithRSA", "(", "context", ")", "{", "// Create the data with hash to be encrypt", "var", "hash", "=", "utility", ".", "createSHAHash", "(", "context", ".", "pqInnerData", ")", ";", "var", "dataWithHash", "=", "Buffer", ".", "concat", "...
Encrypt the pq_inner_data with RSA
[ "Encrypt", "the", "pq_inner_data", "with", "RSA" ]
f069dfcea2d023fc1ca837c5673d3abe26d44d28
https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/request-dh-params.js#L51-L62
22,529
enricostara/telegram-mt-node
lib/auth/request-dh-params.js
requestDHParams
function requestDHParams(callback, context) { var resPQ = context.resPQ; mtproto.service.req_DH_params({ props: { nonce: resPQ.nonce, server_nonce: resPQ.server_nonce, p: context.pBuffer, q: context.qBuffer, public_key_fingerprint: context.fing...
javascript
function requestDHParams(callback, context) { var resPQ = context.resPQ; mtproto.service.req_DH_params({ props: { nonce: resPQ.nonce, server_nonce: resPQ.server_nonce, p: context.pBuffer, q: context.qBuffer, public_key_fingerprint: context.fing...
[ "function", "requestDHParams", "(", "callback", ",", "context", ")", "{", "var", "resPQ", "=", "context", ".", "resPQ", ";", "mtproto", ".", "service", ".", "req_DH_params", "(", "{", "props", ":", "{", "nonce", ":", "resPQ", ".", "nonce", ",", "server_n...
Request server DH parameters
[ "Request", "server", "DH", "parameters" ]
f069dfcea2d023fc1ca837c5673d3abe26d44d28
https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/request-dh-params.js#L65-L102
22,530
enricostara/telegram-mt-node
lib/auth/request-dh-params.js
decryptDHParams
function decryptDHParams(context) { var newNonce = utility.string2Buffer(context.newNonce, 32); var serverNonce = utility.string2Buffer(context.resPQ.server_nonce, 16); if (logger.isDebugEnabled()) { logger.debug('newNonce = %s, serverNonce = %s', newNonce.toString('hex'), serverNonce.toString('hex'...
javascript
function decryptDHParams(context) { var newNonce = utility.string2Buffer(context.newNonce, 32); var serverNonce = utility.string2Buffer(context.resPQ.server_nonce, 16); if (logger.isDebugEnabled()) { logger.debug('newNonce = %s, serverNonce = %s', newNonce.toString('hex'), serverNonce.toString('hex'...
[ "function", "decryptDHParams", "(", "context", ")", "{", "var", "newNonce", "=", "utility", ".", "string2Buffer", "(", "context", ".", "newNonce", ",", "32", ")", ";", "var", "serverNonce", "=", "utility", ".", "string2Buffer", "(", "context", ".", "resPQ", ...
Decrypt DH parameters and synch the local time with the server time
[ "Decrypt", "DH", "parameters", "and", "synch", "the", "local", "time", "with", "the", "server", "time" ]
f069dfcea2d023fc1ca837c5673d3abe26d44d28
https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/request-dh-params.js#L105-L136
22,531
enricostara/telegram-mt-node
lib/auth/request-dh-params.js
deserializeDHInnerData
function deserializeDHInnerData(context) { var decryptedDHParamsWithHash = context.decryptedDHParams; if (logger.isDebugEnabled()) { logger.debug('decryptedDHParamsWithHash(%s) = %s', decryptedDHParamsWithHash.length, decryptedDHParamsWithHash.toString('hex')); } var decryptedDHParams = decrypte...
javascript
function deserializeDHInnerData(context) { var decryptedDHParamsWithHash = context.decryptedDHParams; if (logger.isDebugEnabled()) { logger.debug('decryptedDHParamsWithHash(%s) = %s', decryptedDHParamsWithHash.length, decryptedDHParamsWithHash.toString('hex')); } var decryptedDHParams = decrypte...
[ "function", "deserializeDHInnerData", "(", "context", ")", "{", "var", "decryptedDHParamsWithHash", "=", "context", ".", "decryptedDHParams", ";", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "'decryptedDHParamsWithH...
De-serialize the server DH inner data
[ "De", "-", "serialize", "the", "server", "DH", "inner", "data" ]
f069dfcea2d023fc1ca837c5673d3abe26d44d28
https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/request-dh-params.js#L139-L165
22,532
enricostara/telegram-mt-node
lib/security/cipher.js
aesDecrypt
function aesDecrypt(msg, key, iv) { var logger = getLogger('security.cipher.aesDecrypt'); var encryptedMsg = buffer2WordArray(msg); var keyWordArray = buffer2WordArray(key); var ivWordArray = buffer2WordArray(iv); if (logger.isDebugEnabled()) { logger.debug('encryptedMsg = %s\nkeyWordArray =...
javascript
function aesDecrypt(msg, key, iv) { var logger = getLogger('security.cipher.aesDecrypt'); var encryptedMsg = buffer2WordArray(msg); var keyWordArray = buffer2WordArray(key); var ivWordArray = buffer2WordArray(iv); if (logger.isDebugEnabled()) { logger.debug('encryptedMsg = %s\nkeyWordArray =...
[ "function", "aesDecrypt", "(", "msg", ",", "key", ",", "iv", ")", "{", "var", "logger", "=", "getLogger", "(", "'security.cipher.aesDecrypt'", ")", ";", "var", "encryptedMsg", "=", "buffer2WordArray", "(", "msg", ")", ";", "var", "keyWordArray", "=", "buffer...
AES decrypt function
[ "AES", "decrypt", "function" ]
f069dfcea2d023fc1ca837c5673d3abe26d44d28
https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/security/cipher.js#L50-L68
22,533
enricostara/telegram-mt-node
lib/security/cipher.js
aesEncrypt
function aesEncrypt(msg, key, iv) { var logger = getLogger('security.cipher.aesEncrypt'); // Check if padding is needed var padding = msg.length % 16; if (padding > 0) { var paddingBuffer = utility.createRandomBuffer(16 - padding); msg = Buffer.concat([msg, paddingBuffer]); } // ...
javascript
function aesEncrypt(msg, key, iv) { var logger = getLogger('security.cipher.aesEncrypt'); // Check if padding is needed var padding = msg.length % 16; if (padding > 0) { var paddingBuffer = utility.createRandomBuffer(16 - padding); msg = Buffer.concat([msg, paddingBuffer]); } // ...
[ "function", "aesEncrypt", "(", "msg", ",", "key", ",", "iv", ")", "{", "var", "logger", "=", "getLogger", "(", "'security.cipher.aesEncrypt'", ")", ";", "// Check if padding is needed", "var", "padding", "=", "msg", ".", "length", "%", "16", ";", "if", "(", ...
AES encrypt function
[ "AES", "encrypt", "function" ]
f069dfcea2d023fc1ca837c5673d3abe26d44d28
https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/security/cipher.js#L71-L98
22,534
enricostara/telegram-mt-node
lib/time.js
timeSynchronization
function timeSynchronization(serverTime, requestDuration) { var logger = getLogger('time.timeSynchronization'); var localTime = Math.floor(new Date().getTime() / 1000); var response = requestDuration / 2; if (logger.isDebugEnabled()) { logger.debug('ServerTime %ss - LocalTime %ss - Response in %...
javascript
function timeSynchronization(serverTime, requestDuration) { var logger = getLogger('time.timeSynchronization'); var localTime = Math.floor(new Date().getTime() / 1000); var response = requestDuration / 2; if (logger.isDebugEnabled()) { logger.debug('ServerTime %ss - LocalTime %ss - Response in %...
[ "function", "timeSynchronization", "(", "serverTime", ",", "requestDuration", ")", "{", "var", "logger", "=", "getLogger", "(", "'time.timeSynchronization'", ")", ";", "var", "localTime", "=", "Math", ".", "floor", "(", "new", "Date", "(", ")", ".", "getTime",...
Synchronize the local time with the server time
[ "Synchronize", "the", "local", "time", "with", "the", "server", "time" ]
f069dfcea2d023fc1ca837c5673d3abe26d44d28
https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/time.js#L28-L50
22,535
enricostara/telegram-mt-node
lib/auth/set-client-dh-params.js
encryptClientDHInnerDataWithAES
function encryptClientDHInnerDataWithAES(context) { var hash = utility.createSHAHash(context.clientDHInnerData); var dataWithHash = Buffer.concat([hash, context.clientDHInnerData]); if (logger.isDebugEnabled()) { logger.debug('Data to be encrypted contains: hash(%s), clientDHInnerData(%s), total len...
javascript
function encryptClientDHInnerDataWithAES(context) { var hash = utility.createSHAHash(context.clientDHInnerData); var dataWithHash = Buffer.concat([hash, context.clientDHInnerData]); if (logger.isDebugEnabled()) { logger.debug('Data to be encrypted contains: hash(%s), clientDHInnerData(%s), total len...
[ "function", "encryptClientDHInnerDataWithAES", "(", "context", ")", "{", "var", "hash", "=", "utility", ".", "createSHAHash", "(", "context", ".", "clientDHInnerData", ")", ";", "var", "dataWithHash", "=", "Buffer", ".", "concat", "(", "[", "hash", ",", "conte...
Encrypt Client DH inner data
[ "Encrypt", "Client", "DH", "inner", "data" ]
f069dfcea2d023fc1ca837c5673d3abe26d44d28
https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/set-client-dh-params.js#L57-L74
22,536
enricostara/telegram-mt-node
lib/auth/set-client-dh-params.js
setClientDHParams
function setClientDHParams(callback, context) { mtproto.service.set_client_DH_params({ props: { nonce: context.resPQ.nonce, server_nonce: context.resPQ.server_nonce, encrypted_data: context.encryptClientDHInnerData }, channel: context.channel, call...
javascript
function setClientDHParams(callback, context) { mtproto.service.set_client_DH_params({ props: { nonce: context.resPQ.nonce, server_nonce: context.resPQ.server_nonce, encrypted_data: context.encryptClientDHInnerData }, channel: context.channel, call...
[ "function", "setClientDHParams", "(", "callback", ",", "context", ")", "{", "mtproto", ".", "service", ".", "set_client_DH_params", "(", "{", "props", ":", "{", "nonce", ":", "context", ".", "resPQ", ".", "nonce", ",", "server_nonce", ":", "context", ".", ...
Set client DH parameters
[ "Set", "client", "DH", "parameters" ]
f069dfcea2d023fc1ca837c5673d3abe26d44d28
https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/set-client-dh-params.js#L77-L117
22,537
enricostara/telegram-mt-node
lib/auth/set-client-dh-params.js
calculateAuthKeyValue
function calculateAuthKeyValue(context) { var ga = context.serverDHInnerData.g_a; var b = context.b; var dhPrime = context.serverDHInnerData.dh_prime; var authKeyValue = utility.modPow(ga, b, dhPrime); if (logger.isDebugEnabled()) { logger.debug('authKeyValue(%s) = %s', authKeyValue.length, ...
javascript
function calculateAuthKeyValue(context) { var ga = context.serverDHInnerData.g_a; var b = context.b; var dhPrime = context.serverDHInnerData.dh_prime; var authKeyValue = utility.modPow(ga, b, dhPrime); if (logger.isDebugEnabled()) { logger.debug('authKeyValue(%s) = %s', authKeyValue.length, ...
[ "function", "calculateAuthKeyValue", "(", "context", ")", "{", "var", "ga", "=", "context", ".", "serverDHInnerData", ".", "g_a", ";", "var", "b", "=", "context", ".", "b", ";", "var", "dhPrime", "=", "context", ".", "serverDHInnerData", ".", "dh_prime", "...
Calculate the authentication key value
[ "Calculate", "the", "authentication", "key", "value" ]
f069dfcea2d023fc1ca837c5673d3abe26d44d28
https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/set-client-dh-params.js#L120-L130
22,538
enricostara/telegram-mt-node
lib/auth/set-client-dh-params.js
createAuthKeyID
function createAuthKeyID(context) { var authKeyHash = utility.createSHAHash(context.authKeyValue); var authKeyAuxHash = authKeyHash.slice(0, 8); var authKeyID = authKeyHash.slice(-8); if (logger.isDebugEnabled()) { logger.debug('authKeyID(%s) = %s', authKeyID.length, authKeyID.toString('hex')); ...
javascript
function createAuthKeyID(context) { var authKeyHash = utility.createSHAHash(context.authKeyValue); var authKeyAuxHash = authKeyHash.slice(0, 8); var authKeyID = authKeyHash.slice(-8); if (logger.isDebugEnabled()) { logger.debug('authKeyID(%s) = %s', authKeyID.length, authKeyID.toString('hex')); ...
[ "function", "createAuthKeyID", "(", "context", ")", "{", "var", "authKeyHash", "=", "utility", ".", "createSHAHash", "(", "context", ".", "authKeyValue", ")", ";", "var", "authKeyAuxHash", "=", "authKeyHash", ".", "slice", "(", "0", ",", "8", ")", ";", "va...
Calculate AuthKey hash and ID
[ "Calculate", "AuthKey", "hash", "and", "ID" ]
f069dfcea2d023fc1ca837c5673d3abe26d44d28
https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/set-client-dh-params.js#L133-L143
22,539
enricostara/telegram-mt-node
lib/auth/set-client-dh-params.js
checkNonceMatch
function checkNonceMatch(context) { var newNonce1 = Buffer.concat([utility.string2Buffer(context.newNonce, 32), new Buffer([1]), context.authKeyAuxHash]); var newNonceHash = utility.buffer2String(utility.createSHAHash(newNonce1).slice(-16)); var serverNewNonceHash = context.setClientDHParamsAnswer.new_nonce...
javascript
function checkNonceMatch(context) { var newNonce1 = Buffer.concat([utility.string2Buffer(context.newNonce, 32), new Buffer([1]), context.authKeyAuxHash]); var newNonceHash = utility.buffer2String(utility.createSHAHash(newNonce1).slice(-16)); var serverNewNonceHash = context.setClientDHParamsAnswer.new_nonce...
[ "function", "checkNonceMatch", "(", "context", ")", "{", "var", "newNonce1", "=", "Buffer", ".", "concat", "(", "[", "utility", ".", "string2Buffer", "(", "context", ".", "newNonce", ",", "32", ")", ",", "new", "Buffer", "(", "[", "1", "]", ")", ",", ...
Withstand replay-attacks
[ "Withstand", "replay", "-", "attacks" ]
f069dfcea2d023fc1ca837c5673d3abe26d44d28
https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/set-client-dh-params.js#L146-L158
22,540
enricostara/telegram-mt-node
lib/auth/set-client-dh-params.js
createAuthKey
function createAuthKey(context) { // Extract the nonces var newNonce = utility.string2Buffer(context.newNonce, 32); var serverNonce = utility.string2Buffer(context.resPQ.server_nonce, 16); // Create the serverSalt var serverSalt = utility.xor(newNonce.slice(0, 8), serverNonce.slice(0, 8)); if (l...
javascript
function createAuthKey(context) { // Extract the nonces var newNonce = utility.string2Buffer(context.newNonce, 32); var serverNonce = utility.string2Buffer(context.resPQ.server_nonce, 16); // Create the serverSalt var serverSalt = utility.xor(newNonce.slice(0, 8), serverNonce.slice(0, 8)); if (l...
[ "function", "createAuthKey", "(", "context", ")", "{", "// Extract the nonces", "var", "newNonce", "=", "utility", ".", "string2Buffer", "(", "context", ".", "newNonce", ",", "32", ")", ";", "var", "serverNonce", "=", "utility", ".", "string2Buffer", "(", "con...
Create the AuthKey
[ "Create", "the", "AuthKey" ]
f069dfcea2d023fc1ca837c5673d3abe26d44d28
https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/set-client-dh-params.js#L161-L180
22,541
enricostara/telegram-mt-node
lib/security/public-key.js
PublicKey
function PublicKey(params) { this._fingerprint = params.fingerprint; this._modulus = params.modulus; this._exponent = params.exponent; }
javascript
function PublicKey(params) { this._fingerprint = params.fingerprint; this._modulus = params.modulus; this._exponent = params.exponent; }
[ "function", "PublicKey", "(", "params", ")", "{", "this", ".", "_fingerprint", "=", "params", ".", "fingerprint", ";", "this", ".", "_modulus", "=", "params", ".", "modulus", ";", "this", ".", "_exponent", "=", "params", ".", "exponent", ";", "}" ]
PublicKey class This class represents a Public Key The constructor requires the fingerprint, the modulus and the exponent
[ "PublicKey", "class", "This", "class", "represents", "a", "Public", "Key", "The", "constructor", "requires", "the", "fingerprint", "the", "modulus", "and", "the", "exponent" ]
f069dfcea2d023fc1ca837c5673d3abe26d44d28
https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/security/public-key.js#L11-L15
22,542
jschyma/open_fints_js_client
lib/Classes.js
function (error, order, recvMsg) { if (error) { me_order.client.MsgEndDialog(function (error2, recvMsg2) { if (error2) { me_order.client.log.con.error({ error: error2 }, 'Connection close failed after error.') } else { me_order.client.l...
javascript
function (error, order, recvMsg) { if (error) { me_order.client.MsgEndDialog(function (error2, recvMsg2) { if (error2) { me_order.client.log.con.error({ error: error2 }, 'Connection close failed after error.') } else { me_order.client.l...
[ "function", "(", "error", ",", "order", ",", "recvMsg", ")", "{", "if", "(", "error", ")", "{", "me_order", ".", "client", ".", "MsgEndDialog", "(", "function", "(", "error2", ",", "recvMsg2", ")", "{", "if", "(", "error2", ")", "{", "me_order", ".",...
Exit CB is called when the function returns here it is checked if an error occures and then disconnects
[ "Exit", "CB", "is", "called", "when", "the", "function", "returns", "here", "it", "is", "checked", "if", "an", "error", "occures", "and", "then", "disconnects" ]
1d3a36bebeb40511e99def61b2e3f25c4248d288
https://github.com/jschyma/open_fints_js_client/blob/1d3a36bebeb40511e99def61b2e3f25c4248d288/lib/Classes.js#L896-L909
22,543
modofunjs/modofun
index.js
createServiceHandler
function createServiceHandler(handlers = {}, options = {}, shortcutType) { const errorHandler = options.errorHandler || defaultErrorHandler; const middleware = options.middleware || Array.isArray(options) && options || []; const mode = options.mode || FUNCTION_MODE; const checkArity = options.checkArity === und...
javascript
function createServiceHandler(handlers = {}, options = {}, shortcutType) { const errorHandler = options.errorHandler || defaultErrorHandler; const middleware = options.middleware || Array.isArray(options) && options || []; const mode = options.mode || FUNCTION_MODE; const checkArity = options.checkArity === und...
[ "function", "createServiceHandler", "(", "handlers", "=", "{", "}", ",", "options", "=", "{", "}", ",", "shortcutType", ")", "{", "const", "errorHandler", "=", "options", ".", "errorHandler", "||", "defaultErrorHandler", ";", "const", "middleware", "=", "optio...
The exported function that creates the request handler using the supplied handlers and configuration. Returns a handler with either function(req, res) signature or function(event, context, callback) signature. Example: var app = modofun( { authenticate: authenticate, user: [authorize, getUser] }, { middleware: [logg...
[ "The", "exported", "function", "that", "creates", "the", "request", "handler", "using", "the", "supplied", "handlers", "and", "configuration", "." ]
df5ea1b4d930a0bf1884e6926493b4eb246f5ae2
https://github.com/modofunjs/modofun/blob/df5ea1b4d930a0bf1884e6926493b4eb246f5ae2/index.js#L171-L206
22,544
modofunjs/modofun
index.js
handleRequest
function handleRequest(middleware, handlers, mode, checkArity, req, res, errorHandler) { const done = err => err && setImmediate(errorHandler, err, req, res); // run global middleware first, then start handling request // this is important to allow loggers for example to kick-in regardless runMiddlewareStack(mi...
javascript
function handleRequest(middleware, handlers, mode, checkArity, req, res, errorHandler) { const done = err => err && setImmediate(errorHandler, err, req, res); // run global middleware first, then start handling request // this is important to allow loggers for example to kick-in regardless runMiddlewareStack(mi...
[ "function", "handleRequest", "(", "middleware", ",", "handlers", ",", "mode", ",", "checkArity", ",", "req", ",", "res", ",", "errorHandler", ")", "{", "const", "done", "=", "err", "=>", "err", "&&", "setImmediate", "(", "errorHandler", ",", "err", ",", ...
Execute middleware stack and handle request. @private
[ "Execute", "middleware", "stack", "and", "handle", "request", "." ]
df5ea1b4d930a0bf1884e6926493b4eb246f5ae2
https://github.com/modofunjs/modofun/blob/df5ea1b4d930a0bf1884e6926493b4eb246f5ae2/index.js#L212-L224
22,545
modofunjs/modofun
index.js
handleOperation
function handleOperation(handlers, mode, checkArity, req, res, done) { // parse path: // - first part is the operation name // - the following components of the path are used as arguments const parsedParts = parsePath(req); if (parsedParts[0].length === 0) { done(new ModofunError(403, 'NoOperation', 'Oper...
javascript
function handleOperation(handlers, mode, checkArity, req, res, done) { // parse path: // - first part is the operation name // - the following components of the path are used as arguments const parsedParts = parsePath(req); if (parsedParts[0].length === 0) { done(new ModofunError(403, 'NoOperation', 'Oper...
[ "function", "handleOperation", "(", "handlers", ",", "mode", ",", "checkArity", ",", "req", ",", "res", ",", "done", ")", "{", "// parse path:", "// - first part is the operation name", "// - the following components of the path are used as arguments", "const", "parsedParts",...
Try to apply supplied handlers to the requested operation. @private
[ "Try", "to", "apply", "supplied", "handlers", "to", "the", "requested", "operation", "." ]
df5ea1b4d930a0bf1884e6926493b4eb246f5ae2
https://github.com/modofunjs/modofun/blob/df5ea1b4d930a0bf1884e6926493b4eb246f5ae2/index.js#L230-L282
22,546
modofunjs/modofun
index.js
invokeHTTPHandler
function invokeHTTPHandler(handler, args, req, res, done) { // inject parsed parameters into request req.params = args; // call handler with typical HTTP request/response parameters let result = handler(req, res); // handle results that are not a trusted Promise with Promise.resolve() // which also supports...
javascript
function invokeHTTPHandler(handler, args, req, res, done) { // inject parsed parameters into request req.params = args; // call handler with typical HTTP request/response parameters let result = handler(req, res); // handle results that are not a trusted Promise with Promise.resolve() // which also supports...
[ "function", "invokeHTTPHandler", "(", "handler", ",", "args", ",", "req", ",", "res", ",", "done", ")", "{", "// inject parsed parameters into request", "req", ".", "params", "=", "args", ";", "// call handler with typical HTTP request/response parameters", "let", "resu...
Invoke the provided request handler function. This handler function must send a response. If the handler returns a Promise, it will handle the error if the Promise is rejected. @private
[ "Invoke", "the", "provided", "request", "handler", "function", ".", "This", "handler", "function", "must", "send", "a", "response", ".", "If", "the", "handler", "returns", "a", "Promise", "it", "will", "handle", "the", "error", "if", "the", "Promise", "is", ...
df5ea1b4d930a0bf1884e6926493b4eb246f5ae2
https://github.com/modofunjs/modofun/blob/df5ea1b4d930a0bf1884e6926493b4eb246f5ae2/index.js#L330-L341
22,547
modofunjs/modofun
index.js
invokeFunctionHandler
function invokeFunctionHandler(handler, args, checkArity, req, res, done) { // check if number of arguments provided matches the handler function arity if (checkArity && args.length < handler.length) { // < due to possible optionals done(new ModofunError(400, 'InvalidInput', `This operation requires ${han...
javascript
function invokeFunctionHandler(handler, args, checkArity, req, res, done) { // check if number of arguments provided matches the handler function arity if (checkArity && args.length < handler.length) { // < due to possible optionals done(new ModofunError(400, 'InvalidInput', `This operation requires ${han...
[ "function", "invokeFunctionHandler", "(", "handler", ",", "args", ",", "checkArity", ",", "req", ",", "res", ",", "done", ")", "{", "// check if number of arguments provided matches the handler function arity", "if", "(", "checkArity", "&&", "args", ".", "length", "<"...
Invoke the provided request handler function. The handler should return a value or a Promised value which will be added to the reponse automatically. @private
[ "Invoke", "the", "provided", "request", "handler", "function", ".", "The", "handler", "should", "return", "a", "value", "or", "a", "Promised", "value", "which", "will", "be", "added", "to", "the", "reponse", "automatically", "." ]
df5ea1b4d930a0bf1884e6926493b4eb246f5ae2
https://github.com/modofunjs/modofun/blob/df5ea1b4d930a0bf1884e6926493b4eb246f5ae2/index.js#L349-L387
22,548
modofunjs/modofun
index.js
defaultErrorHandler
function defaultErrorHandler(err, req, res) { if (err.name === 'UnauthorizedError') { // authentication is expected to be a common use-case res.status(401).end(); } else { if (!err.status || err.status >= 500) { console.error(err.stack || err.toString()); } res.status(err.status || 500).json({...
javascript
function defaultErrorHandler(err, req, res) { if (err.name === 'UnauthorizedError') { // authentication is expected to be a common use-case res.status(401).end(); } else { if (!err.status || err.status >= 500) { console.error(err.stack || err.toString()); } res.status(err.status || 500).json({...
[ "function", "defaultErrorHandler", "(", "err", ",", "req", ",", "res", ")", "{", "if", "(", "err", ".", "name", "===", "'UnauthorizedError'", ")", "{", "// authentication is expected to be a common use-case", "res", ".", "status", "(", "401", ")", ".", "end", ...
The default error handler, in case none is provided by the application. @private
[ "The", "default", "error", "handler", "in", "case", "none", "is", "provided", "by", "the", "application", "." ]
df5ea1b4d930a0bf1884e6926493b4eb246f5ae2
https://github.com/modofunjs/modofun/blob/df5ea1b4d930a0bf1884e6926493b4eb246f5ae2/index.js#L393-L402
22,549
modofunjs/modofun
index.js
parsePath
function parsePath(req) { // get path if preprocessed or otherwise separate path from query string const path = req.path || (req.url && req.url.split('?')[0]) || ''; // ignore start and end slashes, and split the path return path.replace(/^\/|\/$/g, '').split('/'); }
javascript
function parsePath(req) { // get path if preprocessed or otherwise separate path from query string const path = req.path || (req.url && req.url.split('?')[0]) || ''; // ignore start and end slashes, and split the path return path.replace(/^\/|\/$/g, '').split('/'); }
[ "function", "parsePath", "(", "req", ")", "{", "// get path if preprocessed or otherwise separate path from query string", "const", "path", "=", "req", ".", "path", "||", "(", "req", ".", "url", "&&", "req", ".", "url", ".", "split", "(", "'?'", ")", "[", "0",...
Parse URL path to an array of its components. @private
[ "Parse", "URL", "path", "to", "an", "array", "of", "its", "components", "." ]
df5ea1b4d930a0bf1884e6926493b4eb246f5ae2
https://github.com/modofunjs/modofun/blob/df5ea1b4d930a0bf1884e6926493b4eb246f5ae2/index.js#L408-L413
22,550
modofunjs/modofun
index.js
arity
function arity(min, max = Number.MAX_SAFE_INTEGER) { return (req, res, next) => { const foundArity = parsePath(req).length-1; if (foundArity < min ) { next(new ModofunError(400, 'InvalidInput', `This operation requires ${min} parameters. Received ${foundArity}.`)); } else if (foundArity > ma...
javascript
function arity(min, max = Number.MAX_SAFE_INTEGER) { return (req, res, next) => { const foundArity = parsePath(req).length-1; if (foundArity < min ) { next(new ModofunError(400, 'InvalidInput', `This operation requires ${min} parameters. Received ${foundArity}.`)); } else if (foundArity > ma...
[ "function", "arity", "(", "min", ",", "max", "=", "Number", ".", "MAX_SAFE_INTEGER", ")", "{", "return", "(", "req", ",", "res", ",", "next", ")", "=>", "{", "const", "foundArity", "=", "parsePath", "(", "req", ")", ".", "length", "-", "1", ";", "i...
Utility middleware to enforce a minimum number of parameters. Accepts an extra argument for an optional maximum number. @public
[ "Utility", "middleware", "to", "enforce", "a", "minimum", "number", "of", "parameters", ".", "Accepts", "an", "extra", "argument", "for", "an", "optional", "maximum", "number", "." ]
df5ea1b4d930a0bf1884e6926493b4eb246f5ae2
https://github.com/modofunjs/modofun/blob/df5ea1b4d930a0bf1884e6926493b4eb246f5ae2/index.js#L420-L433
22,551
dominictarr/hashlru
bench.js
run
function run (N, op, init) { var stats = null, value for(var j = 0; j < 100; j++) { if(init) value = init(j) var start = Date.now() for(var i = 0; i < N; i++) op(value, i) stats = Stats(stats, N/((Date.now() - start))) } return stats }
javascript
function run (N, op, init) { var stats = null, value for(var j = 0; j < 100; j++) { if(init) value = init(j) var start = Date.now() for(var i = 0; i < N; i++) op(value, i) stats = Stats(stats, N/((Date.now() - start))) } return stats }
[ "function", "run", "(", "N", ",", "op", ",", "init", ")", "{", "var", "stats", "=", "null", ",", "value", "for", "(", "var", "j", "=", "0", ";", "j", "<", "100", ";", "j", "++", ")", "{", "if", "(", "init", ")", "value", "=", "init", "(", ...
simple benchmarks, and measure standard deviation
[ "simple", "benchmarks", "and", "measure", "standard", "deviation" ]
522050a6ce00af236e17c709d38621261b87d590
https://github.com/dominictarr/hashlru/blob/522050a6ce00af236e17c709d38621261b87d590/bench.js#L6-L15
22,552
keystonejs/keystone-nightwatch-e2e
lib/src/pageObjects/adminUIApp.js
function (config) { if (config) { if (config.element) { this.expect.element(config.element).to.not.be.visible; } else { throw new Error('adminUIApp:must specify an element!'); } } else { throw new Error('adminUIApp:invalid config specification!'); } return this; }
javascript
function (config) { if (config) { if (config.element) { this.expect.element(config.element).to.not.be.visible; } else { throw new Error('adminUIApp:must specify an element!'); } } else { throw new Error('adminUIApp:invalid config specification!'); } return this; }
[ "function", "(", "config", ")", "{", "if", "(", "config", ")", "{", "if", "(", "config", ".", "element", ")", "{", "this", ".", "expect", ".", "element", "(", "config", ".", "element", ")", ".", "to", ".", "not", ".", "be", ".", "visible", ";", ...
Asserts that the specified home screen element UI is not visible. @param {Object} config The config spec. @param {string} config.element The element whose UI should not be visible.
[ "Asserts", "that", "the", "specified", "home", "screen", "element", "UI", "is", "not", "visible", "." ]
4329b4b296ade1339363837f9f11ba4ea42e1858
https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUIApp.js#L48-L59
22,553
keystonejs/keystone-nightwatch-e2e
lib/src/pageObjects/adminUIApp.js
function (config) { if (config) { if (config.element) { this.expect.element(config.element).to.be.present; } else { throw new Error('adminUIApp:must specify an element!'); } } else { throw new Error('adminUIApp:invalid config specification!'); } return this; }
javascript
function (config) { if (config) { if (config.element) { this.expect.element(config.element).to.be.present; } else { throw new Error('adminUIApp:must specify an element!'); } } else { throw new Error('adminUIApp:invalid config specification!'); } return this; }
[ "function", "(", "config", ")", "{", "if", "(", "config", ")", "{", "if", "(", "config", ".", "element", ")", "{", "this", ".", "expect", ".", "element", "(", "config", ".", "element", ")", ".", "to", ".", "be", ".", "present", ";", "}", "else", ...
Asserts that the specified home screen element DOM is present. @param {Object} config The config spec. @param {string} config.element The element whose DOM should be present.
[ "Asserts", "that", "the", "specified", "home", "screen", "element", "DOM", "is", "present", "." ]
4329b4b296ade1339363837f9f11ba4ea42e1858
https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUIApp.js#L67-L78
22,554
keystonejs/keystone-nightwatch-e2e
lib/src/pageObjects/adminUIApp.js
function (config) { if (config) { if (config.element && config.text) { this.expect.element(config.element).text.to.equal(config.text); } else { throw new Error('adminUIApp:must specify an element and text!'); } } else { throw new Error('adminUIApp:invalid config specification!'); } ...
javascript
function (config) { if (config) { if (config.element && config.text) { this.expect.element(config.element).text.to.equal(config.text); } else { throw new Error('adminUIApp:must specify an element and text!'); } } else { throw new Error('adminUIApp:invalid config specification!'); } ...
[ "function", "(", "config", ")", "{", "if", "(", "config", ")", "{", "if", "(", "config", ".", "element", "&&", "config", ".", "text", ")", "{", "this", ".", "expect", ".", "element", "(", "config", ".", "element", ")", ".", "text", ".", "to", "."...
Asserts that the specified home screen element text equals the specified value. @param {Object} config The config spec. @param {string} config.element The element whose text should be compared to the input text. @param {String} config.text The text to compare against.
[ "Asserts", "that", "the", "specified", "home", "screen", "element", "text", "equals", "the", "specified", "value", "." ]
4329b4b296ade1339363837f9f11ba4ea42e1858
https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUIApp.js#L106-L117
22,555
keystonejs/keystone-nightwatch-e2e
lib/src/pageObjects/adminUIApp.js
function (config) { if (config) { if (config.element && config.text) { this.expect.element(config.element).text.to.contain(config.text); } else { throw new Error('adminUIApp:must specify an element and text!'); } } else { throw new Error('adminUIApp:invalid config specification!'); } ...
javascript
function (config) { if (config) { if (config.element && config.text) { this.expect.element(config.element).text.to.contain(config.text); } else { throw new Error('adminUIApp:must specify an element and text!'); } } else { throw new Error('adminUIApp:invalid config specification!'); } ...
[ "function", "(", "config", ")", "{", "if", "(", "config", ")", "{", "if", "(", "config", ".", "element", "&&", "config", ".", "text", ")", "{", "this", ".", "expect", ".", "element", "(", "config", ".", "element", ")", ".", "text", ".", "to", "."...
Asserts that the specified home screen element text contains the specified value. @param {Object} config The config spec. @param {string} config.element The element whose text should contain the input text. @param {String} config.text The text to compare against.
[ "Asserts", "that", "the", "specified", "home", "screen", "element", "text", "contains", "the", "specified", "value", "." ]
4329b4b296ade1339363837f9f11ba4ea42e1858
https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUIApp.js#L146-L157
22,556
keystonejs/keystone-nightwatch-e2e
lib/src/pageObjects/adminUIApp.js
function (config) { if (config) { if (config.element && config.attribute && config.value) { this.expect.element(config.element).to.have.attribute(config.attribute).which.contains(config.value); } else { throw new Error('adminUIApp:must specify a config element, attribute, and value!'); } } e...
javascript
function (config) { if (config) { if (config.element && config.attribute && config.value) { this.expect.element(config.element).to.have.attribute(config.attribute).which.contains(config.value); } else { throw new Error('adminUIApp:must specify a config element, attribute, and value!'); } } e...
[ "function", "(", "config", ")", "{", "if", "(", "config", ")", "{", "if", "(", "config", ".", "element", "&&", "config", ".", "attribute", "&&", "config", ".", "value", ")", "{", "this", ".", "expect", ".", "element", "(", "config", ".", "element", ...
Asserts that the specified home screen element has the specified attribute. @param {Object} config The config spec. @param {string} config.element The element whose UI should be visible. @param {string} config.attribute The attribute that should be present in the element. @param {string} config.value The value that th...
[ "Asserts", "that", "the", "specified", "home", "screen", "element", "has", "the", "specified", "attribute", "." ]
4329b4b296ade1339363837f9f11ba4ea42e1858
https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUIApp.js#L167-L178
22,557
keystonejs/keystone-nightwatch-e2e
lib/src/pageObjects/adminUIApp.js
function (config) { var _config = objectAssign({}, { wait: true }, config); this.navigate(); if (_config.wait) this.waitForSigninScreen(); return this; }
javascript
function (config) { var _config = objectAssign({}, { wait: true }, config); this.navigate(); if (_config.wait) this.waitForSigninScreen(); return this; }
[ "function", "(", "config", ")", "{", "var", "_config", "=", "objectAssign", "(", "{", "}", ",", "{", "wait", ":", "true", "}", ",", "config", ")", ";", "this", ".", "navigate", "(", ")", ";", "if", "(", "_config", ".", "wait", ")", "this", ".", ...
Navigates to the signin screen. @param {Object} config The config spec. @param {boolean} config.wait Whether to wait for the target UI. Optional, defaults to true.
[ "Navigates", "to", "the", "signin", "screen", "." ]
4329b4b296ade1339363837f9f11ba4ea42e1858
https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUIApp.js#L186-L191
22,558
keystonejs/keystone-nightwatch-e2e
lib/src/pageObjects/adminUIApp.js
function (config) { var _config = objectAssign({}, { wait: true }, config); this.navigate(); if (_config.wait) this.waitForHomeScreen(); return this; }
javascript
function (config) { var _config = objectAssign({}, { wait: true }, config); this.navigate(); if (_config.wait) this.waitForHomeScreen(); return this; }
[ "function", "(", "config", ")", "{", "var", "_config", "=", "objectAssign", "(", "{", "}", ",", "{", "wait", ":", "true", "}", ",", "config", ")", ";", "this", ".", "navigate", "(", ")", ";", "if", "(", "_config", ".", "wait", ")", "this", ".", ...
Navigates to the home screen. @param {Object} config The config spec. @param {boolean} config.wait Whether to wait for the target UI. Optional, defaults to true.
[ "Navigates", "to", "the", "home", "screen", "." ]
4329b4b296ade1339363837f9f11ba4ea42e1858
https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUIApp.js#L199-L204
22,559
keystonejs/keystone-nightwatch-e2e
lib/src/pageObjects/adminUIApp.js
function (config) { var _config = objectAssign({}, { wait: true }, config); if (_config.section && _config.list) { this.clickPrimaryNavbar({ section: _config.section }) .waitForForSecondaryNavbar() .clickSecondaryNavbar({ list: _config.list }); } else { throw new Error('adminUIApp:must specif...
javascript
function (config) { var _config = objectAssign({}, { wait: true }, config); if (_config.section && _config.list) { this.clickPrimaryNavbar({ section: _config.section }) .waitForForSecondaryNavbar() .clickSecondaryNavbar({ list: _config.list }); } else { throw new Error('adminUIApp:must specif...
[ "function", "(", "config", ")", "{", "var", "_config", "=", "objectAssign", "(", "{", "}", ",", "{", "wait", ":", "true", "}", ",", "config", ")", ";", "if", "(", "_config", ".", "section", "&&", "_config", ".", "list", ")", "{", "this", ".", "cl...
Opens the list of items given the specified list config spec. @param {Object} config The config spec. @param {string} config.section The section in the primary navbar to click on. @param {string} config.list The list in the secondary navbar to click on. @param {boolean} config.wait Whether to wait for the target UI. ...
[ "Opens", "the", "list", "of", "items", "given", "the", "specified", "list", "config", "spec", "." ]
4329b4b296ade1339363837f9f11ba4ea42e1858
https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUIApp.js#L214-L225
22,560
keystonejs/keystone-nightwatch-e2e
lib/src/pageObjects/adminUIApp.js
function (config) { var _config = objectAssign({}, { wait: true }, config); if (_config.section) { this.click(this.getPrimaryNavbarSectionElement({ section: _config.section })); } else { throw new Error('adminUIApp:must specify a navbar section!'); } if (_config.wait) this.waitForForSecondaryNavb...
javascript
function (config) { var _config = objectAssign({}, { wait: true }, config); if (_config.section) { this.click(this.getPrimaryNavbarSectionElement({ section: _config.section })); } else { throw new Error('adminUIApp:must specify a navbar section!'); } if (_config.wait) this.waitForForSecondaryNavb...
[ "function", "(", "config", ")", "{", "var", "_config", "=", "objectAssign", "(", "{", "}", ",", "{", "wait", ":", "true", "}", ",", "config", ")", ";", "if", "(", "_config", ".", "section", ")", "{", "this", ".", "click", "(", "this", ".", "getPr...
Clicks the specified section in the primary navbar. @param {Object} config The config spec. @param {string} config.section The section in the primary navbar to click on. @param {boolean} config.wait Whether to wait for the target UI. Optional, defaults to true.
[ "Clicks", "the", "specified", "section", "in", "the", "primary", "navbar", "." ]
4329b4b296ade1339363837f9f11ba4ea42e1858
https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUIApp.js#L234-L243
22,561
keystonejs/keystone-nightwatch-e2e
lib/src/pageObjects/adminUIApp.js
function (config) { var _config = objectAssign({}, { wait: true }, config); if (_config.list) { this.click(this.getSecondaryNavbarListElement({ list: _config.list })); } else { throw new Error('adminUIApp:must specify a navbar list!'); } if (_config.wait) this.waitForListScreen(); return this;...
javascript
function (config) { var _config = objectAssign({}, { wait: true }, config); if (_config.list) { this.click(this.getSecondaryNavbarListElement({ list: _config.list })); } else { throw new Error('adminUIApp:must specify a navbar list!'); } if (_config.wait) this.waitForListScreen(); return this;...
[ "function", "(", "config", ")", "{", "var", "_config", "=", "objectAssign", "(", "{", "}", ",", "{", "wait", ":", "true", "}", ",", "config", ")", ";", "if", "(", "_config", ".", "list", ")", "{", "this", ".", "click", "(", "this", ".", "getSecon...
Clicks the specified list in the secondary navbar. @param {Object} config The config spec. @param {string} list The list in the secondary navbar to click on. @param {boolean} config.wait Whether to wait for the target UI. Optional, defaults to true.
[ "Clicks", "the", "specified", "list", "in", "the", "secondary", "navbar", "." ]
4329b4b296ade1339363837f9f11ba4ea42e1858
https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUIApp.js#L252-L261
22,562
keystonejs/keystone-nightwatch-e2e
lib/src/pageObjects/adminUIApp.js
function (config) { var _config = objectAssign({}, { timeout: this.api.globals.waitForConditionTimeout }, config); this.waitForElementVisible('@signinScreen', _config.timeout); this.api.pause(self.screenTransitionTimeout); return this; }
javascript
function (config) { var _config = objectAssign({}, { timeout: this.api.globals.waitForConditionTimeout }, config); this.waitForElementVisible('@signinScreen', _config.timeout); this.api.pause(self.screenTransitionTimeout); return this; }
[ "function", "(", "config", ")", "{", "var", "_config", "=", "objectAssign", "(", "{", "}", ",", "{", "timeout", ":", "this", ".", "api", ".", "globals", ".", "waitForConditionTimeout", "}", ",", "config", ")", ";", "this", ".", "waitForElementVisible", "...
Waits for the signin screen UI to be visible. @param {Object} config The config spec. @param {number} config.timeout Optional timeout to wait for.
[ "Waits", "for", "the", "signin", "screen", "UI", "to", "be", "visible", "." ]
4329b4b296ade1339363837f9f11ba4ea42e1858
https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUIApp.js#L284-L289
22,563
keystonejs/keystone-nightwatch-e2e
lib/src/pageObjects/adminUIApp.js
function (config) { return this.expect.element(this.getPrimaryNavbarSectionElement({ section: config.section })).to.be.visible; }
javascript
function (config) { return this.expect.element(this.getPrimaryNavbarSectionElement({ section: config.section })).to.be.visible; }
[ "function", "(", "config", ")", "{", "return", "this", ".", "expect", ".", "element", "(", "this", ".", "getPrimaryNavbarSectionElement", "(", "{", "section", ":", "config", ".", "section", "}", ")", ")", ".", "to", ".", "be", ".", "visible", ";", "}" ...
Asserts that the specified primary navbar section is visible. @param {Object} config The config spec. @param {string} config.section The section that should be visible in the primary navbar.
[ "Asserts", "that", "the", "specified", "primary", "navbar", "section", "is", "visible", "." ]
4329b4b296ade1339363837f9f11ba4ea42e1858
https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUIApp.js#L389-L391
22,564
keystonejs/keystone-nightwatch-e2e
lib/src/pageObjects/adminUIApp.js
function (config) { return this.expect.element(this.getSecondaryNavbarListElement({ list: config.list })).to.be.visible; }
javascript
function (config) { return this.expect.element(this.getSecondaryNavbarListElement({ list: config.list })).to.be.visible; }
[ "function", "(", "config", ")", "{", "return", "this", ".", "expect", ".", "element", "(", "this", ".", "getSecondaryNavbarListElement", "(", "{", "list", ":", "config", ".", "list", "}", ")", ")", ".", "to", ".", "be", ".", "visible", ";", "}" ]
Asserts that the specified secondary navbar list is visible. Make sure that the parent primary navbar section is clicked on first. @param {Object} config The config spec. @param {string} config.list The list that should be visible in the secondary navbar.
[ "Asserts", "that", "the", "specified", "secondary", "navbar", "list", "is", "visible", ".", "Make", "sure", "that", "the", "parent", "primary", "navbar", "section", "is", "clicked", "on", "first", "." ]
4329b4b296ade1339363837f9f11ba4ea42e1858
https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUIApp.js#L400-L402
22,565
keystonejs/keystone-nightwatch-e2e
index.js
function (cb) { if (argv.env === 'default' && argv['selenium-in-background']) { process.env.KNE_SELENIUM_START_PROCESS = false; runSeleniumInBackground(cb); } else if (argv.env === 'default') { process.env.KNE_SELENIUM_START_PROCESS = true; cb(); } else { process.env.KNE_SEL...
javascript
function (cb) { if (argv.env === 'default' && argv['selenium-in-background']) { process.env.KNE_SELENIUM_START_PROCESS = false; runSeleniumInBackground(cb); } else if (argv.env === 'default') { process.env.KNE_SELENIUM_START_PROCESS = true; cb(); } else { process.env.KNE_SEL...
[ "function", "(", "cb", ")", "{", "if", "(", "argv", ".", "env", "===", "'default'", "&&", "argv", "[", "'selenium-in-background'", "]", ")", "{", "process", ".", "env", ".", "KNE_SELENIUM_START_PROCESS", "=", "false", ";", "runSeleniumInBackground", "(", "cb...
If the user wants us to start selenium manually then do so
[ "If", "the", "user", "wants", "us", "to", "start", "selenium", "manually", "then", "do", "so" ]
4329b4b296ade1339363837f9f11ba4ea42e1858
https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/index.js#L102-L113
22,566
keystonejs/keystone-nightwatch-e2e
index.js
function (cb) { if (argv.env === 'saucelabs-travis' || (argv.env === 'saucelabs-local' && argv['sauce-username'] && argv['sauce-access-key'])) { startSauceConnect(cb); } else { if (argv.env === 'saucelabs-local') { console.error([moment().format('HH:mm:ss:SSS')] + ' kne: You must specify --...
javascript
function (cb) { if (argv.env === 'saucelabs-travis' || (argv.env === 'saucelabs-local' && argv['sauce-username'] && argv['sauce-access-key'])) { startSauceConnect(cb); } else { if (argv.env === 'saucelabs-local') { console.error([moment().format('HH:mm:ss:SSS')] + ' kne: You must specify --...
[ "function", "(", "cb", ")", "{", "if", "(", "argv", ".", "env", "===", "'saucelabs-travis'", "||", "(", "argv", ".", "env", "===", "'saucelabs-local'", "&&", "argv", "[", "'sauce-username'", "]", "&&", "argv", "[", "'sauce-access-key'", "]", ")", ")", "{...
The only environment that currently requires starting sauce connect is travis.
[ "The", "only", "environment", "that", "currently", "requires", "starting", "sauce", "connect", "is", "travis", "." ]
4329b4b296ade1339363837f9f11ba4ea42e1858
https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/index.js#L118-L129
22,567
keystonejs/keystone-nightwatch-e2e
index.js
function (cb) { Nightwatch.runner(argv, function (status) { var err = null; if (status) { console.log([moment().format('HH:mm:ss:SSS')] + ' kne: tests passed'); } else { console.log([moment().format('HH:mm:ss:SSS')] + ' kne: tests failed'); err = new Error('kne: nightwatch ru...
javascript
function (cb) { Nightwatch.runner(argv, function (status) { var err = null; if (status) { console.log([moment().format('HH:mm:ss:SSS')] + ' kne: tests passed'); } else { console.log([moment().format('HH:mm:ss:SSS')] + ' kne: tests failed'); err = new Error('kne: nightwatch ru...
[ "function", "(", "cb", ")", "{", "Nightwatch", ".", "runner", "(", "argv", ",", "function", "(", "status", ")", "{", "var", "err", "=", "null", ";", "if", "(", "status", ")", "{", "console", ".", "log", "(", "[", "moment", "(", ")", ".", "format"...
Run nightwatch to start executing the tests
[ "Run", "nightwatch", "to", "start", "executing", "the", "tests" ]
4329b4b296ade1339363837f9f11ba4ea42e1858
https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/index.js#L134-L145
22,568
keystonejs/keystone-nightwatch-e2e
index.js
startSauceConnect
function startSauceConnect (done) { console.log([moment().format('HH:mm:ss:SSS')] + ' kne: Starting Sauce Connect'); var default_options = { username: process.env.SAUCE_USERNAME, accessKey: process.env.SAUCE_ACCESS_KEY, connectRetries: 5, connectRetryTimeout: 60000, logger: sauceConnectLog, readyFileId: ...
javascript
function startSauceConnect (done) { console.log([moment().format('HH:mm:ss:SSS')] + ' kne: Starting Sauce Connect'); var default_options = { username: process.env.SAUCE_USERNAME, accessKey: process.env.SAUCE_ACCESS_KEY, connectRetries: 5, connectRetryTimeout: 60000, logger: sauceConnectLog, readyFileId: ...
[ "function", "startSauceConnect", "(", "done", ")", "{", "console", ".", "log", "(", "[", "moment", "(", ")", ".", "format", "(", "'HH:mm:ss:SSS'", ")", "]", "+", "' kne: Starting Sauce Connect'", ")", ";", "var", "default_options", "=", "{", "username", ":",...
Function that starts the sauce connect servers if SAUCE_ACCESS_KEY is set.
[ "Function", "that", "starts", "the", "sauce", "connect", "servers", "if", "SAUCE_ACCESS_KEY", "is", "set", "." ]
4329b4b296ade1339363837f9f11ba4ea42e1858
https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/index.js#L168-L197
22,569
keystonejs/keystone-nightwatch-e2e
index.js
checkKeystoneReady
function checkKeystoneReady (keystone, done) { async.retry({ times: 10, interval: 3000, }, function (done, result) { console.log([moment().format('HH:mm:ss:SSS')] + ' kne: checking if KeystoneJS ready for request'); request .get('http://' + keystone.get('host') + ':' + keystone.get('port') + '/keystone') ...
javascript
function checkKeystoneReady (keystone, done) { async.retry({ times: 10, interval: 3000, }, function (done, result) { console.log([moment().format('HH:mm:ss:SSS')] + ' kne: checking if KeystoneJS ready for request'); request .get('http://' + keystone.get('host') + ':' + keystone.get('port') + '/keystone') ...
[ "function", "checkKeystoneReady", "(", "keystone", ",", "done", ")", "{", "async", ".", "retry", "(", "{", "times", ":", "10", ",", "interval", ":", "3000", ",", "}", ",", "function", "(", "done", ",", "result", ")", "{", "console", ".", "log", "(", ...
Function that checks if keystone is ready before starting testing
[ "Function", "that", "checks", "if", "keystone", "is", "ready", "before", "starting", "testing" ]
4329b4b296ade1339363837f9f11ba4ea42e1858
https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/index.js#L213-L231
22,570
keystonejs/keystone-nightwatch-e2e
lib/src/pageObjects/adminUISignin.js
function (config) { var _config = objectAssign({}, { user: 'user@test.e2e', password: 'test', wait: true }, config); this .setValue('@email', _config.user) .setValue('@password', _config.password) .click('@submitButton'); if (_config.wait) this.api.page.adminUIApp().waitForHomeScreen(); return t...
javascript
function (config) { var _config = objectAssign({}, { user: 'user@test.e2e', password: 'test', wait: true }, config); this .setValue('@email', _config.user) .setValue('@password', _config.password) .click('@submitButton'); if (_config.wait) this.api.page.adminUIApp().waitForHomeScreen(); return t...
[ "function", "(", "config", ")", "{", "var", "_config", "=", "objectAssign", "(", "{", "}", ",", "{", "user", ":", "'user@test.e2e'", ",", "password", ":", "'test'", ",", "wait", ":", "true", "}", ",", "config", ")", ";", "this", ".", "setValue", "(",...
Signs in to the Admin UI. @param {Object} config The login info. @param {string} config.user The login username/email. @param {string} config.password The login password. @param {boolean} config.wait Whether to wait for the home screen by default. Optional, defaults to true.
[ "Signs", "in", "to", "the", "Admin", "UI", "." ]
4329b4b296ade1339363837f9f11ba4ea42e1858
https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUISignin.js#L29-L37
22,571
googlearchive/backbonefire
examples/todos/js/backbonefire.js
function(model, options) { Backbone.Model.apply(this, arguments); var defaults = _.result(this, 'defaults'); // Apply defaults only after first sync. this.once('sync', function() { this.set(_.defaults(this.toJSON(), defaults)); }); this.autoSync = Backbone.Fir...
javascript
function(model, options) { Backbone.Model.apply(this, arguments); var defaults = _.result(this, 'defaults'); // Apply defaults only after first sync. this.once('sync', function() { this.set(_.defaults(this.toJSON(), defaults)); }); this.autoSync = Backbone.Fir...
[ "function", "(", "model", ",", "options", ")", "{", "Backbone", ".", "Model", ".", "apply", "(", "this", ",", "arguments", ")", ";", "var", "defaults", "=", "_", ".", "result", "(", "this", ",", "'defaults'", ")", ";", "// Apply defaults only after first s...
Determine whether the realtime or once methods apply
[ "Determine", "whether", "the", "realtime", "or", "once", "methods", "apply" ]
d6278d4aeb0743bdd7e9de96cc56d4e64476778b
https://github.com/googlearchive/backbonefire/blob/d6278d4aeb0743bdd7e9de96cc56d4e64476778b/examples/todos/js/backbonefire.js#L276-L309
22,572
googlearchive/backbonefire
examples/todos/js/backbonefire.js
function(snap) { var newModel = Backbone.Firebase._checkId(snap); if (typeof newModel === 'object' && newModel !== null) { var diff = _.difference(_.keys(this.attributes), _.keys(newModel)); _.each(diff, _.bind(function(key) { this.unset(key); }, this)); ...
javascript
function(snap) { var newModel = Backbone.Firebase._checkId(snap); if (typeof newModel === 'object' && newModel !== null) { var diff = _.difference(_.keys(this.attributes), _.keys(newModel)); _.each(diff, _.bind(function(key) { this.unset(key); }, this)); ...
[ "function", "(", "snap", ")", "{", "var", "newModel", "=", "Backbone", ".", "Firebase", ".", "_checkId", "(", "snap", ")", ";", "if", "(", "typeof", "newModel", "===", "'object'", "&&", "newModel", "!==", "null", ")", "{", "var", "diff", "=", "_", "....
Unset attributes that have been deleted from the server by comparing the keys that have been removed.
[ "Unset", "attributes", "that", "have", "been", "deleted", "from", "the", "server", "by", "comparing", "the", "keys", "that", "have", "been", "removed", "." ]
d6278d4aeb0743bdd7e9de96cc56d4e64476778b
https://github.com/googlearchive/backbonefire/blob/d6278d4aeb0743bdd7e9de96cc56d4e64476778b/examples/todos/js/backbonefire.js#L334-L348
22,573
googlearchive/backbonefire
examples/todos/js/backbonefire.js
function(model) { var modelObj = model.changedAttributes(); _.each(model.changed, function(value, key) { if (typeof value === 'undefined' || value === null) { if (key == 'id') { delete modelObj[key]; } else { modelObj[key] = null; ...
javascript
function(model) { var modelObj = model.changedAttributes(); _.each(model.changed, function(value, key) { if (typeof value === 'undefined' || value === null) { if (key == 'id') { delete modelObj[key]; } else { modelObj[key] = null; ...
[ "function", "(", "model", ")", "{", "var", "modelObj", "=", "model", ".", "changedAttributes", "(", ")", ";", "_", ".", "each", "(", "model", ".", "changed", ",", "function", "(", "value", ",", "key", ")", "{", "if", "(", "typeof", "value", "===", ...
Find the deleted keys and set their values to null so Firebase properly deletes them.
[ "Find", "the", "deleted", "keys", "and", "set", "their", "values", "to", "null", "so", "Firebase", "properly", "deletes", "them", "." ]
d6278d4aeb0743bdd7e9de96cc56d4e64476778b
https://github.com/googlearchive/backbonefire/blob/d6278d4aeb0743bdd7e9de96cc56d4e64476778b/examples/todos/js/backbonefire.js#L354-L367
22,574
googlearchive/backbonefire
examples/todos/js/backbonefire.js
function(cb) { var method = cb ? 'on' : 'off'; this[method]('change', function(model) { var newModel = this._updateModel(model); if(_.isFunction(cb)){ cb.call(this, newModel); } }, this); }
javascript
function(cb) { var method = cb ? 'on' : 'off'; this[method]('change', function(model) { var newModel = this._updateModel(model); if(_.isFunction(cb)){ cb.call(this, newModel); } }, this); }
[ "function", "(", "cb", ")", "{", "var", "method", "=", "cb", "?", "'on'", ":", "'off'", ";", "this", "[", "method", "]", "(", "'change'", ",", "function", "(", "model", ")", "{", "var", "newModel", "=", "this", ".", "_updateModel", "(", "model", ")...
Determine if the model will update for every local change. Provide a callback function to call events after the update.
[ "Determine", "if", "the", "model", "will", "update", "for", "every", "local", "change", ".", "Provide", "a", "callback", "function", "to", "call", "events", "after", "the", "update", "." ]
d6278d4aeb0743bdd7e9de96cc56d4e64476778b
https://github.com/googlearchive/backbonefire/blob/d6278d4aeb0743bdd7e9de96cc56d4e64476778b/examples/todos/js/backbonefire.js#L374-L382
22,575
googlearchive/backbonefire
examples/todos/js/backbonefire.js
function(model, options) { model.id = Backbone.Firebase._getKey(this.firebase.push()); options = _.extend({ autoSync: false }, options); return Backbone.Collection.prototype.create.apply(this, [model, options]); }
javascript
function(model, options) { model.id = Backbone.Firebase._getKey(this.firebase.push()); options = _.extend({ autoSync: false }, options); return Backbone.Collection.prototype.create.apply(this, [model, options]); }
[ "function", "(", "model", ",", "options", ")", "{", "model", ".", "id", "=", "Backbone", ".", "Firebase", ".", "_getKey", "(", "this", ".", "firebase", ".", "push", "(", ")", ")", ";", "options", "=", "_", ".", "extend", "(", "{", "autoSync", ":", ...
Create an id from a Firebase push-id and call Backbone.create, which will do prepare the models and trigger the proper events and then call Backbone.Firebase.sync with the correct method.
[ "Create", "an", "id", "from", "a", "Firebase", "push", "-", "id", "and", "call", "Backbone", ".", "create", "which", "will", "do", "prepare", "the", "models", "and", "trigger", "the", "proper", "events", "and", "then", "call", "Backbone", ".", "Firebase", ...
d6278d4aeb0743bdd7e9de96cc56d4e64476778b
https://github.com/googlearchive/backbonefire/blob/d6278d4aeb0743bdd7e9de96cc56d4e64476778b/examples/todos/js/backbonefire.js#L396-L400
22,576
googlearchive/backbonefire
examples/todos/js/backbonefire.js
function(options) { options = options ? _.clone(options) : {}; if (options.parse === void 0) { options.parse = true; } var success = options.success; var collection = this; options.success = function(resp) { var arr = []; var keys = _.keys(resp);...
javascript
function(options) { options = options ? _.clone(options) : {}; if (options.parse === void 0) { options.parse = true; } var success = options.success; var collection = this; options.success = function(resp) { var arr = []; var keys = _.keys(resp);...
[ "function", "(", "options", ")", "{", "options", "=", "options", "?", "_", ".", "clone", "(", "options", ")", ":", "{", "}", ";", "if", "(", "options", ".", "parse", "===", "void", "0", ")", "{", "options", ".", "parse", "=", "true", ";", "}", ...
Firebase returns lists as an object with keys, where Backbone collections require an array. This function modifies the existing Backbone.Collection.fetch method by mapping the returned object from Firebase to an array that Backbone can use.
[ "Firebase", "returns", "lists", "as", "an", "object", "with", "keys", "where", "Backbone", "collections", "require", "an", "array", ".", "This", "function", "modifies", "the", "existing", "Backbone", ".", "Collection", ".", "fetch", "method", "by", "mapping", ...
d6278d4aeb0743bdd7e9de96cc56d4e64476778b
https://github.com/googlearchive/backbonefire/blob/d6278d4aeb0743bdd7e9de96cc56d4e64476778b/examples/todos/js/backbonefire.js#L423-L442
22,577
googlearchive/backbonefire
examples/todos/js/backbonefire.js
function(snap) { var model = Backbone.Firebase._checkId(snap); var item = _.find(this.models, function(child) { return child.id == model.id; }); if (!item) { // TODO: Investigate: what is the right way to handle this case? //throw new Error('...
javascript
function(snap) { var model = Backbone.Firebase._checkId(snap); var item = _.find(this.models, function(child) { return child.id == model.id; }); if (!item) { // TODO: Investigate: what is the right way to handle this case? //throw new Error('...
[ "function", "(", "snap", ")", "{", "var", "model", "=", "Backbone", ".", "Firebase", ".", "_checkId", "(", "snap", ")", ";", "var", "item", "=", "_", ".", "find", "(", "this", ".", "models", ",", "function", "(", "child", ")", "{", "return", "child...
when a model has changed remotely find differences between the local and remote data and apply them to the local model
[ "when", "a", "model", "has", "changed", "remotely", "find", "differences", "between", "the", "local", "and", "remote", "data", "and", "apply", "them", "to", "the", "local", "model" ]
d6278d4aeb0743bdd7e9de96cc56d4e64476778b
https://github.com/googlearchive/backbonefire/blob/d6278d4aeb0743bdd7e9de96cc56d4e64476778b/examples/todos/js/backbonefire.js#L592-L620
22,578
googlearchive/backbonefire
examples/todos/js/backbonefire.js
function(snap) { var model = Backbone.Firebase._checkId(snap); if (this._suppressEvent === true) { this._suppressEvent = false; Backbone.Collection.prototype.remove.apply( this, [model], {silent: true} ); } else { // trigger sy...
javascript
function(snap) { var model = Backbone.Firebase._checkId(snap); if (this._suppressEvent === true) { this._suppressEvent = false; Backbone.Collection.prototype.remove.apply( this, [model], {silent: true} ); } else { // trigger sy...
[ "function", "(", "snap", ")", "{", "var", "model", "=", "Backbone", ".", "Firebase", ".", "_checkId", "(", "snap", ")", ";", "if", "(", "this", ".", "_suppressEvent", "===", "true", ")", "{", "this", ".", "_suppressEvent", "=", "false", ";", "Backbone"...
remove an item from the collection when removed remotely provides the ability to remove siliently
[ "remove", "an", "item", "from", "the", "collection", "when", "removed", "remotely", "provides", "the", "ability", "to", "remove", "siliently" ]
d6278d4aeb0743bdd7e9de96cc56d4e64476778b
https://github.com/googlearchive/backbonefire/blob/d6278d4aeb0743bdd7e9de96cc56d4e64476778b/examples/todos/js/backbonefire.js#L624-L637
22,579
googlearchive/backbonefire
examples/todos/js/backbonefire.js
function(model) { var remoteAttributes; var localAttributes; var updateAttributes; var ref; // if the model is already being handled by listeners then return if (model._remoteChanging) { return; } remoteAttributes = model._rem...
javascript
function(model) { var remoteAttributes; var localAttributes; var updateAttributes; var ref; // if the model is already being handled by listeners then return if (model._remoteChanging) { return; } remoteAttributes = model._rem...
[ "function", "(", "model", ")", "{", "var", "remoteAttributes", ";", "var", "localAttributes", ";", "var", "updateAttributes", ";", "var", "ref", ";", "// if the model is already being handled by listeners then return", "if", "(", "model", ".", "_remoteChanging", ")", ...
Add handlers for all models in this collection, and any future ones that may be added.
[ "Add", "handlers", "for", "all", "models", "in", "this", "collection", "and", "any", "future", "ones", "that", "may", "be", "added", "." ]
d6278d4aeb0743bdd7e9de96cc56d4e64476778b
https://github.com/googlearchive/backbonefire/blob/d6278d4aeb0743bdd7e9de96cc56d4e64476778b/examples/todos/js/backbonefire.js#L641-L668
22,580
googlearchive/backbonefire
examples/todos/js/backbonefire.js
function(remoteAttributes, localAttributes) { var updateAttributes = {}; var union = _.union(_.keys(remoteAttributes), _.keys(localAttributes)); _.each(union, function(key) { if (!_.has(localAttributes, key)) { updateAttributes[key] = null; } else if...
javascript
function(remoteAttributes, localAttributes) { var updateAttributes = {}; var union = _.union(_.keys(remoteAttributes), _.keys(localAttributes)); _.each(union, function(key) { if (!_.has(localAttributes, key)) { updateAttributes[key] = null; } else if...
[ "function", "(", "remoteAttributes", ",", "localAttributes", ")", "{", "var", "updateAttributes", "=", "{", "}", ";", "var", "union", "=", "_", ".", "union", "(", "_", ".", "keys", "(", "remoteAttributes", ")", ",", "_", ".", "keys", "(", "localAttribute...
set the attributes to be updated to Firebase set any removed attributes to null so that Firebase removes them
[ "set", "the", "attributes", "to", "be", "updated", "to", "Firebase", "set", "any", "removed", "attributes", "to", "null", "so", "that", "Firebase", "removes", "them" ]
d6278d4aeb0743bdd7e9de96cc56d4e64476778b
https://github.com/googlearchive/backbonefire/blob/d6278d4aeb0743bdd7e9de96cc56d4e64476778b/examples/todos/js/backbonefire.js#L672-L686
22,581
googlearchive/backbonefire
examples/todos/js/backbonefire.js
function(ref, item) { var priority = item['.priority']; delete item['.priority']; ref.setWithPriority(item, priority); return item; }
javascript
function(ref, item) { var priority = item['.priority']; delete item['.priority']; ref.setWithPriority(item, priority); return item; }
[ "function", "(", "ref", ",", "item", ")", "{", "var", "priority", "=", "item", "[", "'.priority'", "]", ";", "delete", "item", "[", "'.priority'", "]", ";", "ref", ".", "setWithPriority", "(", "item", ",", "priority", ")", ";", "return", "item", ";", ...
Special case if '.priority' was updated - a merge is not allowed so we'll have to do a full setWithPriority.
[ "Special", "case", "if", ".", "priority", "was", "updated", "-", "a", "merge", "is", "not", "allowed", "so", "we", "ll", "have", "to", "do", "a", "full", "setWithPriority", "." ]
d6278d4aeb0743bdd7e9de96cc56d4e64476778b
https://github.com/googlearchive/backbonefire/blob/d6278d4aeb0743bdd7e9de96cc56d4e64476778b/examples/todos/js/backbonefire.js#L690-L695
22,582
repetere/modelscript
build/modelscript.umd.js
function(data, param) { var eol = getEol(data,param); var lines = data.split(eol); var partial = lines.pop(); return {lines: lines, partial: partial}; }
javascript
function(data, param) { var eol = getEol(data,param); var lines = data.split(eol); var partial = lines.pop(); return {lines: lines, partial: partial}; }
[ "function", "(", "data", ",", "param", ")", "{", "var", "eol", "=", "getEol", "(", "data", ",", "param", ")", ";", "var", "lines", "=", "data", ".", "split", "(", "eol", ")", ";", "var", "partial", "=", "lines", ".", "pop", "(", ")", ";", "retu...
convert data chunk to file lines array @param {string} data data chunk as utf8 string @param {object} param Converter param object @return {Object} {lines:[line1,line2...],partial:String}
[ "convert", "data", "chunk", "to", "file", "lines", "array" ]
b507fad9b3ecfb4a9ec4d44d41052a8082dac763
https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L7560-L7565
22,583
repetere/modelscript
build/modelscript.umd.js
rowSplit
function rowSplit(rowStr, param) { if (rowStr === "") { return { cols: [], closed: true }; } var quote = param.quote; var trim = param.trim; var escape = param.escape; if (param.delimiter instanceof Array || param.delimi...
javascript
function rowSplit(rowStr, param) { if (rowStr === "") { return { cols: [], closed: true }; } var quote = param.quote; var trim = param.trim; var escape = param.escape; if (param.delimiter instanceof Array || param.delimi...
[ "function", "rowSplit", "(", "rowStr", ",", "param", ")", "{", "if", "(", "rowStr", "===", "\"\"", ")", "{", "return", "{", "cols", ":", "[", "]", ",", "closed", ":", "true", "}", ";", "}", "var", "quote", "=", "param", ".", "quote", ";", "var", ...
Convert a line of string to csv columns according to its delimiter the param._header may not be ready when this is called. @param {[type]} rowStr [description] @param {[type]} param [Converter param] @return {[type]} {cols:["a","b","c"],closed:boolean} the closed field indicate if the row is a complete row
[ "Convert", "a", "line", "of", "string", "to", "csv", "columns", "according", "to", "its", "delimiter", "the", "param", ".", "_header", "may", "not", "be", "ready", "when", "this", "is", "called", "." ]
b507fad9b3ecfb4a9ec4d44d41052a8082dac763
https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L7617-L7692
22,584
repetere/modelscript
build/modelscript.umd.js
function(lines, param) { var csvLines = []; var left = ""; while (lines.length) { var line = left + lines.shift(); var row = rowSplit(line, param); if (row.closed) { csvLines.push(row.cols); lef...
javascript
function(lines, param) { var csvLines = []; var left = ""; while (lines.length) { var line = left + lines.shift(); var row = rowSplit(line, param); if (row.closed) { csvLines.push(row.cols); lef...
[ "function", "(", "lines", ",", "param", ")", "{", "var", "csvLines", "=", "[", "]", ";", "var", "left", "=", "\"\"", ";", "while", "(", "lines", ".", "length", ")", "{", "var", "line", "=", "left", "+", "lines", ".", "shift", "(", ")", ";", "va...
Convert lines to csv columns @param {[type]} lines [file lines] @param {[type]} param [Converter param] @return {[type]} {lines:[[col1,col2,col3...]],partial:String}
[ "Convert", "lines", "to", "csv", "columns" ]
b507fad9b3ecfb4a9ec4d44d41052a8082dac763
https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L7737-L7751
22,585
repetere/modelscript
build/modelscript.umd.js
function(fileLine, params) { var lines = fileLine.lines; var csvLines = csvline(lines,params); return { lines: csvLines.lines, partial: csvLines.partial + fileLine.partial }; }
javascript
function(fileLine, params) { var lines = fileLine.lines; var csvLines = csvline(lines,params); return { lines: csvLines.lines, partial: csvLines.partial + fileLine.partial }; }
[ "function", "(", "fileLine", ",", "params", ")", "{", "var", "lines", "=", "fileLine", ".", "lines", ";", "var", "csvLines", "=", "csvline", "(", "lines", ",", "params", ")", ";", "return", "{", "lines", ":", "csvLines", ".", "lines", ",", "partial", ...
Convert data chunk to csv lines with cols @param {[type]} data [description] @param {[type]} params [description] @return {[type]} {lines:[[col1,col2,col3]],partial:String}
[ "Convert", "data", "chunk", "to", "csv", "lines", "with", "cols" ]
b507fad9b3ecfb4a9ec4d44d41052a8082dac763
https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L7759-L7766
22,586
repetere/modelscript
build/modelscript.umd.js
function (lines, params, idx) { if (params._needParseJson) { if (!params._headers) { params._headers = []; } if (!params.parseRules) { var row = params._headers; params.parseRules = parserMgr.initParsers(...
javascript
function (lines, params, idx) { if (params._needParseJson) { if (!params._headers) { params._headers = []; } if (!params.parseRules) { var row = params._headers; params.parseRules = parserMgr.initParsers(...
[ "function", "(", "lines", ",", "params", ",", "idx", ")", "{", "if", "(", "params", ".", "_needParseJson", ")", "{", "if", "(", "!", "params", ".", "_headers", ")", "{", "params", ".", "_headers", "=", "[", "]", ";", "}", "if", "(", "!", "params"...
Convert lines of csv array into json @param {[type]} lines [[col1,col2,col3]] @param {[type]} params Converter params with _headers field populated @param {[type]} idx start pos of the lines @return {[type]} [{err:null,json:obj,index:line,row:[csv row]}]
[ "Convert", "lines", "of", "csv", "array", "into", "json" ]
b507fad9b3ecfb4a9ec4d44d41052a8082dac763
https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L9419-L9432
22,587
repetere/modelscript
build/modelscript.umd.js
_initConverter
function _initConverter(){ var csvConverter = new Converter_1(); var started = false; var writeStream = process.stdout; csvConverter.on("record_parsed",function(rowJSON){ if (started){ writeStream.write(",\n"); ...
javascript
function _initConverter(){ var csvConverter = new Converter_1(); var started = false; var writeStream = process.stdout; csvConverter.on("record_parsed",function(rowJSON){ if (started){ writeStream.write(",\n"); ...
[ "function", "_initConverter", "(", ")", "{", "var", "csvConverter", "=", "new", "Converter_1", "(", ")", ";", "var", "started", "=", "false", ";", "var", "writeStream", "=", "process", ".", "stdout", ";", "csvConverter", ".", "on", "(", "\"record_parsed\"", ...
Convert input to process stdout implementation
[ "Convert", "input", "to", "process", "stdout", "implementation" ]
b507fad9b3ecfb4a9ec4d44d41052a8082dac763
https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L27505-L27528
22,588
repetere/modelscript
build/modelscript.umd.js
loadCSVURI
async function loadCSVURI(filepath, options) { const reqMethod = (filepath.search('https', 'gi') > -1) ? get : get; return new Promise((resolve, reject) => { const csvData = []; const config = Object.assign({ checkType: true, }, options); ...
javascript
async function loadCSVURI(filepath, options) { const reqMethod = (filepath.search('https', 'gi') > -1) ? get : get; return new Promise((resolve, reject) => { const csvData = []; const config = Object.assign({ checkType: true, }, options); ...
[ "async", "function", "loadCSVURI", "(", "filepath", ",", "options", ")", "{", "const", "reqMethod", "=", "(", "filepath", ".", "search", "(", "'https'", ",", "'gi'", ")", ">", "-", "1", ")", "?", "get", ":", "get", ";", "return", "new", "Promise", "(...
Asynchronously loads a CSV from a remote URL and returns an array of objects @example // returns [{header:value,header2:value2}] loadCSVURI('https://raw.githubusercontent.com/repetere/modelscript/master/test/mock/data.csv').then(csvData).catch(console.error) @memberOf csv @param {string} filepath - URL to CSV path @par...
[ "Asynchronously", "loads", "a", "CSV", "from", "a", "remote", "URL", "and", "returns", "an", "array", "of", "objects" ]
b507fad9b3ecfb4a9ec4d44d41052a8082dac763
https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L27578-L27601
22,589
repetere/modelscript
build/modelscript.umd.js
loadCSV
async function loadCSV(filepath, options) { if (validUrl.isUri(filepath)) { return loadCSVURI(filepath, options); } else { return new Promise((resolve, reject) => { const csvData = []; const config = Object.assign({ ch...
javascript
async function loadCSV(filepath, options) { if (validUrl.isUri(filepath)) { return loadCSVURI(filepath, options); } else { return new Promise((resolve, reject) => { const csvData = []; const config = Object.assign({ ch...
[ "async", "function", "loadCSV", "(", "filepath", ",", "options", ")", "{", "if", "(", "validUrl", ".", "isUri", "(", "filepath", ")", ")", "{", "return", "loadCSVURI", "(", "filepath", ",", "options", ")", ";", "}", "else", "{", "return", "new", "Promi...
Asynchronously loads a CSV from either a filepath or remote URL and returns an array of objects @example // returns [{header:value,header2:value2}] loadCSV('../mock/invalid-file.csv').then(csvData).catch(console.error) @memberOf csv @param {string} filepath - URL to CSV path @param {Object} [options] - options passed t...
[ "Asynchronously", "loads", "a", "CSV", "from", "either", "a", "filepath", "or", "remote", "URL", "and", "returns", "an", "array", "of", "objects" ]
b507fad9b3ecfb4a9ec4d44d41052a8082dac763
https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L27614-L27637
22,590
repetere/modelscript
build/modelscript.umd.js
loadTSV
async function loadTSV(filepath, options) { const tsvOptions = Object.assign({ checkType: true, }, options, { delimiter: '\t', }); return loadCSV(filepath, tsvOptions); }
javascript
async function loadTSV(filepath, options) { const tsvOptions = Object.assign({ checkType: true, }, options, { delimiter: '\t', }); return loadCSV(filepath, tsvOptions); }
[ "async", "function", "loadTSV", "(", "filepath", ",", "options", ")", "{", "const", "tsvOptions", "=", "Object", ".", "assign", "(", "{", "checkType", ":", "true", ",", "}", ",", "options", ",", "{", "delimiter", ":", "'\\t'", ",", "}", ")", ";", "re...
Asynchronously loads a TSV from either a filepath or remote URL and returns an array of objects @example // returns [{header:value,header2:value2}] loadCSV('../mock/invalid-file.tsv').then(csvData).catch(console.error) @memberOf csv @param {string} filepath - URL to CSV path @param {Object} [options] - options passed t...
[ "Asynchronously", "loads", "a", "TSV", "from", "either", "a", "filepath", "or", "remote", "URL", "and", "returns", "an", "array", "of", "objects" ]
b507fad9b3ecfb4a9ec4d44d41052a8082dac763
https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L27649-L27656
22,591
repetere/modelscript
build/modelscript.umd.js
max
function max(input) { if (!Array.isArray(input)) { throw new Error('input must be an array'); } if (input.length === 0) { throw new Error('input must not be empty'); } var max = input[0]; ...
javascript
function max(input) { if (!Array.isArray(input)) { throw new Error('input must be an array'); } if (input.length === 0) { throw new Error('input must not be empty'); } var max = input[0]; ...
[ "function", "max", "(", "input", ")", "{", "if", "(", "!", "Array", ".", "isArray", "(", "input", ")", ")", "{", "throw", "new", "Error", "(", "'input must be an array'", ")", ";", "}", "if", "(", "input", ".", "length", "===", "0", ")", "{", "thro...
Computes the maximum of the given values @param {Array<number>} input @return {number}
[ "Computes", "the", "maximum", "of", "the", "given", "values" ]
b507fad9b3ecfb4a9ec4d44d41052a8082dac763
https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L28466-L28480
22,592
repetere/modelscript
build/modelscript.umd.js
min
function min(input) { if (!Array.isArray(input)) { throw new Error('input must be an array'); } if (input.length === 0) { throw new Error('input must not be empty'); } var min = input[0]; ...
javascript
function min(input) { if (!Array.isArray(input)) { throw new Error('input must be an array'); } if (input.length === 0) { throw new Error('input must not be empty'); } var min = input[0]; ...
[ "function", "min", "(", "input", ")", "{", "if", "(", "!", "Array", ".", "isArray", "(", "input", ")", ")", "{", "throw", "new", "Error", "(", "'input must be an array'", ")", ";", "}", "if", "(", "input", ".", "length", "===", "0", ")", "{", "thro...
Computes the minimum of the given values @param {Array<number>} input @return {number}
[ "Computes", "the", "minimum", "of", "the", "given", "values" ]
b507fad9b3ecfb4a9ec4d44d41052a8082dac763
https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L28487-L28501
22,593
repetere/modelscript
build/modelscript.umd.js
embed
function embed(mat, rows, cols) { var r = mat.rows; var c = mat.columns; if ((r === rows) && (c === cols)) { return mat; } else { var resultat =...
javascript
function embed(mat, rows, cols) { var r = mat.rows; var c = mat.columns; if ((r === rows) && (c === cols)) { return mat; } else { var resultat =...
[ "function", "embed", "(", "mat", ",", "rows", ",", "cols", ")", "{", "var", "r", "=", "mat", ".", "rows", ";", "var", "c", "=", "mat", ".", "columns", ";", "if", "(", "(", "r", "===", "rows", ")", "&&", "(", "c", "===", "cols", ")", ")", "{...
Put a matrix into the top left of a matrix of zeros. `rows` and `cols` are the dimensions of the output matrix.
[ "Put", "a", "matrix", "into", "the", "top", "left", "of", "a", "matrix", "of", "zeros", ".", "rows", "and", "cols", "are", "the", "dimensions", "of", "the", "output", "matrix", "." ]
b507fad9b3ecfb4a9ec4d44d41052a8082dac763
https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L29971-L29981
22,594
repetere/modelscript
build/modelscript.umd.js
mean
function mean(input) { if (!Array.isArray(input)) { throw new Error('input must be an array'); } if (input.length === 0) { throw new Error('input must not be empty'); } var sum = 0; ...
javascript
function mean(input) { if (!Array.isArray(input)) { throw new Error('input must be an array'); } if (input.length === 0) { throw new Error('input must not be empty'); } var sum = 0; ...
[ "function", "mean", "(", "input", ")", "{", "if", "(", "!", "Array", ".", "isArray", "(", "input", ")", ")", "{", "throw", "new", "Error", "(", "'input must be an array'", ")", ";", "}", "if", "(", "input", ".", "length", "===", "0", ")", "{", "thr...
Computes the mean of the given values @param {Array<number>} input @return {number}
[ "Computes", "the", "mean", "of", "the", "given", "values" ]
b507fad9b3ecfb4a9ec4d44d41052a8082dac763
https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L30898-L30912
22,595
repetere/modelscript
build/modelscript.umd.js
examplesBaggingWithReplacement
function examplesBaggingWithReplacement(trainingSet, trainingValue, seed) { var engine = random.engines.mt19937(); var distribution = random.integer(0, trainingSet.rows - 1); if (seed === undefined) { engine = engine.autoSeed(); } else if (Number.i...
javascript
function examplesBaggingWithReplacement(trainingSet, trainingValue, seed) { var engine = random.engines.mt19937(); var distribution = random.integer(0, trainingSet.rows - 1); if (seed === undefined) { engine = engine.autoSeed(); } else if (Number.i...
[ "function", "examplesBaggingWithReplacement", "(", "trainingSet", ",", "trainingValue", ",", "seed", ")", "{", "var", "engine", "=", "random", ".", "engines", ".", "mt19937", "(", ")", ";", "var", "distribution", "=", "random", ".", "integer", "(", "0", ",",...
Select n with replacement elements on the training set and values, where n is the size of the training set. @ignore @param {Matrix} trainingSet @param {Array} trainingValue @param {number} seed - seed for the random selection, must be a 32-bit integer. @return {object} with new X and y.
[ "Select", "n", "with", "replacement", "elements", "on", "the", "training", "set", "and", "values", "where", "n", "is", "the", "size", "of", "the", "training", "set", "." ]
b507fad9b3ecfb4a9ec4d44d41052a8082dac763
https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L36609-L36633
22,596
repetere/modelscript
build/modelscript.umd.js
featureBagging
function featureBagging(trainingSet, n, replacement, seed) { if (trainingSet.columns < n) { throw new RangeError('N should be less or equal to the number of columns of X'); } var distribution = random.integer(0, trainingSet.columns - 1); var engin...
javascript
function featureBagging(trainingSet, n, replacement, seed) { if (trainingSet.columns < n) { throw new RangeError('N should be less or equal to the number of columns of X'); } var distribution = random.integer(0, trainingSet.columns - 1); var engin...
[ "function", "featureBagging", "(", "trainingSet", ",", "n", ",", "replacement", ",", "seed", ")", "{", "if", "(", "trainingSet", ".", "columns", "<", "n", ")", "{", "throw", "new", "RangeError", "(", "'N should be less or equal to the number of columns of X'", ")"...
selects n features from the training set with or without replacement, returns the new training set and the indexes used. @ignore @param {Matrix} trainingSet @param {number} n - features. @param {boolean} replacement @param {number} seed - seed for the random selection, must be a 32-bit integer. @return {object}
[ "selects", "n", "features", "from", "the", "training", "set", "with", "or", "without", "replacement", "returns", "the", "new", "training", "set", "and", "the", "indexes", "used", "." ]
b507fad9b3ecfb4a9ec4d44d41052a8082dac763
https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L36644-L36685
22,597
repetere/modelscript
build/modelscript.umd.js
mode
function mode(arr) { return arr.sort((a, b) => arr.filter((v) => v === a).length - arr.filter((v) => v === b).length ).pop(); }
javascript
function mode(arr) { return arr.sort((a, b) => arr.filter((v) => v === a).length - arr.filter((v) => v === b).length ).pop(); }
[ "function", "mode", "(", "arr", ")", "{", "return", "arr", ".", "sort", "(", "(", "a", ",", "b", ")", "=>", "arr", ".", "filter", "(", "(", "v", ")", "=>", "v", "===", "a", ")", ".", "length", "-", "arr", ".", "filter", "(", "(", "v", ")", ...
Return the most repeated element on the array. @param {Array} arr @return {number} mode
[ "Return", "the", "most", "repeated", "element", "on", "the", "array", "." ]
b507fad9b3ecfb4a9ec4d44d41052a8082dac763
https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L36909-L36914
22,598
repetere/modelscript
build/modelscript.umd.js
median
function median(input) { if (!Array.isArray(input)) { throw new Error('input must be an array'); } if (input.length === 0) { throw new Error('input must not be empty'); } return medianQuickselect_mi...
javascript
function median(input) { if (!Array.isArray(input)) { throw new Error('input must be an array'); } if (input.length === 0) { throw new Error('input must not be empty'); } return medianQuickselect_mi...
[ "function", "median", "(", "input", ")", "{", "if", "(", "!", "Array", ".", "isArray", "(", "input", ")", ")", "{", "throw", "new", "Error", "(", "'input must be an array'", ")", ";", "}", "if", "(", "input", ".", "length", "===", "0", ")", "{", "t...
Computes the median of the given values @param {Array<number>} input @return {number}
[ "Computes", "the", "median", "of", "the", "given", "values" ]
b507fad9b3ecfb4a9ec4d44d41052a8082dac763
https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L36925-L36935
22,599
repetere/modelscript
build/modelscript.umd.js
nearestVector
function nearestVector(listVectors, vector, options) { options = options || defaultOptions$7; const distanceFunction = options.distanceFunction || defaultOptions$7.distanceFunction; const similarityFunction = options.similarityFunction || defaultOptions$7.similarityFuncti...
javascript
function nearestVector(listVectors, vector, options) { options = options || defaultOptions$7; const distanceFunction = options.distanceFunction || defaultOptions$7.distanceFunction; const similarityFunction = options.similarityFunction || defaultOptions$7.similarityFuncti...
[ "function", "nearestVector", "(", "listVectors", ",", "vector", ",", "options", ")", "{", "options", "=", "options", "||", "defaultOptions$7", ";", "const", "distanceFunction", "=", "options", ".", "distanceFunction", "||", "defaultOptions$7", ".", "distanceFunction...
Find the nearest vector in a list to a sample vector @param {Array<Array<number>>} listVectors - List of vectors with same dimensions @param {Array<number>} vector - Reference vector to "classify" @param {object} [options] - Options object @param {function} [options.distanceFunction = squaredDistance] - Function that r...
[ "Find", "the", "nearest", "vector", "in", "a", "list", "to", "a", "sample", "vector" ]
b507fad9b3ecfb4a9ec4d44d41052a8082dac763
https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L43753-L43791