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
57,800
camshaft/anvil-cli
lib/local.js
statFiles
function statFiles(files, source, fn) { var batch = new Batch(); files.forEach(function(file) { batch.push(statFile(file, source)); }); batch.end(fn); }
javascript
function statFiles(files, source, fn) { var batch = new Batch(); files.forEach(function(file) { batch.push(statFile(file, source)); }); batch.end(fn); }
[ "function", "statFiles", "(", "files", ",", "source", ",", "fn", ")", "{", "var", "batch", "=", "new", "Batch", "(", ")", ";", "files", ".", "forEach", "(", "function", "(", "file", ")", "{", "batch", ".", "push", "(", "statFile", "(", "file", ",", "source", ")", ")", ";", "}", ")", ";", "batch", ".", "end", "(", "fn", ")", ";", "}" ]
Get files info @param {Array} files @param {String} source @param {Function} fn
[ "Get", "files", "info" ]
5930e2165698c5577a0bcfa471dd521089acfb78
https://github.com/camshaft/anvil-cli/blob/5930e2165698c5577a0bcfa471dd521089acfb78/lib/local.js#L147-L155
57,801
camshaft/anvil-cli
lib/local.js
statFile
function statFile(file, source) { return function(cb) { var abs = join(source, file); stat(abs, function(err, stats) { if (err) return cb(err); var manifest = { name: file, abs: abs, mtime: Math.floor(stats.mtime.getTime() / 1000), mode: '' + parseInt(stats.mode.toString(8), 10), size: '' + stats.size // do we need this? }; if (stats.isDirectory()) return cb(); if (stats.isSymbolicLink()) return fs.readlink(abs, finish('link')); calculateHash(abs, finish('hash')); function finish(key) { return function(err, val) { if (err) return cb(err); manifest[key] = val; cb(null, manifest); }; } }); }; }
javascript
function statFile(file, source) { return function(cb) { var abs = join(source, file); stat(abs, function(err, stats) { if (err) return cb(err); var manifest = { name: file, abs: abs, mtime: Math.floor(stats.mtime.getTime() / 1000), mode: '' + parseInt(stats.mode.toString(8), 10), size: '' + stats.size // do we need this? }; if (stats.isDirectory()) return cb(); if (stats.isSymbolicLink()) return fs.readlink(abs, finish('link')); calculateHash(abs, finish('hash')); function finish(key) { return function(err, val) { if (err) return cb(err); manifest[key] = val; cb(null, manifest); }; } }); }; }
[ "function", "statFile", "(", "file", ",", "source", ")", "{", "return", "function", "(", "cb", ")", "{", "var", "abs", "=", "join", "(", "source", ",", "file", ")", ";", "stat", "(", "abs", ",", "function", "(", "err", ",", "stats", ")", "{", "if", "(", "err", ")", "return", "cb", "(", "err", ")", ";", "var", "manifest", "=", "{", "name", ":", "file", ",", "abs", ":", "abs", ",", "mtime", ":", "Math", ".", "floor", "(", "stats", ".", "mtime", ".", "getTime", "(", ")", "/", "1000", ")", ",", "mode", ":", "''", "+", "parseInt", "(", "stats", ".", "mode", ".", "toString", "(", "8", ")", ",", "10", ")", ",", "size", ":", "''", "+", "stats", ".", "size", "// do we need this?", "}", ";", "if", "(", "stats", ".", "isDirectory", "(", ")", ")", "return", "cb", "(", ")", ";", "if", "(", "stats", ".", "isSymbolicLink", "(", ")", ")", "return", "fs", ".", "readlink", "(", "abs", ",", "finish", "(", "'link'", ")", ")", ";", "calculateHash", "(", "abs", ",", "finish", "(", "'hash'", ")", ")", ";", "function", "finish", "(", "key", ")", "{", "return", "function", "(", "err", ",", "val", ")", "{", "if", "(", "err", ")", "return", "cb", "(", "err", ")", ";", "manifest", "[", "key", "]", "=", "val", ";", "cb", "(", "null", ",", "manifest", ")", ";", "}", ";", "}", "}", ")", ";", "}", ";", "}" ]
Get a file manifest @param {String} file @param {String} source @return {Function}
[ "Get", "a", "file", "manifest" ]
5930e2165698c5577a0bcfa471dd521089acfb78
https://github.com/camshaft/anvil-cli/blob/5930e2165698c5577a0bcfa471dd521089acfb78/lib/local.js#L165-L192
57,802
camshaft/anvil-cli
lib/local.js
calculateHash
function calculateHash(file, fn) { read(file, function(err, bin) { if (err) return fn(err); fn(null, hash('sha256').update(bin).digest('hex')); }); }
javascript
function calculateHash(file, fn) { read(file, function(err, bin) { if (err) return fn(err); fn(null, hash('sha256').update(bin).digest('hex')); }); }
[ "function", "calculateHash", "(", "file", ",", "fn", ")", "{", "read", "(", "file", ",", "function", "(", "err", ",", "bin", ")", "{", "if", "(", "err", ")", "return", "fn", "(", "err", ")", ";", "fn", "(", "null", ",", "hash", "(", "'sha256'", ")", ".", "update", "(", "bin", ")", ".", "digest", "(", "'hex'", ")", ")", ";", "}", ")", ";", "}" ]
Calculate hash for a file @param {String} file @param {Function} fn
[ "Calculate", "hash", "for", "a", "file" ]
5930e2165698c5577a0bcfa471dd521089acfb78
https://github.com/camshaft/anvil-cli/blob/5930e2165698c5577a0bcfa471dd521089acfb78/lib/local.js#L201-L206
57,803
camshaft/anvil-cli
lib/local.js
normalizeManifest
function normalizeManifest(manifest, fn) { var obj = {}; manifest.forEach(function(file) { if (!file) return; obj[file.name] = { mtime: file.mtime, mode: file.mode, size: file.size, hash: file.hash, link: file.link }; }); fn(null, obj); }
javascript
function normalizeManifest(manifest, fn) { var obj = {}; manifest.forEach(function(file) { if (!file) return; obj[file.name] = { mtime: file.mtime, mode: file.mode, size: file.size, hash: file.hash, link: file.link }; }); fn(null, obj); }
[ "function", "normalizeManifest", "(", "manifest", ",", "fn", ")", "{", "var", "obj", "=", "{", "}", ";", "manifest", ".", "forEach", "(", "function", "(", "file", ")", "{", "if", "(", "!", "file", ")", "return", ";", "obj", "[", "file", ".", "name", "]", "=", "{", "mtime", ":", "file", ".", "mtime", ",", "mode", ":", "file", ".", "mode", ",", "size", ":", "file", ".", "size", ",", "hash", ":", "file", ".", "hash", ",", "link", ":", "file", ".", "link", "}", ";", "}", ")", ";", "fn", "(", "null", ",", "obj", ")", ";", "}" ]
Normalize the manifest into the expected format @param {Object} manifest @param {Function} fn
[ "Normalize", "the", "manifest", "into", "the", "expected", "format" ]
5930e2165698c5577a0bcfa471dd521089acfb78
https://github.com/camshaft/anvil-cli/blob/5930e2165698c5577a0bcfa471dd521089acfb78/lib/local.js#L215-L228
57,804
camshaft/anvil-cli
lib/local.js
findMissing
function findMissing(manifest, request, host, fn) { request .post(host + '/manifest/diff') .send({manifest: JSON.stringify(manifest)}) .end(function(err, res) { if (err) return fn(err); if (res.error) return fn(res.error); fn(null, res.body); }); }
javascript
function findMissing(manifest, request, host, fn) { request .post(host + '/manifest/diff') .send({manifest: JSON.stringify(manifest)}) .end(function(err, res) { if (err) return fn(err); if (res.error) return fn(res.error); fn(null, res.body); }); }
[ "function", "findMissing", "(", "manifest", ",", "request", ",", "host", ",", "fn", ")", "{", "request", ".", "post", "(", "host", "+", "'/manifest/diff'", ")", ".", "send", "(", "{", "manifest", ":", "JSON", ".", "stringify", "(", "manifest", ")", "}", ")", ".", "end", "(", "function", "(", "err", ",", "res", ")", "{", "if", "(", "err", ")", "return", "fn", "(", "err", ")", ";", "if", "(", "res", ".", "error", ")", "return", "fn", "(", "res", ".", "error", ")", ";", "fn", "(", "null", ",", "res", ".", "body", ")", ";", "}", ")", ";", "}" ]
Find the missing files in the manifest @param {Object} manifest @param {Request} request @param {String} host @param {Function} fn
[ "Find", "the", "missing", "files", "in", "the", "manifest" ]
5930e2165698c5577a0bcfa471dd521089acfb78
https://github.com/camshaft/anvil-cli/blob/5930e2165698c5577a0bcfa471dd521089acfb78/lib/local.js#L239-L248
57,805
camshaft/anvil-cli
lib/local.js
selectMissing
function selectMissing(missing, manifest, fn) { fn(null, manifest.filter(function(file) { return file && ~missing.indexOf(file.hash); })); }
javascript
function selectMissing(missing, manifest, fn) { fn(null, manifest.filter(function(file) { return file && ~missing.indexOf(file.hash); })); }
[ "function", "selectMissing", "(", "missing", ",", "manifest", ",", "fn", ")", "{", "fn", "(", "null", ",", "manifest", ".", "filter", "(", "function", "(", "file", ")", "{", "return", "file", "&&", "~", "missing", ".", "indexOf", "(", "file", ".", "hash", ")", ";", "}", ")", ")", ";", "}" ]
Find the missing files from the manifest @param {Array} missing @param {Array} manifest @param {Function} fn
[ "Find", "the", "missing", "files", "from", "the", "manifest" ]
5930e2165698c5577a0bcfa471dd521089acfb78
https://github.com/camshaft/anvil-cli/blob/5930e2165698c5577a0bcfa471dd521089acfb78/lib/local.js#L258-L262
57,806
camshaft/anvil-cli
lib/local.js
uploadMissing
function uploadMissing(missing, request, host, log, fn) { var batch = new Batch(); missing.forEach(function(file) { batch.push(uploadFile(file, request, host)); }); batch.on('progress', function() { log('.'); }); batch.end(function(err, res) { log(' done\n'); fn(err, res); }); }
javascript
function uploadMissing(missing, request, host, log, fn) { var batch = new Batch(); missing.forEach(function(file) { batch.push(uploadFile(file, request, host)); }); batch.on('progress', function() { log('.'); }); batch.end(function(err, res) { log(' done\n'); fn(err, res); }); }
[ "function", "uploadMissing", "(", "missing", ",", "request", ",", "host", ",", "log", ",", "fn", ")", "{", "var", "batch", "=", "new", "Batch", "(", ")", ";", "missing", ".", "forEach", "(", "function", "(", "file", ")", "{", "batch", ".", "push", "(", "uploadFile", "(", "file", ",", "request", ",", "host", ")", ")", ";", "}", ")", ";", "batch", ".", "on", "(", "'progress'", ",", "function", "(", ")", "{", "log", "(", "'.'", ")", ";", "}", ")", ";", "batch", ".", "end", "(", "function", "(", "err", ",", "res", ")", "{", "log", "(", "' done\\n'", ")", ";", "fn", "(", "err", ",", "res", ")", ";", "}", ")", ";", "}" ]
Upload the missing files to the build server @param {Array} missing @param {Request} request @param {String} host @param {Function} fn
[ "Upload", "the", "missing", "files", "to", "the", "build", "server" ]
5930e2165698c5577a0bcfa471dd521089acfb78
https://github.com/camshaft/anvil-cli/blob/5930e2165698c5577a0bcfa471dd521089acfb78/lib/local.js#L273-L288
57,807
camshaft/anvil-cli
lib/local.js
uploadFile
function uploadFile(file, request, host) { return function(cb) { request .post(host + '/file/' + file.hash) .attach('data', file.abs) .end(function(err, res) { if (err) return cb(err); if (res.error) return cb(res.error); return cb(); }); }; }
javascript
function uploadFile(file, request, host) { return function(cb) { request .post(host + '/file/' + file.hash) .attach('data', file.abs) .end(function(err, res) { if (err) return cb(err); if (res.error) return cb(res.error); return cb(); }); }; }
[ "function", "uploadFile", "(", "file", ",", "request", ",", "host", ")", "{", "return", "function", "(", "cb", ")", "{", "request", ".", "post", "(", "host", "+", "'/file/'", "+", "file", ".", "hash", ")", ".", "attach", "(", "'data'", ",", "file", ".", "abs", ")", ".", "end", "(", "function", "(", "err", ",", "res", ")", "{", "if", "(", "err", ")", "return", "cb", "(", "err", ")", ";", "if", "(", "res", ".", "error", ")", "return", "cb", "(", "res", ".", "error", ")", ";", "return", "cb", "(", ")", ";", "}", ")", ";", "}", ";", "}" ]
Upload a single file to the build server @param {String} file @param {Request} request @param {String} host @return {Function}
[ "Upload", "a", "single", "file", "to", "the", "build", "server" ]
5930e2165698c5577a0bcfa471dd521089acfb78
https://github.com/camshaft/anvil-cli/blob/5930e2165698c5577a0bcfa471dd521089acfb78/lib/local.js#L299-L310
57,808
camshaft/anvil-cli
lib/local.js
saveManifest
function saveManifest(manifest, request, host, fn) { request .post(host + '/manifest') .send({manifest: JSON.stringify(manifest)}) .end(function(err, res) { if (err) return fn(err); if (res.error) return fn(res.error); fn(null, res.headers.location); }); }
javascript
function saveManifest(manifest, request, host, fn) { request .post(host + '/manifest') .send({manifest: JSON.stringify(manifest)}) .end(function(err, res) { if (err) return fn(err); if (res.error) return fn(res.error); fn(null, res.headers.location); }); }
[ "function", "saveManifest", "(", "manifest", ",", "request", ",", "host", ",", "fn", ")", "{", "request", ".", "post", "(", "host", "+", "'/manifest'", ")", ".", "send", "(", "{", "manifest", ":", "JSON", ".", "stringify", "(", "manifest", ")", "}", ")", ".", "end", "(", "function", "(", "err", ",", "res", ")", "{", "if", "(", "err", ")", "return", "fn", "(", "err", ")", ";", "if", "(", "res", ".", "error", ")", "return", "fn", "(", "res", ".", "error", ")", ";", "fn", "(", "null", ",", "res", ".", "headers", ".", "location", ")", ";", "}", ")", ";", "}" ]
Save the manifest file to the build server @param {Object} manifest @param {Request} request @param {String} host @param {Function} fn
[ "Save", "the", "manifest", "file", "to", "the", "build", "server" ]
5930e2165698c5577a0bcfa471dd521089acfb78
https://github.com/camshaft/anvil-cli/blob/5930e2165698c5577a0bcfa471dd521089acfb78/lib/local.js#L321-L330
57,809
yanhick/middlebot
lib/index.js
use
function use(type) { // Convert args to array. var args = Array.prototype.slice.call(arguments); // Check if type not provided. if ('string' !== typeof type && type instanceof Array === false) { type = []; } else { if ('string' === typeof type) { //wrap string in array to homogenize handling type = [type]; } args.shift(); } args.forEach(function(arg){ stack.push({type: type, cb: arg}); }); return middlebot; }
javascript
function use(type) { // Convert args to array. var args = Array.prototype.slice.call(arguments); // Check if type not provided. if ('string' !== typeof type && type instanceof Array === false) { type = []; } else { if ('string' === typeof type) { //wrap string in array to homogenize handling type = [type]; } args.shift(); } args.forEach(function(arg){ stack.push({type: type, cb: arg}); }); return middlebot; }
[ "function", "use", "(", "type", ")", "{", "// Convert args to array.", "var", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ")", ";", "// Check if type not provided.", "if", "(", "'string'", "!==", "typeof", "type", "&&", "type", "instanceof", "Array", "===", "false", ")", "{", "type", "=", "[", "]", ";", "}", "else", "{", "if", "(", "'string'", "===", "typeof", "type", ")", "{", "//wrap string in array to homogenize handling", "type", "=", "[", "type", "]", ";", "}", "args", ".", "shift", "(", ")", ";", "}", "args", ".", "forEach", "(", "function", "(", "arg", ")", "{", "stack", ".", "push", "(", "{", "type", ":", "type", ",", "cb", ":", "arg", "}", ")", ";", "}", ")", ";", "return", "middlebot", ";", "}" ]
Add a middleware in the stack for the given type. @param {*} type the handler type where to use the middleware. If not provided, middleware is always used. Can be either a string or an array of string @param {function} middlewares @returns the middlebot instance
[ "Add", "a", "middleware", "in", "the", "stack", "for", "the", "given", "type", "." ]
1920d56c0f4b162d892b8b7f70df575875bc943c
https://github.com/yanhick/middlebot/blob/1920d56c0f4b162d892b8b7f70df575875bc943c/lib/index.js#L29-L49
57,810
yanhick/middlebot
lib/index.js
handle
function handle(type, req, res, out) { var index = 0; var ended = false; // When called stop middlewares execution. res.end = end; // Handle next middleware in stack. function next(err) { var middleware = stack[index++]; // No more middlewares or early end. if (!middleware || ended) { if (out) out(err, req, res); return; } // Check if middleware type matches or if it has no type. if (middleware.type.indexOf(type) === -1 && middleware.type.length > 0) return next(err); try { var arity = middleware.cb.length; //if err, only execute error middlewares if (err) { //error middlewares have an arity of 4, the first //arg being the error if (arity === 4) { middleware.cb(err, req, res, next); } else { next(err); } } else if (arity < 4) { middleware.cb(req, res, next); } else { next(); } } catch (e) { next(e); } } // Stop middlewares execution. function end() { ended = true; } // Start handling. next(); }
javascript
function handle(type, req, res, out) { var index = 0; var ended = false; // When called stop middlewares execution. res.end = end; // Handle next middleware in stack. function next(err) { var middleware = stack[index++]; // No more middlewares or early end. if (!middleware || ended) { if (out) out(err, req, res); return; } // Check if middleware type matches or if it has no type. if (middleware.type.indexOf(type) === -1 && middleware.type.length > 0) return next(err); try { var arity = middleware.cb.length; //if err, only execute error middlewares if (err) { //error middlewares have an arity of 4, the first //arg being the error if (arity === 4) { middleware.cb(err, req, res, next); } else { next(err); } } else if (arity < 4) { middleware.cb(req, res, next); } else { next(); } } catch (e) { next(e); } } // Stop middlewares execution. function end() { ended = true; } // Start handling. next(); }
[ "function", "handle", "(", "type", ",", "req", ",", "res", ",", "out", ")", "{", "var", "index", "=", "0", ";", "var", "ended", "=", "false", ";", "// When called stop middlewares execution.", "res", ".", "end", "=", "end", ";", "// Handle next middleware in stack.", "function", "next", "(", "err", ")", "{", "var", "middleware", "=", "stack", "[", "index", "++", "]", ";", "// No more middlewares or early end.", "if", "(", "!", "middleware", "||", "ended", ")", "{", "if", "(", "out", ")", "out", "(", "err", ",", "req", ",", "res", ")", ";", "return", ";", "}", "// Check if middleware type matches or if it has no type.", "if", "(", "middleware", ".", "type", ".", "indexOf", "(", "type", ")", "===", "-", "1", "&&", "middleware", ".", "type", ".", "length", ">", "0", ")", "return", "next", "(", "err", ")", ";", "try", "{", "var", "arity", "=", "middleware", ".", "cb", ".", "length", ";", "//if err, only execute error middlewares", "if", "(", "err", ")", "{", "//error middlewares have an arity of 4, the first", "//arg being the error", "if", "(", "arity", "===", "4", ")", "{", "middleware", ".", "cb", "(", "err", ",", "req", ",", "res", ",", "next", ")", ";", "}", "else", "{", "next", "(", "err", ")", ";", "}", "}", "else", "if", "(", "arity", "<", "4", ")", "{", "middleware", ".", "cb", "(", "req", ",", "res", ",", "next", ")", ";", "}", "else", "{", "next", "(", ")", ";", "}", "}", "catch", "(", "e", ")", "{", "next", "(", "e", ")", ";", "}", "}", "// Stop middlewares execution.", "function", "end", "(", ")", "{", "ended", "=", "true", ";", "}", "// Start handling.", "next", "(", ")", ";", "}" ]
Handle all middlewares of the provided type. @param {string} type the middleware type to handle @param {Object} req request object @param {Object} res response object @param {function} out optional function to be called once all middleware have been handled @returns the middlebot instance
[ "Handle", "all", "middlewares", "of", "the", "provided", "type", "." ]
1920d56c0f4b162d892b8b7f70df575875bc943c
https://github.com/yanhick/middlebot/blob/1920d56c0f4b162d892b8b7f70df575875bc943c/lib/index.js#L65-L115
57,811
readwritetools/rwserve-plugin-sdk
dist/expect.function.js
writeToConsoleOrStderr
function writeToConsoleOrStderr(message) { if (typeof console == 'object' && typeof console.warn == 'function') console.warn(message); else if (typeof process == 'object' && typeof process.stderr == 'object' && typeof process.stderr.write == 'function') process.stderr.write(message); else throw new Error(message); }
javascript
function writeToConsoleOrStderr(message) { if (typeof console == 'object' && typeof console.warn == 'function') console.warn(message); else if (typeof process == 'object' && typeof process.stderr == 'object' && typeof process.stderr.write == 'function') process.stderr.write(message); else throw new Error(message); }
[ "function", "writeToConsoleOrStderr", "(", "message", ")", "{", "if", "(", "typeof", "console", "==", "'object'", "&&", "typeof", "console", ".", "warn", "==", "'function'", ")", "console", ".", "warn", "(", "message", ")", ";", "else", "if", "(", "typeof", "process", "==", "'object'", "&&", "typeof", "process", ".", "stderr", "==", "'object'", "&&", "typeof", "process", ".", "stderr", ".", "write", "==", "'function'", ")", "process", ".", "stderr", ".", "write", "(", "message", ")", ";", "else", "throw", "new", "Error", "(", "message", ")", ";", "}" ]
^ Send message to browser console or CLI stderr
[ "^", "Send", "message", "to", "browser", "console", "or", "CLI", "stderr" ]
7f3b86b4d5279e26306225983c3d7f382f69dcce
https://github.com/readwritetools/rwserve-plugin-sdk/blob/7f3b86b4d5279e26306225983c3d7f382f69dcce/dist/expect.function.js#L90-L97
57,812
frisb/fdboost
lib/enhance/encoding/typecodes.js
function(value) { switch (typeof value) { case 'undefined': return this.undefined; case 'string': return this.string; case 'number': if (value % 1 === 0) { return this.integer; } else { return this.double; } break; case 'boolean': return this.boolean; case 'function': return this["function"]; default: if (value === null) { return this["null"]; } else if (value instanceof Date) { return this.datetime; } else if (value instanceof Array) { return this.array; } else if (Buffer.isBuffer(value)) { throw new TypeError("Value cannot be a buffer"); } else if (value instanceof Object) { return this.object; } else { throw new TypeError('Value must either be a string, integer, double, boolean, date, array, object or function'); } } }
javascript
function(value) { switch (typeof value) { case 'undefined': return this.undefined; case 'string': return this.string; case 'number': if (value % 1 === 0) { return this.integer; } else { return this.double; } break; case 'boolean': return this.boolean; case 'function': return this["function"]; default: if (value === null) { return this["null"]; } else if (value instanceof Date) { return this.datetime; } else if (value instanceof Array) { return this.array; } else if (Buffer.isBuffer(value)) { throw new TypeError("Value cannot be a buffer"); } else if (value instanceof Object) { return this.object; } else { throw new TypeError('Value must either be a string, integer, double, boolean, date, array, object or function'); } } }
[ "function", "(", "value", ")", "{", "switch", "(", "typeof", "value", ")", "{", "case", "'undefined'", ":", "return", "this", ".", "undefined", ";", "case", "'string'", ":", "return", "this", ".", "string", ";", "case", "'number'", ":", "if", "(", "value", "%", "1", "===", "0", ")", "{", "return", "this", ".", "integer", ";", "}", "else", "{", "return", "this", ".", "double", ";", "}", "break", ";", "case", "'boolean'", ":", "return", "this", ".", "boolean", ";", "case", "'function'", ":", "return", "this", "[", "\"function\"", "]", ";", "default", ":", "if", "(", "value", "===", "null", ")", "{", "return", "this", "[", "\"null\"", "]", ";", "}", "else", "if", "(", "value", "instanceof", "Date", ")", "{", "return", "this", ".", "datetime", ";", "}", "else", "if", "(", "value", "instanceof", "Array", ")", "{", "return", "this", ".", "array", ";", "}", "else", "if", "(", "Buffer", ".", "isBuffer", "(", "value", ")", ")", "{", "throw", "new", "TypeError", "(", "\"Value cannot be a buffer\"", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Object", ")", "{", "return", "this", ".", "object", ";", "}", "else", "{", "throw", "new", "TypeError", "(", "'Value must either be a string, integer, double, boolean, date, array, object or function'", ")", ";", "}", "}", "}" ]
Gets type code value for name. @method @param {string} value Value to test type for. @return {integer} Type code value
[ "Gets", "type", "code", "value", "for", "name", "." ]
66cfb6552940aa92f35dbb1cf4d0695d842205c2
https://github.com/frisb/fdboost/blob/66cfb6552940aa92f35dbb1cf4d0695d842205c2/lib/enhance/encoding/typecodes.js#L36-L68
57,813
tmpfs/manual
index.js
preamble
function preamble(opts) { var str = ''; var index = opts.section || SECTION; var date = opts.date || new Date().toISOString(); var version = opts.version || '1.0'; // section name var sname = section(index); var title = opts.title || opts.name; if(!title) { throw new TypeError('manual preamble requires a name or title'); } // use comment if(opts.comment) { str += util.format(elements.comment, opts.comment); } //console.dir(title) str += util.format( elements.th, strip(title.toUpperCase()), index, date, (strip(opts.name || title)).replace(/\s+.*$/, '') + ' ' + version, sname); // add name section if(opts.name) { var name = strip(opts.name); str += util.format(elements.sh, header(constants.NAME)); if(opts.description) { str += util.format('%s \\- %s' + EOL, name, opts.description); }else{ str += util.format('%s' + EOL, name); } } return str; }
javascript
function preamble(opts) { var str = ''; var index = opts.section || SECTION; var date = opts.date || new Date().toISOString(); var version = opts.version || '1.0'; // section name var sname = section(index); var title = opts.title || opts.name; if(!title) { throw new TypeError('manual preamble requires a name or title'); } // use comment if(opts.comment) { str += util.format(elements.comment, opts.comment); } //console.dir(title) str += util.format( elements.th, strip(title.toUpperCase()), index, date, (strip(opts.name || title)).replace(/\s+.*$/, '') + ' ' + version, sname); // add name section if(opts.name) { var name = strip(opts.name); str += util.format(elements.sh, header(constants.NAME)); if(opts.description) { str += util.format('%s \\- %s' + EOL, name, opts.description); }else{ str += util.format('%s' + EOL, name); } } return str; }
[ "function", "preamble", "(", "opts", ")", "{", "var", "str", "=", "''", ";", "var", "index", "=", "opts", ".", "section", "||", "SECTION", ";", "var", "date", "=", "opts", ".", "date", "||", "new", "Date", "(", ")", ".", "toISOString", "(", ")", ";", "var", "version", "=", "opts", ".", "version", "||", "'1.0'", ";", "// section name", "var", "sname", "=", "section", "(", "index", ")", ";", "var", "title", "=", "opts", ".", "title", "||", "opts", ".", "name", ";", "if", "(", "!", "title", ")", "{", "throw", "new", "TypeError", "(", "'manual preamble requires a name or title'", ")", ";", "}", "// use comment", "if", "(", "opts", ".", "comment", ")", "{", "str", "+=", "util", ".", "format", "(", "elements", ".", "comment", ",", "opts", ".", "comment", ")", ";", "}", "//console.dir(title)", "str", "+=", "util", ".", "format", "(", "elements", ".", "th", ",", "strip", "(", "title", ".", "toUpperCase", "(", ")", ")", ",", "index", ",", "date", ",", "(", "strip", "(", "opts", ".", "name", "||", "title", ")", ")", ".", "replace", "(", "/", "\\s+.*$", "/", ",", "''", ")", "+", "' '", "+", "version", ",", "sname", ")", ";", "// add name section", "if", "(", "opts", ".", "name", ")", "{", "var", "name", "=", "strip", "(", "opts", ".", "name", ")", ";", "str", "+=", "util", ".", "format", "(", "elements", ".", "sh", ",", "header", "(", "constants", ".", "NAME", ")", ")", ";", "if", "(", "opts", ".", "description", ")", "{", "str", "+=", "util", ".", "format", "(", "'%s \\\\- %s'", "+", "EOL", ",", "name", ",", "opts", ".", "description", ")", ";", "}", "else", "{", "str", "+=", "util", ".", "format", "(", "'%s'", "+", "EOL", ",", "name", ")", ";", "}", "}", "return", "str", ";", "}" ]
Gets the preamble for a man page. @param options The preamble options. @param options.title The document title. @param options.version A version number. @param options.date Document generation date. @param options.section The man section number (1-8). @param options.comment A comment string. @param options.name A name that indicates the name section should be added. @param options.description A short description to go aside the name.
[ "Gets", "the", "preamble", "for", "a", "man", "page", "." ]
5a869c4c49e18f7014969eec529ec9e9c9d7ba05
https://github.com/tmpfs/manual/blob/5a869c4c49e18f7014969eec529ec9e9c9d7ba05/index.js#L111-L147
57,814
CCISEL/connect-controller
lib/RouteInfo.js
splitActionName
function splitActionName(actionName) { if(actionName.indexOf('_') > 0) return actionName.split('_') else return actionName.split(/(?=[A-Z])/).map(p => p.toLowerCase()) }
javascript
function splitActionName(actionName) { if(actionName.indexOf('_') > 0) return actionName.split('_') else return actionName.split(/(?=[A-Z])/).map(p => p.toLowerCase()) }
[ "function", "splitActionName", "(", "actionName", ")", "{", "if", "(", "actionName", ".", "indexOf", "(", "'_'", ")", ">", "0", ")", "return", "actionName", ".", "split", "(", "'_'", ")", "else", "return", "actionName", ".", "split", "(", "/", "(?=[A-Z])", "/", ")", ".", "map", "(", "p", "=>", "p", ".", "toLowerCase", "(", ")", ")", "}" ]
Returns an array with the action's name split by underscores or lowerCamelCase.
[ "Returns", "an", "array", "with", "the", "action", "s", "name", "split", "by", "underscores", "or", "lowerCamelCase", "." ]
c8e2587c5a31e3cb54e3668c4b98b7b7526d69b4
https://github.com/CCISEL/connect-controller/blob/c8e2587c5a31e3cb54e3668c4b98b7b7526d69b4/lib/RouteInfo.js#L163-L166
57,815
CCISEL/connect-controller
lib/RouteInfo.js
parseMethodName
function parseMethodName(parts, argsNames) { /** * argsName could be in different case from that * of function's name. */ const argsNamesLower = argsNames.map(arg => arg.toLowerCase()) /** * Suppresses HTTP method if exists */ if(keysMethods.indexOf(parts[0].toLowerCase()) >= 0) parts = parts.slice(1) /** * Converts each method part into route path */ return parts.reduce((prev, curr) => { if(keywordsMaps[curr]) prev += keywordsMaps[curr] else { if(prev.slice(-1) != '/') prev += '/' const index = argsNamesLower.indexOf(curr.toLowerCase()) if(index >= 0) { prev += ':' prev += argsNames[index] // Preserve argument Case } else { prev += curr } } return prev }, '') }
javascript
function parseMethodName(parts, argsNames) { /** * argsName could be in different case from that * of function's name. */ const argsNamesLower = argsNames.map(arg => arg.toLowerCase()) /** * Suppresses HTTP method if exists */ if(keysMethods.indexOf(parts[0].toLowerCase()) >= 0) parts = parts.slice(1) /** * Converts each method part into route path */ return parts.reduce((prev, curr) => { if(keywordsMaps[curr]) prev += keywordsMaps[curr] else { if(prev.slice(-1) != '/') prev += '/' const index = argsNamesLower.indexOf(curr.toLowerCase()) if(index >= 0) { prev += ':' prev += argsNames[index] // Preserve argument Case } else { prev += curr } } return prev }, '') }
[ "function", "parseMethodName", "(", "parts", ",", "argsNames", ")", "{", "/**\r\n * argsName could be in different case from that\r\n * of function's name.\r\n */", "const", "argsNamesLower", "=", "argsNames", ".", "map", "(", "arg", "=>", "arg", ".", "toLowerCase", "(", ")", ")", "/**\r\n * Suppresses HTTP method if exists\r\n */", "if", "(", "keysMethods", ".", "indexOf", "(", "parts", "[", "0", "]", ".", "toLowerCase", "(", ")", ")", ">=", "0", ")", "parts", "=", "parts", ".", "slice", "(", "1", ")", "/**\r\n * Converts each method part into route path \r\n */", "return", "parts", ".", "reduce", "(", "(", "prev", ",", "curr", ")", "=>", "{", "if", "(", "keywordsMaps", "[", "curr", "]", ")", "prev", "+=", "keywordsMaps", "[", "curr", "]", "else", "{", "if", "(", "prev", ".", "slice", "(", "-", "1", ")", "!=", "'/'", ")", "prev", "+=", "'/'", "const", "index", "=", "argsNamesLower", ".", "indexOf", "(", "curr", ".", "toLowerCase", "(", ")", ")", "if", "(", "index", ">=", "0", ")", "{", "prev", "+=", "':'", "prev", "+=", "argsNames", "[", "index", "]", "// Preserve argument Case\r", "}", "else", "{", "prev", "+=", "curr", "}", "}", "return", "prev", "}", ",", "''", ")", "}" ]
Returns the route path for the corresponding controller method name.
[ "Returns", "the", "route", "path", "for", "the", "corresponding", "controller", "method", "name", "." ]
c8e2587c5a31e3cb54e3668c4b98b7b7526d69b4
https://github.com/CCISEL/connect-controller/blob/c8e2587c5a31e3cb54e3668c4b98b7b7526d69b4/lib/RouteInfo.js#L172-L200
57,816
CCISEL/connect-controller
lib/RouteInfo.js
parseHttpMethod
function parseHttpMethod(parts) { const prefix = parts[0].toLowerCase() if(keysMethods.indexOf(prefix) >= 0) return prefix else return GET }
javascript
function parseHttpMethod(parts) { const prefix = parts[0].toLowerCase() if(keysMethods.indexOf(prefix) >= 0) return prefix else return GET }
[ "function", "parseHttpMethod", "(", "parts", ")", "{", "const", "prefix", "=", "parts", "[", "0", "]", ".", "toLowerCase", "(", ")", "if", "(", "keysMethods", ".", "indexOf", "(", "prefix", ")", ">=", "0", ")", "return", "prefix", "else", "return", "GET", "}" ]
Gets the HTTP method from the Controller method name. Otherwise returns 'get'.
[ "Gets", "the", "HTTP", "method", "from", "the", "Controller", "method", "name", ".", "Otherwise", "returns", "get", "." ]
c8e2587c5a31e3cb54e3668c4b98b7b7526d69b4
https://github.com/CCISEL/connect-controller/blob/c8e2587c5a31e3cb54e3668c4b98b7b7526d69b4/lib/RouteInfo.js#L206-L212
57,817
CCISEL/connect-controller
lib/RouteInfo.js
lookupParameterOnReq
function lookupParameterOnReq(name, index, length) { return (req, res) => { if(req[name]) return req[name] if(req.query && req.query[name]) return req.query[name] if(req.body && req.body[name]) return req.body[name] if(res.locals && res.locals[name]) return res.locals[name] if(req.app.locals && req.app.locals[name]) return req.app.locals[name] /** * In this case there is not a matching property in Request object for * the given parameter name. * We just accept it, if that is the last parameter of the method, in which * case it should correspond to a callback. */ if(index != (length - 1)) throw new Error('Parameter ' + name + ' not found in Request object!!!' ) return null } }
javascript
function lookupParameterOnReq(name, index, length) { return (req, res) => { if(req[name]) return req[name] if(req.query && req.query[name]) return req.query[name] if(req.body && req.body[name]) return req.body[name] if(res.locals && res.locals[name]) return res.locals[name] if(req.app.locals && req.app.locals[name]) return req.app.locals[name] /** * In this case there is not a matching property in Request object for * the given parameter name. * We just accept it, if that is the last parameter of the method, in which * case it should correspond to a callback. */ if(index != (length - 1)) throw new Error('Parameter ' + name + ' not found in Request object!!!' ) return null } }
[ "function", "lookupParameterOnReq", "(", "name", ",", "index", ",", "length", ")", "{", "return", "(", "req", ",", "res", ")", "=>", "{", "if", "(", "req", "[", "name", "]", ")", "return", "req", "[", "name", "]", "if", "(", "req", ".", "query", "&&", "req", ".", "query", "[", "name", "]", ")", "return", "req", ".", "query", "[", "name", "]", "if", "(", "req", ".", "body", "&&", "req", ".", "body", "[", "name", "]", ")", "return", "req", ".", "body", "[", "name", "]", "if", "(", "res", ".", "locals", "&&", "res", ".", "locals", "[", "name", "]", ")", "return", "res", ".", "locals", "[", "name", "]", "if", "(", "req", ".", "app", ".", "locals", "&&", "req", ".", "app", ".", "locals", "[", "name", "]", ")", "return", "req", ".", "app", ".", "locals", "[", "name", "]", "/**\r\n * In this case there is not a matching property in Request object for\r\n * the given parameter name. \r\n * We just accept it, if that is the last parameter of the method, in which \r\n * case it should correspond to a callback.\r\n */", "if", "(", "index", "!=", "(", "length", "-", "1", ")", ")", "throw", "new", "Error", "(", "'Parameter '", "+", "name", "+", "' not found in Request object!!!'", ")", "return", "null", "}", "}" ]
!!!!!DEPRECATED >= 2.0.1 Given the name of a parameter search for it in req, req.query, req.body, res.locals, app.locals.
[ "!!!!!DEPRECATED", ">", "=", "2", ".", "0", ".", "1", "Given", "the", "name", "of", "a", "parameter", "search", "for", "it", "in", "req", "req", ".", "query", "req", ".", "body", "res", ".", "locals", "app", ".", "locals", "." ]
c8e2587c5a31e3cb54e3668c4b98b7b7526d69b4
https://github.com/CCISEL/connect-controller/blob/c8e2587c5a31e3cb54e3668c4b98b7b7526d69b4/lib/RouteInfo.js#L245-L263
57,818
assemble/assemble-loader
index.js
appLoader
function appLoader(app, config) { app.define('load', load('view', config)); var fn = app.view; app.define('view', function() { var view = fn.apply(this, arguments); utils.contents.sync(view); return view; }); }
javascript
function appLoader(app, config) { app.define('load', load('view', config)); var fn = app.view; app.define('view', function() { var view = fn.apply(this, arguments); utils.contents.sync(view); return view; }); }
[ "function", "appLoader", "(", "app", ",", "config", ")", "{", "app", ".", "define", "(", "'load'", ",", "load", "(", "'view'", ",", "config", ")", ")", ";", "var", "fn", "=", "app", ".", "view", ";", "app", ".", "define", "(", "'view'", ",", "function", "(", ")", "{", "var", "view", "=", "fn", ".", "apply", "(", "this", ",", "arguments", ")", ";", "utils", ".", "contents", ".", "sync", "(", "view", ")", ";", "return", "view", ";", "}", ")", ";", "}" ]
Adds a `.load` method to the "app" instance for loading views that that don't belong to any particular collection. It just returns the object of views instead of caching them. ```js var loader = require('assemble-loader'); var assemble = require('assemble'); var app = assemble(); app.use(loader()); var views = app.load('foo/*.hbs'); console.log(views); ``` @param {Object} `app` application instance (e.g. assemble, verb, etc) @param {Object} `config` Settings to use when registering the plugin @return {Object} Returns an object of _un-cached_ views, from a glob, string, array of strings, or objects. @api public
[ "Adds", "a", ".", "load", "method", "to", "the", "app", "instance", "for", "loading", "views", "that", "that", "don", "t", "belong", "to", "any", "particular", "collection", ".", "It", "just", "returns", "the", "object", "of", "views", "instead", "of", "caching", "them", "." ]
6d6b001cfa43c0628098f1e77c4d74292b3dbb0d
https://github.com/assemble/assemble-loader/blob/6d6b001cfa43c0628098f1e77c4d74292b3dbb0d/index.js#L59-L68
57,819
assemble/assemble-loader
index.js
createLoader
function createLoader(options, fn) { var loader = new utils.Loader(options); return function() { if (!this.isApp) loader.cache = this.views; loader.options.loaderFn = fn.bind(this); loader.load.apply(loader, arguments); return loader.cache; }; }
javascript
function createLoader(options, fn) { var loader = new utils.Loader(options); return function() { if (!this.isApp) loader.cache = this.views; loader.options.loaderFn = fn.bind(this); loader.load.apply(loader, arguments); return loader.cache; }; }
[ "function", "createLoader", "(", "options", ",", "fn", ")", "{", "var", "loader", "=", "new", "utils", ".", "Loader", "(", "options", ")", ";", "return", "function", "(", ")", "{", "if", "(", "!", "this", ".", "isApp", ")", "loader", ".", "cache", "=", "this", ".", "views", ";", "loader", ".", "options", ".", "loaderFn", "=", "fn", ".", "bind", "(", "this", ")", ";", "loader", ".", "load", ".", "apply", "(", "loader", ",", "arguments", ")", ";", "return", "loader", ".", "cache", ";", "}", ";", "}" ]
Create a `Loader` instance with a `loaderfn` bound to the app or collection instance.
[ "Create", "a", "Loader", "instance", "with", "a", "loaderfn", "bound", "to", "the", "app", "or", "collection", "instance", "." ]
6d6b001cfa43c0628098f1e77c4d74292b3dbb0d
https://github.com/assemble/assemble-loader/blob/6d6b001cfa43c0628098f1e77c4d74292b3dbb0d/index.js#L143-L151
57,820
assemble/assemble-loader
index.js
load
function load(method, config) { return function(patterns, options) { var opts = mergeOptions(this, config, options); var loader = createLoader(opts, this[method]); return loader.apply(this, arguments); }; }
javascript
function load(method, config) { return function(patterns, options) { var opts = mergeOptions(this, config, options); var loader = createLoader(opts, this[method]); return loader.apply(this, arguments); }; }
[ "function", "load", "(", "method", ",", "config", ")", "{", "return", "function", "(", "patterns", ",", "options", ")", "{", "var", "opts", "=", "mergeOptions", "(", "this", ",", "config", ",", "options", ")", ";", "var", "loader", "=", "createLoader", "(", "opts", ",", "this", "[", "method", "]", ")", ";", "return", "loader", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", ";", "}" ]
Create a function for loading views using the given `method` on the collection or app.
[ "Create", "a", "function", "for", "loading", "views", "using", "the", "given", "method", "on", "the", "collection", "or", "app", "." ]
6d6b001cfa43c0628098f1e77c4d74292b3dbb0d
https://github.com/assemble/assemble-loader/blob/6d6b001cfa43c0628098f1e77c4d74292b3dbb0d/index.js#L158-L164
57,821
Nichejs/Seminarjs
private/lib/core/start.js
function () { waitForServers--; if (waitForServers) return; if (seminarjs.get('logger')) { console.log(dashes + startupMessages.join('\n') + dashes); } events.onStart && events.onStart(); }
javascript
function () { waitForServers--; if (waitForServers) return; if (seminarjs.get('logger')) { console.log(dashes + startupMessages.join('\n') + dashes); } events.onStart && events.onStart(); }
[ "function", "(", ")", "{", "waitForServers", "--", ";", "if", "(", "waitForServers", ")", "return", ";", "if", "(", "seminarjs", ".", "get", "(", "'logger'", ")", ")", "{", "console", ".", "log", "(", "dashes", "+", "startupMessages", ".", "join", "(", "'\\n'", ")", "+", "dashes", ")", ";", "}", "events", ".", "onStart", "&&", "events", ".", "onStart", "(", ")", ";", "}" ]
Log the startup messages and calls the onStart method
[ "Log", "the", "startup", "messages", "and", "calls", "the", "onStart", "method" ]
53c4c1d5c33ffbf6320b10f25679bf181cbf853e
https://github.com/Nichejs/Seminarjs/blob/53c4c1d5c33ffbf6320b10f25679bf181cbf853e/private/lib/core/start.js#L89-L96
57,822
thiagodp/better-randstr
index.js
randstr
function randstr(options) { var opt = _validateOptions(options); var from, to; if (Array.isArray(opt.length)) { _a = opt.length, from = _a[0], to = _a[1]; } else { from = to = opt.length; } var str = ''; if (0 === to) { return str; } var charsIsString = 'string' === typeof opt.chars; var charsLastIndex = charsIsString ? opt.chars.length - 1 : 0; var includeControlChars = true === opt.includeControlChars; var hasAcceptableFunc = 'function' === typeof opt.acceptable; var hasReplacer = 'function' === typeof opt.replacer; var max = _randomIntBetween(opt.random, from, to); // console.log( 'max', max, 'from', from, 'to', to ); for (var i = 0, len = 0, charCode = void 0, chr = void 0; i < max && len < max; ++i) { if (charsIsString) { var index = _randomIntBetween(opt.random, 0, charsLastIndex); charCode = opt.chars.charCodeAt(index); } else { charCode = _randomIntBetween(opt.random, opt.chars[0], opt.chars[1]); } // Non printable? if (!includeControlChars && _isControlChar(charCode)) { // console.log( 'NOT PRINTABLE!'); --i; // back to try again continue; } chr = String.fromCharCode(charCode); // console.log( 'charCode', charCode, 'char', chr ); if (hasAcceptableFunc && !opt.acceptable.call(null, chr)) { --i; // back to try again continue; } if (hasReplacer) { chr = opt.replacer.call(null, chr); // console.log( 'char after', chr ); // Their combined length pass the limit? if ((len + chr.length) > max) { // console.log( 'greater than max!', 'i', i, 'max', max, 'str', len, 'chr', chr.length ); --i; // back to try again continue; } } str += chr; len = str.length; } return str; var _a; }
javascript
function randstr(options) { var opt = _validateOptions(options); var from, to; if (Array.isArray(opt.length)) { _a = opt.length, from = _a[0], to = _a[1]; } else { from = to = opt.length; } var str = ''; if (0 === to) { return str; } var charsIsString = 'string' === typeof opt.chars; var charsLastIndex = charsIsString ? opt.chars.length - 1 : 0; var includeControlChars = true === opt.includeControlChars; var hasAcceptableFunc = 'function' === typeof opt.acceptable; var hasReplacer = 'function' === typeof opt.replacer; var max = _randomIntBetween(opt.random, from, to); // console.log( 'max', max, 'from', from, 'to', to ); for (var i = 0, len = 0, charCode = void 0, chr = void 0; i < max && len < max; ++i) { if (charsIsString) { var index = _randomIntBetween(opt.random, 0, charsLastIndex); charCode = opt.chars.charCodeAt(index); } else { charCode = _randomIntBetween(opt.random, opt.chars[0], opt.chars[1]); } // Non printable? if (!includeControlChars && _isControlChar(charCode)) { // console.log( 'NOT PRINTABLE!'); --i; // back to try again continue; } chr = String.fromCharCode(charCode); // console.log( 'charCode', charCode, 'char', chr ); if (hasAcceptableFunc && !opt.acceptable.call(null, chr)) { --i; // back to try again continue; } if (hasReplacer) { chr = opt.replacer.call(null, chr); // console.log( 'char after', chr ); // Their combined length pass the limit? if ((len + chr.length) > max) { // console.log( 'greater than max!', 'i', i, 'max', max, 'str', len, 'chr', chr.length ); --i; // back to try again continue; } } str += chr; len = str.length; } return str; var _a; }
[ "function", "randstr", "(", "options", ")", "{", "var", "opt", "=", "_validateOptions", "(", "options", ")", ";", "var", "from", ",", "to", ";", "if", "(", "Array", ".", "isArray", "(", "opt", ".", "length", ")", ")", "{", "_a", "=", "opt", ".", "length", ",", "from", "=", "_a", "[", "0", "]", ",", "to", "=", "_a", "[", "1", "]", ";", "}", "else", "{", "from", "=", "to", "=", "opt", ".", "length", ";", "}", "var", "str", "=", "''", ";", "if", "(", "0", "===", "to", ")", "{", "return", "str", ";", "}", "var", "charsIsString", "=", "'string'", "===", "typeof", "opt", ".", "chars", ";", "var", "charsLastIndex", "=", "charsIsString", "?", "opt", ".", "chars", ".", "length", "-", "1", ":", "0", ";", "var", "includeControlChars", "=", "true", "===", "opt", ".", "includeControlChars", ";", "var", "hasAcceptableFunc", "=", "'function'", "===", "typeof", "opt", ".", "acceptable", ";", "var", "hasReplacer", "=", "'function'", "===", "typeof", "opt", ".", "replacer", ";", "var", "max", "=", "_randomIntBetween", "(", "opt", ".", "random", ",", "from", ",", "to", ")", ";", "// console.log( 'max', max, 'from', from, 'to', to );", "for", "(", "var", "i", "=", "0", ",", "len", "=", "0", ",", "charCode", "=", "void", "0", ",", "chr", "=", "void", "0", ";", "i", "<", "max", "&&", "len", "<", "max", ";", "++", "i", ")", "{", "if", "(", "charsIsString", ")", "{", "var", "index", "=", "_randomIntBetween", "(", "opt", ".", "random", ",", "0", ",", "charsLastIndex", ")", ";", "charCode", "=", "opt", ".", "chars", ".", "charCodeAt", "(", "index", ")", ";", "}", "else", "{", "charCode", "=", "_randomIntBetween", "(", "opt", ".", "random", ",", "opt", ".", "chars", "[", "0", "]", ",", "opt", ".", "chars", "[", "1", "]", ")", ";", "}", "// Non printable?", "if", "(", "!", "includeControlChars", "&&", "_isControlChar", "(", "charCode", ")", ")", "{", "// console.log( 'NOT PRINTABLE!');", "--", "i", ";", "// back to try again", "continue", ";", "}", "chr", "=", "String", ".", "fromCharCode", "(", "charCode", ")", ";", "// console.log( 'charCode', charCode, 'char', chr );", "if", "(", "hasAcceptableFunc", "&&", "!", "opt", ".", "acceptable", ".", "call", "(", "null", ",", "chr", ")", ")", "{", "--", "i", ";", "// back to try again", "continue", ";", "}", "if", "(", "hasReplacer", ")", "{", "chr", "=", "opt", ".", "replacer", ".", "call", "(", "null", ",", "chr", ")", ";", "// console.log( 'char after', chr );", "// Their combined length pass the limit?", "if", "(", "(", "len", "+", "chr", ".", "length", ")", ">", "max", ")", "{", "// console.log( 'greater than max!', 'i', i, 'max', max, 'str', len, 'chr', chr.length );", "--", "i", ";", "// back to try again", "continue", ";", "}", "}", "str", "+=", "chr", ";", "len", "=", "str", ".", "length", ";", "}", "return", "str", ";", "var", "_a", ";", "}" ]
Generates a random string according to the given options. @param options Options @returns a string
[ "Generates", "a", "random", "string", "according", "to", "the", "given", "options", "." ]
e63bc3085ad87e6f5ed1c59e5710e599127c3dce
https://github.com/thiagodp/better-randstr/blob/e63bc3085ad87e6f5ed1c59e5710e599127c3dce/index.js#L132-L187
57,823
niallo/deadlift
lib/deploy.js
updateStatus
function updateStatus(evType, opts) { var t2 = new Date() var elapsed = (t2.getTime() - t1.getTime()) / 1000 var msg = { timeElapsed:elapsed, stdout: opts.stdout || "", stderr: opts.stderr || "", stdmerged: opts.stdmerged || "", info: opts.info, step: opts.step, deployExitCode: null, url: null || opts.url, } if (opts.deployExitCode !== undefined) { msg.deployExitCode = opts.deployExitCode } emitter.emit(evType, msg) }
javascript
function updateStatus(evType, opts) { var t2 = new Date() var elapsed = (t2.getTime() - t1.getTime()) / 1000 var msg = { timeElapsed:elapsed, stdout: opts.stdout || "", stderr: opts.stderr || "", stdmerged: opts.stdmerged || "", info: opts.info, step: opts.step, deployExitCode: null, url: null || opts.url, } if (opts.deployExitCode !== undefined) { msg.deployExitCode = opts.deployExitCode } emitter.emit(evType, msg) }
[ "function", "updateStatus", "(", "evType", ",", "opts", ")", "{", "var", "t2", "=", "new", "Date", "(", ")", "var", "elapsed", "=", "(", "t2", ".", "getTime", "(", ")", "-", "t1", ".", "getTime", "(", ")", ")", "/", "1000", "var", "msg", "=", "{", "timeElapsed", ":", "elapsed", ",", "stdout", ":", "opts", ".", "stdout", "||", "\"\"", ",", "stderr", ":", "opts", ".", "stderr", "||", "\"\"", ",", "stdmerged", ":", "opts", ".", "stdmerged", "||", "\"\"", ",", "info", ":", "opts", ".", "info", ",", "step", ":", "opts", ".", "step", ",", "deployExitCode", ":", "null", ",", "url", ":", "null", "||", "opts", ".", "url", ",", "}", "if", "(", "opts", ".", "deployExitCode", "!==", "undefined", ")", "{", "msg", ".", "deployExitCode", "=", "opts", ".", "deployExitCode", "}", "emitter", ".", "emit", "(", "evType", ",", "msg", ")", "}" ]
Emit a status update event. This can result in data being sent to the user's browser in realtime via socket.io.
[ "Emit", "a", "status", "update", "event", ".", "This", "can", "result", "in", "data", "being", "sent", "to", "the", "user", "s", "browser", "in", "realtime", "via", "socket", ".", "io", "." ]
ff37d4eeccc326ec5e1390394585f6ac10bcc703
https://github.com/niallo/deadlift/blob/ff37d4eeccc326ec5e1390394585f6ac10bcc703/lib/deploy.js#L24-L42
57,824
blake-regalia/spaz.js
lib/main/js_sparql.js
function(s_thing) { if(H_SPARQL_CHARS[s_thing[0]]) return s_thing; else if(s_thing.indexOf(':') != -1) return s_thing; else if(s_thing == 'a') return s_thing; else return ':'+s_thing; }
javascript
function(s_thing) { if(H_SPARQL_CHARS[s_thing[0]]) return s_thing; else if(s_thing.indexOf(':') != -1) return s_thing; else if(s_thing == 'a') return s_thing; else return ':'+s_thing; }
[ "function", "(", "s_thing", ")", "{", "if", "(", "H_SPARQL_CHARS", "[", "s_thing", "[", "0", "]", "]", ")", "return", "s_thing", ";", "else", "if", "(", "s_thing", ".", "indexOf", "(", "':'", ")", "!=", "-", "1", ")", "return", "s_thing", ";", "else", "if", "(", "s_thing", "==", "'a'", ")", "return", "s_thing", ";", "else", "return", "':'", "+", "s_thing", ";", "}" ]
converts thing alias to proper identifier if not already specified
[ "converts", "thing", "alias", "to", "proper", "identifier", "if", "not", "already", "specified" ]
e0a04ab4783a0e386e245a3551e1a41bd746da35
https://github.com/blake-regalia/spaz.js/blob/e0a04ab4783a0e386e245a3551e1a41bd746da35/lib/main/js_sparql.js#L75-L80
57,825
blake-regalia/spaz.js
lib/main/js_sparql.js
function(s_str) { if(H_SPARQL_CHARS[s_str[0]]) return s_str; else if(s_str.indexOf(':') != -1) return s_str; else if(/^(?:[0-9]|(?:\-|\.|\-\.)[0-9])/.test(s_str)) return s_str; else return JSON.stringify(s_str); }
javascript
function(s_str) { if(H_SPARQL_CHARS[s_str[0]]) return s_str; else if(s_str.indexOf(':') != -1) return s_str; else if(/^(?:[0-9]|(?:\-|\.|\-\.)[0-9])/.test(s_str)) return s_str; else return JSON.stringify(s_str); }
[ "function", "(", "s_str", ")", "{", "if", "(", "H_SPARQL_CHARS", "[", "s_str", "[", "0", "]", "]", ")", "return", "s_str", ";", "else", "if", "(", "s_str", ".", "indexOf", "(", "':'", ")", "!=", "-", "1", ")", "return", "s_str", ";", "else", "if", "(", "/", "^(?:[0-9]|(?:\\-|\\.|\\-\\.)[0-9])", "/", ".", "test", "(", "s_str", ")", ")", "return", "s_str", ";", "else", "return", "JSON", ".", "stringify", "(", "s_str", ")", ";", "}" ]
converts string to proper identifier if not already specified
[ "converts", "string", "to", "proper", "identifier", "if", "not", "already", "specified" ]
e0a04ab4783a0e386e245a3551e1a41bd746da35
https://github.com/blake-regalia/spaz.js/blob/e0a04ab4783a0e386e245a3551e1a41bd746da35/lib/main/js_sparql.js#L90-L95
57,826
blake-regalia/spaz.js
lib/main/js_sparql.js
function(sq_prefixes) { var s_select = this.select || '*'; var sq_select = 'SELECT '+s_select+' WHERE {'; var sq_where = this.where; var sq_tail = this.tail; var sq_group = this.group? ' GROUP BY '+this.group: ''; var sq_order = this.order? ' ORDER BY '+this.order: ''; var sq_limit_offset = this.limit; var sq_close = '\n}'; return '' +sq_prefixes +sq_select +sq_where +sq_tail +sq_close +sq_group +sq_order +sq_limit_offset; }
javascript
function(sq_prefixes) { var s_select = this.select || '*'; var sq_select = 'SELECT '+s_select+' WHERE {'; var sq_where = this.where; var sq_tail = this.tail; var sq_group = this.group? ' GROUP BY '+this.group: ''; var sq_order = this.order? ' ORDER BY '+this.order: ''; var sq_limit_offset = this.limit; var sq_close = '\n}'; return '' +sq_prefixes +sq_select +sq_where +sq_tail +sq_close +sq_group +sq_order +sq_limit_offset; }
[ "function", "(", "sq_prefixes", ")", "{", "var", "s_select", "=", "this", ".", "select", "||", "'*'", ";", "var", "sq_select", "=", "'SELECT '", "+", "s_select", "+", "' WHERE {'", ";", "var", "sq_where", "=", "this", ".", "where", ";", "var", "sq_tail", "=", "this", ".", "tail", ";", "var", "sq_group", "=", "this", ".", "group", "?", "' GROUP BY '", "+", "this", ".", "group", ":", "''", ";", "var", "sq_order", "=", "this", ".", "order", "?", "' ORDER BY '", "+", "this", ".", "order", ":", "''", ";", "var", "sq_limit_offset", "=", "this", ".", "limit", ";", "var", "sq_close", "=", "'\\n}'", ";", "return", "''", "+", "sq_prefixes", "+", "sq_select", "+", "sq_where", "+", "sq_tail", "+", "sq_close", "+", "sq_group", "+", "sq_order", "+", "sq_limit_offset", ";", "}" ]
converts query hash to sparql string
[ "converts", "query", "hash", "to", "sparql", "string" ]
e0a04ab4783a0e386e245a3551e1a41bd746da35
https://github.com/blake-regalia/spaz.js/blob/e0a04ab4783a0e386e245a3551e1a41bd746da35/lib/main/js_sparql.js#L98-L116
57,827
blake-regalia/spaz.js
lib/main/js_sparql.js
function(s_query, f_okay) { $.ajax({ url: s_endpoint_url+'query', method: 'GET', data: { query: s_query, }, dataType: 'json', success: function(h_res) { f_okay && f_okay(h_res); }, }); }
javascript
function(s_query, f_okay) { $.ajax({ url: s_endpoint_url+'query', method: 'GET', data: { query: s_query, }, dataType: 'json', success: function(h_res) { f_okay && f_okay(h_res); }, }); }
[ "function", "(", "s_query", ",", "f_okay", ")", "{", "$", ".", "ajax", "(", "{", "url", ":", "s_endpoint_url", "+", "'query'", ",", "method", ":", "'GET'", ",", "data", ":", "{", "query", ":", "s_query", ",", "}", ",", "dataType", ":", "'json'", ",", "success", ":", "function", "(", "h_res", ")", "{", "f_okay", "&&", "f_okay", "(", "h_res", ")", ";", "}", ",", "}", ")", ";", "}" ]
submits a query
[ "submits", "a", "query" ]
e0a04ab4783a0e386e245a3551e1a41bd746da35
https://github.com/blake-regalia/spaz.js/blob/e0a04ab4783a0e386e245a3551e1a41bd746da35/lib/main/js_sparql.js#L131-L143
57,828
blake-regalia/spaz.js
lib/main/js_sparql.js
function(h_subjects, b_raw) { // initiliaze output var s_out = ''; // add slot for tail var s_tail = ''; // newline + indent var _ = '\n\t'+(b_raw? '\t':''); // root nodes must be subjects for(var s_rs in h_subjects) { // var z_predicates = h_subjects[s_rs]; // declaring optional block if(s_rs == '?') { // these are subjects actually var h_write = query_hash(z_predicates, true); s_out += _+'OPTIONAL {'+h_write.where+_+'}'; s_tail += h_write.tail; } // regular query hash else { var s_rsi = rdf_var(s_rs); // this is subject s_out += _+s_rsi; // predicates are in hash if(typeof z_predicates == 'object') { // recurse var a_write = build_from_ph(z_predicates, _); s_out += a_write[0]+' .'; s_tail += a_write[1]; } } } var h_raw = { treated_vars: {subs:{},lists:{}}, select: '', where: s_out, tail: s_tail, group: '', order: '', limit: '', }; return (b_raw? h_raw: qb(h_raw)); }
javascript
function(h_subjects, b_raw) { // initiliaze output var s_out = ''; // add slot for tail var s_tail = ''; // newline + indent var _ = '\n\t'+(b_raw? '\t':''); // root nodes must be subjects for(var s_rs in h_subjects) { // var z_predicates = h_subjects[s_rs]; // declaring optional block if(s_rs == '?') { // these are subjects actually var h_write = query_hash(z_predicates, true); s_out += _+'OPTIONAL {'+h_write.where+_+'}'; s_tail += h_write.tail; } // regular query hash else { var s_rsi = rdf_var(s_rs); // this is subject s_out += _+s_rsi; // predicates are in hash if(typeof z_predicates == 'object') { // recurse var a_write = build_from_ph(z_predicates, _); s_out += a_write[0]+' .'; s_tail += a_write[1]; } } } var h_raw = { treated_vars: {subs:{},lists:{}}, select: '', where: s_out, tail: s_tail, group: '', order: '', limit: '', }; return (b_raw? h_raw: qb(h_raw)); }
[ "function", "(", "h_subjects", ",", "b_raw", ")", "{", "// initiliaze output", "var", "s_out", "=", "''", ";", "// add slot for tail", "var", "s_tail", "=", "''", ";", "// newline + indent", "var", "_", "=", "'\\n\\t'", "+", "(", "b_raw", "?", "'\\t'", ":", "''", ")", ";", "// root nodes must be subjects", "for", "(", "var", "s_rs", "in", "h_subjects", ")", "{", "//", "var", "z_predicates", "=", "h_subjects", "[", "s_rs", "]", ";", "// declaring optional block", "if", "(", "s_rs", "==", "'?'", ")", "{", "// these are subjects actually", "var", "h_write", "=", "query_hash", "(", "z_predicates", ",", "true", ")", ";", "s_out", "+=", "_", "+", "'OPTIONAL {'", "+", "h_write", ".", "where", "+", "_", "+", "'}'", ";", "s_tail", "+=", "h_write", ".", "tail", ";", "}", "// regular query hash", "else", "{", "var", "s_rsi", "=", "rdf_var", "(", "s_rs", ")", ";", "// this is subject", "s_out", "+=", "_", "+", "s_rsi", ";", "// predicates are in hash", "if", "(", "typeof", "z_predicates", "==", "'object'", ")", "{", "// recurse", "var", "a_write", "=", "build_from_ph", "(", "z_predicates", ",", "_", ")", ";", "s_out", "+=", "a_write", "[", "0", "]", "+", "' .'", ";", "s_tail", "+=", "a_write", "[", "1", "]", ";", "}", "}", "}", "var", "h_raw", "=", "{", "treated_vars", ":", "{", "subs", ":", "{", "}", ",", "lists", ":", "{", "}", "}", ",", "select", ":", "''", ",", "where", ":", "s_out", ",", "tail", ":", "s_tail", ",", "group", ":", "''", ",", "order", ":", "''", ",", "limit", ":", "''", ",", "}", ";", "return", "(", "b_raw", "?", "h_raw", ":", "qb", "(", "h_raw", ")", ")", ";", "}" ]
constructs sparql query string from hash
[ "constructs", "sparql", "query", "string", "from", "hash" ]
e0a04ab4783a0e386e245a3551e1a41bd746da35
https://github.com/blake-regalia/spaz.js/blob/e0a04ab4783a0e386e245a3551e1a41bd746da35/lib/main/js_sparql.js#L415-L471
57,829
blake-regalia/spaz.js
lib/main/js_sparql.js
function(s_query) { // execute function var f_exec = function(f_okay) { submit_query(s_query, f_okay); }; var d_self = { exec: f_exec, results: function(f_okay) { f_exec(function(h_res) { f_okay && f_okay(h_res.results.bindings); }); }, each: function(f_each, f_okay) { f_exec(function(h_res) { if(!f_each) return; var a_rows = h_res.results.bindings; for(var i=0,l=a_rows.length; i<l; i++) { var h_row = a_rows[i]; var h_this = {}; for(var e in h_row) h_this[e] = h_row[e].value; f_each.apply(h_this, [i, h_row]); } f_okay && f_okay(); }); }, }; return d_self; }
javascript
function(s_query) { // execute function var f_exec = function(f_okay) { submit_query(s_query, f_okay); }; var d_self = { exec: f_exec, results: function(f_okay) { f_exec(function(h_res) { f_okay && f_okay(h_res.results.bindings); }); }, each: function(f_each, f_okay) { f_exec(function(h_res) { if(!f_each) return; var a_rows = h_res.results.bindings; for(var i=0,l=a_rows.length; i<l; i++) { var h_row = a_rows[i]; var h_this = {}; for(var e in h_row) h_this[e] = h_row[e].value; f_each.apply(h_this, [i, h_row]); } f_okay && f_okay(); }); }, }; return d_self; }
[ "function", "(", "s_query", ")", "{", "// execute function", "var", "f_exec", "=", "function", "(", "f_okay", ")", "{", "submit_query", "(", "s_query", ",", "f_okay", ")", ";", "}", ";", "var", "d_self", "=", "{", "exec", ":", "f_exec", ",", "results", ":", "function", "(", "f_okay", ")", "{", "f_exec", "(", "function", "(", "h_res", ")", "{", "f_okay", "&&", "f_okay", "(", "h_res", ".", "results", ".", "bindings", ")", ";", "}", ")", ";", "}", ",", "each", ":", "function", "(", "f_each", ",", "f_okay", ")", "{", "f_exec", "(", "function", "(", "h_res", ")", "{", "if", "(", "!", "f_each", ")", "return", ";", "var", "a_rows", "=", "h_res", ".", "results", ".", "bindings", ";", "for", "(", "var", "i", "=", "0", ",", "l", "=", "a_rows", ".", "length", ";", "i", "<", "l", ";", "i", "++", ")", "{", "var", "h_row", "=", "a_rows", "[", "i", "]", ";", "var", "h_this", "=", "{", "}", ";", "for", "(", "var", "e", "in", "h_row", ")", "h_this", "[", "e", "]", "=", "h_row", "[", "e", "]", ".", "value", ";", "f_each", ".", "apply", "(", "h_this", ",", "[", "i", ",", "h_row", "]", ")", ";", "}", "f_okay", "&&", "f_okay", "(", ")", ";", "}", ")", ";", "}", ",", "}", ";", "return", "d_self", ";", "}" ]
executes raw sparql query from string
[ "executes", "raw", "sparql", "query", "from", "string" ]
e0a04ab4783a0e386e245a3551e1a41bd746da35
https://github.com/blake-regalia/spaz.js/blob/e0a04ab4783a0e386e245a3551e1a41bd746da35/lib/main/js_sparql.js#L475-L505
57,830
blake-regalia/spaz.js
lib/main/js_sparql.js
function(channel) { return function() { var args = Array.prototype.slice.call(arguments); args.unshift(__class+':'); console[channel].apply(console, args); }; }
javascript
function(channel) { return function() { var args = Array.prototype.slice.call(arguments); args.unshift(__class+':'); console[channel].apply(console, args); }; }
[ "function", "(", "channel", ")", "{", "return", "function", "(", ")", "{", "var", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ")", ";", "args", ".", "unshift", "(", "__class", "+", "':'", ")", ";", "console", "[", "channel", "]", ".", "apply", "(", "console", ",", "args", ")", ";", "}", ";", "}" ]
output a message to the console prefixed with this class's tag
[ "output", "a", "message", "to", "the", "console", "prefixed", "with", "this", "class", "s", "tag" ]
e0a04ab4783a0e386e245a3551e1a41bd746da35
https://github.com/blake-regalia/spaz.js/blob/e0a04ab4783a0e386e245a3551e1a41bd746da35/lib/main/js_sparql.js#L599-L605
57,831
richRemer/twixt-select
select.js
into
function into(impl) { /** * @param {string} selector * @param {Document|Element} [context] */ return function(selector, context) { var callContext = this, extra; if (typeof selector === "string") { if (context && context.querySelector) { extra = Array.prototype.slice.call(arguments, 2); } else { extra = Array.prototype.slice.call(arguments, 1); context = document; } select(selector, context, function(elem) { impl.apply(callContext, [elem].concat(extra)); }); } else { impl.apply(callContext, arguments); } }; }
javascript
function into(impl) { /** * @param {string} selector * @param {Document|Element} [context] */ return function(selector, context) { var callContext = this, extra; if (typeof selector === "string") { if (context && context.querySelector) { extra = Array.prototype.slice.call(arguments, 2); } else { extra = Array.prototype.slice.call(arguments, 1); context = document; } select(selector, context, function(elem) { impl.apply(callContext, [elem].concat(extra)); }); } else { impl.apply(callContext, arguments); } }; }
[ "function", "into", "(", "impl", ")", "{", "/**\n * @param {string} selector\n * @param {Document|Element} [context]\n */", "return", "function", "(", "selector", ",", "context", ")", "{", "var", "callContext", "=", "this", ",", "extra", ";", "if", "(", "typeof", "selector", "===", "\"string\"", ")", "{", "if", "(", "context", "&&", "context", ".", "querySelector", ")", "{", "extra", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ",", "2", ")", ";", "}", "else", "{", "extra", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ",", "1", ")", ";", "context", "=", "document", ";", "}", "select", "(", "selector", ",", "context", ",", "function", "(", "elem", ")", "{", "impl", ".", "apply", "(", "callContext", ",", "[", "elem", "]", ".", "concat", "(", "extra", ")", ")", ";", "}", ")", ";", "}", "else", "{", "impl", ".", "apply", "(", "callContext", ",", "arguments", ")", ";", "}", "}", ";", "}" ]
Create function composition which passes each selected element to a base function. @param {function} impl @returns {function}
[ "Create", "function", "composition", "which", "passes", "each", "selected", "element", "to", "a", "base", "function", "." ]
8f4cb70623f578d197a23a49e6dcd42a2bb772be
https://github.com/richRemer/twixt-select/blob/8f4cb70623f578d197a23a49e6dcd42a2bb772be/select.js#L7-L31
57,832
richRemer/twixt-select
select.js
select
function select(selector, context, fn) { var nodes; if (arguments.length === 2 && typeof context === "function") { fn = context; context = undefined; } nodes = (context || document).querySelectorAll(selector); nodes = Array.prototype.slice.call(nodes); if (fn) nodes.forEach(fn); else return nodes; }
javascript
function select(selector, context, fn) { var nodes; if (arguments.length === 2 && typeof context === "function") { fn = context; context = undefined; } nodes = (context || document).querySelectorAll(selector); nodes = Array.prototype.slice.call(nodes); if (fn) nodes.forEach(fn); else return nodes; }
[ "function", "select", "(", "selector", ",", "context", ",", "fn", ")", "{", "var", "nodes", ";", "if", "(", "arguments", ".", "length", "===", "2", "&&", "typeof", "context", "===", "\"function\"", ")", "{", "fn", "=", "context", ";", "context", "=", "undefined", ";", "}", "nodes", "=", "(", "context", "||", "document", ")", ".", "querySelectorAll", "(", "selector", ")", ";", "nodes", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "nodes", ")", ";", "if", "(", "fn", ")", "nodes", ".", "forEach", "(", "fn", ")", ";", "else", "return", "nodes", ";", "}" ]
Return selected elements or iterate and apply a function. @param {string} selector @param {Document|Element} [context] @param {function} [fn] @returns {Node[]}
[ "Return", "selected", "elements", "or", "iterate", "and", "apply", "a", "function", "." ]
8f4cb70623f578d197a23a49e6dcd42a2bb772be
https://github.com/richRemer/twixt-select/blob/8f4cb70623f578d197a23a49e6dcd42a2bb772be/select.js#L40-L53
57,833
brycebaril/node-loose-interval
index.js
LooseInterval
function LooseInterval(fn, interval, callback) { if (!(this instanceof LooseInterval)) return new LooseInterval(fn, interval, callback) if (typeof fn != "function") throw new Error("LooseInterval requires a function") if (typeof interval == "function") { callback = interval interval = null } this.fn = fn this.interval = interval this.callback = callback EventEmitter.call(this) this._running = false if (interval != null) this.start(interval) }
javascript
function LooseInterval(fn, interval, callback) { if (!(this instanceof LooseInterval)) return new LooseInterval(fn, interval, callback) if (typeof fn != "function") throw new Error("LooseInterval requires a function") if (typeof interval == "function") { callback = interval interval = null } this.fn = fn this.interval = interval this.callback = callback EventEmitter.call(this) this._running = false if (interval != null) this.start(interval) }
[ "function", "LooseInterval", "(", "fn", ",", "interval", ",", "callback", ")", "{", "if", "(", "!", "(", "this", "instanceof", "LooseInterval", ")", ")", "return", "new", "LooseInterval", "(", "fn", ",", "interval", ",", "callback", ")", "if", "(", "typeof", "fn", "!=", "\"function\"", ")", "throw", "new", "Error", "(", "\"LooseInterval requires a function\"", ")", "if", "(", "typeof", "interval", "==", "\"function\"", ")", "{", "callback", "=", "interval", "interval", "=", "null", "}", "this", ".", "fn", "=", "fn", "this", ".", "interval", "=", "interval", "this", ".", "callback", "=", "callback", "EventEmitter", ".", "call", "(", "this", ")", "this", ".", "_running", "=", "false", "if", "(", "interval", "!=", "null", ")", "this", ".", "start", "(", "interval", ")", "}" ]
Create a loose-interval repeated task. Like setInterval but will reschedule when the task finishes to avoid overlapping tasks. Your function must provide a callback to alert its completion. @param {Function} fn The function to repeatedly call. Must provide a callback. fn(cb) @param {Number} interval Millisecond interval to wait between the function's end next call. @param {Function} callback Callback to forward results to after each run.
[ "Create", "a", "loose", "-", "interval", "repeated", "task", ".", "Like", "setInterval", "but", "will", "reschedule", "when", "the", "task", "finishes", "to", "avoid", "overlapping", "tasks", ".", "Your", "function", "must", "provide", "a", "callback", "to", "alert", "its", "completion", "." ]
68d2880e2ab9b4978c488a3d55be491e0409ebd3
https://github.com/brycebaril/node-loose-interval/blob/68d2880e2ab9b4978c488a3d55be491e0409ebd3/index.js#L14-L30
57,834
Techniv/node-cmd-conf
libs/cmd-conf.js
process
function process(){ if (!conf.configured) that.configure(); var args = command.args.slice(0); for(var i in args){ var arg = args[i]; if(conf.regexp.test(arg)){ var catchWord = RegExp.$2; switch(RegExp.$1){ case '-': processShortKey(catchWord, i, args); break; case '--': processKey(catchWord, i, args); break; } } else { addArgument(arg); } } conf.processed = true }
javascript
function process(){ if (!conf.configured) that.configure(); var args = command.args.slice(0); for(var i in args){ var arg = args[i]; if(conf.regexp.test(arg)){ var catchWord = RegExp.$2; switch(RegExp.$1){ case '-': processShortKey(catchWord, i, args); break; case '--': processKey(catchWord, i, args); break; } } else { addArgument(arg); } } conf.processed = true }
[ "function", "process", "(", ")", "{", "if", "(", "!", "conf", ".", "configured", ")", "that", ".", "configure", "(", ")", ";", "var", "args", "=", "command", ".", "args", ".", "slice", "(", "0", ")", ";", "for", "(", "var", "i", "in", "args", ")", "{", "var", "arg", "=", "args", "[", "i", "]", ";", "if", "(", "conf", ".", "regexp", ".", "test", "(", "arg", ")", ")", "{", "var", "catchWord", "=", "RegExp", ".", "$2", ";", "switch", "(", "RegExp", ".", "$1", ")", "{", "case", "'-'", ":", "processShortKey", "(", "catchWord", ",", "i", ",", "args", ")", ";", "break", ";", "case", "'--'", ":", "processKey", "(", "catchWord", ",", "i", ",", "args", ")", ";", "break", ";", "}", "}", "else", "{", "addArgument", "(", "arg", ")", ";", "}", "}", "conf", ".", "processed", "=", "true", "}" ]
Fire the command line analyse
[ "Fire", "the", "command", "line", "analyse" ]
ecefaf9c1eb3a68a7ab4e5b9a0b71329a7d52646
https://github.com/Techniv/node-cmd-conf/blob/ecefaf9c1eb3a68a7ab4e5b9a0b71329a7d52646/libs/cmd-conf.js#L145-L165
57,835
ForbesLindesay-Unmaintained/sauce-test
lib/get-sauce-platforms.js
getPlatforms
function getPlatforms(options) { return request('GET', 'https://saucelabs.com/rest/v1/info/platforms/webdriver') .getBody('utf8').then(JSON.parse).then(function (platforms) { var obj = {}; platforms.map(function (platform) { return { browserName: platform.api_name, version: platform.short_version, platform: platform.os }; }).forEach(function (platform) { if (platform.browserName === 'lynx') return; if (!(options.filterPlatforms || defaultFilters.filterPlatforms)(platform, defaultFilters.filterPlatforms)) return; obj[platform.browserName] = obj[platform.browserName] || {}; obj[platform.browserName][platform.version] = obj[platform.browserName][platform.version] || []; obj[platform.browserName][platform.version].push(platform); }); var result = {}; Object.keys(obj).forEach(function (browser) { result[browser] = []; Object.keys(obj[browser]).sort(function (versionA, versionB) { if (isNaN(versionA) && isNaN(versionB)) return versionA < versionB ? -1 : 1; if (isNaN(versionA)) return -1; if (isNaN(versionB)) return 1; return (+versionB) - (+versionA); }).forEach(function (version, index) { var platforms = obj[browser][version]; result[browser] = result[browser].concat((options.choosePlatforms || defaultFilters.choosePlatforms)(platforms)); }); }); return result; }); }
javascript
function getPlatforms(options) { return request('GET', 'https://saucelabs.com/rest/v1/info/platforms/webdriver') .getBody('utf8').then(JSON.parse).then(function (platforms) { var obj = {}; platforms.map(function (platform) { return { browserName: platform.api_name, version: platform.short_version, platform: platform.os }; }).forEach(function (platform) { if (platform.browserName === 'lynx') return; if (!(options.filterPlatforms || defaultFilters.filterPlatforms)(platform, defaultFilters.filterPlatforms)) return; obj[platform.browserName] = obj[platform.browserName] || {}; obj[platform.browserName][platform.version] = obj[platform.browserName][platform.version] || []; obj[platform.browserName][platform.version].push(platform); }); var result = {}; Object.keys(obj).forEach(function (browser) { result[browser] = []; Object.keys(obj[browser]).sort(function (versionA, versionB) { if (isNaN(versionA) && isNaN(versionB)) return versionA < versionB ? -1 : 1; if (isNaN(versionA)) return -1; if (isNaN(versionB)) return 1; return (+versionB) - (+versionA); }).forEach(function (version, index) { var platforms = obj[browser][version]; result[browser] = result[browser].concat((options.choosePlatforms || defaultFilters.choosePlatforms)(platforms)); }); }); return result; }); }
[ "function", "getPlatforms", "(", "options", ")", "{", "return", "request", "(", "'GET'", ",", "'https://saucelabs.com/rest/v1/info/platforms/webdriver'", ")", ".", "getBody", "(", "'utf8'", ")", ".", "then", "(", "JSON", ".", "parse", ")", ".", "then", "(", "function", "(", "platforms", ")", "{", "var", "obj", "=", "{", "}", ";", "platforms", ".", "map", "(", "function", "(", "platform", ")", "{", "return", "{", "browserName", ":", "platform", ".", "api_name", ",", "version", ":", "platform", ".", "short_version", ",", "platform", ":", "platform", ".", "os", "}", ";", "}", ")", ".", "forEach", "(", "function", "(", "platform", ")", "{", "if", "(", "platform", ".", "browserName", "===", "'lynx'", ")", "return", ";", "if", "(", "!", "(", "options", ".", "filterPlatforms", "||", "defaultFilters", ".", "filterPlatforms", ")", "(", "platform", ",", "defaultFilters", ".", "filterPlatforms", ")", ")", "return", ";", "obj", "[", "platform", ".", "browserName", "]", "=", "obj", "[", "platform", ".", "browserName", "]", "||", "{", "}", ";", "obj", "[", "platform", ".", "browserName", "]", "[", "platform", ".", "version", "]", "=", "obj", "[", "platform", ".", "browserName", "]", "[", "platform", ".", "version", "]", "||", "[", "]", ";", "obj", "[", "platform", ".", "browserName", "]", "[", "platform", ".", "version", "]", ".", "push", "(", "platform", ")", ";", "}", ")", ";", "var", "result", "=", "{", "}", ";", "Object", ".", "keys", "(", "obj", ")", ".", "forEach", "(", "function", "(", "browser", ")", "{", "result", "[", "browser", "]", "=", "[", "]", ";", "Object", ".", "keys", "(", "obj", "[", "browser", "]", ")", ".", "sort", "(", "function", "(", "versionA", ",", "versionB", ")", "{", "if", "(", "isNaN", "(", "versionA", ")", "&&", "isNaN", "(", "versionB", ")", ")", "return", "versionA", "<", "versionB", "?", "-", "1", ":", "1", ";", "if", "(", "isNaN", "(", "versionA", ")", ")", "return", "-", "1", ";", "if", "(", "isNaN", "(", "versionB", ")", ")", "return", "1", ";", "return", "(", "+", "versionB", ")", "-", "(", "+", "versionA", ")", ";", "}", ")", ".", "forEach", "(", "function", "(", "version", ",", "index", ")", "{", "var", "platforms", "=", "obj", "[", "browser", "]", "[", "version", "]", ";", "result", "[", "browser", "]", "=", "result", "[", "browser", "]", ".", "concat", "(", "(", "options", ".", "choosePlatforms", "||", "defaultFilters", ".", "choosePlatforms", ")", "(", "platforms", ")", ")", ";", "}", ")", ";", "}", ")", ";", "return", "result", ";", "}", ")", ";", "}" ]
Get an object containing the platforms supported by sauce labs Platforms: ```js { "chrome": [{"browserName": "chrome", "version": "34", platform:" Mac 10.9"}, ...] ... } ``` @option {Function.<Platform,Boolean>} filterPlatforms Return `true` to include the platform in the resulting set. @option {Function.<Array.<Platform>,Array.<Platform>>} choosePlatforms Return an array of platforms of a given version to include in the output. This lets you choose only one operating system for each browser version. @param {Options} options @returns {Promise.<Platforms>}
[ "Get", "an", "object", "containing", "the", "platforms", "supported", "by", "sauce", "labs" ]
7c671b3321dc63aefc00c1c8d49e943ead2e7f5e
https://github.com/ForbesLindesay-Unmaintained/sauce-test/blob/7c671b3321dc63aefc00c1c8d49e943ead2e7f5e/lib/get-sauce-platforms.js#L29-L61
57,836
rhyolight/github-data
lib/blob.js
Blob
function Blob(source, parent, githubClient) { this.gh = githubClient; this.parent = parent; this.sha = source.sha; this.rawContent = source.content; this.size = source.size; this.contents = new Buffer(this.rawContent, 'base64').toString('utf-8'); }
javascript
function Blob(source, parent, githubClient) { this.gh = githubClient; this.parent = parent; this.sha = source.sha; this.rawContent = source.content; this.size = source.size; this.contents = new Buffer(this.rawContent, 'base64').toString('utf-8'); }
[ "function", "Blob", "(", "source", ",", "parent", ",", "githubClient", ")", "{", "this", ".", "gh", "=", "githubClient", ";", "this", ".", "parent", "=", "parent", ";", "this", ".", "sha", "=", "source", ".", "sha", ";", "this", ".", "rawContent", "=", "source", ".", "content", ";", "this", ".", "size", "=", "source", ".", "size", ";", "this", ".", "contents", "=", "new", "Buffer", "(", "this", ".", "rawContent", ",", "'base64'", ")", ".", "toString", "(", "'utf-8'", ")", ";", "}" ]
A git blob object. @class Blob @param source {Object} JSON response from API, used to build. @param parent {Object} Expected to be {{#crossLink "Tree"}}{{/crossLink}}. @param githubClient {Object} GitHub API Client object. @constructor
[ "A", "git", "blob", "object", "." ]
5d6a3fc0e7ecfeaec03e4815b0940c2d9ce07d64
https://github.com/rhyolight/github-data/blob/5d6a3fc0e7ecfeaec03e4815b0940c2d9ce07d64/lib/blob.js#L9-L16
57,837
frankc60/jpretty
src/jPretty.js
pJson
function pJson(events, top = '') { Object.keys(events).forEach((i) => { if (typeof events[i] === 'object' && events[i] != null) { let rtn; if (Object.prototype.toString.call(events) === '[object Array]') { rtn = (`${top}[${i}]`); } else { rtn = (`${top}.${i}`); } pJson(events[i], rtn); } else if (Object.prototype.toString.call(events) === '[object Array]') { tmp += `{}${top}[${i}] = ${events[i]}\n`; } else { tmp += `{}${top}.${i} = ${events[i]}\n`; } }); }
javascript
function pJson(events, top = '') { Object.keys(events).forEach((i) => { if (typeof events[i] === 'object' && events[i] != null) { let rtn; if (Object.prototype.toString.call(events) === '[object Array]') { rtn = (`${top}[${i}]`); } else { rtn = (`${top}.${i}`); } pJson(events[i], rtn); } else if (Object.prototype.toString.call(events) === '[object Array]') { tmp += `{}${top}[${i}] = ${events[i]}\n`; } else { tmp += `{}${top}.${i} = ${events[i]}\n`; } }); }
[ "function", "pJson", "(", "events", ",", "top", "=", "''", ")", "{", "Object", ".", "keys", "(", "events", ")", ".", "forEach", "(", "(", "i", ")", "=>", "{", "if", "(", "typeof", "events", "[", "i", "]", "===", "'object'", "&&", "events", "[", "i", "]", "!=", "null", ")", "{", "let", "rtn", ";", "if", "(", "Object", ".", "prototype", ".", "toString", ".", "call", "(", "events", ")", "===", "'[object Array]'", ")", "{", "rtn", "=", "(", "`", "${", "top", "}", "${", "i", "}", "`", ")", ";", "}", "else", "{", "rtn", "=", "(", "`", "${", "top", "}", "${", "i", "}", "`", ")", ";", "}", "pJson", "(", "events", "[", "i", "]", ",", "rtn", ")", ";", "}", "else", "if", "(", "Object", ".", "prototype", ".", "toString", ".", "call", "(", "events", ")", "===", "'[object Array]'", ")", "{", "tmp", "+=", "`", "${", "top", "}", "${", "i", "}", "${", "events", "[", "i", "]", "}", "\\n", "`", ";", "}", "else", "{", "tmp", "+=", "`", "${", "top", "}", "${", "i", "}", "${", "events", "[", "i", "]", "}", "\\n", "`", ";", "}", "}", ")", ";", "}" ]
json needs to arrive stringified
[ "json", "needs", "to", "arrive", "stringified" ]
15c26bff27542c83ce28376b7065e09d2daa935a
https://github.com/frankc60/jpretty/blob/15c26bff27542c83ce28376b7065e09d2daa935a/src/jPretty.js#L11-L25
57,838
frankc60/jpretty
src/jPretty.js
jPretty
function jPretty(obj) { // make sure data is a json obj if(typeof obj === "string") { obj = obj.replace(/\s/g,""); obj = obj.replace(/'/g,'"'); } let gl; try { const p = JSON.parse(obj); gl = obj; // already stringified } catch (e) { // not stringified if(typeof obj === "string") { obj = obj.replace(/([,|{|\s|])([a-zA-Z0-9]*?)([\s|]*\:)/g,'$1"$2"$3'); } const s = JSON.stringify(obj); const k = JSON.parse(JSON.stringify(obj)); if (k && typeof k === 'object') { gl = s; } else { if(typeof obj === "string") { //console.log("ERROR: " + ); obj = obj.replace(/"/g,"'"); obj = obj.replace(/'/g,'"'); gl = ((obj)); } else { return new Error(`jpretty: input is not recognised json: ${typeof obj}- ${JSON.stringify(obj)}`); } } } return (() => { let jp = prettyJson(gl); if(typeof window !== 'undefined') { console.log("jPretty loaded in browser"); jp = jp.replace(/\{\}/g,"<br/>{}"); } return jp; })() }
javascript
function jPretty(obj) { // make sure data is a json obj if(typeof obj === "string") { obj = obj.replace(/\s/g,""); obj = obj.replace(/'/g,'"'); } let gl; try { const p = JSON.parse(obj); gl = obj; // already stringified } catch (e) { // not stringified if(typeof obj === "string") { obj = obj.replace(/([,|{|\s|])([a-zA-Z0-9]*?)([\s|]*\:)/g,'$1"$2"$3'); } const s = JSON.stringify(obj); const k = JSON.parse(JSON.stringify(obj)); if (k && typeof k === 'object') { gl = s; } else { if(typeof obj === "string") { //console.log("ERROR: " + ); obj = obj.replace(/"/g,"'"); obj = obj.replace(/'/g,'"'); gl = ((obj)); } else { return new Error(`jpretty: input is not recognised json: ${typeof obj}- ${JSON.stringify(obj)}`); } } } return (() => { let jp = prettyJson(gl); if(typeof window !== 'undefined') { console.log("jPretty loaded in browser"); jp = jp.replace(/\{\}/g,"<br/>{}"); } return jp; })() }
[ "function", "jPretty", "(", "obj", ")", "{", "// make sure data is a json obj", "if", "(", "typeof", "obj", "===", "\"string\"", ")", "{", "obj", "=", "obj", ".", "replace", "(", "/", "\\s", "/", "g", ",", "\"\"", ")", ";", "obj", "=", "obj", ".", "replace", "(", "/", "'", "/", "g", ",", "'\"'", ")", ";", "}", "let", "gl", ";", "try", "{", "const", "p", "=", "JSON", ".", "parse", "(", "obj", ")", ";", "gl", "=", "obj", ";", "// already stringified", "}", "catch", "(", "e", ")", "{", "// not stringified", "if", "(", "typeof", "obj", "===", "\"string\"", ")", "{", "obj", "=", "obj", ".", "replace", "(", "/", "([,|{|\\s|])([a-zA-Z0-9]*?)([\\s|]*\\:)", "/", "g", ",", "'$1\"$2\"$3'", ")", ";", "}", "const", "s", "=", "JSON", ".", "stringify", "(", "obj", ")", ";", "const", "k", "=", "JSON", ".", "parse", "(", "JSON", ".", "stringify", "(", "obj", ")", ")", ";", "if", "(", "k", "&&", "typeof", "k", "===", "'object'", ")", "{", "gl", "=", "s", ";", "}", "else", "{", "if", "(", "typeof", "obj", "===", "\"string\"", ")", "{", "//console.log(\"ERROR: \" + );", "obj", "=", "obj", ".", "replace", "(", "/", "\"", "/", "g", ",", "\"'\"", ")", ";", "obj", "=", "obj", ".", "replace", "(", "/", "'", "/", "g", ",", "'\"'", ")", ";", "gl", "=", "(", "(", "obj", ")", ")", ";", "}", "else", "{", "return", "new", "Error", "(", "`", "${", "typeof", "obj", "}", "${", "JSON", ".", "stringify", "(", "obj", ")", "}", "`", ")", ";", "}", "}", "}", "return", "(", "(", ")", "=>", "{", "let", "jp", "=", "prettyJson", "(", "gl", ")", ";", "if", "(", "typeof", "window", "!==", "'undefined'", ")", "{", "console", ".", "log", "(", "\"jPretty loaded in browser\"", ")", ";", "jp", "=", "jp", ".", "replace", "(", "/", "\\{\\}", "/", "g", ",", "\"<br/>{}\"", ")", ";", "}", "return", "jp", ";", "}", ")", "(", ")", "}" ]
Tidies up the json into a correct javascript object notation. @param {object} obj text or object. calls the main prettyJson module passing the json obj as argument.
[ "Tidies", "up", "the", "json", "into", "a", "correct", "javascript", "object", "notation", "." ]
15c26bff27542c83ce28376b7065e09d2daa935a
https://github.com/frankc60/jpretty/blob/15c26bff27542c83ce28376b7065e09d2daa935a/src/jPretty.js#L36-L77
57,839
Ma3Route/node-sdk
lib/client.js
Client
function Client(options) { options = options || { }; this._key = options.key || null; this._secret = options.secret || null; this._proxy = options.proxy || null; return this; }
javascript
function Client(options) { options = options || { }; this._key = options.key || null; this._secret = options.secret || null; this._proxy = options.proxy || null; return this; }
[ "function", "Client", "(", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "this", ".", "_key", "=", "options", ".", "key", "||", "null", ";", "this", ".", "_secret", "=", "options", ".", "secret", "||", "null", ";", "this", ".", "_proxy", "=", "options", ".", "proxy", "||", "null", ";", "return", "this", ";", "}" ]
An API client. All the module functions can be accessed using a client @example // create a new client var client = new sdk.Client({ key: "SoM3C0mP1exKey", secret: "pSu3d0rAnD0mS3CrEt" }); // retrieive a single traffic update client.trafficUpdates.getOne(1, function(err, items) { console.log(err, items); }); @constructor @param {Object} [options] @param {String} options.key - API key @param {String} options.secret - API secret @param {String} options.proxy - a valid URL to use as proxy
[ "An", "API", "client", ".", "All", "the", "module", "functions", "can", "be", "accessed", "using", "a", "client" ]
a2769d97d77d6f762d23e743bf4c749e2bad0d8a
https://github.com/Ma3Route/node-sdk/blob/a2769d97d77d6f762d23e743bf4c749e2bad0d8a/lib/client.js#L56-L62
57,840
AndiDittrich/Node.async-magic
lib/parallel.js
parallel
async function parallel(resolvers, limit=-1){ // set default limit if (limit < 1){ limit = 1000; } // buffer const results = []; // calculate chunk size // limit step size to input array size const chunkSize = Math.min(limit, resolvers.length); // process resolvers in chunks for (let i=0;i<resolvers.length;i=i+chunkSize){ // extract current chunk const chunk = resolvers.slice(i, Math.min(i+chunkSize, resolvers.length)); // resolve current chunk const intermediateResults = await Promise.all(chunk.map((r) => r.resolve())); // push results into buffer results.push(...intermediateResults); } // return results return results; }
javascript
async function parallel(resolvers, limit=-1){ // set default limit if (limit < 1){ limit = 1000; } // buffer const results = []; // calculate chunk size // limit step size to input array size const chunkSize = Math.min(limit, resolvers.length); // process resolvers in chunks for (let i=0;i<resolvers.length;i=i+chunkSize){ // extract current chunk const chunk = resolvers.slice(i, Math.min(i+chunkSize, resolvers.length)); // resolve current chunk const intermediateResults = await Promise.all(chunk.map((r) => r.resolve())); // push results into buffer results.push(...intermediateResults); } // return results return results; }
[ "async", "function", "parallel", "(", "resolvers", ",", "limit", "=", "-", "1", ")", "{", "// set default limit", "if", "(", "limit", "<", "1", ")", "{", "limit", "=", "1000", ";", "}", "// buffer", "const", "results", "=", "[", "]", ";", "// calculate chunk size", "// limit step size to input array size", "const", "chunkSize", "=", "Math", ".", "min", "(", "limit", ",", "resolvers", ".", "length", ")", ";", "// process resolvers in chunks", "for", "(", "let", "i", "=", "0", ";", "i", "<", "resolvers", ".", "length", ";", "i", "=", "i", "+", "chunkSize", ")", "{", "// extract current chunk", "const", "chunk", "=", "resolvers", ".", "slice", "(", "i", ",", "Math", ".", "min", "(", "i", "+", "chunkSize", ",", "resolvers", ".", "length", ")", ")", ";", "// resolve current chunk", "const", "intermediateResults", "=", "await", "Promise", ".", "all", "(", "chunk", ".", "map", "(", "(", "r", ")", "=>", "r", ".", "resolve", "(", ")", ")", ")", ";", "// push results into buffer", "results", ".", "push", "(", "...", "intermediateResults", ")", ";", "}", "// return results", "return", "results", ";", "}" ]
resolves multiple promises in parallel
[ "resolves", "multiple", "promises", "in", "parallel" ]
0c41dd27d8f7539bb24034bc23ce870f5f8a10b3
https://github.com/AndiDittrich/Node.async-magic/blob/0c41dd27d8f7539bb24034bc23ce870f5f8a10b3/lib/parallel.js#L2-L30
57,841
eklem/search-index-indexer
index.js
function(error, newIndex) { if (error) { console.log('Data error for ' + dataurl + '\n' + error) } if (!error) { index = newIndex var timeStart = Date.now() request(dataurl) .pipe(JSONStream.parse()) .pipe(index.defaultPipeline()) .pipe(index.add()) .on('data', function(data) { //console.dir(data) // What's going on in the indexing process }) .on('end', () => { var timeEnd = Date.now() var timeUsed = Math.trunc((timeEnd - timeStart) / 1000) console.log('Indexed in ' + timeUsed + ' seconds') }) } }
javascript
function(error, newIndex) { if (error) { console.log('Data error for ' + dataurl + '\n' + error) } if (!error) { index = newIndex var timeStart = Date.now() request(dataurl) .pipe(JSONStream.parse()) .pipe(index.defaultPipeline()) .pipe(index.add()) .on('data', function(data) { //console.dir(data) // What's going on in the indexing process }) .on('end', () => { var timeEnd = Date.now() var timeUsed = Math.trunc((timeEnd - timeStart) / 1000) console.log('Indexed in ' + timeUsed + ' seconds') }) } }
[ "function", "(", "error", ",", "newIndex", ")", "{", "if", "(", "error", ")", "{", "console", ".", "log", "(", "'Data error for '", "+", "dataurl", "+", "'\\n'", "+", "error", ")", "}", "if", "(", "!", "error", ")", "{", "index", "=", "newIndex", "var", "timeStart", "=", "Date", ".", "now", "(", ")", "request", "(", "dataurl", ")", ".", "pipe", "(", "JSONStream", ".", "parse", "(", ")", ")", ".", "pipe", "(", "index", ".", "defaultPipeline", "(", ")", ")", ".", "pipe", "(", "index", ".", "add", "(", ")", ")", ".", "on", "(", "'data'", ",", "function", "(", "data", ")", "{", "//console.dir(data) // What's going on in the indexing process", "}", ")", ".", "on", "(", "'end'", ",", "(", ")", "=>", "{", "var", "timeEnd", "=", "Date", ".", "now", "(", ")", "var", "timeUsed", "=", "Math", ".", "trunc", "(", "(", "timeEnd", "-", "timeStart", ")", "/", "1000", ")", "console", ".", "log", "(", "'Indexed in '", "+", "timeUsed", "+", "' seconds'", ")", "}", ")", "}", "}" ]
indexData const with pipeline pipeline
[ "indexData", "const", "with", "pipeline", "pipeline" ]
8be0dffad9f2babc486ad9f9de9918c4e976dcfa
https://github.com/eklem/search-index-indexer/blob/8be0dffad9f2babc486ad9f9de9918c4e976dcfa/index.js#L28-L48
57,842
greggman/hft-sample-ui
src/hft/scripts/misc/strings.js
function(str, len, padChar) { str = stringIt(str); if (str.length >= len) { return str; } var padStr = getPadding(padChar, len); return str + padStr.substr(str.length - len); }
javascript
function(str, len, padChar) { str = stringIt(str); if (str.length >= len) { return str; } var padStr = getPadding(padChar, len); return str + padStr.substr(str.length - len); }
[ "function", "(", "str", ",", "len", ",", "padChar", ")", "{", "str", "=", "stringIt", "(", "str", ")", ";", "if", "(", "str", ".", "length", ">=", "len", ")", "{", "return", "str", ";", "}", "var", "padStr", "=", "getPadding", "(", "padChar", ",", "len", ")", ";", "return", "str", "+", "padStr", ".", "substr", "(", "str", ".", "length", "-", "len", ")", ";", "}" ]
Pad string on right @param {string} str string to pad @param {number} len number of characters to pad to @param {string} padChar character to pad with @returns {string} padded string. @memberOf module:Strings
[ "Pad", "string", "on", "right" ]
b9e20afd5183db73522bcfae48225c87e01f68c0
https://github.com/greggman/hft-sample-ui/blob/b9e20afd5183db73522bcfae48225c87e01f68c0/src/hft/scripts/misc/strings.js#L75-L82
57,843
greggman/hft-sample-ui
src/hft/scripts/misc/strings.js
function(str, start) { return (str.length >= start.length && str.substr(0, start.length) === start); }
javascript
function(str, start) { return (str.length >= start.length && str.substr(0, start.length) === start); }
[ "function", "(", "str", ",", "start", ")", "{", "return", "(", "str", ".", "length", ">=", "start", ".", "length", "&&", "str", ".", "substr", "(", "0", ",", "start", ".", "length", ")", "===", "start", ")", ";", "}" ]
True if string starts with prefix @static @param {String} str string to check for start @param {String} prefix start value @returns {Boolean} true if str starts with prefix @memberOf module:Strings
[ "True", "if", "string", "starts", "with", "prefix" ]
b9e20afd5183db73522bcfae48225c87e01f68c0
https://github.com/greggman/hft-sample-ui/blob/b9e20afd5183db73522bcfae48225c87e01f68c0/src/hft/scripts/misc/strings.js#L151-L154
57,844
greggman/hft-sample-ui
src/hft/scripts/misc/strings.js
function(str, end) { return (str.length >= end.length && str.substring(str.length - end.length) === end); }
javascript
function(str, end) { return (str.length >= end.length && str.substring(str.length - end.length) === end); }
[ "function", "(", "str", ",", "end", ")", "{", "return", "(", "str", ".", "length", ">=", "end", ".", "length", "&&", "str", ".", "substring", "(", "str", ".", "length", "-", "end", ".", "length", ")", "===", "end", ")", ";", "}" ]
True if string ends with suffix @param {String} str string to check for start @param {String} suffix start value @returns {Boolean} true if str starts with suffix @memberOf module:Strings
[ "True", "if", "string", "ends", "with", "suffix" ]
b9e20afd5183db73522bcfae48225c87e01f68c0
https://github.com/greggman/hft-sample-ui/blob/b9e20afd5183db73522bcfae48225c87e01f68c0/src/hft/scripts/misc/strings.js#L163-L166
57,845
vonWolfehaus/gulp-sort-amd
shim/define.js
set
function set(key, module, global) { var m = null; var isGlobal = global && typeof global !== 'undefined'; // check to make sure the module has been assigned only once if (isGlobal) { if (global.hasOwnProperty(key)) { throw '[define-shim] Module ' + key + ' already exists'; } } else if (_map.hasOwnProperty(key)) { throw '[define-shim] Module ' + key + ' already exists'; return; } // construct the module if needed if (typeof module === 'function') m = module(get); else m = module; // assign the module to whichever object is preferred if (isGlobal) global[key] = m; else _map[key] = m; }
javascript
function set(key, module, global) { var m = null; var isGlobal = global && typeof global !== 'undefined'; // check to make sure the module has been assigned only once if (isGlobal) { if (global.hasOwnProperty(key)) { throw '[define-shim] Module ' + key + ' already exists'; } } else if (_map.hasOwnProperty(key)) { throw '[define-shim] Module ' + key + ' already exists'; return; } // construct the module if needed if (typeof module === 'function') m = module(get); else m = module; // assign the module to whichever object is preferred if (isGlobal) global[key] = m; else _map[key] = m; }
[ "function", "set", "(", "key", ",", "module", ",", "global", ")", "{", "var", "m", "=", "null", ";", "var", "isGlobal", "=", "global", "&&", "typeof", "global", "!==", "'undefined'", ";", "// check to make sure the module has been assigned only once", "if", "(", "isGlobal", ")", "{", "if", "(", "global", ".", "hasOwnProperty", "(", "key", ")", ")", "{", "throw", "'[define-shim] Module '", "+", "key", "+", "' already exists'", ";", "}", "}", "else", "if", "(", "_map", ".", "hasOwnProperty", "(", "key", ")", ")", "{", "throw", "'[define-shim] Module '", "+", "key", "+", "' already exists'", ";", "return", ";", "}", "// construct the module if needed", "if", "(", "typeof", "module", "===", "'function'", ")", "m", "=", "module", "(", "get", ")", ";", "else", "m", "=", "module", ";", "// assign the module to whichever object is preferred", "if", "(", "isGlobal", ")", "global", "[", "key", "]", "=", "m", ";", "else", "_map", "[", "key", "]", "=", "m", ";", "}" ]
global is an optional object and will attach the constructed module to it if present
[ "global", "is", "an", "optional", "object", "and", "will", "attach", "the", "constructed", "module", "to", "it", "if", "present" ]
d778710d95e0d82de68bd767f063b7430815c330
https://github.com/vonWolfehaus/gulp-sort-amd/blob/d778710d95e0d82de68bd767f063b7430815c330/shim/define.js#L11-L33
57,846
queckezz/list
lib/insert.js
insert
function insert (i, val, array) { array = copy(array) array.splice(i, 0, val) return array }
javascript
function insert (i, val, array) { array = copy(array) array.splice(i, 0, val) return array }
[ "function", "insert", "(", "i", ",", "val", ",", "array", ")", "{", "array", "=", "copy", "(", "array", ")", "array", ".", "splice", "(", "i", ",", "0", ",", "val", ")", "return", "array", "}" ]
Returns a new array with the supplied element inserted at index `i`. @param {Int} i @param {Any} val @param {Array} array @return {Array}
[ "Returns", "a", "new", "array", "with", "the", "supplied", "element", "inserted", "at", "index", "i", "." ]
a26130020b447a1aa136f0fed3283821490f7da4
https://github.com/queckezz/list/blob/a26130020b447a1aa136f0fed3283821490f7da4/lib/insert.js#L14-L18
57,847
AmrEldib/agol-data-faker
index.js
generateFakeDataForSchema
function generateFakeDataForSchema(schemaName) { return new RSVP.Promise(function (resolve, reject) { agolSchemas.getSchema(schemaName).then(function (schema) { // Generate fake data var fakeData = jsf(schema); // return fake data resolve(fakeData); }); }); }
javascript
function generateFakeDataForSchema(schemaName) { return new RSVP.Promise(function (resolve, reject) { agolSchemas.getSchema(schemaName).then(function (schema) { // Generate fake data var fakeData = jsf(schema); // return fake data resolve(fakeData); }); }); }
[ "function", "generateFakeDataForSchema", "(", "schemaName", ")", "{", "return", "new", "RSVP", ".", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "agolSchemas", ".", "getSchema", "(", "schemaName", ")", ".", "then", "(", "function", "(", "schema", ")", "{", "// Generate fake data", "var", "fakeData", "=", "jsf", "(", "schema", ")", ";", "// return fake data", "resolve", "(", "fakeData", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
Generate fake data for a certain schema @param {string} schemaName Name of the schema to be generated. @returns {object} Promise. The resolve function has one parameter representing the generated fake data.
[ "Generate", "fake", "data", "for", "a", "certain", "schema" ]
9bb7e29698a34effd98afe135d053256050a072e
https://github.com/AmrEldib/agol-data-faker/blob/9bb7e29698a34effd98afe135d053256050a072e/index.js#L16-L25
57,848
byu-oit/fully-typed
bin/fully-typed.js
FullyTyped
function FullyTyped (configuration) { if (arguments.length === 0 || configuration === null) configuration = {}; // validate input parameter if (!util.isPlainObject(configuration)) { throw Error('If provided, the schema configuration must be a plain object. Received: ' + configuration); } // get a copy of the configuration const config = util.copy(configuration); // if type is not specified then use the default if (!config.type) config.type = 'typed'; // get the controller data const data = FullyTyped.controllers.get(config.type); // type is invalid if (!data) throw Error('Unknown type: ' + config.type); // return a schema object return new Schema(config, data); }
javascript
function FullyTyped (configuration) { if (arguments.length === 0 || configuration === null) configuration = {}; // validate input parameter if (!util.isPlainObject(configuration)) { throw Error('If provided, the schema configuration must be a plain object. Received: ' + configuration); } // get a copy of the configuration const config = util.copy(configuration); // if type is not specified then use the default if (!config.type) config.type = 'typed'; // get the controller data const data = FullyTyped.controllers.get(config.type); // type is invalid if (!data) throw Error('Unknown type: ' + config.type); // return a schema object return new Schema(config, data); }
[ "function", "FullyTyped", "(", "configuration", ")", "{", "if", "(", "arguments", ".", "length", "===", "0", "||", "configuration", "===", "null", ")", "configuration", "=", "{", "}", ";", "// validate input parameter", "if", "(", "!", "util", ".", "isPlainObject", "(", "configuration", ")", ")", "{", "throw", "Error", "(", "'If provided, the schema configuration must be a plain object. Received: '", "+", "configuration", ")", ";", "}", "// get a copy of the configuration", "const", "config", "=", "util", ".", "copy", "(", "configuration", ")", ";", "// if type is not specified then use the default", "if", "(", "!", "config", ".", "type", ")", "config", ".", "type", "=", "'typed'", ";", "// get the controller data", "const", "data", "=", "FullyTyped", ".", "controllers", ".", "get", "(", "config", ".", "type", ")", ";", "// type is invalid", "if", "(", "!", "data", ")", "throw", "Error", "(", "'Unknown type: '", "+", "config", ".", "type", ")", ";", "// return a schema object", "return", "new", "Schema", "(", "config", ",", "data", ")", ";", "}" ]
Validate a value against the schema and throw an error if encountered. @function @name FullyTyped#validate @param {*} value @param {string} [prefix=''] @throws {Error} Get a typed schema. @constructor @param {object, object[]} [configuration={}] @returns {FullyTyped}
[ "Validate", "a", "value", "against", "the", "schema", "and", "throw", "an", "error", "if", "encountered", "." ]
ed6b3ed88ffc72990acffb765232eaaee261afef
https://github.com/byu-oit/fully-typed/blob/ed6b3ed88ffc72990acffb765232eaaee261afef/bin/fully-typed.js#L71-L93
57,849
justinhelmer/vinyl-tasks
lib/hooks.js
validate
function validate(task, options) { if (!task) { if (options.verbose) { console.log(' -', chalk.bold.yellow('[WARNING]:'), 'Task does not exist'); } return Promise.resolve(false); } return new Promise(function(resolve, reject) { var hooks = task.hooks(options) || {}; if (hooks.validate) { var result = hooks.validate(); if (isPromise(result)) { result.then(function(result) { resolve(result !== false); // undefined should represent truthy }); } else { resolve(result); } } else { resolve(true); } }); }
javascript
function validate(task, options) { if (!task) { if (options.verbose) { console.log(' -', chalk.bold.yellow('[WARNING]:'), 'Task does not exist'); } return Promise.resolve(false); } return new Promise(function(resolve, reject) { var hooks = task.hooks(options) || {}; if (hooks.validate) { var result = hooks.validate(); if (isPromise(result)) { result.then(function(result) { resolve(result !== false); // undefined should represent truthy }); } else { resolve(result); } } else { resolve(true); } }); }
[ "function", "validate", "(", "task", ",", "options", ")", "{", "if", "(", "!", "task", ")", "{", "if", "(", "options", ".", "verbose", ")", "{", "console", ".", "log", "(", "' -'", ",", "chalk", ".", "bold", ".", "yellow", "(", "'[WARNING]:'", ")", ",", "'Task does not exist'", ")", ";", "}", "return", "Promise", ".", "resolve", "(", "false", ")", ";", "}", "return", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "var", "hooks", "=", "task", ".", "hooks", "(", "options", ")", "||", "{", "}", ";", "if", "(", "hooks", ".", "validate", ")", "{", "var", "result", "=", "hooks", ".", "validate", "(", ")", ";", "if", "(", "isPromise", "(", "result", ")", ")", "{", "result", ".", "then", "(", "function", "(", "result", ")", "{", "resolve", "(", "result", "!==", "false", ")", ";", "// undefined should represent truthy", "}", ")", ";", "}", "else", "{", "resolve", "(", "result", ")", ";", "}", "}", "else", "{", "resolve", "(", "true", ")", ";", "}", "}", ")", ";", "}" ]
Hook executed before task is run. Validate whether or not the task should be run. Should return `true` or `false` to indicate whether or not to run the task. Can also return a bluebird promise that resolves with the value of `true` or `false`. @name validate @param {object} task - The task object. @param {object} [options] - Options passed to the task runner. Uses options.verbose. @return {bluebird promise} - Resolves with `true` if the task validation succeeds, or `false` if the task validation fails.
[ "Hook", "executed", "before", "task", "is", "run", "." ]
eca1f79065a3653023896c4f546dc44dbac81e62
https://github.com/justinhelmer/vinyl-tasks/blob/eca1f79065a3653023896c4f546dc44dbac81e62/lib/hooks.js#L66-L92
57,850
leomp12/console-files
index.js
log
function log (out, desc) { logger.log(header()) if (desc) { logger.log(desc) } logger.log(out) logger.log() }
javascript
function log (out, desc) { logger.log(header()) if (desc) { logger.log(desc) } logger.log(out) logger.log() }
[ "function", "log", "(", "out", ",", "desc", ")", "{", "logger", ".", "log", "(", "header", "(", ")", ")", "if", "(", "desc", ")", "{", "logger", ".", "log", "(", "desc", ")", "}", "logger", ".", "log", "(", "out", ")", "logger", ".", "log", "(", ")", "}" ]
function to substitute console.log
[ "function", "to", "substitute", "console", ".", "log" ]
07b12b6adee0db8f1bc819f500a3be667838de74
https://github.com/leomp12/console-files/blob/07b12b6adee0db8f1bc819f500a3be667838de74/index.js#L33-L40
57,851
leomp12/console-files
index.js
error
function error (out, desc) { logger.error(header()) if (desc) { logger.error(desc) } logger.error(out) logger.error() }
javascript
function error (out, desc) { logger.error(header()) if (desc) { logger.error(desc) } logger.error(out) logger.error() }
[ "function", "error", "(", "out", ",", "desc", ")", "{", "logger", ".", "error", "(", "header", "(", ")", ")", "if", "(", "desc", ")", "{", "logger", ".", "error", "(", "desc", ")", "}", "logger", ".", "error", "(", "out", ")", "logger", ".", "error", "(", ")", "}" ]
function to substitute console.error
[ "function", "to", "substitute", "console", ".", "error" ]
07b12b6adee0db8f1bc819f500a3be667838de74
https://github.com/leomp12/console-files/blob/07b12b6adee0db8f1bc819f500a3be667838de74/index.js#L43-L50
57,852
robertblackwell/yake
src/yake.js
watch
function watch(glob, taskName) { var watcher = chokidar.watch(glob, {persistent: true,}); watcher.on('ready', ()=> { watcher.on('all', (event, path)=> { invokeTask(taskName); }); }); }
javascript
function watch(glob, taskName) { var watcher = chokidar.watch(glob, {persistent: true,}); watcher.on('ready', ()=> { watcher.on('all', (event, path)=> { invokeTask(taskName); }); }); }
[ "function", "watch", "(", "glob", ",", "taskName", ")", "{", "var", "watcher", "=", "chokidar", ".", "watch", "(", "glob", ",", "{", "persistent", ":", "true", ",", "}", ")", ";", "watcher", ".", "on", "(", "'ready'", ",", "(", ")", "=>", "{", "watcher", ".", "on", "(", "'all'", ",", "(", "event", ",", "path", ")", "=>", "{", "invokeTask", "(", "taskName", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
Watch files and then invoke a task
[ "Watch", "files", "and", "then", "invoke", "a", "task" ]
172b02e29303fb718bac88bbda9b85749c57169c
https://github.com/robertblackwell/yake/blob/172b02e29303fb718bac88bbda9b85749c57169c/src/yake.js#L52-L62
57,853
robertblackwell/yake
src/yake.js
invokeTask
function invokeTask(taskName) { const tc = TASKS.globals.globalTaskCollection; const t = tc.getByName(taskName); if (t === undefined) { YERROR.raiseError(`task ${taskName} not found`); } TASKS.invokeTask(tc, t); }
javascript
function invokeTask(taskName) { const tc = TASKS.globals.globalTaskCollection; const t = tc.getByName(taskName); if (t === undefined) { YERROR.raiseError(`task ${taskName} not found`); } TASKS.invokeTask(tc, t); }
[ "function", "invokeTask", "(", "taskName", ")", "{", "const", "tc", "=", "TASKS", ".", "globals", ".", "globalTaskCollection", ";", "const", "t", "=", "tc", ".", "getByName", "(", "taskName", ")", ";", "if", "(", "t", "===", "undefined", ")", "{", "YERROR", ".", "raiseError", "(", "`", "${", "taskName", "}", "`", ")", ";", "}", "TASKS", ".", "invokeTask", "(", "tc", ",", "t", ")", ";", "}" ]
Invoke a task by name
[ "Invoke", "a", "task", "by", "name" ]
172b02e29303fb718bac88bbda9b85749c57169c
https://github.com/robertblackwell/yake/blob/172b02e29303fb718bac88bbda9b85749c57169c/src/yake.js#L67-L77
57,854
creationix/git-node-platform
sha1.js
create
function create() { var sha1sum = crypto.createHash('sha1'); return { update: update, digest: digest }; function update(data) { sha1sum.update(data); } function digest() { return sha1sum.digest('hex'); } }
javascript
function create() { var sha1sum = crypto.createHash('sha1'); return { update: update, digest: digest }; function update(data) { sha1sum.update(data); } function digest() { return sha1sum.digest('hex'); } }
[ "function", "create", "(", ")", "{", "var", "sha1sum", "=", "crypto", ".", "createHash", "(", "'sha1'", ")", ";", "return", "{", "update", ":", "update", ",", "digest", ":", "digest", "}", ";", "function", "update", "(", "data", ")", "{", "sha1sum", ".", "update", "(", "data", ")", ";", "}", "function", "digest", "(", ")", "{", "return", "sha1sum", ".", "digest", "(", "'hex'", ")", ";", "}", "}" ]
A streaming interface for when nothing is passed in.
[ "A", "streaming", "interface", "for", "when", "nothing", "is", "passed", "in", "." ]
fa9b0367e3b92b6f4f50d93b0d2d7ba93cb27fb9
https://github.com/creationix/git-node-platform/blob/fa9b0367e3b92b6f4f50d93b0d2d7ba93cb27fb9/sha1.js#L11-L22
57,855
georgenorman/tessel-kit
lib/general-utils.js
function(obj, maxNumProperties) { var result = ""; maxNumProperties = maxNumProperties === undefined ? Number.MAX_VALUE : maxNumProperties; if (obj !== undefined && obj !== null) { var separator = ""; var propCount = 0; for (var propertyName in obj) { var objValue; if ((obj[propertyName]) === undefined) { objValue = "*** undefined ***"; } else { objValue = obj[propertyName]; } result += separator + propertyName + " = " + objValue; separator = ",\n"; propCount++; if (propCount >= maxNumProperties) { break; } } } return result; }
javascript
function(obj, maxNumProperties) { var result = ""; maxNumProperties = maxNumProperties === undefined ? Number.MAX_VALUE : maxNumProperties; if (obj !== undefined && obj !== null) { var separator = ""; var propCount = 0; for (var propertyName in obj) { var objValue; if ((obj[propertyName]) === undefined) { objValue = "*** undefined ***"; } else { objValue = obj[propertyName]; } result += separator + propertyName + " = " + objValue; separator = ",\n"; propCount++; if (propCount >= maxNumProperties) { break; } } } return result; }
[ "function", "(", "obj", ",", "maxNumProperties", ")", "{", "var", "result", "=", "\"\"", ";", "maxNumProperties", "=", "maxNumProperties", "===", "undefined", "?", "Number", ".", "MAX_VALUE", ":", "maxNumProperties", ";", "if", "(", "obj", "!==", "undefined", "&&", "obj", "!==", "null", ")", "{", "var", "separator", "=", "\"\"", ";", "var", "propCount", "=", "0", ";", "for", "(", "var", "propertyName", "in", "obj", ")", "{", "var", "objValue", ";", "if", "(", "(", "obj", "[", "propertyName", "]", ")", "===", "undefined", ")", "{", "objValue", "=", "\"*** undefined ***\"", ";", "}", "else", "{", "objValue", "=", "obj", "[", "propertyName", "]", ";", "}", "result", "+=", "separator", "+", "propertyName", "+", "\" = \"", "+", "objValue", ";", "separator", "=", "\",\\n\"", ";", "propCount", "++", ";", "if", "(", "propCount", ">=", "maxNumProperties", ")", "{", "break", ";", "}", "}", "}", "return", "result", ";", "}" ]
Return a String, of the form "propertyName = propertyValue\n", for every property of the given obj, or until maxNumProperties has been reached. @param obj object to retrieve the properties from. @param maxNumProperties optional limiter for the number of properties to retrieve. @returns {string} new-line separated set of property/value pairs
[ "Return", "a", "String", "of", "the", "form", "propertyName", "=", "propertyValue", "\\", "n", "for", "every", "property", "of", "the", "given", "obj", "or", "until", "maxNumProperties", "has", "been", "reached", "." ]
487e91360f0ecf8500d24297228842e2c01ac762
https://github.com/georgenorman/tessel-kit/blob/487e91360f0ecf8500d24297228842e2c01ac762/lib/general-utils.js#L86-L115
57,856
georgenorman/tessel-kit
lib/general-utils.js
function(argumentName, defaultValue) { var result = argMap[argumentName]; if (this.isEmpty(result) && this.isNotEmpty(defaultValue)) { if (typeof defaultValue === 'object') { result = defaultValue[argumentName]; } else { result = defaultValue; } } return result; }
javascript
function(argumentName, defaultValue) { var result = argMap[argumentName]; if (this.isEmpty(result) && this.isNotEmpty(defaultValue)) { if (typeof defaultValue === 'object') { result = defaultValue[argumentName]; } else { result = defaultValue; } } return result; }
[ "function", "(", "argumentName", ",", "defaultValue", ")", "{", "var", "result", "=", "argMap", "[", "argumentName", "]", ";", "if", "(", "this", ".", "isEmpty", "(", "result", ")", "&&", "this", ".", "isNotEmpty", "(", "defaultValue", ")", ")", "{", "if", "(", "typeof", "defaultValue", "===", "'object'", ")", "{", "result", "=", "defaultValue", "[", "argumentName", "]", ";", "}", "else", "{", "result", "=", "defaultValue", ";", "}", "}", "return", "result", ";", "}" ]
Return the commandline argument specified by argumentName. If not found, then return the specified defaultValue. Example commandline: "tessel run app/app.js climatePort=A foo=1.23 bar=4.56" Example Usages (for the commandline shown above): // returns "1.23" tesselKit.tesselUtils.getArgumentValue("foo", "asdfgh"); // returns "qwerty" tesselKit.tesselUtils.getArgumentValue("test", "qwerty");
[ "Return", "the", "commandline", "argument", "specified", "by", "argumentName", ".", "If", "not", "found", "then", "return", "the", "specified", "defaultValue", "." ]
487e91360f0ecf8500d24297228842e2c01ac762
https://github.com/georgenorman/tessel-kit/blob/487e91360f0ecf8500d24297228842e2c01ac762/lib/general-utils.js#L155-L167
57,857
nutella-framework/nutella_lib.js
gulpfile.js
bundle
function bundle() { return bundler.bundle() // log errors if they happen .on('error', gutil.log.bind(gutil, 'Browserify Error')) .pipe(source('nutella_lib.js')) .pipe(gulp.dest('./dist')); }
javascript
function bundle() { return bundler.bundle() // log errors if they happen .on('error', gutil.log.bind(gutil, 'Browserify Error')) .pipe(source('nutella_lib.js')) .pipe(gulp.dest('./dist')); }
[ "function", "bundle", "(", ")", "{", "return", "bundler", ".", "bundle", "(", ")", "// log errors if they happen", ".", "on", "(", "'error'", ",", "gutil", ".", "log", ".", "bind", "(", "gutil", ",", "'Browserify Error'", ")", ")", ".", "pipe", "(", "source", "(", "'nutella_lib.js'", ")", ")", ".", "pipe", "(", "gulp", ".", "dest", "(", "'./dist'", ")", ")", ";", "}" ]
output build logs to terminal
[ "output", "build", "logs", "to", "terminal" ]
b3a3406a407e2a1ada6edcc503b70991f9cb249b
https://github.com/nutella-framework/nutella_lib.js/blob/b3a3406a407e2a1ada6edcc503b70991f9cb249b/gulpfile.js#L17-L23
57,858
TheRoSS/jsfilter
lib/error.js
JFP_Error
function JFP_Error(message) { Error.call(this, message); Object.defineProperty(this, "name", { value: this.constructor.name }); Object.defineProperty(this, "message", { value: message }); if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } else { Object.defineProperty(this, "stack", { value: (new Error()).stack }); } }
javascript
function JFP_Error(message) { Error.call(this, message); Object.defineProperty(this, "name", { value: this.constructor.name }); Object.defineProperty(this, "message", { value: message }); if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } else { Object.defineProperty(this, "stack", { value: (new Error()).stack }); } }
[ "function", "JFP_Error", "(", "message", ")", "{", "Error", ".", "call", "(", "this", ",", "message", ")", ";", "Object", ".", "defineProperty", "(", "this", ",", "\"name\"", ",", "{", "value", ":", "this", ".", "constructor", ".", "name", "}", ")", ";", "Object", ".", "defineProperty", "(", "this", ",", "\"message\"", ",", "{", "value", ":", "message", "}", ")", ";", "if", "(", "Error", ".", "captureStackTrace", ")", "{", "Error", ".", "captureStackTrace", "(", "this", ",", "this", ".", "constructor", ")", ";", "}", "else", "{", "Object", ".", "defineProperty", "(", "this", ",", "\"stack\"", ",", "{", "value", ":", "(", "new", "Error", "(", ")", ")", ".", "stack", "}", ")", ";", "}", "}" ]
JFP_Error - base error class @param {string} message @constructor
[ "JFP_Error", "-", "base", "error", "class" ]
e06e689e7ad175eb1479645c9b4e38fadc385cf5
https://github.com/TheRoSS/jsfilter/blob/e06e689e7ad175eb1479645c9b4e38fadc385cf5/lib/error.js#L17-L35
57,859
AndreasMadsen/piccolo
lib/modules/util.js
type
function type(input) { //If the input value is null, undefined or NaN the toStringTypes object shouldn't be used if (input === null || input === undefined || (input !== input && String(input) === "NaN")) { return String(input); } // use the typeMap to detect the type and fallback to object if the type wasn't found return typeMap[Object.prototype.toString.call(input)] || "object"; }
javascript
function type(input) { //If the input value is null, undefined or NaN the toStringTypes object shouldn't be used if (input === null || input === undefined || (input !== input && String(input) === "NaN")) { return String(input); } // use the typeMap to detect the type and fallback to object if the type wasn't found return typeMap[Object.prototype.toString.call(input)] || "object"; }
[ "function", "type", "(", "input", ")", "{", "//If the input value is null, undefined or NaN the toStringTypes object shouldn't be used", "if", "(", "input", "===", "null", "||", "input", "===", "undefined", "||", "(", "input", "!==", "input", "&&", "String", "(", "input", ")", "===", "\"NaN\"", ")", ")", "{", "return", "String", "(", "input", ")", ";", "}", "// use the typeMap to detect the type and fallback to object if the type wasn't found", "return", "typeMap", "[", "Object", ".", "prototype", ".", "toString", ".", "call", "(", "input", ")", "]", "||", "\"object\"", ";", "}" ]
detect type using typeMap
[ "detect", "type", "using", "typeMap" ]
ef43f5634c564eef0d21a4a6aa103b2f1e3baa3d
https://github.com/AndreasMadsen/piccolo/blob/ef43f5634c564eef0d21a4a6aa103b2f1e3baa3d/lib/modules/util.js#L14-L23
57,860
AndreasMadsen/piccolo
lib/modules/util.js
inherits
function inherits(constructor, superConstructor) { constructor.super_ = superConstructor; constructor.prototype = Object.create(superConstructor.prototype, { 'constructor': { 'value': constructor, 'enumerable': false, 'writable': true, 'configurable': true } }); }
javascript
function inherits(constructor, superConstructor) { constructor.super_ = superConstructor; constructor.prototype = Object.create(superConstructor.prototype, { 'constructor': { 'value': constructor, 'enumerable': false, 'writable': true, 'configurable': true } }); }
[ "function", "inherits", "(", "constructor", ",", "superConstructor", ")", "{", "constructor", ".", "super_", "=", "superConstructor", ";", "constructor", ".", "prototype", "=", "Object", ".", "create", "(", "superConstructor", ".", "prototype", ",", "{", "'constructor'", ":", "{", "'value'", ":", "constructor", ",", "'enumerable'", ":", "false", ",", "'writable'", ":", "true", ",", "'configurable'", ":", "true", "}", "}", ")", ";", "}" ]
Inherit the prototype methods from one constructor into another
[ "Inherit", "the", "prototype", "methods", "from", "one", "constructor", "into", "another" ]
ef43f5634c564eef0d21a4a6aa103b2f1e3baa3d
https://github.com/AndreasMadsen/piccolo/blob/ef43f5634c564eef0d21a4a6aa103b2f1e3baa3d/lib/modules/util.js#L37-L47
57,861
enten/confectioner
lib/confectioner.js
Confectioner
function Confectioner() { if (!(this instanceof Confectioner)) { var instance = Object.create(clazz); Confectioner.apply(instance, arguments); return instance; } this.keys = []; this.addKey.apply(this, Array.prototype.slice.call(arguments)); }
javascript
function Confectioner() { if (!(this instanceof Confectioner)) { var instance = Object.create(clazz); Confectioner.apply(instance, arguments); return instance; } this.keys = []; this.addKey.apply(this, Array.prototype.slice.call(arguments)); }
[ "function", "Confectioner", "(", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Confectioner", ")", ")", "{", "var", "instance", "=", "Object", ".", "create", "(", "clazz", ")", ";", "Confectioner", ".", "apply", "(", "instance", ",", "arguments", ")", ";", "return", "instance", ";", "}", "this", ".", "keys", "=", "[", "]", ";", "this", ".", "addKey", ".", "apply", "(", "this", ",", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ")", ")", ";", "}" ]
Initialize a new `Confectioner`. @public @class @constructor Confectioner @param {Mixed} ... @example var config = Confectioner(); @example var config = Confectioner('env', 'NODE_ENV', 'development'); @example var config = Confectioner({ host: { envName: 'MY_HOST', defValue: 'localhost' }, port: { envName: 'MY_PORT', defValue: 1337 }, });
[ "Initialize", "a", "new", "Confectioner", "." ]
4f735e8ee1e36ebe250a2a866b07e10820207346
https://github.com/enten/confectioner/blob/4f735e8ee1e36ebe250a2a866b07e10820207346/lib/confectioner.js#L193-L203
57,862
fardog/node-random-lib
index.js
floatFromBuffer
function floatFromBuffer (buf) { if (buf.length < FLOAT_ENTROPY_BYTES) { throw new Error( 'buffer must contain at least ' + FLOAT_ENTROPY_BYTES + ' bytes of entropy' ) } var position = 0 // http://stackoverflow.com/questions/15753019/floating-point-number-from-crypto-randombytes-in-javascript return ((((((( buf[position++] % 32) / 32 + buf[position++]) / 256 + buf[position++]) / 256 + buf[position++]) / 256 + buf[position++]) / 256 + buf[position++]) / 256 + buf[position]) / 256 }
javascript
function floatFromBuffer (buf) { if (buf.length < FLOAT_ENTROPY_BYTES) { throw new Error( 'buffer must contain at least ' + FLOAT_ENTROPY_BYTES + ' bytes of entropy' ) } var position = 0 // http://stackoverflow.com/questions/15753019/floating-point-number-from-crypto-randombytes-in-javascript return ((((((( buf[position++] % 32) / 32 + buf[position++]) / 256 + buf[position++]) / 256 + buf[position++]) / 256 + buf[position++]) / 256 + buf[position++]) / 256 + buf[position]) / 256 }
[ "function", "floatFromBuffer", "(", "buf", ")", "{", "if", "(", "buf", ".", "length", "<", "FLOAT_ENTROPY_BYTES", ")", "{", "throw", "new", "Error", "(", "'buffer must contain at least '", "+", "FLOAT_ENTROPY_BYTES", "+", "' bytes of entropy'", ")", "}", "var", "position", "=", "0", "// http://stackoverflow.com/questions/15753019/floating-point-number-from-crypto-randombytes-in-javascript", "return", "(", "(", "(", "(", "(", "(", "(", "buf", "[", "position", "++", "]", "%", "32", ")", "/", "32", "+", "buf", "[", "position", "++", "]", ")", "/", "256", "+", "buf", "[", "position", "++", "]", ")", "/", "256", "+", "buf", "[", "position", "++", "]", ")", "/", "256", "+", "buf", "[", "position", "++", "]", ")", "/", "256", "+", "buf", "[", "position", "++", "]", ")", "/", "256", "+", "buf", "[", "position", "]", ")", "/", "256", "}" ]
Given a buffer containing bytes of entropy, generate a double-precision 64-bit float. @param {Buffer} buf a buffer of bytes @returns {Number} a float
[ "Given", "a", "buffer", "containing", "bytes", "of", "entropy", "generate", "a", "double", "-", "precision", "64", "-", "bit", "float", "." ]
1dc05c8ada71049cbd2382239c1c6c6042bf3d97
https://github.com/fardog/node-random-lib/blob/1dc05c8ada71049cbd2382239c1c6c6042bf3d97/index.js#L142-L159
57,863
fardog/node-random-lib
index.js
applyNSync
function applyNSync () { var args = Array.prototype.slice.call(arguments) var fn = args.shift() var num = args.shift() var arr = [] for (var i = 0; i < num; ++i) { arr.push(fn.apply(null, args)) } return arr }
javascript
function applyNSync () { var args = Array.prototype.slice.call(arguments) var fn = args.shift() var num = args.shift() var arr = [] for (var i = 0; i < num; ++i) { arr.push(fn.apply(null, args)) } return arr }
[ "function", "applyNSync", "(", ")", "{", "var", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ")", "var", "fn", "=", "args", ".", "shift", "(", ")", "var", "num", "=", "args", ".", "shift", "(", ")", "var", "arr", "=", "[", "]", "for", "(", "var", "i", "=", "0", ";", "i", "<", "num", ";", "++", "i", ")", "{", "arr", ".", "push", "(", "fn", ".", "apply", "(", "null", ",", "args", ")", ")", "}", "return", "arr", "}" ]
Apply a function a number of times, returning an array of the results. @param {Function} fn the function to call on each @param {Number} num the size of the array to generate @param {*} args... a list of args to pass to the function fn @returns {Array} the filled array
[ "Apply", "a", "function", "a", "number", "of", "times", "returning", "an", "array", "of", "the", "results", "." ]
1dc05c8ada71049cbd2382239c1c6c6042bf3d97
https://github.com/fardog/node-random-lib/blob/1dc05c8ada71049cbd2382239c1c6c6042bf3d97/index.js#L169-L181
57,864
fardog/node-random-lib
index.js
applyN
function applyN (fn, opts, ready) { var num = opts.num || 0 var unique = opts.unique var arr = [] fn(opts, onValue) function onValue (err, value) { if (err) { return ready(err) } if (!unique || arr.indexOf(value) === -1) { arr.push(value) } if (arr.length >= num) { return ready(null, arr) } process.nextTick(function () { fn(opts, onValue) }) } }
javascript
function applyN (fn, opts, ready) { var num = opts.num || 0 var unique = opts.unique var arr = [] fn(opts, onValue) function onValue (err, value) { if (err) { return ready(err) } if (!unique || arr.indexOf(value) === -1) { arr.push(value) } if (arr.length >= num) { return ready(null, arr) } process.nextTick(function () { fn(opts, onValue) }) } }
[ "function", "applyN", "(", "fn", ",", "opts", ",", "ready", ")", "{", "var", "num", "=", "opts", ".", "num", "||", "0", "var", "unique", "=", "opts", ".", "unique", "var", "arr", "=", "[", "]", "fn", "(", "opts", ",", "onValue", ")", "function", "onValue", "(", "err", ",", "value", ")", "{", "if", "(", "err", ")", "{", "return", "ready", "(", "err", ")", "}", "if", "(", "!", "unique", "||", "arr", ".", "indexOf", "(", "value", ")", "===", "-", "1", ")", "{", "arr", ".", "push", "(", "value", ")", "}", "if", "(", "arr", ".", "length", ">=", "num", ")", "{", "return", "ready", "(", "null", ",", "arr", ")", "}", "process", ".", "nextTick", "(", "function", "(", ")", "{", "fn", "(", "opts", ",", "onValue", ")", "}", ")", "}", "}" ]
Creates an array of items, whose contents are the result of calling asynchronous function fn once for each item in the array. The function is called in series, until the array is filled. @param {Function} fn the function to be called with ({Objct} opts, ready) where `ready` must be called with (err, value) @param {Object} opts the options hash that random-lib expects @param {Function} ready the function to be called with (err, {Array} values)
[ "Creates", "an", "array", "of", "items", "whose", "contents", "are", "the", "result", "of", "calling", "asynchronous", "function", "fn", "once", "for", "each", "item", "in", "the", "array", ".", "The", "function", "is", "called", "in", "series", "until", "the", "array", "is", "filled", "." ]
1dc05c8ada71049cbd2382239c1c6c6042bf3d97
https://github.com/fardog/node-random-lib/blob/1dc05c8ada71049cbd2382239c1c6c6042bf3d97/index.js#L193-L218
57,865
Zenedith/npm-my-restify-api
lib/plugin/cors.js
restifyCORSSimple
function restifyCORSSimple(req, res, next) { var origin; if (!(origin = matchOrigin(req, origins))) { next(); return; } function corsOnHeader() { origin = req.headers.origin; if (opts.credentials) { res.setHeader(AC_ALLOW_CREDS, 'true'); } res.setHeader(AC_ALLOW_ORIGIN, origin); res.setHeader(AC_EXPOSE_HEADERS, headers.join(', ')); res.setHeader(AC_ALLOW_METHODS, ALLOW_METHODS.join(', ')); res.setHeader(AC_ALLOW_HEADERS, ALLOW_HEADERS.join(', ')); res.setHeader(AC_REQUEST_HEADERS, REQUEST_HEADERS.join(', ')); } res.once('header', corsOnHeader); next(); }
javascript
function restifyCORSSimple(req, res, next) { var origin; if (!(origin = matchOrigin(req, origins))) { next(); return; } function corsOnHeader() { origin = req.headers.origin; if (opts.credentials) { res.setHeader(AC_ALLOW_CREDS, 'true'); } res.setHeader(AC_ALLOW_ORIGIN, origin); res.setHeader(AC_EXPOSE_HEADERS, headers.join(', ')); res.setHeader(AC_ALLOW_METHODS, ALLOW_METHODS.join(', ')); res.setHeader(AC_ALLOW_HEADERS, ALLOW_HEADERS.join(', ')); res.setHeader(AC_REQUEST_HEADERS, REQUEST_HEADERS.join(', ')); } res.once('header', corsOnHeader); next(); }
[ "function", "restifyCORSSimple", "(", "req", ",", "res", ",", "next", ")", "{", "var", "origin", ";", "if", "(", "!", "(", "origin", "=", "matchOrigin", "(", "req", ",", "origins", ")", ")", ")", "{", "next", "(", ")", ";", "return", ";", "}", "function", "corsOnHeader", "(", ")", "{", "origin", "=", "req", ".", "headers", ".", "origin", ";", "if", "(", "opts", ".", "credentials", ")", "{", "res", ".", "setHeader", "(", "AC_ALLOW_CREDS", ",", "'true'", ")", ";", "}", "res", ".", "setHeader", "(", "AC_ALLOW_ORIGIN", ",", "origin", ")", ";", "res", ".", "setHeader", "(", "AC_EXPOSE_HEADERS", ",", "headers", ".", "join", "(", "', '", ")", ")", ";", "res", ".", "setHeader", "(", "AC_ALLOW_METHODS", ",", "ALLOW_METHODS", ".", "join", "(", "', '", ")", ")", ";", "res", ".", "setHeader", "(", "AC_ALLOW_HEADERS", ",", "ALLOW_HEADERS", ".", "join", "(", "', '", ")", ")", ";", "res", ".", "setHeader", "(", "AC_REQUEST_HEADERS", ",", "REQUEST_HEADERS", ".", "join", "(", "', '", ")", ")", ";", "}", "res", ".", "once", "(", "'header'", ",", "corsOnHeader", ")", ";", "next", "(", ")", ";", "}" ]
Handler for simple requests
[ "Handler", "for", "simple", "requests" ]
946e40ede37124f6f4acaea19d73ab3c9d5074d9
https://github.com/Zenedith/npm-my-restify-api/blob/946e40ede37124f6f4acaea19d73ab3c9d5074d9/lib/plugin/cors.js#L82-L105
57,866
Itee/i-return
builds/i-return.js
processErrorAndData
function processErrorAndData (error, data) { if (_cb.beforeReturnErrorAndData) { _cb.beforeReturnErrorAndData(error, data); } if (_cb.returnErrorAndData) { _cb.returnErrorAndData(error, data, response); } if (_cb.afterReturnErrorAndData) { _cb.afterReturnErrorAndData(error, data); } }
javascript
function processErrorAndData (error, data) { if (_cb.beforeReturnErrorAndData) { _cb.beforeReturnErrorAndData(error, data); } if (_cb.returnErrorAndData) { _cb.returnErrorAndData(error, data, response); } if (_cb.afterReturnErrorAndData) { _cb.afterReturnErrorAndData(error, data); } }
[ "function", "processErrorAndData", "(", "error", ",", "data", ")", "{", "if", "(", "_cb", ".", "beforeReturnErrorAndData", ")", "{", "_cb", ".", "beforeReturnErrorAndData", "(", "error", ",", "data", ")", ";", "}", "if", "(", "_cb", ".", "returnErrorAndData", ")", "{", "_cb", ".", "returnErrorAndData", "(", "error", ",", "data", ",", "response", ")", ";", "}", "if", "(", "_cb", ".", "afterReturnErrorAndData", ")", "{", "_cb", ".", "afterReturnErrorAndData", "(", "error", ",", "data", ")", ";", "}", "}" ]
Call provided callback for error and data case. @param error - The database receive error @param data - The database retrieved data
[ "Call", "provided", "callback", "for", "error", "and", "data", "case", "." ]
895953cb344e0929883863808429a3b8fa61d678
https://github.com/Itee/i-return/blob/895953cb344e0929883863808429a3b8fa61d678/builds/i-return.js#L314-L318
57,867
Itee/i-return
builds/i-return.js
processError
function processError (error) { if (_cb.beforeReturnError) { _cb.beforeReturnError(error); } if (_cb.returnError) { _cb.returnError(error, response); } if (_cb.afterReturnError) { _cb.afterReturnError(error); } }
javascript
function processError (error) { if (_cb.beforeReturnError) { _cb.beforeReturnError(error); } if (_cb.returnError) { _cb.returnError(error, response); } if (_cb.afterReturnError) { _cb.afterReturnError(error); } }
[ "function", "processError", "(", "error", ")", "{", "if", "(", "_cb", ".", "beforeReturnError", ")", "{", "_cb", ".", "beforeReturnError", "(", "error", ")", ";", "}", "if", "(", "_cb", ".", "returnError", ")", "{", "_cb", ".", "returnError", "(", "error", ",", "response", ")", ";", "}", "if", "(", "_cb", ".", "afterReturnError", ")", "{", "_cb", ".", "afterReturnError", "(", "error", ")", ";", "}", "}" ]
Call provided callback for error case. @param error - The database receive error
[ "Call", "provided", "callback", "for", "error", "case", "." ]
895953cb344e0929883863808429a3b8fa61d678
https://github.com/Itee/i-return/blob/895953cb344e0929883863808429a3b8fa61d678/builds/i-return.js#L325-L329
57,868
Itee/i-return
builds/i-return.js
processData
function processData (data) { if (_cb.beforeReturnData) { _cb.beforeReturnData(data); } if (_cb.returnData) { _cb.returnData(data, response); } if (_cb.afterReturnData) { _cb.afterReturnData(data); } }
javascript
function processData (data) { if (_cb.beforeReturnData) { _cb.beforeReturnData(data); } if (_cb.returnData) { _cb.returnData(data, response); } if (_cb.afterReturnData) { _cb.afterReturnData(data); } }
[ "function", "processData", "(", "data", ")", "{", "if", "(", "_cb", ".", "beforeReturnData", ")", "{", "_cb", ".", "beforeReturnData", "(", "data", ")", ";", "}", "if", "(", "_cb", ".", "returnData", ")", "{", "_cb", ".", "returnData", "(", "data", ",", "response", ")", ";", "}", "if", "(", "_cb", ".", "afterReturnData", ")", "{", "_cb", ".", "afterReturnData", "(", "data", ")", ";", "}", "}" ]
Call provided callback for data case. @param data - The database retrieved data
[ "Call", "provided", "callback", "for", "data", "case", "." ]
895953cb344e0929883863808429a3b8fa61d678
https://github.com/Itee/i-return/blob/895953cb344e0929883863808429a3b8fa61d678/builds/i-return.js#L336-L340
57,869
Itee/i-return
builds/i-return.js
processNotFound
function processNotFound () { if (_cb.beforeReturnNotFound) { _cb.beforeReturnNotFound(); } if (_cb.returnNotFound) { _cb.returnNotFound(response); } if (_cb.afterReturnNotFound) { _cb.afterReturnNotFound(); } }
javascript
function processNotFound () { if (_cb.beforeReturnNotFound) { _cb.beforeReturnNotFound(); } if (_cb.returnNotFound) { _cb.returnNotFound(response); } if (_cb.afterReturnNotFound) { _cb.afterReturnNotFound(); } }
[ "function", "processNotFound", "(", ")", "{", "if", "(", "_cb", ".", "beforeReturnNotFound", ")", "{", "_cb", ".", "beforeReturnNotFound", "(", ")", ";", "}", "if", "(", "_cb", ".", "returnNotFound", ")", "{", "_cb", ".", "returnNotFound", "(", "response", ")", ";", "}", "if", "(", "_cb", ".", "afterReturnNotFound", ")", "{", "_cb", ".", "afterReturnNotFound", "(", ")", ";", "}", "}" ]
Call provided callback for not found data case.
[ "Call", "provided", "callback", "for", "not", "found", "data", "case", "." ]
895953cb344e0929883863808429a3b8fa61d678
https://github.com/Itee/i-return/blob/895953cb344e0929883863808429a3b8fa61d678/builds/i-return.js#L345-L349
57,870
aaaschmitt/hubot-google-auth
auth.js
function(token) { this.oauthClient.setCredentials(token); this.brain.set(this.TOKEN_KEY, token.access_token); if (token.refresh_token) { this.brain.set(this.REFRESH_KEY, token.refresh_token); } this.brain.set(this.EXPIRY_KEY, +token.expiry_date); this.brain.save(); this.brain.resetSaveInterval(60); }
javascript
function(token) { this.oauthClient.setCredentials(token); this.brain.set(this.TOKEN_KEY, token.access_token); if (token.refresh_token) { this.brain.set(this.REFRESH_KEY, token.refresh_token); } this.brain.set(this.EXPIRY_KEY, +token.expiry_date); this.brain.save(); this.brain.resetSaveInterval(60); }
[ "function", "(", "token", ")", "{", "this", ".", "oauthClient", ".", "setCredentials", "(", "token", ")", ";", "this", ".", "brain", ".", "set", "(", "this", ".", "TOKEN_KEY", ",", "token", ".", "access_token", ")", ";", "if", "(", "token", ".", "refresh_token", ")", "{", "this", ".", "brain", ".", "set", "(", "this", ".", "REFRESH_KEY", ",", "token", ".", "refresh_token", ")", ";", "}", "this", ".", "brain", ".", "set", "(", "this", ".", "EXPIRY_KEY", ",", "+", "token", ".", "expiry_date", ")", ";", "this", ".", "brain", ".", "save", "(", ")", ";", "this", ".", "brain", ".", "resetSaveInterval", "(", "60", ")", ";", "}" ]
Stores the token and expire time into the robot brain and Sets it in the oauthClient @param token the token object returned from google oauth2
[ "Stores", "the", "token", "and", "expire", "time", "into", "the", "robot", "brain", "and", "Sets", "it", "in", "the", "oauthClient" ]
046c70965022f1aeebc03eede375650c8dcf1b7c
https://github.com/aaaschmitt/hubot-google-auth/blob/046c70965022f1aeebc03eede375650c8dcf1b7c/auth.js#L65-L74
57,871
aaaschmitt/hubot-google-auth
auth.js
function(code, cb) { var self = this; this.oauthClient.getToken(code, function(err, token) { if (err) { cb({ err: err, msg: 'Error while trying to retrieve access token' }); return; } self.storeToken(token); cb(null, { resp: token, msg: "Google auth code successfully set" }); }); }
javascript
function(code, cb) { var self = this; this.oauthClient.getToken(code, function(err, token) { if (err) { cb({ err: err, msg: 'Error while trying to retrieve access token' }); return; } self.storeToken(token); cb(null, { resp: token, msg: "Google auth code successfully set" }); }); }
[ "function", "(", "code", ",", "cb", ")", "{", "var", "self", "=", "this", ";", "this", ".", "oauthClient", ".", "getToken", "(", "code", ",", "function", "(", "err", ",", "token", ")", "{", "if", "(", "err", ")", "{", "cb", "(", "{", "err", ":", "err", ",", "msg", ":", "'Error while trying to retrieve access token'", "}", ")", ";", "return", ";", "}", "self", ".", "storeToken", "(", "token", ")", ";", "cb", "(", "null", ",", "{", "resp", ":", "token", ",", "msg", ":", "\"Google auth code successfully set\"", "}", ")", ";", "}", ")", ";", "}" ]
Used to set the code provided by the generated auth url. This code is generated for a user and is needed to initiate the oauth2 handshake @param code the code obtained by a user from the auth url
[ "Used", "to", "set", "the", "code", "provided", "by", "the", "generated", "auth", "url", ".", "This", "code", "is", "generated", "for", "a", "user", "and", "is", "needed", "to", "initiate", "the", "oauth2", "handshake" ]
046c70965022f1aeebc03eede375650c8dcf1b7c
https://github.com/aaaschmitt/hubot-google-auth/blob/046c70965022f1aeebc03eede375650c8dcf1b7c/auth.js#L101-L117
57,872
aaaschmitt/hubot-google-auth
auth.js
function(cb) { var at = this.brain.get(this.TOKEN_KEY), rt = this.brain.get(this.REFRESH_KEY); if (at == null || rt == null) { cb({ err: null, msg: 'Error: No tokens found. Please authorize this app and store a refresh token' }); return; } var expirTime = this.brain.get(this.EXPIRY_KEY), curTime = (new Date()) / 1; var self = this; if (expirTime < curTime) { this.oauthClient.refreshAccessToken(function(err, token) { if (err != null) { cb({ err: err, msg: 'Google Authentication Error: error refreshing token' }, null); return; } self.storeToken(token); cb(null, { resp: token, msg: 'Token refreshed' }); }); } else { cb(null); } }
javascript
function(cb) { var at = this.brain.get(this.TOKEN_KEY), rt = this.brain.get(this.REFRESH_KEY); if (at == null || rt == null) { cb({ err: null, msg: 'Error: No tokens found. Please authorize this app and store a refresh token' }); return; } var expirTime = this.brain.get(this.EXPIRY_KEY), curTime = (new Date()) / 1; var self = this; if (expirTime < curTime) { this.oauthClient.refreshAccessToken(function(err, token) { if (err != null) { cb({ err: err, msg: 'Google Authentication Error: error refreshing token' }, null); return; } self.storeToken(token); cb(null, { resp: token, msg: 'Token refreshed' }); }); } else { cb(null); } }
[ "function", "(", "cb", ")", "{", "var", "at", "=", "this", ".", "brain", ".", "get", "(", "this", ".", "TOKEN_KEY", ")", ",", "rt", "=", "this", ".", "brain", ".", "get", "(", "this", ".", "REFRESH_KEY", ")", ";", "if", "(", "at", "==", "null", "||", "rt", "==", "null", ")", "{", "cb", "(", "{", "err", ":", "null", ",", "msg", ":", "'Error: No tokens found. Please authorize this app and store a refresh token'", "}", ")", ";", "return", ";", "}", "var", "expirTime", "=", "this", ".", "brain", ".", "get", "(", "this", ".", "EXPIRY_KEY", ")", ",", "curTime", "=", "(", "new", "Date", "(", ")", ")", "/", "1", ";", "var", "self", "=", "this", ";", "if", "(", "expirTime", "<", "curTime", ")", "{", "this", ".", "oauthClient", ".", "refreshAccessToken", "(", "function", "(", "err", ",", "token", ")", "{", "if", "(", "err", "!=", "null", ")", "{", "cb", "(", "{", "err", ":", "err", ",", "msg", ":", "'Google Authentication Error: error refreshing token'", "}", ",", "null", ")", ";", "return", ";", "}", "self", ".", "storeToken", "(", "token", ")", ";", "cb", "(", "null", ",", "{", "resp", ":", "token", ",", "msg", ":", "'Token refreshed'", "}", ")", ";", "}", ")", ";", "}", "else", "{", "cb", "(", "null", ")", ";", "}", "}" ]
Checks the current expire time and determines if the token is valid. Refreshes the token if it is not valid. @param cb the callback function (err, resp), use this to make api calls
[ "Checks", "the", "current", "expire", "time", "and", "determines", "if", "the", "token", "is", "valid", ".", "Refreshes", "the", "token", "if", "it", "is", "not", "valid", "." ]
046c70965022f1aeebc03eede375650c8dcf1b7c
https://github.com/aaaschmitt/hubot-google-auth/blob/046c70965022f1aeebc03eede375650c8dcf1b7c/auth.js#L125-L161
57,873
aaaschmitt/hubot-google-auth
auth.js
function() { return { token: this.brain.get(this.TOKEN_KEY), refresh_token: this.brain.get(this.REFRESH_KEY), expire_date: this.brain.get(this.EXPIRY_KEY) } }
javascript
function() { return { token: this.brain.get(this.TOKEN_KEY), refresh_token: this.brain.get(this.REFRESH_KEY), expire_date: this.brain.get(this.EXPIRY_KEY) } }
[ "function", "(", ")", "{", "return", "{", "token", ":", "this", ".", "brain", ".", "get", "(", "this", ".", "TOKEN_KEY", ")", ",", "refresh_token", ":", "this", ".", "brain", ".", "get", "(", "this", ".", "REFRESH_KEY", ")", ",", "expire_date", ":", "this", ".", "brain", ".", "get", "(", "this", ".", "EXPIRY_KEY", ")", "}", "}" ]
Returns the current set of tokens
[ "Returns", "the", "current", "set", "of", "tokens" ]
046c70965022f1aeebc03eede375650c8dcf1b7c
https://github.com/aaaschmitt/hubot-google-auth/blob/046c70965022f1aeebc03eede375650c8dcf1b7c/auth.js#L166-L172
57,874
CodersBrothers/BtcAverage
btcaverage.js
findValueByPath
function findValueByPath(jsonData, path){ var errorParts = false; path.split('.').forEach(function(part){ if(!errorParts){ jsonData = jsonData[part]; if(!jsonData) errorParts = true; } }); return errorParts ? 0 : parseFloat(jsonData); }
javascript
function findValueByPath(jsonData, path){ var errorParts = false; path.split('.').forEach(function(part){ if(!errorParts){ jsonData = jsonData[part]; if(!jsonData) errorParts = true; } }); return errorParts ? 0 : parseFloat(jsonData); }
[ "function", "findValueByPath", "(", "jsonData", ",", "path", ")", "{", "var", "errorParts", "=", "false", ";", "path", ".", "split", "(", "'.'", ")", ".", "forEach", "(", "function", "(", "part", ")", "{", "if", "(", "!", "errorParts", ")", "{", "jsonData", "=", "jsonData", "[", "part", "]", ";", "if", "(", "!", "jsonData", ")", "errorParts", "=", "true", ";", "}", "}", ")", ";", "return", "errorParts", "?", "0", ":", "parseFloat", "(", "jsonData", ")", ";", "}" ]
FIND VALUE BY PATH @param {Object} jsonData @param {String} path
[ "FIND", "VALUE", "BY", "PATH" ]
ef936af295f55a3328a790ebb2bcba6df4c1b378
https://github.com/CodersBrothers/BtcAverage/blob/ef936af295f55a3328a790ebb2bcba6df4c1b378/btcaverage.js#L17-L26
57,875
CodersBrothers/BtcAverage
btcaverage.js
requestPrice
function requestPrice(urlAPI, callback){ request({ method: 'GET', url: urlAPI, timeout: TIMEOUT, maxRedirects: 2 }, function(error, res, body){ if(!error){ try{ var current = JSON.parse(body); callback(current); }catch(e){} } if(!current) { callback({}); } }); }
javascript
function requestPrice(urlAPI, callback){ request({ method: 'GET', url: urlAPI, timeout: TIMEOUT, maxRedirects: 2 }, function(error, res, body){ if(!error){ try{ var current = JSON.parse(body); callback(current); }catch(e){} } if(!current) { callback({}); } }); }
[ "function", "requestPrice", "(", "urlAPI", ",", "callback", ")", "{", "request", "(", "{", "method", ":", "'GET'", ",", "url", ":", "urlAPI", ",", "timeout", ":", "TIMEOUT", ",", "maxRedirects", ":", "2", "}", ",", "function", "(", "error", ",", "res", ",", "body", ")", "{", "if", "(", "!", "error", ")", "{", "try", "{", "var", "current", "=", "JSON", ".", "parse", "(", "body", ")", ";", "callback", "(", "current", ")", ";", "}", "catch", "(", "e", ")", "{", "}", "}", "if", "(", "!", "current", ")", "{", "callback", "(", "{", "}", ")", ";", "}", "}", ")", ";", "}" ]
GET PRICE FROM API SERVICE @param {String} urlAPI @param {Function} callback
[ "GET", "PRICE", "FROM", "API", "SERVICE" ]
ef936af295f55a3328a790ebb2bcba6df4c1b378
https://github.com/CodersBrothers/BtcAverage/blob/ef936af295f55a3328a790ebb2bcba6df4c1b378/btcaverage.js#L34-L51
57,876
isaacperaza/elixir-busting
index.js
function(buildPath, manifest) { fs.stat(manifest, function(err, stat) { if (! err) { manifest = JSON.parse(fs.readFileSync(manifest)); for (var key in manifest) { del.sync(buildPath + '/' + manifest[key], { force: true }); } } }); }
javascript
function(buildPath, manifest) { fs.stat(manifest, function(err, stat) { if (! err) { manifest = JSON.parse(fs.readFileSync(manifest)); for (var key in manifest) { del.sync(buildPath + '/' + manifest[key], { force: true }); } } }); }
[ "function", "(", "buildPath", ",", "manifest", ")", "{", "fs", ".", "stat", "(", "manifest", ",", "function", "(", "err", ",", "stat", ")", "{", "if", "(", "!", "err", ")", "{", "manifest", "=", "JSON", ".", "parse", "(", "fs", ".", "readFileSync", "(", "manifest", ")", ")", ";", "for", "(", "var", "key", "in", "manifest", ")", "{", "del", ".", "sync", "(", "buildPath", "+", "'/'", "+", "manifest", "[", "key", "]", ",", "{", "force", ":", "true", "}", ")", ";", "}", "}", "}", ")", ";", "}" ]
Empty all relevant files from the build directory. @param {string} buildPath @param {string} manifest
[ "Empty", "all", "relevant", "files", "from", "the", "build", "directory", "." ]
7238222465f73dfedd8f049b6daf32b5cbaddcf9
https://github.com/isaacperaza/elixir-busting/blob/7238222465f73dfedd8f049b6daf32b5cbaddcf9/index.js#L90-L100
57,877
skerit/alchemy-styleboost
public/ckeditor/4.4dev/core/htmlparser/node.js
function() { var children = this.parent.children, index = CKEDITOR.tools.indexOf( children, this ), previous = this.previous, next = this.next; previous && ( previous.next = next ); next && ( next.previous = previous ); children.splice( index, 1 ); this.parent = null; }
javascript
function() { var children = this.parent.children, index = CKEDITOR.tools.indexOf( children, this ), previous = this.previous, next = this.next; previous && ( previous.next = next ); next && ( next.previous = previous ); children.splice( index, 1 ); this.parent = null; }
[ "function", "(", ")", "{", "var", "children", "=", "this", ".", "parent", ".", "children", ",", "index", "=", "CKEDITOR", ".", "tools", ".", "indexOf", "(", "children", ",", "this", ")", ",", "previous", "=", "this", ".", "previous", ",", "next", "=", "this", ".", "next", ";", "previous", "&&", "(", "previous", ".", "next", "=", "next", ")", ";", "next", "&&", "(", "next", ".", "previous", "=", "previous", ")", ";", "children", ".", "splice", "(", "index", ",", "1", ")", ";", "this", ".", "parent", "=", "null", ";", "}" ]
Remove this node from a tree. @since 4.1
[ "Remove", "this", "node", "from", "a", "tree", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/htmlparser/node.js#L24-L34
57,878
skerit/alchemy-styleboost
public/ckeditor/4.4dev/core/htmlparser/node.js
function( condition ) { var checkFn = typeof condition == 'function' ? condition : typeof condition == 'string' ? function( el ) { return el.name == condition; } : function( el ) { return el.name in condition; }; var parent = this.parent; // Parent has to be an element - don't check doc fragment. while ( parent && parent.type == CKEDITOR.NODE_ELEMENT ) { if ( checkFn( parent ) ) return parent; parent = parent.parent; } return null; }
javascript
function( condition ) { var checkFn = typeof condition == 'function' ? condition : typeof condition == 'string' ? function( el ) { return el.name == condition; } : function( el ) { return el.name in condition; }; var parent = this.parent; // Parent has to be an element - don't check doc fragment. while ( parent && parent.type == CKEDITOR.NODE_ELEMENT ) { if ( checkFn( parent ) ) return parent; parent = parent.parent; } return null; }
[ "function", "(", "condition", ")", "{", "var", "checkFn", "=", "typeof", "condition", "==", "'function'", "?", "condition", ":", "typeof", "condition", "==", "'string'", "?", "function", "(", "el", ")", "{", "return", "el", ".", "name", "==", "condition", ";", "}", ":", "function", "(", "el", ")", "{", "return", "el", ".", "name", "in", "condition", ";", "}", ";", "var", "parent", "=", "this", ".", "parent", ";", "// Parent has to be an element - don't check doc fragment.", "while", "(", "parent", "&&", "parent", ".", "type", "==", "CKEDITOR", ".", "NODE_ELEMENT", ")", "{", "if", "(", "checkFn", "(", "parent", ")", ")", "return", "parent", ";", "parent", "=", "parent", ".", "parent", ";", "}", "return", "null", ";", "}" ]
Gets the closest ancestor element of this element which satisfies given condition @since 4.3 @param {String/Object/Function} condition Name of an ancestor, hash of names or validator function. @returns {CKEDITOR.htmlParser.element} The closest ancestor which satisfies given condition or `null`.
[ "Gets", "the", "closest", "ancestor", "element", "of", "this", "element", "which", "satisfies", "given", "condition" ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/htmlparser/node.js#L105-L127
57,879
leocornus/leocornus-visualdata
src/zoomable-circles.js
function(d) { var self = this; $('#circle-info').html(d.name); console.log(d); var focus0 = self.focus; self.focus = d; var transition = d3.transition() .duration(d3.event.altKey ? 7500 : 750) .tween("zoom", function(d) { var i = d3.interpolateZoom(self.view, [self.focus.x, self.focus.y, self.focus.r * 2 + self.options.margin]); return function(t) { self.zoomTo(i(t)); }; }); transition.selectAll("text") .filter(function(d) { return d.parent === self.focus || this.style.display === "inline" || d.parent === focus0; }) .style("fill-opacity", function(d) { return d.parent === self.focus ? 1 : 0.5; }) .each("start", function(d) { if (d.parent === self.focus) this.style.display = "inline"; }) .each("end", function(d) { if (d.parent !== self.focus) this.style.display = "none"; }); // logos are opaque at root level only transition.selectAll("use") .style("opacity", function(d) { return self.focus.depth === 0 ? 1 : 0.8; }); }
javascript
function(d) { var self = this; $('#circle-info').html(d.name); console.log(d); var focus0 = self.focus; self.focus = d; var transition = d3.transition() .duration(d3.event.altKey ? 7500 : 750) .tween("zoom", function(d) { var i = d3.interpolateZoom(self.view, [self.focus.x, self.focus.y, self.focus.r * 2 + self.options.margin]); return function(t) { self.zoomTo(i(t)); }; }); transition.selectAll("text") .filter(function(d) { return d.parent === self.focus || this.style.display === "inline" || d.parent === focus0; }) .style("fill-opacity", function(d) { return d.parent === self.focus ? 1 : 0.5; }) .each("start", function(d) { if (d.parent === self.focus) this.style.display = "inline"; }) .each("end", function(d) { if (d.parent !== self.focus) this.style.display = "none"; }); // logos are opaque at root level only transition.selectAll("use") .style("opacity", function(d) { return self.focus.depth === 0 ? 1 : 0.8; }); }
[ "function", "(", "d", ")", "{", "var", "self", "=", "this", ";", "$", "(", "'#circle-info'", ")", ".", "html", "(", "d", ".", "name", ")", ";", "console", ".", "log", "(", "d", ")", ";", "var", "focus0", "=", "self", ".", "focus", ";", "self", ".", "focus", "=", "d", ";", "var", "transition", "=", "d3", ".", "transition", "(", ")", ".", "duration", "(", "d3", ".", "event", ".", "altKey", "?", "7500", ":", "750", ")", ".", "tween", "(", "\"zoom\"", ",", "function", "(", "d", ")", "{", "var", "i", "=", "d3", ".", "interpolateZoom", "(", "self", ".", "view", ",", "[", "self", ".", "focus", ".", "x", ",", "self", ".", "focus", ".", "y", ",", "self", ".", "focus", ".", "r", "*", "2", "+", "self", ".", "options", ".", "margin", "]", ")", ";", "return", "function", "(", "t", ")", "{", "self", ".", "zoomTo", "(", "i", "(", "t", ")", ")", ";", "}", ";", "}", ")", ";", "transition", ".", "selectAll", "(", "\"text\"", ")", ".", "filter", "(", "function", "(", "d", ")", "{", "return", "d", ".", "parent", "===", "self", ".", "focus", "||", "this", ".", "style", ".", "display", "===", "\"inline\"", "||", "d", ".", "parent", "===", "focus0", ";", "}", ")", ".", "style", "(", "\"fill-opacity\"", ",", "function", "(", "d", ")", "{", "return", "d", ".", "parent", "===", "self", ".", "focus", "?", "1", ":", "0.5", ";", "}", ")", ".", "each", "(", "\"start\"", ",", "function", "(", "d", ")", "{", "if", "(", "d", ".", "parent", "===", "self", ".", "focus", ")", "this", ".", "style", ".", "display", "=", "\"inline\"", ";", "}", ")", ".", "each", "(", "\"end\"", ",", "function", "(", "d", ")", "{", "if", "(", "d", ".", "parent", "!==", "self", ".", "focus", ")", "this", ".", "style", ".", "display", "=", "\"none\"", ";", "}", ")", ";", "// logos are opaque at root level only", "transition", ".", "selectAll", "(", "\"use\"", ")", ".", "style", "(", "\"opacity\"", ",", "function", "(", "d", ")", "{", "return", "self", ".", "focus", ".", "depth", "===", "0", "?", "1", ":", "0.8", ";", "}", ")", ";", "}" ]
a function responsible for zooming in on circles
[ "a", "function", "responsible", "for", "zooming", "in", "on", "circles" ]
9d9714ca11c126f0250e650f3c1c4086709af3ab
https://github.com/leocornus/leocornus-visualdata/blob/9d9714ca11c126f0250e650f3c1c4086709af3ab/src/zoomable-circles.js#L273-L317
57,880
AKST/nuimo-client.js
src/withNuimo.js
discoverServicesAndCharacteristics
function discoverServicesAndCharacteristics(error) { if (error) { return reject(error); } peripheral.discoverSomeServicesAndCharacteristics( ALL_SERVICES, ALL_CHARACTERISTICS, setupEmitter ); }
javascript
function discoverServicesAndCharacteristics(error) { if (error) { return reject(error); } peripheral.discoverSomeServicesAndCharacteristics( ALL_SERVICES, ALL_CHARACTERISTICS, setupEmitter ); }
[ "function", "discoverServicesAndCharacteristics", "(", "error", ")", "{", "if", "(", "error", ")", "{", "return", "reject", "(", "error", ")", ";", "}", "peripheral", ".", "discoverSomeServicesAndCharacteristics", "(", "ALL_SERVICES", ",", "ALL_CHARACTERISTICS", ",", "setupEmitter", ")", ";", "}" ]
discovers the sensor service and it's characteristics @param {error}
[ "discovers", "the", "sensor", "service", "and", "it", "s", "characteristics" ]
a37977b604aef33abb02f9fdde1a4f64d9a0c906
https://github.com/AKST/nuimo-client.js/blob/a37977b604aef33abb02f9fdde1a4f64d9a0c906/src/withNuimo.js#L66-L73
57,881
AKST/nuimo-client.js
src/withNuimo.js
setupEmitter
function setupEmitter(error) { if (error) { return reject(error); } const sensorService = getService(SERVICE_SENSOR_UUID, peripheral); const notifiable = sensorService.characteristics; const withNotified = Promise.all(notifiable.map(characteristic => new Promise((resolve, reject) => void characteristic.notify([], error => void (!!error ? reject(error) : resolve(characteristic)))))); withNotified.then(characteristics => { const emitter = new EventEmitter(); const onData = uuid => buffer => void emitter.emit("data", { characteristic: uuid, buffer }); characteristics.forEach(characteristic => void characteristic.on('data', onData(characteristic.uuid))); const matrixCharacteristic = getCharacteristic(CHARACTERISTIC_MATRIX_UUID, getService(SERVICE_MATRIX_UUID, peripheral)); resolve(new client.NuimoClient(emitter, matrixCharacteristic, peripheral)); }).catch(reject); }
javascript
function setupEmitter(error) { if (error) { return reject(error); } const sensorService = getService(SERVICE_SENSOR_UUID, peripheral); const notifiable = sensorService.characteristics; const withNotified = Promise.all(notifiable.map(characteristic => new Promise((resolve, reject) => void characteristic.notify([], error => void (!!error ? reject(error) : resolve(characteristic)))))); withNotified.then(characteristics => { const emitter = new EventEmitter(); const onData = uuid => buffer => void emitter.emit("data", { characteristic: uuid, buffer }); characteristics.forEach(characteristic => void characteristic.on('data', onData(characteristic.uuid))); const matrixCharacteristic = getCharacteristic(CHARACTERISTIC_MATRIX_UUID, getService(SERVICE_MATRIX_UUID, peripheral)); resolve(new client.NuimoClient(emitter, matrixCharacteristic, peripheral)); }).catch(reject); }
[ "function", "setupEmitter", "(", "error", ")", "{", "if", "(", "error", ")", "{", "return", "reject", "(", "error", ")", ";", "}", "const", "sensorService", "=", "getService", "(", "SERVICE_SENSOR_UUID", ",", "peripheral", ")", ";", "const", "notifiable", "=", "sensorService", ".", "characteristics", ";", "const", "withNotified", "=", "Promise", ".", "all", "(", "notifiable", ".", "map", "(", "characteristic", "=>", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "void", "characteristic", ".", "notify", "(", "[", "]", ",", "error", "=>", "void", "(", "!", "!", "error", "?", "reject", "(", "error", ")", ":", "resolve", "(", "characteristic", ")", ")", ")", ")", ")", ")", ";", "withNotified", ".", "then", "(", "characteristics", "=>", "{", "const", "emitter", "=", "new", "EventEmitter", "(", ")", ";", "const", "onData", "=", "uuid", "=>", "buffer", "=>", "void", "emitter", ".", "emit", "(", "\"data\"", ",", "{", "characteristic", ":", "uuid", ",", "buffer", "}", ")", ";", "characteristics", ".", "forEach", "(", "characteristic", "=>", "void", "characteristic", ".", "on", "(", "'data'", ",", "onData", "(", "characteristic", ".", "uuid", ")", ")", ")", ";", "const", "matrixCharacteristic", "=", "getCharacteristic", "(", "CHARACTERISTIC_MATRIX_UUID", ",", "getService", "(", "SERVICE_MATRIX_UUID", ",", "peripheral", ")", ")", ";", "resolve", "(", "new", "client", ".", "NuimoClient", "(", "emitter", ",", "matrixCharacteristic", ",", "peripheral", ")", ")", ";", "}", ")", ".", "catch", "(", "reject", ")", ";", "}" ]
setup each service characteristic of the sensor to emit data on new data when all have been setup with characteristic.notify then resolve the promise @param {error}
[ "setup", "each", "service", "characteristic", "of", "the", "sensor", "to", "emit", "data", "on", "new", "data", "when", "all", "have", "been", "setup", "with", "characteristic", ".", "notify", "then", "resolve", "the", "promise" ]
a37977b604aef33abb02f9fdde1a4f64d9a0c906
https://github.com/AKST/nuimo-client.js/blob/a37977b604aef33abb02f9fdde1a4f64d9a0c906/src/withNuimo.js#L80-L104
57,882
jasonrhodes/pagemaki
pagemaki.js
function (config) { this.globals = config.globals || {}; this.templates = {}; this.config = _.extend({}, defaults, config); this.config.optionsRegex = new RegExp("^" + this.config.optionsDelimiter + "([\\S\\s]+)" + this.config.optionsDelimiter + "([\\S\\s]+)"); }
javascript
function (config) { this.globals = config.globals || {}; this.templates = {}; this.config = _.extend({}, defaults, config); this.config.optionsRegex = new RegExp("^" + this.config.optionsDelimiter + "([\\S\\s]+)" + this.config.optionsDelimiter + "([\\S\\s]+)"); }
[ "function", "(", "config", ")", "{", "this", ".", "globals", "=", "config", ".", "globals", "||", "{", "}", ";", "this", ".", "templates", "=", "{", "}", ";", "this", ".", "config", "=", "_", ".", "extend", "(", "{", "}", ",", "defaults", ",", "config", ")", ";", "this", ".", "config", ".", "optionsRegex", "=", "new", "RegExp", "(", "\"^\"", "+", "this", ".", "config", ".", "optionsDelimiter", "+", "\"([\\\\S\\\\s]+)\"", "+", "this", ".", "config", ".", "optionsDelimiter", "+", "\"([\\\\S\\\\s]+)\"", ")", ";", "}" ]
Constructor for the Pagemaki class @param {[type]} config [description]
[ "Constructor", "for", "the", "Pagemaki", "class" ]
843892a62696a6db392d9f4646818a31b44a8da2
https://github.com/jasonrhodes/pagemaki/blob/843892a62696a6db392d9f4646818a31b44a8da2/pagemaki.js#L47-L52
57,883
blake-regalia/rmprop.js
lib/index.js
function(z_real, w_copy, s_property) { // property is a function (ie: instance method) if('function' === typeof z_real[s_property]) { // implement same method name in virtual object w_copy[s_property] = function() { // forward to real class return z_real[s_property].apply(z_real, arguments); }; } // read/write property else { // try to override object property try { Object.defineProperty(w_copy, s_property, { // grant user full capability to modify this property configurable: true, // give enumerability setting same value as original enumerable: z_real.propertyIsEnumerable(s_property), // fetch property from real object get: () => { return z_real[s_property]; }, // set property on real object set: (z_value) => { z_real[s_property] = z_value; }, }); } // cannot redefine property catch(d_redef_err) { // try again, this time only set the value and enumerability try { Object.defineProperty(w_copy, s_property, { // give enumerability setting same value as original enumerable: z_real.propertyIsEnumerable(s_property), // mask w undef value: undefined, }); // was not exepecting this property to give us trouble if(!A_TROUBLE_PROPERTIES.includes(s_property)) { console.warn('was not expecting "'+s_property+'" to prohibit redefinition on '+arginfo(w_copy)); } } // cannot even do that?! catch(d_enum_err) { // last try, this time only set the value try { Object.defineProperty(w_copy, s_property, { // mask w undef value: undefined, }); // was not exepecting this property to give us trouble if(!A_TROUBLE_PROPERTIES.includes(s_property)) { console.warn('was not expecting "'+s_property+'" to prohibit redefinition on '+arginfo(w_copy)); } } // fail catch(d_value_err) { throw 'cannot override property "'+s_property+'" on '+arginfo(w_copy); } } } } }
javascript
function(z_real, w_copy, s_property) { // property is a function (ie: instance method) if('function' === typeof z_real[s_property]) { // implement same method name in virtual object w_copy[s_property] = function() { // forward to real class return z_real[s_property].apply(z_real, arguments); }; } // read/write property else { // try to override object property try { Object.defineProperty(w_copy, s_property, { // grant user full capability to modify this property configurable: true, // give enumerability setting same value as original enumerable: z_real.propertyIsEnumerable(s_property), // fetch property from real object get: () => { return z_real[s_property]; }, // set property on real object set: (z_value) => { z_real[s_property] = z_value; }, }); } // cannot redefine property catch(d_redef_err) { // try again, this time only set the value and enumerability try { Object.defineProperty(w_copy, s_property, { // give enumerability setting same value as original enumerable: z_real.propertyIsEnumerable(s_property), // mask w undef value: undefined, }); // was not exepecting this property to give us trouble if(!A_TROUBLE_PROPERTIES.includes(s_property)) { console.warn('was not expecting "'+s_property+'" to prohibit redefinition on '+arginfo(w_copy)); } } // cannot even do that?! catch(d_enum_err) { // last try, this time only set the value try { Object.defineProperty(w_copy, s_property, { // mask w undef value: undefined, }); // was not exepecting this property to give us trouble if(!A_TROUBLE_PROPERTIES.includes(s_property)) { console.warn('was not expecting "'+s_property+'" to prohibit redefinition on '+arginfo(w_copy)); } } // fail catch(d_value_err) { throw 'cannot override property "'+s_property+'" on '+arginfo(w_copy); } } } } }
[ "function", "(", "z_real", ",", "w_copy", ",", "s_property", ")", "{", "// property is a function (ie: instance method)", "if", "(", "'function'", "===", "typeof", "z_real", "[", "s_property", "]", ")", "{", "// implement same method name in virtual object", "w_copy", "[", "s_property", "]", "=", "function", "(", ")", "{", "// forward to real class", "return", "z_real", "[", "s_property", "]", ".", "apply", "(", "z_real", ",", "arguments", ")", ";", "}", ";", "}", "// read/write property", "else", "{", "// try to override object property", "try", "{", "Object", ".", "defineProperty", "(", "w_copy", ",", "s_property", ",", "{", "// grant user full capability to modify this property", "configurable", ":", "true", ",", "// give enumerability setting same value as original", "enumerable", ":", "z_real", ".", "propertyIsEnumerable", "(", "s_property", ")", ",", "// fetch property from real object", "get", ":", "(", ")", "=>", "{", "return", "z_real", "[", "s_property", "]", ";", "}", ",", "// set property on real object", "set", ":", "(", "z_value", ")", "=>", "{", "z_real", "[", "s_property", "]", "=", "z_value", ";", "}", ",", "}", ")", ";", "}", "// cannot redefine property", "catch", "(", "d_redef_err", ")", "{", "// try again, this time only set the value and enumerability", "try", "{", "Object", ".", "defineProperty", "(", "w_copy", ",", "s_property", ",", "{", "// give enumerability setting same value as original", "enumerable", ":", "z_real", ".", "propertyIsEnumerable", "(", "s_property", ")", ",", "// mask w undef", "value", ":", "undefined", ",", "}", ")", ";", "// was not exepecting this property to give us trouble", "if", "(", "!", "A_TROUBLE_PROPERTIES", ".", "includes", "(", "s_property", ")", ")", "{", "console", ".", "warn", "(", "'was not expecting \"'", "+", "s_property", "+", "'\" to prohibit redefinition on '", "+", "arginfo", "(", "w_copy", ")", ")", ";", "}", "}", "// cannot even do that?!", "catch", "(", "d_enum_err", ")", "{", "// last try, this time only set the value", "try", "{", "Object", ".", "defineProperty", "(", "w_copy", ",", "s_property", ",", "{", "// mask w undef", "value", ":", "undefined", ",", "}", ")", ";", "// was not exepecting this property to give us trouble", "if", "(", "!", "A_TROUBLE_PROPERTIES", ".", "includes", "(", "s_property", ")", ")", "{", "console", ".", "warn", "(", "'was not expecting \"'", "+", "s_property", "+", "'\" to prohibit redefinition on '", "+", "arginfo", "(", "w_copy", ")", ")", ";", "}", "}", "// fail", "catch", "(", "d_value_err", ")", "{", "throw", "'cannot override property \"'", "+", "s_property", "+", "'\" on '", "+", "arginfo", "(", "w_copy", ")", ";", "}", "}", "}", "}", "}" ]
creates a transparent property on w_copy using z_real
[ "creates", "a", "transparent", "property", "on", "w_copy", "using", "z_real" ]
864ff0c4d24f2a4fcf684d5729bc5dafe14b3671
https://github.com/blake-regalia/rmprop.js/blob/864ff0c4d24f2a4fcf684d5729bc5dafe14b3671/lib/index.js#L85-L163
57,884
tbashor/architect-debug-logger
logger.js
logFn
function logFn(level){ return function(msg){ var args = Array.prototype.slice.call(arguments); if (level === 'hr'){ args = ['------------------------------------------------------------']; args.push({_hr: true}); level = 'debug'; } var logFn = logger[level] || console[level].bind(console); if (enabled.enabled) logFn.apply(logger, args); }; }
javascript
function logFn(level){ return function(msg){ var args = Array.prototype.slice.call(arguments); if (level === 'hr'){ args = ['------------------------------------------------------------']; args.push({_hr: true}); level = 'debug'; } var logFn = logger[level] || console[level].bind(console); if (enabled.enabled) logFn.apply(logger, args); }; }
[ "function", "logFn", "(", "level", ")", "{", "return", "function", "(", "msg", ")", "{", "var", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ")", ";", "if", "(", "level", "===", "'hr'", ")", "{", "args", "=", "[", "'------------------------------------------------------------'", "]", ";", "args", ".", "push", "(", "{", "_hr", ":", "true", "}", ")", ";", "level", "=", "'debug'", ";", "}", "var", "logFn", "=", "logger", "[", "level", "]", "||", "console", "[", "level", "]", ".", "bind", "(", "console", ")", ";", "if", "(", "enabled", ".", "enabled", ")", "logFn", ".", "apply", "(", "logger", ",", "args", ")", ";", "}", ";", "}" ]
Wrap winston logger to be somewhat api compatible with debug
[ "Wrap", "winston", "logger", "to", "be", "somewhat", "api", "compatible", "with", "debug" ]
1d2806d2ffb8f66892f6ed7b65bd5b5abc501973
https://github.com/tbashor/architect-debug-logger/blob/1d2806d2ffb8f66892f6ed7b65bd5b5abc501973/logger.js#L156-L169
57,885
tbashor/architect-debug-logger
logger.js
disable
function disable(namespaces) { var split = (namespaces || '').split(/[\s,]+/); var len = split.length; function removeNamespaceFromNames(namespaces){ _.remove(exports.names, function(name){ return name.toString() === '/^' + namespaces + '$/'; }); } for (var i = 0; i < len; i++) { if (!split[i]) continue; // ignore empty strings namespaces = split[i].replace(/\*/g, '.*?'); if (namespaces[0] === '-') { exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); } else { removeNamespaceFromNames(namespaces); exports.skips.push(new RegExp('^' + namespaces + '$')); loggerEventBus.emit('disable', split[i]); } } exports.save(namespaces); }
javascript
function disable(namespaces) { var split = (namespaces || '').split(/[\s,]+/); var len = split.length; function removeNamespaceFromNames(namespaces){ _.remove(exports.names, function(name){ return name.toString() === '/^' + namespaces + '$/'; }); } for (var i = 0; i < len; i++) { if (!split[i]) continue; // ignore empty strings namespaces = split[i].replace(/\*/g, '.*?'); if (namespaces[0] === '-') { exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); } else { removeNamespaceFromNames(namespaces); exports.skips.push(new RegExp('^' + namespaces + '$')); loggerEventBus.emit('disable', split[i]); } } exports.save(namespaces); }
[ "function", "disable", "(", "namespaces", ")", "{", "var", "split", "=", "(", "namespaces", "||", "''", ")", ".", "split", "(", "/", "[\\s,]+", "/", ")", ";", "var", "len", "=", "split", ".", "length", ";", "function", "removeNamespaceFromNames", "(", "namespaces", ")", "{", "_", ".", "remove", "(", "exports", ".", "names", ",", "function", "(", "name", ")", "{", "return", "name", ".", "toString", "(", ")", "===", "'/^'", "+", "namespaces", "+", "'$/'", ";", "}", ")", ";", "}", "for", "(", "var", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "if", "(", "!", "split", "[", "i", "]", ")", "continue", ";", "// ignore empty strings", "namespaces", "=", "split", "[", "i", "]", ".", "replace", "(", "/", "\\*", "/", "g", ",", "'.*?'", ")", ";", "if", "(", "namespaces", "[", "0", "]", "===", "'-'", ")", "{", "exports", ".", "skips", ".", "push", "(", "new", "RegExp", "(", "'^'", "+", "namespaces", ".", "substr", "(", "1", ")", "+", "'$'", ")", ")", ";", "}", "else", "{", "removeNamespaceFromNames", "(", "namespaces", ")", ";", "exports", ".", "skips", ".", "push", "(", "new", "RegExp", "(", "'^'", "+", "namespaces", "+", "'$'", ")", ")", ";", "loggerEventBus", ".", "emit", "(", "'disable'", ",", "split", "[", "i", "]", ")", ";", "}", "}", "exports", ".", "save", "(", "namespaces", ")", ";", "}" ]
Disables a debug mode by namespaces. This can include modes separated by a colon and wildcards. @param {String} namespaces @api public
[ "Disables", "a", "debug", "mode", "by", "namespaces", ".", "This", "can", "include", "modes", "separated", "by", "a", "colon", "and", "wildcards", "." ]
1d2806d2ffb8f66892f6ed7b65bd5b5abc501973
https://github.com/tbashor/architect-debug-logger/blob/1d2806d2ffb8f66892f6ed7b65bd5b5abc501973/logger.js#L236-L259
57,886
zuzana/mocha-xunit-zh
xunit-zh.js
XUnitZH
function XUnitZH(runner) { var tests = [], passes = 0, failures = 0; runner.on('pass', function(test){ test.state = 'passed'; passes++; tests.push(test); test.number = tests.length; }); runner.on('fail', function(test){ test.state = 'failed'; failures++; tests.push(test); test.number = tests.length; }); runner.on('end', function(){ console.log(); console.log('testsuite: Mocha Tests' + ', tests: ' + tests.length + ', failures: ' + failures + ', errors: ' + failures + ', skipped: ' + (tests.length - failures - passes) + ', time: ' + 0 ); appendLine(tag('testsuite', { name: 'Mocha Tests' , tests: tests.length , failures: failures , errors: failures , skipped: tests.length - failures - passes , timestamp: (new Date).toUTCString() , time: 0 }, false)); tests.forEach(test); appendLine('</testsuite>'); fs.closeSync(fd); process.exit(failures); }); }
javascript
function XUnitZH(runner) { var tests = [], passes = 0, failures = 0; runner.on('pass', function(test){ test.state = 'passed'; passes++; tests.push(test); test.number = tests.length; }); runner.on('fail', function(test){ test.state = 'failed'; failures++; tests.push(test); test.number = tests.length; }); runner.on('end', function(){ console.log(); console.log('testsuite: Mocha Tests' + ', tests: ' + tests.length + ', failures: ' + failures + ', errors: ' + failures + ', skipped: ' + (tests.length - failures - passes) + ', time: ' + 0 ); appendLine(tag('testsuite', { name: 'Mocha Tests' , tests: tests.length , failures: failures , errors: failures , skipped: tests.length - failures - passes , timestamp: (new Date).toUTCString() , time: 0 }, false)); tests.forEach(test); appendLine('</testsuite>'); fs.closeSync(fd); process.exit(failures); }); }
[ "function", "XUnitZH", "(", "runner", ")", "{", "var", "tests", "=", "[", "]", ",", "passes", "=", "0", ",", "failures", "=", "0", ";", "runner", ".", "on", "(", "'pass'", ",", "function", "(", "test", ")", "{", "test", ".", "state", "=", "'passed'", ";", "passes", "++", ";", "tests", ".", "push", "(", "test", ")", ";", "test", ".", "number", "=", "tests", ".", "length", ";", "}", ")", ";", "runner", ".", "on", "(", "'fail'", ",", "function", "(", "test", ")", "{", "test", ".", "state", "=", "'failed'", ";", "failures", "++", ";", "tests", ".", "push", "(", "test", ")", ";", "test", ".", "number", "=", "tests", ".", "length", ";", "}", ")", ";", "runner", ".", "on", "(", "'end'", ",", "function", "(", ")", "{", "console", ".", "log", "(", ")", ";", "console", ".", "log", "(", "'testsuite: Mocha Tests'", "+", "', tests: '", "+", "tests", ".", "length", "+", "', failures: '", "+", "failures", "+", "', errors: '", "+", "failures", "+", "', skipped: '", "+", "(", "tests", ".", "length", "-", "failures", "-", "passes", ")", "+", "', time: '", "+", "0", ")", ";", "appendLine", "(", "tag", "(", "'testsuite'", ",", "{", "name", ":", "'Mocha Tests'", ",", "tests", ":", "tests", ".", "length", ",", "failures", ":", "failures", ",", "errors", ":", "failures", ",", "skipped", ":", "tests", ".", "length", "-", "failures", "-", "passes", ",", "timestamp", ":", "(", "new", "Date", ")", ".", "toUTCString", "(", ")", ",", "time", ":", "0", "}", ",", "false", ")", ")", ";", "tests", ".", "forEach", "(", "test", ")", ";", "appendLine", "(", "'</testsuite>'", ")", ";", "fs", ".", "closeSync", "(", "fd", ")", ";", "process", ".", "exit", "(", "failures", ")", ";", "}", ")", ";", "}" ]
Initialize a new `XUnitZH` reporter. @param {Runner} runner @api public
[ "Initialize", "a", "new", "XUnitZH", "reporter", "." ]
9c8862fb0562eae3f0cc9d09704f55a093203e81
https://github.com/zuzana/mocha-xunit-zh/blob/9c8862fb0562eae3f0cc9d09704f55a093203e81/xunit-zh.js#L35-L80
57,887
zuzana/mocha-xunit-zh
xunit-zh.js
toConsole
function toConsole(number, name, state, content){ console.log(number + ') ' + state + ' ' + name); if (content) { console.log('\t' + content); } }
javascript
function toConsole(number, name, state, content){ console.log(number + ') ' + state + ' ' + name); if (content) { console.log('\t' + content); } }
[ "function", "toConsole", "(", "number", ",", "name", ",", "state", ",", "content", ")", "{", "console", ".", "log", "(", "number", "+", "') '", "+", "state", "+", "' '", "+", "name", ")", ";", "if", "(", "content", ")", "{", "console", ".", "log", "(", "'\\t'", "+", "content", ")", ";", "}", "}" ]
Output to console
[ "Output", "to", "console" ]
9c8862fb0562eae3f0cc9d09704f55a093203e81
https://github.com/zuzana/mocha-xunit-zh/blob/9c8862fb0562eae3f0cc9d09704f55a093203e81/xunit-zh.js#L128-L133
57,888
TribeMedia/tribemedia-kurento-client-elements-js
lib/complexTypes/IceComponentState.js
checkIceComponentState
function checkIceComponentState(key, value) { if(typeof value != 'string') throw SyntaxError(key+' param should be a String, not '+typeof value); if(!value.match('DISCONNECTED|GATHERING|CONNECTING|CONNECTED|READY|FAILED')) throw SyntaxError(key+' param is not one of [DISCONNECTED|GATHERING|CONNECTING|CONNECTED|READY|FAILED] ('+value+')'); }
javascript
function checkIceComponentState(key, value) { if(typeof value != 'string') throw SyntaxError(key+' param should be a String, not '+typeof value); if(!value.match('DISCONNECTED|GATHERING|CONNECTING|CONNECTED|READY|FAILED')) throw SyntaxError(key+' param is not one of [DISCONNECTED|GATHERING|CONNECTING|CONNECTED|READY|FAILED] ('+value+')'); }
[ "function", "checkIceComponentState", "(", "key", ",", "value", ")", "{", "if", "(", "typeof", "value", "!=", "'string'", ")", "throw", "SyntaxError", "(", "key", "+", "' param should be a String, not '", "+", "typeof", "value", ")", ";", "if", "(", "!", "value", ".", "match", "(", "'DISCONNECTED|GATHERING|CONNECTING|CONNECTED|READY|FAILED'", ")", ")", "throw", "SyntaxError", "(", "key", "+", "' param is not one of [DISCONNECTED|GATHERING|CONNECTING|CONNECTED|READY|FAILED] ('", "+", "value", "+", "')'", ")", ";", "}" ]
States of an ICE component. @typedef elements/complexTypes.IceComponentState @type {(DISCONNECTED|GATHERING|CONNECTING|CONNECTED|READY|FAILED)} Checker for {@link elements/complexTypes.IceComponentState} @memberof module:elements/complexTypes @param {external:String} key @param {module:elements/complexTypes.IceComponentState} value
[ "States", "of", "an", "ICE", "component", "." ]
1a5570f05bf8c2c25bbeceb4f96cb2770f634de9
https://github.com/TribeMedia/tribemedia-kurento-client-elements-js/blob/1a5570f05bf8c2c25bbeceb4f96cb2770f634de9/lib/complexTypes/IceComponentState.js#L37-L44
57,889
dlindahl/stemcell
src/components/Bit.js
applyStyles
function applyStyles (css) { return flattenDeep(css) .reduce( (classNames, declarations) => { if (!declarations) { return classNames } classNames.push(glamor(declarations)) return classNames }, [] ) .join(' ') }
javascript
function applyStyles (css) { return flattenDeep(css) .reduce( (classNames, declarations) => { if (!declarations) { return classNames } classNames.push(glamor(declarations)) return classNames }, [] ) .join(' ') }
[ "function", "applyStyles", "(", "css", ")", "{", "return", "flattenDeep", "(", "css", ")", ".", "reduce", "(", "(", "classNames", ",", "declarations", ")", "=>", "{", "if", "(", "!", "declarations", ")", "{", "return", "classNames", "}", "classNames", ".", "push", "(", "glamor", "(", "declarations", ")", ")", "return", "classNames", "}", ",", "[", "]", ")", ".", "join", "(", "' '", ")", "}" ]
Generate CSS classnames from CSS props
[ "Generate", "CSS", "classnames", "from", "CSS", "props" ]
1901c637bb5d7dc00e45184a424c429c8b9dc3be
https://github.com/dlindahl/stemcell/blob/1901c637bb5d7dc00e45184a424c429c8b9dc3be/src/components/Bit.js#L18-L31
57,890
sreenaths/em-tgraph
addon/utils/data-processor.js
centericMap
function centericMap(array, callback) { var retArray = [], length, left, right; if(array) { length = array.length - 1; left = length >> 1; while(left >= 0) { retArray[left] = callback(array[left]); right = length - left; if(right !== left) { retArray[right] = callback(array[right]); } left--; } } return retArray; }
javascript
function centericMap(array, callback) { var retArray = [], length, left, right; if(array) { length = array.length - 1; left = length >> 1; while(left >= 0) { retArray[left] = callback(array[left]); right = length - left; if(right !== left) { retArray[right] = callback(array[right]); } left--; } } return retArray; }
[ "function", "centericMap", "(", "array", ",", "callback", ")", "{", "var", "retArray", "=", "[", "]", ",", "length", ",", "left", ",", "right", ";", "if", "(", "array", ")", "{", "length", "=", "array", ".", "length", "-", "1", ";", "left", "=", "length", ">>", "1", ";", "while", "(", "left", ">=", "0", ")", "{", "retArray", "[", "left", "]", "=", "callback", "(", "array", "[", "left", "]", ")", ";", "right", "=", "length", "-", "left", ";", "if", "(", "right", "!==", "left", ")", "{", "retArray", "[", "right", "]", "=", "callback", "(", "array", "[", "right", "]", ")", ";", "}", "left", "--", ";", "}", "}", "return", "retArray", ";", "}" ]
Iterates the array in a symmetric order, from middle to outwards @param array {Array} Array to be iterated @param callback {Function} Function to be called for each item @return A new array created with value returned by callback
[ "Iterates", "the", "array", "in", "a", "symmetric", "order", "from", "middle", "to", "outwards" ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/data-processor.js#L160-L179
57,891
sreenaths/em-tgraph
addon/utils/data-processor.js
function (children) { var allChildren = this.get('allChildren'); if(allChildren) { this._setChildren(allChildren.filter(function (child) { return children.indexOf(child) !== -1; // true if child is in children })); } }
javascript
function (children) { var allChildren = this.get('allChildren'); if(allChildren) { this._setChildren(allChildren.filter(function (child) { return children.indexOf(child) !== -1; // true if child is in children })); } }
[ "function", "(", "children", ")", "{", "var", "allChildren", "=", "this", ".", "get", "(", "'allChildren'", ")", ";", "if", "(", "allChildren", ")", "{", "this", ".", "_setChildren", "(", "allChildren", ".", "filter", "(", "function", "(", "child", ")", "{", "return", "children", ".", "indexOf", "(", "child", ")", "!==", "-", "1", ";", "// true if child is in children", "}", ")", ")", ";", "}", "}" ]
Public function. Set the child array after filtering @param children {Array} Array of DataNodes to be set
[ "Public", "function", ".", "Set", "the", "child", "array", "after", "filtering" ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/data-processor.js#L215-L222
57,892
sreenaths/em-tgraph
addon/utils/data-processor.js
function (childrenToRemove) { var children = this.get('children'); if(children) { children = children.filter(function (child) { return childrenToRemove.indexOf(child) === -1; // false if child is in children }); this._setChildren(children); } }
javascript
function (childrenToRemove) { var children = this.get('children'); if(children) { children = children.filter(function (child) { return childrenToRemove.indexOf(child) === -1; // false if child is in children }); this._setChildren(children); } }
[ "function", "(", "childrenToRemove", ")", "{", "var", "children", "=", "this", ".", "get", "(", "'children'", ")", ";", "if", "(", "children", ")", "{", "children", "=", "children", ".", "filter", "(", "function", "(", "child", ")", "{", "return", "childrenToRemove", ".", "indexOf", "(", "child", ")", "===", "-", "1", ";", "// false if child is in children", "}", ")", ";", "this", ".", "_setChildren", "(", "children", ")", ";", "}", "}" ]
Filter out the given children from the children array. @param childrenToRemove {Array} Array of DataNodes to be removed
[ "Filter", "out", "the", "given", "children", "from", "the", "children", "array", "." ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/data-processor.js#L227-L235
57,893
sreenaths/em-tgraph
addon/utils/data-processor.js
function (property, callback, thisArg) { if(this.get(property)) { this.get(property).forEach(callback, thisArg); } }
javascript
function (property, callback, thisArg) { if(this.get(property)) { this.get(property).forEach(callback, thisArg); } }
[ "function", "(", "property", ",", "callback", ",", "thisArg", ")", "{", "if", "(", "this", ".", "get", "(", "property", ")", ")", "{", "this", ".", "get", "(", "property", ")", ".", "forEach", "(", "callback", ",", "thisArg", ")", ";", "}", "}" ]
If the property is available, expects it to be an array and iterate over its elements using the callback. @param vertex {DataNode} @param callback {Function} @param thisArg {} Will be value of this inside the callback
[ "If", "the", "property", "is", "available", "expects", "it", "to", "be", "an", "array", "and", "iterate", "over", "its", "elements", "using", "the", "callback", "." ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/data-processor.js#L258-L262
57,894
sreenaths/em-tgraph
addon/utils/data-processor.js
function (depth) { this.set('depth', depth); depth++; this.get('inputs').forEach(function (input) { input.set('depth', depth); }); }
javascript
function (depth) { this.set('depth', depth); depth++; this.get('inputs').forEach(function (input) { input.set('depth', depth); }); }
[ "function", "(", "depth", ")", "{", "this", ".", "set", "(", "'depth'", ",", "depth", ")", ";", "depth", "++", ";", "this", ".", "get", "(", "'inputs'", ")", ".", "forEach", "(", "function", "(", "input", ")", "{", "input", ".", "set", "(", "'depth'", ",", "depth", ")", ";", "}", ")", ";", "}" ]
Sets depth of the vertex and all its input children @param depth {Number}
[ "Sets", "depth", "of", "the", "vertex", "and", "all", "its", "input", "children" ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/data-processor.js#L315-L322
57,895
sreenaths/em-tgraph
addon/utils/data-processor.js
function() { this.setChildren(this.get('inputs').concat(this.get('children') || [])); var ancestor = this.get('parent.parent'); if(ancestor) { ancestor.setChildren(this.get('outputs').concat(ancestor.get('children') || [])); } this.set('_additionalsIncluded', true); }
javascript
function() { this.setChildren(this.get('inputs').concat(this.get('children') || [])); var ancestor = this.get('parent.parent'); if(ancestor) { ancestor.setChildren(this.get('outputs').concat(ancestor.get('children') || [])); } this.set('_additionalsIncluded', true); }
[ "function", "(", ")", "{", "this", ".", "setChildren", "(", "this", ".", "get", "(", "'inputs'", ")", ".", "concat", "(", "this", ".", "get", "(", "'children'", ")", "||", "[", "]", ")", ")", ";", "var", "ancestor", "=", "this", ".", "get", "(", "'parent.parent'", ")", ";", "if", "(", "ancestor", ")", "{", "ancestor", ".", "setChildren", "(", "this", ".", "get", "(", "'outputs'", ")", ".", "concat", "(", "ancestor", ".", "get", "(", "'children'", ")", "||", "[", "]", ")", ")", ";", "}", "this", ".", "set", "(", "'_additionalsIncluded'", ",", "true", ")", ";", "}" ]
Include sources and sinks in the children list, so that they are displayed
[ "Include", "sources", "and", "sinks", "in", "the", "children", "list", "so", "that", "they", "are", "displayed" ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/data-processor.js#L335-L343
57,896
sreenaths/em-tgraph
addon/utils/data-processor.js
function() { this.removeChildren(this.get('inputs')); var ancestor = this.get('parent.parent'); if(ancestor) { ancestor.removeChildren(this.get('outputs')); } this.set('_additionalsIncluded', false); }
javascript
function() { this.removeChildren(this.get('inputs')); var ancestor = this.get('parent.parent'); if(ancestor) { ancestor.removeChildren(this.get('outputs')); } this.set('_additionalsIncluded', false); }
[ "function", "(", ")", "{", "this", ".", "removeChildren", "(", "this", ".", "get", "(", "'inputs'", ")", ")", ";", "var", "ancestor", "=", "this", ".", "get", "(", "'parent.parent'", ")", ";", "if", "(", "ancestor", ")", "{", "ancestor", ".", "removeChildren", "(", "this", ".", "get", "(", "'outputs'", ")", ")", ";", "}", "this", ".", "set", "(", "'_additionalsIncluded'", ",", "false", ")", ";", "}" ]
Exclude sources and sinks in the children list, so that they are hidden
[ "Exclude", "sources", "and", "sinks", "in", "the", "children", "list", "so", "that", "they", "are", "hidden" ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/data-processor.js#L347-L355
57,897
sreenaths/em-tgraph
addon/utils/data-processor.js
function () { var vertex = this.get('vertex'); this._super(); // Initialize data members this.setProperties({ id: vertex.get('vertexName') + this.get('name'), depth: vertex.get('depth') + 1 }); }
javascript
function () { var vertex = this.get('vertex'); this._super(); // Initialize data members this.setProperties({ id: vertex.get('vertexName') + this.get('name'), depth: vertex.get('depth') + 1 }); }
[ "function", "(", ")", "{", "var", "vertex", "=", "this", ".", "get", "(", "'vertex'", ")", ";", "this", ".", "_super", "(", ")", ";", "// Initialize data members", "this", ".", "setProperties", "(", "{", "id", ":", "vertex", ".", "get", "(", "'vertexName'", ")", "+", "this", ".", "get", "(", "'name'", ")", ",", "depth", ":", "vertex", ".", "get", "(", "'depth'", ")", "+", "1", "}", ")", ";", "}" ]
The vertex DataNode to which this node is linked
[ "The", "vertex", "DataNode", "to", "which", "this", "node", "is", "linked" ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/data-processor.js#L375-L384
57,898
sreenaths/em-tgraph
addon/utils/data-processor.js
function (vertex, data) { return InputDataNode.create(Ember.$.extend(data, { treeParent: vertex, vertex: vertex })); }
javascript
function (vertex, data) { return InputDataNode.create(Ember.$.extend(data, { treeParent: vertex, vertex: vertex })); }
[ "function", "(", "vertex", ",", "data", ")", "{", "return", "InputDataNode", ".", "create", "(", "Ember", ".", "$", ".", "extend", "(", "data", ",", "{", "treeParent", ":", "vertex", ",", "vertex", ":", "vertex", "}", ")", ")", ";", "}" ]
Initiate an InputDataNode @param vertex {DataNode} @param data {Object}
[ "Initiate", "an", "InputDataNode" ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/data-processor.js#L391-L396
57,899
sreenaths/em-tgraph
addon/utils/data-processor.js
_normalizeVertexTree
function _normalizeVertexTree(vertex) { var children = vertex.get('children'); if(children) { children = children.filter(function (child) { _normalizeVertexTree(child); return child.get('type') !== 'vertex' || child.get('treeParent') === vertex; }); vertex._setChildren(children); } return vertex; }
javascript
function _normalizeVertexTree(vertex) { var children = vertex.get('children'); if(children) { children = children.filter(function (child) { _normalizeVertexTree(child); return child.get('type') !== 'vertex' || child.get('treeParent') === vertex; }); vertex._setChildren(children); } return vertex; }
[ "function", "_normalizeVertexTree", "(", "vertex", ")", "{", "var", "children", "=", "vertex", ".", "get", "(", "'children'", ")", ";", "if", "(", "children", ")", "{", "children", "=", "children", ".", "filter", "(", "function", "(", "child", ")", "{", "_normalizeVertexTree", "(", "child", ")", ";", "return", "child", ".", "get", "(", "'type'", ")", "!==", "'vertex'", "||", "child", ".", "get", "(", "'treeParent'", ")", "===", "vertex", ";", "}", ")", ";", "vertex", ".", "_setChildren", "(", "children", ")", ";", "}", "return", "vertex", ";", "}" ]
Part of step 1 To remove recurring vertices in the tree @param vertex {Object} root vertex
[ "Part", "of", "step", "1", "To", "remove", "recurring", "vertices", "in", "the", "tree" ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/data-processor.js#L495-L508