id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
sequence
docstring
stringlengths
4
11.8k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
86
226
50,500
hubiquitus/hubiquitus-gateway
index.js
sendHeartbeat
function sendHeartbeat() { _.forOwn(_this.socks, function (sock) { sock.write('hb'); }); setTimeout(sendHeartbeat, _this.heartbeatFreq); }
javascript
function sendHeartbeat() { _.forOwn(_this.socks, function (sock) { sock.write('hb'); }); setTimeout(sendHeartbeat, _this.heartbeatFreq); }
[ "function", "sendHeartbeat", "(", ")", "{", "_", ".", "forOwn", "(", "_this", ".", "socks", ",", "function", "(", "sock", ")", "{", "sock", ".", "write", "(", "'hb'", ")", ";", "}", ")", ";", "setTimeout", "(", "sendHeartbeat", ",", "_this", ".", "heartbeatFreq", ")", ";", "}" ]
Send a heartbeat to all opened sockets
[ "Send", "a", "heartbeat", "to", "all", "opened", "sockets" ]
4f2466ef818eb4cfa60be6640f4d84dbeadb2da7
https://github.com/hubiquitus/hubiquitus-gateway/blob/4f2466ef818eb4cfa60be6640f4d84dbeadb2da7/index.js#L192-L197
50,501
hubiquitus/hubiquitus-gateway
index.js
checkClientsHeartbeat
function checkClientsHeartbeat() { var now = Date.now(); _.forOwn(_this.socks, function (sock) { if (sock.hb + _this.clientTimeout < now) { logout(sock); } }); setTimeout(checkClientsHeartbeat, 1000) }
javascript
function checkClientsHeartbeat() { var now = Date.now(); _.forOwn(_this.socks, function (sock) { if (sock.hb + _this.clientTimeout < now) { logout(sock); } }); setTimeout(checkClientsHeartbeat, 1000) }
[ "function", "checkClientsHeartbeat", "(", ")", "{", "var", "now", "=", "Date", ".", "now", "(", ")", ";", "_", ".", "forOwn", "(", "_this", ".", "socks", ",", "function", "(", "sock", ")", "{", "if", "(", "sock", ".", "hb", "+", "_this", ".", "clientTimeout", "<", "now", ")", "{", "logout", "(", "sock", ")", ";", "}", "}", ")", ";", "setTimeout", "(", "checkClientsHeartbeat", ",", "1000", ")", "}" ]
Check that all clients respond to the heartbeat in time
[ "Check", "that", "all", "clients", "respond", "to", "the", "heartbeat", "in", "time" ]
4f2466ef818eb4cfa60be6640f4d84dbeadb2da7
https://github.com/hubiquitus/hubiquitus-gateway/blob/4f2466ef818eb4cfa60be6640f4d84dbeadb2da7/index.js#L203-L211
50,502
derdesign/protos
engines/ejs.js
EJS
function EJS() { var opts = (app.config.engines && app.config.engines.ejs) || {}; this.options = protos.extend({ delimiter: '?' }, opts); this.module = ejs; this.multiPart = true; this.extensions = ['ejs', 'ejs.html']; }
javascript
function EJS() { var opts = (app.config.engines && app.config.engines.ejs) || {}; this.options = protos.extend({ delimiter: '?' }, opts); this.module = ejs; this.multiPart = true; this.extensions = ['ejs', 'ejs.html']; }
[ "function", "EJS", "(", ")", "{", "var", "opts", "=", "(", "app", ".", "config", ".", "engines", "&&", "app", ".", "config", ".", "engines", ".", "ejs", ")", "||", "{", "}", ";", "this", ".", "options", "=", "protos", ".", "extend", "(", "{", "delimiter", ":", "'?'", "}", ",", "opts", ")", ";", "this", ".", "module", "=", "ejs", ";", "this", ".", "multiPart", "=", "true", ";", "this", ".", "extensions", "=", "[", "'ejs'", ",", "'ejs.html'", "]", ";", "}" ]
EJS engine class https://github.com/mde/ejs
[ "EJS", "engine", "class" ]
0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9
https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/engines/ejs.js#L14-L26
50,503
vkiding/jud-vue-render
src/render/browser/extend/components/slider/carrousel.js
cloneEvents
function cloneEvents(origin, clone, deep) { var listeners = origin._listeners if (listeners) { clone._listeners = listeners for (var type in listeners) { clone.addEventListener(type, listeners[type]) } } if (deep && origin.children && origin.children.length) { for (var i = 0, l = origin.children.length; i < l; i++) { cloneEvents(origin.children[i], clone.children[i], deep) } } }
javascript
function cloneEvents(origin, clone, deep) { var listeners = origin._listeners if (listeners) { clone._listeners = listeners for (var type in listeners) { clone.addEventListener(type, listeners[type]) } } if (deep && origin.children && origin.children.length) { for (var i = 0, l = origin.children.length; i < l; i++) { cloneEvents(origin.children[i], clone.children[i], deep) } } }
[ "function", "cloneEvents", "(", "origin", ",", "clone", ",", "deep", ")", "{", "var", "listeners", "=", "origin", ".", "_listeners", "if", "(", "listeners", ")", "{", "clone", ".", "_listeners", "=", "listeners", "for", "(", "var", "type", "in", "listeners", ")", "{", "clone", ".", "addEventListener", "(", "type", ",", "listeners", "[", "type", "]", ")", "}", "}", "if", "(", "deep", "&&", "origin", ".", "children", "&&", "origin", ".", "children", ".", "length", ")", "{", "for", "(", "var", "i", "=", "0", ",", "l", "=", "origin", ".", "children", ".", "length", ";", "i", "<", "l", ";", "i", "++", ")", "{", "cloneEvents", "(", "origin", ".", "children", "[", "i", "]", ",", "clone", ".", "children", "[", "i", "]", ",", "deep", ")", "}", "}", "}" ]
If there a _listeners attribute on the dom element then clone the _listeners as well for the events' binding
[ "If", "there", "a", "_listeners", "attribute", "on", "the", "dom", "element", "then", "clone", "the", "_listeners", "as", "well", "for", "the", "events", "binding" ]
07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47
https://github.com/vkiding/jud-vue-render/blob/07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47/src/render/browser/extend/components/slider/carrousel.js#L153-L166
50,504
Digznav/bilberry
promise-read-files.js
promiseReadFiles
function promiseReadFiles(pattern) { return glob(pattern) .then(foundFiles => { const promisesToReadFiles = foundFiles.map(fileName => pReadFile(fileName)); return Promise.all(promisesToReadFiles); }) .catch(log.error); }
javascript
function promiseReadFiles(pattern) { return glob(pattern) .then(foundFiles => { const promisesToReadFiles = foundFiles.map(fileName => pReadFile(fileName)); return Promise.all(promisesToReadFiles); }) .catch(log.error); }
[ "function", "promiseReadFiles", "(", "pattern", ")", "{", "return", "glob", "(", "pattern", ")", ".", "then", "(", "foundFiles", "=>", "{", "const", "promisesToReadFiles", "=", "foundFiles", ".", "map", "(", "fileName", "=>", "pReadFile", "(", "fileName", ")", ")", ";", "return", "Promise", ".", "all", "(", "promisesToReadFiles", ")", ";", "}", ")", ".", "catch", "(", "log", ".", "error", ")", ";", "}" ]
Get the content of files using the patterns the shell uses, like stars and stuff. @param {string} pattern Regex pattern. @return {promise} Glob promise to get the content.
[ "Get", "the", "content", "of", "files", "using", "the", "patterns", "the", "shell", "uses", "like", "stars", "and", "stuff", "." ]
ef6db49de6c8b0d2f4f9d3e10e8a8153e39ffcc4
https://github.com/Digznav/bilberry/blob/ef6db49de6c8b0d2f4f9d3e10e8a8153e39ffcc4/promise-read-files.js#L10-L18
50,505
jldec/pub-serve-sessions
serve-sessions.js
isAuthorized
function isAuthorized(acl, user) { acl = u.str(acl).toUpperCase(); user = u.str(user).toUpperCase(); if (user && user === acl) return true; if (!aclRe[acl]) { aclRe[acl] = reAccess(sessionOpts.acl[acl] || process.env['ACL_' + acl]); } return aclRe[acl].test(user) || aclRe.ADMIN.test(user); }
javascript
function isAuthorized(acl, user) { acl = u.str(acl).toUpperCase(); user = u.str(user).toUpperCase(); if (user && user === acl) return true; if (!aclRe[acl]) { aclRe[acl] = reAccess(sessionOpts.acl[acl] || process.env['ACL_' + acl]); } return aclRe[acl].test(user) || aclRe.ADMIN.test(user); }
[ "function", "isAuthorized", "(", "acl", ",", "user", ")", "{", "acl", "=", "u", ".", "str", "(", "acl", ")", ".", "toUpperCase", "(", ")", ";", "user", "=", "u", ".", "str", "(", "user", ")", ".", "toUpperCase", "(", ")", ";", "if", "(", "user", "&&", "user", "===", "acl", ")", "return", "true", ";", "if", "(", "!", "aclRe", "[", "acl", "]", ")", "{", "aclRe", "[", "acl", "]", "=", "reAccess", "(", "sessionOpts", ".", "acl", "[", "acl", "]", "||", "process", ".", "env", "[", "'ACL_'", "+", "acl", "]", ")", ";", "}", "return", "aclRe", "[", "acl", "]", ".", "test", "(", "user", ")", "||", "aclRe", ".", "ADMIN", ".", "test", "(", "user", ")", ";", "}" ]
low-level authz api - returns true if user matches or belongs to acl
[ "low", "-", "level", "authz", "api", "-", "returns", "true", "if", "user", "matches", "or", "belongs", "to", "acl" ]
5164480af2632cda59bfed236e92fa7c1a988418
https://github.com/jldec/pub-serve-sessions/blob/5164480af2632cda59bfed236e92fa7c1a988418/serve-sessions.js#L153-L161
50,506
jldec/pub-serve-sessions
serve-sessions.js
reAccess
function reAccess(s) { var list = s ? s.split(/[, ]+/) : []; // avoid [''] return new RegExp( u.map(list, function(s) { return '^' + u.escapeRegExp(s) + '$'; // exact matches only }).join('|') // join([]) returns '' || '$(?=.)' // avoid default regexp /(?:)/ , 'i'); // not case-sensitive }
javascript
function reAccess(s) { var list = s ? s.split(/[, ]+/) : []; // avoid [''] return new RegExp( u.map(list, function(s) { return '^' + u.escapeRegExp(s) + '$'; // exact matches only }).join('|') // join([]) returns '' || '$(?=.)' // avoid default regexp /(?:)/ , 'i'); // not case-sensitive }
[ "function", "reAccess", "(", "s", ")", "{", "var", "list", "=", "s", "?", "s", ".", "split", "(", "/", "[, ]+", "/", ")", ":", "[", "]", ";", "// avoid ['']", "return", "new", "RegExp", "(", "u", ".", "map", "(", "list", ",", "function", "(", "s", ")", "{", "return", "'^'", "+", "u", ".", "escapeRegExp", "(", "s", ")", "+", "'$'", ";", "// exact matches only", "}", ")", ".", "join", "(", "'|'", ")", "// join([]) returns ''", "||", "'$(?=.)'", "// avoid default regexp /(?:)/", ",", "'i'", ")", ";", "// not case-sensitive", "}" ]
turns ACLs into regexps
[ "turns", "ACLs", "into", "regexps" ]
5164480af2632cda59bfed236e92fa7c1a988418
https://github.com/jldec/pub-serve-sessions/blob/5164480af2632cda59bfed236e92fa7c1a988418/serve-sessions.js#L164-L172
50,507
jldec/pub-serve-sessions
serve-sessions.js
saveOldSessions
function saveOldSessions() { var db = self.store; var oldDestroy = db.destroy; db.destroy = newDestroy; return; // rename instead of delete function newDestroy(sid, cb) { db.get(sid, function(err, session) { if (err) return cb(err); if (!session) return cb(); db.set(sid + '_d', session, function(err) { if (err) return cb(err); oldDestroy.call(db, sid, cb); }); }); } }
javascript
function saveOldSessions() { var db = self.store; var oldDestroy = db.destroy; db.destroy = newDestroy; return; // rename instead of delete function newDestroy(sid, cb) { db.get(sid, function(err, session) { if (err) return cb(err); if (!session) return cb(); db.set(sid + '_d', session, function(err) { if (err) return cb(err); oldDestroy.call(db, sid, cb); }); }); } }
[ "function", "saveOldSessions", "(", ")", "{", "var", "db", "=", "self", ".", "store", ";", "var", "oldDestroy", "=", "db", ".", "destroy", ";", "db", ".", "destroy", "=", "newDestroy", ";", "return", ";", "// rename instead of delete", "function", "newDestroy", "(", "sid", ",", "cb", ")", "{", "db", ".", "get", "(", "sid", ",", "function", "(", "err", ",", "session", ")", "{", "if", "(", "err", ")", "return", "cb", "(", "err", ")", ";", "if", "(", "!", "session", ")", "return", "cb", "(", ")", ";", "db", ".", "set", "(", "sid", "+", "'_d'", ",", "session", ",", "function", "(", "err", ")", "{", "if", "(", "err", ")", "return", "cb", "(", "err", ")", ";", "oldDestroy", ".", "call", "(", "db", ",", "sid", ",", "cb", ")", ";", "}", ")", ";", "}", ")", ";", "}", "}" ]
replace session.store destroy handler with a replacement which saves a copy of the session using sid_d first
[ "replace", "session", ".", "store", "destroy", "handler", "with", "a", "replacement", "which", "saves", "a", "copy", "of", "the", "session", "using", "sid_d", "first" ]
5164480af2632cda59bfed236e92fa7c1a988418
https://github.com/jldec/pub-serve-sessions/blob/5164480af2632cda59bfed236e92fa7c1a988418/serve-sessions.js#L176-L193
50,508
jldec/pub-serve-sessions
serve-sessions.js
newDestroy
function newDestroy(sid, cb) { db.get(sid, function(err, session) { if (err) return cb(err); if (!session) return cb(); db.set(sid + '_d', session, function(err) { if (err) return cb(err); oldDestroy.call(db, sid, cb); }); }); }
javascript
function newDestroy(sid, cb) { db.get(sid, function(err, session) { if (err) return cb(err); if (!session) return cb(); db.set(sid + '_d', session, function(err) { if (err) return cb(err); oldDestroy.call(db, sid, cb); }); }); }
[ "function", "newDestroy", "(", "sid", ",", "cb", ")", "{", "db", ".", "get", "(", "sid", ",", "function", "(", "err", ",", "session", ")", "{", "if", "(", "err", ")", "return", "cb", "(", "err", ")", ";", "if", "(", "!", "session", ")", "return", "cb", "(", ")", ";", "db", ".", "set", "(", "sid", "+", "'_d'", ",", "session", ",", "function", "(", "err", ")", "{", "if", "(", "err", ")", "return", "cb", "(", "err", ")", ";", "oldDestroy", ".", "call", "(", "db", ",", "sid", ",", "cb", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
rename instead of delete
[ "rename", "instead", "of", "delete" ]
5164480af2632cda59bfed236e92fa7c1a988418
https://github.com/jldec/pub-serve-sessions/blob/5164480af2632cda59bfed236e92fa7c1a988418/serve-sessions.js#L183-L192
50,509
xiamidaxia/xiami
meteor/minimongo/sort.js
function (i) { var self = this; var invert = !self._sortSpecParts[i].ascending; return function (key1, key2) { var compare = LocalCollection._f._cmp(key1[i], key2[i]); if (invert) compare = -compare; return compare; }; }
javascript
function (i) { var self = this; var invert = !self._sortSpecParts[i].ascending; return function (key1, key2) { var compare = LocalCollection._f._cmp(key1[i], key2[i]); if (invert) compare = -compare; return compare; }; }
[ "function", "(", "i", ")", "{", "var", "self", "=", "this", ";", "var", "invert", "=", "!", "self", ".", "_sortSpecParts", "[", "i", "]", ".", "ascending", ";", "return", "function", "(", "key1", ",", "key2", ")", "{", "var", "compare", "=", "LocalCollection", ".", "_f", ".", "_cmp", "(", "key1", "[", "i", "]", ",", "key2", "[", "i", "]", ")", ";", "if", "(", "invert", ")", "compare", "=", "-", "compare", ";", "return", "compare", ";", "}", ";", "}" ]
Given an index 'i', returns a comparator that compares two key arrays based on field 'i'.
[ "Given", "an", "index", "i", "returns", "a", "comparator", "that", "compares", "two", "key", "arrays", "based", "on", "field", "i", "." ]
6fcee92c493c12bf8fd67c7068e67fa6a72a306b
https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/minimongo/sort.js#L269-L278
50,510
skerit/alchemy
lib/init/functions.js
doClose
function doClose(next, err) { if (fd > 0 && file_path !== fd) { fs.close(fd, function closed() { // Ignore errors next(err); }); } else { next(err); } }
javascript
function doClose(next, err) { if (fd > 0 && file_path !== fd) { fs.close(fd, function closed() { // Ignore errors next(err); }); } else { next(err); } }
[ "function", "doClose", "(", "next", ",", "err", ")", "{", "if", "(", "fd", ">", "0", "&&", "file_path", "!==", "fd", ")", "{", "fs", ".", "close", "(", "fd", ",", "function", "closed", "(", ")", "{", "// Ignore errors", "next", "(", "err", ")", ";", "}", ")", ";", "}", "else", "{", "next", "(", "err", ")", ";", "}", "}" ]
Function to close the descriptor
[ "Function", "to", "close", "the", "descriptor" ]
ede1dad07a5a737d5d1e10c2ff87fdfb057443f8
https://github.com/skerit/alchemy/blob/ede1dad07a5a737d5d1e10c2ff87fdfb057443f8/lib/init/functions.js#L765-L774
50,511
skerit/alchemy
lib/init/functions.js
mcFile
function mcFile(type, source, target, cb) { var targetDir, bin, cmd; if (type == 'cp' || type == 'copy') { bin = '/bin/cp'; } else if (type == 'mv' || type == 'move') { bin = '/bin/mv'; } // We assume the last piece of the target is the file name // Split the string by slashes targetDir = target.split('/'); // Remove the last piece targetDir.splice(targetDir.length-1, 1); // Join it again targetDir = targetDir.join('/'); // Make sure the target directory exists alchemy.createDir(targetDir, function ensuredDir(err) { if (err) { return cb(err); } spawnQueue.add(function queuecp(done) { var options = []; if (process.platform == 'linux') { options = ['--no-target-directory', source, target]; } else { if (source.endsWith('/')) { source = source.slice(0, -1); } if (target.endsWith('/')) { target = target.slice(0, -1); } options = [source, target]; } cmd = child.execFile(bin, options); cmd.on('exit', function onExit(code, signal) { var message; done(); if (code > 0) { message = 'File "' + type + '" operation failed:\n'; message += bin + ' ' + options.join(' '); cb(new Error(message)); } else { cb(null); } }); }); }); }
javascript
function mcFile(type, source, target, cb) { var targetDir, bin, cmd; if (type == 'cp' || type == 'copy') { bin = '/bin/cp'; } else if (type == 'mv' || type == 'move') { bin = '/bin/mv'; } // We assume the last piece of the target is the file name // Split the string by slashes targetDir = target.split('/'); // Remove the last piece targetDir.splice(targetDir.length-1, 1); // Join it again targetDir = targetDir.join('/'); // Make sure the target directory exists alchemy.createDir(targetDir, function ensuredDir(err) { if (err) { return cb(err); } spawnQueue.add(function queuecp(done) { var options = []; if (process.platform == 'linux') { options = ['--no-target-directory', source, target]; } else { if (source.endsWith('/')) { source = source.slice(0, -1); } if (target.endsWith('/')) { target = target.slice(0, -1); } options = [source, target]; } cmd = child.execFile(bin, options); cmd.on('exit', function onExit(code, signal) { var message; done(); if (code > 0) { message = 'File "' + type + '" operation failed:\n'; message += bin + ' ' + options.join(' '); cb(new Error(message)); } else { cb(null); } }); }); }); }
[ "function", "mcFile", "(", "type", ",", "source", ",", "target", ",", "cb", ")", "{", "var", "targetDir", ",", "bin", ",", "cmd", ";", "if", "(", "type", "==", "'cp'", "||", "type", "==", "'copy'", ")", "{", "bin", "=", "'/bin/cp'", ";", "}", "else", "if", "(", "type", "==", "'mv'", "||", "type", "==", "'move'", ")", "{", "bin", "=", "'/bin/mv'", ";", "}", "// We assume the last piece of the target is the file name", "// Split the string by slashes", "targetDir", "=", "target", ".", "split", "(", "'/'", ")", ";", "// Remove the last piece", "targetDir", ".", "splice", "(", "targetDir", ".", "length", "-", "1", ",", "1", ")", ";", "// Join it again", "targetDir", "=", "targetDir", ".", "join", "(", "'/'", ")", ";", "// Make sure the target directory exists", "alchemy", ".", "createDir", "(", "targetDir", ",", "function", "ensuredDir", "(", "err", ")", "{", "if", "(", "err", ")", "{", "return", "cb", "(", "err", ")", ";", "}", "spawnQueue", ".", "add", "(", "function", "queuecp", "(", "done", ")", "{", "var", "options", "=", "[", "]", ";", "if", "(", "process", ".", "platform", "==", "'linux'", ")", "{", "options", "=", "[", "'--no-target-directory'", ",", "source", ",", "target", "]", ";", "}", "else", "{", "if", "(", "source", ".", "endsWith", "(", "'/'", ")", ")", "{", "source", "=", "source", ".", "slice", "(", "0", ",", "-", "1", ")", ";", "}", "if", "(", "target", ".", "endsWith", "(", "'/'", ")", ")", "{", "target", "=", "target", ".", "slice", "(", "0", ",", "-", "1", ")", ";", "}", "options", "=", "[", "source", ",", "target", "]", ";", "}", "cmd", "=", "child", ".", "execFile", "(", "bin", ",", "options", ")", ";", "cmd", ".", "on", "(", "'exit'", ",", "function", "onExit", "(", "code", ",", "signal", ")", "{", "var", "message", ";", "done", "(", ")", ";", "if", "(", "code", ">", "0", ")", "{", "message", "=", "'File \"'", "+", "type", "+", "'\" operation failed:\\n'", ";", "message", "+=", "bin", "+", "' '", "+", "options", ".", "join", "(", "' '", ")", ";", "cb", "(", "new", "Error", "(", "message", ")", ")", ";", "}", "else", "{", "cb", "(", "null", ")", ";", "}", "}", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
Move or copy a file @author Jelle De Loecker <[email protected]> @since 0.0.1 @version 1.0.5 @param {String} source Origin path @param {String} target Target path @param {Function} cb
[ "Move", "or", "copy", "a", "file" ]
ede1dad07a5a737d5d1e10c2ff87fdfb057443f8
https://github.com/skerit/alchemy/blob/ede1dad07a5a737d5d1e10c2ff87fdfb057443f8/lib/init/functions.js#L982-L1048
50,512
jenkinsci/js-preferences
preferences/Preferences.js
Preferences
function Preferences(preferencesArray, namespace) { if (!preferencesArray) { throw new Error('Cannot create config. Must pass an array of properties!'); } this.store = {}; // store the keys we know this.keys = preferencesArray.map((item) => { this.store[item.key] = preference.newPreference(item.key, item.defaultValue, item.allowedValues, namespace); return item.key; }); }
javascript
function Preferences(preferencesArray, namespace) { if (!preferencesArray) { throw new Error('Cannot create config. Must pass an array of properties!'); } this.store = {}; // store the keys we know this.keys = preferencesArray.map((item) => { this.store[item.key] = preference.newPreference(item.key, item.defaultValue, item.allowedValues, namespace); return item.key; }); }
[ "function", "Preferences", "(", "preferencesArray", ",", "namespace", ")", "{", "if", "(", "!", "preferencesArray", ")", "{", "throw", "new", "Error", "(", "'Cannot create config. Must pass an array of properties!'", ")", ";", "}", "this", ".", "store", "=", "{", "}", ";", "// store the keys we know", "this", ".", "keys", "=", "preferencesArray", ".", "map", "(", "(", "item", ")", "=>", "{", "this", ".", "store", "[", "item", ".", "key", "]", "=", "preference", ".", "newPreference", "(", "item", ".", "key", ",", "item", ".", "defaultValue", ",", "item", ".", "allowedValues", ",", "namespace", ")", ";", "return", "item", ".", "key", ";", "}", ")", ";", "}" ]
Creates a configuration object based on preferences. This means we use localStorage to interact with the components. @param preferencesArray {Array} the preferences that we want to sync with the local storage @param {string} [namespace] - if no value we use default namespace @constructor @example const preferencesArray = [{ key: 'runDetails.logView', defaultValue: 'pipeline', allowedValues: ['classic', 'pipeline'], }, { key: 'runDetails.pipeline.updateOnFinish', defaultValue: 'default', allowedValues: ['default', 'never'], }, { key: 'runDetails.pipeline.showPending', defaultValue: 'default', allowedValues: ['default', 'never'], }, { key: 'runDetails.pipeline.karaoke', defaultValue: 'default', allowedValues: ['default', 'never'], }, ]; const karaokeConfig = preferences.newPreferences(preferencesArray);
[ "Creates", "a", "configuration", "object", "based", "on", "preferences", ".", "This", "means", "we", "use", "localStorage", "to", "interact", "with", "the", "components", "." ]
2d2e3e11752898461160e22ff65b4a0516890dcc
https://github.com/jenkinsci/js-preferences/blob/2d2e3e11752898461160e22ff65b4a0516890dcc/preferences/Preferences.js#L32-L42
50,513
alexpods/ClazzJS
src/components/meta/Property/Setters.js
function(object, setters, property) { _.each(setters, function(setter, name) { object.__addSetter(property, name, setter); }); }
javascript
function(object, setters, property) { _.each(setters, function(setter, name) { object.__addSetter(property, name, setter); }); }
[ "function", "(", "object", ",", "setters", ",", "property", ")", "{", "_", ".", "each", "(", "setters", ",", "function", "(", "setter", ",", "name", ")", "{", "object", ".", "__addSetter", "(", "property", ",", "name", ",", "setter", ")", ";", "}", ")", ";", "}" ]
Add property setters to object @param {object} object Some object @param {object} setters Hash of property setters @param {string} property Property name @this {metaProcessor}
[ "Add", "property", "setters", "to", "object" ]
2f94496019669813c8246d48fcceb12a3e68a870
https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Property/Setters.js#L16-L21
50,514
tolokoban/ToloFrameWork
ker/com/x-code/x-code.com.js
removeLeftMargin
function removeLeftMargin( code ) { var margin = 999; var lines = code.split("\n"); lines.forEach(function (line) { var s = line.length; var m = 0; while( m < s && line.charAt(m) == ' ' ) m++; margin = Math.min( m, margin ); }); return lines.map(function(line) { return line.substr( margin ); }).join("\n"); }
javascript
function removeLeftMargin( code ) { var margin = 999; var lines = code.split("\n"); lines.forEach(function (line) { var s = line.length; var m = 0; while( m < s && line.charAt(m) == ' ' ) m++; margin = Math.min( m, margin ); }); return lines.map(function(line) { return line.substr( margin ); }).join("\n"); }
[ "function", "removeLeftMargin", "(", "code", ")", "{", "var", "margin", "=", "999", ";", "var", "lines", "=", "code", ".", "split", "(", "\"\\n\"", ")", ";", "lines", ".", "forEach", "(", "function", "(", "line", ")", "{", "var", "s", "=", "line", ".", "length", ";", "var", "m", "=", "0", ";", "while", "(", "m", "<", "s", "&&", "line", ".", "charAt", "(", "m", ")", "==", "' '", ")", "m", "++", ";", "margin", "=", "Math", ".", "min", "(", "m", ",", "margin", ")", ";", "}", ")", ";", "return", "lines", ".", "map", "(", "function", "(", "line", ")", "{", "return", "line", ".", "substr", "(", "margin", ")", ";", "}", ")", ".", "join", "(", "\"\\n\"", ")", ";", "}" ]
Remove common indentation.
[ "Remove", "common", "indentation", "." ]
730845a833a9660ebfdb60ad027ebaab5ac871b6
https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/com/x-code/x-code.com.js#L60-L72
50,515
tolokoban/ToloFrameWork
ker/com/x-code/x-code.com.js
restrictToSection
function restrictToSection( code, section ) { var linesToKeep = []; var outOfSection = true; var lookFor = '#(' + section + ')'; code.split('\n').forEach(function( line ) { if (outOfSection) { if (line.indexOf( lookFor ) > -1) { outOfSection = false; } } else { if (line.indexOf( lookFor ) > -1) { outOfSection = true; } else { linesToKeep.push( line ); } } }); return linesToKeep.join('\n'); }
javascript
function restrictToSection( code, section ) { var linesToKeep = []; var outOfSection = true; var lookFor = '#(' + section + ')'; code.split('\n').forEach(function( line ) { if (outOfSection) { if (line.indexOf( lookFor ) > -1) { outOfSection = false; } } else { if (line.indexOf( lookFor ) > -1) { outOfSection = true; } else { linesToKeep.push( line ); } } }); return linesToKeep.join('\n'); }
[ "function", "restrictToSection", "(", "code", ",", "section", ")", "{", "var", "linesToKeep", "=", "[", "]", ";", "var", "outOfSection", "=", "true", ";", "var", "lookFor", "=", "'#('", "+", "section", "+", "')'", ";", "code", ".", "split", "(", "'\\n'", ")", ".", "forEach", "(", "function", "(", "line", ")", "{", "if", "(", "outOfSection", ")", "{", "if", "(", "line", ".", "indexOf", "(", "lookFor", ")", ">", "-", "1", ")", "{", "outOfSection", "=", "false", ";", "}", "}", "else", "{", "if", "(", "line", ".", "indexOf", "(", "lookFor", ")", ">", "-", "1", ")", "{", "outOfSection", "=", "true", ";", "}", "else", "{", "linesToKeep", ".", "push", "(", "line", ")", ";", "}", "}", "}", ")", ";", "return", "linesToKeep", ".", "join", "(", "'\\n'", ")", ";", "}" ]
it can be useful to restrict the display to just a section of the entire file. Such sections must start with the following line where we find it's name. Look at the definition of the section `init` in the following example. @example var canvas = $.elem( this, 'div' ); // #(init) var gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl"); gl.clearColor(0.0, 0.3, 1.0, 1.0); gl.enable(gl.DEPTH_TEST); gl.depthFunc(gl.LEQUAL); gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); // #(init)
[ "it", "can", "be", "useful", "to", "restrict", "the", "display", "to", "just", "a", "section", "of", "the", "entire", "file", ".", "Such", "sections", "must", "start", "with", "the", "following", "line", "where", "we", "find", "it", "s", "name", ".", "Look", "at", "the", "definition", "of", "the", "section", "init", "in", "the", "following", "example", "." ]
730845a833a9660ebfdb60ad027ebaab5ac871b6
https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/com/x-code/x-code.com.js#L90-L110
50,516
dominicbarnes/duo-serve
lib/server.js
Server
function Server(root) { if (!(this instanceof Server)) return new Server(root); this.settings = defaults({}, Server.defaults); if (root) this.root(root); this.plugins = []; this.entries = {}; var auth = netrc('api.github.com'); if ('GH_TOKEN' in process.env) this.token(process.env.GH_TOKEN); else if (auth.password) this.token(auth.password); }
javascript
function Server(root) { if (!(this instanceof Server)) return new Server(root); this.settings = defaults({}, Server.defaults); if (root) this.root(root); this.plugins = []; this.entries = {}; var auth = netrc('api.github.com'); if ('GH_TOKEN' in process.env) this.token(process.env.GH_TOKEN); else if (auth.password) this.token(auth.password); }
[ "function", "Server", "(", "root", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Server", ")", ")", "return", "new", "Server", "(", "root", ")", ";", "this", ".", "settings", "=", "defaults", "(", "{", "}", ",", "Server", ".", "defaults", ")", ";", "if", "(", "root", ")", "this", ".", "root", "(", "root", ")", ";", "this", ".", "plugins", "=", "[", "]", ";", "this", ".", "entries", "=", "{", "}", ";", "var", "auth", "=", "netrc", "(", "'api.github.com'", ")", ";", "if", "(", "'GH_TOKEN'", "in", "process", ".", "env", ")", "this", ".", "token", "(", "process", ".", "env", ".", "GH_TOKEN", ")", ";", "else", "if", "(", "auth", ".", "password", ")", "this", ".", "token", "(", "auth", ".", "password", ")", ";", "}" ]
Represents a duo-serve instance @constructor @param {String} root The project root
[ "Represents", "a", "duo", "-", "serve", "instance" ]
c6b2e7073ccd729617567995c28880b94b47f947
https://github.com/dominicbarnes/duo-serve/blob/c6b2e7073ccd729617567995c28880b94b47f947/lib/server.js#L27-L38
50,517
ryanramage/schema-couch-boilerplate
jam/couchr/couchr-browser.js
onComplete
function onComplete(options, callback) { return function (req) { var resp; if (ctype = req.getResponseHeader('Content-Type')) { ctype = ctype.split(';')[0]; } if (ctype === 'application/json' || ctype === 'text/json') { try { resp = $.parseJSON(req.responseText) } catch (e) { return callback(e, null, req); } } else { var ct = req.getResponseHeader("content-type") || ""; var xml = ct.indexOf("xml") >= 0; resp = xml ? req.responseXML : req.responseText; } if (req.status == 200 || req.status == 201 || req.status == 202) { callback(null, resp, req); } else if (resp && (resp.error || resp.reason)) { var err = new Error(resp.reason || resp.error); err.error = resp.error; err.reason = resp.reason; err.code = resp.code; err.status = req.status; callback(err, null, req); } else { // TODO: map status code to meaningful error message var msg = req.statusText; if (!msg || msg === 'error') { msg = 'Returned status code: ' + req.status; } var err2 = new Error(msg); err2.status = req.status; callback(err2, null, req); } }; }
javascript
function onComplete(options, callback) { return function (req) { var resp; if (ctype = req.getResponseHeader('Content-Type')) { ctype = ctype.split(';')[0]; } if (ctype === 'application/json' || ctype === 'text/json') { try { resp = $.parseJSON(req.responseText) } catch (e) { return callback(e, null, req); } } else { var ct = req.getResponseHeader("content-type") || ""; var xml = ct.indexOf("xml") >= 0; resp = xml ? req.responseXML : req.responseText; } if (req.status == 200 || req.status == 201 || req.status == 202) { callback(null, resp, req); } else if (resp && (resp.error || resp.reason)) { var err = new Error(resp.reason || resp.error); err.error = resp.error; err.reason = resp.reason; err.code = resp.code; err.status = req.status; callback(err, null, req); } else { // TODO: map status code to meaningful error message var msg = req.statusText; if (!msg || msg === 'error') { msg = 'Returned status code: ' + req.status; } var err2 = new Error(msg); err2.status = req.status; callback(err2, null, req); } }; }
[ "function", "onComplete", "(", "options", ",", "callback", ")", "{", "return", "function", "(", "req", ")", "{", "var", "resp", ";", "if", "(", "ctype", "=", "req", ".", "getResponseHeader", "(", "'Content-Type'", ")", ")", "{", "ctype", "=", "ctype", ".", "split", "(", "';'", ")", "[", "0", "]", ";", "}", "if", "(", "ctype", "===", "'application/json'", "||", "ctype", "===", "'text/json'", ")", "{", "try", "{", "resp", "=", "$", ".", "parseJSON", "(", "req", ".", "responseText", ")", "}", "catch", "(", "e", ")", "{", "return", "callback", "(", "e", ",", "null", ",", "req", ")", ";", "}", "}", "else", "{", "var", "ct", "=", "req", ".", "getResponseHeader", "(", "\"content-type\"", ")", "||", "\"\"", ";", "var", "xml", "=", "ct", ".", "indexOf", "(", "\"xml\"", ")", ">=", "0", ";", "resp", "=", "xml", "?", "req", ".", "responseXML", ":", "req", ".", "responseText", ";", "}", "if", "(", "req", ".", "status", "==", "200", "||", "req", ".", "status", "==", "201", "||", "req", ".", "status", "==", "202", ")", "{", "callback", "(", "null", ",", "resp", ",", "req", ")", ";", "}", "else", "if", "(", "resp", "&&", "(", "resp", ".", "error", "||", "resp", ".", "reason", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "resp", ".", "reason", "||", "resp", ".", "error", ")", ";", "err", ".", "error", "=", "resp", ".", "error", ";", "err", ".", "reason", "=", "resp", ".", "reason", ";", "err", ".", "code", "=", "resp", ".", "code", ";", "err", ".", "status", "=", "req", ".", "status", ";", "callback", "(", "err", ",", "null", ",", "req", ")", ";", "}", "else", "{", "// TODO: map status code to meaningful error message", "var", "msg", "=", "req", ".", "statusText", ";", "if", "(", "!", "msg", "||", "msg", "===", "'error'", ")", "{", "msg", "=", "'Returned status code: '", "+", "req", ".", "status", ";", "}", "var", "err2", "=", "new", "Error", "(", "msg", ")", ";", "err2", ".", "status", "=", "req", ".", "status", ";", "callback", "(", "err2", ",", "null", ",", "req", ")", ";", "}", "}", ";", "}" ]
Returns a function for handling ajax responses from jquery and calls the callback with the data or appropriate error. @param {Function} callback(err,response) @api private
[ "Returns", "a", "function", "for", "handling", "ajax", "responses", "from", "jquery", "and", "calls", "the", "callback", "with", "the", "data", "or", "appropriate", "error", "." ]
c323516f02c90101aa6b21592bfdd2a6f2e47680
https://github.com/ryanramage/schema-couch-boilerplate/blob/c323516f02c90101aa6b21592bfdd2a6f2e47680/jam/couchr/couchr-browser.js#L28-L69
50,518
caiguanhao/assemble-permalink
permalink.js
function(permalink) { permalink = permalink || ''; if (permalink.slice(0, 1) !== PATH_SEP) { permalink = PATH_SEP + permalink; } permalink = permalink.replace(INDEX_RE, PATH_SEP); return permalink; }
javascript
function(permalink) { permalink = permalink || ''; if (permalink.slice(0, 1) !== PATH_SEP) { permalink = PATH_SEP + permalink; } permalink = permalink.replace(INDEX_RE, PATH_SEP); return permalink; }
[ "function", "(", "permalink", ")", "{", "permalink", "=", "permalink", "||", "''", ";", "if", "(", "permalink", ".", "slice", "(", "0", ",", "1", ")", "!==", "PATH_SEP", ")", "{", "permalink", "=", "PATH_SEP", "+", "permalink", ";", "}", "permalink", "=", "permalink", ".", "replace", "(", "INDEX_RE", ",", "PATH_SEP", ")", ";", "return", "permalink", ";", "}" ]
standardize permalink output
[ "standardize", "permalink", "output" ]
ffba65d742c10e456b95bbf63e24e575e905a967
https://github.com/caiguanhao/assemble-permalink/blob/ffba65d742c10e456b95bbf63e24e575e905a967/permalink.js#L42-L49
50,519
alejonext/humanquery
lib/parse.js
parse
function parse(str) { str = '(' + str.trim() + ')'; /** * expr */ return expr(); /** * Assert `expr`. */ function error(expr, msg) { if (expr) return; var ctx = str.slice(0, 10); assert(0, msg + ' near `' + ctx + '`'); } /** * '(' binop ')' */ function expr() { error('(' == str[0], "missing opening '('"); str = str.slice(1); var node = binop(); error(')' == str[0], "missing closing ')'"); str = str.slice(1); return node; } /** * field | expr */ function primary() { return field() || expr(); } /** * primary (OR|AND) binop */ function binop() { var left = primary(); var m = str.match(/^ *(OR|AND) */i); if (!m) return left; str = str.slice(m[0].length); var right = binop(); return { type: 'op', op: m[1].toLowerCase(), left: left, right: right } } /** * FIELD[:VALUE] */ function field() { var val = true; var m = str.match(/^([-.\w]+)/); if (!m) return; var name = m[0]; str = str.slice(name.length); var m = str.match(/^:([-*\w.]+|".*?"|'.*?'|\/(.*?)\/) */); if (m) { str = str.slice(m[0].length); val = m[1]; if (numeric(val)) val = parseFloat(val); } return { type: 'field', name: name, value: coerce(val) } } }
javascript
function parse(str) { str = '(' + str.trim() + ')'; /** * expr */ return expr(); /** * Assert `expr`. */ function error(expr, msg) { if (expr) return; var ctx = str.slice(0, 10); assert(0, msg + ' near `' + ctx + '`'); } /** * '(' binop ')' */ function expr() { error('(' == str[0], "missing opening '('"); str = str.slice(1); var node = binop(); error(')' == str[0], "missing closing ')'"); str = str.slice(1); return node; } /** * field | expr */ function primary() { return field() || expr(); } /** * primary (OR|AND) binop */ function binop() { var left = primary(); var m = str.match(/^ *(OR|AND) */i); if (!m) return left; str = str.slice(m[0].length); var right = binop(); return { type: 'op', op: m[1].toLowerCase(), left: left, right: right } } /** * FIELD[:VALUE] */ function field() { var val = true; var m = str.match(/^([-.\w]+)/); if (!m) return; var name = m[0]; str = str.slice(name.length); var m = str.match(/^:([-*\w.]+|".*?"|'.*?'|\/(.*?)\/) */); if (m) { str = str.slice(m[0].length); val = m[1]; if (numeric(val)) val = parseFloat(val); } return { type: 'field', name: name, value: coerce(val) } } }
[ "function", "parse", "(", "str", ")", "{", "str", "=", "'('", "+", "str", ".", "trim", "(", ")", "+", "')'", ";", "/**\n\t * expr\n\t */", "return", "expr", "(", ")", ";", "/**\n\t * Assert `expr`.\n\t */", "function", "error", "(", "expr", ",", "msg", ")", "{", "if", "(", "expr", ")", "return", ";", "var", "ctx", "=", "str", ".", "slice", "(", "0", ",", "10", ")", ";", "assert", "(", "0", ",", "msg", "+", "' near `'", "+", "ctx", "+", "'`'", ")", ";", "}", "/**\n\t * '(' binop ')'\n\t */", "function", "expr", "(", ")", "{", "error", "(", "'('", "==", "str", "[", "0", "]", ",", "\"missing opening '('\"", ")", ";", "str", "=", "str", ".", "slice", "(", "1", ")", ";", "var", "node", "=", "binop", "(", ")", ";", "error", "(", "')'", "==", "str", "[", "0", "]", ",", "\"missing closing ')'\"", ")", ";", "str", "=", "str", ".", "slice", "(", "1", ")", ";", "return", "node", ";", "}", "/**\n\t * field | expr\n\t */", "function", "primary", "(", ")", "{", "return", "field", "(", ")", "||", "expr", "(", ")", ";", "}", "/**\n\t * primary (OR|AND) binop\n\t */", "function", "binop", "(", ")", "{", "var", "left", "=", "primary", "(", ")", ";", "var", "m", "=", "str", ".", "match", "(", "/", "^ *(OR|AND) *", "/", "i", ")", ";", "if", "(", "!", "m", ")", "return", "left", ";", "str", "=", "str", ".", "slice", "(", "m", "[", "0", "]", ".", "length", ")", ";", "var", "right", "=", "binop", "(", ")", ";", "return", "{", "type", ":", "'op'", ",", "op", ":", "m", "[", "1", "]", ".", "toLowerCase", "(", ")", ",", "left", ":", "left", ",", "right", ":", "right", "}", "}", "/**\n\t * FIELD[:VALUE]\n\t */", "function", "field", "(", ")", "{", "var", "val", "=", "true", ";", "var", "m", "=", "str", ".", "match", "(", "/", "^([-.\\w]+)", "/", ")", ";", "if", "(", "!", "m", ")", "return", ";", "var", "name", "=", "m", "[", "0", "]", ";", "str", "=", "str", ".", "slice", "(", "name", ".", "length", ")", ";", "var", "m", "=", "str", ".", "match", "(", "/", "^:([-*\\w.]+|\".*?\"|'.*?'|\\/(.*?)\\/) *", "/", ")", ";", "if", "(", "m", ")", "{", "str", "=", "str", ".", "slice", "(", "m", "[", "0", "]", ".", "length", ")", ";", "val", "=", "m", "[", "1", "]", ";", "if", "(", "numeric", "(", "val", ")", ")", "val", "=", "parseFloat", "(", "val", ")", ";", "}", "return", "{", "type", ":", "'field'", ",", "name", ":", "name", ",", "value", ":", "coerce", "(", "val", ")", "}", "}", "}" ]
Parse `str` to produce an AST. @param {String} str @return {Object} @api public
[ "Parse", "str", "to", "produce", "an", "AST", "." ]
f3dbc46379122f40bf9336991e9856a82fc95310
https://github.com/alejonext/humanquery/blob/f3dbc46379122f40bf9336991e9856a82fc95310/lib/parse.js#L23-L114
50,520
alejonext/humanquery
lib/parse.js
error
function error(expr, msg) { if (expr) return; var ctx = str.slice(0, 10); assert(0, msg + ' near `' + ctx + '`'); }
javascript
function error(expr, msg) { if (expr) return; var ctx = str.slice(0, 10); assert(0, msg + ' near `' + ctx + '`'); }
[ "function", "error", "(", "expr", ",", "msg", ")", "{", "if", "(", "expr", ")", "return", ";", "var", "ctx", "=", "str", ".", "slice", "(", "0", ",", "10", ")", ";", "assert", "(", "0", ",", "msg", "+", "' near `'", "+", "ctx", "+", "'`'", ")", ";", "}" ]
Assert `expr`.
[ "Assert", "expr", "." ]
f3dbc46379122f40bf9336991e9856a82fc95310
https://github.com/alejonext/humanquery/blob/f3dbc46379122f40bf9336991e9856a82fc95310/lib/parse.js#L36-L40
50,521
mathieudutour/nplint
lib/ignore-deps.js
loadIgnoreFile
function loadIgnoreFile(filepath) { var ignoredDeps = []; /** * Check if string is not empty * @param {string} line string to examine * @returns {boolean} True is its not empty * @private */ function nonEmpty(line) { return line.trim() !== '' && line[0] !== '#'; } if (filepath) { try { ignoredDeps = fs.readFileSync(filepath, 'utf8') .split(/\r?\n/) .filter(nonEmpty); } catch (e) { e.message = 'Cannot read ignore file: ' + filepath + '\nError: ' + e.message; throw e; } } return ignoredDeps; }
javascript
function loadIgnoreFile(filepath) { var ignoredDeps = []; /** * Check if string is not empty * @param {string} line string to examine * @returns {boolean} True is its not empty * @private */ function nonEmpty(line) { return line.trim() !== '' && line[0] !== '#'; } if (filepath) { try { ignoredDeps = fs.readFileSync(filepath, 'utf8') .split(/\r?\n/) .filter(nonEmpty); } catch (e) { e.message = 'Cannot read ignore file: ' + filepath + '\nError: ' + e.message; throw e; } } return ignoredDeps; }
[ "function", "loadIgnoreFile", "(", "filepath", ")", "{", "var", "ignoredDeps", "=", "[", "]", ";", "/**\n * Check if string is not empty\n * @param {string} line string to examine\n * @returns {boolean} True is its not empty\n * @private\n */", "function", "nonEmpty", "(", "line", ")", "{", "return", "line", ".", "trim", "(", ")", "!==", "''", "&&", "line", "[", "0", "]", "!==", "'#'", ";", "}", "if", "(", "filepath", ")", "{", "try", "{", "ignoredDeps", "=", "fs", ".", "readFileSync", "(", "filepath", ",", "'utf8'", ")", ".", "split", "(", "/", "\\r?\\n", "/", ")", ".", "filter", "(", "nonEmpty", ")", ";", "}", "catch", "(", "e", ")", "{", "e", ".", "message", "=", "'Cannot read ignore file: '", "+", "filepath", "+", "'\\nError: '", "+", "e", ".", "message", ";", "throw", "e", ";", "}", "}", "return", "ignoredDeps", ";", "}" ]
Load and parse ignore dependencies from the file at the given path @param {string} filepath Path to the ignore file. @returns {string[]} An array of ignore dependencies or an empty array if no ignore file.
[ "Load", "and", "parse", "ignore", "dependencies", "from", "the", "file", "at", "the", "given", "path" ]
ef444abcc6dd08fb61d5fc8ce618598d4455e08e
https://github.com/mathieudutour/nplint/blob/ef444abcc6dd08fb61d5fc8ce618598d4455e08e/lib/ignore-deps.js#L13-L38
50,522
kumori-systems/component
taskfile.js
getJSON
function getJSON(filepath) { const jsonString = "g = " + fs.readFileSync(filepath, 'utf8') + "; g"; return (new vm.Script(jsonString)).runInNewContext(); }
javascript
function getJSON(filepath) { const jsonString = "g = " + fs.readFileSync(filepath, 'utf8') + "; g"; return (new vm.Script(jsonString)).runInNewContext(); }
[ "function", "getJSON", "(", "filepath", ")", "{", "const", "jsonString", "=", "\"g = \"", "+", "fs", ".", "readFileSync", "(", "filepath", ",", "'utf8'", ")", "+", "\"; g\"", ";", "return", "(", "new", "vm", ".", "Script", "(", "jsonString", ")", ")", ".", "runInNewContext", "(", ")", ";", "}" ]
Gobble up a JSON file with comments
[ "Gobble", "up", "a", "JSON", "file", "with", "comments" ]
6ff796e5fd8800daf35b10c352a14e09db651fe2
https://github.com/kumori-systems/component/blob/6ff796e5fd8800daf35b10c352a14e09db651fe2/taskfile.js#L8-L11
50,523
jm-root/core
packages/jm-event/lib/index.js
emitAsync
async function emitAsync (eventName, ...args) { // using a copy to avoid error when listener array changed let listeners = this.listeners(eventName) for (let i = 0; i < listeners.length; i++) { let fn = listeners[i] let obj = fn(...args) if (!!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function') obj = await obj if (obj !== undefined) return obj } }
javascript
async function emitAsync (eventName, ...args) { // using a copy to avoid error when listener array changed let listeners = this.listeners(eventName) for (let i = 0; i < listeners.length; i++) { let fn = listeners[i] let obj = fn(...args) if (!!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function') obj = await obj if (obj !== undefined) return obj } }
[ "async", "function", "emitAsync", "(", "eventName", ",", "...", "args", ")", "{", "// using a copy to avoid error when listener array changed", "let", "listeners", "=", "this", ".", "listeners", "(", "eventName", ")", "for", "(", "let", "i", "=", "0", ";", "i", "<", "listeners", ".", "length", ";", "i", "++", ")", "{", "let", "fn", "=", "listeners", "[", "i", "]", "let", "obj", "=", "fn", "(", "...", "args", ")", "if", "(", "!", "!", "obj", "&&", "(", "typeof", "obj", "===", "'object'", "||", "typeof", "obj", "===", "'function'", ")", "&&", "typeof", "obj", ".", "then", "===", "'function'", ")", "obj", "=", "await", "obj", "if", "(", "obj", "!==", "undefined", ")", "return", "obj", "}", "}" ]
event module. @module event
[ "event", "module", "." ]
d05c7356a2991edf861e5c1aac2d0bc971cfdff3
https://github.com/jm-root/core/blob/d05c7356a2991edf861e5c1aac2d0bc971cfdff3/packages/jm-event/lib/index.js#L6-L15
50,524
redisjs/jsr-store
lib/store.js
getDatabase
function getDatabase(index, opts) { var db; if(!this._databases[index]) { db = new Database(this, opts); this._databases[index] = db; } return this._databases[index]; }
javascript
function getDatabase(index, opts) { var db; if(!this._databases[index]) { db = new Database(this, opts); this._databases[index] = db; } return this._databases[index]; }
[ "function", "getDatabase", "(", "index", ",", "opts", ")", "{", "var", "db", ";", "if", "(", "!", "this", ".", "_databases", "[", "index", "]", ")", "{", "db", "=", "new", "Database", "(", "this", ",", "opts", ")", ";", "this", ".", "_databases", "[", "index", "]", "=", "db", ";", "}", "return", "this", ".", "_databases", "[", "index", "]", ";", "}" ]
Get a database and inject it into the list at the specified index if no db exists at that index. @param index The database index. @param opts Database options.
[ "Get", "a", "database", "and", "inject", "it", "into", "the", "list", "at", "the", "specified", "index", "if", "no", "db", "exists", "at", "that", "index", "." ]
b2b5c5b0347819f8a388b5d67e121ee8d73f328c
https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/store.js#L46-L53
50,525
energimolnet/energimolnet-ng
src/date-util.js
getPeriod
function getPeriod(dates, granularity, forced) { var isArray = angular.isArray(dates); var isRange = (isArray && dates.length > 1); if ((isArray && dates.length === 0) || dates === null || dates === undefined) { return null; } if (granularity === 'month') { return (isRange || forced) ? getMonthPeriod(dates) : getYearPeriod(dates); } if (granularity === 'day') { return (isRange || forced) ? getDayPeriod(dates) : getMonthPeriod(dates); } if (granularity === 'week' && !isRange) { // Special case. Week is no actual granularity. This returns a week period // starting at the specified date. No checks are made to determine if the // provided date actually is the first day in a week. var start = (isArray) ? dates[0] : dates; var end = new Date(start.getTime()); end.setDate(end.getDate() + 6); return getDayPeriod([start, end]); } return getDayPeriod(dates); }
javascript
function getPeriod(dates, granularity, forced) { var isArray = angular.isArray(dates); var isRange = (isArray && dates.length > 1); if ((isArray && dates.length === 0) || dates === null || dates === undefined) { return null; } if (granularity === 'month') { return (isRange || forced) ? getMonthPeriod(dates) : getYearPeriod(dates); } if (granularity === 'day') { return (isRange || forced) ? getDayPeriod(dates) : getMonthPeriod(dates); } if (granularity === 'week' && !isRange) { // Special case. Week is no actual granularity. This returns a week period // starting at the specified date. No checks are made to determine if the // provided date actually is the first day in a week. var start = (isArray) ? dates[0] : dates; var end = new Date(start.getTime()); end.setDate(end.getDate() + 6); return getDayPeriod([start, end]); } return getDayPeriod(dates); }
[ "function", "getPeriod", "(", "dates", ",", "granularity", ",", "forced", ")", "{", "var", "isArray", "=", "angular", ".", "isArray", "(", "dates", ")", ";", "var", "isRange", "=", "(", "isArray", "&&", "dates", ".", "length", ">", "1", ")", ";", "if", "(", "(", "isArray", "&&", "dates", ".", "length", "===", "0", ")", "||", "dates", "===", "null", "||", "dates", "===", "undefined", ")", "{", "return", "null", ";", "}", "if", "(", "granularity", "===", "'month'", ")", "{", "return", "(", "isRange", "||", "forced", ")", "?", "getMonthPeriod", "(", "dates", ")", ":", "getYearPeriod", "(", "dates", ")", ";", "}", "if", "(", "granularity", "===", "'day'", ")", "{", "return", "(", "isRange", "||", "forced", ")", "?", "getDayPeriod", "(", "dates", ")", ":", "getMonthPeriod", "(", "dates", ")", ";", "}", "if", "(", "granularity", "===", "'week'", "&&", "!", "isRange", ")", "{", "// Special case. Week is no actual granularity. This returns a week period", "// starting at the specified date. No checks are made to determine if the", "// provided date actually is the first day in a week.", "var", "start", "=", "(", "isArray", ")", "?", "dates", "[", "0", "]", ":", "dates", ";", "var", "end", "=", "new", "Date", "(", "start", ".", "getTime", "(", ")", ")", ";", "end", ".", "setDate", "(", "end", ".", "getDate", "(", ")", "+", "6", ")", ";", "return", "getDayPeriod", "(", "[", "start", ",", "end", "]", ")", ";", "}", "return", "getDayPeriod", "(", "dates", ")", ";", "}" ]
Returns a period for the provided date range, or single date. Will auto-calculate period style depending on granularity, unless force is set to true. E.g. when getting day granularity for a single date, the function will assume you want day values for the date's month.
[ "Returns", "a", "period", "for", "the", "provided", "date", "range", "or", "single", "date", ".", "Will", "auto", "-", "calculate", "period", "style", "depending", "on", "granularity", "unless", "force", "is", "set", "to", "true", ".", "E", ".", "g", ".", "when", "getting", "day", "granularity", "for", "a", "single", "date", "the", "function", "will", "assume", "you", "want", "day", "values", "for", "the", "date", "s", "month", "." ]
7249c7a52aa6878d462a429c3aacb33d43bf9484
https://github.com/energimolnet/energimolnet-ng/blob/7249c7a52aa6878d462a429c3aacb33d43bf9484/src/date-util.js#L72-L100
50,526
energimolnet/energimolnet-ng
src/date-util.js
daysInMonth
function daysInMonth(date) { var d = new Date(date.getTime()); d.setMonth(d.getMonth() + 1); d.setDate(0); return d.getDate(); }
javascript
function daysInMonth(date) { var d = new Date(date.getTime()); d.setMonth(d.getMonth() + 1); d.setDate(0); return d.getDate(); }
[ "function", "daysInMonth", "(", "date", ")", "{", "var", "d", "=", "new", "Date", "(", "date", ".", "getTime", "(", ")", ")", ";", "d", ".", "setMonth", "(", "d", ".", "getMonth", "(", ")", "+", "1", ")", ";", "d", ".", "setDate", "(", "0", ")", ";", "return", "d", ".", "getDate", "(", ")", ";", "}" ]
Helper function for returning the number of days in a month
[ "Helper", "function", "for", "returning", "the", "number", "of", "days", "in", "a", "month" ]
7249c7a52aa6878d462a429c3aacb33d43bf9484
https://github.com/energimolnet/energimolnet-ng/blob/7249c7a52aa6878d462a429c3aacb33d43bf9484/src/date-util.js#L123-L129
50,527
the-terribles/evergreen
lib/directive-context.js
DirectiveContext
function DirectiveContext(strategy, expression, arrayPath){ this.resolved = false; this.strategy = strategy; this.expression = expression; this.path = arrayPath; this.sympath = treeUtils.joinPaths(arrayPath); }
javascript
function DirectiveContext(strategy, expression, arrayPath){ this.resolved = false; this.strategy = strategy; this.expression = expression; this.path = arrayPath; this.sympath = treeUtils.joinPaths(arrayPath); }
[ "function", "DirectiveContext", "(", "strategy", ",", "expression", ",", "arrayPath", ")", "{", "this", ".", "resolved", "=", "false", ";", "this", ".", "strategy", "=", "strategy", ";", "this", ".", "expression", "=", "expression", ";", "this", ".", "path", "=", "arrayPath", ";", "this", ".", "sympath", "=", "treeUtils", ".", "joinPaths", "(", "arrayPath", ")", ";", "}" ]
Represent the context needed to resolve a directive. This should be returned by the directive to the callback. If the directive has resolved the value, there is a convenience method "resolve" you can call to set the value and transition the completion state to "resolved". @param strategy {String} name of the directive. @param expression {String} the value after the directive in the expression @param arrayPath {Array} path to the leaf in which the directive was declared. @constructor
[ "Represent", "the", "context", "needed", "to", "resolve", "a", "directive", ".", "This", "should", "be", "returned", "by", "the", "directive", "to", "the", "callback", ".", "If", "the", "directive", "has", "resolved", "the", "value", "there", "is", "a", "convenience", "method", "resolve", "you", "can", "call", "to", "set", "the", "value", "and", "transition", "the", "completion", "state", "to", "resolved", "." ]
c1adaea1ce825727c5c5ed75d858e2f0d22657e2
https://github.com/the-terribles/evergreen/blob/c1adaea1ce825727c5c5ed75d858e2f0d22657e2/lib/directive-context.js#L14-L20
50,528
on-point/thin-orm
table.js
Table
function Table(tableName, registry) { this.id = 'id'; this.tableName = tableName; this.joins = {}; this.defaultJoins = []; this.columns = null; this.selectColumns = null; this.defaultSelectCriteria = null; this.columnMap = null; this.isInitialized = false; this.defaultJoinsNeedPostProcessing = false; this.registry = registry; }
javascript
function Table(tableName, registry) { this.id = 'id'; this.tableName = tableName; this.joins = {}; this.defaultJoins = []; this.columns = null; this.selectColumns = null; this.defaultSelectCriteria = null; this.columnMap = null; this.isInitialized = false; this.defaultJoinsNeedPostProcessing = false; this.registry = registry; }
[ "function", "Table", "(", "tableName", ",", "registry", ")", "{", "this", ".", "id", "=", "'id'", ";", "this", ".", "tableName", "=", "tableName", ";", "this", ".", "joins", "=", "{", "}", ";", "this", ".", "defaultJoins", "=", "[", "]", ";", "this", ".", "columns", "=", "null", ";", "this", ".", "selectColumns", "=", "null", ";", "this", ".", "defaultSelectCriteria", "=", "null", ";", "this", ".", "columnMap", "=", "null", ";", "this", ".", "isInitialized", "=", "false", ";", "this", ".", "defaultJoinsNeedPostProcessing", "=", "false", ";", "this", ".", "registry", "=", "registry", ";", "}" ]
a table model
[ "a", "table", "model" ]
761783a133ef6983f46060af68febc07e1f880e8
https://github.com/on-point/thin-orm/blob/761783a133ef6983f46060af68febc07e1f880e8/table.js#L5-L17
50,529
on-point/thin-orm
table.js
camelCaseToUnderscoreMap
function camelCaseToUnderscoreMap(columns) { var map = {}; for (var i = 0; i < columns.length; i++) map[columns[i]] = toUnderscore(columns[i]); return map; }
javascript
function camelCaseToUnderscoreMap(columns) { var map = {}; for (var i = 0; i < columns.length; i++) map[columns[i]] = toUnderscore(columns[i]); return map; }
[ "function", "camelCaseToUnderscoreMap", "(", "columns", ")", "{", "var", "map", "=", "{", "}", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "columns", ".", "length", ";", "i", "++", ")", "map", "[", "columns", "[", "i", "]", "]", "=", "toUnderscore", "(", "columns", "[", "i", "]", ")", ";", "return", "map", ";", "}" ]
build a map that converts each camel case column name to an underscore name
[ "build", "a", "map", "that", "converts", "each", "camel", "case", "column", "name", "to", "an", "underscore", "name" ]
761783a133ef6983f46060af68febc07e1f880e8
https://github.com/on-point/thin-orm/blob/761783a133ef6983f46060af68febc07e1f880e8/table.js#L108-L113
50,530
DerZyklop/eslint-plugin-no-unsafe-chars
lib/rules/custom.js
checkForDisallowedCharactersInString
function checkForDisallowedCharactersInString(node, identifier) { if (typeof identifier !== "undefined" && isNotAllowed(identifier)) { context.report(node, "Unexpected umlaut in \"" + identifier + "\"."); } }
javascript
function checkForDisallowedCharactersInString(node, identifier) { if (typeof identifier !== "undefined" && isNotAllowed(identifier)) { context.report(node, "Unexpected umlaut in \"" + identifier + "\"."); } }
[ "function", "checkForDisallowedCharactersInString", "(", "node", ",", "identifier", ")", "{", "if", "(", "typeof", "identifier", "!==", "\"undefined\"", "&&", "isNotAllowed", "(", "identifier", ")", ")", "{", "context", ".", "report", "(", "node", ",", "\"Unexpected umlaut in \\\"\"", "+", "identifier", "+", "\"\\\".\"", ")", ";", "}", "}" ]
Check if function has a underscore at the end @param {ASTNode} node node to evaluate @returns {void} @private
[ "Check", "if", "function", "has", "a", "underscore", "at", "the", "end" ]
f2b23367f02f88ecef65d71be56e15eaaa1400d8
https://github.com/DerZyklop/eslint-plugin-no-unsafe-chars/blob/f2b23367f02f88ecef65d71be56e15eaaa1400d8/lib/rules/custom.js#L40-L44
50,531
csbun/grunt-cmd
tasks/cmd.js
processOptions
function processOptions(opt) { keys(opt).forEach(function (key) { var value = opt[key]; if (typeof value === 'string') { opt[key] = grunt.template.process(value); } else if (Array.isArray(value)) { opt[key] = value.slice().map(function (i) { return grunt.template.process(i); }); } }); }
javascript
function processOptions(opt) { keys(opt).forEach(function (key) { var value = opt[key]; if (typeof value === 'string') { opt[key] = grunt.template.process(value); } else if (Array.isArray(value)) { opt[key] = value.slice().map(function (i) { return grunt.template.process(i); }); } }); }
[ "function", "processOptions", "(", "opt", ")", "{", "keys", "(", "opt", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "var", "value", "=", "opt", "[", "key", "]", ";", "if", "(", "typeof", "value", "===", "'string'", ")", "{", "opt", "[", "key", "]", "=", "grunt", ".", "template", ".", "process", "(", "value", ")", ";", "}", "else", "if", "(", "Array", ".", "isArray", "(", "value", ")", ")", "{", "opt", "[", "key", "]", "=", "value", ".", "slice", "(", ")", ".", "map", "(", "function", "(", "i", ")", "{", "return", "grunt", ".", "template", ".", "process", "(", "i", ")", ";", "}", ")", ";", "}", "}", ")", ";", "}" ]
preprocess template in options default template delimiters are
[ "preprocess", "template", "in", "options", "default", "template", "delimiters", "are" ]
a806eb8b890e4e6d218341fc4bd45fdd080375ca
https://github.com/csbun/grunt-cmd/blob/a806eb8b890e4e6d218341fc4bd45fdd080375ca/tasks/cmd.js#L21-L32
50,532
derdesign/protos
storages/redis.js
RedisStorage
function RedisStorage(config) { var self = this; config = protos.extend({ host: 'localhost', port: 6379, db: undefined, password: undefined }, config || {}); app.debug(util.format('Initializing Redis Storage for %s:%s', config.host, config.port)); this.db = 0; this.config = config; this.className = this.constructor.name; // Set redis client self.client = redis.createClient(config.port, config.host, config.options); // Authenticate if password provided if (config.password) self.client.auth(config.password); // Handle error event self.client.on('error', function(err) { throw err; }); // Select db if specified if (typeof config.db == 'number' && config.db !== 0) { app.addReadyTask(); self.db = config.db; self.client.select(config.db, function(err, res) { if (err) { throw err; } else { app.flushReadyTask(); } }); } // Set enumerable properties protos.util.onlySetEnumerable(this, ['className', 'db']); }
javascript
function RedisStorage(config) { var self = this; config = protos.extend({ host: 'localhost', port: 6379, db: undefined, password: undefined }, config || {}); app.debug(util.format('Initializing Redis Storage for %s:%s', config.host, config.port)); this.db = 0; this.config = config; this.className = this.constructor.name; // Set redis client self.client = redis.createClient(config.port, config.host, config.options); // Authenticate if password provided if (config.password) self.client.auth(config.password); // Handle error event self.client.on('error', function(err) { throw err; }); // Select db if specified if (typeof config.db == 'number' && config.db !== 0) { app.addReadyTask(); self.db = config.db; self.client.select(config.db, function(err, res) { if (err) { throw err; } else { app.flushReadyTask(); } }); } // Set enumerable properties protos.util.onlySetEnumerable(this, ['className', 'db']); }
[ "function", "RedisStorage", "(", "config", ")", "{", "var", "self", "=", "this", ";", "config", "=", "protos", ".", "extend", "(", "{", "host", ":", "'localhost'", ",", "port", ":", "6379", ",", "db", ":", "undefined", ",", "password", ":", "undefined", "}", ",", "config", "||", "{", "}", ")", ";", "app", ".", "debug", "(", "util", ".", "format", "(", "'Initializing Redis Storage for %s:%s'", ",", "config", ".", "host", ",", "config", ".", "port", ")", ")", ";", "this", ".", "db", "=", "0", ";", "this", ".", "config", "=", "config", ";", "this", ".", "className", "=", "this", ".", "constructor", ".", "name", ";", "// Set redis client", "self", ".", "client", "=", "redis", ".", "createClient", "(", "config", ".", "port", ",", "config", ".", "host", ",", "config", ".", "options", ")", ";", "// Authenticate if password provided", "if", "(", "config", ".", "password", ")", "self", ".", "client", ".", "auth", "(", "config", ".", "password", ")", ";", "// Handle error event", "self", ".", "client", ".", "on", "(", "'error'", ",", "function", "(", "err", ")", "{", "throw", "err", ";", "}", ")", ";", "// Select db if specified", "if", "(", "typeof", "config", ".", "db", "==", "'number'", "&&", "config", ".", "db", "!==", "0", ")", "{", "app", ".", "addReadyTask", "(", ")", ";", "self", ".", "db", "=", "config", ".", "db", ";", "self", ".", "client", ".", "select", "(", "config", ".", "db", ",", "function", "(", "err", ",", "res", ")", "{", "if", "(", "err", ")", "{", "throw", "err", ";", "}", "else", "{", "app", ".", "flushReadyTask", "(", ")", ";", "}", "}", ")", ";", "}", "// Set enumerable properties", "protos", ".", "util", ".", "onlySetEnumerable", "(", "this", ",", "[", "'className'", ",", "'db'", "]", ")", ";", "}" ]
Redis Storage class @class RedisStorage @extends Storage @constructor @param {object} app Application instance @param {object} config Storage configuration
[ "Redis", "Storage", "class" ]
0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9
https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/storages/redis.js#L20-L66
50,533
JohnnieFucker/dreamix-rpc
lib/rpc-client/client.js
rpcToSpecifiedServer
function rpcToSpecifiedServer(client, msg, serverType, routeParam, cb) { if (typeof routeParam !== 'string') { logger.error('[dreamix-rpc] server id is not a string, server id: %j', routeParam); return; } if (routeParam === '*') { const servers = client._station.servers; async.each(Object.keys(servers), (serverId, next) => { const server = servers[serverId]; if (server.serverType === serverType) { client.rpcInvoke(serverId, msg, (err) => { next(err); }); } }, cb); } client.rpcInvoke(routeParam, msg, cb); }
javascript
function rpcToSpecifiedServer(client, msg, serverType, routeParam, cb) { if (typeof routeParam !== 'string') { logger.error('[dreamix-rpc] server id is not a string, server id: %j', routeParam); return; } if (routeParam === '*') { const servers = client._station.servers; async.each(Object.keys(servers), (serverId, next) => { const server = servers[serverId]; if (server.serverType === serverType) { client.rpcInvoke(serverId, msg, (err) => { next(err); }); } }, cb); } client.rpcInvoke(routeParam, msg, cb); }
[ "function", "rpcToSpecifiedServer", "(", "client", ",", "msg", ",", "serverType", ",", "routeParam", ",", "cb", ")", "{", "if", "(", "typeof", "routeParam", "!==", "'string'", ")", "{", "logger", ".", "error", "(", "'[dreamix-rpc] server id is not a string, server id: %j'", ",", "routeParam", ")", ";", "return", ";", "}", "if", "(", "routeParam", "===", "'*'", ")", "{", "const", "servers", "=", "client", ".", "_station", ".", "servers", ";", "async", ".", "each", "(", "Object", ".", "keys", "(", "servers", ")", ",", "(", "serverId", ",", "next", ")", "=>", "{", "const", "server", "=", "servers", "[", "serverId", "]", ";", "if", "(", "server", ".", "serverType", "===", "serverType", ")", "{", "client", ".", "rpcInvoke", "(", "serverId", ",", "msg", ",", "(", "err", ")", "=>", "{", "next", "(", "err", ")", ";", "}", ")", ";", "}", "}", ",", "cb", ")", ";", "}", "client", ".", "rpcInvoke", "(", "routeParam", ",", "msg", ",", "cb", ")", ";", "}" ]
client has closed Rpc to specified server id or servers. @param client {Object} current client instance. @param msg {Object} rpc message. @param serverType {String} remote server type. @param routeParam {Object} mailbox init context parameter. @param cb {Function} callback. @api private
[ "client", "has", "closed", "Rpc", "to", "specified", "server", "id", "or", "servers", "." ]
eb29e247214148c025456b2bb0542e1094fd2edb
https://github.com/JohnnieFucker/dreamix-rpc/blob/eb29e247214148c025456b2bb0542e1094fd2edb/lib/rpc-client/client.js#L29-L46
50,534
meaku/lawyer
lib/index.js
checkModuleLicense
function checkModuleLicense(folder) { var licensePath = folder + "/LICENSE", readMePath = folder + "/README.md", licenseContent; //check for LICENSE File First if(fs.existsSync(licensePath)){ licenseContent = fs.readFileSync(licensePath, "utf-8"); return { isMIT : isLicense.mit(licenseContent), content : licenseContent }; } //Maybe in the README else if(fs.existsSync(readMePath)) { licenseContent = fs.readFileSync(readMePath, "utf-8"); return { isMIT : isLicense.mit(licenseContent), content : "Check the README" }; } else { return { isMIT : false, content : "not found" }; } }
javascript
function checkModuleLicense(folder) { var licensePath = folder + "/LICENSE", readMePath = folder + "/README.md", licenseContent; //check for LICENSE File First if(fs.existsSync(licensePath)){ licenseContent = fs.readFileSync(licensePath, "utf-8"); return { isMIT : isLicense.mit(licenseContent), content : licenseContent }; } //Maybe in the README else if(fs.existsSync(readMePath)) { licenseContent = fs.readFileSync(readMePath, "utf-8"); return { isMIT : isLicense.mit(licenseContent), content : "Check the README" }; } else { return { isMIT : false, content : "not found" }; } }
[ "function", "checkModuleLicense", "(", "folder", ")", "{", "var", "licensePath", "=", "folder", "+", "\"/LICENSE\"", ",", "readMePath", "=", "folder", "+", "\"/README.md\"", ",", "licenseContent", ";", "//check for LICENSE File First", "if", "(", "fs", ".", "existsSync", "(", "licensePath", ")", ")", "{", "licenseContent", "=", "fs", ".", "readFileSync", "(", "licensePath", ",", "\"utf-8\"", ")", ";", "return", "{", "isMIT", ":", "isLicense", ".", "mit", "(", "licenseContent", ")", ",", "content", ":", "licenseContent", "}", ";", "}", "//Maybe in the README", "else", "if", "(", "fs", ".", "existsSync", "(", "readMePath", ")", ")", "{", "licenseContent", "=", "fs", ".", "readFileSync", "(", "readMePath", ",", "\"utf-8\"", ")", ";", "return", "{", "isMIT", ":", "isLicense", ".", "mit", "(", "licenseContent", ")", ",", "content", ":", "\"Check the README\"", "}", ";", "}", "else", "{", "return", "{", "isMIT", ":", "false", ",", "content", ":", "\"not found\"", "}", ";", "}", "}" ]
checks the License of a single module-folder @param folder @return {Object}
[ "checks", "the", "License", "of", "a", "single", "module", "-", "folder" ]
6056e7937a1b3cd415b53e1be9b9c4ff8cc115e7
https://github.com/meaku/lawyer/blob/6056e7937a1b3cd415b53e1be9b9c4ff8cc115e7/lib/index.js#L14-L33
50,535
meaku/lawyer
lib/index.js
checkLicenses
function checkLicenses(rootDir){ var licenses = {}, nodeModulesFolder = path.resolve(rootDir, "./node_modules"), moduleFolders = fs.readdirSync(nodeModulesFolder), res; _(moduleFolders).each(function(module) { licenses[module] = checkModuleLicense(nodeModulesFolder + "/" + module); }); return licenses; }
javascript
function checkLicenses(rootDir){ var licenses = {}, nodeModulesFolder = path.resolve(rootDir, "./node_modules"), moduleFolders = fs.readdirSync(nodeModulesFolder), res; _(moduleFolders).each(function(module) { licenses[module] = checkModuleLicense(nodeModulesFolder + "/" + module); }); return licenses; }
[ "function", "checkLicenses", "(", "rootDir", ")", "{", "var", "licenses", "=", "{", "}", ",", "nodeModulesFolder", "=", "path", ".", "resolve", "(", "rootDir", ",", "\"./node_modules\"", ")", ",", "moduleFolders", "=", "fs", ".", "readdirSync", "(", "nodeModulesFolder", ")", ",", "res", ";", "_", "(", "moduleFolders", ")", ".", "each", "(", "function", "(", "module", ")", "{", "licenses", "[", "module", "]", "=", "checkModuleLicense", "(", "nodeModulesFolder", "+", "\"/\"", "+", "module", ")", ";", "}", ")", ";", "return", "licenses", ";", "}" ]
check all licenses of your node_modules @param {String} rootDir your modules' root dir
[ "check", "all", "licenses", "of", "your", "node_modules" ]
6056e7937a1b3cd415b53e1be9b9c4ff8cc115e7
https://github.com/meaku/lawyer/blob/6056e7937a1b3cd415b53e1be9b9c4ff8cc115e7/lib/index.js#L39-L51
50,536
meaku/lawyer
lib/index.js
writeLicensesFile
function writeLicensesFile(rootDir) { var licenses = checkLicenses(rootDir), licensesFileContent = "LICENSES " + "\n \n"; _(licenses).each(function(licenseData, licenseName) { licensesFileContent += licenseName + " : "; if(licenseData.isMIT) { licensesFileContent += "MIT"; } else { licensesFileContent += "Unknown License"; } licensesFileContent += "\n \n"; if(licenseData.content) { licensesFileContent += licenseData.content + "\n \n"; } }); fs.writeFileSync(rootDir + "/LICENSES", licensesFileContent, "utf-8"); }
javascript
function writeLicensesFile(rootDir) { var licenses = checkLicenses(rootDir), licensesFileContent = "LICENSES " + "\n \n"; _(licenses).each(function(licenseData, licenseName) { licensesFileContent += licenseName + " : "; if(licenseData.isMIT) { licensesFileContent += "MIT"; } else { licensesFileContent += "Unknown License"; } licensesFileContent += "\n \n"; if(licenseData.content) { licensesFileContent += licenseData.content + "\n \n"; } }); fs.writeFileSync(rootDir + "/LICENSES", licensesFileContent, "utf-8"); }
[ "function", "writeLicensesFile", "(", "rootDir", ")", "{", "var", "licenses", "=", "checkLicenses", "(", "rootDir", ")", ",", "licensesFileContent", "=", "\"LICENSES \"", "+", "\"\\n \\n\"", ";", "_", "(", "licenses", ")", ".", "each", "(", "function", "(", "licenseData", ",", "licenseName", ")", "{", "licensesFileContent", "+=", "licenseName", "+", "\" : \"", ";", "if", "(", "licenseData", ".", "isMIT", ")", "{", "licensesFileContent", "+=", "\"MIT\"", ";", "}", "else", "{", "licensesFileContent", "+=", "\"Unknown License\"", ";", "}", "licensesFileContent", "+=", "\"\\n \\n\"", ";", "if", "(", "licenseData", ".", "content", ")", "{", "licensesFileContent", "+=", "licenseData", ".", "content", "+", "\"\\n \\n\"", ";", "}", "}", ")", ";", "fs", ".", "writeFileSync", "(", "rootDir", "+", "\"/LICENSES\"", ",", "licensesFileContent", ",", "\"utf-8\"", ")", ";", "}" ]
writes all License-information in a single file called LICENSES @param rootDir the rootDir of your module
[ "writes", "all", "License", "-", "information", "in", "a", "single", "file", "called", "LICENSES" ]
6056e7937a1b3cd415b53e1be9b9c4ff8cc115e7
https://github.com/meaku/lawyer/blob/6056e7937a1b3cd415b53e1be9b9c4ff8cc115e7/lib/index.js#L59-L84
50,537
tolokoban/ToloFrameWork
spec-jasmine/util.spec.js
check
function check( input, expected ) { const output = Util.replaceDotsWithSlashes( input ); expect( output ).toBe( expected.split( '/' ).join( Path.sep ) ); }
javascript
function check( input, expected ) { const output = Util.replaceDotsWithSlashes( input ); expect( output ).toBe( expected.split( '/' ).join( Path.sep ) ); }
[ "function", "check", "(", "input", ",", "expected", ")", "{", "const", "output", "=", "Util", ".", "replaceDotsWithSlashes", "(", "input", ")", ";", "expect", "(", "output", ")", ".", "toBe", "(", "expected", ".", "split", "(", "'/'", ")", ".", "join", "(", "Path", ".", "sep", ")", ")", ";", "}" ]
Check if the input produces what was expected. @param {string} input - File name with full path. @param {string} expected - What was expected. @returns {undefined}
[ "Check", "if", "the", "input", "produces", "what", "was", "expected", "." ]
730845a833a9660ebfdb60ad027ebaab5ac871b6
https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/spec-jasmine/util.spec.js#L17-L20
50,538
mikesamuel/template-tag-common
index.js
memoizedTagFunction
function memoizedTagFunction (computeStaticHelper, computeResultHelper) { const memoTable = new LruCache() /** * @param {!Array.<string>} staticStrings * @return {T} */ function staticStateFor (staticStrings) { let staticState = null const canMemoize = Object.isFrozen(staticStrings) && Object.isFrozen(staticStrings.raw) if (canMemoize) { staticState = memoTable.get(staticStrings) } let failure = null if (!staticState) { try { staticState = { pass: computeStaticHelper(staticStrings) } } catch (exc) { failure = exc staticState = { fail: exc.message || 'Failure' } } if (canMemoize) { memoTable.set(staticStrings, staticState) } } if (staticState.fail) { throw failure || new Error(staticState.fail) } return staticState.pass } /** @param {O} options */ function usingOptions (options) { return (staticStringsOrOptions, ...dynamicValues) => { // If we've only been passed an options object, // return a template tag that uses it. if (dynamicValues.length === 0 && !Array.isArray(staticStringsOrOptions)) { return usingOptions(staticStringsOrOptions) } const staticStrings = staticStringsOrOptions requireValidTagInputs(staticStrings, dynamicValues) return computeResultHelper( options, staticStateFor(staticStrings), staticStrings, dynamicValues) } } // eslint-disable-next-line no-inline-comments return usingOptions(/** @type {O} */ ({})) }
javascript
function memoizedTagFunction (computeStaticHelper, computeResultHelper) { const memoTable = new LruCache() /** * @param {!Array.<string>} staticStrings * @return {T} */ function staticStateFor (staticStrings) { let staticState = null const canMemoize = Object.isFrozen(staticStrings) && Object.isFrozen(staticStrings.raw) if (canMemoize) { staticState = memoTable.get(staticStrings) } let failure = null if (!staticState) { try { staticState = { pass: computeStaticHelper(staticStrings) } } catch (exc) { failure = exc staticState = { fail: exc.message || 'Failure' } } if (canMemoize) { memoTable.set(staticStrings, staticState) } } if (staticState.fail) { throw failure || new Error(staticState.fail) } return staticState.pass } /** @param {O} options */ function usingOptions (options) { return (staticStringsOrOptions, ...dynamicValues) => { // If we've only been passed an options object, // return a template tag that uses it. if (dynamicValues.length === 0 && !Array.isArray(staticStringsOrOptions)) { return usingOptions(staticStringsOrOptions) } const staticStrings = staticStringsOrOptions requireValidTagInputs(staticStrings, dynamicValues) return computeResultHelper( options, staticStateFor(staticStrings), staticStrings, dynamicValues) } } // eslint-disable-next-line no-inline-comments return usingOptions(/** @type {O} */ ({})) }
[ "function", "memoizedTagFunction", "(", "computeStaticHelper", ",", "computeResultHelper", ")", "{", "const", "memoTable", "=", "new", "LruCache", "(", ")", "/**\n * @param {!Array.<string>} staticStrings\n * @return {T}\n */", "function", "staticStateFor", "(", "staticStrings", ")", "{", "let", "staticState", "=", "null", "const", "canMemoize", "=", "Object", ".", "isFrozen", "(", "staticStrings", ")", "&&", "Object", ".", "isFrozen", "(", "staticStrings", ".", "raw", ")", "if", "(", "canMemoize", ")", "{", "staticState", "=", "memoTable", ".", "get", "(", "staticStrings", ")", "}", "let", "failure", "=", "null", "if", "(", "!", "staticState", ")", "{", "try", "{", "staticState", "=", "{", "pass", ":", "computeStaticHelper", "(", "staticStrings", ")", "}", "}", "catch", "(", "exc", ")", "{", "failure", "=", "exc", "staticState", "=", "{", "fail", ":", "exc", ".", "message", "||", "'Failure'", "}", "}", "if", "(", "canMemoize", ")", "{", "memoTable", ".", "set", "(", "staticStrings", ",", "staticState", ")", "}", "}", "if", "(", "staticState", ".", "fail", ")", "{", "throw", "failure", "||", "new", "Error", "(", "staticState", ".", "fail", ")", "}", "return", "staticState", ".", "pass", "}", "/** @param {O} options */", "function", "usingOptions", "(", "options", ")", "{", "return", "(", "staticStringsOrOptions", ",", "...", "dynamicValues", ")", "=>", "{", "// If we've only been passed an options object,", "// return a template tag that uses it.", "if", "(", "dynamicValues", ".", "length", "===", "0", "&&", "!", "Array", ".", "isArray", "(", "staticStringsOrOptions", ")", ")", "{", "return", "usingOptions", "(", "staticStringsOrOptions", ")", "}", "const", "staticStrings", "=", "staticStringsOrOptions", "requireValidTagInputs", "(", "staticStrings", ",", "dynamicValues", ")", "return", "computeResultHelper", "(", "options", ",", "staticStateFor", "(", "staticStrings", ")", ",", "staticStrings", ",", "dynamicValues", ")", "}", "}", "// eslint-disable-next-line no-inline-comments", "return", "usingOptions", "(", "/** @type {O} */", "(", "{", "}", ")", ")", "}" ]
Memoizes operations on the static portions so the per-use cost of a tagged template literal is related to the complexity of handling the dynamic values. @template O @template R @template T @param {!function (!Array.<string>): T} computeStaticHelper called when there is no entry for the frozen static strings object, and cached weakly thereafter. Receives a string of arrays with a {@code .raw} property that is a string array of the same length. @param {!function (O, T, !Array.<string>, !Array.<*>): R} computeResultHelper a function that takes three parameters: @return {configurableTemplateTag<O, R>} A function that either takes an options object (O), in which case it returns another configurableTemplateTag; or it takes a TemplateObject and returns a result of type R. When used as a template tag it calls computeStaticHelper as needed on the static portion and returns the result of applying computeResultHelper.
[ "Memoizes", "operations", "on", "the", "static", "portions", "so", "the", "per", "-", "use", "cost", "of", "a", "tagged", "template", "literal", "is", "related", "to", "the", "complexity", "of", "handling", "the", "dynamic", "values", "." ]
4e397aafc2a570379709172ea110ecdbe1135e91
https://github.com/mikesamuel/template-tag-common/blob/4e397aafc2a570379709172ea110ecdbe1135e91/index.js#L127-L179
50,539
mikesamuel/template-tag-common
index.js
commonPrefixOf
function commonPrefixOf (a, b) { // eslint-disable-line id-length const minLen = Math.min(a.length, b.length) let i = 0 for (; i < minLen; ++i) { if (a[i] !== b[i]) { break } } return a.substring(0, i) }
javascript
function commonPrefixOf (a, b) { // eslint-disable-line id-length const minLen = Math.min(a.length, b.length) let i = 0 for (; i < minLen; ++i) { if (a[i] !== b[i]) { break } } return a.substring(0, i) }
[ "function", "commonPrefixOf", "(", "a", ",", "b", ")", "{", "// eslint-disable-line id-length", "const", "minLen", "=", "Math", ".", "min", "(", "a", ".", "length", ",", "b", ".", "length", ")", "let", "i", "=", "0", "for", "(", ";", "i", "<", "minLen", ";", "++", "i", ")", "{", "if", "(", "a", "[", "i", "]", "!==", "b", "[", "i", "]", ")", "{", "break", "}", "}", "return", "a", ".", "substring", "(", "0", ",", "i", ")", "}" ]
The longest prefix of a that is also a prefix of b
[ "The", "longest", "prefix", "of", "a", "that", "is", "also", "a", "prefix", "of", "b" ]
4e397aafc2a570379709172ea110ecdbe1135e91
https://github.com/mikesamuel/template-tag-common/blob/4e397aafc2a570379709172ea110ecdbe1135e91/index.js#L182-L191
50,540
mikesamuel/template-tag-common
index.js
trimCommonWhitespaceFromLines
function trimCommonWhitespaceFromLines ( templateStrings, { trimEolAtStart = false, trimEolAtEnd = false } = {}) { // Find a common prefix to remove const commonPrefix = commonPrefixOfTemplateStrings(templateStrings) let prefixPattern = null if (commonPrefix) { // commonPrefix contains no RegExp metacharacters since it only contains // whitespace. prefixPattern = new RegExp( `(${LINE_TERMINATORS.source})${commonPrefix}`, 'g') } else if (trimEolAtStart || trimEolAtEnd) { // We don't need to remove a prefix, but we might need to do some // post processing, so just use a prefix pattern that never matches. prefixPattern = /(?!)/ } else { // Fast path. return templateStrings } const { raw, length } = templateStrings // Apply slice so that raw is in the same realm as the tag function. const trimmedRaw = Array.prototype.slice.apply(raw).map( (chunk) => chunk.replace(prefixPattern, '$1')) if (trimEolAtStart) { trimmedRaw[0] = trimmedRaw[0].replace(LINE_TERMINATOR_AT_START, '') } if (trimEolAtEnd) { trimmedRaw[length - 1] = trimmedRaw[length - 1] .replace(LINE_TERMINATOR_AT_END, '') } const trimmedCooked = trimmedRaw.map(cook) trimmedCooked.raw = trimmedRaw Object.freeze(trimmedRaw) Object.freeze(trimmedCooked) return trimmedCooked }
javascript
function trimCommonWhitespaceFromLines ( templateStrings, { trimEolAtStart = false, trimEolAtEnd = false } = {}) { // Find a common prefix to remove const commonPrefix = commonPrefixOfTemplateStrings(templateStrings) let prefixPattern = null if (commonPrefix) { // commonPrefix contains no RegExp metacharacters since it only contains // whitespace. prefixPattern = new RegExp( `(${LINE_TERMINATORS.source})${commonPrefix}`, 'g') } else if (trimEolAtStart || trimEolAtEnd) { // We don't need to remove a prefix, but we might need to do some // post processing, so just use a prefix pattern that never matches. prefixPattern = /(?!)/ } else { // Fast path. return templateStrings } const { raw, length } = templateStrings // Apply slice so that raw is in the same realm as the tag function. const trimmedRaw = Array.prototype.slice.apply(raw).map( (chunk) => chunk.replace(prefixPattern, '$1')) if (trimEolAtStart) { trimmedRaw[0] = trimmedRaw[0].replace(LINE_TERMINATOR_AT_START, '') } if (trimEolAtEnd) { trimmedRaw[length - 1] = trimmedRaw[length - 1] .replace(LINE_TERMINATOR_AT_END, '') } const trimmedCooked = trimmedRaw.map(cook) trimmedCooked.raw = trimmedRaw Object.freeze(trimmedRaw) Object.freeze(trimmedCooked) return trimmedCooked }
[ "function", "trimCommonWhitespaceFromLines", "(", "templateStrings", ",", "{", "trimEolAtStart", "=", "false", ",", "trimEolAtEnd", "=", "false", "}", "=", "{", "}", ")", "{", "// Find a common prefix to remove", "const", "commonPrefix", "=", "commonPrefixOfTemplateStrings", "(", "templateStrings", ")", "let", "prefixPattern", "=", "null", "if", "(", "commonPrefix", ")", "{", "// commonPrefix contains no RegExp metacharacters since it only contains", "// whitespace.", "prefixPattern", "=", "new", "RegExp", "(", "`", "${", "LINE_TERMINATORS", ".", "source", "}", "${", "commonPrefix", "}", "`", ",", "'g'", ")", "}", "else", "if", "(", "trimEolAtStart", "||", "trimEolAtEnd", ")", "{", "// We don't need to remove a prefix, but we might need to do some", "// post processing, so just use a prefix pattern that never matches.", "prefixPattern", "=", "/", "(?!)", "/", "}", "else", "{", "// Fast path.", "return", "templateStrings", "}", "const", "{", "raw", ",", "length", "}", "=", "templateStrings", "// Apply slice so that raw is in the same realm as the tag function.", "const", "trimmedRaw", "=", "Array", ".", "prototype", ".", "slice", ".", "apply", "(", "raw", ")", ".", "map", "(", "(", "chunk", ")", "=>", "chunk", ".", "replace", "(", "prefixPattern", ",", "'$1'", ")", ")", "if", "(", "trimEolAtStart", ")", "{", "trimmedRaw", "[", "0", "]", "=", "trimmedRaw", "[", "0", "]", ".", "replace", "(", "LINE_TERMINATOR_AT_START", ",", "''", ")", "}", "if", "(", "trimEolAtEnd", ")", "{", "trimmedRaw", "[", "length", "-", "1", "]", "=", "trimmedRaw", "[", "length", "-", "1", "]", ".", "replace", "(", "LINE_TERMINATOR_AT_END", ",", "''", ")", "}", "const", "trimmedCooked", "=", "trimmedRaw", ".", "map", "(", "cook", ")", "trimmedCooked", ".", "raw", "=", "trimmedRaw", "Object", ".", "freeze", "(", "trimmedRaw", ")", "Object", ".", "freeze", "(", "trimmedCooked", ")", "return", "trimmedCooked", "}" ]
Simplifies tripping common leading whitespace from a multiline template tag so that a template tag can be re-indented as a block. This may be called from a computeStaticHandler so that it need not happen every time a particular template is reached. "Whitespace" and "line terminators" mean the same as they do in ES6: https://www.ecma-international.org/ecma-262/6.0/#sec-white-space https://www.ecma-international.org/ecma-262/6.0/#sec-line-terminators
[ "Simplifies", "tripping", "common", "leading", "whitespace", "from", "a", "multiline", "template", "tag", "so", "that", "a", "template", "tag", "can", "be", "re", "-", "indented", "as", "a", "block", "." ]
4e397aafc2a570379709172ea110ecdbe1135e91
https://github.com/mikesamuel/template-tag-common/blob/4e397aafc2a570379709172ea110ecdbe1135e91/index.js#L236-L278
50,541
redisjs/jsr-store
lib/type/set.js
Set
function Set(source) { HashMap.call(this); this._rtype = TYPE_NAMES.SET; if(source) { this.sadd(source); } }
javascript
function Set(source) { HashMap.call(this); this._rtype = TYPE_NAMES.SET; if(source) { this.sadd(source); } }
[ "function", "Set", "(", "source", ")", "{", "HashMap", ".", "call", "(", "this", ")", ";", "this", ".", "_rtype", "=", "TYPE_NAMES", ".", "SET", ";", "if", "(", "source", ")", "{", "this", ".", "sadd", "(", "source", ")", ";", "}", "}" ]
Represents the set type.
[ "Represents", "the", "set", "type", "." ]
b2b5c5b0347819f8a388b5d67e121ee8d73f328c
https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/type/set.js#L10-L16
50,542
redisjs/jsr-store
lib/type/set.js
sadd
function sadd(members) { var i , c = 0; for(i = 0;i < members.length;i++) { if(!this._data[members[i]]) { this.setKey(members[i], 1); c++; } } return c; }
javascript
function sadd(members) { var i , c = 0; for(i = 0;i < members.length;i++) { if(!this._data[members[i]]) { this.setKey(members[i], 1); c++; } } return c; }
[ "function", "sadd", "(", "members", ")", "{", "var", "i", ",", "c", "=", "0", ";", "for", "(", "i", "=", "0", ";", "i", "<", "members", ".", "length", ";", "i", "++", ")", "{", "if", "(", "!", "this", ".", "_data", "[", "members", "[", "i", "]", "]", ")", "{", "this", ".", "setKey", "(", "members", "[", "i", "]", ",", "1", ")", ";", "c", "++", ";", "}", "}", "return", "c", ";", "}" ]
Add the specified members to the set.
[ "Add", "the", "specified", "members", "to", "the", "set", "." ]
b2b5c5b0347819f8a388b5d67e121ee8d73f328c
https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/type/set.js#L23-L33
50,543
redisjs/jsr-store
lib/type/set.js
spop
function spop() { var ind = Math.floor(Math.random() * this._keys.length) , val = this._keys[ind]; this.delKey(val); return val; }
javascript
function spop() { var ind = Math.floor(Math.random() * this._keys.length) , val = this._keys[ind]; this.delKey(val); return val; }
[ "function", "spop", "(", ")", "{", "var", "ind", "=", "Math", ".", "floor", "(", "Math", ".", "random", "(", ")", "*", "this", ".", "_keys", ".", "length", ")", ",", "val", "=", "this", ".", "_keys", "[", "ind", "]", ";", "this", ".", "delKey", "(", "val", ")", ";", "return", "val", ";", "}" ]
Removes and returns a random element from the set.
[ "Removes", "and", "returns", "a", "random", "element", "from", "the", "set", "." ]
b2b5c5b0347819f8a388b5d67e121ee8d73f328c
https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/type/set.js#L80-L85
50,544
redisjs/jsr-store
lib/type/set.js
srem
function srem(members) { var i , c = 0; for(i = 0;i < members.length;i++) { if(this.keyExists(members[i])) { this.delKey(members[i]); c++; } } return c; }
javascript
function srem(members) { var i , c = 0; for(i = 0;i < members.length;i++) { if(this.keyExists(members[i])) { this.delKey(members[i]); c++; } } return c; }
[ "function", "srem", "(", "members", ")", "{", "var", "i", ",", "c", "=", "0", ";", "for", "(", "i", "=", "0", ";", "i", "<", "members", ".", "length", ";", "i", "++", ")", "{", "if", "(", "this", ".", "keyExists", "(", "members", "[", "i", "]", ")", ")", "{", "this", ".", "delKey", "(", "members", "[", "i", "]", ")", ";", "c", "++", ";", "}", "}", "return", "c", ";", "}" ]
Remove the specified members from the set.
[ "Remove", "the", "specified", "members", "from", "the", "set", "." ]
b2b5c5b0347819f8a388b5d67e121ee8d73f328c
https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/type/set.js#L90-L100
50,545
PanthR/panthrMath
panthrMath/basicFunc/choose.js
lchoose
function lchoose(n, k) { k = Math.round(k); if (utils.hasNaN(n, k)) { return NaN; } if (k < 0) { return -Infinity; } if (k === 0) { return 0; } if (k === 1) { return Math.log(Math.abs(n)); } if (n < 0) { return lchoose(-n + k - 1, k); } if (n === Math.round(n)) { if (n < k) { return -Infinity; } if (n - k < 2) { return lchoose(n, n - k); } return lfastchoose(n, k); } if (n < k - 1) { return lfastchoose2(n, k); } return lfastchoose(n, k); }
javascript
function lchoose(n, k) { k = Math.round(k); if (utils.hasNaN(n, k)) { return NaN; } if (k < 0) { return -Infinity; } if (k === 0) { return 0; } if (k === 1) { return Math.log(Math.abs(n)); } if (n < 0) { return lchoose(-n + k - 1, k); } if (n === Math.round(n)) { if (n < k) { return -Infinity; } if (n - k < 2) { return lchoose(n, n - k); } return lfastchoose(n, k); } if (n < k - 1) { return lfastchoose2(n, k); } return lfastchoose(n, k); }
[ "function", "lchoose", "(", "n", ",", "k", ")", "{", "k", "=", "Math", ".", "round", "(", "k", ")", ";", "if", "(", "utils", ".", "hasNaN", "(", "n", ",", "k", ")", ")", "{", "return", "NaN", ";", "}", "if", "(", "k", "<", "0", ")", "{", "return", "-", "Infinity", ";", "}", "if", "(", "k", "===", "0", ")", "{", "return", "0", ";", "}", "if", "(", "k", "===", "1", ")", "{", "return", "Math", ".", "log", "(", "Math", ".", "abs", "(", "n", ")", ")", ";", "}", "if", "(", "n", "<", "0", ")", "{", "return", "lchoose", "(", "-", "n", "+", "k", "-", "1", ",", "k", ")", ";", "}", "if", "(", "n", "===", "Math", ".", "round", "(", "n", ")", ")", "{", "if", "(", "n", "<", "k", ")", "{", "return", "-", "Infinity", ";", "}", "if", "(", "n", "-", "k", "<", "2", ")", "{", "return", "lchoose", "(", "n", ",", "n", "-", "k", ")", ";", "}", "return", "lfastchoose", "(", "n", ",", "k", ")", ";", "}", "if", "(", "n", "<", "k", "-", "1", ")", "{", "return", "lfastchoose2", "(", "n", ",", "k", ")", ";", "}", "return", "lfastchoose", "(", "n", ",", "k", ")", ";", "}" ]
Computes the logarithm of the absolute value of the binomial coefficient. Valid for any real n and for integer k. k will be rounded if it is not an integer.
[ "Computes", "the", "logarithm", "of", "the", "absolute", "value", "of", "the", "binomial", "coefficient", ".", "Valid", "for", "any", "real", "n", "and", "for", "integer", "k", ".", "k", "will", "be", "rounded", "if", "it", "is", "not", "an", "integer", "." ]
54d249ca9903a9535f963da711bd3a87fb229c0b
https://github.com/PanthR/panthrMath/blob/54d249ca9903a9535f963da711bd3a87fb229c0b/panthrMath/basicFunc/choose.js#L18-L34
50,546
PanthR/panthrMath
panthrMath/basicFunc/choose.js
choose
function choose(n, k) { var ret, j; k = Math.round(k); if (utils.hasNaN(n, k)) { return NaN; } if (k < kSmallMax) { if (n - k < k && n >= 0 && n === Math.round(n)) { k = n - k; } if (k < 0) { return 0; } if (k === 0) { return 1; } ret = n; for (j = 2; j <= k; j += 1) { ret *= (n - j + 1) / j; } return n === Math.round(n) ? Math.round(ret) : ret; } if (n < 0) { ret = choose(-n + k - 1, k); return k % 2 === 1 ? -ret : ret; } if (n === Math.round(n)) { if (n < k) { return 0; } if (n - k < kSmallMax) { return choose(n, n - k); } return Math.round(Math.exp(lfastchoose(n, k))); } if (n < k - 1) { return signGamma(n - k + 1) * Math.exp(lfastchoose2(n, k)); } return Math.exp(lfastchoose(n, k)); }
javascript
function choose(n, k) { var ret, j; k = Math.round(k); if (utils.hasNaN(n, k)) { return NaN; } if (k < kSmallMax) { if (n - k < k && n >= 0 && n === Math.round(n)) { k = n - k; } if (k < 0) { return 0; } if (k === 0) { return 1; } ret = n; for (j = 2; j <= k; j += 1) { ret *= (n - j + 1) / j; } return n === Math.round(n) ? Math.round(ret) : ret; } if (n < 0) { ret = choose(-n + k - 1, k); return k % 2 === 1 ? -ret : ret; } if (n === Math.round(n)) { if (n < k) { return 0; } if (n - k < kSmallMax) { return choose(n, n - k); } return Math.round(Math.exp(lfastchoose(n, k))); } if (n < k - 1) { return signGamma(n - k + 1) * Math.exp(lfastchoose2(n, k)); } return Math.exp(lfastchoose(n, k)); }
[ "function", "choose", "(", "n", ",", "k", ")", "{", "var", "ret", ",", "j", ";", "k", "=", "Math", ".", "round", "(", "k", ")", ";", "if", "(", "utils", ".", "hasNaN", "(", "n", ",", "k", ")", ")", "{", "return", "NaN", ";", "}", "if", "(", "k", "<", "kSmallMax", ")", "{", "if", "(", "n", "-", "k", "<", "k", "&&", "n", ">=", "0", "&&", "n", "===", "Math", ".", "round", "(", "n", ")", ")", "{", "k", "=", "n", "-", "k", ";", "}", "if", "(", "k", "<", "0", ")", "{", "return", "0", ";", "}", "if", "(", "k", "===", "0", ")", "{", "return", "1", ";", "}", "ret", "=", "n", ";", "for", "(", "j", "=", "2", ";", "j", "<=", "k", ";", "j", "+=", "1", ")", "{", "ret", "*=", "(", "n", "-", "j", "+", "1", ")", "/", "j", ";", "}", "return", "n", "===", "Math", ".", "round", "(", "n", ")", "?", "Math", ".", "round", "(", "ret", ")", ":", "ret", ";", "}", "if", "(", "n", "<", "0", ")", "{", "ret", "=", "choose", "(", "-", "n", "+", "k", "-", "1", ",", "k", ")", ";", "return", "k", "%", "2", "===", "1", "?", "-", "ret", ":", "ret", ";", "}", "if", "(", "n", "===", "Math", ".", "round", "(", "n", ")", ")", "{", "if", "(", "n", "<", "k", ")", "{", "return", "0", ";", "}", "if", "(", "n", "-", "k", "<", "kSmallMax", ")", "{", "return", "choose", "(", "n", ",", "n", "-", "k", ")", ";", "}", "return", "Math", ".", "round", "(", "Math", ".", "exp", "(", "lfastchoose", "(", "n", ",", "k", ")", ")", ")", ";", "}", "if", "(", "n", "<", "k", "-", "1", ")", "{", "return", "signGamma", "(", "n", "-", "k", "+", "1", ")", "*", "Math", ".", "exp", "(", "lfastchoose2", "(", "n", ",", "k", ")", ")", ";", "}", "return", "Math", ".", "exp", "(", "lfastchoose", "(", "n", ",", "k", ")", ")", ";", "}" ]
Computes the binomial coefficient "n choose k". Valid for any real n and for integer k. k will be rounded if it is not an integer.
[ "Computes", "the", "binomial", "coefficient", "n", "choose", "k", ".", "Valid", "for", "any", "real", "n", "and", "for", "integer", "k", ".", "k", "will", "be", "rounded", "if", "it", "is", "not", "an", "integer", "." ]
54d249ca9903a9535f963da711bd3a87fb229c0b
https://github.com/PanthR/panthrMath/blob/54d249ca9903a9535f963da711bd3a87fb229c0b/panthrMath/basicFunc/choose.js#L41-L73
50,547
syntheticore/declaire
src/collection.js
function(item) { var self = this; var items = Array.isArray(item) ? item : [item]; var added = false; _.each(items, function(item) { if(!_.contains(self.items, item)) { self.items.push(item); if(item && item.klass == 'Instance') { item.once('delete', function() { self.remove(item); }); }; added = true; } }); if(added) { self.emit('add'); self.emit('change:size'); self.emit('change'); } return self; }
javascript
function(item) { var self = this; var items = Array.isArray(item) ? item : [item]; var added = false; _.each(items, function(item) { if(!_.contains(self.items, item)) { self.items.push(item); if(item && item.klass == 'Instance') { item.once('delete', function() { self.remove(item); }); }; added = true; } }); if(added) { self.emit('add'); self.emit('change:size'); self.emit('change'); } return self; }
[ "function", "(", "item", ")", "{", "var", "self", "=", "this", ";", "var", "items", "=", "Array", ".", "isArray", "(", "item", ")", "?", "item", ":", "[", "item", "]", ";", "var", "added", "=", "false", ";", "_", ".", "each", "(", "items", ",", "function", "(", "item", ")", "{", "if", "(", "!", "_", ".", "contains", "(", "self", ".", "items", ",", "item", ")", ")", "{", "self", ".", "items", ".", "push", "(", "item", ")", ";", "if", "(", "item", "&&", "item", ".", "klass", "==", "'Instance'", ")", "{", "item", ".", "once", "(", "'delete'", ",", "function", "(", ")", "{", "self", ".", "remove", "(", "item", ")", ";", "}", ")", ";", "}", ";", "added", "=", "true", ";", "}", "}", ")", ";", "if", "(", "added", ")", "{", "self", ".", "emit", "(", "'add'", ")", ";", "self", ".", "emit", "(", "'change:size'", ")", ";", "self", ".", "emit", "(", "'change'", ")", ";", "}", "return", "self", ";", "}" ]
Add one or many items
[ "Add", "one", "or", "many", "items" ]
cb5ea205eeb3aa26fd0c6348e86d840c04e9ba9f
https://github.com/syntheticore/declaire/blob/cb5ea205eeb3aa26fd0c6348e86d840c04e9ba9f/src/collection.js#L11-L32
50,548
MakerCollider/node-red-contrib-smartnode-hook
html/scripts/RGraph/RGraph.bar.js
myOnresizebeforedraw
function myOnresizebeforedraw (obj) { var gutterLeft = obj.Get('chart.gutter.left'); var gutterRight = obj.Get('chart.gutter.right'); obj.Set('chart.hmargin', (obj.canvas.width - gutterLeft - gutterRight) / (obj.original_data[0].length * 2)); }
javascript
function myOnresizebeforedraw (obj) { var gutterLeft = obj.Get('chart.gutter.left'); var gutterRight = obj.Get('chart.gutter.right'); obj.Set('chart.hmargin', (obj.canvas.width - gutterLeft - gutterRight) / (obj.original_data[0].length * 2)); }
[ "function", "myOnresizebeforedraw", "(", "obj", ")", "{", "var", "gutterLeft", "=", "obj", ".", "Get", "(", "'chart.gutter.left'", ")", ";", "var", "gutterRight", "=", "obj", ".", "Get", "(", "'chart.gutter.right'", ")", ";", "obj", ".", "Set", "(", "'chart.hmargin'", ",", "(", "obj", ".", "canvas", ".", "width", "-", "gutterLeft", "-", "gutterRight", ")", "/", "(", "obj", ".", "original_data", "[", "0", "]", ".", "length", "*", "2", ")", ")", ";", "}" ]
This recalculates the Line chart hmargin when the chart is resized
[ "This", "recalculates", "the", "Line", "chart", "hmargin", "when", "the", "chart", "is", "resized" ]
245c267e832968bad880ca009929043e82c7bc25
https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/RGraph/RGraph.bar.js#L3059-L3065
50,549
gethuman/pancakes-recipe
utils/hash.js
compare
function compare(data, encrypted) { var deferred = Q.defer(); bcrypt.compare(data, encrypted, function (err, res) { err ? deferred.reject(err) : deferred.resolve(res); }); return deferred.promise; }
javascript
function compare(data, encrypted) { var deferred = Q.defer(); bcrypt.compare(data, encrypted, function (err, res) { err ? deferred.reject(err) : deferred.resolve(res); }); return deferred.promise; }
[ "function", "compare", "(", "data", ",", "encrypted", ")", "{", "var", "deferred", "=", "Q", ".", "defer", "(", ")", ";", "bcrypt", ".", "compare", "(", "data", ",", "encrypted", ",", "function", "(", "err", ",", "res", ")", "{", "err", "?", "deferred", ".", "reject", "(", "err", ")", ":", "deferred", ".", "resolve", "(", "res", ")", ";", "}", ")", ";", "return", "deferred", ".", "promise", ";", "}" ]
Compare some data to an encrypted version @param data @param encrypted
[ "Compare", "some", "data", "to", "an", "encrypted", "version" ]
ea3feb8839e2edaf1b4577c052b8958953db4498
https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/utils/hash.js#L15-L23
50,550
gethuman/pancakes-recipe
utils/hash.js
generateHash
function generateHash(data) { var deferred = Q.defer(); bcrypt.hash(data, 10, function (err, res) { err ? deferred.reject(err) : deferred.resolve(res); }); return deferred.promise; }
javascript
function generateHash(data) { var deferred = Q.defer(); bcrypt.hash(data, 10, function (err, res) { err ? deferred.reject(err) : deferred.resolve(res); }); return deferred.promise; }
[ "function", "generateHash", "(", "data", ")", "{", "var", "deferred", "=", "Q", ".", "defer", "(", ")", ";", "bcrypt", ".", "hash", "(", "data", ",", "10", ",", "function", "(", "err", ",", "res", ")", "{", "err", "?", "deferred", ".", "reject", "(", "err", ")", ":", "deferred", ".", "resolve", "(", "res", ")", ";", "}", ")", ";", "return", "deferred", ".", "promise", ";", "}" ]
Generate hash off some data @param data
[ "Generate", "hash", "off", "some", "data" ]
ea3feb8839e2edaf1b4577c052b8958953db4498
https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/utils/hash.js#L29-L37
50,551
base/base-pipeline
index.js
isDisabled
function isDisabled(app, key, prop) { // key + '.plugin' if (app.isFalse([key, prop])) { return true; } // key + '.plugin.disable' if (app.isTrue([key, prop, 'disable'])) { return true; } return false; }
javascript
function isDisabled(app, key, prop) { // key + '.plugin' if (app.isFalse([key, prop])) { return true; } // key + '.plugin.disable' if (app.isTrue([key, prop, 'disable'])) { return true; } return false; }
[ "function", "isDisabled", "(", "app", ",", "key", ",", "prop", ")", "{", "// key + '.plugin'", "if", "(", "app", ".", "isFalse", "(", "[", "key", ",", "prop", "]", ")", ")", "{", "return", "true", ";", "}", "// key + '.plugin.disable'", "if", "(", "app", ".", "isTrue", "(", "[", "key", ",", "prop", ",", "'disable'", "]", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Returns true if the plugin is disabled.
[ "Returns", "true", "if", "the", "plugin", "is", "disabled", "." ]
7f5aa3365caa1401567cd5eaf222d92356e1bac0
https://github.com/base/base-pipeline/blob/7f5aa3365caa1401567cd5eaf222d92356e1bac0/index.js#L126-L136
50,552
express-bem/bh
lib/engines/bh.js
bh
function bh(name, options, cb) { var filePath; var bhModule; var html; var lang; if (typeof options.lang === 'string') { lang = options.lang; } // reject rendering for empty options.bemjson if (!options.bemjson) { cb(Error('No bemjson was passed')); return; } filePath = U.fulfillName({ name: name, ext: opts.ext || this.ext, mask: opts.source, lang: lang }); // drop cache if (opts.force || options.forceExec || options.forceLoad) { dropRequireCache = dropRequireCache || require('enb/lib/fs/drop-require-cache'); dropRequireCache(require, filePath); } try { bhModule = require(filePath); } catch (e) { cb(e); return; } // add data to use in templates if (opts.dataKey) { options.bemjson[opts.dataKey] = bhModule.utils.extend({}, options); delete options.bemjson[opts.dataKey].bemjson; } try { html = bhModule.apply(options.bemjson); } catch (e) { cb(e); return; } cb(null, html); }
javascript
function bh(name, options, cb) { var filePath; var bhModule; var html; var lang; if (typeof options.lang === 'string') { lang = options.lang; } // reject rendering for empty options.bemjson if (!options.bemjson) { cb(Error('No bemjson was passed')); return; } filePath = U.fulfillName({ name: name, ext: opts.ext || this.ext, mask: opts.source, lang: lang }); // drop cache if (opts.force || options.forceExec || options.forceLoad) { dropRequireCache = dropRequireCache || require('enb/lib/fs/drop-require-cache'); dropRequireCache(require, filePath); } try { bhModule = require(filePath); } catch (e) { cb(e); return; } // add data to use in templates if (opts.dataKey) { options.bemjson[opts.dataKey] = bhModule.utils.extend({}, options); delete options.bemjson[opts.dataKey].bemjson; } try { html = bhModule.apply(options.bemjson); } catch (e) { cb(e); return; } cb(null, html); }
[ "function", "bh", "(", "name", ",", "options", ",", "cb", ")", "{", "var", "filePath", ";", "var", "bhModule", ";", "var", "html", ";", "var", "lang", ";", "if", "(", "typeof", "options", ".", "lang", "===", "'string'", ")", "{", "lang", "=", "options", ".", "lang", ";", "}", "// reject rendering for empty options.bemjson", "if", "(", "!", "options", ".", "bemjson", ")", "{", "cb", "(", "Error", "(", "'No bemjson was passed'", ")", ")", ";", "return", ";", "}", "filePath", "=", "U", ".", "fulfillName", "(", "{", "name", ":", "name", ",", "ext", ":", "opts", ".", "ext", "||", "this", ".", "ext", ",", "mask", ":", "opts", ".", "source", ",", "lang", ":", "lang", "}", ")", ";", "// drop cache", "if", "(", "opts", ".", "force", "||", "options", ".", "forceExec", "||", "options", ".", "forceLoad", ")", "{", "dropRequireCache", "=", "dropRequireCache", "||", "require", "(", "'enb/lib/fs/drop-require-cache'", ")", ";", "dropRequireCache", "(", "require", ",", "filePath", ")", ";", "}", "try", "{", "bhModule", "=", "require", "(", "filePath", ")", ";", "}", "catch", "(", "e", ")", "{", "cb", "(", "e", ")", ";", "return", ";", "}", "// add data to use in templates", "if", "(", "opts", ".", "dataKey", ")", "{", "options", ".", "bemjson", "[", "opts", ".", "dataKey", "]", "=", "bhModule", ".", "utils", ".", "extend", "(", "{", "}", ",", "options", ")", ";", "delete", "options", ".", "bemjson", "[", "opts", ".", "dataKey", "]", ".", "bemjson", ";", "}", "try", "{", "html", "=", "bhModule", ".", "apply", "(", "options", ".", "bemjson", ")", ";", "}", "catch", "(", "e", ")", "{", "cb", "(", "e", ")", ";", "return", ";", "}", "cb", "(", "null", ",", "html", ")", ";", "}" ]
bh.js express view engine adapter Produces html from bh-templates and data and invokes passed callback with result @param {String} name Bundle name @param {Object} options Data to use in templates @param {String} options.lang Lang ID to render a localized template @param {Object} options.bemjson @param {Boolean} options.forceExec @param {Boolean} options.forceLoad @param {Function} cb Callback to invoke with result or error @returns {Undefined}
[ "bh", ".", "js", "express", "view", "engine", "adapter", "Produces", "html", "from", "bh", "-", "templates", "and", "data", "and", "invokes", "passed", "callback", "with", "result" ]
28da346ad991f09b224445b93f9abfaf6fa3d7b0
https://github.com/express-bem/bh/blob/28da346ad991f09b224445b93f9abfaf6fa3d7b0/lib/engines/bh.js#L25-L76
50,553
onehilltech/blueprint-testing
lib/request.js
request
function request (app) { app = app || blueprint.app.server.express; return supertest (app); }
javascript
function request (app) { app = app || blueprint.app.server.express; return supertest (app); }
[ "function", "request", "(", "app", ")", "{", "app", "=", "app", "||", "blueprint", ".", "app", ".", "server", ".", "express", ";", "return", "supertest", "(", "app", ")", ";", "}" ]
Make a test request. If no Express.js application is provided, then the request is sent to the current Blueprint.js application. @param app Optional application @returns {Test}
[ "Make", "a", "test", "request", ".", "If", "no", "Express", ".", "js", "application", "is", "provided", "then", "the", "request", "is", "sent", "to", "the", "current", "Blueprint", ".", "js", "application", "." ]
f14e38c5671dd7b009049962a0a27b9e5a0bf4a6
https://github.com/onehilltech/blueprint-testing/blob/f14e38c5671dd7b009049962a0a27b9e5a0bf4a6/lib/request.js#L28-L31
50,554
patchless/patchavatar-names
index.js
function (id) { var span = document.createElement('span') span.title = id api.sbot.names.getSignifier(id, function (err, name) { span.textContent = name }) if(!span.textContent) span.textContent = id return span }
javascript
function (id) { var span = document.createElement('span') span.title = id api.sbot.names.getSignifier(id, function (err, name) { span.textContent = name }) if(!span.textContent) span.textContent = id return span }
[ "function", "(", "id", ")", "{", "var", "span", "=", "document", ".", "createElement", "(", "'span'", ")", "span", ".", "title", "=", "id", "api", ".", "sbot", ".", "names", ".", "getSignifier", "(", "id", ",", "function", "(", "err", ",", "name", ")", "{", "span", ".", "textContent", "=", "name", "}", ")", "if", "(", "!", "span", ".", "textContent", ")", "span", ".", "textContent", "=", "id", "return", "span", "}" ]
fall through...
[ "fall", "through", "..." ]
b7ad555bfaaefceb41e3912b6bdf69aef8a99015
https://github.com/patchless/patchavatar-names/blob/b7ad555bfaaefceb41e3912b6bdf69aef8a99015/index.js#L32-L41
50,555
asavoy/grunt-requirejs-auto-bundles
lib/bundle.js
generateBundleName
function generateBundleName(mains) { // Join mains into a string. var joinedMains = mains.sort().join('-'); // Create hash. var hash = crypto.createHash('md5').update(joinedMains).digest('hex'); // Replace any special chars. joinedMains = joinedMains.replace(/\/|\\|\./g, '_'); // Truncate and append hash. var bundleName = joinedMains.slice(0, 16) + '-' + hash.slice(0, 6); return bundleName; }
javascript
function generateBundleName(mains) { // Join mains into a string. var joinedMains = mains.sort().join('-'); // Create hash. var hash = crypto.createHash('md5').update(joinedMains).digest('hex'); // Replace any special chars. joinedMains = joinedMains.replace(/\/|\\|\./g, '_'); // Truncate and append hash. var bundleName = joinedMains.slice(0, 16) + '-' + hash.slice(0, 6); return bundleName; }
[ "function", "generateBundleName", "(", "mains", ")", "{", "// Join mains into a string.", "var", "joinedMains", "=", "mains", ".", "sort", "(", ")", ".", "join", "(", "'-'", ")", ";", "// Create hash.", "var", "hash", "=", "crypto", ".", "createHash", "(", "'md5'", ")", ".", "update", "(", "joinedMains", ")", ".", "digest", "(", "'hex'", ")", ";", "// Replace any special chars.", "joinedMains", "=", "joinedMains", ".", "replace", "(", "/", "\\/|\\\\|\\.", "/", "g", ",", "'_'", ")", ";", "// Truncate and append hash.", "var", "bundleName", "=", "joinedMains", ".", "slice", "(", "0", ",", "16", ")", "+", "'-'", "+", "hash", ".", "slice", "(", "0", ",", "6", ")", ";", "return", "bundleName", ";", "}" ]
Calculate a unique bundle name, given a list of main modules that depend on its contents.
[ "Calculate", "a", "unique", "bundle", "name", "given", "a", "list", "of", "main", "modules", "that", "depend", "on", "its", "contents", "." ]
c0f587c9720943dd32098203d2c71ab1387f1700
https://github.com/asavoy/grunt-requirejs-auto-bundles/blob/c0f587c9720943dd32098203d2c71ab1387f1700/lib/bundle.js#L9-L22
50,556
andrewscwei/requiem
src/helpers/getDirectCustomChildren.js
getDirectCustomChildren
function getDirectCustomChildren(element, inclusive) { if (!inclusive && element.nodeState !== undefined) return []; let childRegistry = getChildRegistry(element); let children = []; for (let name in childRegistry) { let child = [].concat(childRegistry[name]); child.forEach((c) => { if (isCustomElement(c)) children.push(c); else children = children.concat(getDirectCustomChildren(c)); }); } return children; }
javascript
function getDirectCustomChildren(element, inclusive) { if (!inclusive && element.nodeState !== undefined) return []; let childRegistry = getChildRegistry(element); let children = []; for (let name in childRegistry) { let child = [].concat(childRegistry[name]); child.forEach((c) => { if (isCustomElement(c)) children.push(c); else children = children.concat(getDirectCustomChildren(c)); }); } return children; }
[ "function", "getDirectCustomChildren", "(", "element", ",", "inclusive", ")", "{", "if", "(", "!", "inclusive", "&&", "element", ".", "nodeState", "!==", "undefined", ")", "return", "[", "]", ";", "let", "childRegistry", "=", "getChildRegistry", "(", "element", ")", ";", "let", "children", "=", "[", "]", ";", "for", "(", "let", "name", "in", "childRegistry", ")", "{", "let", "child", "=", "[", "]", ".", "concat", "(", "childRegistry", "[", "name", "]", ")", ";", "child", ".", "forEach", "(", "(", "c", ")", "=>", "{", "if", "(", "isCustomElement", "(", "c", ")", ")", "children", ".", "push", "(", "c", ")", ";", "else", "children", "=", "children", ".", "concat", "(", "getDirectCustomChildren", "(", "c", ")", ")", ";", "}", ")", ";", "}", "return", "children", ";", "}" ]
Gets all the direct custom children of an element, flattened to a single array. @param {Node} element - The DOM element to get the direct custom children from. @param {boolean} [inclusive] - Specifies whether the element provided should be included as part of the search even if it is already a custom element. @return {Array} Array of direct custom children. @alias module:requiem~helpers.getInstanceNameFromElement
[ "Gets", "all", "the", "direct", "custom", "children", "of", "an", "element", "flattened", "to", "a", "single", "array", "." ]
c4182bfffc9841c6de5718f689ad3c2060511777
https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/helpers/getDirectCustomChildren.js#L22-L40
50,557
andrewscwei/requiem
src/dom/setStyle.js
setStyle
function setStyle(element, key, value) { assertType(element, Node, false, 'Invalid element specified'); if (typeof value === 'number') value = String(value); if (value === null || value === undefined) value = ''; element.style[key] = value; }
javascript
function setStyle(element, key, value) { assertType(element, Node, false, 'Invalid element specified'); if (typeof value === 'number') value = String(value); if (value === null || value === undefined) value = ''; element.style[key] = value; }
[ "function", "setStyle", "(", "element", ",", "key", ",", "value", ")", "{", "assertType", "(", "element", ",", "Node", ",", "false", ",", "'Invalid element specified'", ")", ";", "if", "(", "typeof", "value", "===", "'number'", ")", "value", "=", "String", "(", "value", ")", ";", "if", "(", "value", "===", "null", "||", "value", "===", "undefined", ")", "value", "=", "''", ";", "element", ".", "style", "[", "key", "]", "=", "value", ";", "}" ]
Sets an inline CSS rule of a Node. @param {Node} element - Target element. @param {string} key - Name of the CSS rule in camelCase. @param {*} value - Value of the style. If a number is provided, it will be automatically suffixed with 'px'. @see {@link http://www.w3schools.com/jsref/dom_obj_style.asp} @alias module:requiem~dom.setStyle
[ "Sets", "an", "inline", "CSS", "rule", "of", "a", "Node", "." ]
c4182bfffc9841c6de5718f689ad3c2060511777
https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/dom/setStyle.js#L19-L25
50,558
willdavis/discrete-time
lib/time_traveler.js
TimeTraveler
function TimeTraveler(settings) { // coerce the +starts_at+ value into a moment var starts_at_moment = moment(settings.starts_at); // initialize new TimeTraveler object attributes this.starts_at = starts_at_moment; this.steps = settings.steps; this.time_units = settings.time_units; this.time_scale = settings.time_scale || 1; this.current = { time: starts_at_moment, step: 0 }; }
javascript
function TimeTraveler(settings) { // coerce the +starts_at+ value into a moment var starts_at_moment = moment(settings.starts_at); // initialize new TimeTraveler object attributes this.starts_at = starts_at_moment; this.steps = settings.steps; this.time_units = settings.time_units; this.time_scale = settings.time_scale || 1; this.current = { time: starts_at_moment, step: 0 }; }
[ "function", "TimeTraveler", "(", "settings", ")", "{", "// coerce the +starts_at+ value into a moment", "var", "starts_at_moment", "=", "moment", "(", "settings", ".", "starts_at", ")", ";", "// initialize new TimeTraveler object attributes", "this", ".", "starts_at", "=", "starts_at_moment", ";", "this", ".", "steps", "=", "settings", ".", "steps", ";", "this", ".", "time_units", "=", "settings", ".", "time_units", ";", "this", ".", "time_scale", "=", "settings", ".", "time_scale", "||", "1", ";", "this", ".", "current", "=", "{", "time", ":", "starts_at_moment", ",", "step", ":", "0", "}", ";", "}" ]
Encapsulates helper functions and attributes to create and step through time series data. @example var settings = { starts_at: "2016-10-31", steps: 100, time_units: "days", time_scale: 10 }; var TimeTraveler = require('discrete-time').traveler; var traveler = new TimeTraveler(settings); // send the TimeTraveler on their journey! traveler.run(function(dt){ console.log('hello world'); }); // outputs "hello world" 100 times @constructor @param {Object} settings @param {(moment|string)} settings.starts_at - Sets the starting point for the time series @param {integer} settings.steps - The total number of intervals in the time series @param {integer} [settings.time_scale=1] - The number of time units per interval in the time series. @param {string} settings.time_units - The units of time to use for the time series. @property {moment} starts_at - Moment.js representation of the start time @property {integer} steps - Total number of intervals in the time series @property {string} time_units - The units of time for each time series interval @property {integer} time_scale - The number of time units per time series interval @property {object} current - Tracks the current state of the TimeTraveler object @property {moment} current.time - The current moment the TimeTraveler is at @property {integer} current.step - The current step the TimeTraveler is at
[ "Encapsulates", "helper", "functions", "and", "attributes", "to", "create", "and", "step", "through", "time", "series", "data", "." ]
d429adb698b00c2ddd6a945c6368d2267480b839
https://github.com/willdavis/discrete-time/blob/d429adb698b00c2ddd6a945c6368d2267480b839/lib/time_traveler.js#L29-L40
50,559
Fovea/jackbone
jackbone.js
function (t, timerName) { if (this.enabled) { var id = _.uniqueId('jt'); this._startDate[id] = t || (+new Date()); if (console.profile && timerName) { this._timerConsoleName[id] = timerName; console.profile(timerName); } return id; } }
javascript
function (t, timerName) { if (this.enabled) { var id = _.uniqueId('jt'); this._startDate[id] = t || (+new Date()); if (console.profile && timerName) { this._timerConsoleName[id] = timerName; console.profile(timerName); } return id; } }
[ "function", "(", "t", ",", "timerName", ")", "{", "if", "(", "this", ".", "enabled", ")", "{", "var", "id", "=", "_", ".", "uniqueId", "(", "'jt'", ")", ";", "this", ".", "_startDate", "[", "id", "]", "=", "t", "||", "(", "+", "new", "Date", "(", ")", ")", ";", "if", "(", "console", ".", "profile", "&&", "timerName", ")", "{", "this", ".", "_timerConsoleName", "[", "id", "]", "=", "timerName", ";", "console", ".", "profile", "(", "timerName", ")", ";", "}", "return", "id", ";", "}", "}" ]
Called at the beggining of an operation
[ "Called", "at", "the", "beggining", "of", "an", "operation" ]
94631030d20c6ff5c331cb824e135120f60c4ff2
https://github.com/Fovea/jackbone/blob/94631030d20c6ff5c331cb824e135120f60c4ff2/jackbone.js#L70-L80
50,560
Fovea/jackbone
jackbone.js
function (timerId, timerName, t) { if (this.enabled) { if (this._startDate[timerId]) { var duration = (t || (+new Date())) - this._startDate[timerId]; delete this._startDate[timerId]; if (console.profile) { if (this._timerConsoleName[timerId]) { console.profileEnd(this._timerConsoleName[timerId]); delete this._timerConsoleName[timerId]; } } // Already have stats for this method? Update them. if (typeof this.stats[timerName] !== 'undefined') { var stats = this.stats[timerName]; stats.calls += 1; stats.totalMs += duration; if (duration > stats.maxMs) { stats.maxMs = duration; } } else { // It's the first time we profile this method, create the // initial stats. this.stats[timerName] = { calls: 1, totalMs: duration, maxMs: duration }; } console.log('time(' + timerName + ') = ' + duration + 'ms'); } else { console.log('WARNING: invalid profiling timer'); } } }
javascript
function (timerId, timerName, t) { if (this.enabled) { if (this._startDate[timerId]) { var duration = (t || (+new Date())) - this._startDate[timerId]; delete this._startDate[timerId]; if (console.profile) { if (this._timerConsoleName[timerId]) { console.profileEnd(this._timerConsoleName[timerId]); delete this._timerConsoleName[timerId]; } } // Already have stats for this method? Update them. if (typeof this.stats[timerName] !== 'undefined') { var stats = this.stats[timerName]; stats.calls += 1; stats.totalMs += duration; if (duration > stats.maxMs) { stats.maxMs = duration; } } else { // It's the first time we profile this method, create the // initial stats. this.stats[timerName] = { calls: 1, totalMs: duration, maxMs: duration }; } console.log('time(' + timerName + ') = ' + duration + 'ms'); } else { console.log('WARNING: invalid profiling timer'); } } }
[ "function", "(", "timerId", ",", "timerName", ",", "t", ")", "{", "if", "(", "this", ".", "enabled", ")", "{", "if", "(", "this", ".", "_startDate", "[", "timerId", "]", ")", "{", "var", "duration", "=", "(", "t", "||", "(", "+", "new", "Date", "(", ")", ")", ")", "-", "this", ".", "_startDate", "[", "timerId", "]", ";", "delete", "this", ".", "_startDate", "[", "timerId", "]", ";", "if", "(", "console", ".", "profile", ")", "{", "if", "(", "this", ".", "_timerConsoleName", "[", "timerId", "]", ")", "{", "console", ".", "profileEnd", "(", "this", ".", "_timerConsoleName", "[", "timerId", "]", ")", ";", "delete", "this", ".", "_timerConsoleName", "[", "timerId", "]", ";", "}", "}", "// Already have stats for this method? Update them.", "if", "(", "typeof", "this", ".", "stats", "[", "timerName", "]", "!==", "'undefined'", ")", "{", "var", "stats", "=", "this", ".", "stats", "[", "timerName", "]", ";", "stats", ".", "calls", "+=", "1", ";", "stats", ".", "totalMs", "+=", "duration", ";", "if", "(", "duration", ">", "stats", ".", "maxMs", ")", "{", "stats", ".", "maxMs", "=", "duration", ";", "}", "}", "else", "{", "// It's the first time we profile this method, create the", "// initial stats.", "this", ".", "stats", "[", "timerName", "]", "=", "{", "calls", ":", "1", ",", "totalMs", ":", "duration", ",", "maxMs", ":", "duration", "}", ";", "}", "console", ".", "log", "(", "'time('", "+", "timerName", "+", "') = '", "+", "duration", "+", "'ms'", ")", ";", "}", "else", "{", "console", ".", "log", "(", "'WARNING: invalid profiling timer'", ")", ";", "}", "}", "}" ]
Called when an operation is done. Will update Jackbone.profiler.stats and show average duration on the console.
[ "Called", "when", "an", "operation", "is", "done", ".", "Will", "update", "Jackbone", ".", "profiler", ".", "stats", "and", "show", "average", "duration", "on", "the", "console", "." ]
94631030d20c6ff5c331cb824e135120f60c4ff2
https://github.com/Fovea/jackbone/blob/94631030d20c6ff5c331cb824e135120f60c4ff2/jackbone.js#L86-L124
50,561
Fovea/jackbone
jackbone.js
function (options) { this.options = options; // options.back can be used to change view 'Back' link. if (options.back) { this.back = options.back; } this.callSubviews('setOptions', options); this.applyOptions(options); }
javascript
function (options) { this.options = options; // options.back can be used to change view 'Back' link. if (options.back) { this.back = options.back; } this.callSubviews('setOptions', options); this.applyOptions(options); }
[ "function", "(", "options", ")", "{", "this", ".", "options", "=", "options", ";", "// options.back can be used to change view 'Back' link.", "if", "(", "options", ".", "back", ")", "{", "this", ".", "back", "=", "options", ".", "back", ";", "}", "this", ".", "callSubviews", "(", "'setOptions'", ",", "options", ")", ";", "this", ".", "applyOptions", "(", "options", ")", ";", "}" ]
Change options for this view and its subviews.
[ "Change", "options", "for", "this", "view", "and", "its", "subviews", "." ]
94631030d20c6ff5c331cb824e135120f60c4ff2
https://github.com/Fovea/jackbone/blob/94631030d20c6ff5c331cb824e135120f60c4ff2/jackbone.js#L155-L165
50,562
Fovea/jackbone
jackbone.js
function (method) { if (this.subviews.length !== 0) { var params = slice.call(arguments); params.shift(); _.each(this.subviews, function (s) { if (s[method]) { s[method].apply(s, params); } }); } }
javascript
function (method) { if (this.subviews.length !== 0) { var params = slice.call(arguments); params.shift(); _.each(this.subviews, function (s) { if (s[method]) { s[method].apply(s, params); } }); } }
[ "function", "(", "method", ")", "{", "if", "(", "this", ".", "subviews", ".", "length", "!==", "0", ")", "{", "var", "params", "=", "slice", ".", "call", "(", "arguments", ")", ";", "params", ".", "shift", "(", ")", ";", "_", ".", "each", "(", "this", ".", "subviews", ",", "function", "(", "s", ")", "{", "if", "(", "s", "[", "method", "]", ")", "{", "s", "[", "method", "]", ".", "apply", "(", "s", ",", "params", ")", ";", "}", "}", ")", ";", "}", "}" ]
Call the given method for all subviews. Passing extra arguments is posible, they will be passed to subviews too.
[ "Call", "the", "given", "method", "for", "all", "subviews", ".", "Passing", "extra", "arguments", "is", "posible", "they", "will", "be", "passed", "to", "subviews", "too", "." ]
94631030d20c6ff5c331cb824e135120f60c4ff2
https://github.com/Fovea/jackbone/blob/94631030d20c6ff5c331cb824e135120f60c4ff2/jackbone.js#L170-L180
50,563
Fovea/jackbone
jackbone.js
function (e) { e.preventDefault(); var $target = $(e.target); while ($target) { var route = $target.attr('route'); if (route) { // A route has been defined, follow the link using // Jackbone's default router. if (route === 'back') { Jackbone.router.goto(this.back.hash); } else { Jackbone.router.goto(route); } return false; } var parent = $target.parent(); if (parent.length > 0) { $target = parent; } else { $target = false; } } return true; }
javascript
function (e) { e.preventDefault(); var $target = $(e.target); while ($target) { var route = $target.attr('route'); if (route) { // A route has been defined, follow the link using // Jackbone's default router. if (route === 'back') { Jackbone.router.goto(this.back.hash); } else { Jackbone.router.goto(route); } return false; } var parent = $target.parent(); if (parent.length > 0) { $target = parent; } else { $target = false; } } return true; }
[ "function", "(", "e", ")", "{", "e", ".", "preventDefault", "(", ")", ";", "var", "$target", "=", "$", "(", "e", ".", "target", ")", ";", "while", "(", "$target", ")", "{", "var", "route", "=", "$target", ".", "attr", "(", "'route'", ")", ";", "if", "(", "route", ")", "{", "// A route has been defined, follow the link using", "// Jackbone's default router.", "if", "(", "route", "===", "'back'", ")", "{", "Jackbone", ".", "router", ".", "goto", "(", "this", ".", "back", ".", "hash", ")", ";", "}", "else", "{", "Jackbone", ".", "router", ".", "goto", "(", "route", ")", ";", "}", "return", "false", ";", "}", "var", "parent", "=", "$target", ".", "parent", "(", ")", ";", "if", "(", "parent", ".", "length", ">", "0", ")", "{", "$target", "=", "parent", ";", "}", "else", "{", "$target", "=", "false", ";", "}", "}", "return", "true", ";", "}" ]
This is the default event handler
[ "This", "is", "the", "default", "event", "handler" ]
94631030d20c6ff5c331cb824e135120f60c4ff2
https://github.com/Fovea/jackbone/blob/94631030d20c6ff5c331cb824e135120f60c4ff2/jackbone.js#L259-L282
50,564
Fovea/jackbone
jackbone.js
function () { // Note: Controllers are responsible of setting needRedraw. if (this.needRedraw) { // Create root element for the page var page = document.createElement('div'); page.style.display = 'block'; page.setAttribute('data-role', 'page'); // Create, render and add the header if (this.header) { var header = document.createElement('div'); header.setAttribute('data-role', 'header'); this.header.setElement(header); this.header.render(); page.appendChild(header); } // Create the content element var content = document.createElement('div'); content.setAttribute('data-role', 'content'); content.className = 'content'; // Render the content this.content.setElement(content); this.content.render(); // Make sure content fills the screen to the top/bottom // when no header/footer are provided. if (!this.header) { content.style.top = '0'; } if (!this.footer) { content.style.bottom = '0'; } page.appendChild(content); // Create, render and add the footer if (this.footer) { var footer = document.createElement('div'); footer.setAttribute('data-role', 'footer'); this.footer.setElement(footer); this.footer.render(); page.appendChild(footer); } // Add the page into the DOM. if (this.el.firstChild) { this.el.replaceChild(page, this.el.firstChild); } else { this.el.appendChild(page); } this.needRedraw = false; } }
javascript
function () { // Note: Controllers are responsible of setting needRedraw. if (this.needRedraw) { // Create root element for the page var page = document.createElement('div'); page.style.display = 'block'; page.setAttribute('data-role', 'page'); // Create, render and add the header if (this.header) { var header = document.createElement('div'); header.setAttribute('data-role', 'header'); this.header.setElement(header); this.header.render(); page.appendChild(header); } // Create the content element var content = document.createElement('div'); content.setAttribute('data-role', 'content'); content.className = 'content'; // Render the content this.content.setElement(content); this.content.render(); // Make sure content fills the screen to the top/bottom // when no header/footer are provided. if (!this.header) { content.style.top = '0'; } if (!this.footer) { content.style.bottom = '0'; } page.appendChild(content); // Create, render and add the footer if (this.footer) { var footer = document.createElement('div'); footer.setAttribute('data-role', 'footer'); this.footer.setElement(footer); this.footer.render(); page.appendChild(footer); } // Add the page into the DOM. if (this.el.firstChild) { this.el.replaceChild(page, this.el.firstChild); } else { this.el.appendChild(page); } this.needRedraw = false; } }
[ "function", "(", ")", "{", "// Note: Controllers are responsible of setting needRedraw.", "if", "(", "this", ".", "needRedraw", ")", "{", "// Create root element for the page", "var", "page", "=", "document", ".", "createElement", "(", "'div'", ")", ";", "page", ".", "style", ".", "display", "=", "'block'", ";", "page", ".", "setAttribute", "(", "'data-role'", ",", "'page'", ")", ";", "// Create, render and add the header", "if", "(", "this", ".", "header", ")", "{", "var", "header", "=", "document", ".", "createElement", "(", "'div'", ")", ";", "header", ".", "setAttribute", "(", "'data-role'", ",", "'header'", ")", ";", "this", ".", "header", ".", "setElement", "(", "header", ")", ";", "this", ".", "header", ".", "render", "(", ")", ";", "page", ".", "appendChild", "(", "header", ")", ";", "}", "// Create the content element", "var", "content", "=", "document", ".", "createElement", "(", "'div'", ")", ";", "content", ".", "setAttribute", "(", "'data-role'", ",", "'content'", ")", ";", "content", ".", "className", "=", "'content'", ";", "// Render the content", "this", ".", "content", ".", "setElement", "(", "content", ")", ";", "this", ".", "content", ".", "render", "(", ")", ";", "// Make sure content fills the screen to the top/bottom", "// when no header/footer are provided.", "if", "(", "!", "this", ".", "header", ")", "{", "content", ".", "style", ".", "top", "=", "'0'", ";", "}", "if", "(", "!", "this", ".", "footer", ")", "{", "content", ".", "style", ".", "bottom", "=", "'0'", ";", "}", "page", ".", "appendChild", "(", "content", ")", ";", "// Create, render and add the footer", "if", "(", "this", ".", "footer", ")", "{", "var", "footer", "=", "document", ".", "createElement", "(", "'div'", ")", ";", "footer", ".", "setAttribute", "(", "'data-role'", ",", "'footer'", ")", ";", "this", ".", "footer", ".", "setElement", "(", "footer", ")", ";", "this", ".", "footer", ".", "render", "(", ")", ";", "page", ".", "appendChild", "(", "footer", ")", ";", "}", "// Add the page into the DOM.", "if", "(", "this", ".", "el", ".", "firstChild", ")", "{", "this", ".", "el", ".", "replaceChild", "(", "page", ",", "this", ".", "el", ".", "firstChild", ")", ";", "}", "else", "{", "this", ".", "el", ".", "appendChild", "(", "page", ")", ";", "}", "this", ".", "needRedraw", "=", "false", ";", "}", "}" ]
Default render. Sets header, content and footer.
[ "Default", "render", ".", "Sets", "header", "content", "and", "footer", "." ]
94631030d20c6ff5c331cb824e135120f60c4ff2
https://github.com/Fovea/jackbone/blob/94631030d20c6ff5c331cb824e135120f60c4ff2/jackbone.js#L354-L412
50,565
Fovea/jackbone
jackbone.js
function () { var that = this; var now = +new Date(); var toRemove = _(this.controllers).filter(function (c) { var age = (now - c.lastView); return (age > 60000); // Keep in cache for 1 minute. }); _(toRemove).each(function (c) { if (c.controller !== that.currentController) { delete that.controllers[c.pageUID]; c.controller.destroy(); if (c.controller._rootView) { c.controller._rootView.clean(); c.controller._rootView.remove(); Jackbone.trigger("destroyview", c.controller._rootView); } } }); }
javascript
function () { var that = this; var now = +new Date(); var toRemove = _(this.controllers).filter(function (c) { var age = (now - c.lastView); return (age > 60000); // Keep in cache for 1 minute. }); _(toRemove).each(function (c) { if (c.controller !== that.currentController) { delete that.controllers[c.pageUID]; c.controller.destroy(); if (c.controller._rootView) { c.controller._rootView.clean(); c.controller._rootView.remove(); Jackbone.trigger("destroyview", c.controller._rootView); } } }); }
[ "function", "(", ")", "{", "var", "that", "=", "this", ";", "var", "now", "=", "+", "new", "Date", "(", ")", ";", "var", "toRemove", "=", "_", "(", "this", ".", "controllers", ")", ".", "filter", "(", "function", "(", "c", ")", "{", "var", "age", "=", "(", "now", "-", "c", ".", "lastView", ")", ";", "return", "(", "age", ">", "60000", ")", ";", "// Keep in cache for 1 minute.", "}", ")", ";", "_", "(", "toRemove", ")", ".", "each", "(", "function", "(", "c", ")", "{", "if", "(", "c", ".", "controller", "!==", "that", ".", "currentController", ")", "{", "delete", "that", ".", "controllers", "[", "c", ".", "pageUID", "]", ";", "c", ".", "controller", ".", "destroy", "(", ")", ";", "if", "(", "c", ".", "controller", ".", "_rootView", ")", "{", "c", ".", "controller", ".", "_rootView", ".", "clean", "(", ")", ";", "c", ".", "controller", ".", "_rootView", ".", "remove", "(", ")", ";", "Jackbone", ".", "trigger", "(", "\"destroyview\"", ",", "c", ".", "controller", ".", "_rootView", ")", ";", "}", "}", "}", ")", ";", "}" ]
Garbage collector, removes unused views and controllers.
[ "Garbage", "collector", "removes", "unused", "views", "and", "controllers", "." ]
94631030d20c6ff5c331cb824e135120f60c4ff2
https://github.com/Fovea/jackbone/blob/94631030d20c6ff5c331cb824e135120f60c4ff2/jackbone.js#L683-L703
50,566
Fovea/jackbone
jackbone.js
function () { var content = ctrl.view; var header = noHeader ? null : new Jackbone.DefaultHeader(); var footer = noFooter ? null : new Jackbone.DefaultFooter(); var view = new JQMView(header, content, footer); // Cache the controller that.controllers[pageUID] = { pageUID: pageUID, controller: ctrl }; ctrl._rootView = view; view.controller = ctrl; doneCreate(); }
javascript
function () { var content = ctrl.view; var header = noHeader ? null : new Jackbone.DefaultHeader(); var footer = noFooter ? null : new Jackbone.DefaultFooter(); var view = new JQMView(header, content, footer); // Cache the controller that.controllers[pageUID] = { pageUID: pageUID, controller: ctrl }; ctrl._rootView = view; view.controller = ctrl; doneCreate(); }
[ "function", "(", ")", "{", "var", "content", "=", "ctrl", ".", "view", ";", "var", "header", "=", "noHeader", "?", "null", ":", "new", "Jackbone", ".", "DefaultHeader", "(", ")", ";", "var", "footer", "=", "noFooter", "?", "null", ":", "new", "Jackbone", ".", "DefaultFooter", "(", ")", ";", "var", "view", "=", "new", "JQMView", "(", "header", ",", "content", ",", "footer", ")", ";", "// Cache the controller", "that", ".", "controllers", "[", "pageUID", "]", "=", "{", "pageUID", ":", "pageUID", ",", "controller", ":", "ctrl", "}", ";", "ctrl", ".", "_rootView", "=", "view", ";", "view", ".", "controller", "=", "ctrl", ";", "doneCreate", "(", ")", ";", "}" ]
Create views for a controller
[ "Create", "views", "for", "a", "controller" ]
94631030d20c6ff5c331cb824e135120f60c4ff2
https://github.com/Fovea/jackbone/blob/94631030d20c6ff5c331cb824e135120f60c4ff2/jackbone.js#L888-L900
50,567
Fovea/jackbone
jackbone.js
function (separator, page, args) { // By default, we return page name without arguments. var ret = page; if (typeof args !== 'undefined') { if (args && args.length) { // Some arguments have been provided, add them. if (args.length !== 0) { ret = page + separator + args.join(separator); } } else { // Argument isn't an array, add it. ret = page + separator + args; } } return ret; }
javascript
function (separator, page, args) { // By default, we return page name without arguments. var ret = page; if (typeof args !== 'undefined') { if (args && args.length) { // Some arguments have been provided, add them. if (args.length !== 0) { ret = page + separator + args.join(separator); } } else { // Argument isn't an array, add it. ret = page + separator + args; } } return ret; }
[ "function", "(", "separator", ",", "page", ",", "args", ")", "{", "// By default, we return page name without arguments.", "var", "ret", "=", "page", ";", "if", "(", "typeof", "args", "!==", "'undefined'", ")", "{", "if", "(", "args", "&&", "args", ".", "length", ")", "{", "// Some arguments have been provided, add them.", "if", "(", "args", ".", "length", "!==", "0", ")", "{", "ret", "=", "page", "+", "separator", "+", "args", ".", "join", "(", "separator", ")", ";", "}", "}", "else", "{", "// Argument isn't an array, add it.", "ret", "=", "page", "+", "separator", "+", "args", ";", "}", "}", "return", "ret", ";", "}" ]
Used to generate page hash tag or HTML attribute. by getPageName and getPageHash. Does it by joining page and arguments using the given separator.
[ "Used", "to", "generate", "page", "hash", "tag", "or", "HTML", "attribute", ".", "by", "getPageName", "and", "getPageHash", ".", "Does", "it", "by", "joining", "page", "and", "arguments", "using", "the", "given", "separator", "." ]
94631030d20c6ff5c331cb824e135120f60c4ff2
https://github.com/Fovea/jackbone/blob/94631030d20c6ff5c331cb824e135120f60c4ff2/jackbone.js#L947-L963
50,568
Fovea/jackbone
jackbone.js
function (pageName, page, role) { // Extends Views // Create JQuery Mobile Page var pageid = 'pagename-' + pageName.toLowerCase(); var isExistingPage = $('#' + pageid); // For already existing pages, only delegate events so they can // handle onPageBeforeShow and onPageShow. if (isExistingPage.length === 1) { // Sometimes, controller may have been destroyed but the // HTML stayed in the DOM (in case of an exception). // We can detect that using needRedraw, which indicate // that we have to do a full repaint. if (page.needRedraw) { page.render(); } else { page.refresh(); page.delegateEvents(); } } else { // Create the page, store its page name in an attribute // so it can be retrieved later. page.el.id = 'pagename-' + pageName.toLowerCase(); page.el.className = 'page-container'; // Render it and add it in the DOM. page.render(); if (Jackbone.manualMode) { // Create the new page page._onPageBeforeCreate(); Jackbone.trigger('createview', page); page._onPageManualCreate(); page._onPageCreate(); } // Append to the DOM. document.body.appendChild(page.el); } if (!Jackbone.manualMode) { // Select the transition to apply. var t = this.selectTransition(pageName, role); // Perform transition using JQuery Mobile $.mobile.changePage(page.$el, { changeHash: false, transition: t.transition, reverse: t.reverse, role: role, pageContainer: page.$el }); } else { var currentActivePage = Jackbone.activePage; try { // Hide previous page, show next if (Jackbone.activePage) { Jackbone.activePage._onPageBeforeHide(); } page._onPageBeforeShow(); page.$el.show(); if (Jackbone.activePage) { Jackbone.activePage.$el.hide(); Jackbone.activePage._onPageHide(); } page._onPageShow(); // Update 'activePage' Jackbone.activePage = page; $.mobile.activePage = page.$el; } catch (error) { page.$el.hide(); if (currentActivePage) { currentActivePage.$el.show(); Jackbone.activePage = currentActivePage; $.mobile.activePage = currentActivePage.$el; } throw new Error('Failed to changePage: ' + error); } } // Current hash is stored so a subsequent openView can know // which page it comes from. this.currentHash = Jackbone.history.getFragment(); }
javascript
function (pageName, page, role) { // Extends Views // Create JQuery Mobile Page var pageid = 'pagename-' + pageName.toLowerCase(); var isExistingPage = $('#' + pageid); // For already existing pages, only delegate events so they can // handle onPageBeforeShow and onPageShow. if (isExistingPage.length === 1) { // Sometimes, controller may have been destroyed but the // HTML stayed in the DOM (in case of an exception). // We can detect that using needRedraw, which indicate // that we have to do a full repaint. if (page.needRedraw) { page.render(); } else { page.refresh(); page.delegateEvents(); } } else { // Create the page, store its page name in an attribute // so it can be retrieved later. page.el.id = 'pagename-' + pageName.toLowerCase(); page.el.className = 'page-container'; // Render it and add it in the DOM. page.render(); if (Jackbone.manualMode) { // Create the new page page._onPageBeforeCreate(); Jackbone.trigger('createview', page); page._onPageManualCreate(); page._onPageCreate(); } // Append to the DOM. document.body.appendChild(page.el); } if (!Jackbone.manualMode) { // Select the transition to apply. var t = this.selectTransition(pageName, role); // Perform transition using JQuery Mobile $.mobile.changePage(page.$el, { changeHash: false, transition: t.transition, reverse: t.reverse, role: role, pageContainer: page.$el }); } else { var currentActivePage = Jackbone.activePage; try { // Hide previous page, show next if (Jackbone.activePage) { Jackbone.activePage._onPageBeforeHide(); } page._onPageBeforeShow(); page.$el.show(); if (Jackbone.activePage) { Jackbone.activePage.$el.hide(); Jackbone.activePage._onPageHide(); } page._onPageShow(); // Update 'activePage' Jackbone.activePage = page; $.mobile.activePage = page.$el; } catch (error) { page.$el.hide(); if (currentActivePage) { currentActivePage.$el.show(); Jackbone.activePage = currentActivePage; $.mobile.activePage = currentActivePage.$el; } throw new Error('Failed to changePage: ' + error); } } // Current hash is stored so a subsequent openView can know // which page it comes from. this.currentHash = Jackbone.history.getFragment(); }
[ "function", "(", "pageName", ",", "page", ",", "role", ")", "{", "// Extends Views", "// Create JQuery Mobile Page", "var", "pageid", "=", "'pagename-'", "+", "pageName", ".", "toLowerCase", "(", ")", ";", "var", "isExistingPage", "=", "$", "(", "'#'", "+", "pageid", ")", ";", "// For already existing pages, only delegate events so they can", "// handle onPageBeforeShow and onPageShow.", "if", "(", "isExistingPage", ".", "length", "===", "1", ")", "{", "// Sometimes, controller may have been destroyed but the", "// HTML stayed in the DOM (in case of an exception).", "// We can detect that using needRedraw, which indicate", "// that we have to do a full repaint.", "if", "(", "page", ".", "needRedraw", ")", "{", "page", ".", "render", "(", ")", ";", "}", "else", "{", "page", ".", "refresh", "(", ")", ";", "page", ".", "delegateEvents", "(", ")", ";", "}", "}", "else", "{", "// Create the page, store its page name in an attribute", "// so it can be retrieved later.", "page", ".", "el", ".", "id", "=", "'pagename-'", "+", "pageName", ".", "toLowerCase", "(", ")", ";", "page", ".", "el", ".", "className", "=", "'page-container'", ";", "// Render it and add it in the DOM.", "page", ".", "render", "(", ")", ";", "if", "(", "Jackbone", ".", "manualMode", ")", "{", "// Create the new page", "page", ".", "_onPageBeforeCreate", "(", ")", ";", "Jackbone", ".", "trigger", "(", "'createview'", ",", "page", ")", ";", "page", ".", "_onPageManualCreate", "(", ")", ";", "page", ".", "_onPageCreate", "(", ")", ";", "}", "// Append to the DOM.", "document", ".", "body", ".", "appendChild", "(", "page", ".", "el", ")", ";", "}", "if", "(", "!", "Jackbone", ".", "manualMode", ")", "{", "// Select the transition to apply.", "var", "t", "=", "this", ".", "selectTransition", "(", "pageName", ",", "role", ")", ";", "// Perform transition using JQuery Mobile", "$", ".", "mobile", ".", "changePage", "(", "page", ".", "$el", ",", "{", "changeHash", ":", "false", ",", "transition", ":", "t", ".", "transition", ",", "reverse", ":", "t", ".", "reverse", ",", "role", ":", "role", ",", "pageContainer", ":", "page", ".", "$el", "}", ")", ";", "}", "else", "{", "var", "currentActivePage", "=", "Jackbone", ".", "activePage", ";", "try", "{", "// Hide previous page, show next", "if", "(", "Jackbone", ".", "activePage", ")", "{", "Jackbone", ".", "activePage", ".", "_onPageBeforeHide", "(", ")", ";", "}", "page", ".", "_onPageBeforeShow", "(", ")", ";", "page", ".", "$el", ".", "show", "(", ")", ";", "if", "(", "Jackbone", ".", "activePage", ")", "{", "Jackbone", ".", "activePage", ".", "$el", ".", "hide", "(", ")", ";", "Jackbone", ".", "activePage", ".", "_onPageHide", "(", ")", ";", "}", "page", ".", "_onPageShow", "(", ")", ";", "// Update 'activePage'", "Jackbone", ".", "activePage", "=", "page", ";", "$", ".", "mobile", ".", "activePage", "=", "page", ".", "$el", ";", "}", "catch", "(", "error", ")", "{", "page", ".", "$el", ".", "hide", "(", ")", ";", "if", "(", "currentActivePage", ")", "{", "currentActivePage", ".", "$el", ".", "show", "(", ")", ";", "Jackbone", ".", "activePage", "=", "currentActivePage", ";", "$", ".", "mobile", ".", "activePage", "=", "currentActivePage", ".", "$el", ";", "}", "throw", "new", "Error", "(", "'Failed to changePage: '", "+", "error", ")", ";", "}", "}", "// Current hash is stored so a subsequent openView can know", "// which page it comes from.", "this", ".", "currentHash", "=", "Jackbone", ".", "history", ".", "getFragment", "(", ")", ";", "}" ]
Change to the given page.
[ "Change", "to", "the", "given", "page", "." ]
94631030d20c6ff5c331cb824e135120f60c4ff2
https://github.com/Fovea/jackbone/blob/94631030d20c6ff5c331cb824e135120f60c4ff2/jackbone.js#L1061-L1151
50,569
Fovea/jackbone
jackbone.js
function (pageName, role) { var lastPageName = this.currentPageName || ''; var lastPageRole = this.currentPageRole || ''; this.currentPageName = pageName; this.currentPageRole = role; // Known transition, return it. if (_(this.transitions).has(lastPageName + '-->' + pageName)) { return this.transitions[lastPageName + '-->' + pageName]; } // Use JQueryMobile default page transition. var transition = $.mobile.defaultPageTransition; // Except for dialogs. if ((role === 'dialog') || (lastPageRole === 'dialog')) { // Use JQueryMobile default dialog transition. transition = $.mobile.defaultDialogTransition; } // Save the transition this.transitions[lastPageName + '-->' + pageName] = { transition: transition, reverse: false }; this.transitions[pageName + '-->' + lastPageName] = { transition: transition, reverse: true }; // And return it. return { transition: transition, reverse: false }; }
javascript
function (pageName, role) { var lastPageName = this.currentPageName || ''; var lastPageRole = this.currentPageRole || ''; this.currentPageName = pageName; this.currentPageRole = role; // Known transition, return it. if (_(this.transitions).has(lastPageName + '-->' + pageName)) { return this.transitions[lastPageName + '-->' + pageName]; } // Use JQueryMobile default page transition. var transition = $.mobile.defaultPageTransition; // Except for dialogs. if ((role === 'dialog') || (lastPageRole === 'dialog')) { // Use JQueryMobile default dialog transition. transition = $.mobile.defaultDialogTransition; } // Save the transition this.transitions[lastPageName + '-->' + pageName] = { transition: transition, reverse: false }; this.transitions[pageName + '-->' + lastPageName] = { transition: transition, reverse: true }; // And return it. return { transition: transition, reverse: false }; }
[ "function", "(", "pageName", ",", "role", ")", "{", "var", "lastPageName", "=", "this", ".", "currentPageName", "||", "''", ";", "var", "lastPageRole", "=", "this", ".", "currentPageRole", "||", "''", ";", "this", ".", "currentPageName", "=", "pageName", ";", "this", ".", "currentPageRole", "=", "role", ";", "// Known transition, return it.", "if", "(", "_", "(", "this", ".", "transitions", ")", ".", "has", "(", "lastPageName", "+", "'-->'", "+", "pageName", ")", ")", "{", "return", "this", ".", "transitions", "[", "lastPageName", "+", "'-->'", "+", "pageName", "]", ";", "}", "// Use JQueryMobile default page transition.", "var", "transition", "=", "$", ".", "mobile", ".", "defaultPageTransition", ";", "// Except for dialogs.", "if", "(", "(", "role", "===", "'dialog'", ")", "||", "(", "lastPageRole", "===", "'dialog'", ")", ")", "{", "// Use JQueryMobile default dialog transition.", "transition", "=", "$", ".", "mobile", ".", "defaultDialogTransition", ";", "}", "// Save the transition", "this", ".", "transitions", "[", "lastPageName", "+", "'-->'", "+", "pageName", "]", "=", "{", "transition", ":", "transition", ",", "reverse", ":", "false", "}", ";", "this", ".", "transitions", "[", "pageName", "+", "'-->'", "+", "lastPageName", "]", "=", "{", "transition", ":", "transition", ",", "reverse", ":", "true", "}", ";", "// And return it.", "return", "{", "transition", ":", "transition", ",", "reverse", ":", "false", "}", ";", "}" ]
Return parameters of the transition to use to switch to pageName It's context dependant, meaning this method remembers the currently viewed view and determine the transition accordingly.
[ "Return", "parameters", "of", "the", "transition", "to", "use", "to", "switch", "to", "pageName", "It", "s", "context", "dependant", "meaning", "this", "method", "remembers", "the", "currently", "viewed", "view", "and", "determine", "the", "transition", "accordingly", "." ]
94631030d20c6ff5c331cb824e135120f60c4ff2
https://github.com/Fovea/jackbone/blob/94631030d20c6ff5c331cb824e135120f60c4ff2/jackbone.js#L1162-L1194
50,570
imiric/tiq-db
index.js
TiqDB
function TiqDB(config) { var defaultConfig = { client: 'sqlite3', connection: { host: 'localhost', user: null, password: null, database: 'tiq', filename: path.join(process.env.XDG_DATA_HOME || path.join(process.env.HOME, '.local', 'share'), 'tiq', 'store.db') } }, config = _.merge(defaultConfig, config || {}); // Setup the DB connection Knex.knex = Knex.initialize(config); this.config = config; return this; }
javascript
function TiqDB(config) { var defaultConfig = { client: 'sqlite3', connection: { host: 'localhost', user: null, password: null, database: 'tiq', filename: path.join(process.env.XDG_DATA_HOME || path.join(process.env.HOME, '.local', 'share'), 'tiq', 'store.db') } }, config = _.merge(defaultConfig, config || {}); // Setup the DB connection Knex.knex = Knex.initialize(config); this.config = config; return this; }
[ "function", "TiqDB", "(", "config", ")", "{", "var", "defaultConfig", "=", "{", "client", ":", "'sqlite3'", ",", "connection", ":", "{", "host", ":", "'localhost'", ",", "user", ":", "null", ",", "password", ":", "null", ",", "database", ":", "'tiq'", ",", "filename", ":", "path", ".", "join", "(", "process", ".", "env", ".", "XDG_DATA_HOME", "||", "path", ".", "join", "(", "process", ".", "env", ".", "HOME", ",", "'.local'", ",", "'share'", ")", ",", "'tiq'", ",", "'store.db'", ")", "}", "}", ",", "config", "=", "_", ".", "merge", "(", "defaultConfig", ",", "config", "||", "{", "}", ")", ";", "// Setup the DB connection", "Knex", ".", "knex", "=", "Knex", ".", "initialize", "(", "config", ")", ";", "this", ".", "config", "=", "config", ";", "return", "this", ";", "}" ]
Main module object. @param {Object} config @param {string} [config.client="sqlite3"] - The client for the chosen RDBMS. This can be one of "sqlite3", "pg" or "mysql". @param {Object} [config.connection={}] @param {string} [config.connection.host="localhost"] @param {string} [config.connection.user=null] @param {string} [config.connection.password=null] @param {string} [config.connection.database="tiq"] @param {string} [config.connection.filename="$XDG_DATA_HOME/tiq/store.db"] - The storage file to use. Only applicable to SQLite. @constructor @private
[ "Main", "module", "object", "." ]
d40afa6523ca150e9b52be7ab6921e03257feb61
https://github.com/imiric/tiq-db/blob/d40afa6523ca150e9b52be7ab6921e03257feb61/index.js#L39-L57
50,571
wunderbyte/grunt-spiritual-dox
src/js/[email protected]/spirits/main/dox.PrismSpirit.js
function () { this._super.onenter (); if ( this.box.pageY < window.innerHeight ) { this._hilite (); } else { this.tick.time ( function () { this._hilite (); }, 200 ); } }
javascript
function () { this._super.onenter (); if ( this.box.pageY < window.innerHeight ) { this._hilite (); } else { this.tick.time ( function () { this._hilite (); }, 200 ); } }
[ "function", "(", ")", "{", "this", ".", "_super", ".", "onenter", "(", ")", ";", "if", "(", "this", ".", "box", ".", "pageY", "<", "window", ".", "innerHeight", ")", "{", "this", ".", "_hilite", "(", ")", ";", "}", "else", "{", "this", ".", "tick", ".", "time", "(", "function", "(", ")", "{", "this", ".", "_hilite", "(", ")", ";", "}", ",", "200", ")", ";", "}", "}" ]
Visible code get's highlighted now while unseen code runs on a timeout. The internal async thing in Prism doesn't seem to work as advertised...
[ "Visible", "code", "get", "s", "highlighted", "now", "while", "unseen", "code", "runs", "on", "a", "timeout", ".", "The", "internal", "async", "thing", "in", "Prism", "doesn", "t", "seem", "to", "work", "as", "advertised", "..." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/[email protected]/spirits/main/dox.PrismSpirit.js#L12-L21
50,572
wunderbyte/grunt-spiritual-dox
src/js/[email protected]/spirits/main/dox.PrismSpirit.js
function ( code ) { var text = code.firstChild; if ( text ) { text.data = text.data.substring ( 1 ); // we inserted a # } }
javascript
function ( code ) { var text = code.firstChild; if ( text ) { text.data = text.data.substring ( 1 ); // we inserted a # } }
[ "function", "(", "code", ")", "{", "var", "text", "=", "code", ".", "firstChild", ";", "if", "(", "text", ")", "{", "text", ".", "data", "=", "text", ".", "data", ".", "substring", "(", "1", ")", ";", "// we inserted a #", "}", "}" ]
Prism appears to have a regexp dysfunction on leading whitespace in the first line of code. @param {HTMLCodeElement} code
[ "Prism", "appears", "to", "have", "a", "regexp", "dysfunction", "on", "leading", "whitespace", "in", "the", "first", "line", "of", "code", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/[email protected]/spirits/main/dox.PrismSpirit.js#L54-L59
50,573
novemberborn/legendary
lib/private/trampoline.js
trampoline
function trampoline(queue) { index = [0]; stack = [queue]; var queueIndex, queueLength; var stackIndex = 1; // 1-indexed! var stackLength = stack.length; var topOfStack = true; while (stackIndex) { queue = stack[stackIndex - 1]; queueIndex = index[stackIndex - 1]; if (queueIndex === -1) { queueIndex = index[stackIndex - 1] = 0; } queueLength = queue.length; while (queueIndex < queueLength && topOfStack) { queue[queueIndex].resolve( queue[queueIndex + 1], queue[queueIndex + 2], queue[queueIndex + 3]); queueIndex += 4; stackLength = stack.length; topOfStack = stackLength === stackIndex; } if (!topOfStack) { index[stackIndex - 1] = queueIndex; stackIndex = stackLength; topOfStack = true; } else { index.pop(); stack.pop(); stackIndex--; } } stack = index = null; }
javascript
function trampoline(queue) { index = [0]; stack = [queue]; var queueIndex, queueLength; var stackIndex = 1; // 1-indexed! var stackLength = stack.length; var topOfStack = true; while (stackIndex) { queue = stack[stackIndex - 1]; queueIndex = index[stackIndex - 1]; if (queueIndex === -1) { queueIndex = index[stackIndex - 1] = 0; } queueLength = queue.length; while (queueIndex < queueLength && topOfStack) { queue[queueIndex].resolve( queue[queueIndex + 1], queue[queueIndex + 2], queue[queueIndex + 3]); queueIndex += 4; stackLength = stack.length; topOfStack = stackLength === stackIndex; } if (!topOfStack) { index[stackIndex - 1] = queueIndex; stackIndex = stackLength; topOfStack = true; } else { index.pop(); stack.pop(); stackIndex--; } } stack = index = null; }
[ "function", "trampoline", "(", "queue", ")", "{", "index", "=", "[", "0", "]", ";", "stack", "=", "[", "queue", "]", ";", "var", "queueIndex", ",", "queueLength", ";", "var", "stackIndex", "=", "1", ";", "// 1-indexed!", "var", "stackLength", "=", "stack", ".", "length", ";", "var", "topOfStack", "=", "true", ";", "while", "(", "stackIndex", ")", "{", "queue", "=", "stack", "[", "stackIndex", "-", "1", "]", ";", "queueIndex", "=", "index", "[", "stackIndex", "-", "1", "]", ";", "if", "(", "queueIndex", "===", "-", "1", ")", "{", "queueIndex", "=", "index", "[", "stackIndex", "-", "1", "]", "=", "0", ";", "}", "queueLength", "=", "queue", ".", "length", ";", "while", "(", "queueIndex", "<", "queueLength", "&&", "topOfStack", ")", "{", "queue", "[", "queueIndex", "]", ".", "resolve", "(", "queue", "[", "queueIndex", "+", "1", "]", ",", "queue", "[", "queueIndex", "+", "2", "]", ",", "queue", "[", "queueIndex", "+", "3", "]", ")", ";", "queueIndex", "+=", "4", ";", "stackLength", "=", "stack", ".", "length", ";", "topOfStack", "=", "stackLength", "===", "stackIndex", ";", "}", "if", "(", "!", "topOfStack", ")", "{", "index", "[", "stackIndex", "-", "1", "]", "=", "queueIndex", ";", "stackIndex", "=", "stackLength", ";", "topOfStack", "=", "true", ";", "}", "else", "{", "index", ".", "pop", "(", ")", ";", "stack", ".", "pop", "(", ")", ";", "stackIndex", "--", ";", "}", "}", "stack", "=", "index", "=", "null", ";", "}" ]
Starts a trampoline to process the queue.
[ "Starts", "a", "trampoline", "to", "process", "the", "queue", "." ]
8420f2dd20e2e3eaced51385fb6b0dc65b81a9fc
https://github.com/novemberborn/legendary/blob/8420f2dd20e2e3eaced51385fb6b0dc65b81a9fc/lib/private/trampoline.js#L8-L47
50,574
novemberborn/legendary
lib/private/trampoline.js
enterTurn
function enterTurn() { var snapshot; while ((snapshot = queue).length) { queue = []; trampoline(snapshot); } queue = null; }
javascript
function enterTurn() { var snapshot; while ((snapshot = queue).length) { queue = []; trampoline(snapshot); } queue = null; }
[ "function", "enterTurn", "(", ")", "{", "var", "snapshot", ";", "while", "(", "(", "snapshot", "=", "queue", ")", ".", "length", ")", "{", "queue", "=", "[", "]", ";", "trampoline", "(", "snapshot", ")", ";", "}", "queue", "=", "null", ";", "}" ]
Once we have entered a turn we can keep executing propagations without waiting for another tick. Start a trampoline to process the current queue.
[ "Once", "we", "have", "entered", "a", "turn", "we", "can", "keep", "executing", "propagations", "without", "waiting", "for", "another", "tick", ".", "Start", "a", "trampoline", "to", "process", "the", "current", "queue", "." ]
8420f2dd20e2e3eaced51385fb6b0dc65b81a9fc
https://github.com/novemberborn/legendary/blob/8420f2dd20e2e3eaced51385fb6b0dc65b81a9fc/lib/private/trampoline.js#L51-L58
50,575
staticbuild/staticbuild
lib/nunjucks/functions.js
createForBuild
function createForBuild(build) { var exports = {}; function bundles(name, sourceType) { /*jshint validthis: true */ var ml = build.bundles(name, sourceType); return this.markSafe(ml); } exports.bundles = bundles; function link(srcPath, relative) { /*jshint validthis: true */ var ml = build.link(srcPath, relative); return this.markSafe(ml); } exports.link = link; function script(srcPath, relative) { /*jshint validthis: true */ var ml = build.script(srcPath, relative); return this.markSafe(ml); } exports.script = script; function scriptCode(js) { /*jshint validthis: true */ var ml = '<script type="text/javascript">' + js + '</script>'; return this.markSafe(ml); } exports.scriptCode = scriptCode; exports.t = build.translate.bind(build); exports.tn = build.translateNumeric.bind(build); return exports; }
javascript
function createForBuild(build) { var exports = {}; function bundles(name, sourceType) { /*jshint validthis: true */ var ml = build.bundles(name, sourceType); return this.markSafe(ml); } exports.bundles = bundles; function link(srcPath, relative) { /*jshint validthis: true */ var ml = build.link(srcPath, relative); return this.markSafe(ml); } exports.link = link; function script(srcPath, relative) { /*jshint validthis: true */ var ml = build.script(srcPath, relative); return this.markSafe(ml); } exports.script = script; function scriptCode(js) { /*jshint validthis: true */ var ml = '<script type="text/javascript">' + js + '</script>'; return this.markSafe(ml); } exports.scriptCode = scriptCode; exports.t = build.translate.bind(build); exports.tn = build.translateNumeric.bind(build); return exports; }
[ "function", "createForBuild", "(", "build", ")", "{", "var", "exports", "=", "{", "}", ";", "function", "bundles", "(", "name", ",", "sourceType", ")", "{", "/*jshint validthis: true */", "var", "ml", "=", "build", ".", "bundles", "(", "name", ",", "sourceType", ")", ";", "return", "this", ".", "markSafe", "(", "ml", ")", ";", "}", "exports", ".", "bundles", "=", "bundles", ";", "function", "link", "(", "srcPath", ",", "relative", ")", "{", "/*jshint validthis: true */", "var", "ml", "=", "build", ".", "link", "(", "srcPath", ",", "relative", ")", ";", "return", "this", ".", "markSafe", "(", "ml", ")", ";", "}", "exports", ".", "link", "=", "link", ";", "function", "script", "(", "srcPath", ",", "relative", ")", "{", "/*jshint validthis: true */", "var", "ml", "=", "build", ".", "script", "(", "srcPath", ",", "relative", ")", ";", "return", "this", ".", "markSafe", "(", "ml", ")", ";", "}", "exports", ".", "script", "=", "script", ";", "function", "scriptCode", "(", "js", ")", "{", "/*jshint validthis: true */", "var", "ml", "=", "'<script type=\"text/javascript\">'", "+", "js", "+", "'</script>'", ";", "return", "this", ".", "markSafe", "(", "ml", ")", ";", "}", "exports", ".", "scriptCode", "=", "scriptCode", ";", "exports", ".", "t", "=", "build", ".", "translate", ".", "bind", "(", "build", ")", ";", "exports", ".", "tn", "=", "build", ".", "translateNumeric", ".", "bind", "(", "build", ")", ";", "return", "exports", ";", "}" ]
Nunjucks specific functions. This module is currently not in use.
[ "Nunjucks", "specific", "functions", ".", "This", "module", "is", "currently", "not", "in", "use", "." ]
73891a9a719de46ba07c26a10ce36c43da34ff0e
https://github.com/staticbuild/staticbuild/blob/73891a9a719de46ba07c26a10ce36c43da34ff0e/lib/nunjucks/functions.js#L5-L40
50,576
tradle/ws-client
index.js
Client
function Client (opts) { var self = this typeforce({ url: 'String', otrKey: 'DSA', // byRootHash: 'Function', instanceTag: '?String', autoconnect: '?Boolean' // defaults to true }, opts) EventEmitter.call(this) this.setMaxListeners(0) this._url = parseURL(opts.url) this._autoconnect = opts.autoconnect !== false this._onmessage = this._onmessage.bind(this) this._sessions = {} this._otrKey = opts.otrKey this._fingerprint = opts.otrKey.fingerprint() this._connected = false this._instanceTag = opts.instanceTag this._backoff = backoff.exponential({ initialDelay: 100 }) if (this._autoconnect) this.connect() }
javascript
function Client (opts) { var self = this typeforce({ url: 'String', otrKey: 'DSA', // byRootHash: 'Function', instanceTag: '?String', autoconnect: '?Boolean' // defaults to true }, opts) EventEmitter.call(this) this.setMaxListeners(0) this._url = parseURL(opts.url) this._autoconnect = opts.autoconnect !== false this._onmessage = this._onmessage.bind(this) this._sessions = {} this._otrKey = opts.otrKey this._fingerprint = opts.otrKey.fingerprint() this._connected = false this._instanceTag = opts.instanceTag this._backoff = backoff.exponential({ initialDelay: 100 }) if (this._autoconnect) this.connect() }
[ "function", "Client", "(", "opts", ")", "{", "var", "self", "=", "this", "typeforce", "(", "{", "url", ":", "'String'", ",", "otrKey", ":", "'DSA'", ",", "// byRootHash: 'Function',", "instanceTag", ":", "'?String'", ",", "autoconnect", ":", "'?Boolean'", "// defaults to true", "}", ",", "opts", ")", "EventEmitter", ".", "call", "(", "this", ")", "this", ".", "setMaxListeners", "(", "0", ")", "this", ".", "_url", "=", "parseURL", "(", "opts", ".", "url", ")", "this", ".", "_autoconnect", "=", "opts", ".", "autoconnect", "!==", "false", "this", ".", "_onmessage", "=", "this", ".", "_onmessage", ".", "bind", "(", "this", ")", "this", ".", "_sessions", "=", "{", "}", "this", ".", "_otrKey", "=", "opts", ".", "otrKey", "this", ".", "_fingerprint", "=", "opts", ".", "otrKey", ".", "fingerprint", "(", ")", "this", ".", "_connected", "=", "false", "this", ".", "_instanceTag", "=", "opts", ".", "instanceTag", "this", ".", "_backoff", "=", "backoff", ".", "exponential", "(", "{", "initialDelay", ":", "100", "}", ")", "if", "(", "this", ".", "_autoconnect", ")", "this", ".", "connect", "(", ")", "}" ]
var HANDSHAKE_TIMEOUT = 5000
[ "var", "HANDSHAKE_TIMEOUT", "=", "5000" ]
4854da00d731d8c8da6da2f6a6b93056be992cb3
https://github.com/tradle/ws-client/blob/4854da00d731d8c8da6da2f6a6b93056be992cb3/index.js#L21-L45
50,577
appcelerator-archive/appc-connector-utils
lib/index.js
preserveNamespace
function preserveNamespace (models) { const prefixedModels = {} if (connector.config.skipModelNamespace) { // if namspace is not applied we do not need to preserve it return models } else { for (var model in models) { prefixedModels[models[model].name] = models[model] } return prefixedModels } }
javascript
function preserveNamespace (models) { const prefixedModels = {} if (connector.config.skipModelNamespace) { // if namspace is not applied we do not need to preserve it return models } else { for (var model in models) { prefixedModels[models[model].name] = models[model] } return prefixedModels } }
[ "function", "preserveNamespace", "(", "models", ")", "{", "const", "prefixedModels", "=", "{", "}", "if", "(", "connector", ".", "config", ".", "skipModelNamespace", ")", "{", "// if namspace is not applied we do not need to preserve it", "return", "models", "}", "else", "{", "for", "(", "var", "model", "in", "models", ")", "{", "prefixedModels", "[", "models", "[", "model", "]", ".", "name", "]", "=", "models", "[", "model", "]", "}", "return", "prefixedModels", "}", "}" ]
Preserves the models namspaces if it exists. @param {Array} models the array of existing models
[ "Preserves", "the", "models", "namspaces", "if", "it", "exists", "." ]
4af3bb7d24c5780270d7ba0ec98017b1f58f1aa8
https://github.com/appcelerator-archive/appc-connector-utils/blob/4af3bb7d24c5780270d7ba0ec98017b1f58f1aa8/lib/index.js#L69-L80
50,578
redisjs/jsr-server
lib/command/pubsub/unsubscribe.js
execute
function execute(req, res) { this.state.pubsub.unsubscribe(req.conn, req.args); }
javascript
function execute(req, res) { this.state.pubsub.unsubscribe(req.conn, req.args); }
[ "function", "execute", "(", "req", ",", "res", ")", "{", "this", ".", "state", ".", "pubsub", ".", "unsubscribe", "(", "req", ".", "conn", ",", "req", ".", "args", ")", ";", "}" ]
Respond to the UNSUBSCRIBE command.
[ "Respond", "to", "the", "UNSUBSCRIBE", "command", "." ]
49413052d3039524fbdd2ade0ef9bae26cb4d647
https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/pubsub/unsubscribe.js#L17-L19
50,579
75lb/gfmt
lib/gfmt.js
gfmTable
function gfmTable (data, options) { options = options || {} if (!data || !data.length) { return '' } data = escapePipes(data) var tableOptions = { nowrap: !options.wrap, padding: { left: '| ', right: ' ' }, columns: options.columns || [], getColumn: function (columnName) { return this.columns.find(function (column) { return columnName === column.name }) }, ignoreEmptyColumns: options.ignoreEmptyColumns } if (options.width) tableOptions.viewWidth = options.width var headerRow = {} var separatorRow = {} var table = new Table(data, tableOptions) table.columns.list .forEach(function (column) { var optionColumn = tableOptions.getColumn(column.name) headerRow[column.name] = (optionColumn && optionColumn.header) || column.name separatorRow[column.name] = function () { return '-'.repeat(this.wrappedContentWidth) } }) data.splice(0, 0, headerRow, separatorRow) table.load(data) var lastColumn = table.columns.list[table.columns.list.length - 1] lastColumn.padding = { left: '| ', right: ' |' } return table.toString() }
javascript
function gfmTable (data, options) { options = options || {} if (!data || !data.length) { return '' } data = escapePipes(data) var tableOptions = { nowrap: !options.wrap, padding: { left: '| ', right: ' ' }, columns: options.columns || [], getColumn: function (columnName) { return this.columns.find(function (column) { return columnName === column.name }) }, ignoreEmptyColumns: options.ignoreEmptyColumns } if (options.width) tableOptions.viewWidth = options.width var headerRow = {} var separatorRow = {} var table = new Table(data, tableOptions) table.columns.list .forEach(function (column) { var optionColumn = tableOptions.getColumn(column.name) headerRow[column.name] = (optionColumn && optionColumn.header) || column.name separatorRow[column.name] = function () { return '-'.repeat(this.wrappedContentWidth) } }) data.splice(0, 0, headerRow, separatorRow) table.load(data) var lastColumn = table.columns.list[table.columns.list.length - 1] lastColumn.padding = { left: '| ', right: ' |' } return table.toString() }
[ "function", "gfmTable", "(", "data", ",", "options", ")", "{", "options", "=", "options", "||", "{", "}", "if", "(", "!", "data", "||", "!", "data", ".", "length", ")", "{", "return", "''", "}", "data", "=", "escapePipes", "(", "data", ")", "var", "tableOptions", "=", "{", "nowrap", ":", "!", "options", ".", "wrap", ",", "padding", ":", "{", "left", ":", "'| '", ",", "right", ":", "' '", "}", ",", "columns", ":", "options", ".", "columns", "||", "[", "]", ",", "getColumn", ":", "function", "(", "columnName", ")", "{", "return", "this", ".", "columns", ".", "find", "(", "function", "(", "column", ")", "{", "return", "columnName", "===", "column", ".", "name", "}", ")", "}", ",", "ignoreEmptyColumns", ":", "options", ".", "ignoreEmptyColumns", "}", "if", "(", "options", ".", "width", ")", "tableOptions", ".", "viewWidth", "=", "options", ".", "width", "var", "headerRow", "=", "{", "}", "var", "separatorRow", "=", "{", "}", "var", "table", "=", "new", "Table", "(", "data", ",", "tableOptions", ")", "table", ".", "columns", ".", "list", ".", "forEach", "(", "function", "(", "column", ")", "{", "var", "optionColumn", "=", "tableOptions", ".", "getColumn", "(", "column", ".", "name", ")", "headerRow", "[", "column", ".", "name", "]", "=", "(", "optionColumn", "&&", "optionColumn", ".", "header", ")", "||", "column", ".", "name", "separatorRow", "[", "column", ".", "name", "]", "=", "function", "(", ")", "{", "return", "'-'", ".", "repeat", "(", "this", ".", "wrappedContentWidth", ")", "}", "}", ")", "data", ".", "splice", "(", "0", ",", "0", ",", "headerRow", ",", "separatorRow", ")", "table", ".", "load", "(", "data", ")", "var", "lastColumn", "=", "table", ".", "columns", ".", "list", "[", "table", ".", "columns", ".", "list", ".", "length", "-", "1", "]", "lastColumn", ".", "padding", "=", "{", "left", ":", "'| '", ",", "right", ":", "' |'", "}", "return", "table", ".", "toString", "(", ")", "}" ]
Get a github-flavoured-markdown table instance @param {object|object[]} - the input data @param [options] {object} @param [options.columns] {object[]} - column definitions @param [options.wrap] {boolean} - wrap to fit into width @param [options.width] {boolean} - table width @param [options.ignoreEmptyColumns] {boolean} - table width @returns {string} @alias module:gfmt @example > gfmt = require("gfmt") > table = gfmt([ { "date": "10 Jun 2015", "downloads": 100 }, { "date": "11 Jun 2015", "downloads": 120 }, { "date": "12 Jun 2015", "downloads": 150 }, { "date": "13 Jun 2015", "downloads": 120 }, { "date": "14 Jun 2015", "downloads": 110 } ]) > console.log(table.getTable()) | date | downloads | | ----------- | --------- | | 10 Jun 2015 | 100 | | 11 Jun 2015 | 120 | | 12 Jun 2015 | 150 | | 13 Jun 2015 | 120 | | 14 Jun 2015 | 110 |
[ "Get", "a", "github", "-", "flavoured", "-", "markdown", "table", "instance" ]
5ed8739f91366cbee62bcc94e6dc9a33141a1057
https://github.com/75lb/gfmt/blob/5ed8739f91366cbee62bcc94e6dc9a33141a1057/lib/gfmt.js#L40-L84
50,580
vkiding/judpack-lib
src/cordova/restore-util.js
installPluginsFromConfigXML
function installPluginsFromConfigXML(args) { events.emit('verbose', 'Checking config.xml for saved plugins that haven\'t been added to the project'); //Install plugins that are listed on config.xml var projectRoot = cordova_util.cdProjectRoot(); var configPath = cordova_util.projectConfig(projectRoot); var cfg = new ConfigParser(configPath); var plugins_dir = path.join(projectRoot, 'plugins'); // Get all configured plugins var plugins = cfg.getPluginIdList(); if (0 === plugins.length) { return Q('No plugins found in config.xml that haven\'t been added to the project'); } // Intermediate variable to store current installing plugin name // to be able to create informative warning on plugin failure var pluginName; // CB-9560 : Run `plugin add` serially, one plugin after another // We need to wait for the plugin and its dependencies to be installed // before installing the next root plugin otherwise we can have common // plugin dependencies installed twice which throws a nasty error. return promiseutil.Q_chainmap_graceful(plugins, function(featureId) { var pluginPath = path.join(plugins_dir, featureId); if (fs.existsSync(pluginPath)) { // Plugin already exists return Q(); } events.emit('log', 'Discovered plugin "' + featureId + '" in config.xml. Adding it to the project'); var pluginEntry = cfg.getPlugin(featureId); // Install from given URL if defined or using a plugin id. If spec isn't a valid version or version range, // assume it is the location to install from. var pluginSpec = pluginEntry.spec; pluginName = pluginEntry.name; // CB-10761 If plugin spec is not specified, use plugin name var installFrom = pluginSpec || pluginName; if (pluginSpec && semver.validRange(pluginSpec, true)) installFrom = pluginName + '@' + pluginSpec; // Add feature preferences as CLI variables if have any var options = { cli_variables: pluginEntry.variables, searchpath: args.searchpath, fetch: args.fetch || false, save: args.save || false }; var plugin = require('./plugin'); return plugin('add', installFrom, options); }, function (error) { // CB-10921 emit a warning in case of error var msg = 'Failed to restore plugin \"' + pluginName + '\" from config.xml. ' + 'You might need to try adding it again. Error: ' + error; events.emit('warn', msg); }); }
javascript
function installPluginsFromConfigXML(args) { events.emit('verbose', 'Checking config.xml for saved plugins that haven\'t been added to the project'); //Install plugins that are listed on config.xml var projectRoot = cordova_util.cdProjectRoot(); var configPath = cordova_util.projectConfig(projectRoot); var cfg = new ConfigParser(configPath); var plugins_dir = path.join(projectRoot, 'plugins'); // Get all configured plugins var plugins = cfg.getPluginIdList(); if (0 === plugins.length) { return Q('No plugins found in config.xml that haven\'t been added to the project'); } // Intermediate variable to store current installing plugin name // to be able to create informative warning on plugin failure var pluginName; // CB-9560 : Run `plugin add` serially, one plugin after another // We need to wait for the plugin and its dependencies to be installed // before installing the next root plugin otherwise we can have common // plugin dependencies installed twice which throws a nasty error. return promiseutil.Q_chainmap_graceful(plugins, function(featureId) { var pluginPath = path.join(plugins_dir, featureId); if (fs.existsSync(pluginPath)) { // Plugin already exists return Q(); } events.emit('log', 'Discovered plugin "' + featureId + '" in config.xml. Adding it to the project'); var pluginEntry = cfg.getPlugin(featureId); // Install from given URL if defined or using a plugin id. If spec isn't a valid version or version range, // assume it is the location to install from. var pluginSpec = pluginEntry.spec; pluginName = pluginEntry.name; // CB-10761 If plugin spec is not specified, use plugin name var installFrom = pluginSpec || pluginName; if (pluginSpec && semver.validRange(pluginSpec, true)) installFrom = pluginName + '@' + pluginSpec; // Add feature preferences as CLI variables if have any var options = { cli_variables: pluginEntry.variables, searchpath: args.searchpath, fetch: args.fetch || false, save: args.save || false }; var plugin = require('./plugin'); return plugin('add', installFrom, options); }, function (error) { // CB-10921 emit a warning in case of error var msg = 'Failed to restore plugin \"' + pluginName + '\" from config.xml. ' + 'You might need to try adding it again. Error: ' + error; events.emit('warn', msg); }); }
[ "function", "installPluginsFromConfigXML", "(", "args", ")", "{", "events", ".", "emit", "(", "'verbose'", ",", "'Checking config.xml for saved plugins that haven\\'t been added to the project'", ")", ";", "//Install plugins that are listed on config.xml", "var", "projectRoot", "=", "cordova_util", ".", "cdProjectRoot", "(", ")", ";", "var", "configPath", "=", "cordova_util", ".", "projectConfig", "(", "projectRoot", ")", ";", "var", "cfg", "=", "new", "ConfigParser", "(", "configPath", ")", ";", "var", "plugins_dir", "=", "path", ".", "join", "(", "projectRoot", ",", "'plugins'", ")", ";", "// Get all configured plugins", "var", "plugins", "=", "cfg", ".", "getPluginIdList", "(", ")", ";", "if", "(", "0", "===", "plugins", ".", "length", ")", "{", "return", "Q", "(", "'No plugins found in config.xml that haven\\'t been added to the project'", ")", ";", "}", "// Intermediate variable to store current installing plugin name", "// to be able to create informative warning on plugin failure", "var", "pluginName", ";", "// CB-9560 : Run `plugin add` serially, one plugin after another", "// We need to wait for the plugin and its dependencies to be installed", "// before installing the next root plugin otherwise we can have common", "// plugin dependencies installed twice which throws a nasty error.", "return", "promiseutil", ".", "Q_chainmap_graceful", "(", "plugins", ",", "function", "(", "featureId", ")", "{", "var", "pluginPath", "=", "path", ".", "join", "(", "plugins_dir", ",", "featureId", ")", ";", "if", "(", "fs", ".", "existsSync", "(", "pluginPath", ")", ")", "{", "// Plugin already exists", "return", "Q", "(", ")", ";", "}", "events", ".", "emit", "(", "'log'", ",", "'Discovered plugin \"'", "+", "featureId", "+", "'\" in config.xml. Adding it to the project'", ")", ";", "var", "pluginEntry", "=", "cfg", ".", "getPlugin", "(", "featureId", ")", ";", "// Install from given URL if defined or using a plugin id. If spec isn't a valid version or version range,", "// assume it is the location to install from.", "var", "pluginSpec", "=", "pluginEntry", ".", "spec", ";", "pluginName", "=", "pluginEntry", ".", "name", ";", "// CB-10761 If plugin spec is not specified, use plugin name", "var", "installFrom", "=", "pluginSpec", "||", "pluginName", ";", "if", "(", "pluginSpec", "&&", "semver", ".", "validRange", "(", "pluginSpec", ",", "true", ")", ")", "installFrom", "=", "pluginName", "+", "'@'", "+", "pluginSpec", ";", "// Add feature preferences as CLI variables if have any", "var", "options", "=", "{", "cli_variables", ":", "pluginEntry", ".", "variables", ",", "searchpath", ":", "args", ".", "searchpath", ",", "fetch", ":", "args", ".", "fetch", "||", "false", ",", "save", ":", "args", ".", "save", "||", "false", "}", ";", "var", "plugin", "=", "require", "(", "'./plugin'", ")", ";", "return", "plugin", "(", "'add'", ",", "installFrom", ",", "options", ")", ";", "}", ",", "function", "(", "error", ")", "{", "// CB-10921 emit a warning in case of error", "var", "msg", "=", "'Failed to restore plugin \\\"'", "+", "pluginName", "+", "'\\\" from config.xml. '", "+", "'You might need to try adding it again. Error: '", "+", "error", ";", "events", ".", "emit", "(", "'warn'", ",", "msg", ")", ";", "}", ")", ";", "}" ]
returns a Promise
[ "returns", "a", "Promise" ]
8657cecfec68221109279106adca8dbc81f430f4
https://github.com/vkiding/judpack-lib/blob/8657cecfec68221109279106adca8dbc81f430f4/src/cordova/restore-util.js#L81-L139
50,581
martinjunior/grunt-emo
tasks/components/StyleGuideGenerator.js
function(grunt, gruntFilesArray, gruntOptions) { /** * @property styleGuideGenerator.grunt * @type {Object} */ this.grunt = grunt; /** * An unexpanded grunt file array * * @property styleGuideGenerator.gruntFilesArray * @type {Array} */ this.gruntFilesArray = gruntFilesArray; /** * Grunt task options * * @property styleGuideGenerator.gruntOptions * @type {Array} */ this.gruntOptions = objectAssign(StyleGuideGenerator.OPTIONS, gruntOptions); /** * An emo-gen instance * * @property styleGuideGenerator.generator */ this.generator = new EMOGen( this.gruntOptions, this.gruntOptions.nunjucksOptions ); }
javascript
function(grunt, gruntFilesArray, gruntOptions) { /** * @property styleGuideGenerator.grunt * @type {Object} */ this.grunt = grunt; /** * An unexpanded grunt file array * * @property styleGuideGenerator.gruntFilesArray * @type {Array} */ this.gruntFilesArray = gruntFilesArray; /** * Grunt task options * * @property styleGuideGenerator.gruntOptions * @type {Array} */ this.gruntOptions = objectAssign(StyleGuideGenerator.OPTIONS, gruntOptions); /** * An emo-gen instance * * @property styleGuideGenerator.generator */ this.generator = new EMOGen( this.gruntOptions, this.gruntOptions.nunjucksOptions ); }
[ "function", "(", "grunt", ",", "gruntFilesArray", ",", "gruntOptions", ")", "{", "/**\n * @property styleGuideGenerator.grunt\n * @type {Object}\n */", "this", ".", "grunt", "=", "grunt", ";", "/**\n * An unexpanded grunt file array\n * \n * @property styleGuideGenerator.gruntFilesArray\n * @type {Array}\n */", "this", ".", "gruntFilesArray", "=", "gruntFilesArray", ";", "/**\n * Grunt task options\n * \n * @property styleGuideGenerator.gruntOptions\n * @type {Array}\n */", "this", ".", "gruntOptions", "=", "objectAssign", "(", "StyleGuideGenerator", ".", "OPTIONS", ",", "gruntOptions", ")", ";", "/**\n * An emo-gen instance\n * \n * @property styleGuideGenerator.generator\n */", "this", ".", "generator", "=", "new", "EMOGen", "(", "this", ".", "gruntOptions", ",", "this", ".", "gruntOptions", ".", "nunjucksOptions", ")", ";", "}" ]
A grunt style guide generator @param {Object} grunt @param {Array} gruntFilesArray an unexpanded grunt file array @param {Object} gruntOptions grunt task options
[ "A", "grunt", "style", "guide", "generator" ]
a7c6de9538bccfcae050a6d389d6aa118c933f3c
https://github.com/martinjunior/grunt-emo/blob/a7c6de9538bccfcae050a6d389d6aa118c933f3c/tasks/components/StyleGuideGenerator.js#L14-L46
50,582
esha/posterior
docs/demo.js
function(obj) { if (typeof obj === "object") { if (Array.isArray(obj) && obj.length > 1) { obj = '[ '+toString(obj[0])+', ... ]'; } } return (obj+''); }
javascript
function(obj) { if (typeof obj === "object") { if (Array.isArray(obj) && obj.length > 1) { obj = '[ '+toString(obj[0])+', ... ]'; } } return (obj+''); }
[ "function", "(", "obj", ")", "{", "if", "(", "typeof", "obj", "===", "\"object\"", ")", "{", "if", "(", "Array", ".", "isArray", "(", "obj", ")", "&&", "obj", ".", "length", ">", "1", ")", "{", "obj", "=", "'[ '", "+", "toString", "(", "obj", "[", "0", "]", ")", "+", "', ... ]'", ";", "}", "}", "return", "(", "obj", "+", "''", ")", ";", "}" ]
hijack console.debug to echo to a DOM element
[ "hijack", "console", ".", "debug", "to", "echo", "to", "a", "DOM", "element" ]
2f50ce98495762eed3b2c1553e371a117b5ae8c6
https://github.com/esha/posterior/blob/2f50ce98495762eed3b2c1553e371a117b5ae8c6/docs/demo.js#L6-L13
50,583
yibn2008/cli-source-preview
index.js
preview
function preview (source, line, options) { let from, to, pos // set from/to line if (Array.isArray(line)) { from = line[0] | 0 to = line[1] | 0 || from } else if (typeof line === 'object') { from = to = line.line | 0 pos = { line: line.line | 0, column: line.column | 0 } } else { from = to = line | 0 } // set options options = Object.assign({}, PREVIEW_OPTS, options) let color = colorer(options.cliColor) // read source by from/to let lines = readSource(source, from, to, options.offset, options.delimiter) let numberWidth = String(to).length + 4 // [] + two space if (!options.lineNumber) { numberWidth = 0 } let parts = lines.map(line => { let prefix = '' let text = '' if (options.lineNumber) { prefix = rightPad(`[${line.number}]`, numberWidth) } if (line.number >= from && line.number <= to) { text = color('red', `${prefix}${line.source}`) } else { text = color('grey', prefix) + line.source } if (pos && pos.line === line.number) { text += '\n' + ' '.repeat(numberWidth + pos.column - 1) + '^' } return text }) // add delimiter parts.unshift(color('grey', DELIMITER)) parts.push(color('grey', DELIMITER)) return parts.join('\n') }
javascript
function preview (source, line, options) { let from, to, pos // set from/to line if (Array.isArray(line)) { from = line[0] | 0 to = line[1] | 0 || from } else if (typeof line === 'object') { from = to = line.line | 0 pos = { line: line.line | 0, column: line.column | 0 } } else { from = to = line | 0 } // set options options = Object.assign({}, PREVIEW_OPTS, options) let color = colorer(options.cliColor) // read source by from/to let lines = readSource(source, from, to, options.offset, options.delimiter) let numberWidth = String(to).length + 4 // [] + two space if (!options.lineNumber) { numberWidth = 0 } let parts = lines.map(line => { let prefix = '' let text = '' if (options.lineNumber) { prefix = rightPad(`[${line.number}]`, numberWidth) } if (line.number >= from && line.number <= to) { text = color('red', `${prefix}${line.source}`) } else { text = color('grey', prefix) + line.source } if (pos && pos.line === line.number) { text += '\n' + ' '.repeat(numberWidth + pos.column - 1) + '^' } return text }) // add delimiter parts.unshift(color('grey', DELIMITER)) parts.push(color('grey', DELIMITER)) return parts.join('\n') }
[ "function", "preview", "(", "source", ",", "line", ",", "options", ")", "{", "let", "from", ",", "to", ",", "pos", "// set from/to line", "if", "(", "Array", ".", "isArray", "(", "line", ")", ")", "{", "from", "=", "line", "[", "0", "]", "|", "0", "to", "=", "line", "[", "1", "]", "|", "0", "||", "from", "}", "else", "if", "(", "typeof", "line", "===", "'object'", ")", "{", "from", "=", "to", "=", "line", ".", "line", "|", "0", "pos", "=", "{", "line", ":", "line", ".", "line", "|", "0", ",", "column", ":", "line", ".", "column", "|", "0", "}", "}", "else", "{", "from", "=", "to", "=", "line", "|", "0", "}", "// set options", "options", "=", "Object", ".", "assign", "(", "{", "}", ",", "PREVIEW_OPTS", ",", "options", ")", "let", "color", "=", "colorer", "(", "options", ".", "cliColor", ")", "// read source by from/to", "let", "lines", "=", "readSource", "(", "source", ",", "from", ",", "to", ",", "options", ".", "offset", ",", "options", ".", "delimiter", ")", "let", "numberWidth", "=", "String", "(", "to", ")", ".", "length", "+", "4", "// [] + two space", "if", "(", "!", "options", ".", "lineNumber", ")", "{", "numberWidth", "=", "0", "}", "let", "parts", "=", "lines", ".", "map", "(", "line", "=>", "{", "let", "prefix", "=", "''", "let", "text", "=", "''", "if", "(", "options", ".", "lineNumber", ")", "{", "prefix", "=", "rightPad", "(", "`", "${", "line", ".", "number", "}", "`", ",", "numberWidth", ")", "}", "if", "(", "line", ".", "number", ">=", "from", "&&", "line", ".", "number", "<=", "to", ")", "{", "text", "=", "color", "(", "'red'", ",", "`", "${", "prefix", "}", "${", "line", ".", "source", "}", "`", ")", "}", "else", "{", "text", "=", "color", "(", "'grey'", ",", "prefix", ")", "+", "line", ".", "source", "}", "if", "(", "pos", "&&", "pos", ".", "line", "===", "line", ".", "number", ")", "{", "text", "+=", "'\\n'", "+", "' '", ".", "repeat", "(", "numberWidth", "+", "pos", ".", "column", "-", "1", ")", "+", "'^'", "}", "return", "text", "}", ")", "// add delimiter", "parts", ".", "unshift", "(", "color", "(", "'grey'", ",", "DELIMITER", ")", ")", "parts", ".", "push", "(", "color", "(", "'grey'", ",", "DELIMITER", ")", ")", "return", "parts", ".", "join", "(", "'\\n'", ")", "}" ]
Preview parts of source code line: - Array: `[ Number, Number ]`, the line range to preview - Object: `{ line: Number, column: Number }`, preivew specified line/column - Number: preivew single line options: - offset: the extra lines number before/after specified line range (default: 5) - lineNumber: show line number or not (default: true) - delimiter: line delimiter (default: '\n') - cliColor: show ASCI CLI color (default: true) @param {String} source Source code @param {Mixed} line Line number to preivew @param {Object} options Options (optional) @return {String} source parts
[ "Preview", "parts", "of", "source", "code" ]
747c2d892b71bbd2c30c4a1782aa2f8c111c41ac
https://github.com/yibn2008/cli-source-preview/blob/747c2d892b71bbd2c30c4a1782aa2f8c111c41ac/index.js#L48-L104
50,584
yibn2008/cli-source-preview
index.js
readSource
function readSource (source, from, to, offset, delimiter) { // fix args from = from | 0 to = to | 0 || from delimiter = delimiter || PREVIEW_OPTS.delimiter if (typeof offset === 'undefined') { offset = PREVIEW_OPTS.offset } else { offset = offset | 0 } let lastIdx = -1 let currIdx = lastIdx let line = 1 let reads = [] from -= offset to += offset while (currIdx < source.length) { currIdx = source.indexOf(delimiter, lastIdx + 1) if (currIdx < 0) { currIdx = source.length } if (line > to) { break } else if (line >= from && line <= to) { reads.push({ number: line, source: source.substring(lastIdx + delimiter.length, currIdx) }) } lastIdx = currIdx line ++ } return reads }
javascript
function readSource (source, from, to, offset, delimiter) { // fix args from = from | 0 to = to | 0 || from delimiter = delimiter || PREVIEW_OPTS.delimiter if (typeof offset === 'undefined') { offset = PREVIEW_OPTS.offset } else { offset = offset | 0 } let lastIdx = -1 let currIdx = lastIdx let line = 1 let reads = [] from -= offset to += offset while (currIdx < source.length) { currIdx = source.indexOf(delimiter, lastIdx + 1) if (currIdx < 0) { currIdx = source.length } if (line > to) { break } else if (line >= from && line <= to) { reads.push({ number: line, source: source.substring(lastIdx + delimiter.length, currIdx) }) } lastIdx = currIdx line ++ } return reads }
[ "function", "readSource", "(", "source", ",", "from", ",", "to", ",", "offset", ",", "delimiter", ")", "{", "// fix args", "from", "=", "from", "|", "0", "to", "=", "to", "|", "0", "||", "from", "delimiter", "=", "delimiter", "||", "PREVIEW_OPTS", ".", "delimiter", "if", "(", "typeof", "offset", "===", "'undefined'", ")", "{", "offset", "=", "PREVIEW_OPTS", ".", "offset", "}", "else", "{", "offset", "=", "offset", "|", "0", "}", "let", "lastIdx", "=", "-", "1", "let", "currIdx", "=", "lastIdx", "let", "line", "=", "1", "let", "reads", "=", "[", "]", "from", "-=", "offset", "to", "+=", "offset", "while", "(", "currIdx", "<", "source", ".", "length", ")", "{", "currIdx", "=", "source", ".", "indexOf", "(", "delimiter", ",", "lastIdx", "+", "1", ")", "if", "(", "currIdx", "<", "0", ")", "{", "currIdx", "=", "source", ".", "length", "}", "if", "(", "line", ">", "to", ")", "{", "break", "}", "else", "if", "(", "line", ">=", "from", "&&", "line", "<=", "to", ")", "{", "reads", ".", "push", "(", "{", "number", ":", "line", ",", "source", ":", "source", ".", "substring", "(", "lastIdx", "+", "delimiter", ".", "length", ",", "currIdx", ")", "}", ")", "}", "lastIdx", "=", "currIdx", "line", "++", "}", "return", "reads", "}" ]
Read source by line number Return: [ { number: Number, source: String }, ... ] @param {String} source @param {Number} from @param {Number} to (optional) @param {Number} offset (optional) @param {String} delimiter (optional) @return {Array} Source splitd by line
[ "Read", "source", "by", "line", "number" ]
747c2d892b71bbd2c30c4a1782aa2f8c111c41ac
https://github.com/yibn2008/cli-source-preview/blob/747c2d892b71bbd2c30c4a1782aa2f8c111c41ac/index.js#L124-L164
50,585
panjiesw/frest
internal/docs/themes/hugo-theme-learn/static/js/hugo-learn.js
getUrlParameter
function getUrlParameter(sPageURL) { var url = sPageURL.split('?'); var obj = {}; if (url.length == 2) { var sURLVariables = url[1].split('&'), sParameterName, i; for (i = 0; i < sURLVariables.length; i++) { sParameterName = sURLVariables[i].split('='); obj[sParameterName[0]] = sParameterName[1]; } return obj; } else { return undefined; } }
javascript
function getUrlParameter(sPageURL) { var url = sPageURL.split('?'); var obj = {}; if (url.length == 2) { var sURLVariables = url[1].split('&'), sParameterName, i; for (i = 0; i < sURLVariables.length; i++) { sParameterName = sURLVariables[i].split('='); obj[sParameterName[0]] = sParameterName[1]; } return obj; } else { return undefined; } }
[ "function", "getUrlParameter", "(", "sPageURL", ")", "{", "var", "url", "=", "sPageURL", ".", "split", "(", "'?'", ")", ";", "var", "obj", "=", "{", "}", ";", "if", "(", "url", ".", "length", "==", "2", ")", "{", "var", "sURLVariables", "=", "url", "[", "1", "]", ".", "split", "(", "'&'", ")", ",", "sParameterName", ",", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "sURLVariables", ".", "length", ";", "i", "++", ")", "{", "sParameterName", "=", "sURLVariables", "[", "i", "]", ".", "split", "(", "'='", ")", ";", "obj", "[", "sParameterName", "[", "0", "]", "]", "=", "sParameterName", "[", "1", "]", ";", "}", "return", "obj", ";", "}", "else", "{", "return", "undefined", ";", "}", "}" ]
Get Parameters from some url
[ "Get", "Parameters", "from", "some", "url" ]
975a16ae24bd214b608d0b0001d3d86e5cd65f9e
https://github.com/panjiesw/frest/blob/975a16ae24bd214b608d0b0001d3d86e5cd65f9e/internal/docs/themes/hugo-theme-learn/static/js/hugo-learn.js#L2-L17
50,586
glesage/node-loop-bench
main.js
function () { var tableData = [ ['LOOP TYPE', ...config.counts] ]; var bases = []; Object.keys(results['while desc']).forEach(function (countType) { var times = results['while desc'][countType]; var sum = times.reduce(function (acc, val) { return acc + val; }, 0); bases.push(sum); }); Object.keys(results).forEach(function (loopType) { var currentResult = [loopType]; Object.keys(results[loopType]).forEach(function (countType, idx) { var times = results[loopType][countType]; var sum = times.reduce(function (acc, val) { return acc + val; }, 0); var relative = '-'; if (bases[idx] > sum) relative = '-' + String((bases[idx] / sum).toFixed(2)) + '%'; else if (bases[idx] < sum) relative = '+' + String((bases[idx] / sum).toFixed(2)) + '%'; currentResult.push(relative); }); tableData.push(currentResult); }); console.log('\n\n' + table(tableData) + '\n'); process.exit(); }
javascript
function () { var tableData = [ ['LOOP TYPE', ...config.counts] ]; var bases = []; Object.keys(results['while desc']).forEach(function (countType) { var times = results['while desc'][countType]; var sum = times.reduce(function (acc, val) { return acc + val; }, 0); bases.push(sum); }); Object.keys(results).forEach(function (loopType) { var currentResult = [loopType]; Object.keys(results[loopType]).forEach(function (countType, idx) { var times = results[loopType][countType]; var sum = times.reduce(function (acc, val) { return acc + val; }, 0); var relative = '-'; if (bases[idx] > sum) relative = '-' + String((bases[idx] / sum).toFixed(2)) + '%'; else if (bases[idx] < sum) relative = '+' + String((bases[idx] / sum).toFixed(2)) + '%'; currentResult.push(relative); }); tableData.push(currentResult); }); console.log('\n\n' + table(tableData) + '\n'); process.exit(); }
[ "function", "(", ")", "{", "var", "tableData", "=", "[", "[", "'LOOP TYPE'", ",", "...", "config", ".", "counts", "]", "]", ";", "var", "bases", "=", "[", "]", ";", "Object", ".", "keys", "(", "results", "[", "'while desc'", "]", ")", ".", "forEach", "(", "function", "(", "countType", ")", "{", "var", "times", "=", "results", "[", "'while desc'", "]", "[", "countType", "]", ";", "var", "sum", "=", "times", ".", "reduce", "(", "function", "(", "acc", ",", "val", ")", "{", "return", "acc", "+", "val", ";", "}", ",", "0", ")", ";", "bases", ".", "push", "(", "sum", ")", ";", "}", ")", ";", "Object", ".", "keys", "(", "results", ")", ".", "forEach", "(", "function", "(", "loopType", ")", "{", "var", "currentResult", "=", "[", "loopType", "]", ";", "Object", ".", "keys", "(", "results", "[", "loopType", "]", ")", ".", "forEach", "(", "function", "(", "countType", ",", "idx", ")", "{", "var", "times", "=", "results", "[", "loopType", "]", "[", "countType", "]", ";", "var", "sum", "=", "times", ".", "reduce", "(", "function", "(", "acc", ",", "val", ")", "{", "return", "acc", "+", "val", ";", "}", ",", "0", ")", ";", "var", "relative", "=", "'-'", ";", "if", "(", "bases", "[", "idx", "]", ">", "sum", ")", "relative", "=", "'-'", "+", "String", "(", "(", "bases", "[", "idx", "]", "/", "sum", ")", ".", "toFixed", "(", "2", ")", ")", "+", "'%'", ";", "else", "if", "(", "bases", "[", "idx", "]", "<", "sum", ")", "relative", "=", "'+'", "+", "String", "(", "(", "bases", "[", "idx", "]", "/", "sum", ")", ".", "toFixed", "(", "2", ")", ")", "+", "'%'", ";", "currentResult", ".", "push", "(", "relative", ")", ";", "}", ")", ";", "tableData", ".", "push", "(", "currentResult", ")", ";", "}", ")", ";", "console", ".", "log", "(", "'\\n\\n'", "+", "table", "(", "tableData", ")", "+", "'\\n'", ")", ";", "process", ".", "exit", "(", ")", ";", "}" ]
Use text-table to log the results in a table format
[ "Use", "text", "-", "table", "to", "log", "the", "results", "in", "a", "table", "format" ]
d034be83191c769ab53dd7bab956e782c5278960
https://github.com/glesage/node-loop-bench/blob/d034be83191c769ab53dd7bab956e782c5278960/main.js#L81-L120
50,587
andrewscwei/requiem
src/dom/getAttribute.js
getAttribute
function getAttribute(element, name) { assertType(element, Node, false, 'Invalid element specified'); if (!element.getAttribute) return null; let value = element.getAttribute(name); if (value === '') return true; if (value === undefined || value === null) return null; try { return JSON.parse(value); } catch (err) { return value; } }
javascript
function getAttribute(element, name) { assertType(element, Node, false, 'Invalid element specified'); if (!element.getAttribute) return null; let value = element.getAttribute(name); if (value === '') return true; if (value === undefined || value === null) return null; try { return JSON.parse(value); } catch (err) { return value; } }
[ "function", "getAttribute", "(", "element", ",", "name", ")", "{", "assertType", "(", "element", ",", "Node", ",", "false", ",", "'Invalid element specified'", ")", ";", "if", "(", "!", "element", ".", "getAttribute", ")", "return", "null", ";", "let", "value", "=", "element", ".", "getAttribute", "(", "name", ")", ";", "if", "(", "value", "===", "''", ")", "return", "true", ";", "if", "(", "value", "===", "undefined", "||", "value", "===", "null", ")", "return", "null", ";", "try", "{", "return", "JSON", ".", "parse", "(", "value", ")", ";", "}", "catch", "(", "err", ")", "{", "return", "value", ";", "}", "}" ]
Gets an attribute of an element by its name. @param {Node} element - Target element. @param {string} name - Attribute name. @return {string} Attribute value. @alias module:requiem~dom.getAttribute
[ "Gets", "an", "attribute", "of", "an", "element", "by", "its", "name", "." ]
c4182bfffc9841c6de5718f689ad3c2060511777
https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/dom/getAttribute.js#L17-L31
50,588
raincatcher-beta/raincatcher-file
lib/client/file-client/FileClient.js
fileUpload
function fileUpload(fileURI, serverURI, fileUploadOptions) { var deferred = q.defer(); var transfer = new FileTransfer(); transfer.upload(fileURI, serverURI, function uploadSuccess(response) { deferred.resolve(response); }, function uploadFailure(error) { deferred.reject(error); }, fileUploadOptions); return deferred.promise; }
javascript
function fileUpload(fileURI, serverURI, fileUploadOptions) { var deferred = q.defer(); var transfer = new FileTransfer(); transfer.upload(fileURI, serverURI, function uploadSuccess(response) { deferred.resolve(response); }, function uploadFailure(error) { deferred.reject(error); }, fileUploadOptions); return deferred.promise; }
[ "function", "fileUpload", "(", "fileURI", ",", "serverURI", ",", "fileUploadOptions", ")", "{", "var", "deferred", "=", "q", ".", "defer", "(", ")", ";", "var", "transfer", "=", "new", "FileTransfer", "(", ")", ";", "transfer", ".", "upload", "(", "fileURI", ",", "serverURI", ",", "function", "uploadSuccess", "(", "response", ")", "{", "deferred", ".", "resolve", "(", "response", ")", ";", "}", ",", "function", "uploadFailure", "(", "error", ")", "{", "deferred", ".", "reject", "(", "error", ")", ";", "}", ",", "fileUploadOptions", ")", ";", "return", "deferred", ".", "promise", ";", "}" ]
Handling file upload to server
[ "Handling", "file", "upload", "to", "server" ]
1a4b5d53505eb381a3d4c0bd384e743c39886c1d
https://github.com/raincatcher-beta/raincatcher-file/blob/1a4b5d53505eb381a3d4c0bd384e743c39886c1d/lib/client/file-client/FileClient.js#L168-L177
50,589
raincatcher-beta/raincatcher-file
lib/client/file-client/FileClient.js
fileUploadRetry
function fileUploadRetry(fileURI, serverURI, fileUploadOptions, timeout, retries) { return fileUpload(fileURI, serverURI, fileUploadOptions) .then(function(response) { return response; }, function() { if (retries === 0) { throw new Error("Can't upload to " + JSON.stringify(serverURI)); } return q.delay(timeout) .then(function() { return fileUploadRetry(fileURI, serverURI, fileUploadOptions, timeout, retries - 1); }); }); }
javascript
function fileUploadRetry(fileURI, serverURI, fileUploadOptions, timeout, retries) { return fileUpload(fileURI, serverURI, fileUploadOptions) .then(function(response) { return response; }, function() { if (retries === 0) { throw new Error("Can't upload to " + JSON.stringify(serverURI)); } return q.delay(timeout) .then(function() { return fileUploadRetry(fileURI, serverURI, fileUploadOptions, timeout, retries - 1); }); }); }
[ "function", "fileUploadRetry", "(", "fileURI", ",", "serverURI", ",", "fileUploadOptions", ",", "timeout", ",", "retries", ")", "{", "return", "fileUpload", "(", "fileURI", ",", "serverURI", ",", "fileUploadOptions", ")", ".", "then", "(", "function", "(", "response", ")", "{", "return", "response", ";", "}", ",", "function", "(", ")", "{", "if", "(", "retries", "===", "0", ")", "{", "throw", "new", "Error", "(", "\"Can't upload to \"", "+", "JSON", ".", "stringify", "(", "serverURI", ")", ")", ";", "}", "return", "q", ".", "delay", "(", "timeout", ")", ".", "then", "(", "function", "(", ")", "{", "return", "fileUploadRetry", "(", "fileURI", ",", "serverURI", ",", "fileUploadOptions", ",", "timeout", ",", "retries", "-", "1", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
Handling retry mechanism of the file upload.
[ "Handling", "retry", "mechanism", "of", "the", "file", "upload", "." ]
1a4b5d53505eb381a3d4c0bd384e743c39886c1d
https://github.com/raincatcher-beta/raincatcher-file/blob/1a4b5d53505eb381a3d4c0bd384e743c39886c1d/lib/client/file-client/FileClient.js#L180-L193
50,590
jkuczm/metalsmith-mtime
lib/index.js
addAllMtimes
function addAllMtimes(files, metalsmith, done) { var source = metalsmith.source(); // File system will be accessed for each element so iterate in parallel. each(Object.keys(files), getAddMtime, done); /** * Gets mtime of given `file` and adds it to metadata. * * @param {String} file * @param {Function} done * @api private */ function getAddMtime(file, done) { fs.stat(path.join(source, file), addMtime); /** * Adds `stats.mtime` of `file` to its metadata. * * @param {Error} err * @param {fs.Stats} stats * @api private */ function addMtime(err, stats) { if (err) { // Skip elements of `files` that don't point to existing files. // This can happen if some other Metalsmith plugin does something // strange with `files`. if (err.code === 'ENOENT') { debug('file %s not found', file); return done(); } return done(err); } debug('mtime of file %s is %s', file, stats.mtime); files[file].mtime = stats.mtime; done(); } } }
javascript
function addAllMtimes(files, metalsmith, done) { var source = metalsmith.source(); // File system will be accessed for each element so iterate in parallel. each(Object.keys(files), getAddMtime, done); /** * Gets mtime of given `file` and adds it to metadata. * * @param {String} file * @param {Function} done * @api private */ function getAddMtime(file, done) { fs.stat(path.join(source, file), addMtime); /** * Adds `stats.mtime` of `file` to its metadata. * * @param {Error} err * @param {fs.Stats} stats * @api private */ function addMtime(err, stats) { if (err) { // Skip elements of `files` that don't point to existing files. // This can happen if some other Metalsmith plugin does something // strange with `files`. if (err.code === 'ENOENT') { debug('file %s not found', file); return done(); } return done(err); } debug('mtime of file %s is %s', file, stats.mtime); files[file].mtime = stats.mtime; done(); } } }
[ "function", "addAllMtimes", "(", "files", ",", "metalsmith", ",", "done", ")", "{", "var", "source", "=", "metalsmith", ".", "source", "(", ")", ";", "// File system will be accessed for each element so iterate in parallel.", "each", "(", "Object", ".", "keys", "(", "files", ")", ",", "getAddMtime", ",", "done", ")", ";", "/**\n * Gets mtime of given `file` and adds it to metadata.\n *\n * @param {String} file\n * @param {Function} done\n * @api private\n */", "function", "getAddMtime", "(", "file", ",", "done", ")", "{", "fs", ".", "stat", "(", "path", ".", "join", "(", "source", ",", "file", ")", ",", "addMtime", ")", ";", "/**\n * Adds `stats.mtime` of `file` to its metadata.\n *\n * @param {Error} err\n * @param {fs.Stats} stats\n * @api private\n */", "function", "addMtime", "(", "err", ",", "stats", ")", "{", "if", "(", "err", ")", "{", "// Skip elements of `files` that don't point to existing files.", "// This can happen if some other Metalsmith plugin does something", "// strange with `files`.", "if", "(", "err", ".", "code", "===", "'ENOENT'", ")", "{", "debug", "(", "'file %s not found'", ",", "file", ")", ";", "return", "done", "(", ")", ";", "}", "return", "done", "(", "err", ")", ";", "}", "debug", "(", "'mtime of file %s is %s'", ",", "file", ",", "stats", ".", "mtime", ")", ";", "files", "[", "file", "]", ".", "mtime", "=", "stats", ".", "mtime", ";", "done", "(", ")", ";", "}", "}", "}" ]
Adds files mtimes to all corresponding objects in `files`. @param {Object} files @param {Object} metalsmith @param {Function} done @api private
[ "Adds", "files", "mtimes", "to", "all", "corresponding", "objects", "in", "files", "." ]
0e7022e82b32f11044da4253833addd26bcdf478
https://github.com/jkuczm/metalsmith-mtime/blob/0e7022e82b32f11044da4253833addd26bcdf478/lib/index.js#L39-L84
50,591
jkuczm/metalsmith-mtime
lib/index.js
getAddMtime
function getAddMtime(file, done) { fs.stat(path.join(source, file), addMtime); /** * Adds `stats.mtime` of `file` to its metadata. * * @param {Error} err * @param {fs.Stats} stats * @api private */ function addMtime(err, stats) { if (err) { // Skip elements of `files` that don't point to existing files. // This can happen if some other Metalsmith plugin does something // strange with `files`. if (err.code === 'ENOENT') { debug('file %s not found', file); return done(); } return done(err); } debug('mtime of file %s is %s', file, stats.mtime); files[file].mtime = stats.mtime; done(); } }
javascript
function getAddMtime(file, done) { fs.stat(path.join(source, file), addMtime); /** * Adds `stats.mtime` of `file` to its metadata. * * @param {Error} err * @param {fs.Stats} stats * @api private */ function addMtime(err, stats) { if (err) { // Skip elements of `files` that don't point to existing files. // This can happen if some other Metalsmith plugin does something // strange with `files`. if (err.code === 'ENOENT') { debug('file %s not found', file); return done(); } return done(err); } debug('mtime of file %s is %s', file, stats.mtime); files[file].mtime = stats.mtime; done(); } }
[ "function", "getAddMtime", "(", "file", ",", "done", ")", "{", "fs", ".", "stat", "(", "path", ".", "join", "(", "source", ",", "file", ")", ",", "addMtime", ")", ";", "/**\n * Adds `stats.mtime` of `file` to its metadata.\n *\n * @param {Error} err\n * @param {fs.Stats} stats\n * @api private\n */", "function", "addMtime", "(", "err", ",", "stats", ")", "{", "if", "(", "err", ")", "{", "// Skip elements of `files` that don't point to existing files.", "// This can happen if some other Metalsmith plugin does something", "// strange with `files`.", "if", "(", "err", ".", "code", "===", "'ENOENT'", ")", "{", "debug", "(", "'file %s not found'", ",", "file", ")", ";", "return", "done", "(", ")", ";", "}", "return", "done", "(", "err", ")", ";", "}", "debug", "(", "'mtime of file %s is %s'", ",", "file", ",", "stats", ".", "mtime", ")", ";", "files", "[", "file", "]", ".", "mtime", "=", "stats", ".", "mtime", ";", "done", "(", ")", ";", "}", "}" ]
Gets mtime of given `file` and adds it to metadata. @param {String} file @param {Function} done @api private
[ "Gets", "mtime", "of", "given", "file", "and", "adds", "it", "to", "metadata", "." ]
0e7022e82b32f11044da4253833addd26bcdf478
https://github.com/jkuczm/metalsmith-mtime/blob/0e7022e82b32f11044da4253833addd26bcdf478/lib/index.js#L55-L83
50,592
jkuczm/metalsmith-mtime
lib/index.js
addMtime
function addMtime(err, stats) { if (err) { // Skip elements of `files` that don't point to existing files. // This can happen if some other Metalsmith plugin does something // strange with `files`. if (err.code === 'ENOENT') { debug('file %s not found', file); return done(); } return done(err); } debug('mtime of file %s is %s', file, stats.mtime); files[file].mtime = stats.mtime; done(); }
javascript
function addMtime(err, stats) { if (err) { // Skip elements of `files` that don't point to existing files. // This can happen if some other Metalsmith plugin does something // strange with `files`. if (err.code === 'ENOENT') { debug('file %s not found', file); return done(); } return done(err); } debug('mtime of file %s is %s', file, stats.mtime); files[file].mtime = stats.mtime; done(); }
[ "function", "addMtime", "(", "err", ",", "stats", ")", "{", "if", "(", "err", ")", "{", "// Skip elements of `files` that don't point to existing files.", "// This can happen if some other Metalsmith plugin does something", "// strange with `files`.", "if", "(", "err", ".", "code", "===", "'ENOENT'", ")", "{", "debug", "(", "'file %s not found'", ",", "file", ")", ";", "return", "done", "(", ")", ";", "}", "return", "done", "(", "err", ")", ";", "}", "debug", "(", "'mtime of file %s is %s'", ",", "file", ",", "stats", ".", "mtime", ")", ";", "files", "[", "file", "]", ".", "mtime", "=", "stats", ".", "mtime", ";", "done", "(", ")", ";", "}" ]
Adds `stats.mtime` of `file` to its metadata. @param {Error} err @param {fs.Stats} stats @api private
[ "Adds", "stats", ".", "mtime", "of", "file", "to", "its", "metadata", "." ]
0e7022e82b32f11044da4253833addd26bcdf478
https://github.com/jkuczm/metalsmith-mtime/blob/0e7022e82b32f11044da4253833addd26bcdf478/lib/index.js#L67-L82
50,593
alexpods/ClazzJS
src/components/meta/Property/Type.js
function(object, type, property) { var self = this; object.__addSetter(property, this.SETTER_NAME, this.SETTER_WEIGHT, function(value, fields) { var fieldsType = type || {}; for (var i = 0, ii = fields.length; i < ii; ++i) { var params = fieldsType[1] || {}; if (!('element' in params)) { return value; } fieldsType = params.element; } return self.apply(value, fieldsType, property, fields, object); }); }
javascript
function(object, type, property) { var self = this; object.__addSetter(property, this.SETTER_NAME, this.SETTER_WEIGHT, function(value, fields) { var fieldsType = type || {}; for (var i = 0, ii = fields.length; i < ii; ++i) { var params = fieldsType[1] || {}; if (!('element' in params)) { return value; } fieldsType = params.element; } return self.apply(value, fieldsType, property, fields, object); }); }
[ "function", "(", "object", ",", "type", ",", "property", ")", "{", "var", "self", "=", "this", ";", "object", ".", "__addSetter", "(", "property", ",", "this", ".", "SETTER_NAME", ",", "this", ".", "SETTER_WEIGHT", ",", "function", "(", "value", ",", "fields", ")", "{", "var", "fieldsType", "=", "type", "||", "{", "}", ";", "for", "(", "var", "i", "=", "0", ",", "ii", "=", "fields", ".", "length", ";", "i", "<", "ii", ";", "++", "i", ")", "{", "var", "params", "=", "fieldsType", "[", "1", "]", "||", "{", "}", ";", "if", "(", "!", "(", "'element'", "in", "params", ")", ")", "{", "return", "value", ";", "}", "fieldsType", "=", "params", ".", "element", ";", "}", "return", "self", ".", "apply", "(", "value", ",", "fieldsType", ",", "property", ",", "fields", ",", "object", ")", ";", "}", ")", ";", "}" ]
Add property setter which checks and converts property value according to its type @param {object} object Some object @param {string} type Property type @param {string} property Property name @this {metaProcessor}
[ "Add", "property", "setter", "which", "checks", "and", "converts", "property", "value", "according", "to", "its", "type" ]
2f94496019669813c8246d48fcceb12a3e68a870
https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Property/Type.js#L24-L44
50,594
alexpods/ClazzJS
src/components/meta/Property/Type.js
function(value, type, property, fields, object) { if (_.isUndefined(value) || _.isNull(value)) { return value; } var params = {}; if (_.isArray(type)) { params = type[1] || {}; type = type[0]; } if (!(type in this._types)) { throw new Error('Property type "' + type + '" does not exist!'); } return this._types[type].call(this, value, params, property, fields, object); }
javascript
function(value, type, property, fields, object) { if (_.isUndefined(value) || _.isNull(value)) { return value; } var params = {}; if (_.isArray(type)) { params = type[1] || {}; type = type[0]; } if (!(type in this._types)) { throw new Error('Property type "' + type + '" does not exist!'); } return this._types[type].call(this, value, params, property, fields, object); }
[ "function", "(", "value", ",", "type", ",", "property", ",", "fields", ",", "object", ")", "{", "if", "(", "_", ".", "isUndefined", "(", "value", ")", "||", "_", ".", "isNull", "(", "value", ")", ")", "{", "return", "value", ";", "}", "var", "params", "=", "{", "}", ";", "if", "(", "_", ".", "isArray", "(", "type", ")", ")", "{", "params", "=", "type", "[", "1", "]", "||", "{", "}", ";", "type", "=", "type", "[", "0", "]", ";", "}", "if", "(", "!", "(", "type", "in", "this", ".", "_types", ")", ")", "{", "throw", "new", "Error", "(", "'Property type \"'", "+", "type", "+", "'\" does not exist!'", ")", ";", "}", "return", "this", ".", "_types", "[", "type", "]", ".", "call", "(", "this", ",", "value", ",", "params", ",", "property", ",", "fields", ",", "object", ")", ";", "}" ]
Check and converts property value according to its type @param {*} value Property value @param {string} type Property type @param {string} property Property name @param {array} fields Property fields @param {object} object Object to which property belongs @throws {Error} if specified property type does not exist @this {metaProcessor}
[ "Check", "and", "converts", "property", "value", "according", "to", "its", "type" ]
2f94496019669813c8246d48fcceb12a3e68a870
https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Property/Type.js#L59-L75
50,595
alexpods/ClazzJS
src/components/meta/Property/Type.js
function(delimiter) { if (!_.isString(delimiter) && !_.isRegExp(delimiter)) { throw new Error('Delimiter must be a string or a regular expression!'); } this._defaultArrayDelimiter = delimiter; return this; }
javascript
function(delimiter) { if (!_.isString(delimiter) && !_.isRegExp(delimiter)) { throw new Error('Delimiter must be a string or a regular expression!'); } this._defaultArrayDelimiter = delimiter; return this; }
[ "function", "(", "delimiter", ")", "{", "if", "(", "!", "_", ".", "isString", "(", "delimiter", ")", "&&", "!", "_", ".", "isRegExp", "(", "delimiter", ")", ")", "{", "throw", "new", "Error", "(", "'Delimiter must be a string or a regular expression!'", ")", ";", "}", "this", ".", "_defaultArrayDelimiter", "=", "delimiter", ";", "return", "this", ";", "}" ]
Sets default array delimiter @param {string} delimiter Array delimiter @returns {metaProcessor} this @throws {Error} if delimiter is not a string @this {metaProcessor}
[ "Sets", "default", "array", "delimiter" ]
2f94496019669813c8246d48fcceb12a3e68a870
https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Property/Type.js#L136-L142
50,596
alexpods/ClazzJS
src/components/meta/Property/Type.js
function(value, params, property) { value = +value; if ('min' in params && value < params.min) { throw new Error('Value "' + value + '" of property "' + property + '" must not be less then "' + params.min + '"!'); } if ('max' in params && value > params.max) { throw new Error('Value "' + value + '" of property "' + property + '" must not be greater then "' + params.max + '"!'); } return value; }
javascript
function(value, params, property) { value = +value; if ('min' in params && value < params.min) { throw new Error('Value "' + value + '" of property "' + property + '" must not be less then "' + params.min + '"!'); } if ('max' in params && value > params.max) { throw new Error('Value "' + value + '" of property "' + property + '" must not be greater then "' + params.max + '"!'); } return value; }
[ "function", "(", "value", ",", "params", ",", "property", ")", "{", "value", "=", "+", "value", ";", "if", "(", "'min'", "in", "params", "&&", "value", "<", "params", ".", "min", ")", "{", "throw", "new", "Error", "(", "'Value \"'", "+", "value", "+", "'\" of property \"'", "+", "property", "+", "'\" must not be less then \"'", "+", "params", ".", "min", "+", "'\"!'", ")", ";", "}", "if", "(", "'max'", "in", "params", "&&", "value", ">", "params", ".", "max", ")", "{", "throw", "new", "Error", "(", "'Value \"'", "+", "value", "+", "'\" of property \"'", "+", "property", "+", "'\" must not be greater then \"'", "+", "params", ".", "max", "+", "'\"!'", ")", ";", "}", "return", "value", ";", "}" ]
Number property type Converts value to number, applies 'min' and 'max' parameters @param {*} value Property value @param {object} params Property parameters @param {string} property Property name @throws {Error} if value less then 'min' parameter @throws {Error} if value greater then 'max' parameter @returns {number} Processed property value @this {metaProcessor}
[ "Number", "property", "type", "Converts", "value", "to", "number", "applies", "min", "and", "max", "parameters" ]
2f94496019669813c8246d48fcceb12a3e68a870
https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Property/Type.js#L189-L201
50,597
alexpods/ClazzJS
src/components/meta/Property/Type.js
function(value, params, property) { value = ''+value; if ('pattern' in params && !params.pattern.test(value)) { throw new Error('Value "' + value + '" of property "' + property + '" does not match pattern "' + params.pattern + '"!'); } if ('variants' in params && -1 === params.variants.indexOf(value)) { throw new Error('Value "' + value + '" of property "' + property + '" must be one of "' + params.variants.join(', ') + '"!'); } return value; }
javascript
function(value, params, property) { value = ''+value; if ('pattern' in params && !params.pattern.test(value)) { throw new Error('Value "' + value + '" of property "' + property + '" does not match pattern "' + params.pattern + '"!'); } if ('variants' in params && -1 === params.variants.indexOf(value)) { throw new Error('Value "' + value + '" of property "' + property + '" must be one of "' + params.variants.join(', ') + '"!'); } return value; }
[ "function", "(", "value", ",", "params", ",", "property", ")", "{", "value", "=", "''", "+", "value", ";", "if", "(", "'pattern'", "in", "params", "&&", "!", "params", ".", "pattern", ".", "test", "(", "value", ")", ")", "{", "throw", "new", "Error", "(", "'Value \"'", "+", "value", "+", "'\" of property \"'", "+", "property", "+", "'\" does not match pattern \"'", "+", "params", ".", "pattern", "+", "'\"!'", ")", ";", "}", "if", "(", "'variants'", "in", "params", "&&", "-", "1", "===", "params", ".", "variants", ".", "indexOf", "(", "value", ")", ")", "{", "throw", "new", "Error", "(", "'Value \"'", "+", "value", "+", "'\" of property \"'", "+", "property", "+", "'\" must be one of \"'", "+", "params", ".", "variants", ".", "join", "(", "', '", ")", "+", "'\"!'", ")", ";", "}", "return", "value", ";", "}" ]
String property type Converts value to string, applies 'pattern' and 'variants' parameters @param {*} value Property value @param {object} params Property parameters @param {string} property Property name @throws {Error} if value does not match 'pattern' @throws {Error} if value does not one of 'variants' values @returns {string} Processed property value @this {metaProcessor}
[ "String", "property", "type", "Converts", "value", "to", "string", "applies", "pattern", "and", "variants", "parameters" ]
2f94496019669813c8246d48fcceb12a3e68a870
https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Property/Type.js#L218-L230
50,598
alexpods/ClazzJS
src/components/meta/Property/Type.js
function(value, params, property) { if (_.isNumber(value) && !isNaN(value)) { value = new Date(value); } else if (_.isString(value)) { value = new Date(Date.parse(value)); } if (!(value instanceof Date)) { throw new Error('Value of property "' + property + '" must have datetime type!'); } return value; }
javascript
function(value, params, property) { if (_.isNumber(value) && !isNaN(value)) { value = new Date(value); } else if (_.isString(value)) { value = new Date(Date.parse(value)); } if (!(value instanceof Date)) { throw new Error('Value of property "' + property + '" must have datetime type!'); } return value; }
[ "function", "(", "value", ",", "params", ",", "property", ")", "{", "if", "(", "_", ".", "isNumber", "(", "value", ")", "&&", "!", "isNaN", "(", "value", ")", ")", "{", "value", "=", "new", "Date", "(", "value", ")", ";", "}", "else", "if", "(", "_", ".", "isString", "(", "value", ")", ")", "{", "value", "=", "new", "Date", "(", "Date", ".", "parse", "(", "value", ")", ")", ";", "}", "if", "(", "!", "(", "value", "instanceof", "Date", ")", ")", "{", "throw", "new", "Error", "(", "'Value of property \"'", "+", "property", "+", "'\" must have datetime type!'", ")", ";", "}", "return", "value", ";", "}" ]
Datetime property type Converts value to Date @param {*} value Property value @param {object} params Property parameters @param {string} property Property name @throws {Error} if value could not be successfully converted to Date @returns {Date} Processed property value @this {metaProcessor}
[ "Datetime", "property", "type", "Converts", "value", "to", "Date" ]
2f94496019669813c8246d48fcceb12a3e68a870
https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Property/Type.js#L246-L259
50,599
alexpods/ClazzJS
src/components/meta/Property/Type.js
function(value, params, property, fields, object) { if (_.isString(value)) { value = value.split(params.delimiter || this._defaultArrayDelimiter); } if ('element' in params) { for (var i = 0, ii = value.length; i < ii; ++i) { value[i] = this.apply(value[i], params.element, property, fields.concat(i), object); } } return value; }
javascript
function(value, params, property, fields, object) { if (_.isString(value)) { value = value.split(params.delimiter || this._defaultArrayDelimiter); } if ('element' in params) { for (var i = 0, ii = value.length; i < ii; ++i) { value[i] = this.apply(value[i], params.element, property, fields.concat(i), object); } } return value; }
[ "function", "(", "value", ",", "params", ",", "property", ",", "fields", ",", "object", ")", "{", "if", "(", "_", ".", "isString", "(", "value", ")", ")", "{", "value", "=", "value", ".", "split", "(", "params", ".", "delimiter", "||", "this", ".", "_defaultArrayDelimiter", ")", ";", "}", "if", "(", "'element'", "in", "params", ")", "{", "for", "(", "var", "i", "=", "0", ",", "ii", "=", "value", ".", "length", ";", "i", "<", "ii", ";", "++", "i", ")", "{", "value", "[", "i", "]", "=", "this", ".", "apply", "(", "value", "[", "i", "]", ",", "params", ".", "element", ",", "property", ",", "fields", ".", "concat", "(", "i", ")", ",", "object", ")", ";", "}", "}", "return", "value", ";", "}" ]
Array property type Converts value to array, applies 'element' parameter @param {*} value Property value @param {object} params Property parameters @param {string} property Property name @param {array} fields Property fields @param {object} object Object to which property belongs @returns {array} Processed property value @this {metaProcessor}
[ "Array", "property", "type", "Converts", "value", "to", "array", "applies", "element", "parameter" ]
2f94496019669813c8246d48fcceb12a3e68a870
https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Property/Type.js#L275-L288