repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
neagle/smartgamer
index.js
function (alphaCoordinates) { var coordinateLabels = 'abcdefghijklmnopqrst'; var intersection = []; intersection[0] = coordinateLabels.indexOf(alphaCoordinates.substring(0, 1)); intersection[1] = coordinateLabels.indexOf(alphaCoordinates.substring(1, 2)); return intersection; }
javascript
function (alphaCoordinates) { var coordinateLabels = 'abcdefghijklmnopqrst'; var intersection = []; intersection[0] = coordinateLabels.indexOf(alphaCoordinates.substring(0, 1)); intersection[1] = coordinateLabels.indexOf(alphaCoordinates.substring(1, 2)); return intersection; }
[ "function", "(", "alphaCoordinates", ")", "{", "var", "coordinateLabels", "=", "'abcdefghijklmnopqrst'", ";", "var", "intersection", "=", "[", "]", ";", "intersection", "[", "0", "]", "=", "coordinateLabels", ".", "indexOf", "(", "alphaCoordinates", ".", "substring", "(", "0", ",", "1", ")", ")", ";", "intersection", "[", "1", "]", "=", "coordinateLabels", ".", "indexOf", "(", "alphaCoordinates", ".", "substring", "(", "1", ",", "2", ")", ")", ";", "return", "intersection", ";", "}" ]
Translate alpha coordinates into an array @param string alphaCoordinates @return array [x, y]
[ "Translate", "alpha", "coordinates", "into", "an", "array" ]
83a4b47c476729a19f8d04c165c0c10b69095d62
https://github.com/neagle/smartgamer/blob/83a4b47c476729a19f8d04c165c0c10b69095d62/index.js#L244-L252
train
neagle/smartgamer
index.js
function (input, outputType, verbose) { var output; // If no output type has been specified, try to set it to the // opposite of the input if (typeof outputType === 'undefined') { outputType = (typeof input === 'string') ? 'object' : 'string'; } /** * Turn a path object into a string. */ function stringify(input) { if (typeof input === 'string') { return input; } if (!input) { return ''; } output = input.m; var variations = []; for (var key in input) { if (input.hasOwnProperty(key) && key !== 'm') { // Only show variations that are not the primary one, since // primary variations are chosen by default if (input[key] > 0) { if (verbose) { variations.push(', variation ' + input[key] + ' at move ' + key); } else { variations.push('-' + key + ':' + input[key]); } } } } output += variations.join(''); return output; } /** * Turn a path string into an object. */ function parse(input) { if (typeof input === 'object') { input = stringify(input); } if (!input) { return { m: 0 }; } var path = input.split('-'); output = { m: Number(path.shift()) }; if (path.length) { path.forEach(function (variation, i) { variation = variation.split(':'); output[Number(variation[0])] = parseInt(variation[1], 10); }); } return output; } if (outputType === 'string') { output = stringify(input); } else if (outputType === 'object') { output = parse(input); } else { output = undefined; } return output; }
javascript
function (input, outputType, verbose) { var output; // If no output type has been specified, try to set it to the // opposite of the input if (typeof outputType === 'undefined') { outputType = (typeof input === 'string') ? 'object' : 'string'; } /** * Turn a path object into a string. */ function stringify(input) { if (typeof input === 'string') { return input; } if (!input) { return ''; } output = input.m; var variations = []; for (var key in input) { if (input.hasOwnProperty(key) && key !== 'm') { // Only show variations that are not the primary one, since // primary variations are chosen by default if (input[key] > 0) { if (verbose) { variations.push(', variation ' + input[key] + ' at move ' + key); } else { variations.push('-' + key + ':' + input[key]); } } } } output += variations.join(''); return output; } /** * Turn a path string into an object. */ function parse(input) { if (typeof input === 'object') { input = stringify(input); } if (!input) { return { m: 0 }; } var path = input.split('-'); output = { m: Number(path.shift()) }; if (path.length) { path.forEach(function (variation, i) { variation = variation.split(':'); output[Number(variation[0])] = parseInt(variation[1], 10); }); } return output; } if (outputType === 'string') { output = stringify(input); } else if (outputType === 'object') { output = parse(input); } else { output = undefined; } return output; }
[ "function", "(", "input", ",", "outputType", ",", "verbose", ")", "{", "var", "output", ";", "if", "(", "typeof", "outputType", "===", "'undefined'", ")", "{", "outputType", "=", "(", "typeof", "input", "===", "'string'", ")", "?", "'object'", ":", "'string'", ";", "}", "function", "stringify", "(", "input", ")", "{", "if", "(", "typeof", "input", "===", "'string'", ")", "{", "return", "input", ";", "}", "if", "(", "!", "input", ")", "{", "return", "''", ";", "}", "output", "=", "input", ".", "m", ";", "var", "variations", "=", "[", "]", ";", "for", "(", "var", "key", "in", "input", ")", "{", "if", "(", "input", ".", "hasOwnProperty", "(", "key", ")", "&&", "key", "!==", "'m'", ")", "{", "if", "(", "input", "[", "key", "]", ">", "0", ")", "{", "if", "(", "verbose", ")", "{", "variations", ".", "push", "(", "', variation '", "+", "input", "[", "key", "]", "+", "' at move '", "+", "key", ")", ";", "}", "else", "{", "variations", ".", "push", "(", "'-'", "+", "key", "+", "':'", "+", "input", "[", "key", "]", ")", ";", "}", "}", "}", "}", "output", "+=", "variations", ".", "join", "(", "''", ")", ";", "return", "output", ";", "}", "function", "parse", "(", "input", ")", "{", "if", "(", "typeof", "input", "===", "'object'", ")", "{", "input", "=", "stringify", "(", "input", ")", ";", "}", "if", "(", "!", "input", ")", "{", "return", "{", "m", ":", "0", "}", ";", "}", "var", "path", "=", "input", ".", "split", "(", "'-'", ")", ";", "output", "=", "{", "m", ":", "Number", "(", "path", ".", "shift", "(", ")", ")", "}", ";", "if", "(", "path", ".", "length", ")", "{", "path", ".", "forEach", "(", "function", "(", "variation", ",", "i", ")", "{", "variation", "=", "variation", ".", "split", "(", "':'", ")", ";", "output", "[", "Number", "(", "variation", "[", "0", "]", ")", "]", "=", "parseInt", "(", "variation", "[", "1", "]", ",", "10", ")", ";", "}", ")", ";", "}", "return", "output", ";", "}", "if", "(", "outputType", "===", "'string'", ")", "{", "output", "=", "stringify", "(", "input", ")", ";", "}", "else", "if", "(", "outputType", "===", "'object'", ")", "{", "output", "=", "parse", "(", "input", ")", ";", "}", "else", "{", "output", "=", "undefined", ";", "}", "return", "output", ";", "}" ]
Convert path objects to strings and path strings to objects
[ "Convert", "path", "objects", "to", "strings", "and", "path", "strings", "to", "objects" ]
83a4b47c476729a19f8d04c165c0c10b69095d62
https://github.com/neagle/smartgamer/blob/83a4b47c476729a19f8d04c165c0c10b69095d62/index.js#L257-L335
train
neagle/smartgamer
index.js
stringify
function stringify(input) { if (typeof input === 'string') { return input; } if (!input) { return ''; } output = input.m; var variations = []; for (var key in input) { if (input.hasOwnProperty(key) && key !== 'm') { // Only show variations that are not the primary one, since // primary variations are chosen by default if (input[key] > 0) { if (verbose) { variations.push(', variation ' + input[key] + ' at move ' + key); } else { variations.push('-' + key + ':' + input[key]); } } } } output += variations.join(''); return output; }
javascript
function stringify(input) { if (typeof input === 'string') { return input; } if (!input) { return ''; } output = input.m; var variations = []; for (var key in input) { if (input.hasOwnProperty(key) && key !== 'm') { // Only show variations that are not the primary one, since // primary variations are chosen by default if (input[key] > 0) { if (verbose) { variations.push(', variation ' + input[key] + ' at move ' + key); } else { variations.push('-' + key + ':' + input[key]); } } } } output += variations.join(''); return output; }
[ "function", "stringify", "(", "input", ")", "{", "if", "(", "typeof", "input", "===", "'string'", ")", "{", "return", "input", ";", "}", "if", "(", "!", "input", ")", "{", "return", "''", ";", "}", "output", "=", "input", ".", "m", ";", "var", "variations", "=", "[", "]", ";", "for", "(", "var", "key", "in", "input", ")", "{", "if", "(", "input", ".", "hasOwnProperty", "(", "key", ")", "&&", "key", "!==", "'m'", ")", "{", "if", "(", "input", "[", "key", "]", ">", "0", ")", "{", "if", "(", "verbose", ")", "{", "variations", ".", "push", "(", "', variation '", "+", "input", "[", "key", "]", "+", "' at move '", "+", "key", ")", ";", "}", "else", "{", "variations", ".", "push", "(", "'-'", "+", "key", "+", "':'", "+", "input", "[", "key", "]", ")", ";", "}", "}", "}", "}", "output", "+=", "variations", ".", "join", "(", "''", ")", ";", "return", "output", ";", "}" ]
Turn a path object into a string.
[ "Turn", "a", "path", "object", "into", "a", "string", "." ]
83a4b47c476729a19f8d04c165c0c10b69095d62
https://github.com/neagle/smartgamer/blob/83a4b47c476729a19f8d04c165c0c10b69095d62/index.js#L269-L297
train
neagle/smartgamer
index.js
parse
function parse(input) { if (typeof input === 'object') { input = stringify(input); } if (!input) { return { m: 0 }; } var path = input.split('-'); output = { m: Number(path.shift()) }; if (path.length) { path.forEach(function (variation, i) { variation = variation.split(':'); output[Number(variation[0])] = parseInt(variation[1], 10); }); } return output; }
javascript
function parse(input) { if (typeof input === 'object') { input = stringify(input); } if (!input) { return { m: 0 }; } var path = input.split('-'); output = { m: Number(path.shift()) }; if (path.length) { path.forEach(function (variation, i) { variation = variation.split(':'); output[Number(variation[0])] = parseInt(variation[1], 10); }); } return output; }
[ "function", "parse", "(", "input", ")", "{", "if", "(", "typeof", "input", "===", "'object'", ")", "{", "input", "=", "stringify", "(", "input", ")", ";", "}", "if", "(", "!", "input", ")", "{", "return", "{", "m", ":", "0", "}", ";", "}", "var", "path", "=", "input", ".", "split", "(", "'-'", ")", ";", "output", "=", "{", "m", ":", "Number", "(", "path", ".", "shift", "(", ")", ")", "}", ";", "if", "(", "path", ".", "length", ")", "{", "path", ".", "forEach", "(", "function", "(", "variation", ",", "i", ")", "{", "variation", "=", "variation", ".", "split", "(", "':'", ")", ";", "output", "[", "Number", "(", "variation", "[", "0", "]", ")", "]", "=", "parseInt", "(", "variation", "[", "1", "]", ",", "10", ")", ";", "}", ")", ";", "}", "return", "output", ";", "}" ]
Turn a path string into an object.
[ "Turn", "a", "path", "string", "into", "an", "object", "." ]
83a4b47c476729a19f8d04c165c0c10b69095d62
https://github.com/neagle/smartgamer/blob/83a4b47c476729a19f8d04c165c0c10b69095d62/index.js#L302-L324
train
AckerApple/ack-node
js/modules/reqres/req.js
processArray
function processArray(req, res, nextarray) { if (!nextarray || !nextarray.length) return; var proc = nextarray.shift(); proc(req, res, function () { processArray(req, res, nextarray); }); }
javascript
function processArray(req, res, nextarray) { if (!nextarray || !nextarray.length) return; var proc = nextarray.shift(); proc(req, res, function () { processArray(req, res, nextarray); }); }
[ "function", "processArray", "(", "req", ",", "res", ",", "nextarray", ")", "{", "if", "(", "!", "nextarray", "||", "!", "nextarray", ".", "length", ")", "return", ";", "var", "proc", "=", "nextarray", ".", "shift", "(", ")", ";", "proc", "(", "req", ",", "res", ",", "function", "(", ")", "{", "processArray", "(", "req", ",", "res", ",", "nextarray", ")", ";", "}", ")", ";", "}" ]
!!!Non-prototypes below express request handler with array shifting
[ "!!!Non", "-", "prototypes", "below", "express", "request", "handler", "with", "array", "shifting" ]
c123d3fcbdd0195630fece6dc9ddee8910c9e115
https://github.com/AckerApple/ack-node/blob/c123d3fcbdd0195630fece6dc9ddee8910c9e115/js/modules/reqres/req.js#L210-L217
train
AckerApple/ack-node
js/modules/reqres/req.js
path
function path(req) { var oUrl = req.originalUrl || req.url; this.string = oUrl.split('?')[0]; this.relative = req.url.split('?')[0]; }
javascript
function path(req) { var oUrl = req.originalUrl || req.url; this.string = oUrl.split('?')[0]; this.relative = req.url.split('?')[0]; }
[ "function", "path", "(", "req", ")", "{", "var", "oUrl", "=", "req", ".", "originalUrl", "||", "req", ".", "url", ";", "this", ".", "string", "=", "oUrl", ".", "split", "(", "'?'", ")", "[", "0", "]", ";", "this", ".", "relative", "=", "req", ".", "url", ".", "split", "(", "'?'", ")", "[", "0", "]", ";", "}" ]
path component to aid in reading the request path
[ "path", "component", "to", "aid", "in", "reading", "the", "request", "path" ]
c123d3fcbdd0195630fece6dc9ddee8910c9e115
https://github.com/AckerApple/ack-node/blob/c123d3fcbdd0195630fece6dc9ddee8910c9e115/js/modules/reqres/req.js#L219-L223
train
rootsdev/gedcomx-js
src/atom/AtomCommon.js
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof AtomCommon)){ return new AtomCommon(json); } // If the given object is already an instance then just return it. DON'T copy it. if(AtomCommon.isInstance(json)){ return json; } this.init(json); }
javascript
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof AtomCommon)){ return new AtomCommon(json); } // If the given object is already an instance then just return it. DON'T copy it. if(AtomCommon.isInstance(json)){ return json; } this.init(json); }
[ "function", "(", "json", ")", "{", "if", "(", "!", "(", "this", "instanceof", "AtomCommon", ")", ")", "{", "return", "new", "AtomCommon", "(", "json", ")", ";", "}", "if", "(", "AtomCommon", ".", "isInstance", "(", "json", ")", ")", "{", "return", "json", ";", "}", "this", ".", "init", "(", "json", ")", ";", "}" ]
Common attributes for all Atom entities @see {@link https://tools.ietf.org/html/rfc4287#page-7|RFC 4287} @class AtomCommon @extends Base @param {Object} [json]
[ "Common", "attributes", "for", "all", "Atom", "entities" ]
08b2fcde96f1e301c78561bfb7a8b0cac606e26e
https://github.com/rootsdev/gedcomx-js/blob/08b2fcde96f1e301c78561bfb7a8b0cac606e26e/src/atom/AtomCommon.js#L13-L26
train
amrdraz/java-code-runner
node/server.js
findPort
function findPort(cb) { var port = tryPort; tryPort += 1; var server = net.createServer(); server.listen(port, function(err) { server.once('close', function() { cb(port); }); server.close(); }); server.on('error', function(err) { log("port " + tryPort + " is occupied"); findPort(cb); }); }
javascript
function findPort(cb) { var port = tryPort; tryPort += 1; var server = net.createServer(); server.listen(port, function(err) { server.once('close', function() { cb(port); }); server.close(); }); server.on('error', function(err) { log("port " + tryPort + " is occupied"); findPort(cb); }); }
[ "function", "findPort", "(", "cb", ")", "{", "var", "port", "=", "tryPort", ";", "tryPort", "+=", "1", ";", "var", "server", "=", "net", ".", "createServer", "(", ")", ";", "server", ".", "listen", "(", "port", ",", "function", "(", "err", ")", "{", "server", ".", "once", "(", "'close'", ",", "function", "(", ")", "{", "cb", "(", "port", ")", ";", "}", ")", ";", "server", ".", "close", "(", ")", ";", "}", ")", ";", "server", ".", "on", "(", "'error'", ",", "function", "(", "err", ")", "{", "log", "(", "\"port \"", "+", "tryPort", "+", "\" is occupied\"", ")", ";", "findPort", "(", "cb", ")", ";", "}", ")", ";", "}" ]
get an empty port for the java server
[ "get", "an", "empty", "port", "for", "the", "java", "server" ]
b5d87b503076bf76a01d111b85c18a639e6f80c8
https://github.com/amrdraz/java-code-runner/blob/b5d87b503076bf76a01d111b85c18a639e6f80c8/node/server.js#L41-L56
train
amrdraz/java-code-runner
node/server.js
startServlet
function startServlet(cb) { startingServer = true; servletReady = false; debugger; findPort(function(port) { servletPort = global._servletPort = '' + port; servlet = global._servlet = cp.spawn('java', ['-cp', '.:../lib/servlet-api-2.5.jar:../lib/jetty-all-7.0.2.v20100331.jar', 'RunnerServlet', servletPort], { cwd: config.rootDir + '/bin' }); servlet.stdout.on('data', function(data) { console.log('OUT:' + data); }); servlet.stderr.on('data', function(data) { console.log("" + data); if (~data.toString().indexOf(servletPort)) { servletReady = true; startingServer = false; // queue.checkQueues(); observer.emit("server.running", port); if (cb) cb(port); } }); servlet.on('exit', function(code, signal) { resetFlags(); if (code === null || signal === null) { serverExit = true; } log('servlet exist with code ' + code + 'signal ' + signal); observer.emit('server.exit',code); }); // make sure to close server after node process ends process.on('exit', function() { stopServer(true); }); }); }
javascript
function startServlet(cb) { startingServer = true; servletReady = false; debugger; findPort(function(port) { servletPort = global._servletPort = '' + port; servlet = global._servlet = cp.spawn('java', ['-cp', '.:../lib/servlet-api-2.5.jar:../lib/jetty-all-7.0.2.v20100331.jar', 'RunnerServlet', servletPort], { cwd: config.rootDir + '/bin' }); servlet.stdout.on('data', function(data) { console.log('OUT:' + data); }); servlet.stderr.on('data', function(data) { console.log("" + data); if (~data.toString().indexOf(servletPort)) { servletReady = true; startingServer = false; // queue.checkQueues(); observer.emit("server.running", port); if (cb) cb(port); } }); servlet.on('exit', function(code, signal) { resetFlags(); if (code === null || signal === null) { serverExit = true; } log('servlet exist with code ' + code + 'signal ' + signal); observer.emit('server.exit',code); }); // make sure to close server after node process ends process.on('exit', function() { stopServer(true); }); }); }
[ "function", "startServlet", "(", "cb", ")", "{", "startingServer", "=", "true", ";", "servletReady", "=", "false", ";", "debugger", ";", "findPort", "(", "function", "(", "port", ")", "{", "servletPort", "=", "global", ".", "_servletPort", "=", "''", "+", "port", ";", "servlet", "=", "global", ".", "_servlet", "=", "cp", ".", "spawn", "(", "'java'", ",", "[", "'-cp'", ",", "'.:../lib/servlet-api-2.5.jar:../lib/jetty-all-7.0.2.v20100331.jar'", ",", "'RunnerServlet'", ",", "servletPort", "]", ",", "{", "cwd", ":", "config", ".", "rootDir", "+", "'/bin'", "}", ")", ";", "servlet", ".", "stdout", ".", "on", "(", "'data'", ",", "function", "(", "data", ")", "{", "console", ".", "log", "(", "'OUT:'", "+", "data", ")", ";", "}", ")", ";", "servlet", ".", "stderr", ".", "on", "(", "'data'", ",", "function", "(", "data", ")", "{", "console", ".", "log", "(", "\"\"", "+", "data", ")", ";", "if", "(", "~", "data", ".", "toString", "(", ")", ".", "indexOf", "(", "servletPort", ")", ")", "{", "servletReady", "=", "true", ";", "startingServer", "=", "false", ";", "observer", ".", "emit", "(", "\"server.running\"", ",", "port", ")", ";", "if", "(", "cb", ")", "cb", "(", "port", ")", ";", "}", "}", ")", ";", "servlet", ".", "on", "(", "'exit'", ",", "function", "(", "code", ",", "signal", ")", "{", "resetFlags", "(", ")", ";", "if", "(", "code", "===", "null", "||", "signal", "===", "null", ")", "{", "serverExit", "=", "true", ";", "}", "log", "(", "'servlet exist with code '", "+", "code", "+", "'signal '", "+", "signal", ")", ";", "observer", ".", "emit", "(", "'server.exit'", ",", "code", ")", ";", "}", ")", ";", "process", ".", "on", "(", "'exit'", ",", "function", "(", ")", "{", "stopServer", "(", "true", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
Starts the servlet on an empty port default is 3678
[ "Starts", "the", "servlet", "on", "an", "empty", "port", "default", "is", "3678" ]
b5d87b503076bf76a01d111b85c18a639e6f80c8
https://github.com/amrdraz/java-code-runner/blob/b5d87b503076bf76a01d111b85c18a639e6f80c8/node/server.js#L144-L182
train
DeviaVir/node-partyflock
partyflock.js
Partyflock
function Partyflock(consumerKey, consumerSecret, endpoint, debug) { this.endpoint = 'partyflock.nl'; // Check instance arguments this.endpoint = (endpoint ? endpoint : this.endpoint); this.consumerKey = (consumerKey ? consumerKey : false); this.consumerSecret = (consumerSecret ? consumerSecret : false); this.debug = (typeof debug !== 'undefined' ? debug : false); // Check config options if(config.partyflock) { this.consumerKey = (this.consumerKey === false ? config.partyflock.consumerKey : false); this.consumerSecret = (this.consumerSecret === false ? config.partyflock.consumerSecret : false); this.endpoint = (this.endpoint !== config.partyflock.endpoint ? config.partyflock.endpoint : this.endpoint); this.debug = (this.debug === false && config.partyflock.debug !== 'undefined' ? config.partyflock.debug : this.debug); } // CI integration if(process.env['CONSUMER_KEY'] && process.env['CONSUMER_SECRET']) { this.consumerKey = process.env['CONSUMER_KEY']; this.consumerSecret = process.env['CONSUMER_SECRET']; } this.type = 'json'; this.date = new date(this); this.location = new location(this); this.artist = new artist(this); this.user = new user(this); this.party = new party(this); this.oauth = new OAuth.OAuth( 'https://' + this.endpoint + '/request_token', '', // no need for an oauth_token request this.consumerKey, this.consumerSecret, '1.0A', null, 'HMAC-SHA1' ); }
javascript
function Partyflock(consumerKey, consumerSecret, endpoint, debug) { this.endpoint = 'partyflock.nl'; // Check instance arguments this.endpoint = (endpoint ? endpoint : this.endpoint); this.consumerKey = (consumerKey ? consumerKey : false); this.consumerSecret = (consumerSecret ? consumerSecret : false); this.debug = (typeof debug !== 'undefined' ? debug : false); // Check config options if(config.partyflock) { this.consumerKey = (this.consumerKey === false ? config.partyflock.consumerKey : false); this.consumerSecret = (this.consumerSecret === false ? config.partyflock.consumerSecret : false); this.endpoint = (this.endpoint !== config.partyflock.endpoint ? config.partyflock.endpoint : this.endpoint); this.debug = (this.debug === false && config.partyflock.debug !== 'undefined' ? config.partyflock.debug : this.debug); } // CI integration if(process.env['CONSUMER_KEY'] && process.env['CONSUMER_SECRET']) { this.consumerKey = process.env['CONSUMER_KEY']; this.consumerSecret = process.env['CONSUMER_SECRET']; } this.type = 'json'; this.date = new date(this); this.location = new location(this); this.artist = new artist(this); this.user = new user(this); this.party = new party(this); this.oauth = new OAuth.OAuth( 'https://' + this.endpoint + '/request_token', '', // no need for an oauth_token request this.consumerKey, this.consumerSecret, '1.0A', null, 'HMAC-SHA1' ); }
[ "function", "Partyflock", "(", "consumerKey", ",", "consumerSecret", ",", "endpoint", ",", "debug", ")", "{", "this", ".", "endpoint", "=", "'partyflock.nl'", ";", "this", ".", "endpoint", "=", "(", "endpoint", "?", "endpoint", ":", "this", ".", "endpoint", ")", ";", "this", ".", "consumerKey", "=", "(", "consumerKey", "?", "consumerKey", ":", "false", ")", ";", "this", ".", "consumerSecret", "=", "(", "consumerSecret", "?", "consumerSecret", ":", "false", ")", ";", "this", ".", "debug", "=", "(", "typeof", "debug", "!==", "'undefined'", "?", "debug", ":", "false", ")", ";", "if", "(", "config", ".", "partyflock", ")", "{", "this", ".", "consumerKey", "=", "(", "this", ".", "consumerKey", "===", "false", "?", "config", ".", "partyflock", ".", "consumerKey", ":", "false", ")", ";", "this", ".", "consumerSecret", "=", "(", "this", ".", "consumerSecret", "===", "false", "?", "config", ".", "partyflock", ".", "consumerSecret", ":", "false", ")", ";", "this", ".", "endpoint", "=", "(", "this", ".", "endpoint", "!==", "config", ".", "partyflock", ".", "endpoint", "?", "config", ".", "partyflock", ".", "endpoint", ":", "this", ".", "endpoint", ")", ";", "this", ".", "debug", "=", "(", "this", ".", "debug", "===", "false", "&&", "config", ".", "partyflock", ".", "debug", "!==", "'undefined'", "?", "config", ".", "partyflock", ".", "debug", ":", "this", ".", "debug", ")", ";", "}", "if", "(", "process", ".", "env", "[", "'CONSUMER_KEY'", "]", "&&", "process", ".", "env", "[", "'CONSUMER_SECRET'", "]", ")", "{", "this", ".", "consumerKey", "=", "process", ".", "env", "[", "'CONSUMER_KEY'", "]", ";", "this", ".", "consumerSecret", "=", "process", ".", "env", "[", "'CONSUMER_SECRET'", "]", ";", "}", "this", ".", "type", "=", "'json'", ";", "this", ".", "date", "=", "new", "date", "(", "this", ")", ";", "this", ".", "location", "=", "new", "location", "(", "this", ")", ";", "this", ".", "artist", "=", "new", "artist", "(", "this", ")", ";", "this", ".", "user", "=", "new", "user", "(", "this", ")", ";", "this", ".", "party", "=", "new", "party", "(", "this", ")", ";", "this", ".", "oauth", "=", "new", "OAuth", ".", "OAuth", "(", "'https://'", "+", "this", ".", "endpoint", "+", "'/request_token'", ",", "''", ",", "this", ".", "consumerKey", ",", "this", ".", "consumerSecret", ",", "'1.0A'", ",", "null", ",", "'HMAC-SHA1'", ")", ";", "}" ]
Partyflock instance constructor @prototype @class Partyflock
[ "Partyflock", "instance", "constructor" ]
dafad1cc1f466d1373637f9748121f0acb7c3499
https://github.com/DeviaVir/node-partyflock/blob/dafad1cc1f466d1373637f9748121f0acb7c3499/partyflock.js#L21-L58
train
rootsdev/gedcomx-js
src/core/Coverage.js
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof Coverage)){ return new Coverage(json); } // If the given object is already an instance then just return it. DON'T copy it. if(Coverage.isInstance(json)){ return json; } this.init(json); }
javascript
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof Coverage)){ return new Coverage(json); } // If the given object is already an instance then just return it. DON'T copy it. if(Coverage.isInstance(json)){ return json; } this.init(json); }
[ "function", "(", "json", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Coverage", ")", ")", "{", "return", "new", "Coverage", "(", "json", ")", ";", "}", "if", "(", "Coverage", ".", "isInstance", "(", "json", ")", ")", "{", "return", "json", ";", "}", "this", ".", "init", "(", "json", ")", ";", "}" ]
A description of the spatial and temporal coverage of a resource. @see {@link https://github.com/FamilySearch/gedcomx/blob/master/specifications/json-format-specification.md#coverage|GEDCOM X JSON Spec} @class @extends ExtensibleData @apram {Object} [json]
[ "A", "description", "of", "the", "spatial", "and", "temporal", "coverage", "of", "a", "resource", "." ]
08b2fcde96f1e301c78561bfb7a8b0cac606e26e
https://github.com/rootsdev/gedcomx-js/blob/08b2fcde96f1e301c78561bfb7a8b0cac606e26e/src/core/Coverage.js#L13-L26
train
WildDogTeam/lib-js-wildgeo
src/geoDogUtils.js
function(resolution, latitude) { var degs = metersToLongitudeDegrees(resolution, latitude); return (Math.abs(degs) > 0.000001) ? Math.max(1, Math.log2(360/degs)) : 1; }
javascript
function(resolution, latitude) { var degs = metersToLongitudeDegrees(resolution, latitude); return (Math.abs(degs) > 0.000001) ? Math.max(1, Math.log2(360/degs)) : 1; }
[ "function", "(", "resolution", ",", "latitude", ")", "{", "var", "degs", "=", "metersToLongitudeDegrees", "(", "resolution", ",", "latitude", ")", ";", "return", "(", "Math", ".", "abs", "(", "degs", ")", ">", "0.000001", ")", "?", "Math", ".", "max", "(", "1", ",", "Math", ".", "log2", "(", "360", "/", "degs", ")", ")", ":", "1", ";", "}" ]
Calculates the bits necessary to reach a given resolution, in meters, for the longitude at a given latitude. @param {number} resolution The desired resolution. @param {number} latitude The latitude used in the conversion. @return {number} The bits necessary to reach a given resolution, in meters.
[ "Calculates", "the", "bits", "necessary", "to", "reach", "a", "given", "resolution", "in", "meters", "for", "the", "longitude", "at", "a", "given", "latitude", "." ]
225c8949e814ec7b39d1457f3aa3c63808a79470
https://github.com/WildDogTeam/lib-js-wildgeo/blob/225c8949e814ec7b39d1457f3aa3c63808a79470/src/geoDogUtils.js#L281-L284
train
WildDogTeam/lib-js-wildgeo
src/geoDogUtils.js
function(coordinate,size) { var latDeltaDegrees = size/g_METERS_PER_DEGREE_LATITUDE; var latitudeNorth = Math.min(90, coordinate[0] + latDeltaDegrees); var latitudeSouth = Math.max(-90, coordinate[0] - latDeltaDegrees); var bitsLat = Math.floor(latitudeBitsForResolution(size))*2; var bitsLongNorth = Math.floor(longitudeBitsForResolution(size, latitudeNorth))*2-1; var bitsLongSouth = Math.floor(longitudeBitsForResolution(size, latitudeSouth))*2-1; return Math.min(bitsLat, bitsLongNorth, bitsLongSouth, g_MAXIMUM_BITS_PRECISION); }
javascript
function(coordinate,size) { var latDeltaDegrees = size/g_METERS_PER_DEGREE_LATITUDE; var latitudeNorth = Math.min(90, coordinate[0] + latDeltaDegrees); var latitudeSouth = Math.max(-90, coordinate[0] - latDeltaDegrees); var bitsLat = Math.floor(latitudeBitsForResolution(size))*2; var bitsLongNorth = Math.floor(longitudeBitsForResolution(size, latitudeNorth))*2-1; var bitsLongSouth = Math.floor(longitudeBitsForResolution(size, latitudeSouth))*2-1; return Math.min(bitsLat, bitsLongNorth, bitsLongSouth, g_MAXIMUM_BITS_PRECISION); }
[ "function", "(", "coordinate", ",", "size", ")", "{", "var", "latDeltaDegrees", "=", "size", "/", "g_METERS_PER_DEGREE_LATITUDE", ";", "var", "latitudeNorth", "=", "Math", ".", "min", "(", "90", ",", "coordinate", "[", "0", "]", "+", "latDeltaDegrees", ")", ";", "var", "latitudeSouth", "=", "Math", ".", "max", "(", "-", "90", ",", "coordinate", "[", "0", "]", "-", "latDeltaDegrees", ")", ";", "var", "bitsLat", "=", "Math", ".", "floor", "(", "latitudeBitsForResolution", "(", "size", ")", ")", "*", "2", ";", "var", "bitsLongNorth", "=", "Math", ".", "floor", "(", "longitudeBitsForResolution", "(", "size", ",", "latitudeNorth", ")", ")", "*", "2", "-", "1", ";", "var", "bitsLongSouth", "=", "Math", ".", "floor", "(", "longitudeBitsForResolution", "(", "size", ",", "latitudeSouth", ")", ")", "*", "2", "-", "1", ";", "return", "Math", ".", "min", "(", "bitsLat", ",", "bitsLongNorth", ",", "bitsLongSouth", ",", "g_MAXIMUM_BITS_PRECISION", ")", ";", "}" ]
Calculates the maximum number of bits of a geohash to get a bounding box that is larger than a given size at the given coordinate. @param {Array.<number>} coordinate The coordinate as a [latitude, longitude] pair. @param {number} size The size of the bounding box. @return {number} The number of bits necessary for the geohash.
[ "Calculates", "the", "maximum", "number", "of", "bits", "of", "a", "geohash", "to", "get", "a", "bounding", "box", "that", "is", "larger", "than", "a", "given", "size", "at", "the", "given", "coordinate", "." ]
225c8949e814ec7b39d1457f3aa3c63808a79470
https://github.com/WildDogTeam/lib-js-wildgeo/blob/225c8949e814ec7b39d1457f3aa3c63808a79470/src/geoDogUtils.js#L322-L330
train
WildDogTeam/lib-js-wildgeo
src/geoDogUtils.js
function(center, radius) { var latDegrees = radius/g_METERS_PER_DEGREE_LATITUDE; var latitudeNorth = Math.min(90, center[0] + latDegrees); var latitudeSouth = Math.max(-90, center[0] - latDegrees); var longDegsNorth = metersToLongitudeDegrees(radius, latitudeNorth); var longDegsSouth = metersToLongitudeDegrees(radius, latitudeSouth); var longDegs = Math.max(longDegsNorth, longDegsSouth); return [ [center[0], center[1]], [center[0], wrapLongitude(center[1] - longDegs)], [center[0], wrapLongitude(center[1] + longDegs)], [latitudeNorth, center[1]], [latitudeNorth, wrapLongitude(center[1] - longDegs)], [latitudeNorth, wrapLongitude(center[1] + longDegs)], [latitudeSouth, center[1]], [latitudeSouth, wrapLongitude(center[1] - longDegs)], [latitudeSouth, wrapLongitude(center[1] + longDegs)] ]; }
javascript
function(center, radius) { var latDegrees = radius/g_METERS_PER_DEGREE_LATITUDE; var latitudeNorth = Math.min(90, center[0] + latDegrees); var latitudeSouth = Math.max(-90, center[0] - latDegrees); var longDegsNorth = metersToLongitudeDegrees(radius, latitudeNorth); var longDegsSouth = metersToLongitudeDegrees(radius, latitudeSouth); var longDegs = Math.max(longDegsNorth, longDegsSouth); return [ [center[0], center[1]], [center[0], wrapLongitude(center[1] - longDegs)], [center[0], wrapLongitude(center[1] + longDegs)], [latitudeNorth, center[1]], [latitudeNorth, wrapLongitude(center[1] - longDegs)], [latitudeNorth, wrapLongitude(center[1] + longDegs)], [latitudeSouth, center[1]], [latitudeSouth, wrapLongitude(center[1] - longDegs)], [latitudeSouth, wrapLongitude(center[1] + longDegs)] ]; }
[ "function", "(", "center", ",", "radius", ")", "{", "var", "latDegrees", "=", "radius", "/", "g_METERS_PER_DEGREE_LATITUDE", ";", "var", "latitudeNorth", "=", "Math", ".", "min", "(", "90", ",", "center", "[", "0", "]", "+", "latDegrees", ")", ";", "var", "latitudeSouth", "=", "Math", ".", "max", "(", "-", "90", ",", "center", "[", "0", "]", "-", "latDegrees", ")", ";", "var", "longDegsNorth", "=", "metersToLongitudeDegrees", "(", "radius", ",", "latitudeNorth", ")", ";", "var", "longDegsSouth", "=", "metersToLongitudeDegrees", "(", "radius", ",", "latitudeSouth", ")", ";", "var", "longDegs", "=", "Math", ".", "max", "(", "longDegsNorth", ",", "longDegsSouth", ")", ";", "return", "[", "[", "center", "[", "0", "]", ",", "center", "[", "1", "]", "]", ",", "[", "center", "[", "0", "]", ",", "wrapLongitude", "(", "center", "[", "1", "]", "-", "longDegs", ")", "]", ",", "[", "center", "[", "0", "]", ",", "wrapLongitude", "(", "center", "[", "1", "]", "+", "longDegs", ")", "]", ",", "[", "latitudeNorth", ",", "center", "[", "1", "]", "]", ",", "[", "latitudeNorth", ",", "wrapLongitude", "(", "center", "[", "1", "]", "-", "longDegs", ")", "]", ",", "[", "latitudeNorth", ",", "wrapLongitude", "(", "center", "[", "1", "]", "+", "longDegs", ")", "]", ",", "[", "latitudeSouth", ",", "center", "[", "1", "]", "]", ",", "[", "latitudeSouth", ",", "wrapLongitude", "(", "center", "[", "1", "]", "-", "longDegs", ")", "]", ",", "[", "latitudeSouth", ",", "wrapLongitude", "(", "center", "[", "1", "]", "+", "longDegs", ")", "]", "]", ";", "}" ]
Calculates eight points on the bounding box and the center of a given circle. At least one geohash of these nine coordinates, truncated to a precision of at most radius, are guaranteed to be prefixes of any geohash that lies within the circle. @param {Array.<number>} center The center given as [latitude, longitude]. @param {number} radius The radius of the circle. @return {Array.<Array.<number>>} The eight bounding box points.
[ "Calculates", "eight", "points", "on", "the", "bounding", "box", "and", "the", "center", "of", "a", "given", "circle", ".", "At", "least", "one", "geohash", "of", "these", "nine", "coordinates", "truncated", "to", "a", "precision", "of", "at", "most", "radius", "are", "guaranteed", "to", "be", "prefixes", "of", "any", "geohash", "that", "lies", "within", "the", "circle", "." ]
225c8949e814ec7b39d1457f3aa3c63808a79470
https://github.com/WildDogTeam/lib-js-wildgeo/blob/225c8949e814ec7b39d1457f3aa3c63808a79470/src/geoDogUtils.js#L341-L359
train
WildDogTeam/lib-js-wildgeo
src/geoDogUtils.js
function(geohash, bits) { validateGeohash(geohash); var precision = Math.ceil(bits/g_BITS_PER_CHAR); if (geohash.length < precision) { return [geohash, geohash+"~"]; } geohash = geohash.substring(0, precision); var base = geohash.substring(0, geohash.length - 1); var lastValue = g_BASE32.indexOf(geohash.charAt(geohash.length - 1)); var significantBits = bits - (base.length*g_BITS_PER_CHAR); var unusedBits = (g_BITS_PER_CHAR - significantBits); /*jshint bitwise: false*/ // delete unused bits var startValue = (lastValue >> unusedBits) << unusedBits; var endValue = startValue + (1 << unusedBits); /*jshint bitwise: true*/ if (endValue > 31) { return [base+g_BASE32[startValue], base+"~"]; } else { return [base+g_BASE32[startValue], base+g_BASE32[endValue]]; } }
javascript
function(geohash, bits) { validateGeohash(geohash); var precision = Math.ceil(bits/g_BITS_PER_CHAR); if (geohash.length < precision) { return [geohash, geohash+"~"]; } geohash = geohash.substring(0, precision); var base = geohash.substring(0, geohash.length - 1); var lastValue = g_BASE32.indexOf(geohash.charAt(geohash.length - 1)); var significantBits = bits - (base.length*g_BITS_PER_CHAR); var unusedBits = (g_BITS_PER_CHAR - significantBits); /*jshint bitwise: false*/ // delete unused bits var startValue = (lastValue >> unusedBits) << unusedBits; var endValue = startValue + (1 << unusedBits); /*jshint bitwise: true*/ if (endValue > 31) { return [base+g_BASE32[startValue], base+"~"]; } else { return [base+g_BASE32[startValue], base+g_BASE32[endValue]]; } }
[ "function", "(", "geohash", ",", "bits", ")", "{", "validateGeohash", "(", "geohash", ")", ";", "var", "precision", "=", "Math", ".", "ceil", "(", "bits", "/", "g_BITS_PER_CHAR", ")", ";", "if", "(", "geohash", ".", "length", "<", "precision", ")", "{", "return", "[", "geohash", ",", "geohash", "+", "\"~\"", "]", ";", "}", "geohash", "=", "geohash", ".", "substring", "(", "0", ",", "precision", ")", ";", "var", "base", "=", "geohash", ".", "substring", "(", "0", ",", "geohash", ".", "length", "-", "1", ")", ";", "var", "lastValue", "=", "g_BASE32", ".", "indexOf", "(", "geohash", ".", "charAt", "(", "geohash", ".", "length", "-", "1", ")", ")", ";", "var", "significantBits", "=", "bits", "-", "(", "base", ".", "length", "*", "g_BITS_PER_CHAR", ")", ";", "var", "unusedBits", "=", "(", "g_BITS_PER_CHAR", "-", "significantBits", ")", ";", "var", "startValue", "=", "(", "lastValue", ">>", "unusedBits", ")", "<<", "unusedBits", ";", "var", "endValue", "=", "startValue", "+", "(", "1", "<<", "unusedBits", ")", ";", "if", "(", "endValue", ">", "31", ")", "{", "return", "[", "base", "+", "g_BASE32", "[", "startValue", "]", ",", "base", "+", "\"~\"", "]", ";", "}", "else", "{", "return", "[", "base", "+", "g_BASE32", "[", "startValue", "]", ",", "base", "+", "g_BASE32", "[", "endValue", "]", "]", ";", "}", "}" ]
Calculates the bounding box query for a geohash with x bits precision. @param {string} geohash The geohash whose bounding box query to generate. @param {number} bits The number of bits of precision. @return {Array.<string>} A [start, end] pair of geohashes.
[ "Calculates", "the", "bounding", "box", "query", "for", "a", "geohash", "with", "x", "bits", "precision", "." ]
225c8949e814ec7b39d1457f3aa3c63808a79470
https://github.com/WildDogTeam/lib-js-wildgeo/blob/225c8949e814ec7b39d1457f3aa3c63808a79470/src/geoDogUtils.js#L368-L390
train
PlatziDev/react-markdown
index.js
reducer
function reducer(props, map, key) { return Object.assign({}, map, { [key]: props[key], }); }
javascript
function reducer(props, map, key) { return Object.assign({}, map, { [key]: props[key], }); }
[ "function", "reducer", "(", "props", ",", "map", ",", "key", ")", "{", "return", "Object", ".", "assign", "(", "{", "}", ",", "map", ",", "{", "[", "key", "]", ":", "props", "[", "key", "]", ",", "}", ")", ";", "}" ]
Merge props into a new map @param {Object} props The original prop map @param {Object} map The new prop map to fill @param {string} key Each key name that have passed the filter @return {Object} The new prop map with the setted prop
[ "Merge", "props", "into", "a", "new", "map" ]
f3f186627231bad7a4422df17191a68ff8c130df
https://github.com/PlatziDev/react-markdown/blob/f3f186627231bad7a4422df17191a68ff8c130df/index.js#L21-L25
train
PlatziDev/react-markdown
index.js
Markdown
function Markdown(props) { const tagProps = Object.keys(props).filter(filter).reduce(reducer.bind(null, props), {}); const parser = createParser(props.parser); return React.createElement( props.tagName, Object.assign(tagProps, { dangerouslySetInnerHTML: { __html: parser(props.content), }, }), ); }
javascript
function Markdown(props) { const tagProps = Object.keys(props).filter(filter).reduce(reducer.bind(null, props), {}); const parser = createParser(props.parser); return React.createElement( props.tagName, Object.assign(tagProps, { dangerouslySetInnerHTML: { __html: parser(props.content), }, }), ); }
[ "function", "Markdown", "(", "props", ")", "{", "const", "tagProps", "=", "Object", ".", "keys", "(", "props", ")", ".", "filter", "(", "filter", ")", ".", "reduce", "(", "reducer", ".", "bind", "(", "null", ",", "props", ")", ",", "{", "}", ")", ";", "const", "parser", "=", "createParser", "(", "props", ".", "parser", ")", ";", "return", "React", ".", "createElement", "(", "props", ".", "tagName", ",", "Object", ".", "assign", "(", "tagProps", ",", "{", "dangerouslySetInnerHTML", ":", "{", "__html", ":", "parser", "(", "props", ".", "content", ")", ",", "}", ",", "}", ")", ",", ")", ";", "}" ]
Render Platzi Flavored Markdown inside a React application. @param {string} [props.tagName='div'] The HTML tag used as wrapper @param {string} props.content The Markdown content to parse and render @param {Object} [props.parser={}] The parser options
[ "Render", "Platzi", "Flavored", "Markdown", "inside", "a", "React", "application", "." ]
f3f186627231bad7a4422df17191a68ff8c130df
https://github.com/PlatziDev/react-markdown/blob/f3f186627231bad7a4422df17191a68ff8c130df/index.js#L33-L46
train
Schoonology/discovery
lib/managers/http.js
HttpManager
function HttpManager(options) { if (!(this instanceof HttpManager)) { return new HttpManager(options); } options = options || {}; Manager.call(this, options); debug('New HttpManager: %j', options); this.hostname = options.hostname || null; this.port = options.port || Defaults.PORT; this.interval = options.interval || Defaults.INTERVAL; this._announceTimerId = null; this._startAnnouncements(); }
javascript
function HttpManager(options) { if (!(this instanceof HttpManager)) { return new HttpManager(options); } options = options || {}; Manager.call(this, options); debug('New HttpManager: %j', options); this.hostname = options.hostname || null; this.port = options.port || Defaults.PORT; this.interval = options.interval || Defaults.INTERVAL; this._announceTimerId = null; this._startAnnouncements(); }
[ "function", "HttpManager", "(", "options", ")", "{", "if", "(", "!", "(", "this", "instanceof", "HttpManager", ")", ")", "{", "return", "new", "HttpManager", "(", "options", ")", ";", "}", "options", "=", "options", "||", "{", "}", ";", "Manager", ".", "call", "(", "this", ",", "options", ")", ";", "debug", "(", "'New HttpManager: %j'", ",", "options", ")", ";", "this", ".", "hostname", "=", "options", ".", "hostname", "||", "null", ";", "this", ".", "port", "=", "options", ".", "port", "||", "Defaults", ".", "PORT", ";", "this", ".", "interval", "=", "options", ".", "interval", "||", "Defaults", ".", "INTERVAL", ";", "this", ".", "_announceTimerId", "=", "null", ";", "this", ".", "_startAnnouncements", "(", ")", ";", "}" ]
Creates a new instance of HttpManager with the provided `options`. The HttpManager provides a client connection to the HTTP-based, Tracker discovery system. For more information, see the README. @param {Object} options
[ "Creates", "a", "new", "instance", "of", "HttpManager", "with", "the", "provided", "options", "." ]
9d123d74c13f8c9b6904e409f8933b09ab22e175
https://github.com/Schoonology/discovery/blob/9d123d74c13f8c9b6904e409f8933b09ab22e175/lib/managers/http.js#L23-L42
train
AmpersandJS/ampersand-filtered-subcollection
ampersand-filtered-subcollection.js
function (newFilters, oldFilters) { var self = this; if (!oldFilters) { oldFilters = this._filters; } else if (!isArray(oldFilters)) { oldFilters = [oldFilters]; } if (!newFilters) { newFilters = []; } else if (!isArray(newFilters)) { newFilters = [newFilters]; } oldFilters.forEach(function (filter) { self._removeFilter(filter); }); newFilters.forEach(function (filter) { self._addFilter(filter); }); this._runFilters(); }
javascript
function (newFilters, oldFilters) { var self = this; if (!oldFilters) { oldFilters = this._filters; } else if (!isArray(oldFilters)) { oldFilters = [oldFilters]; } if (!newFilters) { newFilters = []; } else if (!isArray(newFilters)) { newFilters = [newFilters]; } oldFilters.forEach(function (filter) { self._removeFilter(filter); }); newFilters.forEach(function (filter) { self._addFilter(filter); }); this._runFilters(); }
[ "function", "(", "newFilters", ",", "oldFilters", ")", "{", "var", "self", "=", "this", ";", "if", "(", "!", "oldFilters", ")", "{", "oldFilters", "=", "this", ".", "_filters", ";", "}", "else", "if", "(", "!", "isArray", "(", "oldFilters", ")", ")", "{", "oldFilters", "=", "[", "oldFilters", "]", ";", "}", "if", "(", "!", "newFilters", ")", "{", "newFilters", "=", "[", "]", ";", "}", "else", "if", "(", "!", "isArray", "(", "newFilters", ")", ")", "{", "newFilters", "=", "[", "newFilters", "]", ";", "}", "oldFilters", ".", "forEach", "(", "function", "(", "filter", ")", "{", "self", ".", "_removeFilter", "(", "filter", ")", ";", "}", ")", ";", "newFilters", ".", "forEach", "(", "function", "(", "filter", ")", "{", "self", ".", "_addFilter", "(", "filter", ")", ";", "}", ")", ";", "this", ".", "_runFilters", "(", ")", ";", "}" ]
Swap out a set of old filters with a set of new filters
[ "Swap", "out", "a", "set", "of", "old", "filters", "with", "a", "set", "of", "new", "filters" ]
50fe385c658faff62e5c610217c949ad0e2c3ce2
https://github.com/AmpersandJS/ampersand-filtered-subcollection/blob/50fe385c658faff62e5c610217c949ad0e2c3ce2/ampersand-filtered-subcollection.js#L53-L77
train
AmpersandJS/ampersand-filtered-subcollection
ampersand-filtered-subcollection.js
function (query, indexName) { var model = this.collection.get(query, indexName); if (model && includes(this.models, model)) return model; }
javascript
function (query, indexName) { var model = this.collection.get(query, indexName); if (model && includes(this.models, model)) return model; }
[ "function", "(", "query", ",", "indexName", ")", "{", "var", "model", "=", "this", ".", "collection", ".", "get", "(", "query", ",", "indexName", ")", ";", "if", "(", "model", "&&", "includes", "(", "this", ".", "models", ",", "model", ")", ")", "return", "model", ";", "}" ]
proxy `get` method to the underlying collection
[ "proxy", "get", "method", "to", "the", "underlying", "collection" ]
50fe385c658faff62e5c610217c949ad0e2c3ce2
https://github.com/AmpersandJS/ampersand-filtered-subcollection/blob/50fe385c658faff62e5c610217c949ad0e2c3ce2/ampersand-filtered-subcollection.js#L92-L95
train
AmpersandJS/ampersand-filtered-subcollection
ampersand-filtered-subcollection.js
function (query, indexName) { if (!query) return; var index = this._indexes[indexName || this.mainIndex]; return index[query] || index[query[this.mainIndex]] || this._indexes.cid[query] || this._indexes.cid[query.cid]; }
javascript
function (query, indexName) { if (!query) return; var index = this._indexes[indexName || this.mainIndex]; return index[query] || index[query[this.mainIndex]] || this._indexes.cid[query] || this._indexes.cid[query.cid]; }
[ "function", "(", "query", ",", "indexName", ")", "{", "if", "(", "!", "query", ")", "return", ";", "var", "index", "=", "this", ".", "_indexes", "[", "indexName", "||", "this", ".", "mainIndex", "]", ";", "return", "index", "[", "query", "]", "||", "index", "[", "query", "[", "this", ".", "mainIndex", "]", "]", "||", "this", ".", "_indexes", ".", "cid", "[", "query", "]", "||", "this", ".", "_indexes", ".", "cid", "[", "query", ".", "cid", "]", ";", "}" ]
Internal API try to get a model by index
[ "Internal", "API", "try", "to", "get", "a", "model", "by", "index" ]
50fe385c658faff62e5c610217c949ad0e2c3ce2
https://github.com/AmpersandJS/ampersand-filtered-subcollection/blob/50fe385c658faff62e5c610217c949ad0e2c3ce2/ampersand-filtered-subcollection.js#L105-L109
train
AmpersandJS/ampersand-filtered-subcollection
ampersand-filtered-subcollection.js
function (model, options, eventName) { var newModels = slice.call(this.models); var comparator = this.comparator || this.collection.comparator; //Whether or not we are to expect a sort event from our collection later var sortable = eventName === 'add' && this.collection.comparator && (options.at == null) && options.sort !== false; if (!sortable) { var index = sortedIndexBy(newModels, model, comparator); newModels.splice(index, 0, model); } else { newModels.push(model); if (options.at) newModels = this._sortModels(newModels); } this.models = newModels; this._addIndex(this._indexes, model); if (this.comparator && !sortable) { this.trigger('sort', this); } }
javascript
function (model, options, eventName) { var newModels = slice.call(this.models); var comparator = this.comparator || this.collection.comparator; //Whether or not we are to expect a sort event from our collection later var sortable = eventName === 'add' && this.collection.comparator && (options.at == null) && options.sort !== false; if (!sortable) { var index = sortedIndexBy(newModels, model, comparator); newModels.splice(index, 0, model); } else { newModels.push(model); if (options.at) newModels = this._sortModels(newModels); } this.models = newModels; this._addIndex(this._indexes, model); if (this.comparator && !sortable) { this.trigger('sort', this); } }
[ "function", "(", "model", ",", "options", ",", "eventName", ")", "{", "var", "newModels", "=", "slice", ".", "call", "(", "this", ".", "models", ")", ";", "var", "comparator", "=", "this", ".", "comparator", "||", "this", ".", "collection", ".", "comparator", ";", "var", "sortable", "=", "eventName", "===", "'add'", "&&", "this", ".", "collection", ".", "comparator", "&&", "(", "options", ".", "at", "==", "null", ")", "&&", "options", ".", "sort", "!==", "false", ";", "if", "(", "!", "sortable", ")", "{", "var", "index", "=", "sortedIndexBy", "(", "newModels", ",", "model", ",", "comparator", ")", ";", "newModels", ".", "splice", "(", "index", ",", "0", ",", "model", ")", ";", "}", "else", "{", "newModels", ".", "push", "(", "model", ")", ";", "if", "(", "options", ".", "at", ")", "newModels", "=", "this", ".", "_sortModels", "(", "newModels", ")", ";", "}", "this", ".", "models", "=", "newModels", ";", "this", ".", "_addIndex", "(", "this", ".", "_indexes", ",", "model", ")", ";", "if", "(", "this", ".", "comparator", "&&", "!", "sortable", ")", "{", "this", ".", "trigger", "(", "'sort'", ",", "this", ")", ";", "}", "}" ]
Add a model to this filtered collection that has already passed the filters
[ "Add", "a", "model", "to", "this", "filtered", "collection", "that", "has", "already", "passed", "the", "filters" ]
50fe385c658faff62e5c610217c949ad0e2c3ce2
https://github.com/AmpersandJS/ampersand-filtered-subcollection/blob/50fe385c658faff62e5c610217c949ad0e2c3ce2/ampersand-filtered-subcollection.js#L178-L196
train
AmpersandJS/ampersand-filtered-subcollection
ampersand-filtered-subcollection.js
function (model) { var newModels = slice.call(this.models); var modelIndex = newModels.indexOf(model); if (modelIndex > -1) { newModels.splice(modelIndex, 1); this.models = newModels; this._removeIndex(this._indexes, model); return true; } return false; }
javascript
function (model) { var newModels = slice.call(this.models); var modelIndex = newModels.indexOf(model); if (modelIndex > -1) { newModels.splice(modelIndex, 1); this.models = newModels; this._removeIndex(this._indexes, model); return true; } return false; }
[ "function", "(", "model", ")", "{", "var", "newModels", "=", "slice", ".", "call", "(", "this", ".", "models", ")", ";", "var", "modelIndex", "=", "newModels", ".", "indexOf", "(", "model", ")", ";", "if", "(", "modelIndex", ">", "-", "1", ")", "{", "newModels", ".", "splice", "(", "modelIndex", ",", "1", ")", ";", "this", ".", "models", "=", "newModels", ";", "this", ".", "_removeIndex", "(", "this", ".", "_indexes", ",", "model", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Remove a model if it's in this filtered collection
[ "Remove", "a", "model", "if", "it", "s", "in", "this", "filtered", "collection" ]
50fe385c658faff62e5c610217c949ad0e2c3ce2
https://github.com/AmpersandJS/ampersand-filtered-subcollection/blob/50fe385c658faff62e5c610217c949ad0e2c3ce2/ampersand-filtered-subcollection.js#L199-L209
train
AmpersandJS/ampersand-filtered-subcollection
ampersand-filtered-subcollection.js
function () { // make a copy of the array for comparisons var existingModels = slice.call(this.models); var rootModels = slice.call(this.collection.models); var newIndexes = {}; var newModels, toAdd, toRemove; this._resetIndexes(newIndexes); // reduce base model set by applying filters if (this._filters.length) { newModels = reduce(this._filters, function (startingArray, filterFunc) { return startingArray.filter(filterFunc); }, rootModels); } else { newModels = slice.call(rootModels); } // sort it if (this.comparator) newModels = this._sortModels(newModels, this.comparator); newModels.forEach(function (model) { this._addIndex(newIndexes, model); }, this); // Cache a reference to the full filtered set to allow this._filtered.length. Ref: #6 if (rootModels.length) { this._filtered = newModels; this._indexes = newIndexes; } else { this._filtered = []; this._resetIndexes(this._indexes); } // now we've got our new models time to compare toAdd = difference(newModels, existingModels); toRemove = difference(existingModels, newModels); // save 'em this.models = newModels; forEach(toRemove, bind(function (model) { this.trigger('remove', model, this); }, this)); forEach(toAdd, bind(function (model) { this.trigger('add', model, this); }, this)); // unless we have the same models in same order trigger `sort` if (!isEqual(existingModels, newModels) && this.comparator) { this.trigger('sort', this); } }
javascript
function () { // make a copy of the array for comparisons var existingModels = slice.call(this.models); var rootModels = slice.call(this.collection.models); var newIndexes = {}; var newModels, toAdd, toRemove; this._resetIndexes(newIndexes); // reduce base model set by applying filters if (this._filters.length) { newModels = reduce(this._filters, function (startingArray, filterFunc) { return startingArray.filter(filterFunc); }, rootModels); } else { newModels = slice.call(rootModels); } // sort it if (this.comparator) newModels = this._sortModels(newModels, this.comparator); newModels.forEach(function (model) { this._addIndex(newIndexes, model); }, this); // Cache a reference to the full filtered set to allow this._filtered.length. Ref: #6 if (rootModels.length) { this._filtered = newModels; this._indexes = newIndexes; } else { this._filtered = []; this._resetIndexes(this._indexes); } // now we've got our new models time to compare toAdd = difference(newModels, existingModels); toRemove = difference(existingModels, newModels); // save 'em this.models = newModels; forEach(toRemove, bind(function (model) { this.trigger('remove', model, this); }, this)); forEach(toAdd, bind(function (model) { this.trigger('add', model, this); }, this)); // unless we have the same models in same order trigger `sort` if (!isEqual(existingModels, newModels) && this.comparator) { this.trigger('sort', this); } }
[ "function", "(", ")", "{", "var", "existingModels", "=", "slice", ".", "call", "(", "this", ".", "models", ")", ";", "var", "rootModels", "=", "slice", ".", "call", "(", "this", ".", "collection", ".", "models", ")", ";", "var", "newIndexes", "=", "{", "}", ";", "var", "newModels", ",", "toAdd", ",", "toRemove", ";", "this", ".", "_resetIndexes", "(", "newIndexes", ")", ";", "if", "(", "this", ".", "_filters", ".", "length", ")", "{", "newModels", "=", "reduce", "(", "this", ".", "_filters", ",", "function", "(", "startingArray", ",", "filterFunc", ")", "{", "return", "startingArray", ".", "filter", "(", "filterFunc", ")", ";", "}", ",", "rootModels", ")", ";", "}", "else", "{", "newModels", "=", "slice", ".", "call", "(", "rootModels", ")", ";", "}", "if", "(", "this", ".", "comparator", ")", "newModels", "=", "this", ".", "_sortModels", "(", "newModels", ",", "this", ".", "comparator", ")", ";", "newModels", ".", "forEach", "(", "function", "(", "model", ")", "{", "this", ".", "_addIndex", "(", "newIndexes", ",", "model", ")", ";", "}", ",", "this", ")", ";", "if", "(", "rootModels", ".", "length", ")", "{", "this", ".", "_filtered", "=", "newModels", ";", "this", ".", "_indexes", "=", "newIndexes", ";", "}", "else", "{", "this", ".", "_filtered", "=", "[", "]", ";", "this", ".", "_resetIndexes", "(", "this", ".", "_indexes", ")", ";", "}", "toAdd", "=", "difference", "(", "newModels", ",", "existingModels", ")", ";", "toRemove", "=", "difference", "(", "existingModels", ",", "newModels", ")", ";", "this", ".", "models", "=", "newModels", ";", "forEach", "(", "toRemove", ",", "bind", "(", "function", "(", "model", ")", "{", "this", ".", "trigger", "(", "'remove'", ",", "model", ",", "this", ")", ";", "}", ",", "this", ")", ")", ";", "forEach", "(", "toAdd", ",", "bind", "(", "function", "(", "model", ")", "{", "this", ".", "trigger", "(", "'add'", ",", "model", ",", "this", ")", ";", "}", ",", "this", ")", ")", ";", "if", "(", "!", "isEqual", "(", "existingModels", ",", "newModels", ")", "&&", "this", ".", "comparator", ")", "{", "this", ".", "trigger", "(", "'sort'", ",", "this", ")", ";", "}", "}" ]
Re-run the filters on all our parent's models
[ "Re", "-", "run", "the", "filters", "on", "all", "our", "parent", "s", "models" ]
50fe385c658faff62e5c610217c949ad0e2c3ce2
https://github.com/AmpersandJS/ampersand-filtered-subcollection/blob/50fe385c658faff62e5c610217c949ad0e2c3ce2/ampersand-filtered-subcollection.js#L245-L298
train
rootsdev/gedcomx-js
src/core/NameForm.js
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof NameForm)){ return new NameForm(json); } // If the given object is already an instance then just return it. DON'T copy it. if(NameForm.isInstance(json)){ return json; } this.init(json); }
javascript
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof NameForm)){ return new NameForm(json); } // If the given object is already an instance then just return it. DON'T copy it. if(NameForm.isInstance(json)){ return json; } this.init(json); }
[ "function", "(", "json", ")", "{", "if", "(", "!", "(", "this", "instanceof", "NameForm", ")", ")", "{", "return", "new", "NameForm", "(", "json", ")", ";", "}", "if", "(", "NameForm", ".", "isInstance", "(", "json", ")", ")", "{", "return", "json", ";", "}", "this", ".", "init", "(", "json", ")", ";", "}" ]
A form of a name. @see {@link https://github.com/FamilySearch/gedcomx/blob/master/specifications/json-format-specification.md#name-form|GEDCOM X JSON Spec} @class @extends ExtensibleData @param {Object} [json]
[ "A", "form", "of", "a", "name", "." ]
08b2fcde96f1e301c78561bfb7a8b0cac606e26e
https://github.com/rootsdev/gedcomx-js/blob/08b2fcde96f1e301c78561bfb7a8b0cac606e26e/src/core/NameForm.js#L13-L26
train
Ubudu/uBeacon-uart-lib
node/examples/mesh-sender.js
function(callback){ ubeacon.getMeshSettingsRegisterObject( function(data, error){ if( error === null ){ meshSettings.setFrom( data ); console.log( 'meshSettings: ', meshSettings ); if( meshSettings.enabled !== true && program.enableMesh !== true ){ return callback(new Error('Mesh is disabled on device. Enable it by adding `--enable-mesh` parameter.')); } return callback(null); }else{ return callback(error); } }); }
javascript
function(callback){ ubeacon.getMeshSettingsRegisterObject( function(data, error){ if( error === null ){ meshSettings.setFrom( data ); console.log( 'meshSettings: ', meshSettings ); if( meshSettings.enabled !== true && program.enableMesh !== true ){ return callback(new Error('Mesh is disabled on device. Enable it by adding `--enable-mesh` parameter.')); } return callback(null); }else{ return callback(error); } }); }
[ "function", "(", "callback", ")", "{", "ubeacon", ".", "getMeshSettingsRegisterObject", "(", "function", "(", "data", ",", "error", ")", "{", "if", "(", "error", "===", "null", ")", "{", "meshSettings", ".", "setFrom", "(", "data", ")", ";", "console", ".", "log", "(", "'meshSettings: '", ",", "meshSettings", ")", ";", "if", "(", "meshSettings", ".", "enabled", "!==", "true", "&&", "program", ".", "enableMesh", "!==", "true", ")", "{", "return", "callback", "(", "new", "Error", "(", "'Mesh is disabled on device. Enable it by adding `--enable-mesh` parameter.'", ")", ")", ";", "}", "return", "callback", "(", "null", ")", ";", "}", "else", "{", "return", "callback", "(", "error", ")", ";", "}", "}", ")", ";", "}" ]
Check if mesh is enabled
[ "Check", "if", "mesh", "is", "enabled" ]
a7436f3491f61ffabb34e2bc3b2441cc048f5dfa
https://github.com/Ubudu/uBeacon-uart-lib/blob/a7436f3491f61ffabb34e2bc3b2441cc048f5dfa/node/examples/mesh-sender.js#L35-L49
train
Ubudu/uBeacon-uart-lib
node/examples/mesh-sender.js
function(callback){ ubeacon.getMeshDeviceId( function( deviceAddress ){ console.log( '[ubeacon] Device address is: ' + deviceAddress + ' (0x' + deviceAddress.toString(16) + ')' ); callback(null); }); }
javascript
function(callback){ ubeacon.getMeshDeviceId( function( deviceAddress ){ console.log( '[ubeacon] Device address is: ' + deviceAddress + ' (0x' + deviceAddress.toString(16) + ')' ); callback(null); }); }
[ "function", "(", "callback", ")", "{", "ubeacon", ".", "getMeshDeviceId", "(", "function", "(", "deviceAddress", ")", "{", "console", ".", "log", "(", "'[ubeacon] Device address is: '", "+", "deviceAddress", "+", "' (0x'", "+", "deviceAddress", ".", "toString", "(", "16", ")", "+", "')'", ")", ";", "callback", "(", "null", ")", ";", "}", ")", ";", "}" ]
Get device address and print it
[ "Get", "device", "address", "and", "print", "it" ]
a7436f3491f61ffabb34e2bc3b2441cc048f5dfa
https://github.com/Ubudu/uBeacon-uart-lib/blob/a7436f3491f61ffabb34e2bc3b2441cc048f5dfa/node/examples/mesh-sender.js#L68-L73
train
Ubudu/uBeacon-uart-lib
node/examples/mesh-sender.js
function(callback){ console.log( 'Start sending messages... '); setInterval(function(){ var msg = ''; if( program.message != null ){ msg = program.message; }else{ msgCounter++; msg = 'Hello #' + msgCounter + ' from node.js'; } console.log( '[ubeacon] Sending "' +msg+ '" to device: ' + program.destinationAddress ); ubeacon.sendMeshGenericMessage( program.destinationAddress, msg, function( response ){ console.log( '[ubeacon] Mesh message #' + msgCounter + ' sent. Response: ' + response ); }); }, interval); }
javascript
function(callback){ console.log( 'Start sending messages... '); setInterval(function(){ var msg = ''; if( program.message != null ){ msg = program.message; }else{ msgCounter++; msg = 'Hello #' + msgCounter + ' from node.js'; } console.log( '[ubeacon] Sending "' +msg+ '" to device: ' + program.destinationAddress ); ubeacon.sendMeshGenericMessage( program.destinationAddress, msg, function( response ){ console.log( '[ubeacon] Mesh message #' + msgCounter + ' sent. Response: ' + response ); }); }, interval); }
[ "function", "(", "callback", ")", "{", "console", ".", "log", "(", "'Start sending messages... '", ")", ";", "setInterval", "(", "function", "(", ")", "{", "var", "msg", "=", "''", ";", "if", "(", "program", ".", "message", "!=", "null", ")", "{", "msg", "=", "program", ".", "message", ";", "}", "else", "{", "msgCounter", "++", ";", "msg", "=", "'Hello #'", "+", "msgCounter", "+", "' from node.js'", ";", "}", "console", ".", "log", "(", "'[ubeacon] Sending \"'", "+", "msg", "+", "'\" to device: '", "+", "program", ".", "destinationAddress", ")", ";", "ubeacon", ".", "sendMeshGenericMessage", "(", "program", ".", "destinationAddress", ",", "msg", ",", "function", "(", "response", ")", "{", "console", ".", "log", "(", "'[ubeacon] Mesh message #'", "+", "msgCounter", "+", "' sent. Response: '", "+", "response", ")", ";", "}", ")", ";", "}", ",", "interval", ")", ";", "}" ]
Send message - works until script is terminated
[ "Send", "message", "-", "works", "until", "script", "is", "terminated" ]
a7436f3491f61ffabb34e2bc3b2441cc048f5dfa
https://github.com/Ubudu/uBeacon-uart-lib/blob/a7436f3491f61ffabb34e2bc3b2441cc048f5dfa/node/examples/mesh-sender.js#L76-L91
train
AppGeo/cartodb
lib/builder.js
columns
function columns(column) { if (!column) { return this; } this._statements.push({ grouping: 'columns', value: normalizeArr.apply(null, arguments) }); return this; }
javascript
function columns(column) { if (!column) { return this; } this._statements.push({ grouping: 'columns', value: normalizeArr.apply(null, arguments) }); return this; }
[ "function", "columns", "(", "column", ")", "{", "if", "(", "!", "column", ")", "{", "return", "this", ";", "}", "this", ".", "_statements", ".", "push", "(", "{", "grouping", ":", "'columns'", ",", "value", ":", "normalizeArr", ".", "apply", "(", "null", ",", "arguments", ")", "}", ")", ";", "return", "this", ";", "}" ]
Adds a column or columns to the list of "columns" being selected on the query.
[ "Adds", "a", "column", "or", "columns", "to", "the", "list", "of", "columns", "being", "selected", "on", "the", "query", "." ]
4cc624975d359800961bf34cb74de97488d2efb5
https://github.com/AppGeo/cartodb/blob/4cc624975d359800961bf34cb74de97488d2efb5/lib/builder.js#L59-L68
train
AppGeo/cartodb
lib/builder.js
distinct
function distinct() { this._statements.push({ grouping: 'columns', value: normalizeArr.apply(null, arguments), distinct: true }); return this; }
javascript
function distinct() { this._statements.push({ grouping: 'columns', value: normalizeArr.apply(null, arguments), distinct: true }); return this; }
[ "function", "distinct", "(", ")", "{", "this", ".", "_statements", ".", "push", "(", "{", "grouping", ":", "'columns'", ",", "value", ":", "normalizeArr", ".", "apply", "(", "null", ",", "arguments", ")", ",", "distinct", ":", "true", "}", ")", ";", "return", "this", ";", "}" ]
Adds a `distinct` clause to the query.
[ "Adds", "a", "distinct", "clause", "to", "the", "query", "." ]
4cc624975d359800961bf34cb74de97488d2efb5
https://github.com/AppGeo/cartodb/blob/4cc624975d359800961bf34cb74de97488d2efb5/lib/builder.js#L86-L93
train
AppGeo/cartodb
lib/builder.js
_objectWhere
function _objectWhere(obj) { var boolVal = this._bool(); var notVal = this._not() ? 'Not' : ''; for (var key in obj) { this[boolVal + 'Where' + notVal](key, obj[key]); } return this; }
javascript
function _objectWhere(obj) { var boolVal = this._bool(); var notVal = this._not() ? 'Not' : ''; for (var key in obj) { this[boolVal + 'Where' + notVal](key, obj[key]); } return this; }
[ "function", "_objectWhere", "(", "obj", ")", "{", "var", "boolVal", "=", "this", ".", "_bool", "(", ")", ";", "var", "notVal", "=", "this", ".", "_not", "(", ")", "?", "'Not'", ":", "''", ";", "for", "(", "var", "key", "in", "obj", ")", "{", "this", "[", "boolVal", "+", "'Where'", "+", "notVal", "]", "(", "key", ",", "obj", "[", "key", "]", ")", ";", "}", "return", "this", ";", "}" ]
Processes an object literal provided in a "where" clause.
[ "Processes", "an", "object", "literal", "provided", "in", "a", "where", "clause", "." ]
4cc624975d359800961bf34cb74de97488d2efb5
https://github.com/AppGeo/cartodb/blob/4cc624975d359800961bf34cb74de97488d2efb5/lib/builder.js#L241-L248
train
AppGeo/cartodb
lib/builder.js
havingWrapped
function havingWrapped(callback) { this._statements.push({ grouping: 'having', type: 'whereWrapped', value: callback, bool: this._bool() }); return this; }
javascript
function havingWrapped(callback) { this._statements.push({ grouping: 'having', type: 'whereWrapped', value: callback, bool: this._bool() }); return this; }
[ "function", "havingWrapped", "(", "callback", ")", "{", "this", ".", "_statements", ".", "push", "(", "{", "grouping", ":", "'having'", ",", "type", ":", "'whereWrapped'", ",", "value", ":", "callback", ",", "bool", ":", "this", ".", "_bool", "(", ")", "}", ")", ";", "return", "this", ";", "}" ]
Helper for compiling any advanced `having` queries.
[ "Helper", "for", "compiling", "any", "advanced", "having", "queries", "." ]
4cc624975d359800961bf34cb74de97488d2efb5
https://github.com/AppGeo/cartodb/blob/4cc624975d359800961bf34cb74de97488d2efb5/lib/builder.js#L279-L287
train
AppGeo/cartodb
lib/builder.js
whereExists
function whereExists(callback) { this._statements.push({ grouping: 'where', type: 'whereExists', value: callback, not: this._not(), bool: this._bool() }); return this; }
javascript
function whereExists(callback) { this._statements.push({ grouping: 'where', type: 'whereExists', value: callback, not: this._not(), bool: this._bool() }); return this; }
[ "function", "whereExists", "(", "callback", ")", "{", "this", ".", "_statements", ".", "push", "(", "{", "grouping", ":", "'where'", ",", "type", ":", "'whereExists'", ",", "value", ":", "callback", ",", "not", ":", "this", ".", "_not", "(", ")", ",", "bool", ":", "this", ".", "_bool", "(", ")", "}", ")", ";", "return", "this", ";", "}" ]
Adds a `where exists` clause to the query.
[ "Adds", "a", "where", "exists", "clause", "to", "the", "query", "." ]
4cc624975d359800961bf34cb74de97488d2efb5
https://github.com/AppGeo/cartodb/blob/4cc624975d359800961bf34cb74de97488d2efb5/lib/builder.js#L290-L298
train
AppGeo/cartodb
lib/builder.js
whereIn
function whereIn(column, values) { if (Array.isArray(values) && isEmpty(values)) { return this.where(this._not()); } this._statements.push({ grouping: 'where', type: 'whereIn', column: column, value: values, not: this._not(), bool: this._bool() }); return this; }
javascript
function whereIn(column, values) { if (Array.isArray(values) && isEmpty(values)) { return this.where(this._not()); } this._statements.push({ grouping: 'where', type: 'whereIn', column: column, value: values, not: this._not(), bool: this._bool() }); return this; }
[ "function", "whereIn", "(", "column", ",", "values", ")", "{", "if", "(", "Array", ".", "isArray", "(", "values", ")", "&&", "isEmpty", "(", "values", ")", ")", "{", "return", "this", ".", "where", "(", "this", ".", "_not", "(", ")", ")", ";", "}", "this", ".", "_statements", ".", "push", "(", "{", "grouping", ":", "'where'", ",", "type", ":", "'whereIn'", ",", "column", ":", "column", ",", "value", ":", "values", ",", "not", ":", "this", ".", "_not", "(", ")", ",", "bool", ":", "this", ".", "_bool", "(", ")", "}", ")", ";", "return", "this", ";", "}" ]
Adds a `where in` clause to the query.
[ "Adds", "a", "where", "in", "clause", "to", "the", "query", "." ]
4cc624975d359800961bf34cb74de97488d2efb5
https://github.com/AppGeo/cartodb/blob/4cc624975d359800961bf34cb74de97488d2efb5/lib/builder.js#L316-L329
train
AppGeo/cartodb
lib/builder.js
whereNull
function whereNull(column) { this._statements.push({ grouping: 'where', type: 'whereNull', column: column, not: this._not(), bool: this._bool() }); return this; }
javascript
function whereNull(column) { this._statements.push({ grouping: 'where', type: 'whereNull', column: column, not: this._not(), bool: this._bool() }); return this; }
[ "function", "whereNull", "(", "column", ")", "{", "this", ".", "_statements", ".", "push", "(", "{", "grouping", ":", "'where'", ",", "type", ":", "'whereNull'", ",", "column", ":", "column", ",", "not", ":", "this", ".", "_not", "(", ")", ",", "bool", ":", "this", ".", "_bool", "(", ")", "}", ")", ";", "return", "this", ";", "}" ]
Adds a `where null` clause to the query.
[ "Adds", "a", "where", "null", "clause", "to", "the", "query", "." ]
4cc624975d359800961bf34cb74de97488d2efb5
https://github.com/AppGeo/cartodb/blob/4cc624975d359800961bf34cb74de97488d2efb5/lib/builder.js#L347-L356
train
AppGeo/cartodb
lib/builder.js
whereBetween
function whereBetween(column, values) { assert(Array.isArray(values), 'The second argument to whereBetween must be an array.'); assert(values.length === 2, 'You must specify 2 values for the whereBetween clause'); this._statements.push({ grouping: 'where', type: 'whereBetween', column: column, value: values, not: this._not(), bool: this._bool() }); return this; }
javascript
function whereBetween(column, values) { assert(Array.isArray(values), 'The second argument to whereBetween must be an array.'); assert(values.length === 2, 'You must specify 2 values for the whereBetween clause'); this._statements.push({ grouping: 'where', type: 'whereBetween', column: column, value: values, not: this._not(), bool: this._bool() }); return this; }
[ "function", "whereBetween", "(", "column", ",", "values", ")", "{", "assert", "(", "Array", ".", "isArray", "(", "values", ")", ",", "'The second argument to whereBetween must be an array.'", ")", ";", "assert", "(", "values", ".", "length", "===", "2", ",", "'You must specify 2 values for the whereBetween clause'", ")", ";", "this", ".", "_statements", ".", "push", "(", "{", "grouping", ":", "'where'", ",", "type", ":", "'whereBetween'", ",", "column", ":", "column", ",", "value", ":", "values", ",", "not", ":", "this", ".", "_not", "(", ")", ",", "bool", ":", "this", ".", "_bool", "(", ")", "}", ")", ";", "return", "this", ";", "}" ]
Adds a `where between` clause to the query.
[ "Adds", "a", "where", "between", "clause", "to", "the", "query", "." ]
4cc624975d359800961bf34cb74de97488d2efb5
https://github.com/AppGeo/cartodb/blob/4cc624975d359800961bf34cb74de97488d2efb5/lib/builder.js#L374-L386
train
AppGeo/cartodb
lib/builder.js
groupBy
function groupBy(item) { if (item instanceof Raw) { return this.groupByRaw.apply(this, arguments); } this._statements.push({ grouping: 'group', type: 'groupByBasic', value: normalizeArr.apply(null, arguments) }); return this; }
javascript
function groupBy(item) { if (item instanceof Raw) { return this.groupByRaw.apply(this, arguments); } this._statements.push({ grouping: 'group', type: 'groupByBasic', value: normalizeArr.apply(null, arguments) }); return this; }
[ "function", "groupBy", "(", "item", ")", "{", "if", "(", "item", "instanceof", "Raw", ")", "{", "return", "this", ".", "groupByRaw", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", "this", ".", "_statements", ".", "push", "(", "{", "grouping", ":", "'group'", ",", "type", ":", "'groupByBasic'", ",", "value", ":", "normalizeArr", ".", "apply", "(", "null", ",", "arguments", ")", "}", ")", ";", "return", "this", ";", "}" ]
Adds a `group by` clause to the query.
[ "Adds", "a", "group", "by", "clause", "to", "the", "query", "." ]
4cc624975d359800961bf34cb74de97488d2efb5
https://github.com/AppGeo/cartodb/blob/4cc624975d359800961bf34cb74de97488d2efb5/lib/builder.js#L404-L414
train
AppGeo/cartodb
lib/builder.js
groupByRaw
function groupByRaw(sql, bindings) { var raw = sql instanceof Raw ? sql : this.client.raw(sql, bindings); this._statements.push({ grouping: 'group', type: 'groupByRaw', value: raw }); return this; }
javascript
function groupByRaw(sql, bindings) { var raw = sql instanceof Raw ? sql : this.client.raw(sql, bindings); this._statements.push({ grouping: 'group', type: 'groupByRaw', value: raw }); return this; }
[ "function", "groupByRaw", "(", "sql", ",", "bindings", ")", "{", "var", "raw", "=", "sql", "instanceof", "Raw", "?", "sql", ":", "this", ".", "client", ".", "raw", "(", "sql", ",", "bindings", ")", ";", "this", ".", "_statements", ".", "push", "(", "{", "grouping", ":", "'group'", ",", "type", ":", "'groupByRaw'", ",", "value", ":", "raw", "}", ")", ";", "return", "this", ";", "}" ]
Adds a raw `group by` clause to the query.
[ "Adds", "a", "raw", "group", "by", "clause", "to", "the", "query", "." ]
4cc624975d359800961bf34cb74de97488d2efb5
https://github.com/AppGeo/cartodb/blob/4cc624975d359800961bf34cb74de97488d2efb5/lib/builder.js#L417-L425
train
AppGeo/cartodb
lib/builder.js
orderBy
function orderBy(column, direction) { this._statements.push({ grouping: 'order', type: 'orderByBasic', value: column, direction: direction }); return this; }
javascript
function orderBy(column, direction) { this._statements.push({ grouping: 'order', type: 'orderByBasic', value: column, direction: direction }); return this; }
[ "function", "orderBy", "(", "column", ",", "direction", ")", "{", "this", ".", "_statements", ".", "push", "(", "{", "grouping", ":", "'order'", ",", "type", ":", "'orderByBasic'", ",", "value", ":", "column", ",", "direction", ":", "direction", "}", ")", ";", "return", "this", ";", "}" ]
Adds a `order by` clause to the query.
[ "Adds", "a", "order", "by", "clause", "to", "the", "query", "." ]
4cc624975d359800961bf34cb74de97488d2efb5
https://github.com/AppGeo/cartodb/blob/4cc624975d359800961bf34cb74de97488d2efb5/lib/builder.js#L428-L436
train
AppGeo/cartodb
lib/builder.js
union
function union(callbacks, wrap) { if (arguments.length === 1 || arguments.length === 2 && typeof wrap === 'boolean') { if (!Array.isArray(callbacks)) { callbacks = [callbacks]; } for (var i = 0, l = callbacks.length; i < l; i++) { this._statements.push({ grouping: 'union', clause: 'union', value: callbacks[i], wrap: wrap || false }); } } else { callbacks = normalizeArr.apply(null, arguments).slice(0, arguments.length - 1); wrap = arguments[arguments.length - 1]; if (typeof wrap !== 'boolean') { callbacks.push(wrap); wrap = false; } this.union(callbacks, wrap); } return this; }
javascript
function union(callbacks, wrap) { if (arguments.length === 1 || arguments.length === 2 && typeof wrap === 'boolean') { if (!Array.isArray(callbacks)) { callbacks = [callbacks]; } for (var i = 0, l = callbacks.length; i < l; i++) { this._statements.push({ grouping: 'union', clause: 'union', value: callbacks[i], wrap: wrap || false }); } } else { callbacks = normalizeArr.apply(null, arguments).slice(0, arguments.length - 1); wrap = arguments[arguments.length - 1]; if (typeof wrap !== 'boolean') { callbacks.push(wrap); wrap = false; } this.union(callbacks, wrap); } return this; }
[ "function", "union", "(", "callbacks", ",", "wrap", ")", "{", "if", "(", "arguments", ".", "length", "===", "1", "||", "arguments", ".", "length", "===", "2", "&&", "typeof", "wrap", "===", "'boolean'", ")", "{", "if", "(", "!", "Array", ".", "isArray", "(", "callbacks", ")", ")", "{", "callbacks", "=", "[", "callbacks", "]", ";", "}", "for", "(", "var", "i", "=", "0", ",", "l", "=", "callbacks", ".", "length", ";", "i", "<", "l", ";", "i", "++", ")", "{", "this", ".", "_statements", ".", "push", "(", "{", "grouping", ":", "'union'", ",", "clause", ":", "'union'", ",", "value", ":", "callbacks", "[", "i", "]", ",", "wrap", ":", "wrap", "||", "false", "}", ")", ";", "}", "}", "else", "{", "callbacks", "=", "normalizeArr", ".", "apply", "(", "null", ",", "arguments", ")", ".", "slice", "(", "0", ",", "arguments", ".", "length", "-", "1", ")", ";", "wrap", "=", "arguments", "[", "arguments", ".", "length", "-", "1", "]", ";", "if", "(", "typeof", "wrap", "!==", "'boolean'", ")", "{", "callbacks", ".", "push", "(", "wrap", ")", ";", "wrap", "=", "false", ";", "}", "this", ".", "union", "(", "callbacks", ",", "wrap", ")", ";", "}", "return", "this", ";", "}" ]
Add a union statement to the query.
[ "Add", "a", "union", "statement", "to", "the", "query", "." ]
4cc624975d359800961bf34cb74de97488d2efb5
https://github.com/AppGeo/cartodb/blob/4cc624975d359800961bf34cb74de97488d2efb5/lib/builder.js#L450-L473
train
AppGeo/cartodb
lib/builder.js
unionAll
function unionAll(callback, wrap) { this._statements.push({ grouping: 'union', clause: 'union all', value: callback, wrap: wrap || false }); return this; }
javascript
function unionAll(callback, wrap) { this._statements.push({ grouping: 'union', clause: 'union all', value: callback, wrap: wrap || false }); return this; }
[ "function", "unionAll", "(", "callback", ",", "wrap", ")", "{", "this", ".", "_statements", ".", "push", "(", "{", "grouping", ":", "'union'", ",", "clause", ":", "'union all'", ",", "value", ":", "callback", ",", "wrap", ":", "wrap", "||", "false", "}", ")", ";", "return", "this", ";", "}" ]
Adds a union all statement to the query.
[ "Adds", "a", "union", "all", "statement", "to", "the", "query", "." ]
4cc624975d359800961bf34cb74de97488d2efb5
https://github.com/AppGeo/cartodb/blob/4cc624975d359800961bf34cb74de97488d2efb5/lib/builder.js#L476-L484
train
AppGeo/cartodb
lib/builder.js
having
function having(column, operator, value) { if (column instanceof Raw && arguments.length === 1) { return this._havingRaw(column); } // Check if the column is a function, in which case it's // a having statement wrapped in parens. if (typeof column === 'function') { return this.havingWrapped(column); } this._statements.push({ grouping: 'having', type: 'havingBasic', column: column, operator: operator, value: value, bool: this._bool() }); return this; }
javascript
function having(column, operator, value) { if (column instanceof Raw && arguments.length === 1) { return this._havingRaw(column); } // Check if the column is a function, in which case it's // a having statement wrapped in parens. if (typeof column === 'function') { return this.havingWrapped(column); } this._statements.push({ grouping: 'having', type: 'havingBasic', column: column, operator: operator, value: value, bool: this._bool() }); return this; }
[ "function", "having", "(", "column", ",", "operator", ",", "value", ")", "{", "if", "(", "column", "instanceof", "Raw", "&&", "arguments", ".", "length", "===", "1", ")", "{", "return", "this", ".", "_havingRaw", "(", "column", ")", ";", "}", "if", "(", "typeof", "column", "===", "'function'", ")", "{", "return", "this", ".", "havingWrapped", "(", "column", ")", ";", "}", "this", ".", "_statements", ".", "push", "(", "{", "grouping", ":", "'having'", ",", "type", ":", "'havingBasic'", ",", "column", ":", "column", ",", "operator", ":", "operator", ",", "value", ":", "value", ",", "bool", ":", "this", ".", "_bool", "(", ")", "}", ")", ";", "return", "this", ";", "}" ]
Adds a `having` clause to the query.
[ "Adds", "a", "having", "clause", "to", "the", "query", "." ]
4cc624975d359800961bf34cb74de97488d2efb5
https://github.com/AppGeo/cartodb/blob/4cc624975d359800961bf34cb74de97488d2efb5/lib/builder.js#L487-L507
train
AppGeo/cartodb
lib/builder.js
_havingRaw
function _havingRaw(sql, bindings) { var raw = sql instanceof Raw ? sql : this.client.raw(sql, bindings); this._statements.push({ grouping: 'having', type: 'havingRaw', value: raw, bool: this._bool() }); return this; }
javascript
function _havingRaw(sql, bindings) { var raw = sql instanceof Raw ? sql : this.client.raw(sql, bindings); this._statements.push({ grouping: 'having', type: 'havingRaw', value: raw, bool: this._bool() }); return this; }
[ "function", "_havingRaw", "(", "sql", ",", "bindings", ")", "{", "var", "raw", "=", "sql", "instanceof", "Raw", "?", "sql", ":", "this", ".", "client", ".", "raw", "(", "sql", ",", "bindings", ")", ";", "this", ".", "_statements", ".", "push", "(", "{", "grouping", ":", "'having'", ",", "type", ":", "'havingRaw'", ",", "value", ":", "raw", ",", "bool", ":", "this", ".", "_bool", "(", ")", "}", ")", ";", "return", "this", ";", "}" ]
Adds a raw `having` clause to the query.
[ "Adds", "a", "raw", "having", "clause", "to", "the", "query", "." ]
4cc624975d359800961bf34cb74de97488d2efb5
https://github.com/AppGeo/cartodb/blob/4cc624975d359800961bf34cb74de97488d2efb5/lib/builder.js#L519-L528
train
AppGeo/cartodb
lib/builder.js
limit
function limit(value) { var val = parseInt(value, 10); if (isNaN(val)) { debug('A valid integer must be provided to limit'); } else { this._single.limit = val; } return this; }
javascript
function limit(value) { var val = parseInt(value, 10); if (isNaN(val)) { debug('A valid integer must be provided to limit'); } else { this._single.limit = val; } return this; }
[ "function", "limit", "(", "value", ")", "{", "var", "val", "=", "parseInt", "(", "value", ",", "10", ")", ";", "if", "(", "isNaN", "(", "val", ")", ")", "{", "debug", "(", "'A valid integer must be provided to limit'", ")", ";", "}", "else", "{", "this", ".", "_single", ".", "limit", "=", "val", ";", "}", "return", "this", ";", "}" ]
Only allow a single "limit" to be set for the current query.
[ "Only", "allow", "a", "single", "limit", "to", "be", "set", "for", "the", "current", "query", "." ]
4cc624975d359800961bf34cb74de97488d2efb5
https://github.com/AppGeo/cartodb/blob/4cc624975d359800961bf34cb74de97488d2efb5/lib/builder.js#L537-L545
train
AppGeo/cartodb
lib/builder.js
pluck
function pluck(column) { this._method = 'pluck'; this._single.pluck = column; this._statements.push({ grouping: 'columns', type: 'pluck', value: column }); return this; }
javascript
function pluck(column) { this._method = 'pluck'; this._single.pluck = column; this._statements.push({ grouping: 'columns', type: 'pluck', value: column }); return this; }
[ "function", "pluck", "(", "column", ")", "{", "this", ".", "_method", "=", "'pluck'", ";", "this", ".", "_single", ".", "pluck", "=", "column", ";", "this", ".", "_statements", ".", "push", "(", "{", "grouping", ":", "'columns'", ",", "type", ":", "'pluck'", ",", "value", ":", "column", "}", ")", ";", "return", "this", ";", "}" ]
Pluck a column from a query.
[ "Pluck", "a", "column", "from", "a", "query", "." ]
4cc624975d359800961bf34cb74de97488d2efb5
https://github.com/AppGeo/cartodb/blob/4cc624975d359800961bf34cb74de97488d2efb5/lib/builder.js#L597-L606
train
AppGeo/cartodb
lib/builder.js
fromJS
function fromJS(obj) { Object.keys(obj).forEach(function (key) { var val = obj[key]; if (typeof this[key] !== 'function') { debug('Knex Error: unknown key ' + key); } if (Array.isArray(val)) { this[key].apply(this, val); } else { this[key](val); } }, this); return this; }
javascript
function fromJS(obj) { Object.keys(obj).forEach(function (key) { var val = obj[key]; if (typeof this[key] !== 'function') { debug('Knex Error: unknown key ' + key); } if (Array.isArray(val)) { this[key].apply(this, val); } else { this[key](val); } }, this); return this; }
[ "function", "fromJS", "(", "obj", ")", "{", "Object", ".", "keys", "(", "obj", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "var", "val", "=", "obj", "[", "key", "]", ";", "if", "(", "typeof", "this", "[", "key", "]", "!==", "'function'", ")", "{", "debug", "(", "'Knex Error: unknown key '", "+", "key", ")", ";", "}", "if", "(", "Array", ".", "isArray", "(", "val", ")", ")", "{", "this", "[", "key", "]", ".", "apply", "(", "this", ",", "val", ")", ";", "}", "else", "{", "this", "[", "key", "]", "(", "val", ")", ";", "}", "}", ",", "this", ")", ";", "return", "this", ";", "}" ]
Takes a JS object of methods to call and calls them
[ "Takes", "a", "JS", "object", "of", "methods", "to", "call", "and", "calls", "them" ]
4cc624975d359800961bf34cb74de97488d2efb5
https://github.com/AppGeo/cartodb/blob/4cc624975d359800961bf34cb74de97488d2efb5/lib/builder.js#L697-L710
train
AppGeo/cartodb
lib/builder.js
_bool
function _bool(val) { if (arguments.length === 1) { this._boolFlag = val; return this; } var ret = this._boolFlag; this._boolFlag = 'and'; return ret; }
javascript
function _bool(val) { if (arguments.length === 1) { this._boolFlag = val; return this; } var ret = this._boolFlag; this._boolFlag = 'and'; return ret; }
[ "function", "_bool", "(", "val", ")", "{", "if", "(", "arguments", ".", "length", "===", "1", ")", "{", "this", ".", "_boolFlag", "=", "val", ";", "return", "this", ";", "}", "var", "ret", "=", "this", ".", "_boolFlag", ";", "this", ".", "_boolFlag", "=", "'and'", ";", "return", "ret", ";", "}" ]
Helper to get or set the "boolFlag" value.
[ "Helper", "to", "get", "or", "set", "the", "boolFlag", "value", "." ]
4cc624975d359800961bf34cb74de97488d2efb5
https://github.com/AppGeo/cartodb/blob/4cc624975d359800961bf34cb74de97488d2efb5/lib/builder.js#L730-L738
train
AppGeo/cartodb
lib/builder.js
_not
function _not(val) { if (arguments.length === 1) { this._notFlag = val; return this; } var ret = this._notFlag; this._notFlag = false; return ret; }
javascript
function _not(val) { if (arguments.length === 1) { this._notFlag = val; return this; } var ret = this._notFlag; this._notFlag = false; return ret; }
[ "function", "_not", "(", "val", ")", "{", "if", "(", "arguments", ".", "length", "===", "1", ")", "{", "this", ".", "_notFlag", "=", "val", ";", "return", "this", ";", "}", "var", "ret", "=", "this", ".", "_notFlag", ";", "this", ".", "_notFlag", "=", "false", ";", "return", "ret", ";", "}" ]
Helper to get or set the "notFlag" value.
[ "Helper", "to", "get", "or", "set", "the", "notFlag", "value", "." ]
4cc624975d359800961bf34cb74de97488d2efb5
https://github.com/AppGeo/cartodb/blob/4cc624975d359800961bf34cb74de97488d2efb5/lib/builder.js#L741-L749
train
AppGeo/cartodb
lib/builder.js
_joinType
function _joinType(val) { if (arguments.length === 1) { this._joinFlag = val; return this; } var ret = this._joinFlag || 'inner'; this._joinFlag = 'inner'; return ret; }
javascript
function _joinType(val) { if (arguments.length === 1) { this._joinFlag = val; return this; } var ret = this._joinFlag || 'inner'; this._joinFlag = 'inner'; return ret; }
[ "function", "_joinType", "(", "val", ")", "{", "if", "(", "arguments", ".", "length", "===", "1", ")", "{", "this", ".", "_joinFlag", "=", "val", ";", "return", "this", ";", "}", "var", "ret", "=", "this", ".", "_joinFlag", "||", "'inner'", ";", "this", ".", "_joinFlag", "=", "'inner'", ";", "return", "ret", ";", "}" ]
Helper to get or set the "joinFlag" value.
[ "Helper", "to", "get", "or", "set", "the", "joinFlag", "value", "." ]
4cc624975d359800961bf34cb74de97488d2efb5
https://github.com/AppGeo/cartodb/blob/4cc624975d359800961bf34cb74de97488d2efb5/lib/builder.js#L752-L760
train
AppGeo/cartodb
lib/builder.js
_aggregate
function _aggregate(method, column) { this._statements.push({ grouping: 'columns', type: 'aggregate', method: method, value: column }); return this; }
javascript
function _aggregate(method, column) { this._statements.push({ grouping: 'columns', type: 'aggregate', method: method, value: column }); return this; }
[ "function", "_aggregate", "(", "method", ",", "column", ")", "{", "this", ".", "_statements", ".", "push", "(", "{", "grouping", ":", "'columns'", ",", "type", ":", "'aggregate'", ",", "method", ":", "method", ",", "value", ":", "column", "}", ")", ";", "return", "this", ";", "}" ]
Helper for compiling any aggregate queries.
[ "Helper", "for", "compiling", "any", "aggregate", "queries", "." ]
4cc624975d359800961bf34cb74de97488d2efb5
https://github.com/AppGeo/cartodb/blob/4cc624975d359800961bf34cb74de97488d2efb5/lib/builder.js#L763-L771
train
rootsdev/gedcomx-js
src/core/ExtensibleData.js
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof ExtensibleData)){ return new ExtensibleData(json); } // If the given object is already an instance then just return it. DON'T copy it. if(ExtensibleData.isInstance(json)){ return json; } this.init(json); }
javascript
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof ExtensibleData)){ return new ExtensibleData(json); } // If the given object is already an instance then just return it. DON'T copy it. if(ExtensibleData.isInstance(json)){ return json; } this.init(json); }
[ "function", "(", "json", ")", "{", "if", "(", "!", "(", "this", "instanceof", "ExtensibleData", ")", ")", "{", "return", "new", "ExtensibleData", "(", "json", ")", ";", "}", "if", "(", "ExtensibleData", ".", "isInstance", "(", "json", ")", ")", "{", "return", "json", ";", "}", "this", ".", "init", "(", "json", ")", ";", "}" ]
A set of data that supports extension elements. @class @extends Base @param {Object} [json]
[ "A", "set", "of", "data", "that", "supports", "extension", "elements", "." ]
08b2fcde96f1e301c78561bfb7a8b0cac606e26e
https://github.com/rootsdev/gedcomx-js/blob/08b2fcde96f1e301c78561bfb7a8b0cac606e26e/src/core/ExtensibleData.js#L11-L24
train
anvilresearch/connect-keys
index.js
generateKeyPairs
function generateKeyPairs () { AnvilConnectKeys.generateKeyPair(this.sig.pub, this.sig.prv) AnvilConnectKeys.generateKeyPair(this.enc.pub, this.enc.prv) }
javascript
function generateKeyPairs () { AnvilConnectKeys.generateKeyPair(this.sig.pub, this.sig.prv) AnvilConnectKeys.generateKeyPair(this.enc.pub, this.enc.prv) }
[ "function", "generateKeyPairs", "(", ")", "{", "AnvilConnectKeys", ".", "generateKeyPair", "(", "this", ".", "sig", ".", "pub", ",", "this", ".", "sig", ".", "prv", ")", "AnvilConnectKeys", ".", "generateKeyPair", "(", "this", ".", "enc", ".", "pub", ",", "this", ".", "enc", ".", "prv", ")", "}" ]
Generate key pairs
[ "Generate", "key", "pairs" ]
45c7b4c7092cd37e92300add6951a8b1d74f3033
https://github.com/anvilresearch/connect-keys/blob/45c7b4c7092cd37e92300add6951a8b1d74f3033/index.js#L42-L45
train
anvilresearch/connect-keys
index.js
generateKeyPair
function generateKeyPair (pub, prv) { try { mkdirp.sync(path.dirname(pub)) mkdirp.sync(path.dirname(prv)) childProcess.execFileSync('openssl', [ 'genrsa', '-out', prv, '4096' ], { stdio: 'ignore' }) childProcess.execFileSync('openssl', [ 'rsa', '-pubout', '-in', prv, '-out', pub ], { stdio: 'ignore' }) } catch (e) { throw new Error( 'Failed to generate keys using OpenSSL. Please ensure you have OpenSSL ' + 'installed and configured on your system.' ) } }
javascript
function generateKeyPair (pub, prv) { try { mkdirp.sync(path.dirname(pub)) mkdirp.sync(path.dirname(prv)) childProcess.execFileSync('openssl', [ 'genrsa', '-out', prv, '4096' ], { stdio: 'ignore' }) childProcess.execFileSync('openssl', [ 'rsa', '-pubout', '-in', prv, '-out', pub ], { stdio: 'ignore' }) } catch (e) { throw new Error( 'Failed to generate keys using OpenSSL. Please ensure you have OpenSSL ' + 'installed and configured on your system.' ) } }
[ "function", "generateKeyPair", "(", "pub", ",", "prv", ")", "{", "try", "{", "mkdirp", ".", "sync", "(", "path", ".", "dirname", "(", "pub", ")", ")", "mkdirp", ".", "sync", "(", "path", ".", "dirname", "(", "prv", ")", ")", "childProcess", ".", "execFileSync", "(", "'openssl'", ",", "[", "'genrsa'", ",", "'-out'", ",", "prv", ",", "'4096'", "]", ",", "{", "stdio", ":", "'ignore'", "}", ")", "childProcess", ".", "execFileSync", "(", "'openssl'", ",", "[", "'rsa'", ",", "'-pubout'", ",", "'-in'", ",", "prv", ",", "'-out'", ",", "pub", "]", ",", "{", "stdio", ":", "'ignore'", "}", ")", "}", "catch", "(", "e", ")", "{", "throw", "new", "Error", "(", "'Failed to generate keys using OpenSSL. Please ensure you have OpenSSL '", "+", "'installed and configured on your system.'", ")", "}", "}" ]
Generate single key pair
[ "Generate", "single", "key", "pair" ]
45c7b4c7092cd37e92300add6951a8b1d74f3033
https://github.com/anvilresearch/connect-keys/blob/45c7b4c7092cd37e92300add6951a8b1d74f3033/index.js#L53-L83
train
anvilresearch/connect-keys
index.js
loadKeyPairs
function loadKeyPairs () { var sig = AnvilConnectKeys.loadKeyPair(this.sig.pub, this.sig.prv, 'sig') var enc = AnvilConnectKeys.loadKeyPair(this.enc.pub, this.enc.prv, 'enc') var jwkKeys = [] jwkKeys.push(sig.jwk.pub, enc.jwk.pub) return { sig: sig.pem, enc: enc.pem, jwks: { keys: jwkKeys } } }
javascript
function loadKeyPairs () { var sig = AnvilConnectKeys.loadKeyPair(this.sig.pub, this.sig.prv, 'sig') var enc = AnvilConnectKeys.loadKeyPair(this.enc.pub, this.enc.prv, 'enc') var jwkKeys = [] jwkKeys.push(sig.jwk.pub, enc.jwk.pub) return { sig: sig.pem, enc: enc.pem, jwks: { keys: jwkKeys } } }
[ "function", "loadKeyPairs", "(", ")", "{", "var", "sig", "=", "AnvilConnectKeys", ".", "loadKeyPair", "(", "this", ".", "sig", ".", "pub", ",", "this", ".", "sig", ".", "prv", ",", "'sig'", ")", "var", "enc", "=", "AnvilConnectKeys", ".", "loadKeyPair", "(", "this", ".", "enc", ".", "pub", ",", "this", ".", "enc", ".", "prv", ",", "'enc'", ")", "var", "jwkKeys", "=", "[", "]", "jwkKeys", ".", "push", "(", "sig", ".", "jwk", ".", "pub", ",", "enc", ".", "jwk", ".", "pub", ")", "return", "{", "sig", ":", "sig", ".", "pem", ",", "enc", ":", "enc", ".", "pem", ",", "jwks", ":", "{", "keys", ":", "jwkKeys", "}", "}", "}" ]
Load key pairs
[ "Load", "key", "pairs" ]
45c7b4c7092cd37e92300add6951a8b1d74f3033
https://github.com/anvilresearch/connect-keys/blob/45c7b4c7092cd37e92300add6951a8b1d74f3033/index.js#L91-L105
train
anvilresearch/connect-keys
index.js
loadKeyPair
function loadKeyPair (pub, prv, use) { var pubPEM, prvPEM, pubJWK try { pubPEM = fs.readFileSync(pub).toString('ascii') } catch (e) { throw new Error('Unable to read the public key from ' + pub) } try { prvPEM = fs.readFileSync(prv).toString('ascii') } catch (e) { throw new Error('Unable to read the private key from ' + pub) } try { pubJWK = pemjwk.pem2jwk(pubPEM) } catch (e) { throw new Error('Unable to convert the public key ' + pub + ' to a JWK') } return { pem: { pub: pubPEM, prv: prvPEM }, jwk: { pub: { kty: pubJWK.kty, use: use, alg: 'RS256', n: pubJWK.n, e: pubJWK.e } } } }
javascript
function loadKeyPair (pub, prv, use) { var pubPEM, prvPEM, pubJWK try { pubPEM = fs.readFileSync(pub).toString('ascii') } catch (e) { throw new Error('Unable to read the public key from ' + pub) } try { prvPEM = fs.readFileSync(prv).toString('ascii') } catch (e) { throw new Error('Unable to read the private key from ' + pub) } try { pubJWK = pemjwk.pem2jwk(pubPEM) } catch (e) { throw new Error('Unable to convert the public key ' + pub + ' to a JWK') } return { pem: { pub: pubPEM, prv: prvPEM }, jwk: { pub: { kty: pubJWK.kty, use: use, alg: 'RS256', n: pubJWK.n, e: pubJWK.e } } } }
[ "function", "loadKeyPair", "(", "pub", ",", "prv", ",", "use", ")", "{", "var", "pubPEM", ",", "prvPEM", ",", "pubJWK", "try", "{", "pubPEM", "=", "fs", ".", "readFileSync", "(", "pub", ")", ".", "toString", "(", "'ascii'", ")", "}", "catch", "(", "e", ")", "{", "throw", "new", "Error", "(", "'Unable to read the public key from '", "+", "pub", ")", "}", "try", "{", "prvPEM", "=", "fs", ".", "readFileSync", "(", "prv", ")", ".", "toString", "(", "'ascii'", ")", "}", "catch", "(", "e", ")", "{", "throw", "new", "Error", "(", "'Unable to read the private key from '", "+", "pub", ")", "}", "try", "{", "pubJWK", "=", "pemjwk", ".", "pem2jwk", "(", "pubPEM", ")", "}", "catch", "(", "e", ")", "{", "throw", "new", "Error", "(", "'Unable to convert the public key '", "+", "pub", "+", "' to a JWK'", ")", "}", "return", "{", "pem", ":", "{", "pub", ":", "pubPEM", ",", "prv", ":", "prvPEM", "}", ",", "jwk", ":", "{", "pub", ":", "{", "kty", ":", "pubJWK", ".", "kty", ",", "use", ":", "use", ",", "alg", ":", "'RS256'", ",", "n", ":", "pubJWK", ".", "n", ",", "e", ":", "pubJWK", ".", "e", "}", "}", "}", "}" ]
Load single key pair
[ "Load", "single", "key", "pair" ]
45c7b4c7092cd37e92300add6951a8b1d74f3033
https://github.com/anvilresearch/connect-keys/blob/45c7b4c7092cd37e92300add6951a8b1d74f3033/index.js#L113-L149
train
anvilresearch/connect-keys
index.js
generateSetupToken
function generateSetupToken (tokenPath) { mkdirp.sync(path.dirname(tokenPath)) var token = crypto.randomBytes(256).toString('hex') try { fs.writeFileSync(tokenPath, token, 'utf8') } catch (e) { throw new Error('Unable to save setup token to ' + tokenPath) } return token }
javascript
function generateSetupToken (tokenPath) { mkdirp.sync(path.dirname(tokenPath)) var token = crypto.randomBytes(256).toString('hex') try { fs.writeFileSync(tokenPath, token, 'utf8') } catch (e) { throw new Error('Unable to save setup token to ' + tokenPath) } return token }
[ "function", "generateSetupToken", "(", "tokenPath", ")", "{", "mkdirp", ".", "sync", "(", "path", ".", "dirname", "(", "tokenPath", ")", ")", "var", "token", "=", "crypto", ".", "randomBytes", "(", "256", ")", ".", "toString", "(", "'hex'", ")", "try", "{", "fs", ".", "writeFileSync", "(", "tokenPath", ",", "token", ",", "'utf8'", ")", "}", "catch", "(", "e", ")", "{", "throw", "new", "Error", "(", "'Unable to save setup token to '", "+", "tokenPath", ")", "}", "return", "token", "}" ]
Generate setup token
[ "Generate", "setup", "token" ]
45c7b4c7092cd37e92300add6951a8b1d74f3033
https://github.com/anvilresearch/connect-keys/blob/45c7b4c7092cd37e92300add6951a8b1d74f3033/index.js#L157-L167
train
benderjs/benderjs-coverage
lib/middleware.js
Transformer
function Transformer( file, res ) { stream.Transform.call( this ); this.file = file; this.res = res; this.chunks = []; }
javascript
function Transformer( file, res ) { stream.Transform.call( this ); this.file = file; this.res = res; this.chunks = []; }
[ "function", "Transformer", "(", "file", ",", "res", ")", "{", "stream", ".", "Transform", ".", "call", "(", "this", ")", ";", "this", ".", "file", "=", "file", ";", "this", ".", "res", "=", "res", ";", "this", ".", "chunks", "=", "[", "]", ";", "}" ]
Transofrms the code from an incomming stream and outputs the code instrumented by Istanbul @param {String} file File name used by Istanbul @param {Object} res HTTP response
[ "Transofrms", "the", "code", "from", "an", "incomming", "stream", "and", "outputs", "the", "code", "instrumented", "by", "Istanbul" ]
37099604257d7acf6dae57c425095cd884205a1f
https://github.com/benderjs/benderjs-coverage/blob/37099604257d7acf6dae57c425095cd884205a1f/lib/middleware.js#L27-L33
train
nomocas/kroked
lib/utils.js
function(src, skipBlanck) { var tokens = [], cells, cap; while (src) { cells = []; while (cap = cellDelimitter.exec(src)) { src = src.substring(cap[0].length); cells.push(cap[1]); } if (cells.length || !skipBlanck) tokens.push(cells); // src should start now with \n or \r src = src.substring(1); } return tokens; }
javascript
function(src, skipBlanck) { var tokens = [], cells, cap; while (src) { cells = []; while (cap = cellDelimitter.exec(src)) { src = src.substring(cap[0].length); cells.push(cap[1]); } if (cells.length || !skipBlanck) tokens.push(cells); // src should start now with \n or \r src = src.substring(1); } return tokens; }
[ "function", "(", "src", ",", "skipBlanck", ")", "{", "var", "tokens", "=", "[", "]", ",", "cells", ",", "cap", ";", "while", "(", "src", ")", "{", "cells", "=", "[", "]", ";", "while", "(", "cap", "=", "cellDelimitter", ".", "exec", "(", "src", ")", ")", "{", "src", "=", "src", ".", "substring", "(", "cap", "[", "0", "]", ".", "length", ")", ";", "cells", ".", "push", "(", "cap", "[", "1", "]", ")", ";", "}", "if", "(", "cells", ".", "length", "||", "!", "skipBlanck", ")", "tokens", ".", "push", "(", "cells", ")", ";", "src", "=", "src", ".", "substring", "(", "1", ")", ";", "}", "return", "tokens", ";", "}" ]
Parse tab delimitted lines from string. usefull for raw macros and table like widgets rendering. @param {String} src the content block to parse until the end. @param {Boolean} skipBlanck optional. if true, skip blank lines. @return {Array} Parsed lines. Array of cells array. i.e. lines[2][3] gives you third cell of second line.
[ "Parse", "tab", "delimitted", "lines", "from", "string", ".", "usefull", "for", "raw", "macros", "and", "table", "like", "widgets", "rendering", "." ]
1d6baf62df437c0b4ab242be7b8915fa66c2cdb8
https://github.com/nomocas/kroked/blob/1d6baf62df437c0b4ab242be7b8915fa66c2cdb8/lib/utils.js#L33-L48
train
lionel-rigoux/pandemic
lib/load-instructions.js
defaultInstructions
function defaultInstructions (format) { // start with empty instructions let instructions = emptyInstructions('_defaults', format); // extend with the default recipe, if it exists for the target extension const recipeFilePath = path.join( __dirname, '..', '_defaults', `recipe.${format}.json` ); if (fs.existsSync(recipeFilePath)) { instructions = Object.assign( instructions, JSON.parse(fs.readFileSync(recipeFilePath, 'utf8')) ); } return instructions; }
javascript
function defaultInstructions (format) { // start with empty instructions let instructions = emptyInstructions('_defaults', format); // extend with the default recipe, if it exists for the target extension const recipeFilePath = path.join( __dirname, '..', '_defaults', `recipe.${format}.json` ); if (fs.existsSync(recipeFilePath)) { instructions = Object.assign( instructions, JSON.parse(fs.readFileSync(recipeFilePath, 'utf8')) ); } return instructions; }
[ "function", "defaultInstructions", "(", "format", ")", "{", "let", "instructions", "=", "emptyInstructions", "(", "'_defaults'", ",", "format", ")", ";", "const", "recipeFilePath", "=", "path", ".", "join", "(", "__dirname", ",", "'..'", ",", "'_defaults'", ",", "`", "${", "format", "}", "`", ")", ";", "if", "(", "fs", ".", "existsSync", "(", "recipeFilePath", ")", ")", "{", "instructions", "=", "Object", ".", "assign", "(", "instructions", ",", "JSON", ".", "parse", "(", "fs", ".", "readFileSync", "(", "recipeFilePath", ",", "'utf8'", ")", ")", ")", ";", "}", "return", "instructions", ";", "}" ]
default recipe instruction
[ "default", "recipe", "instruction" ]
133b2445ea4981f64012f6af4e6210a18981d46e
https://github.com/lionel-rigoux/pandemic/blob/133b2445ea4981f64012f6af4e6210a18981d46e/lib/load-instructions.js#L28-L46
train
lionel-rigoux/pandemic
lib/load-instructions.js
isTemplate
function isTemplate (file, format) { const { prefix, ext } = splitFormat(format); return formatMap[ext] .map(e => (prefix.length ? '.' : '') + prefix + e) .some(e => file.endsWith(e)); }
javascript
function isTemplate (file, format) { const { prefix, ext } = splitFormat(format); return formatMap[ext] .map(e => (prefix.length ? '.' : '') + prefix + e) .some(e => file.endsWith(e)); }
[ "function", "isTemplate", "(", "file", ",", "format", ")", "{", "const", "{", "prefix", ",", "ext", "}", "=", "splitFormat", "(", "format", ")", ";", "return", "formatMap", "[", "ext", "]", ".", "map", "(", "e", "=>", "(", "prefix", ".", "length", "?", "'.'", ":", "''", ")", "+", "prefix", "+", "e", ")", ".", "some", "(", "e", "=>", "file", ".", "endsWith", "(", "e", ")", ")", ";", "}" ]
test if a given file could serve as a template for the format
[ "test", "if", "a", "given", "file", "could", "serve", "as", "a", "template", "for", "the", "format" ]
133b2445ea4981f64012f6af4e6210a18981d46e
https://github.com/lionel-rigoux/pandemic/blob/133b2445ea4981f64012f6af4e6210a18981d46e/lib/load-instructions.js#L49-L54
train
ningsuhen/passport-linkedin-token
lib/passport-linkedin-token/strategy.js
LinkedInTokenStrategy
function LinkedInTokenStrategy(options, verify) { options = options || {}; options.requestTokenURL = options.requestTokenURL || 'https://api.linkedin.com/uas/oauth/requestToken'; options.accessTokenURL = options.accessTokenURL || 'https://api.linkedin.com/uas/oauth/accessToken'; options.userAuthorizationURL = options.userAuthorizationURL || 'https://www.linkedin.com/uas/oauth/authenticate'; options.sessionKey = options.sessionKey || 'oauth:linkedin'; OAuthStrategy.call(this, options, verify); this.name = 'linkedin-token'; this._profileFields = options.profileFields; this._skipExtendedUserProfile = (options.skipExtendedUserProfile === undefined) ? false : options.skipExtendedUserProfile; }
javascript
function LinkedInTokenStrategy(options, verify) { options = options || {}; options.requestTokenURL = options.requestTokenURL || 'https://api.linkedin.com/uas/oauth/requestToken'; options.accessTokenURL = options.accessTokenURL || 'https://api.linkedin.com/uas/oauth/accessToken'; options.userAuthorizationURL = options.userAuthorizationURL || 'https://www.linkedin.com/uas/oauth/authenticate'; options.sessionKey = options.sessionKey || 'oauth:linkedin'; OAuthStrategy.call(this, options, verify); this.name = 'linkedin-token'; this._profileFields = options.profileFields; this._skipExtendedUserProfile = (options.skipExtendedUserProfile === undefined) ? false : options.skipExtendedUserProfile; }
[ "function", "LinkedInTokenStrategy", "(", "options", ",", "verify", ")", "{", "options", "=", "options", "||", "{", "}", ";", "options", ".", "requestTokenURL", "=", "options", ".", "requestTokenURL", "||", "'https://api.linkedin.com/uas/oauth/requestToken'", ";", "options", ".", "accessTokenURL", "=", "options", ".", "accessTokenURL", "||", "'https://api.linkedin.com/uas/oauth/accessToken'", ";", "options", ".", "userAuthorizationURL", "=", "options", ".", "userAuthorizationURL", "||", "'https://www.linkedin.com/uas/oauth/authenticate'", ";", "options", ".", "sessionKey", "=", "options", ".", "sessionKey", "||", "'oauth:linkedin'", ";", "OAuthStrategy", ".", "call", "(", "this", ",", "options", ",", "verify", ")", ";", "this", ".", "name", "=", "'linkedin-token'", ";", "this", ".", "_profileFields", "=", "options", ".", "profileFields", ";", "this", ".", "_skipExtendedUserProfile", "=", "(", "options", ".", "skipExtendedUserProfile", "===", "undefined", ")", "?", "false", ":", "options", ".", "skipExtendedUserProfile", ";", "}" ]
`LinkedInTokenStrategy` constructor. The LinkedIn authentication strategy authenticates requests by delegating to LinkedIn using the OAuth protocol. Applications must supply a `verify` callback which accepts a `token`, `tokenSecret` and service-specific `profile`, and then calls the `done` callback supplying a `user`, which should be set to `false` if the credentials are not valid. If an exception occured, `err` should be set. Options: - `consumerKey` identifies client to LinkedIn - `consumerSecret` secret used to establish ownership of the consumer key Examples: passport.use(new LinkedInTokenStrategy({ consumerKey: '123-456-789', consumerSecret: 'shhh-its-a-secret' }, function(token, tokenSecret, profile, done) { User.findOrCreate(..., function (err, user) { done(err, user); }); } )); @param {Object} options @param {Function} verify @api public
[ "LinkedInTokenStrategy", "constructor", "." ]
da9e364abcaafca674d1a605101912844d46bde3
https://github.com/ningsuhen/passport-linkedin-token/blob/da9e364abcaafca674d1a605101912844d46bde3/lib/passport-linkedin-token/strategy.js#L41-L53
train
rootsdev/gedcomx-js
src/core/PlaceDescription.js
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof PlaceDescription)){ return new PlaceDescription(json); } // If the given object is already an instance then just return it. DON'T copy it. if(PlaceDescription.isInstance(json)){ return json; } this.init(json); }
javascript
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof PlaceDescription)){ return new PlaceDescription(json); } // If the given object is already an instance then just return it. DON'T copy it. if(PlaceDescription.isInstance(json)){ return json; } this.init(json); }
[ "function", "(", "json", ")", "{", "if", "(", "!", "(", "this", "instanceof", "PlaceDescription", ")", ")", "{", "return", "new", "PlaceDescription", "(", "json", ")", ";", "}", "if", "(", "PlaceDescription", ".", "isInstance", "(", "json", ")", ")", "{", "return", "json", ";", "}", "this", ".", "init", "(", "json", ")", ";", "}" ]
A description of a place @see {@link https://github.com/FamilySearch/gedcomx/blob/master/specifications/json-format-specification.md#place-description|GEDCOM X JSON Spec} @class @extends Subject @param {Object} [json]
[ "A", "description", "of", "a", "place" ]
08b2fcde96f1e301c78561bfb7a8b0cac606e26e
https://github.com/rootsdev/gedcomx-js/blob/08b2fcde96f1e301c78561bfb7a8b0cac606e26e/src/core/PlaceDescription.js#L13-L26
train
reworkcss/rework-import
index.js
createImportError
function createImportError(rule) { var url = rule.import ? rule.import.replace(/\r?\n/g, '\\n') : '<no url>'; var err = ['Bad import url: @import ' + url]; if (rule.position) { err.push(' starting at line ' + rule.position.start.line + ' column ' + rule.position.start.column); err.push(' ending at line ' + rule.position.end.line + ' column ' + rule.position.end.column); if (rule.position.source) { err.push(' in ' + rule.position.source); } } return err.join('\n'); }
javascript
function createImportError(rule) { var url = rule.import ? rule.import.replace(/\r?\n/g, '\\n') : '<no url>'; var err = ['Bad import url: @import ' + url]; if (rule.position) { err.push(' starting at line ' + rule.position.start.line + ' column ' + rule.position.start.column); err.push(' ending at line ' + rule.position.end.line + ' column ' + rule.position.end.column); if (rule.position.source) { err.push(' in ' + rule.position.source); } } return err.join('\n'); }
[ "function", "createImportError", "(", "rule", ")", "{", "var", "url", "=", "rule", ".", "import", "?", "rule", ".", "import", ".", "replace", "(", "/", "\\r?\\n", "/", "g", ",", "'\\\\n'", ")", ":", "\\\\", ";", "'<no url>'", "var", "err", "=", "[", "'Bad import url: @import '", "+", "url", "]", ";", "if", "(", "rule", ".", "position", ")", "{", "err", ".", "push", "(", "' starting at line '", "+", "rule", ".", "position", ".", "start", ".", "line", "+", "' column '", "+", "rule", ".", "position", ".", "start", ".", "column", ")", ";", "err", ".", "push", "(", "' ending at line '", "+", "rule", ".", "position", ".", "end", ".", "line", "+", "' column '", "+", "rule", ".", "position", ".", "end", ".", "column", ")", ";", "if", "(", "rule", ".", "position", ".", "source", ")", "{", "err", ".", "push", "(", "' in '", "+", "rule", ".", "position", ".", "source", ")", ";", "}", "}", "}" ]
Create bad import rule error @param {String} rule @api private
[ "Create", "bad", "import", "rule", "error" ]
071a715124c7b10eeb1c298a72b7fc106a4bb8f0
https://github.com/reworkcss/rework-import/blob/071a715124c7b10eeb1c298a72b7fc106a4bb8f0/index.js#L76-L90
train
reworkcss/rework-import
index.js
read
function read(file, opts) { var encoding = opts.encoding || 'utf8'; var data = opts.transform(fs.readFileSync(file, encoding)); return css.parse(data, {source: file}).stylesheet; }
javascript
function read(file, opts) { var encoding = opts.encoding || 'utf8'; var data = opts.transform(fs.readFileSync(file, encoding)); return css.parse(data, {source: file}).stylesheet; }
[ "function", "read", "(", "file", ",", "opts", ")", "{", "var", "encoding", "=", "opts", ".", "encoding", "||", "'utf8'", ";", "var", "data", "=", "opts", ".", "transform", "(", "fs", ".", "readFileSync", "(", "file", ",", "encoding", ")", ")", ";", "return", "css", ".", "parse", "(", "data", ",", "{", "source", ":", "file", "}", ")", ".", "stylesheet", ";", "}" ]
Read the contents of a file @param {String} file @param {Object} opts @api private
[ "Read", "the", "contents", "of", "a", "file" ]
071a715124c7b10eeb1c298a72b7fc106a4bb8f0
https://github.com/reworkcss/rework-import/blob/071a715124c7b10eeb1c298a72b7fc106a4bb8f0/index.js#L123-L127
train
WRidder/backgrid-advanced-filter
src/filter-collection.js
function (attributes, options) { var AttrCollection = Backgrid.Extension.AdvancedFilter.AttributeFilterCollection; if (attributes.attributeFilters !== undefined && !(attributes.attributeFilters instanceof AttrCollection)) { attributes.attributeFilters = new AttrCollection(attributes.attributeFilters); } return Backbone.Model.prototype.set.call(this, attributes, options); }
javascript
function (attributes, options) { var AttrCollection = Backgrid.Extension.AdvancedFilter.AttributeFilterCollection; if (attributes.attributeFilters !== undefined && !(attributes.attributeFilters instanceof AttrCollection)) { attributes.attributeFilters = new AttrCollection(attributes.attributeFilters); } return Backbone.Model.prototype.set.call(this, attributes, options); }
[ "function", "(", "attributes", ",", "options", ")", "{", "var", "AttrCollection", "=", "Backgrid", ".", "Extension", ".", "AdvancedFilter", ".", "AttributeFilterCollection", ";", "if", "(", "attributes", ".", "attributeFilters", "!==", "undefined", "&&", "!", "(", "attributes", ".", "attributeFilters", "instanceof", "AttrCollection", ")", ")", "{", "attributes", ".", "attributeFilters", "=", "new", "AttrCollection", "(", "attributes", ".", "attributeFilters", ")", ";", "}", "return", "Backbone", ".", "Model", ".", "prototype", ".", "set", ".", "call", "(", "this", ",", "attributes", ",", "options", ")", ";", "}" ]
Set override Makes sure the attributeFilters are set as a collection. @method set @param {Object} attributes @param {Object} options @return {*}
[ "Set", "override", "Makes", "sure", "the", "attributeFilters", "are", "set", "as", "a", "collection", "." ]
5b10216f091d0e4bad418398fb4ec4c4588f4475
https://github.com/WRidder/backgrid-advanced-filter/blob/5b10216f091d0e4bad418398fb4ec4c4588f4475/src/filter-collection.js#L238-L244
train
WRidder/backgrid-advanced-filter
src/filter-collection.js
function (style, exportAsString) { var self = this; var result; switch (style) { case "mongo": case "mongodb": default: var mongoParser = new Backgrid.Extension.AdvancedFilter.FilterParsers.MongoParser(); result = mongoParser.parse(self); if (exportAsString) { result = self.stringifyFilterJson(result); } } return result; }
javascript
function (style, exportAsString) { var self = this; var result; switch (style) { case "mongo": case "mongodb": default: var mongoParser = new Backgrid.Extension.AdvancedFilter.FilterParsers.MongoParser(); result = mongoParser.parse(self); if (exportAsString) { result = self.stringifyFilterJson(result); } } return result; }
[ "function", "(", "style", ",", "exportAsString", ")", "{", "var", "self", "=", "this", ";", "var", "result", ";", "switch", "(", "style", ")", "{", "case", "\"mongo\"", ":", "case", "\"mongodb\"", ":", "default", ":", "var", "mongoParser", "=", "new", "Backgrid", ".", "Extension", ".", "AdvancedFilter", ".", "FilterParsers", ".", "MongoParser", "(", ")", ";", "result", "=", "mongoParser", ".", "parse", "(", "self", ")", ";", "if", "(", "exportAsString", ")", "{", "result", "=", "self", ".", "stringifyFilterJson", "(", "result", ")", ";", "}", "}", "return", "result", ";", "}" ]
Export the filter for a given style @method exportFilter @param {String} style. Values: "(mongo|mongodb), ..." @param {boolean} exportAsString exports as a string if true. @return {Object}
[ "Export", "the", "filter", "for", "a", "given", "style" ]
5b10216f091d0e4bad418398fb4ec4c4588f4475
https://github.com/WRidder/backgrid-advanced-filter/blob/5b10216f091d0e4bad418398fb4ec4c4588f4475/src/filter-collection.js#L253-L269
train
WRidder/backgrid-advanced-filter
src/filter-collection.js
function() { var self = this; self.newFilterCount += 1; if (self.length === 0) { return self.newFilterCount; } else { var newFilterName = self.newFilterName.replace(self.filterNamePartial, ""); var results = self.filter(function(fm) { return fm.get("name").indexOf(newFilterName) === 0; }).map(function(fm) { return fm.get("name"); }); if (_.isArray(results) && results.length > 0) { // Sort results results.sort(); // Get highest count var highestCount = parseInt(results[results.length - 1].replace(newFilterName, "")); if (_.isNaN(highestCount)) { highestCount = self.newFilterCount; } else { highestCount += 1; } } else { highestCount = self.newFilterCount; } return highestCount; } }
javascript
function() { var self = this; self.newFilterCount += 1; if (self.length === 0) { return self.newFilterCount; } else { var newFilterName = self.newFilterName.replace(self.filterNamePartial, ""); var results = self.filter(function(fm) { return fm.get("name").indexOf(newFilterName) === 0; }).map(function(fm) { return fm.get("name"); }); if (_.isArray(results) && results.length > 0) { // Sort results results.sort(); // Get highest count var highestCount = parseInt(results[results.length - 1].replace(newFilterName, "")); if (_.isNaN(highestCount)) { highestCount = self.newFilterCount; } else { highestCount += 1; } } else { highestCount = self.newFilterCount; } return highestCount; } }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "self", ".", "newFilterCount", "+=", "1", ";", "if", "(", "self", ".", "length", "===", "0", ")", "{", "return", "self", ".", "newFilterCount", ";", "}", "else", "{", "var", "newFilterName", "=", "self", ".", "newFilterName", ".", "replace", "(", "self", ".", "filterNamePartial", ",", "\"\"", ")", ";", "var", "results", "=", "self", ".", "filter", "(", "function", "(", "fm", ")", "{", "return", "fm", ".", "get", "(", "\"name\"", ")", ".", "indexOf", "(", "newFilterName", ")", "===", "0", ";", "}", ")", ".", "map", "(", "function", "(", "fm", ")", "{", "return", "fm", ".", "get", "(", "\"name\"", ")", ";", "}", ")", ";", "if", "(", "_", ".", "isArray", "(", "results", ")", "&&", "results", ".", "length", ">", "0", ")", "{", "results", ".", "sort", "(", ")", ";", "var", "highestCount", "=", "parseInt", "(", "results", "[", "results", ".", "length", "-", "1", "]", ".", "replace", "(", "newFilterName", ",", "\"\"", ")", ")", ";", "if", "(", "_", ".", "isNaN", "(", "highestCount", ")", ")", "{", "highestCount", "=", "self", ".", "newFilterCount", ";", "}", "else", "{", "highestCount", "+=", "1", ";", "}", "}", "else", "{", "highestCount", "=", "self", ".", "newFilterCount", ";", "}", "return", "highestCount", ";", "}", "}" ]
Retrieves a new filter number. @method getNewFilterNumber @return {int} @private
[ "Retrieves", "a", "new", "filter", "number", "." ]
5b10216f091d0e4bad418398fb4ec4c4588f4475
https://github.com/WRidder/backgrid-advanced-filter/blob/5b10216f091d0e4bad418398fb4ec4c4588f4475/src/filter-collection.js#L332-L366
train
furf/vineapple
lib/vineapple.js
function (username, password, callback) { var request; var promise; // Preemptively validate username and password if (!username) { throw new Error('Invalid credentials. Missing username.'); } if (!password) { throw new Error('Invalid credentials. Missing password.'); } // Execute the API request for authentication request = this.request({ method: 'post', url: 'users/authenticate', form: { deviceToken: Vineapple.DEVICE_TOKEN || createDeviceToken([ Vineapple.DEVICE_TOKEN_SEED, username, password ].join(':')), username: username, password: password } }); promise = request.then(this.authorize.bind(this)); if (callback) { promise.then(callback.bind(null, null)).fail(callback); } return promise; }
javascript
function (username, password, callback) { var request; var promise; // Preemptively validate username and password if (!username) { throw new Error('Invalid credentials. Missing username.'); } if (!password) { throw new Error('Invalid credentials. Missing password.'); } // Execute the API request for authentication request = this.request({ method: 'post', url: 'users/authenticate', form: { deviceToken: Vineapple.DEVICE_TOKEN || createDeviceToken([ Vineapple.DEVICE_TOKEN_SEED, username, password ].join(':')), username: username, password: password } }); promise = request.then(this.authorize.bind(this)); if (callback) { promise.then(callback.bind(null, null)).fail(callback); } return promise; }
[ "function", "(", "username", ",", "password", ",", "callback", ")", "{", "var", "request", ";", "var", "promise", ";", "if", "(", "!", "username", ")", "{", "throw", "new", "Error", "(", "'Invalid credentials. Missing username.'", ")", ";", "}", "if", "(", "!", "password", ")", "{", "throw", "new", "Error", "(", "'Invalid credentials. Missing password.'", ")", ";", "}", "request", "=", "this", ".", "request", "(", "{", "method", ":", "'post'", ",", "url", ":", "'users/authenticate'", ",", "form", ":", "{", "deviceToken", ":", "Vineapple", ".", "DEVICE_TOKEN", "||", "createDeviceToken", "(", "[", "Vineapple", ".", "DEVICE_TOKEN_SEED", ",", "username", ",", "password", "]", ".", "join", "(", "':'", ")", ")", ",", "username", ":", "username", ",", "password", ":", "password", "}", "}", ")", ";", "promise", "=", "request", ".", "then", "(", "this", ".", "authorize", ".", "bind", "(", "this", ")", ")", ";", "if", "(", "callback", ")", "{", "promise", ".", "then", "(", "callback", ".", "bind", "(", "null", ",", "null", ")", ")", ".", "fail", "(", "callback", ")", ";", "}", "return", "promise", ";", "}" ]
Authenticate the Vine API client @param username {String} @param password {String} @param callback {Function} [optional] @return {Object} request API promise
[ "Authenticate", "the", "Vine", "API", "client" ]
9c71f2e45f306a517b6cfcfb3ef8e804918e3f81
https://github.com/furf/vineapple/blob/9c71f2e45f306a517b6cfcfb3ef8e804918e3f81/lib/vineapple.js#L155-L191
train
furf/vineapple
lib/vineapple.js
function (callback) { var promise = this.request({ method: 'delete', url: 'users/authenticate' }).then(this.authorize.bind(this)); if (callback) { promise.then(callback.bind(null, null)).fail(callback); } return promise; }
javascript
function (callback) { var promise = this.request({ method: 'delete', url: 'users/authenticate' }).then(this.authorize.bind(this)); if (callback) { promise.then(callback.bind(null, null)).fail(callback); } return promise; }
[ "function", "(", "callback", ")", "{", "var", "promise", "=", "this", ".", "request", "(", "{", "method", ":", "'delete'", ",", "url", ":", "'users/authenticate'", "}", ")", ".", "then", "(", "this", ".", "authorize", ".", "bind", "(", "this", ")", ")", ";", "if", "(", "callback", ")", "{", "promise", ".", "then", "(", "callback", ".", "bind", "(", "null", ",", "null", ")", ")", ".", "fail", "(", "callback", ")", ";", "}", "return", "promise", ";", "}" ]
De-authenticate the Vine API client @param username {String} @param password {String} @param callback {Function} [optional] @return {Object} request API promise
[ "De", "-", "authenticate", "the", "Vine", "API", "client" ]
9c71f2e45f306a517b6cfcfb3ef8e804918e3f81
https://github.com/furf/vineapple/blob/9c71f2e45f306a517b6cfcfb3ef8e804918e3f81/lib/vineapple.js#L200-L212
train
furf/vineapple
lib/vineapple.js
function (settings) { this.key = settings && settings.key; this.userId = settings && settings.userId; this.username = settings && settings.username; return this; }
javascript
function (settings) { this.key = settings && settings.key; this.userId = settings && settings.userId; this.username = settings && settings.username; return this; }
[ "function", "(", "settings", ")", "{", "this", ".", "key", "=", "settings", "&&", "settings", ".", "key", ";", "this", ".", "userId", "=", "settings", "&&", "settings", ".", "userId", ";", "this", ".", "username", "=", "settings", "&&", "settings", ".", "username", ";", "return", "this", ";", "}" ]
Authorize the current client @param settings {Object} @return {Object} self
[ "Authorize", "the", "current", "client" ]
9c71f2e45f306a517b6cfcfb3ef8e804918e3f81
https://github.com/furf/vineapple/blob/9c71f2e45f306a517b6cfcfb3ef8e804918e3f81/lib/vineapple.js#L219-L224
train
kozervar/napi-js
dist/download.js
generateFileHashes
function generateFileHashes(options, files) { if (options.verbose) { _utils.logger.info('Generating files hash...'); } if (files.length === 0) _utils.logger.info('No files found!');else if (options.verbose) { _utils.logger.info('Files found: '); var _iteratorNormalCompletion = true; var _didIteratorError = false; var _iteratorError = undefined; try { for (var _iterator = files[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { var file = _step.value; _utils.logger.info(file); } } catch (err) { _didIteratorError = true; _iteratorError = err; } finally { try { if (!_iteratorNormalCompletion && _iterator.return) { _iterator.return(); } } finally { if (_didIteratorError) { throw _iteratorError; } } } } var promises = []; var _iteratorNormalCompletion2 = true; var _didIteratorError2 = false; var _iteratorError2 = undefined; try { for (var _iterator2 = files[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { var file = _step2.value; promises.push((0, _utils.hash)(file)); } } catch (err) { _didIteratorError2 = true; _iteratorError2 = err; } finally { try { if (!_iteratorNormalCompletion2 && _iterator2.return) { _iterator2.return(); } } finally { if (_didIteratorError2) { throw _iteratorError2; } } } return Promise.all(promises); }
javascript
function generateFileHashes(options, files) { if (options.verbose) { _utils.logger.info('Generating files hash...'); } if (files.length === 0) _utils.logger.info('No files found!');else if (options.verbose) { _utils.logger.info('Files found: '); var _iteratorNormalCompletion = true; var _didIteratorError = false; var _iteratorError = undefined; try { for (var _iterator = files[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { var file = _step.value; _utils.logger.info(file); } } catch (err) { _didIteratorError = true; _iteratorError = err; } finally { try { if (!_iteratorNormalCompletion && _iterator.return) { _iterator.return(); } } finally { if (_didIteratorError) { throw _iteratorError; } } } } var promises = []; var _iteratorNormalCompletion2 = true; var _didIteratorError2 = false; var _iteratorError2 = undefined; try { for (var _iterator2 = files[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { var file = _step2.value; promises.push((0, _utils.hash)(file)); } } catch (err) { _didIteratorError2 = true; _iteratorError2 = err; } finally { try { if (!_iteratorNormalCompletion2 && _iterator2.return) { _iterator2.return(); } } finally { if (_didIteratorError2) { throw _iteratorError2; } } } return Promise.all(promises); }
[ "function", "generateFileHashes", "(", "options", ",", "files", ")", "{", "if", "(", "options", ".", "verbose", ")", "{", "_utils", ".", "logger", ".", "info", "(", "'Generating files hash...'", ")", ";", "}", "if", "(", "files", ".", "length", "===", "0", ")", "_utils", ".", "logger", ".", "info", "(", "'No files found!'", ")", ";", "else", "if", "(", "options", ".", "verbose", ")", "{", "_utils", ".", "logger", ".", "info", "(", "'Files found: '", ")", ";", "var", "_iteratorNormalCompletion", "=", "true", ";", "var", "_didIteratorError", "=", "false", ";", "var", "_iteratorError", "=", "undefined", ";", "try", "{", "for", "(", "var", "_iterator", "=", "files", "[", "Symbol", ".", "iterator", "]", "(", ")", ",", "_step", ";", "!", "(", "_iteratorNormalCompletion", "=", "(", "_step", "=", "_iterator", ".", "next", "(", ")", ")", ".", "done", ")", ";", "_iteratorNormalCompletion", "=", "true", ")", "{", "var", "file", "=", "_step", ".", "value", ";", "_utils", ".", "logger", ".", "info", "(", "file", ")", ";", "}", "}", "catch", "(", "err", ")", "{", "_didIteratorError", "=", "true", ";", "_iteratorError", "=", "err", ";", "}", "finally", "{", "try", "{", "if", "(", "!", "_iteratorNormalCompletion", "&&", "_iterator", ".", "return", ")", "{", "_iterator", ".", "return", "(", ")", ";", "}", "}", "finally", "{", "if", "(", "_didIteratorError", ")", "{", "throw", "_iteratorError", ";", "}", "}", "}", "}", "var", "promises", "=", "[", "]", ";", "var", "_iteratorNormalCompletion2", "=", "true", ";", "var", "_didIteratorError2", "=", "false", ";", "var", "_iteratorError2", "=", "undefined", ";", "try", "{", "for", "(", "var", "_iterator2", "=", "files", "[", "Symbol", ".", "iterator", "]", "(", ")", ",", "_step2", ";", "!", "(", "_iteratorNormalCompletion2", "=", "(", "_step2", "=", "_iterator2", ".", "next", "(", ")", ")", ".", "done", ")", ";", "_iteratorNormalCompletion2", "=", "true", ")", "{", "var", "file", "=", "_step2", ".", "value", ";", "promises", ".", "push", "(", "(", "0", ",", "_utils", ".", "hash", ")", "(", "file", ")", ")", ";", "}", "}", "catch", "(", "err", ")", "{", "_didIteratorError2", "=", "true", ";", "_iteratorError2", "=", "err", ";", "}", "finally", "{", "try", "{", "if", "(", "!", "_iteratorNormalCompletion2", "&&", "_iterator2", ".", "return", ")", "{", "_iterator2", ".", "return", "(", ")", ";", "}", "}", "finally", "{", "if", "(", "_didIteratorError2", ")", "{", "throw", "_iteratorError2", ";", "}", "}", "}", "return", "Promise", ".", "all", "(", "promises", ")", ";", "}" ]
Generate MD5 partial hash for provided files @param {NapijsOptions} options @param files @returns {Promise}
[ "Generate", "MD5", "partial", "hash", "for", "provided", "files" ]
f54809fdd20ad293c46ce1fbed0b4c1e12d4977c
https://github.com/kozervar/napi-js/blob/f54809fdd20ad293c46ce1fbed0b4c1e12d4977c/dist/download.js#L18-L77
train
kozervar/napi-js
dist/download.js
makeHttpRequests
function makeHttpRequests(options, fileHashes) { if (options.verbose) { _utils.logger.info('Performing HTTP requests...'); } var promises = []; var _iteratorNormalCompletion4 = true; var _didIteratorError4 = false; var _iteratorError4 = undefined; try { for (var _iterator4 = fileHashes[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { var fileWithHash = _step4.value; if (fileWithHash.subtitlesPresent) continue; if (options.verbose) { _utils.logger.info('Downloading subtitles for file [%s] with hash [%s]', fileWithHash.file, fileWithHash.hash); } var httpRequest = new _utils.HttpRequest(options, fileWithHash); promises.push(httpRequest.request()); } } catch (err) { _didIteratorError4 = true; _iteratorError4 = err; } finally { try { if (!_iteratorNormalCompletion4 && _iterator4.return) { _iterator4.return(); } } finally { if (_didIteratorError4) { throw _iteratorError4; } } } return Promise.all(promises); }
javascript
function makeHttpRequests(options, fileHashes) { if (options.verbose) { _utils.logger.info('Performing HTTP requests...'); } var promises = []; var _iteratorNormalCompletion4 = true; var _didIteratorError4 = false; var _iteratorError4 = undefined; try { for (var _iterator4 = fileHashes[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { var fileWithHash = _step4.value; if (fileWithHash.subtitlesPresent) continue; if (options.verbose) { _utils.logger.info('Downloading subtitles for file [%s] with hash [%s]', fileWithHash.file, fileWithHash.hash); } var httpRequest = new _utils.HttpRequest(options, fileWithHash); promises.push(httpRequest.request()); } } catch (err) { _didIteratorError4 = true; _iteratorError4 = err; } finally { try { if (!_iteratorNormalCompletion4 && _iterator4.return) { _iterator4.return(); } } finally { if (_didIteratorError4) { throw _iteratorError4; } } } return Promise.all(promises); }
[ "function", "makeHttpRequests", "(", "options", ",", "fileHashes", ")", "{", "if", "(", "options", ".", "verbose", ")", "{", "_utils", ".", "logger", ".", "info", "(", "'Performing HTTP requests...'", ")", ";", "}", "var", "promises", "=", "[", "]", ";", "var", "_iteratorNormalCompletion4", "=", "true", ";", "var", "_didIteratorError4", "=", "false", ";", "var", "_iteratorError4", "=", "undefined", ";", "try", "{", "for", "(", "var", "_iterator4", "=", "fileHashes", "[", "Symbol", ".", "iterator", "]", "(", ")", ",", "_step4", ";", "!", "(", "_iteratorNormalCompletion4", "=", "(", "_step4", "=", "_iterator4", ".", "next", "(", ")", ")", ".", "done", ")", ";", "_iteratorNormalCompletion4", "=", "true", ")", "{", "var", "fileWithHash", "=", "_step4", ".", "value", ";", "if", "(", "fileWithHash", ".", "subtitlesPresent", ")", "continue", ";", "if", "(", "options", ".", "verbose", ")", "{", "_utils", ".", "logger", ".", "info", "(", "'Downloading subtitles for file [%s] with hash [%s]'", ",", "fileWithHash", ".", "file", ",", "fileWithHash", ".", "hash", ")", ";", "}", "var", "httpRequest", "=", "new", "_utils", ".", "HttpRequest", "(", "options", ",", "fileWithHash", ")", ";", "promises", ".", "push", "(", "httpRequest", ".", "request", "(", ")", ")", ";", "}", "}", "catch", "(", "err", ")", "{", "_didIteratorError4", "=", "true", ";", "_iteratorError4", "=", "err", ";", "}", "finally", "{", "try", "{", "if", "(", "!", "_iteratorNormalCompletion4", "&&", "_iterator4", ".", "return", ")", "{", "_iterator4", ".", "return", "(", ")", ";", "}", "}", "finally", "{", "if", "(", "_didIteratorError4", ")", "{", "throw", "_iteratorError4", ";", "}", "}", "}", "return", "Promise", ".", "all", "(", "promises", ")", ";", "}" ]
Perform HTTP request to Napiprojekt server @param {NapijsOptions} options @param fileHashes @returns {Promise}
[ "Perform", "HTTP", "request", "to", "Napiprojekt", "server" ]
f54809fdd20ad293c46ce1fbed0b4c1e12d4977c
https://github.com/kozervar/napi-js/blob/f54809fdd20ad293c46ce1fbed0b4c1e12d4977c/dist/download.js#L123-L159
train
kozervar/napi-js
dist/download.js
parseHttpResponse
function parseHttpResponse(options, filesWithHash) { if (options.verbose) { _utils.logger.info('Parsing HTTP responses...'); } var promises = []; var _iteratorNormalCompletion5 = true; var _didIteratorError5 = false; var _iteratorError5 = undefined; try { for (var _iterator5 = filesWithHash[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) { var fileWithHash = _step5.value; if (fileWithHash.subtitlesPresent) continue; var p = (0, _utils.XML2JSON)(options, fileWithHash).catch(function (err) { if (options.verbose) { _utils.logger.info('Error in HTTP response: ', err.err); } return err.fileWithHash; }); promises.push(p); } } catch (err) { _didIteratorError5 = true; _iteratorError5 = err; } finally { try { if (!_iteratorNormalCompletion5 && _iterator5.return) { _iterator5.return(); } } finally { if (_didIteratorError5) { throw _iteratorError5; } } } return Promise.all(promises); }
javascript
function parseHttpResponse(options, filesWithHash) { if (options.verbose) { _utils.logger.info('Parsing HTTP responses...'); } var promises = []; var _iteratorNormalCompletion5 = true; var _didIteratorError5 = false; var _iteratorError5 = undefined; try { for (var _iterator5 = filesWithHash[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) { var fileWithHash = _step5.value; if (fileWithHash.subtitlesPresent) continue; var p = (0, _utils.XML2JSON)(options, fileWithHash).catch(function (err) { if (options.verbose) { _utils.logger.info('Error in HTTP response: ', err.err); } return err.fileWithHash; }); promises.push(p); } } catch (err) { _didIteratorError5 = true; _iteratorError5 = err; } finally { try { if (!_iteratorNormalCompletion5 && _iterator5.return) { _iterator5.return(); } } finally { if (_didIteratorError5) { throw _iteratorError5; } } } return Promise.all(promises); }
[ "function", "parseHttpResponse", "(", "options", ",", "filesWithHash", ")", "{", "if", "(", "options", ".", "verbose", ")", "{", "_utils", ".", "logger", ".", "info", "(", "'Parsing HTTP responses...'", ")", ";", "}", "var", "promises", "=", "[", "]", ";", "var", "_iteratorNormalCompletion5", "=", "true", ";", "var", "_didIteratorError5", "=", "false", ";", "var", "_iteratorError5", "=", "undefined", ";", "try", "{", "for", "(", "var", "_iterator5", "=", "filesWithHash", "[", "Symbol", ".", "iterator", "]", "(", ")", ",", "_step5", ";", "!", "(", "_iteratorNormalCompletion5", "=", "(", "_step5", "=", "_iterator5", ".", "next", "(", ")", ")", ".", "done", ")", ";", "_iteratorNormalCompletion5", "=", "true", ")", "{", "var", "fileWithHash", "=", "_step5", ".", "value", ";", "if", "(", "fileWithHash", ".", "subtitlesPresent", ")", "continue", ";", "var", "p", "=", "(", "0", ",", "_utils", ".", "XML2JSON", ")", "(", "options", ",", "fileWithHash", ")", ".", "catch", "(", "function", "(", "err", ")", "{", "if", "(", "options", ".", "verbose", ")", "{", "_utils", ".", "logger", ".", "info", "(", "'Error in HTTP response: '", ",", "err", ".", "err", ")", ";", "}", "return", "err", ".", "fileWithHash", ";", "}", ")", ";", "promises", ".", "push", "(", "p", ")", ";", "}", "}", "catch", "(", "err", ")", "{", "_didIteratorError5", "=", "true", ";", "_iteratorError5", "=", "err", ";", "}", "finally", "{", "try", "{", "if", "(", "!", "_iteratorNormalCompletion5", "&&", "_iterator5", ".", "return", ")", "{", "_iterator5", ".", "return", "(", ")", ";", "}", "}", "finally", "{", "if", "(", "_didIteratorError5", ")", "{", "throw", "_iteratorError5", ";", "}", "}", "}", "return", "Promise", ".", "all", "(", "promises", ")", ";", "}" ]
Parse HTTP response from Napiprojekt server. Format XML response to JSON and save subtitles to file. @param {NapijsOptions} options @param filesWithHash @returns {Promise}
[ "Parse", "HTTP", "response", "from", "Napiprojekt", "server", ".", "Format", "XML", "response", "to", "JSON", "and", "save", "subtitles", "to", "file", "." ]
f54809fdd20ad293c46ce1fbed0b4c1e12d4977c
https://github.com/kozervar/napi-js/blob/f54809fdd20ad293c46ce1fbed0b4c1e12d4977c/dist/download.js#L167-L205
train
ipanli/xlsxtojson
lib/xlsx-to-json.js
parseObjectArrayField
function parseObjectArrayField(row, key, value) { var obj_array = []; if (value) { if (value.indexOf(',') !== -1) { obj_array = value.split(','); } else { obj_array.push(value.toString()); }; }; // if (typeof(value) === 'string' && value.indexOf(',') !== -1) { // obj_array = value.split(','); // } else { // obj_array.push(value.toString()); // }; var result = []; obj_array.forEach(function(e) { if (e) { result.push(array2object(e.split(';'))); } }); row[key] = result; }
javascript
function parseObjectArrayField(row, key, value) { var obj_array = []; if (value) { if (value.indexOf(',') !== -1) { obj_array = value.split(','); } else { obj_array.push(value.toString()); }; }; // if (typeof(value) === 'string' && value.indexOf(',') !== -1) { // obj_array = value.split(','); // } else { // obj_array.push(value.toString()); // }; var result = []; obj_array.forEach(function(e) { if (e) { result.push(array2object(e.split(';'))); } }); row[key] = result; }
[ "function", "parseObjectArrayField", "(", "row", ",", "key", ",", "value", ")", "{", "var", "obj_array", "=", "[", "]", ";", "if", "(", "value", ")", "{", "if", "(", "value", ".", "indexOf", "(", "','", ")", "!==", "-", "1", ")", "{", "obj_array", "=", "value", ".", "split", "(", "','", ")", ";", "}", "else", "{", "obj_array", ".", "push", "(", "value", ".", "toString", "(", ")", ")", ";", "}", ";", "}", ";", "var", "result", "=", "[", "]", ";", "obj_array", ".", "forEach", "(", "function", "(", "e", ")", "{", "if", "(", "e", ")", "{", "result", ".", "push", "(", "array2object", "(", "e", ".", "split", "(", "';'", ")", ")", ")", ";", "}", "}", ")", ";", "row", "[", "key", "]", "=", "result", ";", "}" ]
parse object array.
[ "parse", "object", "array", "." ]
7432f133d584d6f32eb2bf722de084e2416bc468
https://github.com/ipanli/xlsxtojson/blob/7432f133d584d6f32eb2bf722de084e2416bc468/lib/xlsx-to-json.js#L205-L232
train
ipanli/xlsxtojson
lib/xlsx-to-json.js
parseBasicArrayField
function parseBasicArrayField(field, key, array) { var basic_array; if (typeof array === "string") { basic_array = array.split(arraySeparator); } else { basic_array = []; basic_array.push(array); }; var result = []; if (isNumberArray(basic_array)) { basic_array.forEach(function(element) { result.push(Number(element)); }); } else if (isBooleanArray(basic_array)) { basic_array.forEach(function(element) { result.push(toBoolean(element)); }); } else { //string array result = basic_array; }; // console.log("basic_array", result + "|||" + cell.value); field[key] = result; }
javascript
function parseBasicArrayField(field, key, array) { var basic_array; if (typeof array === "string") { basic_array = array.split(arraySeparator); } else { basic_array = []; basic_array.push(array); }; var result = []; if (isNumberArray(basic_array)) { basic_array.forEach(function(element) { result.push(Number(element)); }); } else if (isBooleanArray(basic_array)) { basic_array.forEach(function(element) { result.push(toBoolean(element)); }); } else { //string array result = basic_array; }; // console.log("basic_array", result + "|||" + cell.value); field[key] = result; }
[ "function", "parseBasicArrayField", "(", "field", ",", "key", ",", "array", ")", "{", "var", "basic_array", ";", "if", "(", "typeof", "array", "===", "\"string\"", ")", "{", "basic_array", "=", "array", ".", "split", "(", "arraySeparator", ")", ";", "}", "else", "{", "basic_array", "=", "[", "]", ";", "basic_array", ".", "push", "(", "array", ")", ";", "}", ";", "var", "result", "=", "[", "]", ";", "if", "(", "isNumberArray", "(", "basic_array", ")", ")", "{", "basic_array", ".", "forEach", "(", "function", "(", "element", ")", "{", "result", ".", "push", "(", "Number", "(", "element", ")", ")", ";", "}", ")", ";", "}", "else", "if", "(", "isBooleanArray", "(", "basic_array", ")", ")", "{", "basic_array", ".", "forEach", "(", "function", "(", "element", ")", "{", "result", ".", "push", "(", "toBoolean", "(", "element", ")", ")", ";", "}", ")", ";", "}", "else", "{", "result", "=", "basic_array", ";", "}", ";", "field", "[", "key", "]", "=", "result", ";", "}" ]
parse simple array.
[ "parse", "simple", "array", "." ]
7432f133d584d6f32eb2bf722de084e2416bc468
https://github.com/ipanli/xlsxtojson/blob/7432f133d584d6f32eb2bf722de084e2416bc468/lib/xlsx-to-json.js#L267-L291
train
ipanli/xlsxtojson
lib/xlsx-to-json.js
isBoolean
function isBoolean(value) { if (typeof(value) == "undefined") { return false; } if (typeof value === 'boolean') { return true; }; var b = value.toString().trim().toLowerCase(); return b === 'true' || b === 'false'; }
javascript
function isBoolean(value) { if (typeof(value) == "undefined") { return false; } if (typeof value === 'boolean') { return true; }; var b = value.toString().trim().toLowerCase(); return b === 'true' || b === 'false'; }
[ "function", "isBoolean", "(", "value", ")", "{", "if", "(", "typeof", "(", "value", ")", "==", "\"undefined\"", ")", "{", "return", "false", ";", "}", "if", "(", "typeof", "value", "===", "'boolean'", ")", "{", "return", "true", ";", "}", ";", "var", "b", "=", "value", ".", "toString", "(", ")", ".", "trim", "(", ")", ".", "toLowerCase", "(", ")", ";", "return", "b", "===", "'true'", "||", "b", "===", "'false'", ";", "}" ]
boolean type check.
[ "boolean", "type", "check", "." ]
7432f133d584d6f32eb2bf722de084e2416bc468
https://github.com/ipanli/xlsxtojson/blob/7432f133d584d6f32eb2bf722de084e2416bc468/lib/xlsx-to-json.js#L336-L349
train
ipanli/xlsxtojson
lib/xlsx-to-json.js
isDateType
function isDateType(value) { if (value) { var str = value.toString(); return moment(new Date(value), "YYYY-M-D", true).isValid() || moment(value, "YYYY-M-D H:m:s", true).isValid() || moment(value, "YYYY/M/D H:m:s", true).isValid() || moment(value, "YYYY/M/D", true).isValid(); }; return false; }
javascript
function isDateType(value) { if (value) { var str = value.toString(); return moment(new Date(value), "YYYY-M-D", true).isValid() || moment(value, "YYYY-M-D H:m:s", true).isValid() || moment(value, "YYYY/M/D H:m:s", true).isValid() || moment(value, "YYYY/M/D", true).isValid(); }; return false; }
[ "function", "isDateType", "(", "value", ")", "{", "if", "(", "value", ")", "{", "var", "str", "=", "value", ".", "toString", "(", ")", ";", "return", "moment", "(", "new", "Date", "(", "value", ")", ",", "\"YYYY-M-D\"", ",", "true", ")", ".", "isValid", "(", ")", "||", "moment", "(", "value", ",", "\"YYYY-M-D H:m:s\"", ",", "true", ")", ".", "isValid", "(", ")", "||", "moment", "(", "value", ",", "\"YYYY/M/D H:m:s\"", ",", "true", ")", ".", "isValid", "(", ")", "||", "moment", "(", "value", ",", "\"YYYY/M/D\"", ",", "true", ")", ".", "isValid", "(", ")", ";", "}", ";", "return", "false", ";", "}" ]
date type check.
[ "date", "type", "check", "." ]
7432f133d584d6f32eb2bf722de084e2416bc468
https://github.com/ipanli/xlsxtojson/blob/7432f133d584d6f32eb2bf722de084e2416bc468/lib/xlsx-to-json.js#L359-L365
train
mjlescano/domator
domator.js
domator
function domator() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return render(parse(args)); }
javascript
function domator() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return render(parse(args)); }
[ "function", "domator", "(", ")", "{", "for", "(", "var", "_len", "=", "arguments", ".", "length", ",", "args", "=", "Array", "(", "_len", ")", ",", "_key", "=", "0", ";", "_key", "<", "_len", ";", "_key", "++", ")", "{", "args", "[", "_key", "]", "=", "arguments", "[", "_key", "]", ";", "}", "return", "render", "(", "parse", "(", "args", ")", ")", ";", "}" ]
Default domator export
[ "Default", "domator", "export" ]
8307bee6172f4830d40df61ba277ac2b2b4c0fc2
https://github.com/mjlescano/domator/blob/8307bee6172f4830d40df61ba277ac2b2b4c0fc2/domator.js#L175-L181
train
rootsdev/gedcomx-js
src/core/Subject.js
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof Subject)){ return new Subject(json); } // If the given object is already an instance then just return it. DON'T copy it. if(Subject.isInstance(json)){ return json; } this.init(json); }
javascript
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof Subject)){ return new Subject(json); } // If the given object is already an instance then just return it. DON'T copy it. if(Subject.isInstance(json)){ return json; } this.init(json); }
[ "function", "(", "json", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Subject", ")", ")", "{", "return", "new", "Subject", "(", "json", ")", ";", "}", "if", "(", "Subject", ".", "isInstance", "(", "json", ")", ")", "{", "return", "json", ";", "}", "this", ".", "init", "(", "json", ")", ";", "}" ]
An object identified in time and space by various conclusions. @see {@link https://github.com/FamilySearch/gedcomx/blob/master/specifications/json-format-specification.md#subject|GEDCOM X JSON Spec} @class @extends Conclusion @param {Object} [json]
[ "An", "object", "identified", "in", "time", "and", "space", "by", "various", "conclusions", "." ]
08b2fcde96f1e301c78561bfb7a8b0cac606e26e
https://github.com/rootsdev/gedcomx-js/blob/08b2fcde96f1e301c78561bfb7a8b0cac606e26e/src/core/Subject.js#L13-L26
train
rootsdev/gedcomx-js
src/core/Document.js
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof Document)){ return new Document(json); } // If the given object is already an instance then just return it. DON'T copy it. if(Document.isInstance(json)){ return json; } this.init(json); }
javascript
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof Document)){ return new Document(json); } // If the given object is already an instance then just return it. DON'T copy it. if(Document.isInstance(json)){ return json; } this.init(json); }
[ "function", "(", "json", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Document", ")", ")", "{", "return", "new", "Document", "(", "json", ")", ";", "}", "if", "(", "Document", ".", "isInstance", "(", "json", ")", ")", "{", "return", "json", ";", "}", "this", ".", "init", "(", "json", ")", ";", "}" ]
A textual document @see {@link https://github.com/FamilySearch/gedcomx/blob/master/specifications/json-format-specification.md#document|GEDCOM X JSON Spec} @class @extends Conclusion @param {Object} [json]
[ "A", "textual", "document" ]
08b2fcde96f1e301c78561bfb7a8b0cac606e26e
https://github.com/rootsdev/gedcomx-js/blob/08b2fcde96f1e301c78561bfb7a8b0cac606e26e/src/core/Document.js#L13-L26
train
rootsdev/gedcomx-js
src/records/FieldValue.js
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof FieldValue)){ return new FieldValue(json); } // If the given object is already an instance then just return it. DON'T copy it. if(FieldValue.isInstance(json)){ return json; } this.init(json); }
javascript
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof FieldValue)){ return new FieldValue(json); } // If the given object is already an instance then just return it. DON'T copy it. if(FieldValue.isInstance(json)){ return json; } this.init(json); }
[ "function", "(", "json", ")", "{", "if", "(", "!", "(", "this", "instanceof", "FieldValue", ")", ")", "{", "return", "new", "FieldValue", "(", "json", ")", ";", "}", "if", "(", "FieldValue", ".", "isInstance", "(", "json", ")", ")", "{", "return", "json", ";", "}", "this", ".", "init", "(", "json", ")", ";", "}" ]
Information about the value of a field. @see {@link https://github.com/FamilySearch/gedcomx-record/blob/master/specifications/record-specification.md#field-value-data-type|GEDCOM X Records Spec} @class FieldValue @extends Conclusion @param {Object} [json]
[ "Information", "about", "the", "value", "of", "a", "field", "." ]
08b2fcde96f1e301c78561bfb7a8b0cac606e26e
https://github.com/rootsdev/gedcomx-js/blob/08b2fcde96f1e301c78561bfb7a8b0cac606e26e/src/records/FieldValue.js#L14-L27
train
rootsdev/gedcomx-js
src/core/Name.js
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof Name)){ return new Name(json); } // If the given object is already an instance then just return it. DON'T copy it. if(Name.isInstance(json)){ return json; } this.init(json); }
javascript
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof Name)){ return new Name(json); } // If the given object is already an instance then just return it. DON'T copy it. if(Name.isInstance(json)){ return json; } this.init(json); }
[ "function", "(", "json", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Name", ")", ")", "{", "return", "new", "Name", "(", "json", ")", ";", "}", "if", "(", "Name", ".", "isInstance", "(", "json", ")", ")", "{", "return", "json", ";", "}", "this", ".", "init", "(", "json", ")", ";", "}" ]
A name. @see {@link https://github.com/FamilySearch/gedcomx/blob/master/specifications/json-format-specification.md#name-conclusion|GEDCOM X JSON Spec} @class @extends Conclusion @param {Object} [json]
[ "A", "name", "." ]
08b2fcde96f1e301c78561bfb7a8b0cac606e26e
https://github.com/rootsdev/gedcomx-js/blob/08b2fcde96f1e301c78561bfb7a8b0cac606e26e/src/core/Name.js#L13-L26
train
Adeptive/Smappee-NodeJS
smappee-api.js
function(handler) { if (typeof accessToken == 'undefined') { var body = { client_id: clientId, client_secret: clientSecret, username: username, password: password, grant_type: 'password' }; if (thisObject.debug) { console.log("Making oAuth call..."); } var options = { url: 'https://app1pub.smappee.net/dev/v1/oauth2/token', headers: { 'Host': 'app1pub.smappee.net' }, form: body }; request.post(options, function (err, httpResponse, body) { if (err) { return console.error('Request failed:', err); } if (thisObject.debug) { console.log('Server responded with:', body); } accessToken = JSON.parse(body); handler(accessToken); }); } else { handler(accessToken) } }
javascript
function(handler) { if (typeof accessToken == 'undefined') { var body = { client_id: clientId, client_secret: clientSecret, username: username, password: password, grant_type: 'password' }; if (thisObject.debug) { console.log("Making oAuth call..."); } var options = { url: 'https://app1pub.smappee.net/dev/v1/oauth2/token', headers: { 'Host': 'app1pub.smappee.net' }, form: body }; request.post(options, function (err, httpResponse, body) { if (err) { return console.error('Request failed:', err); } if (thisObject.debug) { console.log('Server responded with:', body); } accessToken = JSON.parse(body); handler(accessToken); }); } else { handler(accessToken) } }
[ "function", "(", "handler", ")", "{", "if", "(", "typeof", "accessToken", "==", "'undefined'", ")", "{", "var", "body", "=", "{", "client_id", ":", "clientId", ",", "client_secret", ":", "clientSecret", ",", "username", ":", "username", ",", "password", ":", "password", ",", "grant_type", ":", "'password'", "}", ";", "if", "(", "thisObject", ".", "debug", ")", "{", "console", ".", "log", "(", "\"Making oAuth call...\"", ")", ";", "}", "var", "options", "=", "{", "url", ":", "'https://app1pub.smappee.net/dev/v1/oauth2/token'", ",", "headers", ":", "{", "'Host'", ":", "'app1pub.smappee.net'", "}", ",", "form", ":", "body", "}", ";", "request", ".", "post", "(", "options", ",", "function", "(", "err", ",", "httpResponse", ",", "body", ")", "{", "if", "(", "err", ")", "{", "return", "console", ".", "error", "(", "'Request failed:'", ",", "err", ")", ";", "}", "if", "(", "thisObject", ".", "debug", ")", "{", "console", ".", "log", "(", "'Server responded with:'", ",", "body", ")", ";", "}", "accessToken", "=", "JSON", ".", "parse", "(", "body", ")", ";", "handler", "(", "accessToken", ")", ";", "}", ")", ";", "}", "else", "{", "handler", "(", "accessToken", ")", "}", "}" ]
HELPER METHODS ++++++++++++++++++++++++++++++++++++++++
[ "HELPER", "METHODS", "++++++++++++++++++++++++++++++++++++++++" ]
02de2f6f8fcc1d48a39b1b36d36535ea24435395
https://github.com/Adeptive/Smappee-NodeJS/blob/02de2f6f8fcc1d48a39b1b36d36535ea24435395/smappee-api.js#L125-L161
train
gabrieleds/node-argv
index.js
parse
function parse (argv, opts, target) { if ('string' === typeof argv) argv = argv.split(rSplit).filter(ignore); if (!opts) opts = {}; opts[don] = true; var parsed = parseArray(argv, opts); opts[don] = false; var through = parsed[don].length ? parseArray(parsed[don], opts) : null; if (!target) target = {}; target.options = parsed; target.commands = parsed[din]; target.input = argv; if (through) { target.through = { options: through, commands: through[din] }; delete through[din]; } delete parsed[din]; delete parsed[don]; return target; function ignore (s) { return s && '' !== s; } }
javascript
function parse (argv, opts, target) { if ('string' === typeof argv) argv = argv.split(rSplit).filter(ignore); if (!opts) opts = {}; opts[don] = true; var parsed = parseArray(argv, opts); opts[don] = false; var through = parsed[don].length ? parseArray(parsed[don], opts) : null; if (!target) target = {}; target.options = parsed; target.commands = parsed[din]; target.input = argv; if (through) { target.through = { options: through, commands: through[din] }; delete through[din]; } delete parsed[din]; delete parsed[don]; return target; function ignore (s) { return s && '' !== s; } }
[ "function", "parse", "(", "argv", ",", "opts", ",", "target", ")", "{", "if", "(", "'string'", "===", "typeof", "argv", ")", "argv", "=", "argv", ".", "split", "(", "rSplit", ")", ".", "filter", "(", "ignore", ")", ";", "if", "(", "!", "opts", ")", "opts", "=", "{", "}", ";", "opts", "[", "don", "]", "=", "true", ";", "var", "parsed", "=", "parseArray", "(", "argv", ",", "opts", ")", ";", "opts", "[", "don", "]", "=", "false", ";", "var", "through", "=", "parsed", "[", "don", "]", ".", "length", "?", "parseArray", "(", "parsed", "[", "don", "]", ",", "opts", ")", ":", "null", ";", "if", "(", "!", "target", ")", "target", "=", "{", "}", ";", "target", ".", "options", "=", "parsed", ";", "target", ".", "commands", "=", "parsed", "[", "din", "]", ";", "target", ".", "input", "=", "argv", ";", "if", "(", "through", ")", "{", "target", ".", "through", "=", "{", "options", ":", "through", ",", "commands", ":", "through", "[", "din", "]", "}", ";", "delete", "through", "[", "din", "]", ";", "}", "delete", "parsed", "[", "din", "]", ";", "delete", "parsed", "[", "don", "]", ";", "return", "target", ";", "function", "ignore", "(", "s", ")", "{", "return", "s", "&&", "''", "!==", "s", ";", "}", "}" ]
Parse arguments. @param {argv} String/Array to parse @param {opts} Object of properties @param {target} Object @return {target|Object} @api public
[ "Parse", "arguments", "." ]
c970e90d0a812fc93435051a89ee1cc9c87a80d5
https://github.com/gabrieleds/node-argv/blob/c970e90d0a812fc93435051a89ee1cc9c87a80d5/index.js#L38-L62
train
rootsdev/gedcomx-js
src/rs/Link.js
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof Link)){ return new Link(json); } // If the given object is already an instance then just return it. DON'T copy it. if(Link.isInstance(json)){ return json; } // TODO: Enforce spec constraint that requires either an href or a template? this.init(json); }
javascript
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof Link)){ return new Link(json); } // If the given object is already an instance then just return it. DON'T copy it. if(Link.isInstance(json)){ return json; } // TODO: Enforce spec constraint that requires either an href or a template? this.init(json); }
[ "function", "(", "json", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Link", ")", ")", "{", "return", "new", "Link", "(", "json", ")", ";", "}", "if", "(", "Link", ".", "isInstance", "(", "json", ")", ")", "{", "return", "json", ";", "}", "this", ".", "init", "(", "json", ")", ";", "}" ]
A representation of an available transition from one application state to another. {@link https://github.com/FamilySearch/gedcomx-rs/blob/master/specifications/rs-specification.md#link|GEDCOM X RS Spec} @class Link @extends Base @param {Object} [json]
[ "A", "representation", "of", "an", "available", "transition", "from", "one", "application", "state", "to", "another", "." ]
08b2fcde96f1e301c78561bfb7a8b0cac606e26e
https://github.com/rootsdev/gedcomx-js/blob/08b2fcde96f1e301c78561bfb7a8b0cac606e26e/src/rs/Link.js#L15-L30
train
crcn/celeri
lib/plugins/help.js
function(category, name, desc) { if(used[name]) return; used[name]= 1; if(!items[category]) items[category] = []; items[category].push({ name: name, desc: desc }); }
javascript
function(category, name, desc) { if(used[name]) return; used[name]= 1; if(!items[category]) items[category] = []; items[category].push({ name: name, desc: desc }); }
[ "function", "(", "category", ",", "name", ",", "desc", ")", "{", "if", "(", "used", "[", "name", "]", ")", "return", ";", "used", "[", "name", "]", "=", "1", ";", "if", "(", "!", "items", "[", "category", "]", ")", "items", "[", "category", "]", "=", "[", "]", ";", "items", "[", "category", "]", ".", "push", "(", "{", "name", ":", "name", ",", "desc", ":", "desc", "}", ")", ";", "}" ]
adds a help item
[ "adds", "a", "help", "item" ]
f10471478b9119485c7c72a49015e22ec4339e29
https://github.com/crcn/celeri/blob/f10471478b9119485c7c72a49015e22ec4339e29/lib/plugins/help.js#L40-L51
train
rootsdev/gedcomx-js
src/rs/FamilyView.js
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof FamilyView)){ return new FamilyView(json); } // If the given object is already an instance then just return it. DON'T copy it. if(FamilyView.isInstance(json)){ return json; } this.init(json); }
javascript
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof FamilyView)){ return new FamilyView(json); } // If the given object is already an instance then just return it. DON'T copy it. if(FamilyView.isInstance(json)){ return json; } this.init(json); }
[ "function", "(", "json", ")", "{", "if", "(", "!", "(", "this", "instanceof", "FamilyView", ")", ")", "{", "return", "new", "FamilyView", "(", "json", ")", ";", "}", "if", "(", "FamilyView", ".", "isInstance", "(", "json", ")", ")", "{", "return", "json", ";", "}", "this", ".", "init", "(", "json", ")", ";", "}" ]
A view of a family that consists of up to two parents and a list of children who have that set of parents in common. While the Relationship data type carries the canonical information about the nature of the relationship between the each pair of persons, the FamilyView is designed as a convenience for display purposes. {@link https://github.com/FamilySearch/gedcomx-rs/blob/master/specifications/rs-specification.md#family-view|GEDCOM X RS Spec} @class FamilyView @extends Base @param {Object} [json]
[ "A", "view", "of", "a", "family", "that", "consists", "of", "up", "to", "two", "parents", "and", "a", "list", "of", "children", "who", "have", "that", "set", "of", "parents", "in", "common", ".", "While", "the", "Relationship", "data", "type", "carries", "the", "canonical", "information", "about", "the", "nature", "of", "the", "relationship", "between", "the", "each", "pair", "of", "persons", "the", "FamilyView", "is", "designed", "as", "a", "convenience", "for", "display", "purposes", "." ]
08b2fcde96f1e301c78561bfb7a8b0cac606e26e
https://github.com/rootsdev/gedcomx-js/blob/08b2fcde96f1e301c78561bfb7a8b0cac606e26e/src/rs/FamilyView.js#L19-L32
train
xfix/python-format
lib/python-format.js
repeat
function repeat(string, times) { var result = "" // Optimized repeat function concatenates concatenated // strings. while (times > 0) { if (times & 1) result += string times >>= 1 string += string } return result }
javascript
function repeat(string, times) { var result = "" // Optimized repeat function concatenates concatenated // strings. while (times > 0) { if (times & 1) result += string times >>= 1 string += string } return result }
[ "function", "repeat", "(", "string", ",", "times", ")", "{", "var", "result", "=", "\"\"", "while", "(", "times", ">", "0", ")", "{", "if", "(", "times", "&", "1", ")", "result", "+=", "string", "times", ">>=", "1", "string", "+=", "string", "}", "return", "result", "}" ]
Internal function used for padding
[ "Internal", "function", "used", "for", "padding" ]
3921fa3846386d754d2dfc163fa5221be654be63
https://github.com/xfix/python-format/blob/3921fa3846386d754d2dfc163fa5221be654be63/lib/python-format.js#L79-L89
train
zanata/fake-zanata-server
index.js
endpointWithAlias
function endpointWithAlias(path, aliasPath) { return function () { endpoint(path)(); endpoint(aliasPath, null, getJSON(path))(); } }
javascript
function endpointWithAlias(path, aliasPath) { return function () { endpoint(path)(); endpoint(aliasPath, null, getJSON(path))(); } }
[ "function", "endpointWithAlias", "(", "path", ",", "aliasPath", ")", "{", "return", "function", "(", ")", "{", "endpoint", "(", "path", ")", "(", ")", ";", "endpoint", "(", "aliasPath", ",", "null", ",", "getJSON", "(", "path", ")", ")", "(", ")", ";", "}", "}" ]
Create a thunk that registers multiple endpoints that use the same data. The path of the JSON file in the mock directory must be the same as the first path argument. @path Local portion of endpoint path. @aliasPath Alternative path that will return the same data as the first path.
[ "Create", "a", "thunk", "that", "registers", "multiple", "endpoints", "that", "use", "the", "same", "data", "." ]
e44855572514b1dc9f5779ebb49298d75f04b4fb
https://github.com/zanata/fake-zanata-server/blob/e44855572514b1dc9f5779ebb49298d75f04b4fb/index.js#L164-L169
train
zanata/fake-zanata-server
index.js
extendingEndpoints
function extendingEndpoints() { var segments = Array.prototype.slice.call(arguments, 0); return function () { var path = ''; segments.forEach(function (pathSegment) { path = path + pathSegment; createEndpointFromPath(path); console.log(' registered path %s', path); }); } }
javascript
function extendingEndpoints() { var segments = Array.prototype.slice.call(arguments, 0); return function () { var path = ''; segments.forEach(function (pathSegment) { path = path + pathSegment; createEndpointFromPath(path); console.log(' registered path %s', path); }); } }
[ "function", "extendingEndpoints", "(", ")", "{", "var", "segments", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ",", "0", ")", ";", "return", "function", "(", ")", "{", "var", "path", "=", "''", ";", "segments", ".", "forEach", "(", "function", "(", "pathSegment", ")", "{", "path", "=", "path", "+", "pathSegment", ";", "createEndpointFromPath", "(", "path", ")", ";", "console", ".", "log", "(", "' registered path %s'", ",", "path", ")", ";", "}", ")", ";", "}", "}" ]
Create a thunk that will build up endpoints from an ordered set of path segments, registering the endpoints at all stages along the way. Each endpoint must have a corresponding JSON file in the mocks directory.
[ "Create", "a", "thunk", "that", "will", "build", "up", "endpoints", "from", "an", "ordered", "set", "of", "path", "segments", "registering", "the", "endpoints", "at", "all", "stages", "along", "the", "way", "." ]
e44855572514b1dc9f5779ebb49298d75f04b4fb
https://github.com/zanata/fake-zanata-server/blob/e44855572514b1dc9f5779ebb49298d75f04b4fb/index.js#L177-L187
train
zanata/fake-zanata-server
index.js
subEndpoints
function subEndpoints(prefix, suffixes) { return function () { Array.prototype.forEach.call(suffixes, function (suffix) { var path = prefix + suffix; createEndpointFromPath(path); console.log(' registered path %s', path); }); } }
javascript
function subEndpoints(prefix, suffixes) { return function () { Array.prototype.forEach.call(suffixes, function (suffix) { var path = prefix + suffix; createEndpointFromPath(path); console.log(' registered path %s', path); }); } }
[ "function", "subEndpoints", "(", "prefix", ",", "suffixes", ")", "{", "return", "function", "(", ")", "{", "Array", ".", "prototype", ".", "forEach", ".", "call", "(", "suffixes", ",", "function", "(", "suffix", ")", "{", "var", "path", "=", "prefix", "+", "suffix", ";", "createEndpointFromPath", "(", "path", ")", ";", "console", ".", "log", "(", "' registered path %s'", ",", "path", ")", ";", "}", ")", ";", "}", "}" ]
Create a thunk to make a set of endpoints with a common prefix. The prefix is prepended to each suffix to make each path. Each endpoint must have a corresponding JSON file in the mocks directory.
[ "Create", "a", "thunk", "to", "make", "a", "set", "of", "endpoints", "with", "a", "common", "prefix", "." ]
e44855572514b1dc9f5779ebb49298d75f04b4fb
https://github.com/zanata/fake-zanata-server/blob/e44855572514b1dc9f5779ebb49298d75f04b4fb/index.js#L196-L204
train
zanata/fake-zanata-server
index.js
badRequestEndpoint
function badRequestEndpoint(path, query, body) { return function () { body = body || getJSON(path); createEndpointFromObject(path, query, body).status(400); console.log(' registered error path %s', path); } }
javascript
function badRequestEndpoint(path, query, body) { return function () { body = body || getJSON(path); createEndpointFromObject(path, query, body).status(400); console.log(' registered error path %s', path); } }
[ "function", "badRequestEndpoint", "(", "path", ",", "query", ",", "body", ")", "{", "return", "function", "(", ")", "{", "body", "=", "body", "||", "getJSON", "(", "path", ")", ";", "createEndpointFromObject", "(", "path", ",", "query", ",", "body", ")", ".", "status", "(", "400", ")", ";", "console", ".", "log", "(", "' registered error path %s'", ",", "path", ")", ";", "}", "}" ]
Create a thunk that registers an endpoint that responds with BAD REQUEST status.
[ "Create", "a", "thunk", "that", "registers", "an", "endpoint", "that", "responds", "with", "BAD", "REQUEST", "status", "." ]
e44855572514b1dc9f5779ebb49298d75f04b4fb
https://github.com/zanata/fake-zanata-server/blob/e44855572514b1dc9f5779ebb49298d75f04b4fb/index.js#L242-L248
train
zanata/fake-zanata-server
index.js
createEndpointFromPath
function createEndpointFromPath(path, query, filePath) { filePath = filePath || path; return createEndpointFromObject(path, query, getJSON(filePath)); }
javascript
function createEndpointFromPath(path, query, filePath) { filePath = filePath || path; return createEndpointFromObject(path, query, getJSON(filePath)); }
[ "function", "createEndpointFromPath", "(", "path", ",", "query", ",", "filePath", ")", "{", "filePath", "=", "filePath", "||", "path", ";", "return", "createEndpointFromObject", "(", "path", ",", "query", ",", "getJSON", "(", "filePath", ")", ")", ";", "}" ]
Registers an endpoint using the file at the given path as the response body. If filePath is not provided, path will be used as the file location.
[ "Registers", "an", "endpoint", "using", "the", "file", "at", "the", "given", "path", "as", "the", "response", "body", "." ]
e44855572514b1dc9f5779ebb49298d75f04b4fb
https://github.com/zanata/fake-zanata-server/blob/e44855572514b1dc9f5779ebb49298d75f04b4fb/index.js#L255-L258
train
zanata/fake-zanata-server
index.js
createEndpointFromObject
function createEndpointFromObject(path, query, body) { // OPTIONS gives server permission to use CORS server.createRoute({ request: { url: path, query: query || {}, method: 'options', }, response: { code: 200, delay: config.latency, body: {}, headers: { 'Access-Control-Allow-Origin': config.allowOrigin, // allow several methods since some endpoints are writable 'Access-Control-Allow-Methods': 'GET, PUT, POST', 'Access-Control-Allow-Credentials': 'true' } } }); return server.get(path) .query(query) .responseHeaders({ 'Access-Control-Allow-Origin': config.allowOrigin, 'Access-Control-Allow-Methods': 'GET, PUT, POST', 'Access-Control-Allow-Credentials': 'true' }) .body(body) .delay(config.latency); }
javascript
function createEndpointFromObject(path, query, body) { // OPTIONS gives server permission to use CORS server.createRoute({ request: { url: path, query: query || {}, method: 'options', }, response: { code: 200, delay: config.latency, body: {}, headers: { 'Access-Control-Allow-Origin': config.allowOrigin, // allow several methods since some endpoints are writable 'Access-Control-Allow-Methods': 'GET, PUT, POST', 'Access-Control-Allow-Credentials': 'true' } } }); return server.get(path) .query(query) .responseHeaders({ 'Access-Control-Allow-Origin': config.allowOrigin, 'Access-Control-Allow-Methods': 'GET, PUT, POST', 'Access-Control-Allow-Credentials': 'true' }) .body(body) .delay(config.latency); }
[ "function", "createEndpointFromObject", "(", "path", ",", "query", ",", "body", ")", "{", "server", ".", "createRoute", "(", "{", "request", ":", "{", "url", ":", "path", ",", "query", ":", "query", "||", "{", "}", ",", "method", ":", "'options'", ",", "}", ",", "response", ":", "{", "code", ":", "200", ",", "delay", ":", "config", ".", "latency", ",", "body", ":", "{", "}", ",", "headers", ":", "{", "'Access-Control-Allow-Origin'", ":", "config", ".", "allowOrigin", ",", "'Access-Control-Allow-Methods'", ":", "'GET, PUT, POST'", ",", "'Access-Control-Allow-Credentials'", ":", "'true'", "}", "}", "}", ")", ";", "return", "server", ".", "get", "(", "path", ")", ".", "query", "(", "query", ")", ".", "responseHeaders", "(", "{", "'Access-Control-Allow-Origin'", ":", "config", ".", "allowOrigin", ",", "'Access-Control-Allow-Methods'", ":", "'GET, PUT, POST'", ",", "'Access-Control-Allow-Credentials'", ":", "'true'", "}", ")", ".", "body", "(", "body", ")", ".", "delay", "(", "config", ".", "latency", ")", ";", "}" ]
Registers an endpoint using the given response body.
[ "Registers", "an", "endpoint", "using", "the", "given", "response", "body", "." ]
e44855572514b1dc9f5779ebb49298d75f04b4fb
https://github.com/zanata/fake-zanata-server/blob/e44855572514b1dc9f5779ebb49298d75f04b4fb/index.js#L263-L292
train
rootsdev/gedcomx-js
src/core/OnlineAccount.js
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof OnlineAccount)){ return new OnlineAccount(json); } // If the given object is already an instance then just return it. DON'T copy it. if(OnlineAccount.isInstance(json)){ return json; } this.init(json); }
javascript
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof OnlineAccount)){ return new OnlineAccount(json); } // If the given object is already an instance then just return it. DON'T copy it. if(OnlineAccount.isInstance(json)){ return json; } this.init(json); }
[ "function", "(", "json", ")", "{", "if", "(", "!", "(", "this", "instanceof", "OnlineAccount", ")", ")", "{", "return", "new", "OnlineAccount", "(", "json", ")", ";", "}", "if", "(", "OnlineAccount", ".", "isInstance", "(", "json", ")", ")", "{", "return", "json", ";", "}", "this", ".", "init", "(", "json", ")", ";", "}" ]
An online account for a web application. @see {@link https://github.com/FamilySearch/gedcomx/blob/master/specifications/json-format-specification.md#online-account|GEDCOM X JSON Spec} @class @extends ExtensibleData @param {Object} [json]
[ "An", "online", "account", "for", "a", "web", "application", "." ]
08b2fcde96f1e301c78561bfb7a8b0cac606e26e
https://github.com/rootsdev/gedcomx-js/blob/08b2fcde96f1e301c78561bfb7a8b0cac606e26e/src/core/OnlineAccount.js#L13-L26
train
AppGeo/cartodb
lib/compiler.js
toSQL
function toSQL(method) { method = method || this.method; var val = this[method](); var defaults = { method: method, options: assign({}, this.options), bindings: this.formatter.bindings }; if (typeof val === 'string') { val = { sql: val }; } if (method === 'select' && this.single.as) { defaults.as = this.single.as; } var out = assign(defaults, val); debug(out); return out; }
javascript
function toSQL(method) { method = method || this.method; var val = this[method](); var defaults = { method: method, options: assign({}, this.options), bindings: this.formatter.bindings }; if (typeof val === 'string') { val = { sql: val }; } if (method === 'select' && this.single.as) { defaults.as = this.single.as; } var out = assign(defaults, val); debug(out); return out; }
[ "function", "toSQL", "(", "method", ")", "{", "method", "=", "method", "||", "this", ".", "method", ";", "var", "val", "=", "this", "[", "method", "]", "(", ")", ";", "var", "defaults", "=", "{", "method", ":", "method", ",", "options", ":", "assign", "(", "{", "}", ",", "this", ".", "options", ")", ",", "bindings", ":", "this", ".", "formatter", ".", "bindings", "}", ";", "if", "(", "typeof", "val", "===", "'string'", ")", "{", "val", "=", "{", "sql", ":", "val", "}", ";", "}", "if", "(", "method", "===", "'select'", "&&", "this", ".", "single", ".", "as", ")", "{", "defaults", ".", "as", "=", "this", ".", "single", ".", "as", ";", "}", "var", "out", "=", "assign", "(", "defaults", ",", "val", ")", ";", "debug", "(", "out", ")", ";", "return", "out", ";", "}" ]
Collapse the builder into a single object
[ "Collapse", "the", "builder", "into", "a", "single", "object" ]
4cc624975d359800961bf34cb74de97488d2efb5
https://github.com/AppGeo/cartodb/blob/4cc624975d359800961bf34cb74de97488d2efb5/lib/compiler.js#L43-L61
train
AppGeo/cartodb
lib/compiler.js
select
function select() { var i = -1, statements = []; while (++i < components.length) { statements.push(this[components[i]](this)); } return statements.filter(function (item) { return item; }).join(' '); }
javascript
function select() { var i = -1, statements = []; while (++i < components.length) { statements.push(this[components[i]](this)); } return statements.filter(function (item) { return item; }).join(' '); }
[ "function", "select", "(", ")", "{", "var", "i", "=", "-", "1", ",", "statements", "=", "[", "]", ";", "while", "(", "++", "i", "<", "components", ".", "length", ")", "{", "statements", ".", "push", "(", "this", "[", "components", "[", "i", "]", "]", "(", "this", ")", ")", ";", "}", "return", "statements", ".", "filter", "(", "function", "(", "item", ")", "{", "return", "item", ";", "}", ")", ".", "join", "(", "' '", ")", ";", "}" ]
Compiles the `select` statement, or nested sub-selects by calling each of the component compilers, trimming out the empties, and returning a generated query string.
[ "Compiles", "the", "select", "statement", "or", "nested", "sub", "-", "selects", "by", "calling", "each", "of", "the", "component", "compilers", "trimming", "out", "the", "empties", "and", "returning", "a", "generated", "query", "string", "." ]
4cc624975d359800961bf34cb74de97488d2efb5
https://github.com/AppGeo/cartodb/blob/4cc624975d359800961bf34cb74de97488d2efb5/lib/compiler.js#L66-L75
train
AppGeo/cartodb
lib/compiler.js
update
function update() { var updateData = this._prepUpdate(this.single.update); var wheres = this.where(); var returning = this.single.returning; return { sql: 'update ' + this.tableName + ' set ' + updateData.join(', ') + (wheres ? ' ' + wheres : '') + this._returning(returning), returning: returning }; }
javascript
function update() { var updateData = this._prepUpdate(this.single.update); var wheres = this.where(); var returning = this.single.returning; return { sql: 'update ' + this.tableName + ' set ' + updateData.join(', ') + (wheres ? ' ' + wheres : '') + this._returning(returning), returning: returning }; }
[ "function", "update", "(", ")", "{", "var", "updateData", "=", "this", ".", "_prepUpdate", "(", "this", ".", "single", ".", "update", ")", ";", "var", "wheres", "=", "this", ".", "where", "(", ")", ";", "var", "returning", "=", "this", ".", "single", ".", "returning", ";", "return", "{", "sql", ":", "'update '", "+", "this", ".", "tableName", "+", "' set '", "+", "updateData", ".", "join", "(", "', '", ")", "+", "(", "wheres", "?", "' '", "+", "wheres", ":", "''", ")", "+", "this", ".", "_returning", "(", "returning", ")", ",", "returning", ":", "returning", "}", ";", "}" ]
Compiles the "update" query.
[ "Compiles", "the", "update", "query", "." ]
4cc624975d359800961bf34cb74de97488d2efb5
https://github.com/AppGeo/cartodb/blob/4cc624975d359800961bf34cb74de97488d2efb5/lib/compiler.js#L125-L133
train
AppGeo/cartodb
lib/compiler.js
_columns
function _columns() { var distinct = false; if (this.onlyUnions()) { return ''; } var columns = this.grouped.columns || []; var i = -1, sql = []; if (columns) { while (++i < columns.length) { var stmt = columns[i]; if (stmt.distinct) { distinct = true; } if (stmt.type === 'aggregate') { sql.push(this.aggregate(stmt)); } else if (stmt.value && stmt.value.length > 0) { sql.push(this.formatter.columnize(stmt.value)); } } } if (sql.length === 0) { sql = ['*']; } return 'select ' + (distinct ? 'distinct ' : '') + sql.join(', ') + (this.tableName ? ' from ' + this.tableName : ''); }
javascript
function _columns() { var distinct = false; if (this.onlyUnions()) { return ''; } var columns = this.grouped.columns || []; var i = -1, sql = []; if (columns) { while (++i < columns.length) { var stmt = columns[i]; if (stmt.distinct) { distinct = true; } if (stmt.type === 'aggregate') { sql.push(this.aggregate(stmt)); } else if (stmt.value && stmt.value.length > 0) { sql.push(this.formatter.columnize(stmt.value)); } } } if (sql.length === 0) { sql = ['*']; } return 'select ' + (distinct ? 'distinct ' : '') + sql.join(', ') + (this.tableName ? ' from ' + this.tableName : ''); }
[ "function", "_columns", "(", ")", "{", "var", "distinct", "=", "false", ";", "if", "(", "this", ".", "onlyUnions", "(", ")", ")", "{", "return", "''", ";", "}", "var", "columns", "=", "this", ".", "grouped", ".", "columns", "||", "[", "]", ";", "var", "i", "=", "-", "1", ",", "sql", "=", "[", "]", ";", "if", "(", "columns", ")", "{", "while", "(", "++", "i", "<", "columns", ".", "length", ")", "{", "var", "stmt", "=", "columns", "[", "i", "]", ";", "if", "(", "stmt", ".", "distinct", ")", "{", "distinct", "=", "true", ";", "}", "if", "(", "stmt", ".", "type", "===", "'aggregate'", ")", "{", "sql", ".", "push", "(", "this", ".", "aggregate", "(", "stmt", ")", ")", ";", "}", "else", "if", "(", "stmt", ".", "value", "&&", "stmt", ".", "value", ".", "length", ">", "0", ")", "{", "sql", ".", "push", "(", "this", ".", "formatter", ".", "columnize", "(", "stmt", ".", "value", ")", ")", ";", "}", "}", "}", "if", "(", "sql", ".", "length", "===", "0", ")", "{", "sql", "=", "[", "'*'", "]", ";", "}", "return", "'select '", "+", "(", "distinct", "?", "'distinct '", ":", "''", ")", "+", "sql", ".", "join", "(", "', '", ")", "+", "(", "this", ".", "tableName", "?", "' from '", "+", "this", ".", "tableName", ":", "''", ")", ";", "}" ]
Compiles the columns in the query, specifying if an item was distinct.
[ "Compiles", "the", "columns", "in", "the", "query", "specifying", "if", "an", "item", "was", "distinct", "." ]
4cc624975d359800961bf34cb74de97488d2efb5
https://github.com/AppGeo/cartodb/blob/4cc624975d359800961bf34cb74de97488d2efb5/lib/compiler.js#L136-L161
train
AppGeo/cartodb
lib/compiler.js
_join
function _join() { var sql = '', i = -1, joins = this.grouped.join; if (!joins) { return ''; } while (++i < joins.length) { var join = joins[i]; if (i > 0) { sql += ' '; } if (join.joinType === 'raw') { sql += this.formatter.unwrapRaw(join.table); } else { sql += join.joinType + ' join ' + this.formatter.wrap(join.table); var ii = -1; while (++ii < join.clauses.length) { var clause = join.clauses[ii]; sql += ' ' + (ii > 0 ? clause[0] : clause[1]) + ' '; sql += this.formatter.wrap(clause[2]); if (clause[3]) { sql += ' ' + this.formatter.operator(clause[3]); } if (clause[4]) { sql += ' ' + this.formatter.wrap(clause[4]); } } } } return sql; }
javascript
function _join() { var sql = '', i = -1, joins = this.grouped.join; if (!joins) { return ''; } while (++i < joins.length) { var join = joins[i]; if (i > 0) { sql += ' '; } if (join.joinType === 'raw') { sql += this.formatter.unwrapRaw(join.table); } else { sql += join.joinType + ' join ' + this.formatter.wrap(join.table); var ii = -1; while (++ii < join.clauses.length) { var clause = join.clauses[ii]; sql += ' ' + (ii > 0 ? clause[0] : clause[1]) + ' '; sql += this.formatter.wrap(clause[2]); if (clause[3]) { sql += ' ' + this.formatter.operator(clause[3]); } if (clause[4]) { sql += ' ' + this.formatter.wrap(clause[4]); } } } } return sql; }
[ "function", "_join", "(", ")", "{", "var", "sql", "=", "''", ",", "i", "=", "-", "1", ",", "joins", "=", "this", ".", "grouped", ".", "join", ";", "if", "(", "!", "joins", ")", "{", "return", "''", ";", "}", "while", "(", "++", "i", "<", "joins", ".", "length", ")", "{", "var", "join", "=", "joins", "[", "i", "]", ";", "if", "(", "i", ">", "0", ")", "{", "sql", "+=", "' '", ";", "}", "if", "(", "join", ".", "joinType", "===", "'raw'", ")", "{", "sql", "+=", "this", ".", "formatter", ".", "unwrapRaw", "(", "join", ".", "table", ")", ";", "}", "else", "{", "sql", "+=", "join", ".", "joinType", "+", "' join '", "+", "this", ".", "formatter", ".", "wrap", "(", "join", ".", "table", ")", ";", "var", "ii", "=", "-", "1", ";", "while", "(", "++", "ii", "<", "join", ".", "clauses", ".", "length", ")", "{", "var", "clause", "=", "join", ".", "clauses", "[", "ii", "]", ";", "sql", "+=", "' '", "+", "(", "ii", ">", "0", "?", "clause", "[", "0", "]", ":", "clause", "[", "1", "]", ")", "+", "' '", ";", "sql", "+=", "this", ".", "formatter", ".", "wrap", "(", "clause", "[", "2", "]", ")", ";", "if", "(", "clause", "[", "3", "]", ")", "{", "sql", "+=", "' '", "+", "this", ".", "formatter", ".", "operator", "(", "clause", "[", "3", "]", ")", ";", "}", "if", "(", "clause", "[", "4", "]", ")", "{", "sql", "+=", "' '", "+", "this", ".", "formatter", ".", "wrap", "(", "clause", "[", "4", "]", ")", ";", "}", "}", "}", "}", "return", "sql", ";", "}" ]
Compiles all each of the `join` clauses on the query, including any nested join queries.
[ "Compiles", "all", "each", "of", "the", "join", "clauses", "on", "the", "query", "including", "any", "nested", "join", "queries", "." ]
4cc624975d359800961bf34cb74de97488d2efb5
https://github.com/AppGeo/cartodb/blob/4cc624975d359800961bf34cb74de97488d2efb5/lib/compiler.js#L177-L208
train