id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
50,800
Amberlamps/object-subset
dist/objectSubset.js
createLookUp
function createLookUp(keywords) { return keywords.reduce(function(p, c) { c.split('.').reduce(function(pr, cu) { if (pr.hasOwnProperty(cu)) { return pr[cu]; } else { pr[cu] = {}; return pr[cu]; } }, p); return p; }, {}); }
javascript
function createLookUp(keywords) { return keywords.reduce(function(p, c) { c.split('.').reduce(function(pr, cu) { if (pr.hasOwnProperty(cu)) { return pr[cu]; } else { pr[cu] = {}; return pr[cu]; } }, p); return p; }, {}); }
[ "function", "createLookUp", "(", "keywords", ")", "{", "return", "keywords", ".", "reduce", "(", "function", "(", "p", ",", "c", ")", "{", "c", ".", "split", "(", "'.'", ")", ".", "reduce", "(", "function", "(", "pr", ",", "cu", ")", "{", "if", "...
createLookUp iterates over every keyword and creates a tree where the leaves are empty objects. The lookup object is used to be able to traverse along the input document.
[ "createLookUp", "iterates", "over", "every", "keyword", "and", "creates", "a", "tree", "where", "the", "leaves", "are", "empty", "objects", ".", "The", "lookup", "object", "is", "used", "to", "be", "able", "to", "traverse", "along", "the", "input", "document...
c96436360381a4e0c662531c18a82afc6290ea0c
https://github.com/Amberlamps/object-subset/blob/c96436360381a4e0c662531c18a82afc6290ea0c/dist/objectSubset.js#L41-L64
50,801
Amberlamps/object-subset
dist/objectSubset.js
traverseThroughObject
function traverseThroughObject(lookup, doc, output) { if (!output) { output = {}; } for (var key in lookup) { if (doc.hasOwnProperty(key)) { if(Object.keys(lookup[key]).length === 0) { output[key] = doc[key]; } else { if (!output.hasOwnProperty(key)) { if (Object.prototype.toString.call(doc[key]) === '[object Array]') { output[key] = []; for (var i = 0, _len = doc[key].length; i < _len; i++) { var field = {}; output[key].push(field); traverseThroughObject(lookup[key], doc[key][i], field); } } else { output[key] = {}; traverseThroughObject(lookup[key], doc[key], output[key]); } } } } } return output; }
javascript
function traverseThroughObject(lookup, doc, output) { if (!output) { output = {}; } for (var key in lookup) { if (doc.hasOwnProperty(key)) { if(Object.keys(lookup[key]).length === 0) { output[key] = doc[key]; } else { if (!output.hasOwnProperty(key)) { if (Object.prototype.toString.call(doc[key]) === '[object Array]') { output[key] = []; for (var i = 0, _len = doc[key].length; i < _len; i++) { var field = {}; output[key].push(field); traverseThroughObject(lookup[key], doc[key][i], field); } } else { output[key] = {}; traverseThroughObject(lookup[key], doc[key], output[key]); } } } } } return output; }
[ "function", "traverseThroughObject", "(", "lookup", ",", "doc", ",", "output", ")", "{", "if", "(", "!", "output", ")", "{", "output", "=", "{", "}", ";", "}", "for", "(", "var", "key", "in", "lookup", ")", "{", "if", "(", "doc", ".", "hasOwnProper...
traverseThroughObject is traversing through the object by the fields described in lookup and filling the output object accordingly in the process.
[ "traverseThroughObject", "is", "traversing", "through", "the", "object", "by", "the", "fields", "described", "in", "lookup", "and", "filling", "the", "output", "object", "accordingly", "in", "the", "process", "." ]
c96436360381a4e0c662531c18a82afc6290ea0c
https://github.com/Amberlamps/object-subset/blob/c96436360381a4e0c662531c18a82afc6290ea0c/dist/objectSubset.js#L72-L116
50,802
Alhadis/Chai-Untab
chai-untab.js
setUntab
function setUntab(depth, trim){ started = true; /** Disable untab */ if(!depth){ _depth = null; _trim = false; } else{ _depth = depth; _trim = trim; } }
javascript
function setUntab(depth, trim){ started = true; /** Disable untab */ if(!depth){ _depth = null; _trim = false; } else{ _depth = depth; _trim = trim; } }
[ "function", "setUntab", "(", "depth", ",", "trim", ")", "{", "started", "=", "true", ";", "/** Disable untab */", "if", "(", "!", "depth", ")", "{", "_depth", "=", "null", ";", "_trim", "=", "false", ";", "}", "else", "{", "_depth", "=", "depth", ";"...
Set unindentation settings for this suite level. @param {Number} depth @param {Boolean} trim @private
[ "Set", "unindentation", "settings", "for", "this", "suite", "level", "." ]
4669cdf71a46d4370ade92ef387709615d5eb204
https://github.com/Alhadis/Chai-Untab/blob/4669cdf71a46d4370ade92ef387709615d5eb204/chai-untab.js#L67-L80
50,803
Alhadis/Chai-Untab
chai-untab.js
doUntab
function doUntab(input, depth = undefined, trim = undefined){ /** Not a string? Leave it. */ if("[object String]" !== Object.prototype.toString.call(input)) return input; if(trim === undefined) trim = _trim; if(depth === undefined) depth = _depth; /** Strip leading and trailing lines if told to */ if(trim) input = input.replace(/^(?:[\x20\t]*\n)*|(?:\n[\x20\t]*)*$/gi, ""); const untabPatt = new RegExp("^(?:" + untabChar + "){0," + depth + "}", "gm"); return input.replace(untabPatt, ""); }
javascript
function doUntab(input, depth = undefined, trim = undefined){ /** Not a string? Leave it. */ if("[object String]" !== Object.prototype.toString.call(input)) return input; if(trim === undefined) trim = _trim; if(depth === undefined) depth = _depth; /** Strip leading and trailing lines if told to */ if(trim) input = input.replace(/^(?:[\x20\t]*\n)*|(?:\n[\x20\t]*)*$/gi, ""); const untabPatt = new RegExp("^(?:" + untabChar + "){0," + depth + "}", "gm"); return input.replace(untabPatt, ""); }
[ "function", "doUntab", "(", "input", ",", "depth", "=", "undefined", ",", "trim", "=", "undefined", ")", "{", "/** Not a string? Leave it. */", "if", "(", "\"[object String]\"", "!==", "Object", ".", "prototype", ".", "toString", ".", "call", "(", "input", ")"...
Remove leading indentation using Chai's current untab- settings. Called automatically, but exposed for external use. If the supplied argument isn't a string, it's returned untouched without further ado. Arguments beyond the first are optional: if either depth or trim are omitted, they default to those set for the current suite level. @param {Mixed} input @param {Number} depth @param {Boolean} trim @return {Mixed|String} @public
[ "Remove", "leading", "indentation", "using", "Chai", "s", "current", "untab", "-", "settings", "." ]
4669cdf71a46d4370ade92ef387709615d5eb204
https://github.com/Alhadis/Chai-Untab/blob/4669cdf71a46d4370ade92ef387709615d5eb204/chai-untab.js#L98-L113
50,804
Alhadis/Chai-Untab
chai-untab.js
hookIntoChai
function hookIntoChai(){ if(hooked) return; hooked = true; for(const method of ["equal", "string"]){ Chai.Assertion.overwriteMethod(method, function(__super){ return function(input, ...rest){ __super.apply(this, [ doUntab(input), ...rest ]); } }); } }
javascript
function hookIntoChai(){ if(hooked) return; hooked = true; for(const method of ["equal", "string"]){ Chai.Assertion.overwriteMethod(method, function(__super){ return function(input, ...rest){ __super.apply(this, [ doUntab(input), ...rest ]); } }); } }
[ "function", "hookIntoChai", "(", ")", "{", "if", "(", "hooked", ")", "return", ";", "hooked", "=", "true", ";", "for", "(", "const", "method", "of", "[", "\"equal\"", ",", "\"string\"", "]", ")", "{", "Chai", ".", "Assertion", ".", "overwriteMethod", "...
Overwrite the necessary Chai methods for comparing string-blocks. Only executed the first time Chai.untab is set. @private
[ "Overwrite", "the", "necessary", "Chai", "methods", "for", "comparing", "string", "-", "blocks", "." ]
4669cdf71a46d4370ade92ef387709615d5eb204
https://github.com/Alhadis/Chai-Untab/blob/4669cdf71a46d4370ade92ef387709615d5eb204/chai-untab.js#L122-L133
50,805
Xen3r0/pagesJson_uirouter
tasks/pagesJson_uirouter.js
objectToString
function objectToString(object, tabs) { var result = []; var keys = Object.keys(object); keys.forEach(function (key, keyIndex) { var line; var formatedKey; if (-1 < key.indexOf('@')) { formatedKey = '\'' + key + '\''; } else { formatedKey = key; } if (typeof object[key] === 'object') { if (Array.isArray(object[key])) { var newTabs = (tabs + 1); line = getTabs(tabs) + '' + formatedKey + ': ['; object[key].forEach(function (item, itemIndex) { if (typeof item === 'object') { line += "\n" + getTabs(newTabs) + '{'; line += "\n" + objectToString(item, (newTabs + 1)); line += "\n" + getTabs(newTabs) + '}'; } else if (typeof item === 'string') { line += "\n" + getTabs(newTabs) + '\'' + addslashes(item) + '\''; } else if (typeof item === 'boolean') { line += "\n" + getTabs(newTabs) + '' + item; } else if (typeof item === 'number') { line += "\n" + getTabs(newTabs) + '' + item; } if (itemIndex < (object[key].length - 1)) { line += ','; } }); line += "\n" + getTabs(tabs) + ']'; } else { line = getTabs(tabs) + '' + formatedKey + ': {' + "\n"; line += objectToString(object[key], (tabs + 1)); line += "\n" + getTabs(tabs) + '}'; } } else if (typeof object[key] === 'string') { line = getTabs(tabs) + '' + formatedKey + ': \'' + addslashes(object[key]) + '\''; } else if (typeof object[key] === 'boolean') { line = getTabs(tabs) + '' + formatedKey + ': ' + object[key]; } else if (typeof object[key] === 'number') { line = getTabs(tabs) + '' + formatedKey + ': ' + object[key]; } if (keyIndex < (keys.length - 1)) { line += ','; } result.push(line); }); return result.join("\n"); }
javascript
function objectToString(object, tabs) { var result = []; var keys = Object.keys(object); keys.forEach(function (key, keyIndex) { var line; var formatedKey; if (-1 < key.indexOf('@')) { formatedKey = '\'' + key + '\''; } else { formatedKey = key; } if (typeof object[key] === 'object') { if (Array.isArray(object[key])) { var newTabs = (tabs + 1); line = getTabs(tabs) + '' + formatedKey + ': ['; object[key].forEach(function (item, itemIndex) { if (typeof item === 'object') { line += "\n" + getTabs(newTabs) + '{'; line += "\n" + objectToString(item, (newTabs + 1)); line += "\n" + getTabs(newTabs) + '}'; } else if (typeof item === 'string') { line += "\n" + getTabs(newTabs) + '\'' + addslashes(item) + '\''; } else if (typeof item === 'boolean') { line += "\n" + getTabs(newTabs) + '' + item; } else if (typeof item === 'number') { line += "\n" + getTabs(newTabs) + '' + item; } if (itemIndex < (object[key].length - 1)) { line += ','; } }); line += "\n" + getTabs(tabs) + ']'; } else { line = getTabs(tabs) + '' + formatedKey + ': {' + "\n"; line += objectToString(object[key], (tabs + 1)); line += "\n" + getTabs(tabs) + '}'; } } else if (typeof object[key] === 'string') { line = getTabs(tabs) + '' + formatedKey + ': \'' + addslashes(object[key]) + '\''; } else if (typeof object[key] === 'boolean') { line = getTabs(tabs) + '' + formatedKey + ': ' + object[key]; } else if (typeof object[key] === 'number') { line = getTabs(tabs) + '' + formatedKey + ': ' + object[key]; } if (keyIndex < (keys.length - 1)) { line += ','; } result.push(line); }); return result.join("\n"); }
[ "function", "objectToString", "(", "object", ",", "tabs", ")", "{", "var", "result", "=", "[", "]", ";", "var", "keys", "=", "Object", ".", "keys", "(", "object", ")", ";", "keys", ".", "forEach", "(", "function", "(", "key", ",", "keyIndex", ")", ...
Transformer un objet en chaine @param {Object} object @param {Number} tabs
[ "Transformer", "un", "objet", "en", "chaine" ]
2d15ec9cac71c010073ff812239613f3ab101ba2
https://github.com/Xen3r0/pagesJson_uirouter/blob/2d15ec9cac71c010073ff812239613f3ab101ba2/tasks/pagesJson_uirouter.js#L81-L141
50,806
Xen3r0/pagesJson_uirouter
tasks/pagesJson_uirouter.js
stateRefSearch
function stateRefSearch(pages, stateName) { for (var i = 0; i < pages.length; i++) { if (pages[i].name === stateName) { return pages[i]; } } return null; }
javascript
function stateRefSearch(pages, stateName) { for (var i = 0; i < pages.length; i++) { if (pages[i].name === stateName) { return pages[i]; } } return null; }
[ "function", "stateRefSearch", "(", "pages", ",", "stateName", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "pages", ".", "length", ";", "i", "++", ")", "{", "if", "(", "pages", "[", "i", "]", ".", "name", "===", "stateName", ")", ...
Chercher une state @param {Object[]} pages @param {String} stateName @returns {null|Object}
[ "Chercher", "une", "state" ]
2d15ec9cac71c010073ff812239613f3ab101ba2
https://github.com/Xen3r0/pagesJson_uirouter/blob/2d15ec9cac71c010073ff812239613f3ab101ba2/tasks/pagesJson_uirouter.js#L312-L320
50,807
Xen3r0/pagesJson_uirouter
tasks/pagesJson_uirouter.js
isEmpty
function isEmpty(str) { if (null === str || typeof str === 'undefined') { return true; } if (typeof str === 'string') { return (0 === str.length); } if (typeof str === 'object' && Array.isArray(str)) { return (0 === str.length); } return false; }
javascript
function isEmpty(str) { if (null === str || typeof str === 'undefined') { return true; } if (typeof str === 'string') { return (0 === str.length); } if (typeof str === 'object' && Array.isArray(str)) { return (0 === str.length); } return false; }
[ "function", "isEmpty", "(", "str", ")", "{", "if", "(", "null", "===", "str", "||", "typeof", "str", "===", "'undefined'", ")", "{", "return", "true", ";", "}", "if", "(", "typeof", "str", "===", "'string'", ")", "{", "return", "(", "0", "===", "st...
Chaine vide ? @param {*} str @returns {Boolean}
[ "Chaine", "vide", "?" ]
2d15ec9cac71c010073ff812239613f3ab101ba2
https://github.com/Xen3r0/pagesJson_uirouter/blob/2d15ec9cac71c010073ff812239613f3ab101ba2/tasks/pagesJson_uirouter.js#L327-L341
50,808
alantu/queues
lib/sqs.js
Provider
function Provider(id, secret) { if (!(this instanceof Provider)) { return new Provider(id, secret); } this.client = new AWS.SQS({ accessKeyId: id, secretAccessKey: secret, region: 'us-east-1' }); this.queues = {}; }
javascript
function Provider(id, secret) { if (!(this instanceof Provider)) { return new Provider(id, secret); } this.client = new AWS.SQS({ accessKeyId: id, secretAccessKey: secret, region: 'us-east-1' }); this.queues = {}; }
[ "function", "Provider", "(", "id", ",", "secret", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Provider", ")", ")", "{", "return", "new", "Provider", "(", "id", ",", "secret", ")", ";", "}", "this", ".", "client", "=", "new", "AWS", ".", ...
AWS SQS provider @class Provider
[ "AWS", "SQS", "provider" ]
709bf8688b662e3ccbb67647a30bbd69066d9996
https://github.com/alantu/queues/blob/709bf8688b662e3ccbb67647a30bbd69066d9996/lib/sqs.js#L24-L36
50,809
whyhankee/oap
oap.js
checkAdd
function checkAdd(list, key, func) { list.push({key: key, func: func}); }
javascript
function checkAdd(list, key, func) { list.push({key: key, func: func}); }
[ "function", "checkAdd", "(", "list", ",", "key", ",", "func", ")", "{", "list", ".", "push", "(", "{", "key", ":", "key", ",", "func", ":", "func", "}", ")", ";", "}" ]
Argument checking flow
[ "Argument", "checking", "flow" ]
668133c1fd9bc28eb7f5f66630b99611d228120e
https://github.com/whyhankee/oap/blob/668133c1fd9bc28eb7f5f66630b99611d228120e/oap.js#L113-L115
50,810
whyhankee/oap
oap.js
checksDo
function checksDo(listChecks, cb) { if (listChecks.length === 0) { return cb(); } var check = listChecks.shift(); check.func(check.key, function () { // schedule the next check setImmediate(checksDo, listChecks, cb); }); }
javascript
function checksDo(listChecks, cb) { if (listChecks.length === 0) { return cb(); } var check = listChecks.shift(); check.func(check.key, function () { // schedule the next check setImmediate(checksDo, listChecks, cb); }); }
[ "function", "checksDo", "(", "listChecks", ",", "cb", ")", "{", "if", "(", "listChecks", ".", "length", "===", "0", ")", "{", "return", "cb", "(", ")", ";", "}", "var", "check", "=", "listChecks", ".", "shift", "(", ")", ";", "check", ".", "func", ...
Do all the checks in the list
[ "Do", "all", "the", "checks", "in", "the", "list" ]
668133c1fd9bc28eb7f5f66630b99611d228120e
https://github.com/whyhankee/oap/blob/668133c1fd9bc28eb7f5f66630b99611d228120e/oap.js#L136-L146
50,811
whyhankee/oap
oap.js
checkRequired
function checkRequired(k, cb) { if (k in args) return cb(null); else return cb(buildError(k, 'argument missing')); }
javascript
function checkRequired(k, cb) { if (k in args) return cb(null); else return cb(buildError(k, 'argument missing')); }
[ "function", "checkRequired", "(", "k", ",", "cb", ")", "{", "if", "(", "k", "in", "args", ")", "return", "cb", "(", "null", ")", ";", "else", "return", "cb", "(", "buildError", "(", "k", ",", "'argument missing'", ")", ")", ";", "}" ]
The argument checking functions
[ "The", "argument", "checking", "functions" ]
668133c1fd9bc28eb7f5f66630b99611d228120e
https://github.com/whyhankee/oap/blob/668133c1fd9bc28eb7f5f66630b99611d228120e/oap.js#L151-L156
50,812
whyhankee/oap
oap.js
buildError
function buildError(k, message) { if (!Array.isArray(errors[k])) errors[k] = []; errors[k].push(message); }
javascript
function buildError(k, message) { if (!Array.isArray(errors[k])) errors[k] = []; errors[k].push(message); }
[ "function", "buildError", "(", "k", ",", "message", ")", "{", "if", "(", "!", "Array", ".", "isArray", "(", "errors", "[", "k", "]", ")", ")", "errors", "[", "k", "]", "=", "[", "]", ";", "errors", "[", "k", "]", ".", "push", "(", "message", ...
Add's error to the errors object;
[ "Add", "s", "error", "to", "the", "errors", "object", ";" ]
668133c1fd9bc28eb7f5f66630b99611d228120e
https://github.com/whyhankee/oap/blob/668133c1fd9bc28eb7f5f66630b99611d228120e/oap.js#L195-L198
50,813
wzr1337/grunt-closure-linter
tasks/lib/common.js
function(options, opt_fileList, opt_dirList) { var cmd = ''; // Detect if the tool file is a python script. If so we need to // prefix the exec command with 'python'. if (stringEndsWith(options.toolFile, '.py')) { cmd += 'python '; } // Normalize the folder path and join the tool file. cmd += path.join(path.resolve(options.closureLinterPath), options.toolFile) + ' '; // Set command flags cmd += (options.strict) ? '--strict ' : ''; cmd += (options.maxLineLength) ? '--max_line_length ' + options.maxLineLength + ' ' : ''; // Finally add files to be linted if (opt_dirList && opt_dirList.length > 0) { cmd += opt_dirList.map(function(value) {return '-r ' + value;}).join(' ') + ' '; } if (opt_fileList && opt_fileList.length > 0) { cmd += opt_fileList.join(' '); } return cmd; }
javascript
function(options, opt_fileList, opt_dirList) { var cmd = ''; // Detect if the tool file is a python script. If so we need to // prefix the exec command with 'python'. if (stringEndsWith(options.toolFile, '.py')) { cmd += 'python '; } // Normalize the folder path and join the tool file. cmd += path.join(path.resolve(options.closureLinterPath), options.toolFile) + ' '; // Set command flags cmd += (options.strict) ? '--strict ' : ''; cmd += (options.maxLineLength) ? '--max_line_length ' + options.maxLineLength + ' ' : ''; // Finally add files to be linted if (opt_dirList && opt_dirList.length > 0) { cmd += opt_dirList.map(function(value) {return '-r ' + value;}).join(' ') + ' '; } if (opt_fileList && opt_fileList.length > 0) { cmd += opt_fileList.join(' '); } return cmd; }
[ "function", "(", "options", ",", "opt_fileList", ",", "opt_dirList", ")", "{", "var", "cmd", "=", "''", ";", "// Detect if the tool file is a python script. If so we need to", "// prefix the exec command with 'python'.", "if", "(", "stringEndsWith", "(", "options", ".", "...
Create the linter command. @param {object} options Grunt options. @param {array=} opt_fileList List of source files to be linted. @param {array=} opt_dirList List of directories to be linted.
[ "Create", "the", "linter", "command", "." ]
c4ee930d6d384c2d25207bbe1ca01c852d5e092e
https://github.com/wzr1337/grunt-closure-linter/blob/c4ee930d6d384c2d25207bbe1ca01c852d5e092e/tasks/lib/common.js#L38-L65
50,814
wzr1337/grunt-closure-linter
tasks/lib/common.js
function(results, filePath) { var destDir = path.dirname(filePath); if (!grunt.file.exists(destDir)) { grunt.file.mkdir(destDir); } grunt.file.write(filePath, results); grunt.log.ok('File "' + filePath + '" created.'); }
javascript
function(results, filePath) { var destDir = path.dirname(filePath); if (!grunt.file.exists(destDir)) { grunt.file.mkdir(destDir); } grunt.file.write(filePath, results); grunt.log.ok('File "' + filePath + '" created.'); }
[ "function", "(", "results", ",", "filePath", ")", "{", "var", "destDir", "=", "path", ".", "dirname", "(", "filePath", ")", ";", "if", "(", "!", "grunt", ".", "file", ".", "exists", "(", "destDir", ")", ")", "{", "grunt", ".", "file", ".", "mkdir",...
Writes linter |results| to file. @param {!string} results Linter results as a string. @param {!string} filePath Path to the file.
[ "Writes", "linter", "|results|", "to", "file", "." ]
c4ee930d6d384c2d25207bbe1ca01c852d5e092e
https://github.com/wzr1337/grunt-closure-linter/blob/c4ee930d6d384c2d25207bbe1ca01c852d5e092e/tasks/lib/common.js#L73-L83
50,815
gethuman/pancakes-recipe
middleware/mw.app.context.js
setLanguage
function setLanguage(req) { var host = req.info.host; // hack fix for m.reviews, m.fr, m.es, etc. if (host.substring(0, 2) === 'm.') { req.app.isLegacyMobile = true; host = host.substring(2); } var subdomain = host.substring(0, 2); // either at language-based subdomain or we use english req.app.lang = (host.charAt(2) === '.' && langSubdomains.indexOf(subdomain) >= 0) ? subdomain : 'en'; }
javascript
function setLanguage(req) { var host = req.info.host; // hack fix for m.reviews, m.fr, m.es, etc. if (host.substring(0, 2) === 'm.') { req.app.isLegacyMobile = true; host = host.substring(2); } var subdomain = host.substring(0, 2); // either at language-based subdomain or we use english req.app.lang = (host.charAt(2) === '.' && langSubdomains.indexOf(subdomain) >= 0) ? subdomain : 'en'; }
[ "function", "setLanguage", "(", "req", ")", "{", "var", "host", "=", "req", ".", "info", ".", "host", ";", "// hack fix for m.reviews, m.fr, m.es, etc.", "if", "(", "host", ".", "substring", "(", "0", ",", "2", ")", "===", "'m.'", ")", "{", "req", ".", ...
Set the language depending on a couple different potential sources @param req
[ "Set", "the", "language", "depending", "on", "a", "couple", "different", "potential", "sources" ]
ea3feb8839e2edaf1b4577c052b8958953db4498
https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.app.context.js#L14-L28
50,816
gethuman/pancakes-recipe
middleware/mw.app.context.js
setAppInfo
function setAppInfo(req, domainMap) { var host = req.info.hostname; var domain; // hack fix for m.reviews, m.fr, m.es, etc. if (host.substring(0, 2) === 'm.') { req.app.isLegacyMobile = true; host = host.substring(2); } // if the host starts with the lang, then remove it if (host.indexOf(req.app.lang + '.') === 0) { host = host.substring(3); } // if the host name equals the base host then we are dealing with the default domain (ex. gethuman.com) if (host === config.baseHost) { domain = ''; } // else we need to extract the domain from the host else { var dotIdx = host.indexOf('.'); var dashIdx = host.indexOf('-'); var idx = (dashIdx > 0 && dashIdx < dotIdx) ? dashIdx : dotIdx; domain = host.substring(0, idx); } // get the app name var appName = domainMap[domain]; // if no app name found, try to use the default (else if no default, throw error) if (!appName) { if (config.webserver && config.webserver.defaultApp) { appName = config.webserver.defaultApp; } else { throw AppError.invalidRequestError('No valid domain in requested host: ' + req.info.host); } } // at this point we should have the domain and the app name so set it in the request req.app.domain = domain; req.app.name = appName; }
javascript
function setAppInfo(req, domainMap) { var host = req.info.hostname; var domain; // hack fix for m.reviews, m.fr, m.es, etc. if (host.substring(0, 2) === 'm.') { req.app.isLegacyMobile = true; host = host.substring(2); } // if the host starts with the lang, then remove it if (host.indexOf(req.app.lang + '.') === 0) { host = host.substring(3); } // if the host name equals the base host then we are dealing with the default domain (ex. gethuman.com) if (host === config.baseHost) { domain = ''; } // else we need to extract the domain from the host else { var dotIdx = host.indexOf('.'); var dashIdx = host.indexOf('-'); var idx = (dashIdx > 0 && dashIdx < dotIdx) ? dashIdx : dotIdx; domain = host.substring(0, idx); } // get the app name var appName = domainMap[domain]; // if no app name found, try to use the default (else if no default, throw error) if (!appName) { if (config.webserver && config.webserver.defaultApp) { appName = config.webserver.defaultApp; } else { throw AppError.invalidRequestError('No valid domain in requested host: ' + req.info.host); } } // at this point we should have the domain and the app name so set it in the request req.app.domain = domain; req.app.name = appName; }
[ "function", "setAppInfo", "(", "req", ",", "domainMap", ")", "{", "var", "host", "=", "req", ".", "info", ".", "hostname", ";", "var", "domain", ";", "// hack fix for m.reviews, m.fr, m.es, etc.", "if", "(", "host", ".", "substring", "(", "0", ",", "2", ")...
Set the app domain and name @param req @param domainMap Key is subdomain value, value is the name of the app
[ "Set", "the", "app", "domain", "and", "name" ]
ea3feb8839e2edaf1b4577c052b8958953db4498
https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.app.context.js#L35-L78
50,817
gethuman/pancakes-recipe
middleware/mw.app.context.js
setContext
function setContext(req) { var session = cls.getNamespace('appSession'); var appName = req.app.name; if (session && session.active) { session.set('app', appName); session.set('lang', req.app.lang); session.set('url', routeHelper.getBaseUrl(appName) + req.url.path); } }
javascript
function setContext(req) { var session = cls.getNamespace('appSession'); var appName = req.app.name; if (session && session.active) { session.set('app', appName); session.set('lang', req.app.lang); session.set('url', routeHelper.getBaseUrl(appName) + req.url.path); } }
[ "function", "setContext", "(", "req", ")", "{", "var", "session", "=", "cls", ".", "getNamespace", "(", "'appSession'", ")", ";", "var", "appName", "=", "req", ".", "app", ".", "name", ";", "if", "(", "session", "&&", "session", ".", "active", ")", "...
Set the context into CLS for later usage @param req
[ "Set", "the", "context", "into", "CLS", "for", "later", "usage" ]
ea3feb8839e2edaf1b4577c052b8958953db4498
https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.app.context.js#L84-L93
50,818
gethuman/pancakes-recipe
middleware/mw.app.context.js
getDomainMap
function getDomainMap() { var domainMap = { 'www': 'www' }; // temp hack for mobile redirect stuff (remove later) _.each(appConfigs, function (appConfig, appName) { var domain = appConfig.domain || appName; // by default domain is the app name domainMap[domain] = appName; }); return domainMap; }
javascript
function getDomainMap() { var domainMap = { 'www': 'www' }; // temp hack for mobile redirect stuff (remove later) _.each(appConfigs, function (appConfig, appName) { var domain = appConfig.domain || appName; // by default domain is the app name domainMap[domain] = appName; }); return domainMap; }
[ "function", "getDomainMap", "(", ")", "{", "var", "domainMap", "=", "{", "'www'", ":", "'www'", "}", ";", "// temp hack for mobile redirect stuff (remove later)", "_", ".", "each", "(", "appConfigs", ",", "function", "(", "appConfig", ",", "appName", ")", "{", ...
Get the domain map by inspecting the app files @returns {{}}
[ "Get", "the", "domain", "map", "by", "inspecting", "the", "app", "files" ]
ea3feb8839e2edaf1b4577c052b8958953db4498
https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.app.context.js#L99-L107
50,819
gethuman/pancakes-recipe
middleware/mw.app.context.js
init
function init(ctx) { var domainMap = getDomainMap(); // for each request we need to set the proper context ctx.server.ext('onRequest', function (req, reply) { setLanguage(req); setAppInfo(req, domainMap); var appName = req.app.name; var lang = req.app.lang; if (req.app.isLegacyMobile || appName === 'www' || req.app.domain === 'contact') { appName = appName === 'www' ? 'contact' : appName; reply.redirect(routeHelper.getBaseUrl(appName, lang) + req.url.path).permanent(true); return; } setContext(req); reply.continue(); }); return new Q(ctx); }
javascript
function init(ctx) { var domainMap = getDomainMap(); // for each request we need to set the proper context ctx.server.ext('onRequest', function (req, reply) { setLanguage(req); setAppInfo(req, domainMap); var appName = req.app.name; var lang = req.app.lang; if (req.app.isLegacyMobile || appName === 'www' || req.app.domain === 'contact') { appName = appName === 'www' ? 'contact' : appName; reply.redirect(routeHelper.getBaseUrl(appName, lang) + req.url.path).permanent(true); return; } setContext(req); reply.continue(); }); return new Q(ctx); }
[ "function", "init", "(", "ctx", ")", "{", "var", "domainMap", "=", "getDomainMap", "(", ")", ";", "// for each request we need to set the proper context", "ctx", ".", "server", ".", "ext", "(", "'onRequest'", ",", "function", "(", "req", ",", "reply", ")", "{"...
Figure out the language and target app @param ctx @returns {Q}
[ "Figure", "out", "the", "language", "and", "target", "app" ]
ea3feb8839e2edaf1b4577c052b8958953db4498
https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.app.context.js#L114-L135
50,820
appsngen/generator-appsngen-web-widget
app/index.js
function (directoryNames) { var i, directoryName; for (i = 0; i < directoryNames.length; i++) { directoryName = directoryNames[i]; mkdirp.sync(directoryName); // make output similar to yeoman's console.log(' ' + chalk.green('create') + ' ' + directoryName.replace('/', '\\') + '\\'); } }
javascript
function (directoryNames) { var i, directoryName; for (i = 0; i < directoryNames.length; i++) { directoryName = directoryNames[i]; mkdirp.sync(directoryName); // make output similar to yeoman's console.log(' ' + chalk.green('create') + ' ' + directoryName.replace('/', '\\') + '\\'); } }
[ "function", "(", "directoryNames", ")", "{", "var", "i", ",", "directoryName", ";", "for", "(", "i", "=", "0", ";", "i", "<", "directoryNames", ".", "length", ";", "i", "++", ")", "{", "directoryName", "=", "directoryNames", "[", "i", "]", ";", "mkdi...
copyFiles doesn't create empty folders so we need to create them manually
[ "copyFiles", "doesn", "t", "create", "empty", "folders", "so", "we", "need", "to", "create", "them", "manually" ]
f10e55bcf6742abf7a555294385070f25be467c8
https://github.com/appsngen/generator-appsngen-web-widget/blob/f10e55bcf6742abf7a555294385070f25be467c8/app/index.js#L42-L52
50,821
cemtopkaya/kuark-db
src/db_ihale.js
f_teklif_tumu
function f_teklif_tumu(_tahta_id, _ihale_id, _arama) { return f_teklif_idleri(_tahta_id, _ihale_id, _arama.Sayfalama) .then( /** * * @param {string[]} _teklif_idler * @returns {*} */ function (_teklif_idler) { var sonucAnahtari = result.kp.temp.ssetTahtaIhaleTeklifleri(_tahta_id, _ihale_id), /** @type {LazyLoadingResponse} */ sonuc = schema.f_create_default_object(schema.SCHEMA.LAZY_LOADING_RESPONSE); if (_teklif_idler && _teklif_idler.length > 0) { return result.dbQ.scard(sonucAnahtari) .then(function (_toplamKayitSayisi) { sonuc.ToplamKayitSayisi = parseInt(_toplamKayitSayisi); var db_teklif = require('./db_teklif'); var opts = db_teklif.OptionsTeklif({ bArrUrunler: true, bKalemBilgisi: true, bIhaleBilgisi: true, bKurumBilgisi: true, optUrun: {} }); return db_teklif.f_db_teklif_id(_teklif_idler, _tahta_id, opts) .then(function (_dbTeklifler) { //göndermeden önce sıralıyoruz var teklifler = _.sortBy(_dbTeklifler, ['Kalem_Id', 'TeklifDurumu_Id']); sonuc.Data = teklifler; return sonuc; }); }); } else { //teklif yok sonuc.ToplamKayitSayisi = 0; sonuc.Data = []; return sonuc; } }); }
javascript
function f_teklif_tumu(_tahta_id, _ihale_id, _arama) { return f_teklif_idleri(_tahta_id, _ihale_id, _arama.Sayfalama) .then( /** * * @param {string[]} _teklif_idler * @returns {*} */ function (_teklif_idler) { var sonucAnahtari = result.kp.temp.ssetTahtaIhaleTeklifleri(_tahta_id, _ihale_id), /** @type {LazyLoadingResponse} */ sonuc = schema.f_create_default_object(schema.SCHEMA.LAZY_LOADING_RESPONSE); if (_teklif_idler && _teklif_idler.length > 0) { return result.dbQ.scard(sonucAnahtari) .then(function (_toplamKayitSayisi) { sonuc.ToplamKayitSayisi = parseInt(_toplamKayitSayisi); var db_teklif = require('./db_teklif'); var opts = db_teklif.OptionsTeklif({ bArrUrunler: true, bKalemBilgisi: true, bIhaleBilgisi: true, bKurumBilgisi: true, optUrun: {} }); return db_teklif.f_db_teklif_id(_teklif_idler, _tahta_id, opts) .then(function (_dbTeklifler) { //göndermeden önce sıralıyoruz var teklifler = _.sortBy(_dbTeklifler, ['Kalem_Id', 'TeklifDurumu_Id']); sonuc.Data = teklifler; return sonuc; }); }); } else { //teklif yok sonuc.ToplamKayitSayisi = 0; sonuc.Data = []; return sonuc; } }); }
[ "function", "f_teklif_tumu", "(", "_tahta_id", ",", "_ihale_id", ",", "_arama", ")", "{", "return", "f_teklif_idleri", "(", "_tahta_id", ",", "_ihale_id", ",", "_arama", ".", "Sayfalama", ")", ".", "then", "(", "/**\r\n *\r\n * @param {...
ihaleye ait teklifleri bulur @param {integer} _tahta_id @param {integer} _ihale_id @param {URLQuery} _arama @returns {Promise}
[ "ihaleye", "ait", "teklifleri", "bulur" ]
d584aaf51f65a013bec79220a05007bd70767ac2
https://github.com/cemtopkaya/kuark-db/blob/d584aaf51f65a013bec79220a05007bd70767ac2/src/db_ihale.js#L270-L314
50,822
redisjs/jsr-conf
lib/encoder.js
Encoder
function Encoder(options) { Transform.call(this); this._writableState.objectMode = true; this._readableState.objectMode = false; this.eol = options.eol; }
javascript
function Encoder(options) { Transform.call(this); this._writableState.objectMode = true; this._readableState.objectMode = false; this.eol = options.eol; }
[ "function", "Encoder", "(", "options", ")", "{", "Transform", ".", "call", "(", "this", ")", ";", "this", ".", "_writableState", ".", "objectMode", "=", "true", ";", "this", ".", "_readableState", ".", "objectMode", "=", "false", ";", "this", ".", "eol",...
Configuration file encoder.
[ "Configuration", "file", "encoder", "." ]
97c5e2e77e1601c879a62dfc2d500df537eaaddd
https://github.com/redisjs/jsr-conf/blob/97c5e2e77e1601c879a62dfc2d500df537eaaddd/lib/encoder.js#L7-L14
50,823
SoftwarePlumbers/abstract-query
src/range.js
isComparable
function isComparable(object) { let type = typeof object; if (type === 'number' || type === 'string' || type == 'boolean') return true; if (type === 'object' && object instanceof Date) return true; return false; }
javascript
function isComparable(object) { let type = typeof object; if (type === 'number' || type === 'string' || type == 'boolean') return true; if (type === 'object' && object instanceof Date) return true; return false; }
[ "function", "isComparable", "(", "object", ")", "{", "let", "type", "=", "typeof", "object", ";", "if", "(", "type", "===", "'number'", "||", "type", "===", "'string'", "||", "type", "==", "'boolean'", ")", "return", "true", ";", "if", "(", "type", "==...
Types on which comparison operators are valid. @typedef {number|string|boolean|Date} Comparable Return true if object is one of the comparable types @param object - object to test @returns true if object is comparable (@see Comparable)
[ "Types", "on", "which", "comparison", "operators", "are", "valid", "." ]
b67f40cf20f392d7eb00bca31aedec58de55ceff
https://github.com/SoftwarePlumbers/abstract-query/blob/b67f40cf20f392d7eb00bca31aedec58de55ceff/src/range.js#L27-L32
50,824
gethuman/pancakes-recipe
utils/casing.js
dashCase
function dashCase(str) { var newStr = ''; for (var i = 0, len = str.length; i < len; i++) { if (str[i] === str[i].toUpperCase()) { newStr += '-'; } newStr += str[i].toLowerCase(); } return newStr; }
javascript
function dashCase(str) { var newStr = ''; for (var i = 0, len = str.length; i < len; i++) { if (str[i] === str[i].toUpperCase()) { newStr += '-'; } newStr += str[i].toLowerCase(); } return newStr; }
[ "function", "dashCase", "(", "str", ")", "{", "var", "newStr", "=", "''", ";", "for", "(", "var", "i", "=", "0", ",", "len", "=", "str", ".", "length", ";", "i", "<", "len", ";", "i", "++", ")", "{", "if", "(", "str", "[", "i", "]", "===", ...
Convert a camelCase string into dash case @param str
[ "Convert", "a", "camelCase", "string", "into", "dash", "case" ]
ea3feb8839e2edaf1b4577c052b8958953db4498
https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/utils/casing.js#L41-L50
50,825
SoftwarePlumbers/db-plumbing-map
store.js
defaultComparator
function defaultComparator(key, a, b) { if (key(a) < key(b)) return -1; if (key(a) > key(b)) return 1; return 0; }
javascript
function defaultComparator(key, a, b) { if (key(a) < key(b)) return -1; if (key(a) > key(b)) return 1; return 0; }
[ "function", "defaultComparator", "(", "key", ",", "a", ",", "b", ")", "{", "if", "(", "key", "(", "a", ")", "<", "key", "(", "b", ")", ")", "return", "-", "1", ";", "if", "(", "key", "(", "a", ")", ">", "key", "(", "b", ")", ")", "return", ...
Default comparison operation. @param key {Function} function that extracts a key value (number or string) from a stored object @param a {Object} First object @param b {Object} Second object @returns {boolean} -1, 1, 0 depending on whether a < b, b < a, or a == b
[ "Default", "comparison", "operation", "." ]
fef5f4db895ccd2817b8ba9179b18b0252b8b0a6
https://github.com/SoftwarePlumbers/db-plumbing-map/blob/fef5f4db895ccd2817b8ba9179b18b0252b8b0a6/store.js#L18-L22
50,826
nearform/docker-container
lib/localExecutor.js
function(mode, targetHost, system, containerDef, container, out, cb) { if (container.specific && container.specific.dockerContainerId) { var stopCmd = commands.kill.replace('__TARGETID__', container.specific.dockerContainerId); executor.exec(mode, stopCmd, config.imageCachePath, out, function(err) { out.preview({cmd: stopCmd, host: 'localhost'}); if (err && err.code !== 2) { cb(err); } else { cb(); } }); } else { cb(); } }
javascript
function(mode, targetHost, system, containerDef, container, out, cb) { if (container.specific && container.specific.dockerContainerId) { var stopCmd = commands.kill.replace('__TARGETID__', container.specific.dockerContainerId); executor.exec(mode, stopCmd, config.imageCachePath, out, function(err) { out.preview({cmd: stopCmd, host: 'localhost'}); if (err && err.code !== 2) { cb(err); } else { cb(); } }); } else { cb(); } }
[ "function", "(", "mode", ",", "targetHost", ",", "system", ",", "containerDef", ",", "container", ",", "out", ",", "cb", ")", "{", "if", "(", "container", ".", "specific", "&&", "container", ".", "specific", ".", "dockerContainerId", ")", "{", "var", "st...
stop needs to
[ "stop", "needs", "to" ]
724ff6a9d8d3c116f9a6b8239594c4b5cd5e8e17
https://github.com/nearform/docker-container/blob/724ff6a9d8d3c116f9a6b8239594c4b5cd5e8e17/lib/localExecutor.js#L106-L117
50,827
nearform/docker-container
lib/localExecutor.js
function(mode, targetHost, system, containerDef, container, out, newConfig, cb) { if (container.specific && container.specific.dockerContainerId && container.specific.configPath && container.specific.hup) { tmp.file(function(err, path) { if (err) { return cb(err); } fs.writeFile(path, newConfig, 'utf8', function(err) { if (err) { return cb(err); } var copyCmd = commands.generateCopyCommand(container.specific.dockerContainerId, container.specific.configPath, path); var hupCmd = commands.generateHupCommand(container); executor.exec(mode, copyCmd, config.imageCachePath, out, function(err) { if (err) { return cb(err); } executor.exec(mode, hupCmd, config.imageCachePath, out, function(err) { cb(err); }); }); }); }); } else { cb(); } }
javascript
function(mode, targetHost, system, containerDef, container, out, newConfig, cb) { if (container.specific && container.specific.dockerContainerId && container.specific.configPath && container.specific.hup) { tmp.file(function(err, path) { if (err) { return cb(err); } fs.writeFile(path, newConfig, 'utf8', function(err) { if (err) { return cb(err); } var copyCmd = commands.generateCopyCommand(container.specific.dockerContainerId, container.specific.configPath, path); var hupCmd = commands.generateHupCommand(container); executor.exec(mode, copyCmd, config.imageCachePath, out, function(err) { if (err) { return cb(err); } executor.exec(mode, hupCmd, config.imageCachePath, out, function(err) { cb(err); }); }); }); }); } else { cb(); } }
[ "function", "(", "mode", ",", "targetHost", ",", "system", ",", "containerDef", ",", "container", ",", "out", ",", "newConfig", ",", "cb", ")", "{", "if", "(", "container", ".", "specific", "&&", "container", ".", "specific", ".", "dockerContainerId", "&&"...
provide a new config and hup the container internal daemon
[ "provide", "a", "new", "config", "and", "hup", "the", "container", "internal", "daemon" ]
724ff6a9d8d3c116f9a6b8239594c4b5cd5e8e17
https://github.com/nearform/docker-container/blob/724ff6a9d8d3c116f9a6b8239594c4b5cd5e8e17/lib/localExecutor.js#L133-L157
50,828
samplx/samplx-agentdb
utils/check-status.js
addInsert
function addInsert(agent) { /* `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, `userAgent` VARCHAR(255) NOT NULL, `agentGroup_id` INT UNSIGNED NOT NULL DEFAULT '1', `agentSource_id` INT UNSIGNED NOT NULL DEFAULT '1', `timesReported` INT UNSIGNED NOT NULL DEFAULT '1', `status` TINYINT UNSIGNED NOT NULL DEFAULT '0', `description` TEXT, `created` DATETIME NULL, `modified` DATETIME NULL, */ console.log("INSERT INTO `Agents` VALUES (NULL, '" + quote(agent.agent) + "', '" + agent.groupId + "', '" + agent.sourceId + "', '0', '0', '', NOW(), NOW());"); }
javascript
function addInsert(agent) { /* `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, `userAgent` VARCHAR(255) NOT NULL, `agentGroup_id` INT UNSIGNED NOT NULL DEFAULT '1', `agentSource_id` INT UNSIGNED NOT NULL DEFAULT '1', `timesReported` INT UNSIGNED NOT NULL DEFAULT '1', `status` TINYINT UNSIGNED NOT NULL DEFAULT '0', `description` TEXT, `created` DATETIME NULL, `modified` DATETIME NULL, */ console.log("INSERT INTO `Agents` VALUES (NULL, '" + quote(agent.agent) + "', '" + agent.groupId + "', '" + agent.sourceId + "', '0', '0', '', NOW(), NOW());"); }
[ "function", "addInsert", "(", "agent", ")", "{", "/*\n `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,\n `userAgent` VARCHAR(255) NOT NULL,\n `agentGroup_id` INT UNSIGNED NOT NULL DEFAULT '1',\n `agentSource_id` INT UNSIGNED NOT NULL DEFAULT '1',\n `timesReported` INT UNSIGNED NOT ...
create an INSERT statement to add a user-agent. This is normally not needed since the agents.json file comes from the database to which the data would be inserted.
[ "create", "an", "INSERT", "statement", "to", "add", "a", "user", "-", "agent", ".", "This", "is", "normally", "not", "needed", "since", "the", "agents", ".", "json", "file", "comes", "from", "the", "database", "to", "which", "the", "data", "would", "be",...
4ded3176c8a9dceb3f2017f66581929d3cfc1084
https://github.com/samplx/samplx-agentdb/blob/4ded3176c8a9dceb3f2017f66581929d3cfc1084/utils/check-status.js#L54-L71
50,829
samplx/samplx-agentdb
utils/check-status.js
updateAgent
function updateAgent(id, group, source, status) { var groupId = groups.indexOf(group); if (groupId <= 0) { console.error("ERROR: group='" + group + "' was not found."); return; } var sourceId = sources.indexOf(source); if (sourceId <= 0) { console.error("ERROR: source='" + source + "' was not found."); return; } console.log("UPDATE `Agents` SET `status`='" + status + "', " + "`agentGroup_id`='" + groupId + "', " + "`agentSource_id`='" + sourceId + "' WHERE " + "`id`='" + id + "';"); }
javascript
function updateAgent(id, group, source, status) { var groupId = groups.indexOf(group); if (groupId <= 0) { console.error("ERROR: group='" + group + "' was not found."); return; } var sourceId = sources.indexOf(source); if (sourceId <= 0) { console.error("ERROR: source='" + source + "' was not found."); return; } console.log("UPDATE `Agents` SET `status`='" + status + "', " + "`agentGroup_id`='" + groupId + "', " + "`agentSource_id`='" + sourceId + "' WHERE " + "`id`='" + id + "';"); }
[ "function", "updateAgent", "(", "id", ",", "group", ",", "source", ",", "status", ")", "{", "var", "groupId", "=", "groups", ".", "indexOf", "(", "group", ")", ";", "if", "(", "groupId", "<=", "0", ")", "{", "console", ".", "error", "(", "\"ERROR: gr...
create an UPDATE statement to set Agent status, groupId and sourceId. @param id Agent.id @param group string. @param source string.
[ "create", "an", "UPDATE", "statement", "to", "set", "Agent", "status", "groupId", "and", "sourceId", "." ]
4ded3176c8a9dceb3f2017f66581929d3cfc1084
https://github.com/samplx/samplx-agentdb/blob/4ded3176c8a9dceb3f2017f66581929d3cfc1084/utils/check-status.js#L90-L105
50,830
samplx/samplx-agentdb
utils/check-status.js
main
function main() { agents.forEach(function (agent) { var r = agentdb.lookupPattern(agent.agent); if (r !== null) { if (agent.groupId == 1) { // Unknown group -> update agent updateAgent(agent.id, r.group, r.source, 2); } else if (agent.status != 1) { if (r.group == agent.group) { if ((agent.source == 'Unknown') && (r.source != 'Unknown')) { // Unknown source -> update agent updateAgent(agent.id, r.group, r.source, 2); } else if ((agent.source == r.source) && (agent.status != 2)) { // 2 is good updateStatus(agent.id, 2); } else if ((agent.source != r.source) && (agent.status != 3)) { // must include exact. updateStatus(agent.id, 1); } } else if (agent.status != 3) { // need to include exact. updateStatus(agent.id, 1); } } else if ((r.group == agent.group) && (r.source == agent.source)) { // can use pattern updateStatus(agent.id, 2); } } else { r = agentdb.lookupHash(agent.agent); if (r !== null) { if ((r.group != agent.group) || (r.source != agent.source)) { if (debug) { console.error("ERROR: lookup did not match: " + agent.agent); } if (debug) { console.error(" lookup.group=" + r.group+", expected="+agent.group+", lookup.source=" + r.source + ", expected="+agent.source); } } else if ((agent.status != 1) && (agent.status != 3)) { updateStatus(agent.id, 1); } } else { if ((agent.status < 3) && ((agent.group != "Unknown") || (agent.source != "Unknown"))) { if (debug) { console.error("ERROR: missing:" + agent.agent); } notfound.push(agent); } } } }); if (notfound.length > 0) { console.error("Warning: user-agents were not found: " + notfound.length); if (createMissing) { notfound.forEach(function (agent) { addInsert(agent); }); } } }
javascript
function main() { agents.forEach(function (agent) { var r = agentdb.lookupPattern(agent.agent); if (r !== null) { if (agent.groupId == 1) { // Unknown group -> update agent updateAgent(agent.id, r.group, r.source, 2); } else if (agent.status != 1) { if (r.group == agent.group) { if ((agent.source == 'Unknown') && (r.source != 'Unknown')) { // Unknown source -> update agent updateAgent(agent.id, r.group, r.source, 2); } else if ((agent.source == r.source) && (agent.status != 2)) { // 2 is good updateStatus(agent.id, 2); } else if ((agent.source != r.source) && (agent.status != 3)) { // must include exact. updateStatus(agent.id, 1); } } else if (agent.status != 3) { // need to include exact. updateStatus(agent.id, 1); } } else if ((r.group == agent.group) && (r.source == agent.source)) { // can use pattern updateStatus(agent.id, 2); } } else { r = agentdb.lookupHash(agent.agent); if (r !== null) { if ((r.group != agent.group) || (r.source != agent.source)) { if (debug) { console.error("ERROR: lookup did not match: " + agent.agent); } if (debug) { console.error(" lookup.group=" + r.group+", expected="+agent.group+", lookup.source=" + r.source + ", expected="+agent.source); } } else if ((agent.status != 1) && (agent.status != 3)) { updateStatus(agent.id, 1); } } else { if ((agent.status < 3) && ((agent.group != "Unknown") || (agent.source != "Unknown"))) { if (debug) { console.error("ERROR: missing:" + agent.agent); } notfound.push(agent); } } } }); if (notfound.length > 0) { console.error("Warning: user-agents were not found: " + notfound.length); if (createMissing) { notfound.forEach(function (agent) { addInsert(agent); }); } } }
[ "function", "main", "(", ")", "{", "agents", ".", "forEach", "(", "function", "(", "agent", ")", "{", "var", "r", "=", "agentdb", ".", "lookupPattern", "(", "agent", ".", "agent", ")", ";", "if", "(", "r", "!==", "null", ")", "{", "if", "(", "age...
check-status main function.
[ "check", "-", "status", "main", "function", "." ]
4ded3176c8a9dceb3f2017f66581929d3cfc1084
https://github.com/samplx/samplx-agentdb/blob/4ded3176c8a9dceb3f2017f66581929d3cfc1084/utils/check-status.js#L110-L158
50,831
kimvin/hny-gulp-htmlcs
src/index.js
onStreamEnd
function onStreamEnd(done) { Promise .all(lintPromiseList) .then(passLintResultsThroughReporters) .then(lintResults => { process.nextTick(() => { const errorCount = lintResults.reduce((sum, res) => { const errors = res.results[0].warnings.filter(isErrorSeverity); return sum + errors.length; }, 0); if (pluginOptions.failAfterError && errorCount > 0) { const errorMessage = `Failed with ${errorCount} ${errorCount === 1 ? 'error' : 'errors'}`; this.emit('error', new PluginError(pluginName, errorMessage)); } done(); }); }) .catch(error => { process.nextTick(() => { this.emit('error', new PluginError(pluginName, error, { showStack: Boolean(pluginOptions.debug) })); done(); }); }); }
javascript
function onStreamEnd(done) { Promise .all(lintPromiseList) .then(passLintResultsThroughReporters) .then(lintResults => { process.nextTick(() => { const errorCount = lintResults.reduce((sum, res) => { const errors = res.results[0].warnings.filter(isErrorSeverity); return sum + errors.length; }, 0); if (pluginOptions.failAfterError && errorCount > 0) { const errorMessage = `Failed with ${errorCount} ${errorCount === 1 ? 'error' : 'errors'}`; this.emit('error', new PluginError(pluginName, errorMessage)); } done(); }); }) .catch(error => { process.nextTick(() => { this.emit('error', new PluginError(pluginName, error, { showStack: Boolean(pluginOptions.debug) })); done(); }); }); }
[ "function", "onStreamEnd", "(", "done", ")", "{", "Promise", ".", "all", "(", "lintPromiseList", ")", ".", "then", "(", "passLintResultsThroughReporters", ")", ".", "then", "(", "lintResults", "=>", "{", "process", ".", "nextTick", "(", "(", ")", "=>", "{"...
Resolves promises and provides accumulated report to reporters. @param {Function} done - Stream completion callback. @return {undefined} Nothing is returned (done callback is used instead).
[ "Resolves", "promises", "and", "provides", "accumulated", "report", "to", "reporters", "." ]
c7dd41dc4e6f572a8adf995f0e07ea9fc367c8dc
https://github.com/kimvin/hny-gulp-htmlcs/blob/c7dd41dc4e6f572a8adf995f0e07ea9fc367c8dc/src/index.js#L178-L203
50,832
MakerCollider/node-red-contrib-smartnode-hook
html/scripts/highchart/modules/heatmap.src.js
function (userOptions) { Axis.prototype.setOptions.call(this, userOptions); this.options.crosshair = this.options.marker; this.coll = 'colorAxis'; }
javascript
function (userOptions) { Axis.prototype.setOptions.call(this, userOptions); this.options.crosshair = this.options.marker; this.coll = 'colorAxis'; }
[ "function", "(", "userOptions", ")", "{", "Axis", ".", "prototype", ".", "setOptions", ".", "call", "(", "this", ",", "userOptions", ")", ";", "this", ".", "options", ".", "crosshair", "=", "this", ".", "options", ".", "marker", ";", "this", ".", "coll...
Extend the setOptions method to process extreme colors and color stops.
[ "Extend", "the", "setOptions", "method", "to", "process", "extreme", "colors", "and", "color", "stops", "." ]
245c267e832968bad880ca009929043e82c7bc25
https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/heatmap.src.js#L175-L180
50,833
MakerCollider/node-red-contrib-smartnode-hook
html/scripts/highchart/modules/heatmap.src.js
function (value, point) { var pos, stops = this.stops, from, to, color, dataClasses = this.dataClasses, dataClass, i; if (dataClasses) { i = dataClasses.length; while (i--) { dataClass = dataClasses[i]; from = dataClass.from; to = dataClass.to; if ((from === UNDEFINED || value >= from) && (to === UNDEFINED || value <= to)) { color = dataClass.color; if (point) { point.dataClass = i; } break; } } } else { if (this.isLog) { value = this.val2lin(value); } pos = 1 - ((this.max - value) / ((this.max - this.min) || 1)); i = stops.length; while (i--) { if (pos > stops[i][0]) { break; } } from = stops[i] || stops[i + 1]; to = stops[i + 1] || from; // The position within the gradient pos = 1 - (to[0] - pos) / ((to[0] - from[0]) || 1); color = this.tweenColors( from.color, to.color, pos ); } return color; }
javascript
function (value, point) { var pos, stops = this.stops, from, to, color, dataClasses = this.dataClasses, dataClass, i; if (dataClasses) { i = dataClasses.length; while (i--) { dataClass = dataClasses[i]; from = dataClass.from; to = dataClass.to; if ((from === UNDEFINED || value >= from) && (to === UNDEFINED || value <= to)) { color = dataClass.color; if (point) { point.dataClass = i; } break; } } } else { if (this.isLog) { value = this.val2lin(value); } pos = 1 - ((this.max - value) / ((this.max - this.min) || 1)); i = stops.length; while (i--) { if (pos > stops[i][0]) { break; } } from = stops[i] || stops[i + 1]; to = stops[i + 1] || from; // The position within the gradient pos = 1 - (to[0] - pos) / ((to[0] - from[0]) || 1); color = this.tweenColors( from.color, to.color, pos ); } return color; }
[ "function", "(", "value", ",", "point", ")", "{", "var", "pos", ",", "stops", "=", "this", ".", "stops", ",", "from", ",", "to", ",", "color", ",", "dataClasses", "=", "this", ".", "dataClasses", ",", "dataClass", ",", "i", ";", "if", "(", "dataCla...
Translate from a value to a color
[ "Translate", "from", "a", "value", "to", "a", "color" ]
245c267e832968bad880ca009929043e82c7bc25
https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/heatmap.src.js#L206-L256
50,834
MakerCollider/node-red-contrib-smartnode-hook
html/scripts/highchart/modules/heatmap.src.js
function () { var grad, horiz = this.horiz, options = this.options, reversed = this.reversed; grad = horiz ? [+reversed, 0, +!reversed, 0] : [0, +!reversed, 0, +reversed]; // #3190 this.legendColor = { linearGradient: { x1: grad[0], y1: grad[1], x2: grad[2], y2: grad[3] }, stops: options.stops || [ [0, options.minColor], [1, options.maxColor] ] }; }
javascript
function () { var grad, horiz = this.horiz, options = this.options, reversed = this.reversed; grad = horiz ? [+reversed, 0, +!reversed, 0] : [0, +!reversed, 0, +reversed]; // #3190 this.legendColor = { linearGradient: { x1: grad[0], y1: grad[1], x2: grad[2], y2: grad[3] }, stops: options.stops || [ [0, options.minColor], [1, options.maxColor] ] }; }
[ "function", "(", ")", "{", "var", "grad", ",", "horiz", "=", "this", ".", "horiz", ",", "options", "=", "this", ".", "options", ",", "reversed", "=", "this", ".", "reversed", ";", "grad", "=", "horiz", "?", "[", "+", "reversed", ",", "0", ",", "+...
Create the color gradient
[ "Create", "the", "color", "gradient" ]
245c267e832968bad880ca009929043e82c7bc25
https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/heatmap.src.js#L286-L300
50,835
MakerCollider/node-red-contrib-smartnode-hook
html/scripts/highchart/modules/heatmap.src.js
function (legend, item) { var padding = legend.padding, legendOptions = legend.options, horiz = this.horiz, box, width = pick(legendOptions.symbolWidth, horiz ? 200 : 12), height = pick(legendOptions.symbolHeight, horiz ? 12 : 200), labelPadding = pick(legendOptions.labelPadding, horiz ? 16 : 30), itemDistance = pick(legendOptions.itemDistance, 10); this.setLegendColor(); // Create the gradient item.legendSymbol = this.chart.renderer.rect( 0, legend.baseline - 11, width, height ).attr({ zIndex: 1 }).add(item.legendGroup); box = item.legendSymbol.getBBox(); // Set how much space this legend item takes up this.legendItemWidth = width + padding + (horiz ? itemDistance : labelPadding); this.legendItemHeight = height + padding + (horiz ? labelPadding : 0); }
javascript
function (legend, item) { var padding = legend.padding, legendOptions = legend.options, horiz = this.horiz, box, width = pick(legendOptions.symbolWidth, horiz ? 200 : 12), height = pick(legendOptions.symbolHeight, horiz ? 12 : 200), labelPadding = pick(legendOptions.labelPadding, horiz ? 16 : 30), itemDistance = pick(legendOptions.itemDistance, 10); this.setLegendColor(); // Create the gradient item.legendSymbol = this.chart.renderer.rect( 0, legend.baseline - 11, width, height ).attr({ zIndex: 1 }).add(item.legendGroup); box = item.legendSymbol.getBBox(); // Set how much space this legend item takes up this.legendItemWidth = width + padding + (horiz ? itemDistance : labelPadding); this.legendItemHeight = height + padding + (horiz ? labelPadding : 0); }
[ "function", "(", "legend", ",", "item", ")", "{", "var", "padding", "=", "legend", ".", "padding", ",", "legendOptions", "=", "legend", ".", "options", ",", "horiz", "=", "this", ".", "horiz", ",", "box", ",", "width", "=", "pick", "(", "legendOptions"...
The color axis appears inside the legend and has its own legend symbol
[ "The", "color", "axis", "appears", "inside", "the", "legend", "and", "has", "its", "own", "legend", "symbol" ]
245c267e832968bad880ca009929043e82c7bc25
https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/heatmap.src.js#L305-L331
50,836
MakerCollider/node-red-contrib-smartnode-hook
html/scripts/highchart/modules/heatmap.src.js
function () { var axis = this, chart = this.chart, legendItems = this.legendItems, legendOptions = chart.options.legend, valueDecimals = legendOptions.valueDecimals, valueSuffix = legendOptions.valueSuffix || '', name; if (!legendItems.length) { each(this.dataClasses, function (dataClass, i) { var vis = true, from = dataClass.from, to = dataClass.to; // Assemble the default name. This can be overridden by legend.options.labelFormatter name = ''; if (from === UNDEFINED) { name = '< '; } else if (to === UNDEFINED) { name = '> '; } if (from !== UNDEFINED) { name += Highcharts.numberFormat(from, valueDecimals) + valueSuffix; } if (from !== UNDEFINED && to !== UNDEFINED) { name += ' - '; } if (to !== UNDEFINED) { name += Highcharts.numberFormat(to, valueDecimals) + valueSuffix; } // Add a mock object to the legend items legendItems.push(extend({ chart: chart, name: name, options: {}, drawLegendSymbol: LegendSymbolMixin.drawRectangle, visible: true, setState: noop, setVisible: function () { vis = this.visible = !vis; each(axis.series, function (series) { each(series.points, function (point) { if (point.dataClass === i) { point.setVisible(vis); } }); }); chart.legend.colorizeItem(this, vis); } }, dataClass)); }); } return legendItems; }
javascript
function () { var axis = this, chart = this.chart, legendItems = this.legendItems, legendOptions = chart.options.legend, valueDecimals = legendOptions.valueDecimals, valueSuffix = legendOptions.valueSuffix || '', name; if (!legendItems.length) { each(this.dataClasses, function (dataClass, i) { var vis = true, from = dataClass.from, to = dataClass.to; // Assemble the default name. This can be overridden by legend.options.labelFormatter name = ''; if (from === UNDEFINED) { name = '< '; } else if (to === UNDEFINED) { name = '> '; } if (from !== UNDEFINED) { name += Highcharts.numberFormat(from, valueDecimals) + valueSuffix; } if (from !== UNDEFINED && to !== UNDEFINED) { name += ' - '; } if (to !== UNDEFINED) { name += Highcharts.numberFormat(to, valueDecimals) + valueSuffix; } // Add a mock object to the legend items legendItems.push(extend({ chart: chart, name: name, options: {}, drawLegendSymbol: LegendSymbolMixin.drawRectangle, visible: true, setState: noop, setVisible: function () { vis = this.visible = !vis; each(axis.series, function (series) { each(series.points, function (point) { if (point.dataClass === i) { point.setVisible(vis); } }); }); chart.legend.colorizeItem(this, vis); } }, dataClass)); }); } return legendItems; }
[ "function", "(", ")", "{", "var", "axis", "=", "this", ",", "chart", "=", "this", ".", "chart", ",", "legendItems", "=", "this", ".", "legendItems", ",", "legendOptions", "=", "chart", ".", "options", ".", "legend", ",", "valueDecimals", "=", "legendOpti...
Get the legend item symbols for data classes
[ "Get", "the", "legend", "item", "symbols", "for", "data", "classes" ]
245c267e832968bad880ca009929043e82c7bc25
https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/heatmap.src.js#L400-L456
50,837
MakerCollider/node-red-contrib-smartnode-hook
html/scripts/highchart/modules/heatmap.src.js
function () { var options; seriesTypes.scatter.prototype.init.apply(this, arguments); options = this.options; this.pointRange = options.pointRange = pick(options.pointRange, options.colsize || 1); // #3758, prevent resetting in setData this.yAxis.axisPointRange = options.rowsize || 1; // general point range }
javascript
function () { var options; seriesTypes.scatter.prototype.init.apply(this, arguments); options = this.options; this.pointRange = options.pointRange = pick(options.pointRange, options.colsize || 1); // #3758, prevent resetting in setData this.yAxis.axisPointRange = options.rowsize || 1; // general point range }
[ "function", "(", ")", "{", "var", "options", ";", "seriesTypes", ".", "scatter", ".", "prototype", ".", "init", ".", "apply", "(", "this", ",", "arguments", ")", ";", "options", "=", "this", ".", "options", ";", "this", ".", "pointRange", "=", "options...
Override the init method to add point ranges on both axes.
[ "Override", "the", "init", "method", "to", "add", "point", "ranges", "on", "both", "axes", "." ]
245c267e832968bad880ca009929043e82c7bc25
https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/heatmap.src.js#L596-L603
50,838
wacky6/grunt-fontmin
tasks/fontmin.js
taskFontmin
function taskFontmin() { // prase options let opts = this.options() let data = this.data let destdir = opts.dest || './' let basedir = opts.basedir || './' let src = grunt.file.expand(data.src) let fonts = grunt.file.expand(join(basedir, this.target)) let getText = opts.getText!==undefined ? opts.getText : (content)=>html2text.fromString(content) let type='woff', typeOpts=true // check if more than one output option is specified if ( !atMostDefined(data, 1, 'woff', 'css') ) throw new Error('Multiple output type defined!') // set type, typeOpts if (data.woff!==undefined) { type='woff' } if (data.css!==undefined) { type='css'; typeOpts=data.css } // string of unique characters(glyphs) to be included in minimized font let uniqGlyphs = src.map( path => grunt.file.read(path) ) .map( getText ) .join() .split('') .sort().reduce( nodup(), [] ) // remove duplicate characters .join('') fonts.forEach( path => { // create output ArrayBuffer let ttf = readToTTF(path) let stripped = glyphStrip(ttf, uniqGlyphs) let output = ttfToOutput(stripped, type, typeOpts) // solve dest path, write output let destPath = join(destdir, getOutputFilename(path,type)) grunt.file.write(destPath, toBuffer(output)) // output information grunt.log.writeln(basename(path)+' => '+type+' ' +chalk.green(stripped.glyf.length)+' glyphs, ' +chalk.green(output.byteLength)+' bytes') } ) }
javascript
function taskFontmin() { // prase options let opts = this.options() let data = this.data let destdir = opts.dest || './' let basedir = opts.basedir || './' let src = grunt.file.expand(data.src) let fonts = grunt.file.expand(join(basedir, this.target)) let getText = opts.getText!==undefined ? opts.getText : (content)=>html2text.fromString(content) let type='woff', typeOpts=true // check if more than one output option is specified if ( !atMostDefined(data, 1, 'woff', 'css') ) throw new Error('Multiple output type defined!') // set type, typeOpts if (data.woff!==undefined) { type='woff' } if (data.css!==undefined) { type='css'; typeOpts=data.css } // string of unique characters(glyphs) to be included in minimized font let uniqGlyphs = src.map( path => grunt.file.read(path) ) .map( getText ) .join() .split('') .sort().reduce( nodup(), [] ) // remove duplicate characters .join('') fonts.forEach( path => { // create output ArrayBuffer let ttf = readToTTF(path) let stripped = glyphStrip(ttf, uniqGlyphs) let output = ttfToOutput(stripped, type, typeOpts) // solve dest path, write output let destPath = join(destdir, getOutputFilename(path,type)) grunt.file.write(destPath, toBuffer(output)) // output information grunt.log.writeln(basename(path)+' => '+type+' ' +chalk.green(stripped.glyf.length)+' glyphs, ' +chalk.green(output.byteLength)+' bytes') } ) }
[ "function", "taskFontmin", "(", ")", "{", "// prase options", "let", "opts", "=", "this", ".", "options", "(", ")", "let", "data", "=", "this", ".", "data", "let", "destdir", "=", "opts", ".", "dest", "||", "'./'", "let", "basedir", "=", "opts", ".", ...
grunt task function
[ "grunt", "task", "function" ]
ed73e44e67326e45db86d78aa7bdef83d5acbc25
https://github.com/wacky6/grunt-fontmin/blob/ed73e44e67326e45db86d78aa7bdef83d5acbc25/tasks/fontmin.js#L19-L64
50,839
nikitadyumin/stk
src/arrays.js
extract
function extract(arr, obj) { return arr.filter(item => Object.keys(obj).every(key => item[key] === obj[key])); }
javascript
function extract(arr, obj) { return arr.filter(item => Object.keys(obj).every(key => item[key] === obj[key])); }
[ "function", "extract", "(", "arr", ",", "obj", ")", "{", "return", "arr", ".", "filter", "(", "item", "=>", "Object", ".", "keys", "(", "obj", ")", ".", "every", "(", "key", "=>", "item", "[", "key", "]", "===", "obj", "[", "key", "]", ")", ")"...
Created by ndyumin on 15.09.2016.
[ "Created", "by", "ndyumin", "on", "15", ".", "09", ".", "2016", "." ]
7bf8e3c8c042061b3c976b7a919b6b700d7b96bd
https://github.com/nikitadyumin/stk/blob/7bf8e3c8c042061b3c976b7a919b6b700d7b96bd/src/arrays.js#L4-L6
50,840
socialally/emanate
lib/event-emitter.js
once
function once(event, listener) { function g() { this.removeListener(event, g); listener.apply(this, arguments); }; this.on(event, g); return this; }
javascript
function once(event, listener) { function g() { this.removeListener(event, g); listener.apply(this, arguments); }; this.on(event, g); return this; }
[ "function", "once", "(", "event", ",", "listener", ")", "{", "function", "g", "(", ")", "{", "this", ".", "removeListener", "(", "event", ",", "g", ")", ";", "listener", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", ";", "this", ".", ...
Registers a listener to be invoked once. @param event The event name. @param listener The listener function.
[ "Registers", "a", "listener", "to", "be", "invoked", "once", "." ]
bdfcbae2d1dcb92c6354da3db07e1993258518fa
https://github.com/socialally/emanate/blob/bdfcbae2d1dcb92c6354da3db07e1993258518fa/lib/event-emitter.js#L25-L32
50,841
socialally/emanate
lib/event-emitter.js
removeListener
function removeListener(event, listener) { this._events = this._events || {}; if(event in this._events) { this._events[event].splice(this._events[event].indexOf(listener), 1); } return this; }
javascript
function removeListener(event, listener) { this._events = this._events || {}; if(event in this._events) { this._events[event].splice(this._events[event].indexOf(listener), 1); } return this; }
[ "function", "removeListener", "(", "event", ",", "listener", ")", "{", "this", ".", "_events", "=", "this", ".", "_events", "||", "{", "}", ";", "if", "(", "event", "in", "this", ".", "_events", ")", "{", "this", ".", "_events", "[", "event", "]", ...
Remove a listener for an event. @param event The event name. @param listener The event listener function.
[ "Remove", "a", "listener", "for", "an", "event", "." ]
bdfcbae2d1dcb92c6354da3db07e1993258518fa
https://github.com/socialally/emanate/blob/bdfcbae2d1dcb92c6354da3db07e1993258518fa/lib/event-emitter.js#L54-L60
50,842
socialally/emanate
lib/event-emitter.js
emit
function emit(event /* , args... */) { this._events = this._events || {}; // NOTE: copy array so that removing listeners in listeners (once etc) // NOTE: does not affect the iteration var list = (this._events[event] || []).slice(0); for(var i = 0; i < list.length; i++) { list[i].apply(this, Array.prototype.slice.call(arguments, 1)) } return list.length > 0; }
javascript
function emit(event /* , args... */) { this._events = this._events || {}; // NOTE: copy array so that removing listeners in listeners (once etc) // NOTE: does not affect the iteration var list = (this._events[event] || []).slice(0); for(var i = 0; i < list.length; i++) { list[i].apply(this, Array.prototype.slice.call(arguments, 1)) } return list.length > 0; }
[ "function", "emit", "(", "event", "/* , args... */", ")", "{", "this", ".", "_events", "=", "this", ".", "_events", "||", "{", "}", ";", "// NOTE: copy array so that removing listeners in listeners (once etc)", "// NOTE: does not affect the iteration", "var", "list", "=",...
Execute each of the listeners in order with the supplied arguments. Returns true if event had listeners, false otherwise. @param event The event name. @param args... The arguments to pass to event listeners.
[ "Execute", "each", "of", "the", "listeners", "in", "order", "with", "the", "supplied", "arguments", "." ]
bdfcbae2d1dcb92c6354da3db07e1993258518fa
https://github.com/socialally/emanate/blob/bdfcbae2d1dcb92c6354da3db07e1993258518fa/lib/event-emitter.js#L78-L87
50,843
Digznav/bilberry
promise-write-file.js
promiseWriteFile
function promiseWriteFile(targetPath, content, tabs = 2) { const fileName = targetPath.split('/').pop(); let contentHolder = content; if (targetPath.endsWith('.json')) { contentHolder = JSON.stringify(contentHolder, null, tabs); } return new Promise((resolve, reject) => { fs.writeFile(targetPath, contentHolder, err => { if (err) reject(err); resolve({ path: targetPath, fileName, content: contentHolder }); }); }); }
javascript
function promiseWriteFile(targetPath, content, tabs = 2) { const fileName = targetPath.split('/').pop(); let contentHolder = content; if (targetPath.endsWith('.json')) { contentHolder = JSON.stringify(contentHolder, null, tabs); } return new Promise((resolve, reject) => { fs.writeFile(targetPath, contentHolder, err => { if (err) reject(err); resolve({ path: targetPath, fileName, content: contentHolder }); }); }); }
[ "function", "promiseWriteFile", "(", "targetPath", ",", "content", ",", "tabs", "=", "2", ")", "{", "const", "fileName", "=", "targetPath", ".", "split", "(", "'/'", ")", ".", "pop", "(", ")", ";", "let", "contentHolder", "=", "content", ";", "if", "("...
Promise-base `writeFile` function. @param {string} targetPath File path. @param {string} content File content. @param {number} tabs Number of tabs. @return {promise} Promise to write the given file.
[ "Promise", "-", "base", "writeFile", "function", "." ]
ef6db49de6c8b0d2f4f9d3e10e8a8153e39ffcc4
https://github.com/Digznav/bilberry/blob/ef6db49de6c8b0d2f4f9d3e10e8a8153e39ffcc4/promise-write-file.js#L10-L29
50,844
tolokoban/ToloFrameWork
ker/mod/tfw.gestures.js
getGesture
function getGesture( element_ ) { const element = ensureDom( element_ ); if ( !element[ SYMBOL ] ) element[ SYMBOL ] = new Gesture( element ); return element[ SYMBOL ]; }
javascript
function getGesture( element_ ) { const element = ensureDom( element_ ); if ( !element[ SYMBOL ] ) element[ SYMBOL ] = new Gesture( element ); return element[ SYMBOL ]; }
[ "function", "getGesture", "(", "element_", ")", "{", "const", "element", "=", "ensureDom", "(", "element_", ")", ";", "if", "(", "!", "element", "[", "SYMBOL", "]", ")", "element", "[", "SYMBOL", "]", "=", "new", "Gesture", "(", "element", ")", ";", ...
Return the associated gesture object. If it does not exist, create it. @param {[type]} element_ [description] @returns {[type]} [description]
[ "Return", "the", "associated", "gesture", "object", ".", "If", "it", "does", "not", "exist", "create", "it", "." ]
730845a833a9660ebfdb60ad027ebaab5ac871b6
https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/tfw.gestures.js#L87-L91
50,845
tolokoban/ToloFrameWork
ker/mod/tfw.gestures.js
handlerWithChainOfResponsability
function handlerWithChainOfResponsability( eventName, evt ) { const chain = this._events[ eventName ].chain; for ( let i = 0; i < chain.length; i++ ) { const responsible = chain[ i ]; if ( responsible( evt ) === true ) return; } }
javascript
function handlerWithChainOfResponsability( eventName, evt ) { const chain = this._events[ eventName ].chain; for ( let i = 0; i < chain.length; i++ ) { const responsible = chain[ i ]; if ( responsible( evt ) === true ) return; } }
[ "function", "handlerWithChainOfResponsability", "(", "eventName", ",", "evt", ")", "{", "const", "chain", "=", "this", ".", "_events", "[", "eventName", "]", ".", "chain", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "chain", ".", "length", ";...
We map a chain of responsability to each hammer event we need to deal with. When an item of that chain returns `true` that means it will take the responsability and we do not ask the others.
[ "We", "map", "a", "chain", "of", "responsability", "to", "each", "hammer", "event", "we", "need", "to", "deal", "with", ".", "When", "an", "item", "of", "that", "chain", "returns", "true", "that", "means", "it", "will", "take", "the", "responsability", "...
730845a833a9660ebfdb60ad027ebaab5ac871b6
https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/tfw.gestures.js#L98-L104
50,846
tolokoban/ToloFrameWork
ker/mod/tfw.gestures.js
doRegister
function doRegister( event, responsible ) { var hammerEvent = getEventNameForPrefix( event, "hammer." ); if ( hammerEvent && !this._hammer ) { this._hammer = new Hammer( this.$, { domEvents: true } ); // To get domEvents.stopPropagation() available. this._hammer.domEvents = true; } var eventDef = this._events[ event ]; if ( !eventDef ) { var handler = handlerWithChainOfResponsability.bind( this, event ); eventDef = { chain: [], handler: handler }; if ( hammerEvent ) this._hammer.on( hammerEvent, handler ); else this.$.addEventListener( event, handler ); this._events[ event ] = eventDef; } eventDef.chain.push( responsible ); }
javascript
function doRegister( event, responsible ) { var hammerEvent = getEventNameForPrefix( event, "hammer." ); if ( hammerEvent && !this._hammer ) { this._hammer = new Hammer( this.$, { domEvents: true } ); // To get domEvents.stopPropagation() available. this._hammer.domEvents = true; } var eventDef = this._events[ event ]; if ( !eventDef ) { var handler = handlerWithChainOfResponsability.bind( this, event ); eventDef = { chain: [], handler: handler }; if ( hammerEvent ) this._hammer.on( hammerEvent, handler ); else this.$.addEventListener( event, handler ); this._events[ event ] = eventDef; } eventDef.chain.push( responsible ); }
[ "function", "doRegister", "(", "event", ",", "responsible", ")", "{", "var", "hammerEvent", "=", "getEventNameForPrefix", "(", "event", ",", "\"hammer.\"", ")", ";", "if", "(", "hammerEvent", "&&", "!", "this", ".", "_hammer", ")", "{", "this", ".", "_hamm...
Add a responsability item in the chain of a hammer event.
[ "Add", "a", "responsability", "item", "in", "the", "chain", "of", "a", "hammer", "event", "." ]
730845a833a9660ebfdb60ad027ebaab5ac871b6
https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/tfw.gestures.js#L109-L126
50,847
tolokoban/ToloFrameWork
ker/mod/tfw.gestures.js
onDrag
function onDrag( register, slot, args ) { const that = this; register( 'hammer.pan', function ( evt ) { if ( evt.isFinal ) return false; setHammerXY( that.$, evt ); if ( typeof that._dragX === 'undefined' ) { that._dragX = evt.x; that._dragY = evt.y; that._dragStart = true; } setHammerVxVy.call( that, that.$, evt ); const domEvt = evt.srcEvent; slot( { x: evt.x, y: evt.y, x0: evt.x0, y0: evt.y0, vx: evt.vx, vy: evt.vy, sx: evt.velocityX, sy: evt.velocityY, event: evt, target: evt.target, buttons: getButtons( evt ), preventDefault: domEvt.preventDefault.bind( domEvt ), stopPropagation: domEvt.stopImmediatePropagation.bind( domEvt ) }, args ); return true; } ); }
javascript
function onDrag( register, slot, args ) { const that = this; register( 'hammer.pan', function ( evt ) { if ( evt.isFinal ) return false; setHammerXY( that.$, evt ); if ( typeof that._dragX === 'undefined' ) { that._dragX = evt.x; that._dragY = evt.y; that._dragStart = true; } setHammerVxVy.call( that, that.$, evt ); const domEvt = evt.srcEvent; slot( { x: evt.x, y: evt.y, x0: evt.x0, y0: evt.y0, vx: evt.vx, vy: evt.vy, sx: evt.velocityX, sy: evt.velocityY, event: evt, target: evt.target, buttons: getButtons( evt ), preventDefault: domEvt.preventDefault.bind( domEvt ), stopPropagation: domEvt.stopImmediatePropagation.bind( domEvt ) }, args ); return true; } ); }
[ "function", "onDrag", "(", "register", ",", "slot", ",", "args", ")", "{", "const", "that", "=", "this", ";", "register", "(", "'hammer.pan'", ",", "function", "(", "evt", ")", "{", "if", "(", "evt", ".", "isFinal", ")", "return", "false", ";", "setH...
Dragging is moving while touching. @this Gesture @param {function} register - Hammer register function. @param {function} slot - Function to call when the event occurs. @param {any} args - Any argument to send to the slot. @returns {undefined}
[ "Dragging", "is", "moving", "while", "touching", "." ]
730845a833a9660ebfdb60ad027ebaab5ac871b6
https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/tfw.gestures.js#L261-L291
50,848
jslovesyou/resolver-revolver
lib/completion.js
froms
function froms(froms) { var args = Array.prototype.splice.call(arguments, 0); if (isUndefined(froms)) { froms = []; } if (!isArray(froms)) { throw { name: 'Error', message: 'Argument is not an array', arguments: args }; } var f = froms .filter(function (from) { return !isUndefined(from); }) .map(function (from) { if (isObject(from)) { if (isUndefined(from.target) && isUndefined(from.default)) { throw { name: 'Error', message: 'from.target and from.default are both undefined', arguments: args }; } if (isUndefined(from.default) && !isString(from.target)) { throw { name: 'Error', message: 'from.target is not a string', arguments: args }; } return from; } else { return { target: from }; }; }); return f; }
javascript
function froms(froms) { var args = Array.prototype.splice.call(arguments, 0); if (isUndefined(froms)) { froms = []; } if (!isArray(froms)) { throw { name: 'Error', message: 'Argument is not an array', arguments: args }; } var f = froms .filter(function (from) { return !isUndefined(from); }) .map(function (from) { if (isObject(from)) { if (isUndefined(from.target) && isUndefined(from.default)) { throw { name: 'Error', message: 'from.target and from.default are both undefined', arguments: args }; } if (isUndefined(from.default) && !isString(from.target)) { throw { name: 'Error', message: 'from.target is not a string', arguments: args }; } return from; } else { return { target: from }; }; }); return f; }
[ "function", "froms", "(", "froms", ")", "{", "var", "args", "=", "Array", ".", "prototype", ".", "splice", ".", "call", "(", "arguments", ",", "0", ")", ";", "if", "(", "isUndefined", "(", "froms", ")", ")", "{", "froms", "=", "[", "]", ";", "}",...
Helper function which returns an array of
[ "Helper", "function", "which", "returns", "an", "array", "of" ]
bf76dd899f3ccfe05be1aa637b4bf638c02a9af5
https://github.com/jslovesyou/resolver-revolver/blob/bf76dd899f3ccfe05be1aa637b4bf638c02a9af5/lib/completion.js#L97-L140
50,849
rowanmanning/thingme
lib/thingme.js
createThingme
function createThingme (opts) { opts = defaultOptions(opts); validateThings(opts.things); return createWebservice(opts); }
javascript
function createThingme (opts) { opts = defaultOptions(opts); validateThings(opts.things); return createWebservice(opts); }
[ "function", "createThingme", "(", "opts", ")", "{", "opts", "=", "defaultOptions", "(", "opts", ")", ";", "validateThings", "(", "opts", ".", "things", ")", ";", "return", "createWebservice", "(", "opts", ")", ";", "}" ]
Create a thingme web-service
[ "Create", "a", "thingme", "web", "-", "service" ]
e74a9e20535e9b52229950e55b73c179d34f6ae2
https://github.com/rowanmanning/thingme/blob/e74a9e20535e9b52229950e55b73c179d34f6ae2/lib/thingme.js#L9-L13
50,850
rowanmanning/thingme
lib/thingme.js
createWebservice
function createWebservice (opts) { var server = new Hapi.Server(opts.host, opts.port, { cors: { methods: ['GET'] } }); defineRoutes(server, opts); return { address: 'http://' + opts.host + ':' + opts.port + '/', hapi: server, options: opts, start: server.start.bind(server) }; }
javascript
function createWebservice (opts) { var server = new Hapi.Server(opts.host, opts.port, { cors: { methods: ['GET'] } }); defineRoutes(server, opts); return { address: 'http://' + opts.host + ':' + opts.port + '/', hapi: server, options: opts, start: server.start.bind(server) }; }
[ "function", "createWebservice", "(", "opts", ")", "{", "var", "server", "=", "new", "Hapi", ".", "Server", "(", "opts", ".", "host", ",", "opts", ".", "port", ",", "{", "cors", ":", "{", "methods", ":", "[", "'GET'", "]", "}", "}", ")", ";", "def...
Create a webservice
[ "Create", "a", "webservice" ]
e74a9e20535e9b52229950e55b73c179d34f6ae2
https://github.com/rowanmanning/thingme/blob/e74a9e20535e9b52229950e55b73c179d34f6ae2/lib/thingme.js#L16-L29
50,851
rowanmanning/thingme
lib/thingme.js
defineRoutes
function defineRoutes (server, opts) { require('../route')(server, opts); require('../route/things')(server, opts); require('../route/random')(server, opts); require('../route/bomb')(server, opts); require('../route/count')(server, opts); }
javascript
function defineRoutes (server, opts) { require('../route')(server, opts); require('../route/things')(server, opts); require('../route/random')(server, opts); require('../route/bomb')(server, opts); require('../route/count')(server, opts); }
[ "function", "defineRoutes", "(", "server", ",", "opts", ")", "{", "require", "(", "'../route'", ")", "(", "server", ",", "opts", ")", ";", "require", "(", "'../route/things'", ")", "(", "server", ",", "opts", ")", ";", "require", "(", "'../route/random'", ...
Define webservice routes
[ "Define", "webservice", "routes" ]
e74a9e20535e9b52229950e55b73c179d34f6ae2
https://github.com/rowanmanning/thingme/blob/e74a9e20535e9b52229950e55b73c179d34f6ae2/lib/thingme.js#L32-L38
50,852
Minetrocity/nodb
index.js
write
function write (database) { var deferred = q.defer(); // Write database to file under database name fs.writeFile(globalConfig.db.location + database + '.db.json', JSON.stringify(databases[database]), function (err) { if(err) return deferred.reject(err); deferred.resolve(); }); return deferred.promise; }
javascript
function write (database) { var deferred = q.defer(); // Write database to file under database name fs.writeFile(globalConfig.db.location + database + '.db.json', JSON.stringify(databases[database]), function (err) { if(err) return deferred.reject(err); deferred.resolve(); }); return deferred.promise; }
[ "function", "write", "(", "database", ")", "{", "var", "deferred", "=", "q", ".", "defer", "(", ")", ";", "// Write database to file under database name", "fs", ".", "writeFile", "(", "globalConfig", ".", "db", ".", "location", "+", "database", "+", "'.db.json...
Writes a database to file @param {string} database Database to write @return {promise} Denotes success or failure of write
[ "Writes", "a", "database", "to", "file" ]
e45e8f1d8141d3f2c788ebafb69ca8be6a816ada
https://github.com/Minetrocity/nodb/blob/e45e8f1d8141d3f2c788ebafb69ca8be6a816ada/index.js#L142-L153
50,853
Minetrocity/nodb
index.js
verifyConfig
function verifyConfig (config) { config = config || {}; config.db = config.db || {}; config.db.location = config.db.location || __dirname + 'databases/'; // /cwd/databases/ default config.db.timeout = config.db.timeout || 1000 * 60 * 5; // 5 minute default config.db.fileTimeout = config.db.fileTimeout || -1; // No limit default return config; }
javascript
function verifyConfig (config) { config = config || {}; config.db = config.db || {}; config.db.location = config.db.location || __dirname + 'databases/'; // /cwd/databases/ default config.db.timeout = config.db.timeout || 1000 * 60 * 5; // 5 minute default config.db.fileTimeout = config.db.fileTimeout || -1; // No limit default return config; }
[ "function", "verifyConfig", "(", "config", ")", "{", "config", "=", "config", "||", "{", "}", ";", "config", ".", "db", "=", "config", ".", "db", "||", "{", "}", ";", "config", ".", "db", ".", "location", "=", "config", ".", "db", ".", "location", ...
Verifies the needed config options are available @param {object} config Configuration object @return {object} Returns the properly adjusted config object
[ "Verifies", "the", "needed", "config", "options", "are", "available" ]
e45e8f1d8141d3f2c788ebafb69ca8be6a816ada
https://github.com/Minetrocity/nodb/blob/e45e8f1d8141d3f2c788ebafb69ca8be6a816ada/index.js#L161-L169
50,854
Minetrocity/nodb
index.js
createLocation
function createLocation () { var deferred = q.defer(); // Make the directory, and report status mkdirp(globalConfig.db.location, function (err, made) { if(err) return deferred.reject(err); deferred.resolve(made); }); return deferred.promise; }
javascript
function createLocation () { var deferred = q.defer(); // Make the directory, and report status mkdirp(globalConfig.db.location, function (err, made) { if(err) return deferred.reject(err); deferred.resolve(made); }); return deferred.promise; }
[ "function", "createLocation", "(", ")", "{", "var", "deferred", "=", "q", ".", "defer", "(", ")", ";", "// Make the directory, and report status", "mkdirp", "(", "globalConfig", ".", "db", ".", "location", ",", "function", "(", "err", ",", "made", ")", "{", ...
Verifies the database location exists @return {promise} Denotes success or failure of folder creation
[ "Verifies", "the", "database", "location", "exists" ]
e45e8f1d8141d3f2c788ebafb69ca8be6a816ada
https://github.com/Minetrocity/nodb/blob/e45e8f1d8141d3f2c788ebafb69ca8be6a816ada/index.js#L176-L187
50,855
Minetrocity/nodb
index.js
createDatabase
function createDatabase (name) { var deferred = q.defer(); // Make sure the database location exists ready.then(function () { // Check if database exists fs.exists(globalConfig.db.location + name + '.db.json', function (exists) { if(exists) return deferred.resolve(); // If database is non-existent, simply write an empty object as placeholder fs.writeFile(globalConfig.db.location + name + '.db.json', '{}', function (err) { if(err) return deferred.reject('Database couldn\'t create table'); return deferred.resolve(); }); }); }, function () { deferred.reject('Database couldn\'t instantiate'); }); return deferred.promise; }
javascript
function createDatabase (name) { var deferred = q.defer(); // Make sure the database location exists ready.then(function () { // Check if database exists fs.exists(globalConfig.db.location + name + '.db.json', function (exists) { if(exists) return deferred.resolve(); // If database is non-existent, simply write an empty object as placeholder fs.writeFile(globalConfig.db.location + name + '.db.json', '{}', function (err) { if(err) return deferred.reject('Database couldn\'t create table'); return deferred.resolve(); }); }); }, function () { deferred.reject('Database couldn\'t instantiate'); }); return deferred.promise; }
[ "function", "createDatabase", "(", "name", ")", "{", "var", "deferred", "=", "q", ".", "defer", "(", ")", ";", "// Make sure the database location exists", "ready", ".", "then", "(", "function", "(", ")", "{", "// Check if database exists", "fs", ".", "exists", ...
Checks for existence of a database, creates if non-existent @param {string} name Name of database to open @return {promise} Denotes existence of database
[ "Checks", "for", "existence", "of", "a", "database", "creates", "if", "non", "-", "existent" ]
e45e8f1d8141d3f2c788ebafb69ca8be6a816ada
https://github.com/Minetrocity/nodb/blob/e45e8f1d8141d3f2c788ebafb69ca8be6a816ada/index.js#L233-L254
50,856
Minetrocity/nodb
index.js
closeDatabase
function closeDatabase (name) { var deferred = q.defer(); // We need to be sure the database location exists ready.then(function () { clearTimeout(timeouts[name]); // Write to file write(name).then(function () { // Remove database from memory delete databases[name]; deferred.resolve(); }, function (err) { deferred.reject(err); }); }, function () { deferred.reject('Database couldn\'t instantiate'); }); return deferred.promise; }
javascript
function closeDatabase (name) { var deferred = q.defer(); // We need to be sure the database location exists ready.then(function () { clearTimeout(timeouts[name]); // Write to file write(name).then(function () { // Remove database from memory delete databases[name]; deferred.resolve(); }, function (err) { deferred.reject(err); }); }, function () { deferred.reject('Database couldn\'t instantiate'); }); return deferred.promise; }
[ "function", "closeDatabase", "(", "name", ")", "{", "var", "deferred", "=", "q", ".", "defer", "(", ")", ";", "// We need to be sure the database location exists", "ready", ".", "then", "(", "function", "(", ")", "{", "clearTimeout", "(", "timeouts", "[", "nam...
Closes a database and writes to file @param {[type]} @return {[type]}
[ "Closes", "a", "database", "and", "writes", "to", "file" ]
e45e8f1d8141d3f2c788ebafb69ca8be6a816ada
https://github.com/Minetrocity/nodb/blob/e45e8f1d8141d3f2c788ebafb69ca8be6a816ada/index.js#L262-L283
50,857
Minetrocity/nodb
index.js
actionOn
function actionOn (name) { // Clear a possibly existing timeout clearTimeout(timeouts[name]); // Make sure user hasn't declined auto-close if(globalConfig.db.timeout < 0) return; // Set up auto-close timeouts[name] = setTimeout(function () { closeDatabase(name); }, globalConfig.db.timeout); }
javascript
function actionOn (name) { // Clear a possibly existing timeout clearTimeout(timeouts[name]); // Make sure user hasn't declined auto-close if(globalConfig.db.timeout < 0) return; // Set up auto-close timeouts[name] = setTimeout(function () { closeDatabase(name); }, globalConfig.db.timeout); }
[ "function", "actionOn", "(", "name", ")", "{", "// Clear a possibly existing timeout", "clearTimeout", "(", "timeouts", "[", "name", "]", ")", ";", "// Make sure user hasn't declined auto-close", "if", "(", "globalConfig", ".", "db", ".", "timeout", "<", "0", ")", ...
Logs actions to the database, and preps for auto-close if specified @param {string} name Database with action
[ "Logs", "actions", "to", "the", "database", "and", "preps", "for", "auto", "-", "close", "if", "specified" ]
e45e8f1d8141d3f2c788ebafb69ca8be6a816ada
https://github.com/Minetrocity/nodb/blob/e45e8f1d8141d3f2c788ebafb69ca8be6a816ada/index.js#L290-L301
50,858
fronteerio/node-embdr
lib/api/resources.js
function(file, options, callback) { // If the file is a string, we assume it's a path on disk if (_.isString(file)) { try { file = fs.createReadStream(file); } catch (err) { return callback({'message': 'A stream could not be opened for the provided path', 'err': err}); } } // Attach an error listener to the stream file.on('error', function(err) { return callback({'message': 'An error occurred when reading from the stream', 'err': err}); }); // Upload the file var data = {'file': file}; addSizes(data, options, 'thumbnailSizes'); addSizes(data, options, 'imageSizes'); return processr._request('POST', '/resources', data, callback); }
javascript
function(file, options, callback) { // If the file is a string, we assume it's a path on disk if (_.isString(file)) { try { file = fs.createReadStream(file); } catch (err) { return callback({'message': 'A stream could not be opened for the provided path', 'err': err}); } } // Attach an error listener to the stream file.on('error', function(err) { return callback({'message': 'An error occurred when reading from the stream', 'err': err}); }); // Upload the file var data = {'file': file}; addSizes(data, options, 'thumbnailSizes'); addSizes(data, options, 'imageSizes'); return processr._request('POST', '/resources', data, callback); }
[ "function", "(", "file", ",", "options", ",", "callback", ")", "{", "// If the file is a string, we assume it's a path on disk", "if", "(", "_", ".", "isString", "(", "file", ")", ")", "{", "try", "{", "file", "=", "fs", ".", "createReadStream", "(", "file", ...
Create and process a file @param {stream} file A stream that holds the data for a file that should be uploaded and processed @param {Object} [options] A set of extra options @param {string[]} [options.thumbnailSizes] A set of thumbnail dimensions @param {string[]} [options.imageSizes] A set of image dimensions @param {Function} callback Standard callback function @param {Error} callback.err The error object as returned by the REST API. If no error occurred, this value will be `null` @param {Object} callback.data The data as returned by the REST API. If the request errored, this value will be `null`
[ "Create", "and", "process", "a", "file" ]
050916baa37b069d894fdd4db3b80f110ad8c51e
https://github.com/fronteerio/node-embdr/blob/050916baa37b069d894fdd4db3b80f110ad8c51e/lib/api/resources.js#L25-L45
50,859
fronteerio/node-embdr
lib/api/resources.js
function(link, options, callback) { var data = {'link': link}; addSizes(data, options, 'thumbnailSizes'); addSizes(data, options, 'imageSizes'); return processr._request('POST', '/resources', data, callback); }
javascript
function(link, options, callback) { var data = {'link': link}; addSizes(data, options, 'thumbnailSizes'); addSizes(data, options, 'imageSizes'); return processr._request('POST', '/resources', data, callback); }
[ "function", "(", "link", ",", "options", ",", "callback", ")", "{", "var", "data", "=", "{", "'link'", ":", "link", "}", ";", "addSizes", "(", "data", ",", "options", ",", "'thumbnailSizes'", ")", ";", "addSizes", "(", "data", ",", "options", ",", "'...
Create and process a link @param {string} link The link that should be processed @param {Object} [options] A set of extra options @param {string[]} [options.thumbnailSizes] A set of thumbnail dimensions @param {string[]} [options.imageSizes] A set of image dimensions @param {Function} callback Standard callback function @param {Error} callback.err The error object as returned by the REST API. If no error occurred, this value will be `null` @param {Object} callback.data The data as returned by the REST API. If the request errored, this value will be `null`
[ "Create", "and", "process", "a", "link" ]
050916baa37b069d894fdd4db3b80f110ad8c51e
https://github.com/fronteerio/node-embdr/blob/050916baa37b069d894fdd4db3b80f110ad8c51e/lib/api/resources.js#L58-L63
50,860
fronteerio/node-embdr
lib/api/resources.js
function(id, callback) { var url = '/resources/' + ProcessrUtil.encodeURIComponent(id); return processr._request('GET', url, null, callback); }
javascript
function(id, callback) { var url = '/resources/' + ProcessrUtil.encodeURIComponent(id); return processr._request('GET', url, null, callback); }
[ "function", "(", "id", ",", "callback", ")", "{", "var", "url", "=", "'/resources/'", "+", "ProcessrUtil", ".", "encodeURIComponent", "(", "id", ")", ";", "return", "processr", ".", "_request", "(", "'GET'", ",", "url", ",", "null", ",", "callback", ")",...
Get a resource @param {string} id The id of the resource that should be retrieved @param {Function} callback Standard callback function @param {Error} callback.err The error object as returned by the REST API. If no error occurred, this value will be `null` @param {Object} callback.data The data as returned by the REST API. If the request errored, this value will be `null`
[ "Get", "a", "resource" ]
050916baa37b069d894fdd4db3b80f110ad8c51e
https://github.com/fronteerio/node-embdr/blob/050916baa37b069d894fdd4db3b80f110ad8c51e/lib/api/resources.js#L73-L76
50,861
skerit/hawkejs
lib/client/scene.js
onReadystatechange
function onReadystatechange(e) { if (!(e instanceof Event)) { throw new TypeError('Invalid event was given'); } if (document.readyState == 'interactive') { makeReady.call(this); } if (document.readyState == 'complete') { makeLoaded.call(this); } }
javascript
function onReadystatechange(e) { if (!(e instanceof Event)) { throw new TypeError('Invalid event was given'); } if (document.readyState == 'interactive') { makeReady.call(this); } if (document.readyState == 'complete') { makeLoaded.call(this); } }
[ "function", "onReadystatechange", "(", "e", ")", "{", "if", "(", "!", "(", "e", "instanceof", "Event", ")", ")", "{", "throw", "new", "TypeError", "(", "'Invalid event was given'", ")", ";", "}", "if", "(", "document", ".", "readyState", "==", "'interactiv...
Listen to the readystate changes of the `document` @author Jelle De Loecker <jelle@develry.be> @since 1.0.0 @version 1.0.0
[ "Listen", "to", "the", "readystate", "changes", "of", "the", "document" ]
15ed7205183ac2c425362deb8c0796c0d16b898a
https://github.com/skerit/hawkejs/blob/15ed7205183ac2c425362deb8c0796c0d16b898a/lib/client/scene.js#L208-L221
50,862
skerit/hawkejs
lib/client/scene.js
check
function check() { var el, i; // Return early if no elements need to be checked if (!elements.length) { return; } for (i = 0; i < elements.length; i++) { el = elements[i]; if (el.isVisible(options.padding)) { if (live) { el.classList.remove(query); } else { elements.splice(i, 1); } i--; callback(el); // If delay_callback is true, // wait until the next check to call another item if (options.delay_callback) { req(); break; } } } // Stop all future checks if no elements are left and it's not live if (!live && !elements.length) { document.removeEventListener('wheel', req); document.removeEventListener('click', req); document.removeEventListener('scroll', req); that.removeListener('rendered', req); clearInterval(intervalId); queue.destroy(); } }
javascript
function check() { var el, i; // Return early if no elements need to be checked if (!elements.length) { return; } for (i = 0; i < elements.length; i++) { el = elements[i]; if (el.isVisible(options.padding)) { if (live) { el.classList.remove(query); } else { elements.splice(i, 1); } i--; callback(el); // If delay_callback is true, // wait until the next check to call another item if (options.delay_callback) { req(); break; } } } // Stop all future checks if no elements are left and it's not live if (!live && !elements.length) { document.removeEventListener('wheel', req); document.removeEventListener('click', req); document.removeEventListener('scroll', req); that.removeListener('rendered', req); clearInterval(intervalId); queue.destroy(); } }
[ "function", "check", "(", ")", "{", "var", "el", ",", "i", ";", "// Return early if no elements need to be checked", "if", "(", "!", "elements", ".", "length", ")", "{", "return", ";", "}", "for", "(", "i", "=", "0", ";", "i", "<", "elements", ".", "le...
The actual check
[ "The", "actual", "check" ]
15ed7205183ac2c425362deb8c0796c0d16b898a
https://github.com/skerit/hawkejs/blob/15ed7205183ac2c425362deb8c0796c0d16b898a/lib/client/scene.js#L3004-L3045
50,863
alexpods/ClazzJS
src/components/meta/Events.js
function(clazz, metaData) { this.applyEvents(clazz, metaData.clazz_events || {}); this.applyEvents(clazz.prototype, metaData.events || {}); }
javascript
function(clazz, metaData) { this.applyEvents(clazz, metaData.clazz_events || {}); this.applyEvents(clazz.prototype, metaData.events || {}); }
[ "function", "(", "clazz", ",", "metaData", ")", "{", "this", ".", "applyEvents", "(", "clazz", ",", "metaData", ".", "clazz_events", "||", "{", "}", ")", ";", "this", ".", "applyEvents", "(", "clazz", ".", "prototype", ",", "metaData", ".", "events", "...
Applies events to clazz and its prototype @param {clazz} clazz Clazz @param {object} metaData Meta data with 'clazz_event' and 'event' properties @this {metaProcessor}
[ "Applies", "events", "to", "clazz", "and", "its", "prototype" ]
2f94496019669813c8246d48fcceb12a3e68a870
https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Events.js#L15-L18
50,864
alexpods/ClazzJS
src/components/meta/Events.js
function(object, events) { if (!object.__isInterfaceImplemented('events')) { object.__implementInterface('events', this.interface); } object.__initEvents(); _.each(events, function(eventListeners, eventName) { _.each(eventListeners, function(listener, listenerName) { object.__addEventListener(eventName, listenerName, listener); }); }); }
javascript
function(object, events) { if (!object.__isInterfaceImplemented('events')) { object.__implementInterface('events', this.interface); } object.__initEvents(); _.each(events, function(eventListeners, eventName) { _.each(eventListeners, function(listener, listenerName) { object.__addEventListener(eventName, listenerName, listener); }); }); }
[ "function", "(", "object", ",", "events", ")", "{", "if", "(", "!", "object", ".", "__isInterfaceImplemented", "(", "'events'", ")", ")", "{", "object", ".", "__implementInterface", "(", "'events'", ",", "this", ".", "interface", ")", ";", "}", "object", ...
Implements events prototype and applies events to object @param {clazz|object} object Clazz of its prototype @param {object} events Events @this {metaProcessor}
[ "Implements", "events", "prototype", "and", "applies", "events", "to", "object" ]
2f94496019669813c8246d48fcceb12a3e68a870
https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Events.js#L28-L40
50,865
alexpods/ClazzJS
src/components/meta/Events.js
function(event /* params */) { var listeners; var that = this; var params = _.toArray(arguments).slice(1); listeners = this.__getEventListeners(event); _.each(listeners, function(listener) { listener.apply(that, params); }); listeners = this.__getEventListeners('event.emit'); _.each(listeners, function(listener) { listener.call(that, event, params); }); return this; }
javascript
function(event /* params */) { var listeners; var that = this; var params = _.toArray(arguments).slice(1); listeners = this.__getEventListeners(event); _.each(listeners, function(listener) { listener.apply(that, params); }); listeners = this.__getEventListeners('event.emit'); _.each(listeners, function(listener) { listener.call(that, event, params); }); return this; }
[ "function", "(", "event", "/* params */", ")", "{", "var", "listeners", ";", "var", "that", "=", "this", ";", "var", "params", "=", "_", ".", "toArray", "(", "arguments", ")", ".", "slice", "(", "1", ")", ";", "listeners", "=", "this", ".", "__getEve...
Emits specified event @param {string} event Event name @returns {clazz|object} this @this {clazz|object}
[ "Emits", "specified", "event" ]
2f94496019669813c8246d48fcceb12a3e68a870
https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Events.js#L64-L83
50,866
alexpods/ClazzJS
src/components/meta/Events.js
function(event, name, callback) { if (this.__hasEventListener(event, name)) { throw new Error('Event listener for event "' + event + '" with name "' + name + '" already exist!'); } if (!(event in this.__events)) { this.__events[event] = {}; } this.__events[event][name] = callback; return this; }
javascript
function(event, name, callback) { if (this.__hasEventListener(event, name)) { throw new Error('Event listener for event "' + event + '" with name "' + name + '" already exist!'); } if (!(event in this.__events)) { this.__events[event] = {}; } this.__events[event][name] = callback; return this; }
[ "function", "(", "event", ",", "name", ",", "callback", ")", "{", "if", "(", "this", ".", "__hasEventListener", "(", "event", ",", "name", ")", ")", "{", "throw", "new", "Error", "(", "'Event listener for event \"'", "+", "event", "+", "'\" with name \"'", ...
Adds event listener for specified event @param {string} event Event name @param {string} name Listener name @param {function} callback Listener handler @returns {clazz|object} this @throws {Error} if event listener for specified event already exist @this {clazz|object}
[ "Adds", "event", "listener", "for", "specified", "event" ]
2f94496019669813c8246d48fcceb12a3e68a870
https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Events.js#L97-L109
50,867
alexpods/ClazzJS
src/components/meta/Events.js
function(event, name) { var that = this; if (!(event in that.__events)) { that.__events[event] = {}; } if (!_.isUndefined(name)) { if (!that.__hasEventListener(event, name)) { throw new Error('There is no "' + event + (name ? '"::"' + name : '') + '" event callback!'); } that.__events[event][name] = undefined; } else { _.each(that.__getEventListeners(event), function(listener, name) { that.__events[event][name] = undefined; }); } return that; }
javascript
function(event, name) { var that = this; if (!(event in that.__events)) { that.__events[event] = {}; } if (!_.isUndefined(name)) { if (!that.__hasEventListener(event, name)) { throw new Error('There is no "' + event + (name ? '"::"' + name : '') + '" event callback!'); } that.__events[event][name] = undefined; } else { _.each(that.__getEventListeners(event), function(listener, name) { that.__events[event][name] = undefined; }); } return that; }
[ "function", "(", "event", ",", "name", ")", "{", "var", "that", "=", "this", ";", "if", "(", "!", "(", "event", "in", "that", ".", "__events", ")", ")", "{", "that", ".", "__events", "[", "event", "]", "=", "{", "}", ";", "}", "if", "(", "!",...
Removes event listener for specified event @param {string} event Event name @param {string} name Listener name @returns {clazz|object} this @throws {Error} if event listener for specified event does not exists @this {clazz|object}
[ "Removes", "event", "listener", "for", "specified", "event" ]
2f94496019669813c8246d48fcceb12a3e68a870
https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Events.js#L122-L144
50,868
alexpods/ClazzJS
src/components/meta/Events.js
function(event, name) { var eventListeners = this.__getEventListeners(event); if (!(name in eventListeners)) { throw new Error('Event listener for event "' + event + '" with name "' + name + '" does not exist!'); } return eventListeners[event][name]; }
javascript
function(event, name) { var eventListeners = this.__getEventListeners(event); if (!(name in eventListeners)) { throw new Error('Event listener for event "' + event + '" with name "' + name + '" does not exist!'); } return eventListeners[event][name]; }
[ "function", "(", "event", ",", "name", ")", "{", "var", "eventListeners", "=", "this", ".", "__getEventListeners", "(", "event", ")", ";", "if", "(", "!", "(", "name", "in", "eventListeners", ")", ")", "{", "throw", "new", "Error", "(", "'Event listener ...
Gets event listener @param {string} event Event name @param {string} name Listener name @returns {function} Event listener handler @throws {Error} if event listener does not exist @this {clazz|object}
[ "Gets", "event", "listener" ]
2f94496019669813c8246d48fcceb12a3e68a870
https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Events.js#L170-L179
50,869
alexpods/ClazzJS
src/components/meta/Events.js
function(event) { var events = this.__collectAllPropertyValues.apply(this, ['__events', 2].concat(event || [])); _.each(events, function(eventsListeners) { _.each(eventsListeners, function(listener, listenerName) { if (_.isUndefined(listener)) { delete eventsListeners[listenerName]; } }) }); return event ? events[event] || {} : events; }
javascript
function(event) { var events = this.__collectAllPropertyValues.apply(this, ['__events', 2].concat(event || [])); _.each(events, function(eventsListeners) { _.each(eventsListeners, function(listener, listenerName) { if (_.isUndefined(listener)) { delete eventsListeners[listenerName]; } }) }); return event ? events[event] || {} : events; }
[ "function", "(", "event", ")", "{", "var", "events", "=", "this", ".", "__collectAllPropertyValues", ".", "apply", "(", "this", ",", "[", "'__events'", ",", "2", "]", ".", "concat", "(", "event", "||", "[", "]", ")", ")", ";", "_", ".", "each", "("...
Gets all event listeners for specified event @param {string} event Event name @returns {object} Hash of event listener @this {clazz|object}
[ "Gets", "all", "event", "listeners", "for", "specified", "event" ]
2f94496019669813c8246d48fcceb12a3e68a870
https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Events.js#L191-L203
50,870
redisjs/jsr-script
lib/manager.js
ScriptManager
function ScriptManager() { // child process this.ps = null; // script execution limit in milliseconds this._limit = 5000; // flag determining if a script is busy executing this._busy = false; // flag determining if script execution issued // any write commands this._written = false; // currently executing script name this._script = null; // injected reference to the command handlers this._commands = {}; // script limit timeout listener this.onTimeout = this.onTimeout.bind(this); }
javascript
function ScriptManager() { // child process this.ps = null; // script execution limit in milliseconds this._limit = 5000; // flag determining if a script is busy executing this._busy = false; // flag determining if script execution issued // any write commands this._written = false; // currently executing script name this._script = null; // injected reference to the command handlers this._commands = {}; // script limit timeout listener this.onTimeout = this.onTimeout.bind(this); }
[ "function", "ScriptManager", "(", ")", "{", "// child process", "this", ".", "ps", "=", "null", ";", "// script execution limit in milliseconds", "this", ".", "_limit", "=", "5000", ";", "// flag determining if a script is busy executing", "this", ".", "_busy", "=", "...
Manages script evaluation, compilation and command execution. Scripts are executed in a child process so that a script that contains an infinite loop or other bad code will not prevent this process from serving client requests.
[ "Manages", "script", "evaluation", "compilation", "and", "command", "execution", "." ]
eab3df935372724a82a9ad9ba3bca7e6e165e9d1
https://github.com/redisjs/jsr-script/blob/eab3df935372724a82a9ad9ba3bca7e6e165e9d1/lib/manager.js#L19-L42
50,871
redisjs/jsr-script
lib/manager.js
load
function load(req, res, source) { this.spawn(); this.reply(req, res); this.ps.send({event: 'load', source: source}); }
javascript
function load(req, res, source) { this.spawn(); this.reply(req, res); this.ps.send({event: 'load', source: source}); }
[ "function", "load", "(", "req", ",", "res", ",", "source", ")", "{", "this", ".", "spawn", "(", ")", ";", "this", ".", "reply", "(", "req", ",", "res", ")", ";", "this", ".", "ps", ".", "send", "(", "{", "event", ":", "'load'", ",", "source", ...
Load a script in to the script cache.
[ "Load", "a", "script", "in", "to", "the", "script", "cache", "." ]
eab3df935372724a82a9ad9ba3bca7e6e165e9d1
https://github.com/redisjs/jsr-script/blob/eab3df935372724a82a9ad9ba3bca7e6e165e9d1/lib/manager.js#L60-L64
50,872
redisjs/jsr-script
lib/manager.js
eval
function eval(req, res, source, args) { this.spawn(); this.reply(req, res, this._limit); // need to coerce buffers for the moment args = args.map(function(a) { if(a instanceof Buffer) return a.toString(); return a; }) this.ps.send({event: 'eval', source: source, args: args}); }
javascript
function eval(req, res, source, args) { this.spawn(); this.reply(req, res, this._limit); // need to coerce buffers for the moment args = args.map(function(a) { if(a instanceof Buffer) return a.toString(); return a; }) this.ps.send({event: 'eval', source: source, args: args}); }
[ "function", "eval", "(", "req", ",", "res", ",", "source", ",", "args", ")", "{", "this", ".", "spawn", "(", ")", ";", "this", ".", "reply", "(", "req", ",", "res", ",", "this", ".", "_limit", ")", ";", "// need to coerce buffers for the moment", "args...
Evaluate a script.
[ "Evaluate", "a", "script", "." ]
eab3df935372724a82a9ad9ba3bca7e6e165e9d1
https://github.com/redisjs/jsr-script/blob/eab3df935372724a82a9ad9ba3bca7e6e165e9d1/lib/manager.js#L69-L78
50,873
redisjs/jsr-script
lib/manager.js
evalsha
function evalsha(req, res, sha, args) { this.spawn(); this.reply(req, res, this._limit); // need to coerce buffers for the moment args = args.map(function(a) { if(a instanceof Buffer) return a.toString(); return a; }) this.ps.send({event: 'evalsha', sha: sha, args: args}); }
javascript
function evalsha(req, res, sha, args) { this.spawn(); this.reply(req, res, this._limit); // need to coerce buffers for the moment args = args.map(function(a) { if(a instanceof Buffer) return a.toString(); return a; }) this.ps.send({event: 'evalsha', sha: sha, args: args}); }
[ "function", "evalsha", "(", "req", ",", "res", ",", "sha", ",", "args", ")", "{", "this", ".", "spawn", "(", ")", ";", "this", ".", "reply", "(", "req", ",", "res", ",", "this", ".", "_limit", ")", ";", "// need to coerce buffers for the moment", "args...
Evaluate a script by sha checksum.
[ "Evaluate", "a", "script", "by", "sha", "checksum", "." ]
eab3df935372724a82a9ad9ba3bca7e6e165e9d1
https://github.com/redisjs/jsr-script/blob/eab3df935372724a82a9ad9ba3bca7e6e165e9d1/lib/manager.js#L83-L92
50,874
redisjs/jsr-script
lib/manager.js
flush
function flush(req, res) { this.spawn(); this.reply(req, res); this.ps.send({event: 'flush'}); }
javascript
function flush(req, res) { this.spawn(); this.reply(req, res); this.ps.send({event: 'flush'}); }
[ "function", "flush", "(", "req", ",", "res", ")", "{", "this", ".", "spawn", "(", ")", ";", "this", ".", "reply", "(", "req", ",", "res", ")", ";", "this", ".", "ps", ".", "send", "(", "{", "event", ":", "'flush'", "}", ")", ";", "}" ]
Flush the script cache.
[ "Flush", "the", "script", "cache", "." ]
eab3df935372724a82a9ad9ba3bca7e6e165e9d1
https://github.com/redisjs/jsr-script/blob/eab3df935372724a82a9ad9ba3bca7e6e165e9d1/lib/manager.js#L111-L115
50,875
redisjs/jsr-script
lib/manager.js
kill
function kill(req, res) { if(!this._busy || !this.ps) return res.send(NotBusy); if(this._busy && this._written) return res.send(Unkillable); this.ps.removeAllListeners(); this._busy = false; this._written = false; function onClose() { res.send(null, Constants.OK); // re-spawn for next execution //this.spawn(); } this.ps.once('close', onClose.bind(this)) process.kill(this.ps.pid, 'SIGQUIT'); this.emit('kill'); }
javascript
function kill(req, res) { if(!this._busy || !this.ps) return res.send(NotBusy); if(this._busy && this._written) return res.send(Unkillable); this.ps.removeAllListeners(); this._busy = false; this._written = false; function onClose() { res.send(null, Constants.OK); // re-spawn for next execution //this.spawn(); } this.ps.once('close', onClose.bind(this)) process.kill(this.ps.pid, 'SIGQUIT'); this.emit('kill'); }
[ "function", "kill", "(", "req", ",", "res", ")", "{", "if", "(", "!", "this", ".", "_busy", "||", "!", "this", ".", "ps", ")", "return", "res", ".", "send", "(", "NotBusy", ")", ";", "if", "(", "this", ".", "_busy", "&&", "this", ".", "_written...
Kill a running script.
[ "Kill", "a", "running", "script", "." ]
eab3df935372724a82a9ad9ba3bca7e6e165e9d1
https://github.com/redisjs/jsr-script/blob/eab3df935372724a82a9ad9ba3bca7e6e165e9d1/lib/manager.js#L120-L134
50,876
fin-hypergrid/hyper-analytics
example/generateSampleData.js
function() { var firstName = Math.round((firstNames.length - 1) * randomFunc()); var lastName = Math.round((lastNames.length - 1) * randomFunc()); var pets = Math.round(10 * randomFunc()); var birthyear = 1900 + Math.round(randomFunc() * 114); var birthmonth = Math.round(randomFunc() * 11); var birthday = Math.round(randomFunc() * 29); var birthstate = Math.round(randomFunc() * 49); var residencestate = Math.round(randomFunc() * 49); var travel = randomFunc() * 1000; var income = randomFunc() * 100000; var employed = Math.round(randomFunc()); var person = { last_name: lastNames[lastName], //jshint ignore:line first_name: firstNames[firstName], //jshint ignore:line pets: pets, birthDate: birthyear + '-' + months[birthmonth] + '-' + days[birthday], birthState: states[birthstate], residenceState: states[residencestate], employed: employed === 1, income: income, travel: travel }; return person; }
javascript
function() { var firstName = Math.round((firstNames.length - 1) * randomFunc()); var lastName = Math.round((lastNames.length - 1) * randomFunc()); var pets = Math.round(10 * randomFunc()); var birthyear = 1900 + Math.round(randomFunc() * 114); var birthmonth = Math.round(randomFunc() * 11); var birthday = Math.round(randomFunc() * 29); var birthstate = Math.round(randomFunc() * 49); var residencestate = Math.round(randomFunc() * 49); var travel = randomFunc() * 1000; var income = randomFunc() * 100000; var employed = Math.round(randomFunc()); var person = { last_name: lastNames[lastName], //jshint ignore:line first_name: firstNames[firstName], //jshint ignore:line pets: pets, birthDate: birthyear + '-' + months[birthmonth] + '-' + days[birthday], birthState: states[birthstate], residenceState: states[residencestate], employed: employed === 1, income: income, travel: travel }; return person; }
[ "function", "(", ")", "{", "var", "firstName", "=", "Math", ".", "round", "(", "(", "firstNames", ".", "length", "-", "1", ")", "*", "randomFunc", "(", ")", ")", ";", "var", "lastName", "=", "Math", ".", "round", "(", "(", "lastNames", ".", "length...
var randomFunc = rnd;
[ "var", "randomFunc", "=", "rnd", ";" ]
70257bf0d0388d29177ce86192d0d08508b2a22e
https://github.com/fin-hypergrid/hyper-analytics/blob/70257bf0d0388d29177ce86192d0d08508b2a22e/example/generateSampleData.js#L13-L39
50,877
iopa-io/iopa-http
src/common/incomingParser.js
HTTPParser
function HTTPParser(channelContext, context) { _classCallCheck(this, HTTPParser); if (channelContext) { this._channelContext = channelContext; channelContext[SERVER.Capabilities][HTTP.CAPABILITY].incoming = []; channelContext[SERVER.Capabilities][HTTP.CAPABILITY].currentIncoming = null; } this.context = context || this._createNewRequest(); this.context[HTTP.SkipBody] = false; this.context[HTTP.ShouldKeepAlive] = true; this.context[IOPA.Trailers] = []; this._state = 'HTTP_LINE'; this._upgrade = false; this._line = ''; this._isChunked = false; this._connection = ''; this._headerSize = 0; this._contentLength = null; // this._currentChunk; // this._offset; // this._end; }
javascript
function HTTPParser(channelContext, context) { _classCallCheck(this, HTTPParser); if (channelContext) { this._channelContext = channelContext; channelContext[SERVER.Capabilities][HTTP.CAPABILITY].incoming = []; channelContext[SERVER.Capabilities][HTTP.CAPABILITY].currentIncoming = null; } this.context = context || this._createNewRequest(); this.context[HTTP.SkipBody] = false; this.context[HTTP.ShouldKeepAlive] = true; this.context[IOPA.Trailers] = []; this._state = 'HTTP_LINE'; this._upgrade = false; this._line = ''; this._isChunked = false; this._connection = ''; this._headerSize = 0; this._contentLength = null; // this._currentChunk; // this._offset; // this._end; }
[ "function", "HTTPParser", "(", "channelContext", ",", "context", ")", "{", "_classCallCheck", "(", "this", ",", "HTTPParser", ")", ";", "if", "(", "channelContext", ")", "{", "this", ".", "_channelContext", "=", "channelContext", ";", "channelContext", "[", "S...
IOPA HTTPParser converts inbound HTTP requests and inbound HTTP responses into IOPA Request and Response contexts @class HTTPParser @param channelContext (required) the transport context on which to parse the SERVER.RawStream message stream for one or more requests/responses; typically TCP or UDP @param context (optional) the IOPA Context on which to add the IOPA fields; if blank new one(s) are created; optimization for non-session-oriented protocols such as UDP @event IOPA.EVENTS.Request on channelContext[IOPA.Events] @event IOPA.EVENTS.Response on channelContext[IOPA.Events] @constructor @public
[ "IOPA", "HTTPParser", "converts", "inbound", "HTTP", "requests", "and", "inbound", "HTTP", "responses", "into", "IOPA", "Request", "and", "Response", "contexts" ]
7fc01ecdeddbb3fa55e23b9918e176f16f630844
https://github.com/iopa-io/iopa-http/blob/7fc01ecdeddbb3fa55e23b9918e176f16f630844/src/common/incomingParser.js#L66-L90
50,878
wrote/write
build/index.js
write
async function write(path, data) { if (!path) throw new Error('No path is given.') const er = erotic(true) const ws = createWriteStream(path) await new Promise((r, j) => { ws .on('error', (e) => { const err = er(e) j(err) }) .on('close', r) .end(data) }) }
javascript
async function write(path, data) { if (!path) throw new Error('No path is given.') const er = erotic(true) const ws = createWriteStream(path) await new Promise((r, j) => { ws .on('error', (e) => { const err = er(e) j(err) }) .on('close', r) .end(data) }) }
[ "async", "function", "write", "(", "path", ",", "data", ")", "{", "if", "(", "!", "path", ")", "throw", "new", "Error", "(", "'No path is given.'", ")", "const", "er", "=", "erotic", "(", "true", ")", "const", "ws", "=", "createWriteStream", "(", "path...
Write a file to the filesystem. @param {string} path The path of the file to write. @param {string|Buffer} data The data to write.
[ "Write", "a", "file", "to", "the", "filesystem", "." ]
b665396d791ac48ec57d3485fa2302926c3a9502
https://github.com/wrote/write/blob/b665396d791ac48ec57d3485fa2302926c3a9502/build/index.js#L9-L22
50,879
redisjs/jsr-server
lib/command/database/zset/zadd.js
validate
function validate(cmd, args, info) { AbstractCommand.prototype.validate.apply(this, arguments); var i , num; if((args.length - 1) % 2 !== 0) { throw new CommandArgLength(cmd); } for(i = 1;i < args.length;i += 2) { num = parseFloat('' + args[i]); if(isNaN(num)) { throw InvalidFloat; } args[i] = num; } }
javascript
function validate(cmd, args, info) { AbstractCommand.prototype.validate.apply(this, arguments); var i , num; if((args.length - 1) % 2 !== 0) { throw new CommandArgLength(cmd); } for(i = 1;i < args.length;i += 2) { num = parseFloat('' + args[i]); if(isNaN(num)) { throw InvalidFloat; } args[i] = num; } }
[ "function", "validate", "(", "cmd", ",", "args", ",", "info", ")", "{", "AbstractCommand", ".", "prototype", ".", "validate", ".", "apply", "(", "this", ",", "arguments", ")", ";", "var", "i", ",", "num", ";", "if", "(", "(", "args", ".", "length", ...
Validate the ZADD command.
[ "Validate", "the", "ZADD", "command", "." ]
49413052d3039524fbdd2ade0ef9bae26cb4d647
https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/database/zset/zadd.js#L20-L35
50,880
allex-servercore-libs/servicepack
user/creator.js
distinctElements
function distinctElements(a1,a2){ var ret = a1.slice(); a2.forEach(function(a2item){ if(ret.indexOf(a2item)<0){ ret.push(a2item); } }); return ret; }
javascript
function distinctElements(a1,a2){ var ret = a1.slice(); a2.forEach(function(a2item){ if(ret.indexOf(a2item)<0){ ret.push(a2item); } }); return ret; }
[ "function", "distinctElements", "(", "a1", ",", "a2", ")", "{", "var", "ret", "=", "a1", ".", "slice", "(", ")", ";", "a2", ".", "forEach", "(", "function", "(", "a2item", ")", "{", "if", "(", "ret", ".", "indexOf", "(", "a2item", ")", "<", "0", ...
User.inherit = UserEntity.inherit;
[ "User", ".", "inherit", "=", "UserEntity", ".", "inherit", ";" ]
1b0ce2fe7b9208ab6c8d60d862ceeaf970797d23
https://github.com/allex-servercore-libs/servicepack/blob/1b0ce2fe7b9208ab6c8d60d862ceeaf970797d23/user/creator.js#L27-L35
50,881
zorojs/zoro-kit-vue
dist/js/router/index.js
stringToRegexp
function stringToRegexp (path, keys, options) { var tokens = parse(path) var re = tokensToRegExp(tokens, options) // Attach keys back to the regexp. for (var i = 0; i < tokens.length; i++) { if (typeof tokens[i] !== 'string') { keys.push(tokens[i]) } } return attachKeys(re, keys) }
javascript
function stringToRegexp (path, keys, options) { var tokens = parse(path) var re = tokensToRegExp(tokens, options) // Attach keys back to the regexp. for (var i = 0; i < tokens.length; i++) { if (typeof tokens[i] !== 'string') { keys.push(tokens[i]) } } return attachKeys(re, keys) }
[ "function", "stringToRegexp", "(", "path", ",", "keys", ",", "options", ")", "{", "var", "tokens", "=", "parse", "(", "path", ")", "var", "re", "=", "tokensToRegExp", "(", "tokens", ",", "options", ")", "// Attach keys back to the regexp.", "for", "(", "var"...
Create a path regexp from string input. @param {string} path @param {!Array} keys @param {!Object} options @return {!RegExp}
[ "Create", "a", "path", "regexp", "from", "string", "input", "." ]
fe65e25bbdcc7f9c47961112c8709b105528d595
https://github.com/zorojs/zoro-kit-vue/blob/fe65e25bbdcc7f9c47961112c8709b105528d595/dist/js/router/index.js#L943-L955
50,882
zorojs/zoro-kit-vue
dist/js/router/index.js
looseEqual
function looseEqual (a, b) { /* eslint-disable eqeqeq */ return a == b || ( isObject(a) && isObject(b) ? JSON.stringify(a) === JSON.stringify(b) : false ) /* eslint-enable eqeqeq */ }
javascript
function looseEqual (a, b) { /* eslint-disable eqeqeq */ return a == b || ( isObject(a) && isObject(b) ? JSON.stringify(a) === JSON.stringify(b) : false ) /* eslint-enable eqeqeq */ }
[ "function", "looseEqual", "(", "a", ",", "b", ")", "{", "/* eslint-disable eqeqeq */", "return", "a", "==", "b", "||", "(", "isObject", "(", "a", ")", "&&", "isObject", "(", "b", ")", "?", "JSON", ".", "stringify", "(", "a", ")", "===", "JSON", ".", ...
Check if two values are loosely equal - that is, if they are plain objects, do they have the same shape?
[ "Check", "if", "two", "values", "are", "loosely", "equal", "-", "that", "is", "if", "they", "are", "plain", "objects", "do", "they", "have", "the", "same", "shape?" ]
fe65e25bbdcc7f9c47961112c8709b105528d595
https://github.com/zorojs/zoro-kit-vue/blob/fe65e25bbdcc7f9c47961112c8709b105528d595/dist/js/router/index.js#L2227-L2235
50,883
zorojs/zoro-kit-vue
dist/js/router/index.js
mergeData
function mergeData (to, from) { var key, toVal, fromVal; for (key in from) { toVal = to[key]; fromVal = from[key]; if (!hasOwn(to, key)) { set(to, key, fromVal); } else if (isObject(toVal) && isObject(fromVal)) { mergeData(toVal, fromVal); } } return to }
javascript
function mergeData (to, from) { var key, toVal, fromVal; for (key in from) { toVal = to[key]; fromVal = from[key]; if (!hasOwn(to, key)) { set(to, key, fromVal); } else if (isObject(toVal) && isObject(fromVal)) { mergeData(toVal, fromVal); } } return to }
[ "function", "mergeData", "(", "to", ",", "from", ")", "{", "var", "key", ",", "toVal", ",", "fromVal", ";", "for", "(", "key", "in", "from", ")", "{", "toVal", "=", "to", "[", "key", "]", ";", "fromVal", "=", "from", "[", "key", "]", ";", "if",...
Helper that recursively merges two data objects together.
[ "Helper", "that", "recursively", "merges", "two", "data", "objects", "together", "." ]
fe65e25bbdcc7f9c47961112c8709b105528d595
https://github.com/zorojs/zoro-kit-vue/blob/fe65e25bbdcc7f9c47961112c8709b105528d595/dist/js/router/index.js#L4676-L4688
50,884
zorojs/zoro-kit-vue
dist/js/router/index.js
normalizeComponents
function normalizeComponents (options) { if (options.components) { var components = options.components; var def; for (var key in components) { var lower = key.toLowerCase(); if (isBuiltInTag(lower) || config.isReservedTag(lower)) { "development" !== 'production' && warn( 'Do not use built-in or reserved HTML elements as component ' + 'id: ' + key ); continue } def = components[key]; if (isPlainObject(def)) { components[key] = Vue$3.extend(def); } } } }
javascript
function normalizeComponents (options) { if (options.components) { var components = options.components; var def; for (var key in components) { var lower = key.toLowerCase(); if (isBuiltInTag(lower) || config.isReservedTag(lower)) { "development" !== 'production' && warn( 'Do not use built-in or reserved HTML elements as component ' + 'id: ' + key ); continue } def = components[key]; if (isPlainObject(def)) { components[key] = Vue$3.extend(def); } } } }
[ "function", "normalizeComponents", "(", "options", ")", "{", "if", "(", "options", ".", "components", ")", "{", "var", "components", "=", "options", ".", "components", ";", "var", "def", ";", "for", "(", "var", "key", "in", "components", ")", "{", "var",...
Make sure component options get converted to actual constructors.
[ "Make", "sure", "component", "options", "get", "converted", "to", "actual", "constructors", "." ]
fe65e25bbdcc7f9c47961112c8709b105528d595
https://github.com/zorojs/zoro-kit-vue/blob/fe65e25bbdcc7f9c47961112c8709b105528d595/dist/js/router/index.js#L4834-L4853
50,885
zorojs/zoro-kit-vue
dist/js/router/index.js
updateDOMListeners
function updateDOMListeners (oldVnode, vnode) { if (!oldVnode.data.on && !vnode.data.on) { return } var on = vnode.data.on || {}; var oldOn = oldVnode.data.on || {}; var add = vnode.elm._v_add || (vnode.elm._v_add = function (event, handler, capture) { vnode.elm.addEventListener(event, handler, capture); }); var remove = vnode.elm._v_remove || (vnode.elm._v_remove = function (event, handler) { vnode.elm.removeEventListener(event, handler); }); updateListeners(on, oldOn, add, remove, vnode.context); }
javascript
function updateDOMListeners (oldVnode, vnode) { if (!oldVnode.data.on && !vnode.data.on) { return } var on = vnode.data.on || {}; var oldOn = oldVnode.data.on || {}; var add = vnode.elm._v_add || (vnode.elm._v_add = function (event, handler, capture) { vnode.elm.addEventListener(event, handler, capture); }); var remove = vnode.elm._v_remove || (vnode.elm._v_remove = function (event, handler) { vnode.elm.removeEventListener(event, handler); }); updateListeners(on, oldOn, add, remove, vnode.context); }
[ "function", "updateDOMListeners", "(", "oldVnode", ",", "vnode", ")", "{", "if", "(", "!", "oldVnode", ".", "data", ".", "on", "&&", "!", "vnode", ".", "data", ".", "on", ")", "{", "return", "}", "var", "on", "=", "vnode", ".", "data", ".", "on", ...
skip type checking this file because we need to attach private properties to elements
[ "skip", "type", "checking", "this", "file", "because", "we", "need", "to", "attach", "private", "properties", "to", "elements" ]
fe65e25bbdcc7f9c47961112c8709b105528d595
https://github.com/zorojs/zoro-kit-vue/blob/fe65e25bbdcc7f9c47961112c8709b105528d595/dist/js/router/index.js#L6488-L6501
50,886
zorojs/zoro-kit-vue
dist/js/router/index.js
removeClass
function removeClass (el, cls) { /* istanbul ignore else */ if (el.classList) { if (cls.indexOf(' ') > -1) { cls.split(/\s+/).forEach(function (c) { return el.classList.remove(c); }); } else { el.classList.remove(cls); } } else { var cur = ' ' + el.getAttribute('class') + ' '; var tar = ' ' + cls + ' '; while (cur.indexOf(tar) >= 0) { cur = cur.replace(tar, ' '); } el.setAttribute('class', cur.trim()); } }
javascript
function removeClass (el, cls) { /* istanbul ignore else */ if (el.classList) { if (cls.indexOf(' ') > -1) { cls.split(/\s+/).forEach(function (c) { return el.classList.remove(c); }); } else { el.classList.remove(cls); } } else { var cur = ' ' + el.getAttribute('class') + ' '; var tar = ' ' + cls + ' '; while (cur.indexOf(tar) >= 0) { cur = cur.replace(tar, ' '); } el.setAttribute('class', cur.trim()); } }
[ "function", "removeClass", "(", "el", ",", "cls", ")", "{", "/* istanbul ignore else */", "if", "(", "el", ".", "classList", ")", "{", "if", "(", "cls", ".", "indexOf", "(", "' '", ")", ">", "-", "1", ")", "{", "cls", ".", "split", "(", "/", "\\s+"...
Remove class with compatibility for SVG since classList is not supported on SVG elements in IE
[ "Remove", "class", "with", "compatibility", "for", "SVG", "since", "classList", "is", "not", "supported", "on", "SVG", "elements", "in", "IE" ]
fe65e25bbdcc7f9c47961112c8709b105528d595
https://github.com/zorojs/zoro-kit-vue/blob/fe65e25bbdcc7f9c47961112c8709b105528d595/dist/js/router/index.js#L6649-L6665
50,887
vesln/printr
lib/printr.js
Printr
function Printr(options) { options = options || {}; options.out = options.out || process.stdout; options.err = options.err || process.stderr; options.prefix = options.prefix || ''; this.options = options; }
javascript
function Printr(options) { options = options || {}; options.out = options.out || process.stdout; options.err = options.err || process.stderr; options.prefix = options.prefix || ''; this.options = options; }
[ "function", "Printr", "(", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "options", ".", "out", "=", "options", ".", "out", "||", "process", ".", "stdout", ";", "options", ".", "err", "=", "options", ".", "err", "||", "process"...
Printr - tiny print util. Options: - `out` out stream, default: process.stdout - `err` err stream, default: process.stderr - `prefix` prefix to append for `Message#print`, default: '' @param {Object} options @constructor
[ "Printr", "-", "tiny", "print", "util", "." ]
09f7e61b313bbb5991071d54f7a5fd38a9c4f81f
https://github.com/vesln/printr/blob/09f7e61b313bbb5991071d54f7a5fd38a9c4f81f/lib/printr.js#L19-L25
50,888
chrisenytc/livi18n
lib/client/livi18n.js
function (key, obj) { //Split key var p = key.split('.'); //Loop and save object state for (var i = 0, len = p.length; i < len - 1; i++) { obj = obj[p[i]]; } //Return object value return obj[p[len - 1]]; }
javascript
function (key, obj) { //Split key var p = key.split('.'); //Loop and save object state for (var i = 0, len = p.length; i < len - 1; i++) { obj = obj[p[i]]; } //Return object value return obj[p[len - 1]]; }
[ "function", "(", "key", ",", "obj", ")", "{", "//Split key", "var", "p", "=", "key", ".", "split", "(", "'.'", ")", ";", "//Loop and save object state", "for", "(", "var", "i", "=", "0", ",", "len", "=", "p", ".", "length", ";", "i", "<", "len", ...
Get Data Property
[ "Get", "Data", "Property" ]
cff846d533f2db9162013dd572d18ffd8fa38340
https://github.com/chrisenytc/livi18n/blob/cff846d533f2db9162013dd572d18ffd8fa38340/lib/client/livi18n.js#L217-L226
50,889
chrisenytc/livi18n
lib/client/livi18n.js
function () { //Init Var var length = 0; //Loop filenames $.each(config.data, function () { length++; }); //If value of length is equal to filenames length, // return true, if not, return false if (length === config.filenames.length) { return true; } else { return false; } }
javascript
function () { //Init Var var length = 0; //Loop filenames $.each(config.data, function () { length++; }); //If value of length is equal to filenames length, // return true, if not, return false if (length === config.filenames.length) { return true; } else { return false; } }
[ "function", "(", ")", "{", "//Init Var", "var", "length", "=", "0", ";", "//Loop filenames", "$", ".", "each", "(", "config", ".", "data", ",", "function", "(", ")", "{", "length", "++", ";", "}", ")", ";", "//If value of length is equal to filenames length,...
Check if dataStorage is loaded
[ "Check", "if", "dataStorage", "is", "loaded" ]
cff846d533f2db9162013dd572d18ffd8fa38340
https://github.com/chrisenytc/livi18n/blob/cff846d533f2db9162013dd572d18ffd8fa38340/lib/client/livi18n.js#L287-L301
50,890
chrisenytc/livi18n
lib/client/livi18n.js
function (key) { var string = key.split('.'); string.shift(0); var value = string.join('.'); return value; }
javascript
function (key) { var string = key.split('.'); string.shift(0); var value = string.join('.'); return value; }
[ "function", "(", "key", ")", "{", "var", "string", "=", "key", ".", "split", "(", "'.'", ")", ";", "string", ".", "shift", "(", "0", ")", ";", "var", "value", "=", "string", ".", "join", "(", "'.'", ")", ";", "return", "value", ";", "}" ]
Get Keyname in Key
[ "Get", "Keyname", "in", "Key" ]
cff846d533f2db9162013dd572d18ffd8fa38340
https://github.com/chrisenytc/livi18n/blob/cff846d533f2db9162013dd572d18ffd8fa38340/lib/client/livi18n.js#L308-L313
50,891
the-terribles/evergreen
lib/errors.js
DependenciesNotResolvedError
function DependenciesNotResolvedError(dependencies){ superError.call( this, 'DependenciesNotResolvedError', util.format('Dependencies cannot be resolved: %s', dependencies.join(',')) ); this.dependencies = dependencies; }
javascript
function DependenciesNotResolvedError(dependencies){ superError.call( this, 'DependenciesNotResolvedError', util.format('Dependencies cannot be resolved: %s', dependencies.join(',')) ); this.dependencies = dependencies; }
[ "function", "DependenciesNotResolvedError", "(", "dependencies", ")", "{", "superError", ".", "call", "(", "this", ",", "'DependenciesNotResolvedError'", ",", "util", ".", "format", "(", "'Dependencies cannot be resolved: %s'", ",", "dependencies", ".", "join", "(", "...
Dependencies in the Graph could not be resolved. @param dependencies {Array} Dependencies that could not be resolved. @constructor
[ "Dependencies", "in", "the", "Graph", "could", "not", "be", "resolved", "." ]
c1adaea1ce825727c5c5ed75d858e2f0d22657e2
https://github.com/the-terribles/evergreen/blob/c1adaea1ce825727c5c5ed75d858e2f0d22657e2/lib/errors.js#L22-L30
50,892
the-terribles/evergreen
lib/errors.js
PathNotFoundError
function PathNotFoundError(path, sympath){ superError.call( this, 'PathNotFoundError', util.format('Path was not found in the tree: %s', sympath) ); this.arrayPath = path; this.sympath = sympath; }
javascript
function PathNotFoundError(path, sympath){ superError.call( this, 'PathNotFoundError', util.format('Path was not found in the tree: %s', sympath) ); this.arrayPath = path; this.sympath = sympath; }
[ "function", "PathNotFoundError", "(", "path", ",", "sympath", ")", "{", "superError", ".", "call", "(", "this", ",", "'PathNotFoundError'", ",", "util", ".", "format", "(", "'Path was not found in the tree: %s'", ",", "sympath", ")", ")", ";", "this", ".", "ar...
The Path does not exist in the tree. @param path {Array} Path that was not found @param sympath {String} Symbolic path representation. @constructor
[ "The", "Path", "does", "not", "exist", "in", "the", "tree", "." ]
c1adaea1ce825727c5c5ed75d858e2f0d22657e2
https://github.com/the-terribles/evergreen/blob/c1adaea1ce825727c5c5ed75d858e2f0d22657e2/lib/errors.js#L61-L70
50,893
the-terribles/evergreen
lib/errors.js
CannotBuildDependencyGraphError
function CannotBuildDependencyGraphError(nestedError){ this.name = 'CannotBuildDependencyGraphError'; this.message = nestedError.message; this.stack = nestedError.stack; this.nestedError = nestedError; }
javascript
function CannotBuildDependencyGraphError(nestedError){ this.name = 'CannotBuildDependencyGraphError'; this.message = nestedError.message; this.stack = nestedError.stack; this.nestedError = nestedError; }
[ "function", "CannotBuildDependencyGraphError", "(", "nestedError", ")", "{", "this", ".", "name", "=", "'CannotBuildDependencyGraphError'", ";", "this", ".", "message", "=", "nestedError", ".", "message", ";", "this", ".", "stack", "=", "nestedError", ".", "stack"...
Wraps errors returned from Topo representing a failure to build the dependency graph. @param nestedError {Error} error encountered topo sorting the dependency graph. @constructor
[ "Wraps", "errors", "returned", "from", "Topo", "representing", "a", "failure", "to", "build", "the", "dependency", "graph", "." ]
c1adaea1ce825727c5c5ed75d858e2f0d22657e2
https://github.com/the-terribles/evergreen/blob/c1adaea1ce825727c5c5ed75d858e2f0d22657e2/lib/errors.js#L138-L144
50,894
the-terribles/evergreen
lib/errors.js
JavaScriptFileLoadError
function JavaScriptFileLoadError(file, nestedError){ nestedError = nestedError || null; var message = (nestedError)? util.format('"%s" failed to load as JavaScript; VM error: %s', file, nestedError.toString()) : util.format('"%s" failed to load as JavaScript.', file); superError.call(this, 'JavaScriptFileLoadError', message); this.fsPath = file; this.nestedError = nestedError; }
javascript
function JavaScriptFileLoadError(file, nestedError){ nestedError = nestedError || null; var message = (nestedError)? util.format('"%s" failed to load as JavaScript; VM error: %s', file, nestedError.toString()) : util.format('"%s" failed to load as JavaScript.', file); superError.call(this, 'JavaScriptFileLoadError', message); this.fsPath = file; this.nestedError = nestedError; }
[ "function", "JavaScriptFileLoadError", "(", "file", ",", "nestedError", ")", "{", "nestedError", "=", "nestedError", "||", "null", ";", "var", "message", "=", "(", "nestedError", ")", "?", "util", ".", "format", "(", "'\"%s\" failed to load as JavaScript; VM error: ...
Failed to load the JavaScript file. @param file {String} path to file @param nestedError {Error} nested error from VM. @constructor
[ "Failed", "to", "load", "the", "JavaScript", "file", "." ]
c1adaea1ce825727c5c5ed75d858e2f0d22657e2
https://github.com/the-terribles/evergreen/blob/c1adaea1ce825727c5c5ed75d858e2f0d22657e2/lib/errors.js#L225-L236
50,895
the-terribles/evergreen
lib/errors.js
HttpRequestError
function HttpRequestError(nestedError, status, body){ nestedError = nestedError || null; status = status || -1; body = body || null; superError.call( this, 'HttpRequestError', util.format('An error [%s] occurred requesting content from an HTTP source: %s', status, nestedError || body) ); this.status = status; this.body = body; this.nestedError = nestedError; }
javascript
function HttpRequestError(nestedError, status, body){ nestedError = nestedError || null; status = status || -1; body = body || null; superError.call( this, 'HttpRequestError', util.format('An error [%s] occurred requesting content from an HTTP source: %s', status, nestedError || body) ); this.status = status; this.body = body; this.nestedError = nestedError; }
[ "function", "HttpRequestError", "(", "nestedError", ",", "status", ",", "body", ")", "{", "nestedError", "=", "nestedError", "||", "null", ";", "status", "=", "status", "||", "-", "1", ";", "body", "=", "body", "||", "null", ";", "superError", ".", "call...
Wraps an HTTP Request Error coming from an HTTP client library. @param status {int} status code @param body {String|Object} body of the response @param nestedError {Error} error thrown by the client library. @constructor
[ "Wraps", "an", "HTTP", "Request", "Error", "coming", "from", "an", "HTTP", "client", "library", "." ]
c1adaea1ce825727c5c5ed75d858e2f0d22657e2
https://github.com/the-terribles/evergreen/blob/c1adaea1ce825727c5c5ed75d858e2f0d22657e2/lib/errors.js#L249-L264
50,896
the-terribles/evergreen
lib/errors.js
CannotParseTreeError
function CannotParseTreeError(errors){ superError.call( this, 'CannotParseTreeError', util.format('Could not parse the tree for metadata; errors: %s', JSON.stringify(errors)) ); this.errors = errors; }
javascript
function CannotParseTreeError(errors){ superError.call( this, 'CannotParseTreeError', util.format('Could not parse the tree for metadata; errors: %s', JSON.stringify(errors)) ); this.errors = errors; }
[ "function", "CannotParseTreeError", "(", "errors", ")", "{", "superError", ".", "call", "(", "this", ",", "'CannotParseTreeError'", ",", "util", ".", "format", "(", "'Could not parse the tree for metadata; errors: %s'", ",", "JSON", ".", "stringify", "(", "errors", ...
Thrown if errors occurred in parsing the tree. @param errors {Array} @constructor
[ "Thrown", "if", "errors", "occurred", "in", "parsing", "the", "tree", "." ]
c1adaea1ce825727c5c5ed75d858e2f0d22657e2
https://github.com/the-terribles/evergreen/blob/c1adaea1ce825727c5c5ed75d858e2f0d22657e2/lib/errors.js#L275-L284
50,897
integreat-io/great-uri-template
lib/filters/prepend.js
prepend
function prepend (value, string) { if ( value === null || value === undefined || value === '' || string === null || string === undefined ) { return value } return string + value }
javascript
function prepend (value, string) { if ( value === null || value === undefined || value === '' || string === null || string === undefined ) { return value } return string + value }
[ "function", "prepend", "(", "value", ",", "string", ")", "{", "if", "(", "value", "===", "null", "||", "value", "===", "undefined", "||", "value", "===", "''", "||", "string", "===", "null", "||", "string", "===", "undefined", ")", "{", "return", "valu...
Prepend the given string to the value, unless the value is empty. @param {string} value - The value to prepend to @returns {string} The prepended result
[ "Prepend", "the", "given", "string", "to", "the", "value", "unless", "the", "value", "is", "empty", "." ]
0e896ead0567737cf31a4a8b76a26cfa6ce60759
https://github.com/integreat-io/great-uri-template/blob/0e896ead0567737cf31a4a8b76a26cfa6ce60759/lib/filters/prepend.js#L6-L14
50,898
jonschlinkert/enable-travis
index.js
enable
function enable(options, cb) { options = options || {}; var travis = new Travis({ version: '2.0.0', // user-agent needs to start with "Travis" // https://github.com/travis-ci/travis-ci/issues/5649 headers: {'user-agent': 'Travis: jonschlinkert/enable-travis'} }); travis.auth.github.post({ github_token: options.GITHUB_OAUTH_TOKEN }, function(err, res) { if (err) return cb(err); travis.authenticate({ access_token: res.access_token }, function(err) { if (err) return cb(err); var segs = options.repo.split('/'); travis.repos(segs[0], segs[1]).get(function(err, res) { if (err) return cb(err); travis.hooks(res.repo && res.repo.id).put({ hook: {active: true} }, function(err, content) { if (err) return cb(err); cb(null, content); }); }); }); }); }
javascript
function enable(options, cb) { options = options || {}; var travis = new Travis({ version: '2.0.0', // user-agent needs to start with "Travis" // https://github.com/travis-ci/travis-ci/issues/5649 headers: {'user-agent': 'Travis: jonschlinkert/enable-travis'} }); travis.auth.github.post({ github_token: options.GITHUB_OAUTH_TOKEN }, function(err, res) { if (err) return cb(err); travis.authenticate({ access_token: res.access_token }, function(err) { if (err) return cb(err); var segs = options.repo.split('/'); travis.repos(segs[0], segs[1]).get(function(err, res) { if (err) return cb(err); travis.hooks(res.repo && res.repo.id).put({ hook: {active: true} }, function(err, content) { if (err) return cb(err); cb(null, content); }); }); }); }); }
[ "function", "enable", "(", "options", ",", "cb", ")", "{", "options", "=", "options", "||", "{", "}", ";", "var", "travis", "=", "new", "Travis", "(", "{", "version", ":", "'2.0.0'", ",", "// user-agent needs to start with \"Travis\"", "// https://github.com/tra...
Enable a travis project
[ "Enable", "a", "travis", "project" ]
9f35e788e294dfc6879781ef8e62f74ea355500d
https://github.com/jonschlinkert/enable-travis/blob/9f35e788e294dfc6879781ef8e62f74ea355500d/index.js#L22-L56
50,899
Nazariglez/perenquen
lib/pixi/src/filters/color/ColorStepFilter.js
ColorStepFilter
function ColorStepFilter() { core.AbstractFilter.call(this, // vertex shader null, // fragment shader fs.readFileSync(__dirname + '/colorStep.frag', 'utf8'), // custom uniforms { step: { type: '1f', value: 5 } } ); }
javascript
function ColorStepFilter() { core.AbstractFilter.call(this, // vertex shader null, // fragment shader fs.readFileSync(__dirname + '/colorStep.frag', 'utf8'), // custom uniforms { step: { type: '1f', value: 5 } } ); }
[ "function", "ColorStepFilter", "(", ")", "{", "core", ".", "AbstractFilter", ".", "call", "(", "this", ",", "// vertex shader", "null", ",", "// fragment shader", "fs", ".", "readFileSync", "(", "__dirname", "+", "'/colorStep.frag'", ",", "'utf8'", ")", ",", "...
This lowers the color depth of your image by the given amount, producing an image with a smaller palette. @class @extends AbstractFilter @memberof PIXI.filters
[ "This", "lowers", "the", "color", "depth", "of", "your", "image", "by", "the", "given", "amount", "producing", "an", "image", "with", "a", "smaller", "palette", "." ]
e023964d05afeefebdcac4e2044819fdfa3899ae
https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/filters/color/ColorStepFilter.js#L12-L24