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
jmjuanes/logty
lib/timestamp.js
function () { let date = new Date(); let result = {}; let regex = /(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d).\d\d\dZ/g; let current = regex.exec(date.toJSON()); if (current === null || current.length < 7) { return null; } for (let i = 0; i < 6; i++) { //The first element ...
javascript
function () { let date = new Date(); let result = {}; let regex = /(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d).\d\d\dZ/g; let current = regex.exec(date.toJSON()); if (current === null || current.length < 7) { return null; } for (let i = 0; i < 6; i++) { //The first element ...
[ "function", "(", ")", "{", "let", "date", "=", "new", "Date", "(", ")", ";", "let", "result", "=", "{", "}", ";", "let", "regex", "=", "/", "(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)T(\\d\\d):(\\d\\d):(\\d\\d).\\d\\d\\dZ", "/", "g", ";", "let", "current", "=", "regex...
Get the current time
[ "Get", "the", "current", "time" ]
47c4f9ea65f9443f54bd2ccb6a7277fb7c12201b
https://github.com/jmjuanes/logty/blob/47c4f9ea65f9443f54bd2ccb6a7277fb7c12201b/lib/timestamp.js#L10-L23
train
MakerCollider/upm_mc
doxy/node/generators/jsdoc/generator.js
generateDocs
function generateDocs(specjs) { var docs = GENERATE_MODULE(specjs.MODULE); docs = _.reduce(specjs.METHODS, function(memo, methodSpec, methodName) { return memo += GENERATE_METHOD(methodName, methodSpec); }, docs); docs = _.reduce(specjs.ENUMS, function(memo, enumSpec, enumName) { return memo += GENERATE...
javascript
function generateDocs(specjs) { var docs = GENERATE_MODULE(specjs.MODULE); docs = _.reduce(specjs.METHODS, function(memo, methodSpec, methodName) { return memo += GENERATE_METHOD(methodName, methodSpec); }, docs); docs = _.reduce(specjs.ENUMS, function(memo, enumSpec, enumName) { return memo += GENERATE...
[ "function", "generateDocs", "(", "specjs", ")", "{", "var", "docs", "=", "GENERATE_MODULE", "(", "specjs", ".", "MODULE", ")", ";", "docs", "=", "_", ".", "reduce", "(", "specjs", ".", "METHODS", ",", "function", "(", "memo", ",", "methodSpec", ",", "m...
generate JSDoc-style documentation
[ "generate", "JSDoc", "-", "style", "documentation" ]
525e775a17b85c30716c00435a2acb26bb198c12
https://github.com/MakerCollider/upm_mc/blob/525e775a17b85c30716c00435a2acb26bb198c12/doxy/node/generators/jsdoc/generator.js#L30-L44
train
jamespdlynn/microjs
examples/game/lib/server.js
function(buffer){ //Deserialize binary data into a JSON object var data = micro.toJSON(buffer); var type = data._type; delete data._type; switch (type) { case "Ping" : ...
javascript
function(buffer){ //Deserialize binary data into a JSON object var data = micro.toJSON(buffer); var type = data._type; delete data._type; switch (type) { case "Ping" : ...
[ "function", "(", "buffer", ")", "{", "//Deserialize binary data into a JSON object", "var", "data", "=", "micro", ".", "toJSON", "(", "buffer", ")", ";", "var", "type", "=", "data", ".", "_type", ";", "delete", "data", ".", "_type", ";", "switch", "(", "ty...
Parse client sent binary data buffer
[ "Parse", "client", "sent", "binary", "data", "buffer" ]
780a4074de84bcd74e3ae50d0ed64144b4474166
https://github.com/jamespdlynn/microjs/blob/780a4074de84bcd74e3ae50d0ed64144b4474166/examples/game/lib/server.js#L194-L235
train
jamespdlynn/microjs
examples/game/lib/server.js
function(data){ data = data || {timestamps:[]}; data.timestamps.push(new Date().getTime()); send(connection, "Ping", data); }
javascript
function(data){ data = data || {timestamps:[]}; data.timestamps.push(new Date().getTime()); send(connection, "Ping", data); }
[ "function", "(", "data", ")", "{", "data", "=", "data", "||", "{", "timestamps", ":", "[", "]", "}", ";", "data", ".", "timestamps", ".", "push", "(", "new", "Date", "(", ")", ".", "getTime", "(", ")", ")", ";", "send", "(", "connection", ",", ...
Kick off the connection by pinging the client
[ "Kick", "off", "the", "connection", "by", "pinging", "the", "client" ]
780a4074de84bcd74e3ae50d0ed64144b4474166
https://github.com/jamespdlynn/microjs/blob/780a4074de84bcd74e3ae50d0ed64144b4474166/examples/game/lib/server.js#L238-L242
train
jamespdlynn/microjs
examples/game/lib/server.js
send
function send(conn,schemaName,json,byteLength){ var buffer = micro.toBinary(json, schemaName,byteLength); if (FAKE_LATENCY){ setTimeout(function(){ conn.sendBytes(buffer); },FAKE_LATENCY); }else{ conn.sendBytes(buffer); } }
javascript
function send(conn,schemaName,json,byteLength){ var buffer = micro.toBinary(json, schemaName,byteLength); if (FAKE_LATENCY){ setTimeout(function(){ conn.sendBytes(buffer); },FAKE_LATENCY); }else{ conn.sendBytes(buffer); } }
[ "function", "send", "(", "conn", ",", "schemaName", ",", "json", ",", "byteLength", ")", "{", "var", "buffer", "=", "micro", ".", "toBinary", "(", "json", ",", "schemaName", ",", "byteLength", ")", ";", "if", "(", "FAKE_LATENCY", ")", "{", "setTimeout", ...
Helper function that serializes a JSON data object according to a given schema, and then sends it through a given client connection @param {object} conn @param {string} schemaName @param {object} json @param {number} [byteLength]
[ "Helper", "function", "that", "serializes", "a", "JSON", "data", "object", "according", "to", "a", "given", "schema", "and", "then", "sends", "it", "through", "a", "given", "client", "connection" ]
780a4074de84bcd74e3ae50d0ed64144b4474166
https://github.com/jamespdlynn/microjs/blob/780a4074de84bcd74e3ae50d0ed64144b4474166/examples/game/lib/server.js#L259-L270
train
jamespdlynn/microjs
examples/game/lib/server.js
calculateLatency
function calculateLatency(timestamps){ var length = timestamps.length, sumLatency = 0; for (var i = 1; i < length; i++){ sumLatency += (timestamps[i] - timestamps[i-1])/2; } return (sumLatency/(length-1)); }
javascript
function calculateLatency(timestamps){ var length = timestamps.length, sumLatency = 0; for (var i = 1; i < length; i++){ sumLatency += (timestamps[i] - timestamps[i-1])/2; } return (sumLatency/(length-1)); }
[ "function", "calculateLatency", "(", "timestamps", ")", "{", "var", "length", "=", "timestamps", ".", "length", ",", "sumLatency", "=", "0", ";", "for", "(", "var", "i", "=", "1", ";", "i", "<", "length", ";", "i", "++", ")", "{", "sumLatency", "+=",...
Helper function that calculates the latency by getting the average of all the ping timestamps differences @param {Array.<number>} timestamps @returns {number}
[ "Helper", "function", "that", "calculates", "the", "latency", "by", "getting", "the", "average", "of", "all", "the", "ping", "timestamps", "differences" ]
780a4074de84bcd74e3ae50d0ed64144b4474166
https://github.com/jamespdlynn/microjs/blob/780a4074de84bcd74e3ae50d0ed64144b4474166/examples/game/lib/server.js#L278-L287
train
macbre/tap-eater
lib/tap-eater.js
eat
function eat(stream, callback) { if (!stream instanceof Stream) { throw 'eat() accepts Stream only!'; } this.callback = callback; this.consumer = new TapConsumer(); this.report = { pass: false, skip: false, fail: false, total: false, failures: [], text: '' }; // setup events this....
javascript
function eat(stream, callback) { if (!stream instanceof Stream) { throw 'eat() accepts Stream only!'; } this.callback = callback; this.consumer = new TapConsumer(); this.report = { pass: false, skip: false, fail: false, total: false, failures: [], text: '' }; // setup events this....
[ "function", "eat", "(", "stream", ",", "callback", ")", "{", "if", "(", "!", "stream", "instanceof", "Stream", ")", "{", "throw", "'eat() accepts Stream only!'", ";", "}", "this", ".", "callback", "=", "callback", ";", "this", ".", "consumer", "=", "new", ...
consumes TAP data from given stream
[ "consumes", "TAP", "data", "from", "given", "stream" ]
a4079972a021756ab1c58a433578d264305551ff
https://github.com/macbre/tap-eater/blob/a4079972a021756ab1c58a433578d264305551ff/lib/tap-eater.js#L102-L126
train
gethuman/pancakes-recipe
middleware/mw.service.init.js
init
function init(ctx) { var container = ctx.container; // reactors can be initialized without a promise since just attaching event handlers initReactors(container); // adapters and services may be making database calls, so do with promises return initAdapters(container) ...
javascript
function init(ctx) { var container = ctx.container; // reactors can be initialized without a promise since just attaching event handlers initReactors(container); // adapters and services may be making database calls, so do with promises return initAdapters(container) ...
[ "function", "init", "(", "ctx", ")", "{", "var", "container", "=", "ctx", ".", "container", ";", "// reactors can be initialized without a promise since just attaching event handlers", "initReactors", "(", "container", ")", ";", "// adapters and services may be making database ...
Initialize all the reactors, adapters and services @returns {Q}
[ "Initialize", "all", "the", "reactors", "adapters", "and", "services" ]
ea3feb8839e2edaf1b4577c052b8958953db4498
https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.service.init.js#L14-L28
train
gethuman/pancakes-recipe
middleware/mw.service.init.js
reactHandler
function reactHandler(reactData) { return function (eventData) { // handler should always be run asynchronously setTimeout(function () { var payload = eventData.payload; var inputData = payload.inputData; var reactor = reactors[reactData.t...
javascript
function reactHandler(reactData) { return function (eventData) { // handler should always be run asynchronously setTimeout(function () { var payload = eventData.payload; var inputData = payload.inputData; var reactor = reactors[reactData.t...
[ "function", "reactHandler", "(", "reactData", ")", "{", "return", "function", "(", "eventData", ")", "{", "// handler should always be run asynchronously", "setTimeout", "(", "function", "(", ")", "{", "var", "payload", "=", "eventData", ".", "payload", ";", "var"...
Get handler for a react event @param reactData @returns {Function}
[ "Get", "handler", "for", "a", "react", "event" ]
ea3feb8839e2edaf1b4577c052b8958953db4498
https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.service.init.js#L35-L69
train
gethuman/pancakes-recipe
middleware/mw.service.init.js
initReactors
function initReactors(container) { var isBatch = container === 'batch'; // loop through each reactor and call init if it exists _.each(reactors, function (reactor) { if (reactor.init) { reactor.init({ config: config, pancakes: pancakes }); } }); ...
javascript
function initReactors(container) { var isBatch = container === 'batch'; // loop through each reactor and call init if it exists _.each(reactors, function (reactor) { if (reactor.init) { reactor.init({ config: config, pancakes: pancakes }); } }); ...
[ "function", "initReactors", "(", "container", ")", "{", "var", "isBatch", "=", "container", "===", "'batch'", ";", "// loop through each reactor and call init if it exists", "_", ".", "each", "(", "reactors", ",", "function", "(", "reactor", ")", "{", "if", "(", ...
Call all reactor init functions and attach reactors based on reactor data within resource files. @param container
[ "Call", "all", "reactor", "init", "functions", "and", "attach", "reactors", "based", "on", "reactor", "data", "within", "resource", "files", "." ]
ea3feb8839e2edaf1b4577c052b8958953db4498
https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.service.init.js#L76-L103
train
gethuman/pancakes-recipe
middleware/mw.service.init.js
initAdapters
function initAdapters(container) { var calls = []; if (container === 'webserver') { _.each(adapters, function (adapter) { if (adapter.webInit) { calls.push(adapter.webInit); } }); } else { _.each(ad...
javascript
function initAdapters(container) { var calls = []; if (container === 'webserver') { _.each(adapters, function (adapter) { if (adapter.webInit) { calls.push(adapter.webInit); } }); } else { _.each(ad...
[ "function", "initAdapters", "(", "container", ")", "{", "var", "calls", "=", "[", "]", ";", "if", "(", "container", "===", "'webserver'", ")", "{", "_", ".", "each", "(", "adapters", ",", "function", "(", "adapter", ")", "{", "if", "(", "adapter", "....
Initialize the adapters as long as the container is no webserver @param container @returns {*}
[ "Initialize", "the", "adapters", "as", "long", "as", "the", "container", "is", "no", "webserver" ]
ea3feb8839e2edaf1b4577c052b8958953db4498
https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.service.init.js#L111-L139
train
derdesign/protos
lib/application.js
function() { var args = [].slice.call(arguments, 0); var workerMessage, done = 0; var workerKeys = Object.keys(cluster.workers); var nextWorker = function() { if (workerKeys.length) { done++; cluster.workers[workerKeys.shift()].send(taskMessage.concat([a...
javascript
function() { var args = [].slice.call(arguments, 0); var workerMessage, done = 0; var workerKeys = Object.keys(cluster.workers); var nextWorker = function() { if (workerKeys.length) { done++; cluster.workers[workerKeys.shift()].send(taskMessage.concat([a...
[ "function", "(", ")", "{", "var", "args", "=", "[", "]", ".", "slice", ".", "call", "(", "arguments", ",", "0", ")", ";", "var", "workerMessage", ",", "done", "=", "0", ";", "var", "workerKeys", "=", "Object", ".", "keys", "(", "cluster", ".", "w...
Master 1. Listen for worker messages and send task to all workers on receive Sends a message to all workers to run the task
[ "Master", "1", ".", "Listen", "for", "worker", "messages", "and", "send", "task", "to", "all", "workers", "on", "receive", "Sends", "a", "message", "to", "all", "workers", "to", "run", "the", "task" ]
0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9
https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/lib/application.js#L489-L508
train
derdesign/protos
lib/application.js
buildPartialView
function buildPartialView(path) { var self = this; var layoutPrefix = /^layout_/; var p = pathModule.basename(path); var pos = p.indexOf('.'); var ext = p.slice(pos+1); if (ext in this.enginesByExtension) { var engine = this.enginesByExtension[ext]; var func = engine.renderPartial(path)...
javascript
function buildPartialView(path) { var self = this; var layoutPrefix = /^layout_/; var p = pathModule.basename(path); var pos = p.indexOf('.'); var ext = p.slice(pos+1); if (ext in this.enginesByExtension) { var engine = this.enginesByExtension[ext]; var func = engine.renderPartial(path)...
[ "function", "buildPartialView", "(", "path", ")", "{", "var", "self", "=", "this", ";", "var", "layoutPrefix", "=", "/", "^layout_", "/", ";", "var", "p", "=", "pathModule", ".", "basename", "(", "path", ")", ";", "var", "pos", "=", "p", ".", "indexO...
Builds a partial view and caches its function
[ "Builds", "a", "partial", "view", "and", "caches", "its", "function" ]
0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9
https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/lib/application.js#L1910-L1954
train
derdesign/protos
lib/application.js
getDriverInstance
function getDriverInstance(driver, config) { if (!(driver in protos.drivers)) throw new Error(util.format("The '%s' driver is not loaded. Load it with app.loadDrivers('%s')", driver, driver)); return new protos.drivers[driver](config || {}); }
javascript
function getDriverInstance(driver, config) { if (!(driver in protos.drivers)) throw new Error(util.format("The '%s' driver is not loaded. Load it with app.loadDrivers('%s')", driver, driver)); return new protos.drivers[driver](config || {}); }
[ "function", "getDriverInstance", "(", "driver", ",", "config", ")", "{", "if", "(", "!", "(", "driver", "in", "protos", ".", "drivers", ")", ")", "throw", "new", "Error", "(", "util", ".", "format", "(", "\"The '%s' driver is not loaded. Load it with app.loadDri...
Returns a new driver instance
[ "Returns", "a", "new", "driver", "instance" ]
0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9
https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/lib/application.js#L1958-L1961
train
derdesign/protos
lib/application.js
getStorageInstance
function getStorageInstance(storage, config) { if (!(storage in protos.storages)) throw new Error(util.format("The '%s' storage is not loaded. Load it with app.loadStorages('%s')", storage, storage)); return new protos.storages[storage](config || {}); }
javascript
function getStorageInstance(storage, config) { if (!(storage in protos.storages)) throw new Error(util.format("The '%s' storage is not loaded. Load it with app.loadStorages('%s')", storage, storage)); return new protos.storages[storage](config || {}); }
[ "function", "getStorageInstance", "(", "storage", ",", "config", ")", "{", "if", "(", "!", "(", "storage", "in", "protos", ".", "storages", ")", ")", "throw", "new", "Error", "(", "util", ".", "format", "(", "\"The '%s' storage is not loaded. Load it with app.lo...
Returns a new storage instance
[ "Returns", "a", "new", "storage", "instance" ]
0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9
https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/lib/application.js#L1965-L1968
train
derdesign/protos
lib/application.js
loadControllers
function loadControllers() { // Note: runs on app context // Get controllers/ var cpath = this.mvcpath + 'controllers/', files = protos.util.getFiles(cpath); // Create controllers and attach to app var controllerCtor = protos.lib.controller; for (var controller, key, file, instance, className, ...
javascript
function loadControllers() { // Note: runs on app context // Get controllers/ var cpath = this.mvcpath + 'controllers/', files = protos.util.getFiles(cpath); // Create controllers and attach to app var controllerCtor = protos.lib.controller; for (var controller, key, file, instance, className, ...
[ "function", "loadControllers", "(", ")", "{", "// Note: runs on app context", "// Get controllers/", "var", "cpath", "=", "this", ".", "mvcpath", "+", "'controllers/'", ",", "files", "=", "protos", ".", "util", ".", "getFiles", "(", "cpath", ")", ";", "// Create...
Loads controllers & routes
[ "Loads", "controllers", "&", "routes" ]
0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9
https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/lib/application.js#L1972-L1997
train
derdesign/protos
lib/application.js
processControllerHandlers
function processControllerHandlers() { var self = this; var jsFile = this.regex.jsFile; var handlersPath = this.mvcpath + 'handlers'; var relPath = self.relPath(this.mvcpath) + 'handlers'; if (fs.existsSync(handlersPath)) { fs.readdirSync(handlersPath).forEach(function(dirname) { var dir = h...
javascript
function processControllerHandlers() { var self = this; var jsFile = this.regex.jsFile; var handlersPath = this.mvcpath + 'handlers'; var relPath = self.relPath(this.mvcpath) + 'handlers'; if (fs.existsSync(handlersPath)) { fs.readdirSync(handlersPath).forEach(function(dirname) { var dir = h...
[ "function", "processControllerHandlers", "(", ")", "{", "var", "self", "=", "this", ";", "var", "jsFile", "=", "this", ".", "regex", ".", "jsFile", ";", "var", "handlersPath", "=", "this", ".", "mvcpath", "+", "'handlers'", ";", "var", "relPath", "=", "s...
Processes controller handlers
[ "Processes", "controller", "handlers" ]
0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9
https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/lib/application.js#L2001-L2041
train
derdesign/protos
lib/application.js
parseConfig
function parseConfig() { // Get main config var p = this.path + '/config/', files = protos.util.getFiles(p), mainPos = files.indexOf('base.js'), jsExt = protos.regex.jsFile, configFile = this.path + '/config.js'; // If config.js is not present, use the one from skeleton to provide defa...
javascript
function parseConfig() { // Get main config var p = this.path + '/config/', files = protos.util.getFiles(p), mainPos = files.indexOf('base.js'), jsExt = protos.regex.jsFile, configFile = this.path + '/config.js'; // If config.js is not present, use the one from skeleton to provide defa...
[ "function", "parseConfig", "(", ")", "{", "// Get main config", "var", "p", "=", "this", ".", "path", "+", "'/config/'", ",", "files", "=", "protos", ".", "util", ".", "getFiles", "(", "p", ")", ",", "mainPos", "=", "files", ".", "indexOf", "(", "'base...
Parses the application configuration
[ "Parses", "the", "application", "configuration" ]
0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9
https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/lib/application.js#L2045-L2074
train
derdesign/protos
lib/application.js
watchPartial
function watchPartial(path, callback) { // Don't watch partials again when reloading if (this.watchPartials && RELOADING === false) { var self = this; self.debug('Watching Partial for changes: %s', self.relPath(path, 'app/views')); var watcher = chokidar.watch(path, {interval: self.confi...
javascript
function watchPartial(path, callback) { // Don't watch partials again when reloading if (this.watchPartials && RELOADING === false) { var self = this; self.debug('Watching Partial for changes: %s', self.relPath(path, 'app/views')); var watcher = chokidar.watch(path, {interval: self.confi...
[ "function", "watchPartial", "(", "path", ",", "callback", ")", "{", "// Don't watch partials again when reloading", "if", "(", "this", ".", "watchPartials", "&&", "RELOADING", "===", "false", ")", "{", "var", "self", "=", "this", ";", "self", ".", "debug", "("...
Watches a view Partial for changes
[ "Watches", "a", "view", "Partial", "for", "changes" ]
0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9
https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/lib/application.js#L2078-L2107
train
derdesign/protos
lib/application.js
parseDriverConfig
function parseDriverConfig() { var cfg, def, x, y, z, config = this.config.drivers, drivers = this.drivers; if (!config) config = this.config.drivers = {}; if (Object.keys(config).length === 0) return; for (x in config) { cfg = config[x]; if (x == 'default') { def = cfg; continue; } ...
javascript
function parseDriverConfig() { var cfg, def, x, y, z, config = this.config.drivers, drivers = this.drivers; if (!config) config = this.config.drivers = {}; if (Object.keys(config).length === 0) return; for (x in config) { cfg = config[x]; if (x == 'default') { def = cfg; continue; } ...
[ "function", "parseDriverConfig", "(", ")", "{", "var", "cfg", ",", "def", ",", "x", ",", "y", ",", "z", ",", "config", "=", "this", ".", "config", ".", "drivers", ",", "drivers", "=", "this", ".", "drivers", ";", "if", "(", "!", "config", ")", "c...
Parses database drivers from config
[ "Parses", "database", "drivers", "from", "config" ]
0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9
https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/lib/application.js#L2111-L2134
train
derdesign/protos
lib/application.js
parseStorageConfig
function parseStorageConfig() { var cfg, x, y, z, config = this.config.storages, storages = this.storages; if (!config) config = this.config.storages = {}; if (Object.keys(config).length === 0) return; for (x in config) { cfg = config[x]; for (y in cfg) { if (typeof cfg[y] == ...
javascript
function parseStorageConfig() { var cfg, x, y, z, config = this.config.storages, storages = this.storages; if (!config) config = this.config.storages = {}; if (Object.keys(config).length === 0) return; for (x in config) { cfg = config[x]; for (y in cfg) { if (typeof cfg[y] == ...
[ "function", "parseStorageConfig", "(", ")", "{", "var", "cfg", ",", "x", ",", "y", ",", "z", ",", "config", "=", "this", ".", "config", ".", "storages", ",", "storages", "=", "this", ".", "storages", ";", "if", "(", "!", "config", ")", "config", "=...
Parses storages from config
[ "Parses", "storages", "from", "config" ]
0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9
https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/lib/application.js#L2138-L2159
train
derdesign/protos
lib/application.js
loadAPI
function loadAPI() { var apiPath = this.fullPath(this.paths.api); if (fs.existsSync(apiPath) && fs.statSync(apiPath).isDirectory()) { var files = protos.util.ls(apiPath, this.regex.jsFile); files.forEach(function(file) { var methods = protos.require(apiPath + "/" + file, true); // Don't use module cac...
javascript
function loadAPI() { var apiPath = this.fullPath(this.paths.api); if (fs.existsSync(apiPath) && fs.statSync(apiPath).isDirectory()) { var files = protos.util.ls(apiPath, this.regex.jsFile); files.forEach(function(file) { var methods = protos.require(apiPath + "/" + file, true); // Don't use module cac...
[ "function", "loadAPI", "(", ")", "{", "var", "apiPath", "=", "this", ".", "fullPath", "(", "this", ".", "paths", ".", "api", ")", ";", "if", "(", "fs", ".", "existsSync", "(", "apiPath", ")", "&&", "fs", ".", "statSync", "(", "apiPath", ")", ".", ...
Loads the Application API
[ "Loads", "the", "Application", "API" ]
0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9
https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/lib/application.js#L2289-L2299
train
derdesign/protos
lib/application.js
loadHooks
function loadHooks() { var events = this._events; var jsFile = /\.js$/i; var hooksPath = this.fullPath('hook'); var loadedHooks = []; if (fs.existsSync(hooksPath)) { var files = protos.util.ls(hooksPath, jsFile); for (var cb,idx,evt,file,len=files.length,i=0; i < len; i++) { file = files[i]; ...
javascript
function loadHooks() { var events = this._events; var jsFile = /\.js$/i; var hooksPath = this.fullPath('hook'); var loadedHooks = []; if (fs.existsSync(hooksPath)) { var files = protos.util.ls(hooksPath, jsFile); for (var cb,idx,evt,file,len=files.length,i=0; i < len; i++) { file = files[i]; ...
[ "function", "loadHooks", "(", ")", "{", "var", "events", "=", "this", ".", "_events", ";", "var", "jsFile", "=", "/", "\\.js$", "/", "i", ";", "var", "hooksPath", "=", "this", ".", "fullPath", "(", "'hook'", ")", ";", "var", "loadedHooks", "=", "[", ...
Loads application hooks
[ "Loads", "application", "hooks" ]
0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9
https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/lib/application.js#L2303-L2361
train
derdesign/protos
lib/application.js
loadEngines
function loadEngines() { // Initialize engine properties this.enginesByExtension = {}; // Engine local variables var exts = []; var loadedEngines = this.loadedEngines = Object.keys(protos.engines); if (loadedEngines.length > 0) { // Get view engines var engine, instance, engineProps = ...
javascript
function loadEngines() { // Initialize engine properties this.enginesByExtension = {}; // Engine local variables var exts = []; var loadedEngines = this.loadedEngines = Object.keys(protos.engines); if (loadedEngines.length > 0) { // Get view engines var engine, instance, engineProps = ...
[ "function", "loadEngines", "(", ")", "{", "// Initialize engine properties", "this", ".", "enginesByExtension", "=", "{", "}", ";", "// Engine local variables", "var", "exts", "=", "[", "]", ";", "var", "loadedEngines", "=", "this", ".", "loadedEngines", "=", "O...
Loads view engines
[ "Loads", "view", "engines" ]
0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9
https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/lib/application.js#L2365-L2428
train
derdesign/protos
lib/application.js
buildTemplatePartial
function buildTemplatePartial(path) { var tplDir = app.mvcpath + app.paths.templates; var p = path.replace(tplDir, ''); var pos = p.indexOf('.'); var ext = p.slice(pos+1); var tpl = p.slice(0,pos); if (ext in this.enginesByExtension) { var engine = this.enginesByExtension[ext]; var func = e...
javascript
function buildTemplatePartial(path) { var tplDir = app.mvcpath + app.paths.templates; var p = path.replace(tplDir, ''); var pos = p.indexOf('.'); var ext = p.slice(pos+1); var tpl = p.slice(0,pos); if (ext in this.enginesByExtension) { var engine = this.enginesByExtension[ext]; var func = e...
[ "function", "buildTemplatePartial", "(", "path", ")", "{", "var", "tplDir", "=", "app", ".", "mvcpath", "+", "app", ".", "paths", ".", "templates", ";", "var", "p", "=", "path", ".", "replace", "(", "tplDir", ",", "''", ")", ";", "var", "pos", "=", ...
Builds a template partial
[ "Builds", "a", "template", "partial" ]
0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9
https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/lib/application.js#L2542-L2566
train
derdesign/protos
lib/application.js
setupViewPartials
function setupViewPartials() { // Set view path association object this.views.pathAsoc = {}; // Partial & template regexes var self = this; var exts = this.templateExtensions; var partialRegex = new RegExp('\/views\/(.+)\/partials\/[a-zA-Z0-9-_]+\\.(' + exts.join('|') + ')$'); var templateRegex = new ...
javascript
function setupViewPartials() { // Set view path association object this.views.pathAsoc = {}; // Partial & template regexes var self = this; var exts = this.templateExtensions; var partialRegex = new RegExp('\/views\/(.+)\/partials\/[a-zA-Z0-9-_]+\\.(' + exts.join('|') + ')$'); var templateRegex = new ...
[ "function", "setupViewPartials", "(", ")", "{", "// Set view path association object", "this", ".", "views", ".", "pathAsoc", "=", "{", "}", ";", "// Partial & template regexes", "var", "self", "=", "this", ";", "var", "exts", "=", "this", ".", "templateExtensions...
Configures View Partials
[ "Configures", "View", "Partials" ]
0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9
https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/lib/application.js#L2570-L2688
train
derdesign/protos
lib/application.js
createControllerFunction
function createControllerFunction(func) { var Handlebars = protos.require('handlebars'); var context, newFunc, compile, source, funcSrc = func.toString(); var code = funcSrc .trim() .replace(/^function\s+(.*?)(\s+)?\{(\s+)?/, '') .replace(/(\s+)?\}$/, ''); // Get source file path var...
javascript
function createControllerFunction(func) { var Handlebars = protos.require('handlebars'); var context, newFunc, compile, source, funcSrc = func.toString(); var code = funcSrc .trim() .replace(/^function\s+(.*?)(\s+)?\{(\s+)?/, '') .replace(/(\s+)?\}$/, ''); // Get source file path var...
[ "function", "createControllerFunction", "(", "func", ")", "{", "var", "Handlebars", "=", "protos", ".", "require", "(", "'handlebars'", ")", ";", "var", "context", ",", "newFunc", ",", "compile", ",", "source", ",", "funcSrc", "=", "func", ".", "toString", ...
Converts a regular function into a controller constructor
[ "Converts", "a", "regular", "function", "into", "a", "controller", "constructor" ]
0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9
https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/lib/application.js#L2692-L2777
train
yefremov/aggregatejs
percentile.js
percentile
function percentile(array, k) { var length = array.length; if (length === 0) { return 0; } if (typeof k !== 'number') { throw new TypeError('k must be a number'); } if (k <= 0) { return array[0]; } if (k >= 1) { return array[length - 1]; } array.sort(function (a, b) { return...
javascript
function percentile(array, k) { var length = array.length; if (length === 0) { return 0; } if (typeof k !== 'number') { throw new TypeError('k must be a number'); } if (k <= 0) { return array[0]; } if (k >= 1) { return array[length - 1]; } array.sort(function (a, b) { return...
[ "function", "percentile", "(", "array", ",", "k", ")", "{", "var", "length", "=", "array", ".", "length", ";", "if", "(", "length", "===", "0", ")", "{", "return", "0", ";", "}", "if", "(", "typeof", "k", "!==", "'number'", ")", "{", "throw", "ne...
Returns the `k`-th percentile of values in `array`. @param {Array} array Range of data that defines relative standing. @param {number} k The percentile value that is between 0 through 1. @return {number} @example percentile([100, -100, 150, -50, 100, 250], 0.25); // => -12.5 percentile([100, -100, 150, -50, 100, 250...
[ "Returns", "the", "k", "-", "th", "percentile", "of", "values", "in", "array", "." ]
932b28a15a5707135e7095950000a838db409511
https://github.com/yefremov/aggregatejs/blob/932b28a15a5707135e7095950000a838db409511/percentile.js#L26-L59
train
lepisma/coelacanth
src.js
mergeObject
function mergeObject (oldObject, newObject) { let oldCopy = Object.assign({}, oldObject) function _merge (oo, no) { for (let key in no) { if (key in oo) { // Follow structure of oo if (oo[key] === Object(oo[key])) { _merge(oo[key], no[key]) } else if (no[key] !== Object(...
javascript
function mergeObject (oldObject, newObject) { let oldCopy = Object.assign({}, oldObject) function _merge (oo, no) { for (let key in no) { if (key in oo) { // Follow structure of oo if (oo[key] === Object(oo[key])) { _merge(oo[key], no[key]) } else if (no[key] !== Object(...
[ "function", "mergeObject", "(", "oldObject", ",", "newObject", ")", "{", "let", "oldCopy", "=", "Object", ".", "assign", "(", "{", "}", ",", "oldObject", ")", "function", "_merge", "(", "oo", ",", "no", ")", "{", "for", "(", "let", "key", "in", "no",...
Merge two objects with nested data
[ "Merge", "two", "objects", "with", "nested", "data" ]
fdfa70dadafe5f74850eb1f8eba41ce7a9ac56a1
https://github.com/lepisma/coelacanth/blob/fdfa70dadafe5f74850eb1f8eba41ce7a9ac56a1/src.js#L4-L25
train
subfuzion/snapfinder-lib
main.js
connect
function connect(mongodbUri, callback) { snapdb.connect(mongodbUri, function(err, client) { if (err) return callback(err); callback(null, client); }); }
javascript
function connect(mongodbUri, callback) { snapdb.connect(mongodbUri, function(err, client) { if (err) return callback(err); callback(null, client); }); }
[ "function", "connect", "(", "mongodbUri", ",", "callback", ")", "{", "snapdb", ".", "connect", "(", "mongodbUri", ",", "function", "(", "err", ",", "client", ")", "{", "if", "(", "err", ")", "return", "callback", "(", "err", ")", ";", "callback", "(", ...
Connect to the snapdb mongo database.
[ "Connect", "to", "the", "snapdb", "mongo", "database", "." ]
121172f10a9ec64bc5f3d749fba97662b336caae
https://github.com/subfuzion/snapfinder-lib/blob/121172f10a9ec64bc5f3d749fba97662b336caae/main.js#L16-L21
train
subfuzion/snapfinder-lib
main.js
findStoresInZip
function findStoresInZip(address, callback) { geo.geocode(address, function(err, georesult) { if (err) return callback(err); snapdb.findStoresInZip(georesult.zip5, function(err, stores) { if (err) return callback(err); georesult.stores = stores; return callback(null, georesult); }); }...
javascript
function findStoresInZip(address, callback) { geo.geocode(address, function(err, georesult) { if (err) return callback(err); snapdb.findStoresInZip(georesult.zip5, function(err, stores) { if (err) return callback(err); georesult.stores = stores; return callback(null, georesult); }); }...
[ "function", "findStoresInZip", "(", "address", ",", "callback", ")", "{", "geo", ".", "geocode", "(", "address", ",", "function", "(", "err", ",", "georesult", ")", "{", "if", "(", "err", ")", "return", "callback", "(", "err", ")", ";", "snapdb", ".", ...
Find stores within a zip code. @param address a valid address, address fragment, or pair of coordinates
[ "Find", "stores", "within", "a", "zip", "code", "." ]
121172f10a9ec64bc5f3d749fba97662b336caae
https://github.com/subfuzion/snapfinder-lib/blob/121172f10a9ec64bc5f3d749fba97662b336caae/main.js#L66-L76
train
subfuzion/snapfinder-lib
main.js
sortStoresByDistance
function sortStoresByDistance(location, stores) { var i, s; for (i = 0; i < stores.length; i++) { s = stores[i]; s.distance = geo.getDistanceInMiles(location, { lat:s.latitude, lng:s.longitude }); } stores.sort(function(a,b) { return a.distance - b.distance; }); return stores; }
javascript
function sortStoresByDistance(location, stores) { var i, s; for (i = 0; i < stores.length; i++) { s = stores[i]; s.distance = geo.getDistanceInMiles(location, { lat:s.latitude, lng:s.longitude }); } stores.sort(function(a,b) { return a.distance - b.distance; }); return stores; }
[ "function", "sortStoresByDistance", "(", "location", ",", "stores", ")", "{", "var", "i", ",", "s", ";", "for", "(", "i", "=", "0", ";", "i", "<", "stores", ".", "length", ";", "i", "++", ")", "{", "s", "=", "stores", "[", "i", "]", ";", "s", ...
Sorts the stores array in distance order from location, and also returns it. @param location an object with lat and lng properties @param stores an array of store objects
[ "Sorts", "the", "stores", "array", "in", "distance", "order", "from", "location", "and", "also", "returns", "it", "." ]
121172f10a9ec64bc5f3d749fba97662b336caae
https://github.com/subfuzion/snapfinder-lib/blob/121172f10a9ec64bc5f3d749fba97662b336caae/main.js#L83-L94
train
peerigon/value
lib/value.js
setup
function setup(subject) { context.subject = subject; context.subjectType = null; context.subjectConstructor = null; context.isSet = false; }
javascript
function setup(subject) { context.subject = subject; context.subjectType = null; context.subjectConstructor = null; context.isSet = false; }
[ "function", "setup", "(", "subject", ")", "{", "context", ".", "subject", "=", "subject", ";", "context", ".", "subjectType", "=", "null", ";", "context", ".", "subjectConstructor", "=", "null", ";", "context", ".", "isSet", "=", "false", ";", "}" ]
Resets all values of the context object. @private @param subject
[ "Resets", "all", "values", "of", "the", "context", "object", "." ]
5cdaad2c9c5d9431b0d123196571f1e708e42b40
https://github.com/peerigon/value/blob/5cdaad2c9c5d9431b0d123196571f1e708e42b40/lib/value.js#L211-L216
train
MaximTovstashev/brest
lib/utils/reject_fields.js
rejectFields
function rejectFields(result, fields) { // If result is an array, then rejection rules are applied to each array entry if (_.isArray(result)) { return _.map(result, (single_entry) => _.omit(single_entry, fields)); } return _.omit(result, fields); }
javascript
function rejectFields(result, fields) { // If result is an array, then rejection rules are applied to each array entry if (_.isArray(result)) { return _.map(result, (single_entry) => _.omit(single_entry, fields)); } return _.omit(result, fields); }
[ "function", "rejectFields", "(", "result", ",", "fields", ")", "{", "// If result is an array, then rejection rules are applied to each array entry", "if", "(", "_", ".", "isArray", "(", "result", ")", ")", "{", "return", "_", ".", "map", "(", "result", ",", "(", ...
Reject fields from result @param result @param fields @return {*}
[ "Reject", "fields", "from", "result" ]
9b0bd6ee452e55b86cd01d1647f0dff460ad191f
https://github.com/MaximTovstashev/brest/blob/9b0bd6ee452e55b86cd01d1647f0dff460ad191f/lib/utils/reject_fields.js#L9-L15
train
jonschlinkert/detect-conflicts
index.js
stringDiff
function stringDiff(existing, proposed, method) { method = method || 'diffJson'; lazy.diff[method](existing, proposed).forEach(function (res) { var color = utils.gray; if (res.added) color = utils.green; if (res.removed) color = utils.red; process.stdout.write(color(res.value)); }); console.log(...
javascript
function stringDiff(existing, proposed, method) { method = method || 'diffJson'; lazy.diff[method](existing, proposed).forEach(function (res) { var color = utils.gray; if (res.added) color = utils.green; if (res.removed) color = utils.red; process.stdout.write(color(res.value)); }); console.log(...
[ "function", "stringDiff", "(", "existing", ",", "proposed", ",", "method", ")", "{", "method", "=", "method", "||", "'diffJson'", ";", "lazy", ".", "diff", "[", "method", "]", "(", "existing", ",", "proposed", ")", ".", "forEach", "(", "function", "(", ...
Show a diff comparison of the existing content versus the content about to be written. @param {String} `existing` @param {String} `proposed` @param {String} method Optionally pass a specific method name from the [diff] library to use for the diff. @return {String} Visual diff comparison.
[ "Show", "a", "diff", "comparison", "of", "the", "existing", "content", "versus", "the", "content", "about", "to", "be", "written", "." ]
851acf9e57923eb791e9974ad92b4cba5c7fe44e
https://github.com/jonschlinkert/detect-conflicts/blob/851acf9e57923eb791e9974ad92b4cba5c7fe44e/index.js#L94-L103
train
jonschlinkert/detect-conflicts
index.js
ask
function ask(file, opts, cb) { if (typeof opts === 'function') { cb = opts; opts = {}; } opts = opts || {}; var prompt = lazy.inquirer.createPromptModule(); var fp = path.relative(process.cwd(), file.path); var questions = { name: 'action', type: 'expand', message: 'Overwrite `' + fp + ...
javascript
function ask(file, opts, cb) { if (typeof opts === 'function') { cb = opts; opts = {}; } opts = opts || {}; var prompt = lazy.inquirer.createPromptModule(); var fp = path.relative(process.cwd(), file.path); var questions = { name: 'action', type: 'expand', message: 'Overwrite `' + fp + ...
[ "function", "ask", "(", "file", ",", "opts", ",", "cb", ")", "{", "if", "(", "typeof", "opts", "===", "'function'", ")", "{", "cb", "=", "opts", ";", "opts", "=", "{", "}", ";", "}", "opts", "=", "opts", "||", "{", "}", ";", "var", "prompt", ...
Prompt the user for feedback. @param {Object} `file` @param {Function} `cb`
[ "Prompt", "the", "user", "for", "feedback", "." ]
851acf9e57923eb791e9974ad92b4cba5c7fe44e
https://github.com/jonschlinkert/detect-conflicts/blob/851acf9e57923eb791e9974ad92b4cba5c7fe44e/index.js#L112-L196
train
willemdewit/java.properties.js
lib/java.properties.js
splitEscaped
function splitEscaped(src, separator) { let escapeFlag = false, token = '', result = []; src.split('').forEach(letter => { if (escapeFlag) { token += letter; escapeFlag = false; } else if (letter === '\\') { escapeFlag = true; } else if...
javascript
function splitEscaped(src, separator) { let escapeFlag = false, token = '', result = []; src.split('').forEach(letter => { if (escapeFlag) { token += letter; escapeFlag = false; } else if (letter === '\\') { escapeFlag = true; } else if...
[ "function", "splitEscaped", "(", "src", ",", "separator", ")", "{", "let", "escapeFlag", "=", "false", ",", "token", "=", "''", ",", "result", "=", "[", "]", ";", "src", ".", "split", "(", "''", ")", ".", "forEach", "(", "letter", "=>", "{", "if", ...
Split a string using a separator, if not preceded by a backslash. For simplicity, this does not correctly handle two preceding backslashes @param src {String} value to parse @param separator {String} single character separator @returns []
[ "Split", "a", "string", "using", "a", "separator", "if", "not", "preceded", "by", "a", "backslash", ".", "For", "simplicity", "this", "does", "not", "correctly", "handle", "two", "preceding", "backslashes" ]
dfd733f74e8bc0d196a7238caf92bdae07a80aa5
https://github.com/willemdewit/java.properties.js/blob/dfd733f74e8bc0d196a7238caf92bdae07a80aa5/lib/java.properties.js#L33-L54
train
willemdewit/java.properties.js
lib/java.properties.js
combineMultiLines
function combineMultiLines(lines) { return lines.reduce((acc, cur) => { const line = acc[acc.length - 1]; if (acc.length && isLineContinued(line)) { acc[acc.length - 1] = line.replace(/\\$/, ''); acc[acc.length - 1] += cur; } else { acc.push(cur); ...
javascript
function combineMultiLines(lines) { return lines.reduce((acc, cur) => { const line = acc[acc.length - 1]; if (acc.length && isLineContinued(line)) { acc[acc.length - 1] = line.replace(/\\$/, ''); acc[acc.length - 1] += cur; } else { acc.push(cur); ...
[ "function", "combineMultiLines", "(", "lines", ")", "{", "return", "lines", ".", "reduce", "(", "(", "acc", ",", "cur", ")", "=>", "{", "const", "line", "=", "acc", "[", "acc", ".", "length", "-", "1", "]", ";", "if", "(", "acc", ".", "length", "...
Combines lines which end with a backslash with the next line @param lines {String[]} @returns {String[]}
[ "Combines", "lines", "which", "end", "with", "a", "backslash", "with", "the", "next", "line" ]
dfd733f74e8bc0d196a7238caf92bdae07a80aa5
https://github.com/willemdewit/java.properties.js/blob/dfd733f74e8bc0d196a7238caf92bdae07a80aa5/lib/java.properties.js#L120-L131
train
feedhenry/fh-mbaas-middleware
lib/util/mongo.js
createDb
function createDb(config, dbUser, dbUserPass, dbName, cb) { log.logger.trace({user: dbUser, pwd: dbUserPass, name: dbName}, 'creating new datatbase'); var url = config.mongoUrl; var admin = config.mongo.admin_auth.user; var admin_pass = config.mongo.admin_auth.pass; MongoClient.connect(url, function(err, db)...
javascript
function createDb(config, dbUser, dbUserPass, dbName, cb) { log.logger.trace({user: dbUser, pwd: dbUserPass, name: dbName}, 'creating new datatbase'); var url = config.mongoUrl; var admin = config.mongo.admin_auth.user; var admin_pass = config.mongo.admin_auth.pass; MongoClient.connect(url, function(err, db)...
[ "function", "createDb", "(", "config", ",", "dbUser", ",", "dbUserPass", ",", "dbName", ",", "cb", ")", "{", "log", ".", "logger", ".", "trace", "(", "{", "user", ":", "dbUser", ",", "pwd", ":", "dbUserPass", ",", "name", ":", "dbName", "}", ",", "...
create a database, including user name and pwd
[ "create", "a", "database", "including", "user", "name", "and", "pwd" ]
f906e98efbb4b0963bf5137b34b5e0589ba24e69
https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/util/mongo.js#L16-L44
train
feedhenry/fh-mbaas-middleware
lib/util/mongo.js
dropDb
function dropDb(config, dbUser, dbName, cb){ log.logger.trace({user: dbUser, name: dbName}, 'drop database'); var url = config.mongoUrl; var admin = config.mongo.admin_auth.user; var admin_pass = config.mongo.admin_auth.pass; MongoClient.connect(url, function(err, dbObj){ if (err) return handleError(n...
javascript
function dropDb(config, dbUser, dbName, cb){ log.logger.trace({user: dbUser, name: dbName}, 'drop database'); var url = config.mongoUrl; var admin = config.mongo.admin_auth.user; var admin_pass = config.mongo.admin_auth.pass; MongoClient.connect(url, function(err, dbObj){ if (err) return handleError(n...
[ "function", "dropDb", "(", "config", ",", "dbUser", ",", "dbName", ",", "cb", ")", "{", "log", ".", "logger", ".", "trace", "(", "{", "user", ":", "dbUser", ",", "name", ":", "dbName", "}", ",", "'drop database'", ")", ";", "var", "url", "=", "conf...
drop a database
[ "drop", "a", "database" ]
f906e98efbb4b0963bf5137b34b5e0589ba24e69
https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/util/mongo.js#L47-L73
train
Xotic750/util-x
lib/util-x.js
throwIfIsPrimitive
function throwIfIsPrimitive(inputArg) { var type = typeof inputArg; if (type === 'undefined' || inputArg === null || type === 'boolean' || type === 'string' || type === 'number') { throw new CTypeError('called on non-object: ' + typeof inputArg); } return inputArg; }
javascript
function throwIfIsPrimitive(inputArg) { var type = typeof inputArg; if (type === 'undefined' || inputArg === null || type === 'boolean' || type === 'string' || type === 'number') { throw new CTypeError('called on non-object: ' + typeof inputArg); } return inputArg; }
[ "function", "throwIfIsPrimitive", "(", "inputArg", ")", "{", "var", "type", "=", "typeof", "inputArg", ";", "if", "(", "type", "===", "'undefined'", "||", "inputArg", "===", "null", "||", "type", "===", "'boolean'", "||", "type", "===", "'string'", "||", "...
Throws a TypeError if the operand inputArg is not an object or not a function, otherise returns the object. @private @function throwIfIsPrimitive @param {*} inputArg @throws {TypeError} if inputArg is not an object or a function. @returns {(Object|Function)}
[ "Throws", "a", "TypeError", "if", "the", "operand", "inputArg", "is", "not", "an", "object", "or", "not", "a", "function", "otherise", "returns", "the", "object", "." ]
13b6a5ba6555f71c2b64032bdfdab8cfb8497aee
https://github.com/Xotic750/util-x/blob/13b6a5ba6555f71c2b64032bdfdab8cfb8497aee/lib/util-x.js#L2271-L2279
train
Xotic750/util-x
lib/util-x.js
isFunctionBasic
function isFunctionBasic(inputArg) { var isFn = toClass(inputArg) === classFunction, type; if (!isFn && inputArg !== null) { type = typeof inputArg; if ((type === 'function' || type === 'object') && ('constructor' in inputA...
javascript
function isFunctionBasic(inputArg) { var isFn = toClass(inputArg) === classFunction, type; if (!isFn && inputArg !== null) { type = typeof inputArg; if ((type === 'function' || type === 'object') && ('constructor' in inputA...
[ "function", "isFunctionBasic", "(", "inputArg", ")", "{", "var", "isFn", "=", "toClass", "(", "inputArg", ")", "===", "classFunction", ",", "type", ";", "if", "(", "!", "isFn", "&&", "inputArg", "!==", "null", ")", "{", "type", "=", "typeof", "inputArg",...
Returns true if the operand inputArg is a Function. Used by Function.isFunction. @private @function isFunctionBasic @param {*} inputArg @returns {boolean}
[ "Returns", "true", "if", "the", "operand", "inputArg", "is", "a", "Function", ".", "Used", "by", "Function", ".", "isFunction", "." ]
13b6a5ba6555f71c2b64032bdfdab8cfb8497aee
https://github.com/Xotic750/util-x/blob/13b6a5ba6555f71c2b64032bdfdab8cfb8497aee/lib/util-x.js#L2928-L2946
train
Xotic750/util-x
lib/util-x.js
copyRegExp
function copyRegExp(regExpArg, options) { var flags; if (!isPlainObject(options)) { options = {}; } // Get native flags in use flags = onlyCoercibleToString(pExec.call(getNativeFlags, $toString(regExpArg))[1]); if (options.add) { ...
javascript
function copyRegExp(regExpArg, options) { var flags; if (!isPlainObject(options)) { options = {}; } // Get native flags in use flags = onlyCoercibleToString(pExec.call(getNativeFlags, $toString(regExpArg))[1]); if (options.add) { ...
[ "function", "copyRegExp", "(", "regExpArg", ",", "options", ")", "{", "var", "flags", ";", "if", "(", "!", "isPlainObject", "(", "options", ")", ")", "{", "options", "=", "{", "}", ";", "}", "// Get native flags in use", "flags", "=", "onlyCoercibleToString"...
Copies a regex object. Allows adding and removing native flags while copying the regex. @private @function copyRegExp @param {RegExp} regex Regex to copy. @param {Object} [options] Allows specifying native flags to add or remove while copying the regex. @returns {RegExp} Copy of the provided regex, possibly with modifi...
[ "Copies", "a", "regex", "object", ".", "Allows", "adding", "and", "removing", "native", "flags", "while", "copying", "the", "regex", "." ]
13b6a5ba6555f71c2b64032bdfdab8cfb8497aee
https://github.com/Xotic750/util-x/blob/13b6a5ba6555f71c2b64032bdfdab8cfb8497aee/lib/util-x.js#L4210-L4229
train
Xotic750/util-x
lib/util-x.js
stringRepeatRep
function stringRepeatRep(s, times) { var half, val; if (times < 1) { val = ''; } else if (times % 2) { val = stringRepeatRep(s, times - 1) + s; } else { half = stringRepeatRep...
javascript
function stringRepeatRep(s, times) { var half, val; if (times < 1) { val = ''; } else if (times % 2) { val = stringRepeatRep(s, times - 1) + s; } else { half = stringRepeatRep...
[ "function", "stringRepeatRep", "(", "s", ",", "times", ")", "{", "var", "half", ",", "val", ";", "if", "(", "times", "<", "1", ")", "{", "val", "=", "''", ";", "}", "else", "if", "(", "times", "%", "2", ")", "{", "val", "=", "stringRepeatRep", ...
Repeat the current string several times, return the new string. Used by String.repeat @private @function stringRepeatRep @param {string} s @param {number} times @returns {string}
[ "Repeat", "the", "current", "string", "several", "times", "return", "the", "new", "string", ".", "Used", "by", "String", ".", "repeat" ]
13b6a5ba6555f71c2b64032bdfdab8cfb8497aee
https://github.com/Xotic750/util-x/blob/13b6a5ba6555f71c2b64032bdfdab8cfb8497aee/lib/util-x.js#L4767-L4781
train
Xotic750/util-x
lib/util-x.js
checkV8StrictBug
function checkV8StrictBug(fn) { var hasV8StrictBug = false; if (isStrictMode) { fn.call([1], function () { hasV8StrictBug = this !== null && typeof this === 'object'; }, 'foo'); } return hasV8StrictBug; }
javascript
function checkV8StrictBug(fn) { var hasV8StrictBug = false; if (isStrictMode) { fn.call([1], function () { hasV8StrictBug = this !== null && typeof this === 'object'; }, 'foo'); } return hasV8StrictBug; }
[ "function", "checkV8StrictBug", "(", "fn", ")", "{", "var", "hasV8StrictBug", "=", "false", ";", "if", "(", "isStrictMode", ")", "{", "fn", ".", "call", "(", "[", "1", "]", ",", "function", "(", ")", "{", "hasV8StrictBug", "=", "this", "!==", "null", ...
Checks if the supplied function suffers from the V8 strict mode bug. @private @function checkV8StrictBug @param {Function} fn @returns {boolean}
[ "Checks", "if", "the", "supplied", "function", "suffers", "from", "the", "V8", "strict", "mode", "bug", "." ]
13b6a5ba6555f71c2b64032bdfdab8cfb8497aee
https://github.com/Xotic750/util-x/blob/13b6a5ba6555f71c2b64032bdfdab8cfb8497aee/lib/util-x.js#L5352-L5362
train
Xotic750/util-x
lib/util-x.js
defaultComparison
function defaultComparison(left, right) { var leftS = $toString(left), rightS = $toString(right), val = 1; if (leftS === rightS) { val = +0; } else if (leftS < rightS) { val = -1; } return val; }
javascript
function defaultComparison(left, right) { var leftS = $toString(left), rightS = $toString(right), val = 1; if (leftS === rightS) { val = +0; } else if (leftS < rightS) { val = -1; } return val; }
[ "function", "defaultComparison", "(", "left", ",", "right", ")", "{", "var", "leftS", "=", "$toString", "(", "left", ")", ",", "rightS", "=", "$toString", "(", "right", ")", ",", "val", "=", "1", ";", "if", "(", "leftS", "===", "rightS", ")", "{", ...
Default compare function for stableSort. @private @function defaultComparison @param {*} left @param {*} right @returns {number}
[ "Default", "compare", "function", "for", "stableSort", "." ]
13b6a5ba6555f71c2b64032bdfdab8cfb8497aee
https://github.com/Xotic750/util-x/blob/13b6a5ba6555f71c2b64032bdfdab8cfb8497aee/lib/util-x.js#L6125-L6137
train
Xotic750/util-x
lib/util-x.js
sortCompare
function sortCompare(left, right) { var hasj = $hasOwn(left, 0), hask = $hasOwn(right, 0), typex, typey, val; if (!hasj && !hask) { val = +0; } else if (!hasj) { val = 1; } else if (!hask) { val = -1; ...
javascript
function sortCompare(left, right) { var hasj = $hasOwn(left, 0), hask = $hasOwn(right, 0), typex, typey, val; if (!hasj && !hask) { val = +0; } else if (!hasj) { val = 1; } else if (!hask) { val = -1; ...
[ "function", "sortCompare", "(", "left", ",", "right", ")", "{", "var", "hasj", "=", "$hasOwn", "(", "left", ",", "0", ")", ",", "hask", "=", "$hasOwn", "(", "right", ",", "0", ")", ",", "typex", ",", "typey", ",", "val", ";", "if", "(", "!", "h...
sortCompare function for stableSort. @private @function sortCompare @param {*} object @param {*} left @param {*} right @returns {number}
[ "sortCompare", "function", "for", "stableSort", "." ]
13b6a5ba6555f71c2b64032bdfdab8cfb8497aee
https://github.com/Xotic750/util-x/blob/13b6a5ba6555f71c2b64032bdfdab8cfb8497aee/lib/util-x.js#L6148-L6174
train
Xotic750/util-x
lib/util-x.js
merge
function merge(left, right, comparison) { var result = [], next = 0, sComp; result.length = left.length + right.length; while (left.length && right.length) { sComp = sortCompare(left, right); if (typeof sComp !== 'number') { if (co...
javascript
function merge(left, right, comparison) { var result = [], next = 0, sComp; result.length = left.length + right.length; while (left.length && right.length) { sComp = sortCompare(left, right); if (typeof sComp !== 'number') { if (co...
[ "function", "merge", "(", "left", ",", "right", ",", "comparison", ")", "{", "var", "result", "=", "[", "]", ",", "next", "=", "0", ",", "sComp", ";", "result", ".", "length", "=", "left", ".", "length", "+", "right", ".", "length", ";", "while", ...
merge function for stableSort. @private @function merge @param {ArrayLike} left @param {ArrayLike} right @param {Function} comparison @returns {Array}
[ "merge", "function", "for", "stableSort", "." ]
13b6a5ba6555f71c2b64032bdfdab8cfb8497aee
https://github.com/Xotic750/util-x/blob/13b6a5ba6555f71c2b64032bdfdab8cfb8497aee/lib/util-x.js#L6185-L6243
train
Xotic750/util-x
lib/util-x.js
mergeSort
function mergeSort(array, comparefn) { var length = array.length, middle, front, back, val; if (length < 2) { val = $slice(array); } else { middle = ceil(length / 2); front = $slice(array, 0, middle); ...
javascript
function mergeSort(array, comparefn) { var length = array.length, middle, front, back, val; if (length < 2) { val = $slice(array); } else { middle = ceil(length / 2); front = $slice(array, 0, middle); ...
[ "function", "mergeSort", "(", "array", ",", "comparefn", ")", "{", "var", "length", "=", "array", ".", "length", ",", "middle", ",", "front", ",", "back", ",", "val", ";", "if", "(", "length", "<", "2", ")", "{", "val", "=", "$slice", "(", "array",...
mergeSort function for stableSort. @private @function mergeSort @param {ArrayLike} array @param {Function} comparefn @returns {Array}
[ "mergeSort", "function", "for", "stableSort", "." ]
13b6a5ba6555f71c2b64032bdfdab8cfb8497aee
https://github.com/Xotic750/util-x/blob/13b6a5ba6555f71c2b64032bdfdab8cfb8497aee/lib/util-x.js#L6253-L6270
train
ubenzer/metalsmith-rho
lib/index.js
plugin
function plugin(options) { options = normalize(options); return function(files, metalsmith, done) { var tbConvertedFiles = _.filter(Object.keys(files), function(file) { return minimatch(file, options.match); }); var convertFns = _.map(tbConvertedFiles, function(file) { debug("Asyncly conve...
javascript
function plugin(options) { options = normalize(options); return function(files, metalsmith, done) { var tbConvertedFiles = _.filter(Object.keys(files), function(file) { return minimatch(file, options.match); }); var convertFns = _.map(tbConvertedFiles, function(file) { debug("Asyncly conve...
[ "function", "plugin", "(", "options", ")", "{", "options", "=", "normalize", "(", "options", ")", ";", "return", "function", "(", "files", ",", "metalsmith", ",", "done", ")", "{", "var", "tbConvertedFiles", "=", "_", ".", "filter", "(", "Object", ".", ...
Metalsmith plugin that renders rho files to HTML. @param {Object} options @return {Function}
[ "Metalsmith", "plugin", "that", "renders", "rho", "files", "to", "HTML", "." ]
74703b8be2a8a051d4ac3c97caf7e78411dcf9d8
https://github.com/ubenzer/metalsmith-rho/blob/74703b8be2a8a051d4ac3c97caf7e78411dcf9d8/lib/index.js#L14-L61
train
noderaider/contextual
lib/theme/palettes/invert.js
invertPalette
function invertPalette(palette) { return _extends({}, palette, { base03: palette.base3, base02: palette.base2, base01: palette.base1, base00: palette.base0, base0: palette.base00, base1: palette.base01, base2: palett...
javascript
function invertPalette(palette) { return _extends({}, palette, { base03: palette.base3, base02: palette.base2, base01: palette.base1, base00: palette.base0, base0: palette.base00, base1: palette.base01, base2: palett...
[ "function", "invertPalette", "(", "palette", ")", "{", "return", "_extends", "(", "{", "}", ",", "palette", ",", "{", "base03", ":", "palette", ".", "base3", ",", "base02", ":", "palette", ".", "base2", ",", "base01", ":", "palette", ".", "base1", ",",...
Inverts solarized style palette.
[ "Inverts", "solarized", "style", "palette", "." ]
e3b8e12975eb3611483cf0adb4f9e7a388d12039
https://github.com/noderaider/contextual/blob/e3b8e12975eb3611483cf0adb4f9e7a388d12039/lib/theme/palettes/invert.js#L11-L21
train
danielhusar/grunt-file-replace
tasks/fileReplace.js
function(url, dest, cb) { var get = request(url); get.on('response', function (res) { res.pipe(fs.createWriteStream(dest)); res.on('end', function () { cb(); }); res.on('error', function (err) { cb(err); }); }); }
javascript
function(url, dest, cb) { var get = request(url); get.on('response', function (res) { res.pipe(fs.createWriteStream(dest)); res.on('end', function () { cb(); }); res.on('error', function (err) { cb(err); }); }); }
[ "function", "(", "url", ",", "dest", ",", "cb", ")", "{", "var", "get", "=", "request", "(", "url", ")", ";", "get", ".", "on", "(", "'response'", ",", "function", "(", "res", ")", "{", "res", ".", "pipe", "(", "fs", ".", "createWriteStream", "("...
Copy remote file to local hardrive @param {string} url url of the remote file @param {string} dest destination where to copy file @param {Function} cb callback when file is copied @return {void}
[ "Copy", "remote", "file", "to", "local", "hardrive" ]
bdbc0b428dddee6956fc9b09864133b3927a1c44
https://github.com/danielhusar/grunt-file-replace/blob/bdbc0b428dddee6956fc9b09864133b3927a1c44/tasks/fileReplace.js#L60-L71
train
Digznav/bilberry
changelog.js
changelog
function changelog(tagsList, prevTag, repoUrl, repoName) { const writeLogFiles = []; let logIndex; let logDetailed; let logContent; let link; let prevTagHolder = prevTag; Object.keys(tagsList).forEach(majorVersion => { logIndex = []; logDetailed = []; logContent = [ `\n# ${repoName} ${m...
javascript
function changelog(tagsList, prevTag, repoUrl, repoName) { const writeLogFiles = []; let logIndex; let logDetailed; let logContent; let link; let prevTagHolder = prevTag; Object.keys(tagsList).forEach(majorVersion => { logIndex = []; logDetailed = []; logContent = [ `\n# ${repoName} ${m...
[ "function", "changelog", "(", "tagsList", ",", "prevTag", ",", "repoUrl", ",", "repoName", ")", "{", "const", "writeLogFiles", "=", "[", "]", ";", "let", "logIndex", ";", "let", "logDetailed", ";", "let", "logContent", ";", "let", "link", ";", "let", "pr...
Create Changelog files. @param {object} tagsList Tags info. @param {string} prevTag Previous tag to compare with. @param {string} repoUrl URL of the repository. @param {string} repoName Name of the repository. @return {promise} A promise to do it.
[ "Create", "Changelog", "files", "." ]
ef6db49de6c8b0d2f4f9d3e10e8a8153e39ffcc4
https://github.com/Digznav/bilberry/blob/ef6db49de6c8b0d2f4f9d3e10e8a8153e39ffcc4/changelog.js#L11-L48
train
redisjs/jsr-client
lib/client.js
Client
function Client(socket, options) { options = options || {}; // hook up subcommand nested properties var cmd, sub, method; for(cmd in SubCommand) { // we have defined the cluster slots subcommand // but the cluster command is not returned in the // command list, ignore this for the moment if(!th...
javascript
function Client(socket, options) { options = options || {}; // hook up subcommand nested properties var cmd, sub, method; for(cmd in SubCommand) { // we have defined the cluster slots subcommand // but the cluster command is not returned in the // command list, ignore this for the moment if(!th...
[ "function", "Client", "(", "socket", ",", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "// hook up subcommand nested properties", "var", "cmd", ",", "sub", ",", "method", ";", "for", "(", "cmd", "in", "SubCommand", ")", "{", "// we ...
Represents a redis client connection. @param socket The underlying socket. @param options Client connection options.
[ "Represents", "a", "redis", "client", "connection", "." ]
be90dd5c062e4efb38d5b7f91d3ad9f43174cb3b
https://github.com/redisjs/jsr-client/blob/be90dd5c062e4efb38d5b7f91d3ad9f43174cb3b/lib/client.js#L21-L71
train
redisjs/jsr-client
lib/client.js
execute
function execute(cmd, args, cb) { if(typeof args === 'function') { cb = args; args = null; } var arr = [cmd].concat(args || []); if(typeof cb === 'function') { this.once('reply', cb); } // sending over tcp if(this.tcp) { this.encoder.write(arr); // connected to a server within this proc...
javascript
function execute(cmd, args, cb) { if(typeof args === 'function') { cb = args; args = null; } var arr = [cmd].concat(args || []); if(typeof cb === 'function') { this.once('reply', cb); } // sending over tcp if(this.tcp) { this.encoder.write(arr); // connected to a server within this proc...
[ "function", "execute", "(", "cmd", ",", "args", ",", "cb", ")", "{", "if", "(", "typeof", "args", "===", "'function'", ")", "{", "cb", "=", "args", ";", "args", "=", "null", ";", "}", "var", "arr", "=", "[", "cmd", "]", ".", "concat", "(", "arg...
Execute a named command with arguments.
[ "Execute", "a", "named", "command", "with", "arguments", "." ]
be90dd5c062e4efb38d5b7f91d3ad9f43174cb3b
https://github.com/redisjs/jsr-client/blob/be90dd5c062e4efb38d5b7f91d3ad9f43174cb3b/lib/client.js#L102-L119
train
redisjs/jsr-client
lib/client.js
multi
function multi(cb) { // not chainable with a callback if(typeof cb === 'function') { return this.execute(Constants.MAP.multi.name, [], cb); } // chainable instance return new Multi(this); }
javascript
function multi(cb) { // not chainable with a callback if(typeof cb === 'function') { return this.execute(Constants.MAP.multi.name, [], cb); } // chainable instance return new Multi(this); }
[ "function", "multi", "(", "cb", ")", "{", "// not chainable with a callback", "if", "(", "typeof", "cb", "===", "'function'", ")", "{", "return", "this", ".", "execute", "(", "Constants", ".", "MAP", ".", "multi", ".", "name", ",", "[", "]", ",", "cb", ...
Get a chainable multi command builder.
[ "Get", "a", "chainable", "multi", "command", "builder", "." ]
be90dd5c062e4efb38d5b7f91d3ad9f43174cb3b
https://github.com/redisjs/jsr-client/blob/be90dd5c062e4efb38d5b7f91d3ad9f43174cb3b/lib/client.js#L124-L132
train
redisjs/jsr-client
lib/client.js
_data
function _data(data) { if(this.tcp) { this.decoder.write(data); // connected to an in-process server, // emit the reply from the server socket }else{ if(data instanceof Error) { this.emit('reply', data, null); }else{ this.emit('reply', null, data); } } }
javascript
function _data(data) { if(this.tcp) { this.decoder.write(data); // connected to an in-process server, // emit the reply from the server socket }else{ if(data instanceof Error) { this.emit('reply', data, null); }else{ this.emit('reply', null, data); } } }
[ "function", "_data", "(", "data", ")", "{", "if", "(", "this", ".", "tcp", ")", "{", "this", ".", "decoder", ".", "write", "(", "data", ")", ";", "// connected to an in-process server,", "// emit the reply from the server socket", "}", "else", "{", "if", "(", ...
Listener for the socket data event.
[ "Listener", "for", "the", "socket", "data", "event", "." ]
be90dd5c062e4efb38d5b7f91d3ad9f43174cb3b
https://github.com/redisjs/jsr-client/blob/be90dd5c062e4efb38d5b7f91d3ad9f43174cb3b/lib/client.js#L156-L168
train
redisjs/jsr-client
lib/client.js
create
function create(sock, options) { var socket; if(!sock) { sock = {port: PORT, host: HOST}; } if(typeof sock.createConnection === 'function') { socket = sock.createConnection(); }else{ socket = net.createConnection(sock); } return new Client(socket, options); }
javascript
function create(sock, options) { var socket; if(!sock) { sock = {port: PORT, host: HOST}; } if(typeof sock.createConnection === 'function') { socket = sock.createConnection(); }else{ socket = net.createConnection(sock); } return new Client(socket, options); }
[ "function", "create", "(", "sock", ",", "options", ")", "{", "var", "socket", ";", "if", "(", "!", "sock", ")", "{", "sock", "=", "{", "port", ":", "PORT", ",", "host", ":", "HOST", "}", ";", "}", "if", "(", "typeof", "sock", ".", "createConnecti...
Create a new client. When the first argument is a server reference createConnection() is called on the server which returns an object that mimics the socket event handling. @param sock Options for the underlying TCP socket or a server reference. @param options Client connection options.
[ "Create", "a", "new", "client", "." ]
be90dd5c062e4efb38d5b7f91d3ad9f43174cb3b
https://github.com/redisjs/jsr-client/blob/be90dd5c062e4efb38d5b7f91d3ad9f43174cb3b/lib/client.js#L224-L235
train
360fy/expressjs-boilerplate
src/server/ApiRequestHandler.js
buildRoutes
function buildRoutes(router, apiOrBuilder) { // if it's a builder function, build it... let pathPrefix = null; let api = null; let registry = null; let instanceName = null; if (_.isObject(apiOrBuilder)) { pathPrefix = apiOrBuilder.path; api = apiOrBuilder.api; registry = ...
javascript
function buildRoutes(router, apiOrBuilder) { // if it's a builder function, build it... let pathPrefix = null; let api = null; let registry = null; let instanceName = null; if (_.isObject(apiOrBuilder)) { pathPrefix = apiOrBuilder.path; api = apiOrBuilder.api; registry = ...
[ "function", "buildRoutes", "(", "router", ",", "apiOrBuilder", ")", "{", "// if it's a builder function, build it...", "let", "pathPrefix", "=", "null", ";", "let", "api", "=", "null", ";", "let", "registry", "=", "null", ";", "let", "instanceName", "=", "null",...
should build a catch all route for pathPrefix ??
[ "should", "build", "a", "catch", "all", "route", "for", "pathPrefix", "??" ]
1953048bca726d2dbab6a44fedb8c0846c12f0b5
https://github.com/360fy/expressjs-boilerplate/blob/1953048bca726d2dbab6a44fedb8c0846c12f0b5/src/server/ApiRequestHandler.js#L122-L157
train
feedhenry/fh-mbaas-middleware
lib/util/responseTranslator.js
mapMongoAlertsToResponseObj
function mapMongoAlertsToResponseObj(alerts){ // Base response, regardless of whether we have alerts or not var res = {"list":[],"status":"ok"}; // Filter and add alerts to response if we have them if (alerts){ res.list = _.map(alerts, function(alert){ var al = alert.toJSON(); al.guid = alert....
javascript
function mapMongoAlertsToResponseObj(alerts){ // Base response, regardless of whether we have alerts or not var res = {"list":[],"status":"ok"}; // Filter and add alerts to response if we have them if (alerts){ res.list = _.map(alerts, function(alert){ var al = alert.toJSON(); al.guid = alert....
[ "function", "mapMongoAlertsToResponseObj", "(", "alerts", ")", "{", "// Base response, regardless of whether we have alerts or not", "var", "res", "=", "{", "\"list\"", ":", "[", "]", ",", "\"status\"", ":", "\"ok\"", "}", ";", "// Filter and add alerts to response if we ha...
Alerts from Mongo should not be coupled to response format Map query result Alerts to single response object as it is defined @param alerts @returns {{}}
[ "Alerts", "from", "Mongo", "should", "not", "be", "coupled", "to", "response", "format", "Map", "query", "result", "Alerts", "to", "single", "response", "object", "as", "it", "is", "defined" ]
f906e98efbb4b0963bf5137b34b5e0589ba24e69
https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/util/responseTranslator.js#L9-L25
train
feedhenry/fh-mbaas-middleware
lib/util/responseTranslator.js
mapMongoNotificationsToResponseObj
function mapMongoNotificationsToResponseObj(notifications){ // Base response, regardless of whether we have alerts or not var res = {"list":[],"status":"ok"}; // Filter and add alerts to response if we have them if (notifications){ res.list = _.map(notifications, function(notification){ return notif...
javascript
function mapMongoNotificationsToResponseObj(notifications){ // Base response, regardless of whether we have alerts or not var res = {"list":[],"status":"ok"}; // Filter and add alerts to response if we have them if (notifications){ res.list = _.map(notifications, function(notification){ return notif...
[ "function", "mapMongoNotificationsToResponseObj", "(", "notifications", ")", "{", "// Base response, regardless of whether we have alerts or not", "var", "res", "=", "{", "\"list\"", ":", "[", "]", ",", "\"status\"", ":", "\"ok\"", "}", ";", "// Filter and add alerts to res...
Notifications from Mongo should not be coupled to response format Map query result Notifications to single response object as it is defined @param alerts @returns {{}}
[ "Notifications", "from", "Mongo", "should", "not", "be", "coupled", "to", "response", "format", "Map", "query", "result", "Notifications", "to", "single", "response", "object", "as", "it", "is", "defined" ]
f906e98efbb4b0963bf5137b34b5e0589ba24e69
https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/util/responseTranslator.js#L33-L46
train
feedhenry/fh-mbaas-middleware
lib/util/responseTranslator.js
mapMongoEventsToResponseObj
function mapMongoEventsToResponseObj(events){ // Base response, regardless of whether we have alerts or not var res = {"list":[],"status":"ok"}; // Filter and add alerts to response if we have them if (events){ res.list = _.map(events, function(event){ var ev = event.toJSON(); ev.message = ...
javascript
function mapMongoEventsToResponseObj(events){ // Base response, regardless of whether we have alerts or not var res = {"list":[],"status":"ok"}; // Filter and add alerts to response if we have them if (events){ res.list = _.map(events, function(event){ var ev = event.toJSON(); ev.message = ...
[ "function", "mapMongoEventsToResponseObj", "(", "events", ")", "{", "// Base response, regardless of whether we have alerts or not", "var", "res", "=", "{", "\"list\"", ":", "[", "]", ",", "\"status\"", ":", "\"ok\"", "}", ";", "// Filter and add alerts to response if we ha...
Events from Mongo should not be coupled to response format Map query result Events to single response object as it is defined @param alerts @returns {{}}
[ "Events", "from", "Mongo", "should", "not", "be", "coupled", "to", "response", "format", "Map", "query", "result", "Events", "to", "single", "response", "object", "as", "it", "is", "defined" ]
f906e98efbb4b0963bf5137b34b5e0589ba24e69
https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/util/responseTranslator.js#L54-L74
train
Crafity/crafity-webserver
lib/fileserver.js
createListener
function createListener(virtualPath) { return function listener(req, res, next) { var paths = allPaths[virtualPath].slice(); function processRequest(paths) { var physicalPath = paths.pop() , synchronizer = new Synchronizer() , uri = urlParser.parse(req.url).pathname , filename...
javascript
function createListener(virtualPath) { return function listener(req, res, next) { var paths = allPaths[virtualPath].slice(); function processRequest(paths) { var physicalPath = paths.pop() , synchronizer = new Synchronizer() , uri = urlParser.parse(req.url).pathname , filename...
[ "function", "createListener", "(", "virtualPath", ")", "{", "return", "function", "listener", "(", "req", ",", "res", ",", "next", ")", "{", "var", "paths", "=", "allPaths", "[", "virtualPath", "]", ".", "slice", "(", ")", ";", "function", "processRequest"...
Create a new static file handler @param virtualPath @param physicalPath
[ "Create", "a", "new", "static", "file", "handler" ]
a4239c66966a64fe004ca6ef2d8920946c44f0b7
https://github.com/Crafity/crafity-webserver/blob/a4239c66966a64fe004ca6ef2d8920946c44f0b7/lib/fileserver.js#L195-L282
train
marcojonker/data-elevator
lib/logger/base-logger.js
function(error, verbose) { var message = ""; //Some errors have a base error (in case of ElevatorError for example) while(error) { message += (verbose === true && error.stack) ? error.stack : error.message; error = error.baseError; if(error) { message += "\r\n"...
javascript
function(error, verbose) { var message = ""; //Some errors have a base error (in case of ElevatorError for example) while(error) { message += (verbose === true && error.stack) ? error.stack : error.message; error = error.baseError; if(error) { message += "\r\n"...
[ "function", "(", "error", ",", "verbose", ")", "{", "var", "message", "=", "\"\"", ";", "//Some errors have a base error (in case of ElevatorError for example)", "while", "(", "error", ")", "{", "message", "+=", "(", "verbose", "===", "true", "&&", "error", ".", ...
Create a log string for an error @param error @param verbose
[ "Create", "a", "log", "string", "for", "an", "error" ]
7d56e5b2e8ca24b9576066e5265713db6452f289
https://github.com/marcojonker/data-elevator/blob/7d56e5b2e8ca24b9576066e5265713db6452f289/lib/logger/base-logger.js#L10-L24
train
gethuman/pancakes-angular
lib/ngapp/casing.js
camelCase
function camelCase(str, delim) { var delims = delim || ['_', '.', '-']; if (!_.isArray(delims)) { delims = [delims]; } _.each(delims, function (adelim) { var codeParts = str.split(adelim); var i, codePart; for (i = 1; i < codeParts.lengt...
javascript
function camelCase(str, delim) { var delims = delim || ['_', '.', '-']; if (!_.isArray(delims)) { delims = [delims]; } _.each(delims, function (adelim) { var codeParts = str.split(adelim); var i, codePart; for (i = 1; i < codeParts.lengt...
[ "function", "camelCase", "(", "str", ",", "delim", ")", "{", "var", "delims", "=", "delim", "||", "[", "'_'", ",", "'.'", ",", "'-'", "]", ";", "if", "(", "!", "_", ".", "isArray", "(", "delims", ")", ")", "{", "delims", "=", "[", "delims", "]"...
Convert to camelCase @param str @param delim
[ "Convert", "to", "camelCase" ]
9589b7ba09619843e271293088005c62ed23f355
https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/ngapp/casing.js#L16-L36
train
philipbordallo/eslint-config
build.js
buildConfig
async function buildConfig(file) { const { default: config } = await import(`${CONFIGS_PATH}/${file}`); const { creator, name, packageName } = config; creator .then((data) => { const stringifiedData = JSON.stringify(data); const generatedData = TEMPLATE.replace(/{{ data }}/, stringifiedData); ...
javascript
async function buildConfig(file) { const { default: config } = await import(`${CONFIGS_PATH}/${file}`); const { creator, name, packageName } = config; creator .then((data) => { const stringifiedData = JSON.stringify(data); const generatedData = TEMPLATE.replace(/{{ data }}/, stringifiedData); ...
[ "async", "function", "buildConfig", "(", "file", ")", "{", "const", "{", "default", ":", "config", "}", "=", "await", "import", "(", "`", "${", "CONFIGS_PATH", "}", "${", "file", "}", "`", ")", ";", "const", "{", "creator", ",", "name", ",", "package...
Builds config file to packages folder @param {string} file - Config file
[ "Builds", "config", "file", "to", "packages", "folder" ]
a2f1bff442fdb8ee622f842f075fa10d555302a4
https://github.com/philipbordallo/eslint-config/blob/a2f1bff442fdb8ee622f842f075fa10d555302a4/build.js#L14-L29
train
Nazariglez/perenquen
lib/pixi/src/mesh/Mesh.js
Mesh
function Mesh(texture, vertices, uvs, indices, drawMode) { core.Container.call(this); /** * The texture of the Mesh * * @member {Texture} */ this.texture = texture; /** * The Uvs of the Mesh * * @member {Float32Array} */ this.uvs = uvs || new Float32Array([0...
javascript
function Mesh(texture, vertices, uvs, indices, drawMode) { core.Container.call(this); /** * The texture of the Mesh * * @member {Texture} */ this.texture = texture; /** * The Uvs of the Mesh * * @member {Float32Array} */ this.uvs = uvs || new Float32Array([0...
[ "function", "Mesh", "(", "texture", ",", "vertices", ",", "uvs", ",", "indices", ",", "drawMode", ")", "{", "core", ".", "Container", ".", "call", "(", "this", ")", ";", "/**\n * The texture of the Mesh\n *\n * @member {Texture}\n */", "this", ".", ...
Base mesh class @class @extends Container @memberof PIXI.mesh @param texture {Texture} The texture to use @param [vertices] {Float32Arrif you want to specify the vertices @param [uvs] {Float32Array} if you want to specify the uvs @param [indices] {Uint16Array} if you want to specify the indices @param [drawMode] {numbe...
[ "Base", "mesh", "class" ]
e023964d05afeefebdcac4e2044819fdfa3899ae
https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/mesh/Mesh.js#L14-L79
train
gethuman/pancakes-recipe
utils/app.error.js
function (opts) { this.isAppError = true; this.code = opts.code; this.message = this.msg = opts.msg; this.type = opts.type; this.err = opts.err; this.stack = (new Error(opts.msg)).stack; }
javascript
function (opts) { this.isAppError = true; this.code = opts.code; this.message = this.msg = opts.msg; this.type = opts.type; this.err = opts.err; this.stack = (new Error(opts.msg)).stack; }
[ "function", "(", "opts", ")", "{", "this", ".", "isAppError", "=", "true", ";", "this", ".", "code", "=", "opts", ".", "code", ";", "this", ".", "message", "=", "this", ".", "msg", "=", "opts", ".", "msg", ";", "this", ".", "type", "=", "opts", ...
Constructor recieves a object with options that are used to define values on the error. These values are used at the middleware layer to translate into friendly messages @param opts @constructor
[ "Constructor", "recieves", "a", "object", "with", "options", "that", "are", "used", "to", "define", "values", "on", "the", "error", ".", "These", "values", "are", "used", "at", "the", "middleware", "layer", "to", "translate", "into", "friendly", "messages" ]
ea3feb8839e2edaf1b4577c052b8958953db4498
https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/utils/app.error.js#L18-L25
train
christophehurpeau/springbokjs-dom
lib/prototypes/events.js
onDelayed
function onDelayed(delay, throttle, eventNames, selector, listener) { if (typeof throttle !== 'boolean') { listener = selector; selector = eventNames; eventNames = throttle; throttle = false; } if (typeof selector === 'function') { listener = selector; select...
javascript
function onDelayed(delay, throttle, eventNames, selector, listener) { if (typeof throttle !== 'boolean') { listener = selector; selector = eventNames; eventNames = throttle; throttle = false; } if (typeof selector === 'function') { listener = selector; select...
[ "function", "onDelayed", "(", "delay", ",", "throttle", ",", "eventNames", ",", "selector", ",", "listener", ")", "{", "if", "(", "typeof", "throttle", "!==", "'boolean'", ")", "{", "listener", "=", "selector", ";", "selector", "=", "eventNames", ";", "eve...
Register a delayed listener for a space separated list of events Usefull for key typing events @example <caption>Example usage of onDelayed.</caption> $('#input-search').onDelayed(200, 'keyup', (event) => { console.log(event.$element.getValue() } @method Element#onDelayed @param {Number} delay @param {String} even...
[ "Register", "a", "delayed", "listener", "for", "a", "space", "separated", "list", "of", "events" ]
6e14a87fbe71124a0cbb68d1cb8626689c3b18a1
https://github.com/christophehurpeau/springbokjs-dom/blob/6e14a87fbe71124a0cbb68d1cb8626689c3b18a1/lib/prototypes/events.js#L330-L364
train
iceroad/baresoil-server
lib/sysapp/server/api/authenticated/account/get.js
get
function get(ignored, cb) { assert(this.$session); const ugRequest = { userId: this.$session.userId, }; this.syscall('UserManager', 'get', ugRequest, (err, userInfo, curVersion) => { if (err) return cb(err); // Strip security-sensitive information. delete userInfo.hashedPassword; _.forEach(...
javascript
function get(ignored, cb) { assert(this.$session); const ugRequest = { userId: this.$session.userId, }; this.syscall('UserManager', 'get', ugRequest, (err, userInfo, curVersion) => { if (err) return cb(err); // Strip security-sensitive information. delete userInfo.hashedPassword; _.forEach(...
[ "function", "get", "(", "ignored", ",", "cb", ")", "{", "assert", "(", "this", ".", "$session", ")", ";", "const", "ugRequest", "=", "{", "userId", ":", "this", ".", "$session", ".", "userId", ",", "}", ";", "this", ".", "syscall", "(", "'UserManager...
Get logged-in user information.
[ "Get", "logged", "-", "in", "user", "information", "." ]
8285f1647a81eb935331ea24491b38002b51278d
https://github.com/iceroad/baresoil-server/blob/8285f1647a81eb935331ea24491b38002b51278d/lib/sysapp/server/api/authenticated/account/get.js#L6-L24
train
AppAndFlow/anf
packages/scripts/deploy.js
safeExec
function safeExec(command, options) { const result = exec(command, options); if (result.code !== 0) { exit(result.code); return null; } return result; }
javascript
function safeExec(command, options) { const result = exec(command, options); if (result.code !== 0) { exit(result.code); return null; } return result; }
[ "function", "safeExec", "(", "command", ",", "options", ")", "{", "const", "result", "=", "exec", "(", "command", ",", "options", ")", ";", "if", "(", "result", ".", "code", "!==", "0", ")", "{", "exit", "(", "result", ".", "code", ")", ";", "retur...
Exec that exits on non 0 exit code.
[ "Exec", "that", "exits", "on", "non", "0", "exit", "code", "." ]
82a50bcab9f85a3c1b5c22c1f127f67d04810c89
https://github.com/AppAndFlow/anf/blob/82a50bcab9f85a3c1b5c22c1f127f67d04810c89/packages/scripts/deploy.js#L6-L13
train
AppAndFlow/anf
packages/scripts/deploy.js
deploy
function deploy({ containerName, containerRepository, clusterName, serviceName, accessKeyId, secretAccessKey, region = 'us-west-2', }) { AWS.config.update({ accessKeyId, secretAccessKey, region }); cd('C:\\Users\\janic\\Developer\\pikapik\\th3rdwave-api'); const commitSHA = env.CIRCLE_SHA1 || safeEx...
javascript
function deploy({ containerName, containerRepository, clusterName, serviceName, accessKeyId, secretAccessKey, region = 'us-west-2', }) { AWS.config.update({ accessKeyId, secretAccessKey, region }); cd('C:\\Users\\janic\\Developer\\pikapik\\th3rdwave-api'); const commitSHA = env.CIRCLE_SHA1 || safeEx...
[ "function", "deploy", "(", "{", "containerName", ",", "containerRepository", ",", "clusterName", ",", "serviceName", ",", "accessKeyId", ",", "secretAccessKey", ",", "region", "=", "'us-west-2'", ",", "}", ")", "{", "AWS", ".", "config", ".", "update", "(", ...
Build and deploy a new image and update the service on AWS ECS.
[ "Build", "and", "deploy", "a", "new", "image", "and", "update", "the", "service", "on", "AWS", "ECS", "." ]
82a50bcab9f85a3c1b5c22c1f127f67d04810c89
https://github.com/AppAndFlow/anf/blob/82a50bcab9f85a3c1b5c22c1f127f67d04810c89/packages/scripts/deploy.js#L18-L88
train
aliaksandr-master/grunt-process
Gruntfile.js
function (src, dest, content, fileObject) { var files = {}; _.each(content, function (v, k) { var file = fileObject.orig.dest + '/' + k + '.json'; files[file] = JSON.stringify(v); }); return files; }
javascript
function (src, dest, content, fileObject) { var files = {}; _.each(content, function (v, k) { var file = fileObject.orig.dest + '/' + k + '.json'; files[file] = JSON.stringify(v); }); return files; }
[ "function", "(", "src", ",", "dest", ",", "content", ",", "fileObject", ")", "{", "var", "files", "=", "{", "}", ";", "_", ".", "each", "(", "content", ",", "function", "(", "v", ",", "k", ")", "{", "var", "file", "=", "fileObject", ".", "orig", ...
split json by object key
[ "split", "json", "by", "object", "key" ]
1e9f87b85a1a6ec1549027d5a07f57e21a7a3710
https://github.com/aliaksandr-master/grunt-process/blob/1e9f87b85a1a6ec1549027d5a07f57e21a7a3710/Gruntfile.js#L71-L81
train
emeryrose/noisegen
lib/random-stream.js
RandomStream
function RandomStream(options) { if (!(this instanceof RandomStream)) { return new RandomStream(options); } this._options = merge(Object.create(RandomStream.DEFAULTS), options); assert(typeof this._options.length === 'number', 'Invalid length supplied'); assert(typeof this._options.size === 'number', 'I...
javascript
function RandomStream(options) { if (!(this instanceof RandomStream)) { return new RandomStream(options); } this._options = merge(Object.create(RandomStream.DEFAULTS), options); assert(typeof this._options.length === 'number', 'Invalid length supplied'); assert(typeof this._options.size === 'number', 'I...
[ "function", "RandomStream", "(", "options", ")", "{", "if", "(", "!", "(", "this", "instanceof", "RandomStream", ")", ")", "{", "return", "new", "RandomStream", "(", "options", ")", ";", "}", "this", ".", "_options", "=", "merge", "(", "Object", ".", "...
Create a readable stream of random data @extends {ReadableStream} @constructor @param {Object} options @param {Number} options.length - The total length of the stream in bytes @param {Number} options.size - The number of bytes in each data chunk @param {String} options.hash - The hash algorithm to use
[ "Create", "a", "readable", "stream", "of", "random", "data" ]
aa0f27b080c97922824f281c6614a03455ed418e
https://github.com/emeryrose/noisegen/blob/aa0f27b080c97922824f281c6614a03455ed418e/lib/random-stream.js#L18-L33
train
aleclarson/persec
index.js
psec
function psec(name, run) { const test = { name, run, before: null, after: null } ctx.tests.push(test) ctx.run() return { beforeEach(fn) { test.before = fn return this }, afterEach(fn) { test.after = fn return this }, } }
javascript
function psec(name, run) { const test = { name, run, before: null, after: null } ctx.tests.push(test) ctx.run() return { beforeEach(fn) { test.before = fn return this }, afterEach(fn) { test.after = fn return this }, } }
[ "function", "psec", "(", "name", ",", "run", ")", "{", "const", "test", "=", "{", "name", ",", "run", ",", "before", ":", "null", ",", "after", ":", "null", "}", "ctx", ".", "tests", ".", "push", "(", "test", ")", "ctx", ".", "run", "(", ")", ...
Register a test to cycle
[ "Register", "a", "test", "to", "cycle" ]
c9da078c485319f536c88a39f366e692c67e831f
https://github.com/aleclarson/persec/blob/c9da078c485319f536c88a39f366e692c67e831f/index.js#L37-L51
train
aleclarson/persec
index.js
flush
function flush() { if (queue.length) { let bench = queue[0] process.nextTick(() => { run(bench).then(() => { queue.shift() flush() }, console.error) }) } }
javascript
function flush() { if (queue.length) { let bench = queue[0] process.nextTick(() => { run(bench).then(() => { queue.shift() flush() }, console.error) }) } }
[ "function", "flush", "(", ")", "{", "if", "(", "queue", ".", "length", ")", "{", "let", "bench", "=", "queue", "[", "0", "]", "process", ".", "nextTick", "(", "(", ")", "=>", "{", "run", "(", "bench", ")", ".", "then", "(", "(", ")", "=>", "{...
Internal Flush the benchmark queue
[ "Internal", "Flush", "the", "benchmark", "queue" ]
c9da078c485319f536c88a39f366e692c67e831f
https://github.com/aleclarson/persec/blob/c9da078c485319f536c88a39f366e692c67e831f/index.js#L124-L134
train
aleclarson/persec
index.js
run
async function run(bench) { let { tests, config } = bench if (tests.length == 0) { throw Error('Benchmark has no test cycles') } // Find the longest test name. config.width = tests.reduce(longest, 0) let cycles = {} for (let i = 0; i < tests.length; i++) { const test = tests[i] try { ...
javascript
async function run(bench) { let { tests, config } = bench if (tests.length == 0) { throw Error('Benchmark has no test cycles') } // Find the longest test name. config.width = tests.reduce(longest, 0) let cycles = {} for (let i = 0; i < tests.length; i++) { const test = tests[i] try { ...
[ "async", "function", "run", "(", "bench", ")", "{", "let", "{", "tests", ",", "config", "}", "=", "bench", "if", "(", "tests", ".", "length", "==", "0", ")", "{", "throw", "Error", "(", "'Benchmark has no test cycles'", ")", "}", "// Find the longest test ...
Run a benchmark
[ "Run", "a", "benchmark" ]
c9da078c485319f536c88a39f366e692c67e831f
https://github.com/aleclarson/persec/blob/c9da078c485319f536c88a39f366e692c67e831f/index.js#L137-L160
train
aleclarson/persec
index.js
measure
async function measure(test, bench) { let { delay, minTime, minSamples, minWarmups, onCycle, onSample, } = bench.config let { name, run } = test delay *= 1e3 minTime *= 1e3 let samples = [] let cycle = { name, // test name hz: null, // samples per second size: null, /...
javascript
async function measure(test, bench) { let { delay, minTime, minSamples, minWarmups, onCycle, onSample, } = bench.config let { name, run } = test delay *= 1e3 minTime *= 1e3 let samples = [] let cycle = { name, // test name hz: null, // samples per second size: null, /...
[ "async", "function", "measure", "(", "test", ",", "bench", ")", "{", "let", "{", "delay", ",", "minTime", ",", "minSamples", ",", "minWarmups", ",", "onCycle", ",", "onSample", ",", "}", "=", "bench", ".", "config", "let", "{", "name", ",", "run", "}...
Measure a performance test
[ "Measure", "a", "performance", "test" ]
c9da078c485319f536c88a39f366e692c67e831f
https://github.com/aleclarson/persec/blob/c9da078c485319f536c88a39f366e692c67e831f/index.js#L163-L274
train
aleclarson/persec
index.js
function() { let sample = clock(start) if (test.after) test.after() bench.after.forEach(call) if (warmups == -1) { warmups = Math.max(minWarmups, sample > 100 ? 1 : sample > 10 ? 5 : 50) } if (warmups > 0) { warmups-- } else { samples[n++] = sample ...
javascript
function() { let sample = clock(start) if (test.after) test.after() bench.after.forEach(call) if (warmups == -1) { warmups = Math.max(minWarmups, sample > 100 ? 1 : sample > 10 ? 5 : 50) } if (warmups > 0) { warmups-- } else { samples[n++] = sample ...
[ "function", "(", ")", "{", "let", "sample", "=", "clock", "(", "start", ")", "if", "(", "test", ".", "after", ")", "test", ".", "after", "(", ")", "bench", ".", "after", ".", "forEach", "(", "call", ")", "if", "(", "warmups", "==", "-", "1", ")...
called by the test function for every sample
[ "called", "by", "the", "test", "function", "for", "every", "sample" ]
c9da078c485319f536c88a39f366e692c67e831f
https://github.com/aleclarson/persec/blob/c9da078c485319f536c88a39f366e692c67e831f/index.js#L235-L257
train
aleclarson/persec
index.js
onCycle
function onCycle(cycle, opts) { let hz = Math.round(cycle.hz).toLocaleString() let rme = '\xb1' + cycle.stats.rme.toFixed(2) + '%' // add colors hz = color(34) + hz + color(0) rme = color(33) + rme + color(0) const padding = ' '.repeat(opts.width - cycle.name.length) console.log(`${cycle.name}${padding}...
javascript
function onCycle(cycle, opts) { let hz = Math.round(cycle.hz).toLocaleString() let rme = '\xb1' + cycle.stats.rme.toFixed(2) + '%' // add colors hz = color(34) + hz + color(0) rme = color(33) + rme + color(0) const padding = ' '.repeat(opts.width - cycle.name.length) console.log(`${cycle.name}${padding}...
[ "function", "onCycle", "(", "cycle", ",", "opts", ")", "{", "let", "hz", "=", "Math", ".", "round", "(", "cycle", ".", "hz", ")", ".", "toLocaleString", "(", ")", "let", "rme", "=", "'\\xb1'", "+", "cycle", ".", "stats", ".", "rme", ".", "toFixed",...
default cycle reporter
[ "default", "cycle", "reporter" ]
c9da078c485319f536c88a39f366e692c67e831f
https://github.com/aleclarson/persec/blob/c9da078c485319f536c88a39f366e692c67e831f/index.js#L387-L397
train
antoniobrandao/mongoose3-bsonfix-bson
lib/bson/binary.js
Binary
function Binary(buffer, subType) { if(!(this instanceof Binary)) return new Binary(buffer, subType); this._bsontype = 'Binary'; if(buffer instanceof Number) { this.sub_type = buffer; this.position = 0; } else { this.sub_type = subType == null ? BSON_BINARY_SUBTYPE_DEFAULT : subType; this...
javascript
function Binary(buffer, subType) { if(!(this instanceof Binary)) return new Binary(buffer, subType); this._bsontype = 'Binary'; if(buffer instanceof Number) { this.sub_type = buffer; this.position = 0; } else { this.sub_type = subType == null ? BSON_BINARY_SUBTYPE_DEFAULT : subType; this...
[ "function", "Binary", "(", "buffer", ",", "subType", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Binary", ")", ")", "return", "new", "Binary", "(", "buffer", ",", "subType", ")", ";", "this", ".", "_bsontype", "=", "'Binary'", ";", "if", "(...
A class representation of the BSON Binary type. Sub types - **BSON.BSON_BINARY_SUBTYPE_DEFAULT**, default BSON type. - **BSON.BSON_BINARY_SUBTYPE_FUNCTION**, BSON function type. - **BSON.BSON_BINARY_SUBTYPE_BYTE_ARRAY**, BSON byte array type. - **BSON.BSON_BINARY_SUBTYPE_UUID**, BSON uuid type. - **BSON.BSON_BINARY_SU...
[ "A", "class", "representation", "of", "the", "BSON", "Binary", "type", "." ]
b0eae261710704de70f6f282669cf020dbd6a490
https://github.com/antoniobrandao/mongoose3-bsonfix-bson/blob/b0eae261710704de70f6f282669cf020dbd6a490/lib/bson/binary.js#L25-L64
train
jmjuanes/minsql
lib/query/update.js
QueryUpdate
function QueryUpdate(data) { //Initialize the set var set = ''; //Get all data for(var key in data) { //Save data value var value = data[key]; //Check the data type if(typeof value === 'string' || value instanceof String) { //Add the quotes value = '"' + value + '"'; } ...
javascript
function QueryUpdate(data) { //Initialize the set var set = ''; //Get all data for(var key in data) { //Save data value var value = data[key]; //Check the data type if(typeof value === 'string' || value instanceof String) { //Add the quotes value = '"' + value + '"'; } ...
[ "function", "QueryUpdate", "(", "data", ")", "{", "//Initialize the set\r", "var", "set", "=", "''", ";", "//Get all data\r", "for", "(", "var", "key", "in", "data", ")", "{", "//Save data value\r", "var", "value", "=", "data", "[", "key", "]", ";", "//Che...
Query for update
[ "Query", "for", "update" ]
80eddd97e858545997b30e3c9bc067d5fc2df5a0
https://github.com/jmjuanes/minsql/blob/80eddd97e858545997b30e3c9bc067d5fc2df5a0/lib/query/update.js#L2-L33
train
Nazariglez/perenquen
lib/pixi/src/filters/color/ColorMatrixFilter.js
ColorMatrixFilter
function ColorMatrixFilter() { core.AbstractFilter.call(this, // vertex shader null, // fragment shader fs.readFileSync(__dirname + '/colorMatrix.frag', 'utf8'), // custom uniforms { m: { type: '1fv', value: [1, 0, 0, 0, 0, ...
javascript
function ColorMatrixFilter() { core.AbstractFilter.call(this, // vertex shader null, // fragment shader fs.readFileSync(__dirname + '/colorMatrix.frag', 'utf8'), // custom uniforms { m: { type: '1fv', value: [1, 0, 0, 0, 0, ...
[ "function", "ColorMatrixFilter", "(", ")", "{", "core", ".", "AbstractFilter", ".", "call", "(", "this", ",", "// vertex shader", "null", ",", "// fragment shader", "fs", ".", "readFileSync", "(", "__dirname", "+", "'/colorMatrix.frag'", ",", "'utf8'", ")", ",",...
The ColorMatrixFilter class lets you apply a 5x5 matrix transformation on the RGBA color and alpha values of every pixel on your displayObject to produce a result with a new set of RGBA color and alpha values. It's pretty powerful! ```js var colorMatrix = new PIXI.ColorMatrixFilter(); container.filters = [colorMatrix]...
[ "The", "ColorMatrixFilter", "class", "lets", "you", "apply", "a", "5x5", "matrix", "transformation", "on", "the", "RGBA", "color", "and", "alpha", "values", "of", "every", "pixel", "on", "your", "displayObject", "to", "produce", "a", "result", "with", "a", "...
e023964d05afeefebdcac4e2044819fdfa3899ae
https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/filters/color/ColorMatrixFilter.js#L20-L36
train
redsift/ui-rs-core
src/js/xkcd/index.js
smooth
function smooth(d, w) { let result = []; for (let i = 0, l = d.length; i < l; ++i) { let mn = Math.max(0, i - 5 * w), mx = Math.min(d.length - 1, i + 5 * w), s = 0.0; result[i] = 0.0; for (let j = mn; j < mx; ++j) { let wd = Math.exp(-0.5 * (i - j) * (...
javascript
function smooth(d, w) { let result = []; for (let i = 0, l = d.length; i < l; ++i) { let mn = Math.max(0, i - 5 * w), mx = Math.min(d.length - 1, i + 5 * w), s = 0.0; result[i] = 0.0; for (let j = mn; j < mx; ++j) { let wd = Math.exp(-0.5 * (i - j) * (...
[ "function", "smooth", "(", "d", ",", "w", ")", "{", "let", "result", "=", "[", "]", ";", "for", "(", "let", "i", "=", "0", ",", "l", "=", "d", ".", "length", ";", "i", "<", "l", ";", "++", "i", ")", "{", "let", "mn", "=", "Math", ".", "...
Smooth some data with a given window size.
[ "Smooth", "some", "data", "with", "a", "given", "window", "size", "." ]
9b126fd50ad7ae757303734fc290868ea49c9620
https://github.com/redsift/ui-rs-core/blob/9b126fd50ad7ae757303734fc290868ea49c9620/src/js/xkcd/index.js#L2-L17
train
biggora/trinte-creator
app/bin/router.js
TrinteBridge
function TrinteBridge(namespace, controller, action) { var responseHandler; if (typeof action === 'function') { return action; } try { if (/\//.test(controller)) { var cnts = controller.split('/'); namespace = cnts[0] + '/'; controller = cnts[1]; ...
javascript
function TrinteBridge(namespace, controller, action) { var responseHandler; if (typeof action === 'function') { return action; } try { if (/\//.test(controller)) { var cnts = controller.split('/'); namespace = cnts[0] + '/'; controller = cnts[1]; ...
[ "function", "TrinteBridge", "(", "namespace", ",", "controller", ",", "action", ")", "{", "var", "responseHandler", ";", "if", "(", "typeof", "action", "===", "'function'", ")", "{", "return", "action", ";", "}", "try", "{", "if", "(", "/", "\\/", "/", ...
Some TrinteBridge method that will server requests from routing map to application @param {String} namespace @param {String} controller @param {String} action @return {Function} responseHandler
[ "Some", "TrinteBridge", "method", "that", "will", "server", "requests", "from", "routing", "map", "to", "application" ]
fdd723405418967ca8a690867940863fd77e636b
https://github.com/biggora/trinte-creator/blob/fdd723405418967ca8a690867940863fd77e636b/app/bin/router.js#L16-L44
train
biggora/trinte-creator
app/bin/router.js
getActiveRoutes
function getActiveRoutes(params) { var activeRoutes = {}, availableRoutes = { 'index': 'GET /', 'create': 'POST /', 'new': 'GET /new', 'edit': 'GET /:id/edit', 'destroy': 'DELETE /:id', ...
javascript
function getActiveRoutes(params) { var activeRoutes = {}, availableRoutes = { 'index': 'GET /', 'create': 'POST /', 'new': 'GET /new', 'edit': 'GET /:id/edit', 'destroy': 'DELETE /:id', ...
[ "function", "getActiveRoutes", "(", "params", ")", "{", "var", "activeRoutes", "=", "{", "}", ",", "availableRoutes", "=", "{", "'index'", ":", "'GET /'", ",", "'create'", ":", "'POST /'", ",", "'new'", ":", "'GET /new'", ",", "'edit'", ":", "'GET...
calculate set of routes based on params.only and params.except
[ "calculate", "set", "of", "routes", "based", "on", "params", ".", "only", "and", "params", ".", "except" ]
fdd723405418967ca8a690867940863fd77e636b
https://github.com/biggora/trinte-creator/blob/fdd723405418967ca8a690867940863fd77e636b/app/bin/router.js#L392-L450
train
angelozerr/tern-yui3
generator/yuidoc2tern.js
function(yuiType, c) { var index = yuiType.indexOf(c); if (index != -1) { yuiType = yuiType.substring(0, index); yuiType = yuiType.trim(); } return yuiType; }
javascript
function(yuiType, c) { var index = yuiType.indexOf(c); if (index != -1) { yuiType = yuiType.substring(0, index); yuiType = yuiType.trim(); } return yuiType; }
[ "function", "(", "yuiType", ",", "c", ")", "{", "var", "index", "=", "yuiType", ".", "indexOf", "(", "c", ")", ";", "if", "(", "index", "!=", "-", "1", ")", "{", "yuiType", "=", "yuiType", ".", "substring", "(", "0", ",", "index", ")", ";", "yu...
YUI -> Tern type
[ "YUI", "-", ">", "Tern", "type" ]
9fc454aa0e426cd2eb713d8320c1d9ecd019bd1a
https://github.com/angelozerr/tern-yui3/blob/9fc454aa0e426cd2eb713d8320c1d9ecd019bd1a/generator/yuidoc2tern.js#L287-L294
train
AndreasMadsen/thintalk
lib/core/requester.js
request
function request(ipc, name, args) { // check online if (!ipc.root.online) { ipc.root.emit('error', new Error("Could not make a request, channel is offline")); return; } // store callback for later var callback = args.pop(); // check that a callback is set if (typeof callback !== 'function') { ...
javascript
function request(ipc, name, args) { // check online if (!ipc.root.online) { ipc.root.emit('error', new Error("Could not make a request, channel is offline")); return; } // store callback for later var callback = args.pop(); // check that a callback is set if (typeof callback !== 'function') { ...
[ "function", "request", "(", "ipc", ",", "name", ",", "args", ")", "{", "// check online", "if", "(", "!", "ipc", ".", "root", ".", "online", ")", "{", "ipc", ".", "root", ".", "emit", "(", "'error'", ",", "new", "Error", "(", "\"Could not make a reques...
request a method from the listener
[ "request", "a", "method", "from", "the", "listener" ]
1ea0c2703d303874fc50d8efb2013ee4d7dadeb1
https://github.com/AndreasMadsen/thintalk/blob/1ea0c2703d303874fc50d8efb2013ee4d7dadeb1/lib/core/requester.js#L121-L150
train
Aniket965/emojifylogs
app.js
setEmoji
function setEmoji(type,emojiDefault, emojiInfo, emojiError, emojiWarn) { let icon = emojiDefault switch (type) { case 'info': icon = emojiInfo break case 'error': icon = emojiError break case 'warn': icon = emojiWarn break default: } return icon }
javascript
function setEmoji(type,emojiDefault, emojiInfo, emojiError, emojiWarn) { let icon = emojiDefault switch (type) { case 'info': icon = emojiInfo break case 'error': icon = emojiError break case 'warn': icon = emojiWarn break default: } return icon }
[ "function", "setEmoji", "(", "type", ",", "emojiDefault", ",", "emojiInfo", ",", "emojiError", ",", "emojiWarn", ")", "{", "let", "icon", "=", "emojiDefault", "switch", "(", "type", ")", "{", "case", "'info'", ":", "icon", "=", "emojiInfo", "break", "case"...
map icon to Given Type @param {string} type @param {*} emojiDefault @param {*} emojiInfo @param {*} emojiError @param {*} emojiWarn
[ "map", "icon", "to", "Given", "Type" ]
eeb4adad01ed102725368676a605ebbc59b9cd83
https://github.com/Aniket965/emojifylogs/blob/eeb4adad01ed102725368676a605ebbc59b9cd83/app.js#L9-L24
train
iceroad/baresoil-server
lib/util/setupCLI.js
ShowVersion
function ShowVersion(packageJson) { const pkgName = packageJson.name; let latestVer = spawnSync(`npm show ${pkgName} version`, { shell: true, stdio: ['inherit', 'pipe', 'inherit'], }).stdout; let latestVerStr = ''; if (latestVer) { latestVer = latestVer.toString('utf-8').replace(/\s/gm, ''); ...
javascript
function ShowVersion(packageJson) { const pkgName = packageJson.name; let latestVer = spawnSync(`npm show ${pkgName} version`, { shell: true, stdio: ['inherit', 'pipe', 'inherit'], }).stdout; let latestVerStr = ''; if (latestVer) { latestVer = latestVer.toString('utf-8').replace(/\s/gm, ''); ...
[ "function", "ShowVersion", "(", "packageJson", ")", "{", "const", "pkgName", "=", "packageJson", ".", "name", ";", "let", "latestVer", "=", "spawnSync", "(", "`", "${", "pkgName", "}", "`", ",", "{", "shell", ":", "true", ",", "stdio", ":", "[", "'inhe...
Check for latest package version on npm, return warning on outdated version.
[ "Check", "for", "latest", "package", "version", "on", "npm", "return", "warning", "on", "outdated", "version", "." ]
8285f1647a81eb935331ea24491b38002b51278d
https://github.com/iceroad/baresoil-server/blob/8285f1647a81eb935331ea24491b38002b51278d/lib/util/setupCLI.js#L12-L32
train
iceroad/baresoil-server
lib/util/setupCLI.js
GetCommandList
function GetCommandList(execName, packageJson, Commands) { const header = `\ ${packageJson.title || packageJson.name || execName} ${packageJson.version} Usage: ${execName} ${col.bold('<command>')} [options] Commands:`; const grouped = _.groupBy(Commands, 'helpGroup'); const sorted = _.mapValues(grouped, arr =...
javascript
function GetCommandList(execName, packageJson, Commands) { const header = `\ ${packageJson.title || packageJson.name || execName} ${packageJson.version} Usage: ${execName} ${col.bold('<command>')} [options] Commands:`; const grouped = _.groupBy(Commands, 'helpGroup'); const sorted = _.mapValues(grouped, arr =...
[ "function", "GetCommandList", "(", "execName", ",", "packageJson", ",", "Commands", ")", "{", "const", "header", "=", "`", "\\\n", "${", "packageJson", ".", "title", "||", "packageJson", ".", "name", "||", "execName", "}", "${", "packageJson", ".", "version"...
Get list of available sub-commands for package.
[ "Get", "list", "of", "available", "sub", "-", "commands", "for", "package", "." ]
8285f1647a81eb935331ea24491b38002b51278d
https://github.com/iceroad/baresoil-server/blob/8285f1647a81eb935331ea24491b38002b51278d/lib/util/setupCLI.js#L37-L63
train
iceroad/baresoil-server
lib/util/setupCLI.js
GetCommandUsage
function GetCommandUsage(execName, packageJson, cmdSpec, args) { const argSpec = cmdSpec.argSpec || []; const optStr = argSpec.length ? ' [options]' : ''; const header = `\ Usage: ${execName} ${cmdSpec.name}${optStr} Purpose: ${cmdSpec.desc} Options: ${argSpec.length ? '' : 'none.'}`; const usageTableRows = ...
javascript
function GetCommandUsage(execName, packageJson, cmdSpec, args) { const argSpec = cmdSpec.argSpec || []; const optStr = argSpec.length ? ' [options]' : ''; const header = `\ Usage: ${execName} ${cmdSpec.name}${optStr} Purpose: ${cmdSpec.desc} Options: ${argSpec.length ? '' : 'none.'}`; const usageTableRows = ...
[ "function", "GetCommandUsage", "(", "execName", ",", "packageJson", ",", "cmdSpec", ",", "args", ")", "{", "const", "argSpec", "=", "cmdSpec", ".", "argSpec", "||", "[", "]", ";", "const", "optStr", "=", "argSpec", ".", "length", "?", "' [options]'", ":", ...
Get command-specific help.
[ "Get", "command", "-", "specific", "help", "." ]
8285f1647a81eb935331ea24491b38002b51278d
https://github.com/iceroad/baresoil-server/blob/8285f1647a81eb935331ea24491b38002b51278d/lib/util/setupCLI.js#L68-L115
train
iceroad/baresoil-server
lib/util/setupCLI.js
ParseArguments
function ParseArguments(cmd, args) { assert(_.isObject(cmd), 'require an object argument for "cmd".'); assert(_.isObject(args), 'require an object argument for "args".'); const argSpec = cmd.argSpec || []; const cmdName = cmd.name; // // Build a map of all flag aliases. // const allAliases = _.fromPair...
javascript
function ParseArguments(cmd, args) { assert(_.isObject(cmd), 'require an object argument for "cmd".'); assert(_.isObject(args), 'require an object argument for "args".'); const argSpec = cmd.argSpec || []; const cmdName = cmd.name; // // Build a map of all flag aliases. // const allAliases = _.fromPair...
[ "function", "ParseArguments", "(", "cmd", ",", "args", ")", "{", "assert", "(", "_", ".", "isObject", "(", "cmd", ")", ",", "'require an object argument for \"cmd\".'", ")", ";", "assert", "(", "_", ".", "isObject", "(", "args", ")", ",", "'require an object...
Parse command-line arguments.
[ "Parse", "command", "-", "line", "arguments", "." ]
8285f1647a81eb935331ea24491b38002b51278d
https://github.com/iceroad/baresoil-server/blob/8285f1647a81eb935331ea24491b38002b51278d/lib/util/setupCLI.js#L120-L196
train
xiamidaxia/xiami
meteor/minimongo/selector.js
function (selector) { var self = this; // you can pass a literal function instead of a selector if (_.isFunction(selector)) { self._isSimple = false; self._selector = selector; self._recordPathUsed(''); return function (doc) { return {result: !!selector.call(doc)}; }; ...
javascript
function (selector) { var self = this; // you can pass a literal function instead of a selector if (_.isFunction(selector)) { self._isSimple = false; self._selector = selector; self._recordPathUsed(''); return function (doc) { return {result: !!selector.call(doc)}; }; ...
[ "function", "(", "selector", ")", "{", "var", "self", "=", "this", ";", "// you can pass a literal function instead of a selector", "if", "(", "_", ".", "isFunction", "(", "selector", ")", ")", "{", "self", ".", "_isSimple", "=", "false", ";", "self", ".", "...
Given a selector, return a function that takes one argument, a document. It returns a result object.
[ "Given", "a", "selector", "return", "a", "function", "that", "takes", "one", "argument", "a", "document", ".", "It", "returns", "a", "result", "object", "." ]
6fcee92c493c12bf8fd67c7068e67fa6a72a306b
https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/minimongo/selector.js#L82-L118
train
xiamidaxia/xiami
meteor/minimongo/selector.js
function (v) { if (typeof v === "number") return 1; if (typeof v === "string") return 2; if (typeof v === "boolean") return 8; if (isArray(v)) return 4; if (v === null) return 10; if (_.isRegExp(v)) // note that typeof(/x/) === "object" return 11; if...
javascript
function (v) { if (typeof v === "number") return 1; if (typeof v === "string") return 2; if (typeof v === "boolean") return 8; if (isArray(v)) return 4; if (v === null) return 10; if (_.isRegExp(v)) // note that typeof(/x/) === "object" return 11; if...
[ "function", "(", "v", ")", "{", "if", "(", "typeof", "v", "===", "\"number\"", ")", "return", "1", ";", "if", "(", "typeof", "v", "===", "\"string\"", ")", "return", "2", ";", "if", "(", "typeof", "v", "===", "\"boolean\"", ")", "return", "8", ";",...
XXX for _all and _in, consider building 'inquery' at compile time..
[ "XXX", "for", "_all", "and", "_in", "consider", "building", "inquery", "at", "compile", "time", ".." ]
6fcee92c493c12bf8fd67c7068e67fa6a72a306b
https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/minimongo/selector.js#L975-L1006
train
brentlintner/arctor
deps/browser-require/require.js
normalizeArray
function normalizeArray (v, keepBlanks) { var L = v.length, dst = new Array(L), dsti = 0, i = 0, part, negatives = 0, isRelative = (L && v[0] !== ''); for (; i<L; ++i) { part = v[i]; if (part === '..') { if (dsti > 1) { --dsti; } else if (isRelative) { ...
javascript
function normalizeArray (v, keepBlanks) { var L = v.length, dst = new Array(L), dsti = 0, i = 0, part, negatives = 0, isRelative = (L && v[0] !== ''); for (; i<L; ++i) { part = v[i]; if (part === '..') { if (dsti > 1) { --dsti; } else if (isRelative) { ...
[ "function", "normalizeArray", "(", "v", ",", "keepBlanks", ")", "{", "var", "L", "=", "v", ".", "length", ",", "dst", "=", "new", "Array", "(", "L", ")", ",", "dsti", "=", "0", ",", "i", "=", "0", ",", "part", ",", "negatives", "=", "0", ",", ...
normalize an array of path components
[ "normalize", "an", "array", "of", "path", "components" ]
557110f0bde85f23a3af8a03d9bfc01cd9ecf4dd
https://github.com/brentlintner/arctor/blob/557110f0bde85f23a3af8a03d9bfc01cd9ecf4dd/deps/browser-require/require.js#L5-L30
train
brentlintner/arctor
deps/browser-require/require.js
normalizeId
function normalizeId(id, parentId) { id = id.replace(/\/+$/g, ''); return normalizeArray((parentId ? parentId + '/../' + id : id).split('/')) .join('/'); }
javascript
function normalizeId(id, parentId) { id = id.replace(/\/+$/g, ''); return normalizeArray((parentId ? parentId + '/../' + id : id).split('/')) .join('/'); }
[ "function", "normalizeId", "(", "id", ",", "parentId", ")", "{", "id", "=", "id", ".", "replace", "(", "/", "\\/+$", "/", "g", ",", "''", ")", ";", "return", "normalizeArray", "(", "(", "parentId", "?", "parentId", "+", "'/../'", "+", "id", ":", "i...
normalize an id
[ "normalize", "an", "id" ]
557110f0bde85f23a3af8a03d9bfc01cd9ecf4dd
https://github.com/brentlintner/arctor/blob/557110f0bde85f23a3af8a03d9bfc01cd9ecf4dd/deps/browser-require/require.js#L32-L36
train
brentlintner/arctor
deps/browser-require/require.js
normalizeUrl
function normalizeUrl(url, baseLocation) { if (!(/^\w+:/).test(url)) { var u = baseLocation.protocol+'//'+baseLocation.hostname; if (baseLocation.port && baseLocation.port !== 80) { u += ':'+baseLocation.port; } var path = baseLocation.pathname; if (url.charAt(0) === '/') { ...
javascript
function normalizeUrl(url, baseLocation) { if (!(/^\w+:/).test(url)) { var u = baseLocation.protocol+'//'+baseLocation.hostname; if (baseLocation.port && baseLocation.port !== 80) { u += ':'+baseLocation.port; } var path = baseLocation.pathname; if (url.charAt(0) === '/') { ...
[ "function", "normalizeUrl", "(", "url", ",", "baseLocation", ")", "{", "if", "(", "!", "(", "/", "^\\w+:", "/", ")", ".", "test", "(", "url", ")", ")", "{", "var", "u", "=", "baseLocation", ".", "protocol", "+", "'//'", "+", "baseLocation", ".", "h...
normalize a url
[ "normalize", "a", "url" ]
557110f0bde85f23a3af8a03d9bfc01cd9ecf4dd
https://github.com/brentlintner/arctor/blob/557110f0bde85f23a3af8a03d9bfc01cd9ecf4dd/deps/browser-require/require.js#L38-L53
train
JohnnieFucker/dreamix-monitor
lib/processMonitor.js
format
function format(param, data, cb) { const time = util.formatTime(new Date()); const outArray = data.toString().replace(/^\s+|\s+$/g, '').split(/\s+/); let outValueArray = []; for (let i = 0; i < outArray.length; i++) { if ((!isNaN(outArray[i]))) { outValueArray.push(outArray[i]); ...
javascript
function format(param, data, cb) { const time = util.formatTime(new Date()); const outArray = data.toString().replace(/^\s+|\s+$/g, '').split(/\s+/); let outValueArray = []; for (let i = 0; i < outArray.length; i++) { if ((!isNaN(outArray[i]))) { outValueArray.push(outArray[i]); ...
[ "function", "format", "(", "param", ",", "data", ",", "cb", ")", "{", "const", "time", "=", "util", ".", "formatTime", "(", "new", "Date", "(", ")", ")", ";", "const", "outArray", "=", "data", ".", "toString", "(", ")", ".", "replace", "(", "/", ...
convert serverInfo to required format, and the callback will handle the serverInfo @param {Object} param, contains serverId etc @param {String} data, the output if the command 'ps' @param {Function} cb @api private
[ "convert", "serverInfo", "to", "required", "format", "and", "the", "callback", "will", "handle", "the", "serverInfo" ]
c9e18d386f48a9bfca9dcb6211229cea3a0eed0e
https://github.com/JohnnieFucker/dreamix-monitor/blob/c9e18d386f48a9bfca9dcb6211229cea3a0eed0e/lib/processMonitor.js#L18-L62
train
eliranmal/npm-package-env
lib/namespace.js
slice
function slice(toToken) { if (has(toToken) && !isLast(toToken)) { _tokens = _tokens.slice(0, _tokens.lastIndexOf(toToken) + 1); } }
javascript
function slice(toToken) { if (has(toToken) && !isLast(toToken)) { _tokens = _tokens.slice(0, _tokens.lastIndexOf(toToken) + 1); } }
[ "function", "slice", "(", "toToken", ")", "{", "if", "(", "has", "(", "toToken", ")", "&&", "!", "isLast", "(", "toToken", ")", ")", "{", "_tokens", "=", "_tokens", ".", "slice", "(", "0", ",", "_tokens", ".", "lastIndexOf", "(", "toToken", ")", "+...
removes last tokens, up to and not including the specified token. @param toToken the token to back into (exclusive!)
[ "removes", "last", "tokens", "up", "to", "and", "not", "including", "the", "specified", "token", "." ]
4af33e9e388f72b895b27c00bbbe29407715b7b5
https://github.com/eliranmal/npm-package-env/blob/4af33e9e388f72b895b27c00bbbe29407715b7b5/lib/namespace.js#L39-L43
train